summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-02-17 06:00:35 +0000
committerChris Lattner <sabre@nondot.org>2007-02-17 06:00:35 +0000
commita9f917af594ccefc4140d4236204728a6527c4dc (patch)
tree85225a29ea10d818bf9f9dc5ccbafa5cfd78508e /llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
parentbc9111e290be1c7df82e06b01ad77fb5c7d3977f (diff)
downloadbcm5719-llvm-a9f917af594ccefc4140d4236204728a6527c4dc.tar.gz
bcm5719-llvm-a9f917af594ccefc4140d4236204728a6527c4dc.zip
Implement i/n/s constraints correctly. This fixes
test/CodeGen/PowerPC/2007-02-16-InlineAsmNConstraint.ll llvm-svn: 34368
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index d389a5a97c0..fd7500f71ef 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -1856,12 +1856,26 @@ SDOperand TargetLowering::isOperandValidForConstraint(SDOperand Op,
char ConstraintLetter,
SelectionDAG &DAG) {
switch (ConstraintLetter) {
- default: return SDOperand(0,0);
+ default: break;
case 'i': // Simple Integer or Relocatable Constant
case 'n': // Simple Integer
case 's': // Relocatable Constant
- return Op; // FIXME: not right.
+ // These are okay if the operand is either a global variable address or a
+ // simple immediate value. If we have one of these, map to the TargetXXX
+ // version so that the value itself doesn't get selected.
+ if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(Op)) {
+ // Simple constants are not allowed for 's'.
+ if (ConstraintLetter != 's')
+ return DAG.getTargetConstant(C->getValue(), Op.getValueType());
+ }
+ if (GlobalAddressSDNode *GA = dyn_cast<GlobalAddressSDNode>(Op)) {
+ if (ConstraintLetter != 'n')
+ return DAG.getTargetGlobalAddress(GA->getGlobal(), Op.getValueType(),
+ GA->getOffset());
+ }
+ break;
}
+ return SDOperand(0,0);
}
std::vector<unsigned> TargetLowering::
OpenPOWER on IntegriCloud