diff options
author | Tanya Lattner <tonic@nondot.org> | 2007-05-18 05:59:52 +0000 |
---|---|---|
committer | Tanya Lattner <tonic@nondot.org> | 2007-05-18 05:59:52 +0000 |
commit | ea07ab45ca3597da0cb1e9305ed15ccf547fe90e (patch) | |
tree | 90fe28beb32627114eac6cef1359456d62f91934 | |
parent | defd57348ecfaf78f3f2d87ee05c6ecdf54c6949 (diff) |
Merging from mainline.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_20@37212 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/PowerPC/PPCISelLowering.cpp | 26 | ||||
-rw-r--r-- | lib/Target/X86/X86ISelLowering.cpp | 7 |
2 files changed, 21 insertions, 12 deletions
diff --git a/lib/Target/PowerPC/PPCISelLowering.cpp b/lib/Target/PowerPC/PPCISelLowering.cpp index 13ab52abd4..818fcd5f59 100644 --- a/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/lib/Target/PowerPC/PPCISelLowering.cpp @@ -3326,31 +3326,39 @@ isOperandValidForConstraint(SDOperand Op, char Letter, SelectionDAG &DAG) { case 'N': case 'O': case 'P': { - if (!isa<ConstantSDNode>(Op)) return SDOperand(0,0);// Must be an immediate. - unsigned Value = cast<ConstantSDNode>(Op)->getValue(); + ConstantSDNode *CST = dyn_cast<ConstantSDNode>(Op); + if (!CST) return SDOperand(0, 0); // Must be an immediate to match. + unsigned Value = CST->getValue(); switch (Letter) { default: assert(0 && "Unknown constraint letter!"); case 'I': // "I" is a signed 16-bit constant. - if ((short)Value == (int)Value) return Op; + if ((short)Value == (int)Value) + return DAG.getTargetConstant(Value, Op.getValueType()); break; case 'J': // "J" is a constant with only the high-order 16 bits nonzero. case 'L': // "L" is a signed 16-bit constant shifted left 16 bits. - if ((short)Value == 0) return Op; + if ((short)Value == 0) + return DAG.getTargetConstant(Value, Op.getValueType()); break; case 'K': // "K" is a constant with only the low-order 16 bits nonzero. - if ((Value >> 16) == 0) return Op; + if ((Value >> 16) == 0) + return DAG.getTargetConstant(Value, Op.getValueType()); break; case 'M': // "M" is a constant that is greater than 31. - if (Value > 31) return Op; + if (Value > 31) + return DAG.getTargetConstant(Value, Op.getValueType()); break; case 'N': // "N" is a positive constant that is an exact power of two. - if ((int)Value > 0 && isPowerOf2_32(Value)) return Op; + if ((int)Value > 0 && isPowerOf2_32(Value)) + return DAG.getTargetConstant(Value, Op.getValueType()); break; case 'O': // "O" is the constant zero. - if (Value == 0) return Op; + if (Value == 0) + return DAG.getTargetConstant(Value, Op.getValueType()); break; case 'P': // "P" is a constant whose negation is a signed 16-bit constant. - if ((short)-Value == (int)-Value) return Op; + if ((short)-Value == (int)-Value) + return DAG.getTargetConstant(Value, Op.getValueType()); break; } break; diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index da95925848..6de6b21c78 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -4725,18 +4725,19 @@ isOperandValidForConstraint(SDOperand Op, char Constraint, SelectionDAG &DAG) { case 'I': if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(Op)) { if (C->getValue() <= 31) - return Op; + return DAG.getTargetConstant(C->getValue(), Op.getValueType()); } return SDOperand(0,0); case 'N': if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(Op)) { if (C->getValue() <= 255) - return Op; + return DAG.getTargetConstant(C->getValue(), Op.getValueType()); } return SDOperand(0,0); case 'i': { // Literal immediates are always ok. - if (isa<ConstantSDNode>(Op)) return Op; + if (ConstantSDNode *CST = dyn_cast<ConstantSDNode>(Op)) + return DAG.getTargetConstant(CST->getValue(), Op.getValueType()); // If we are in non-pic codegen mode, we allow the address of a global (with // an optional displacement) to be used with 'i'. |