mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-09-27 15:57:13 +00:00
Allow i/s to match (gv+c). This fixes CodeGen/PowerPC/2007-05-03-InlineAsm-S-Constraint.ll
and PR1382 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36672 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b0d151540d
commit
75c7d2bd55
@ -1915,22 +1915,43 @@ SDOperand TargetLowering::isOperandValidForConstraint(SDOperand Op,
|
|||||||
case 'i': // Simple Integer or Relocatable Constant
|
case 'i': // Simple Integer or Relocatable Constant
|
||||||
case 'n': // Simple Integer
|
case 'n': // Simple Integer
|
||||||
case 's': // Relocatable Constant
|
case 's': // Relocatable Constant
|
||||||
case 'X': // Allows any operand.
|
case 'X': { // Allows any operand.
|
||||||
// These are okay if the operand is either a global variable address or a
|
// These operands are interested in values of the form (GV+C), where C may
|
||||||
// simple immediate value. If we have one of these, map to the TargetXXX
|
// be folded in as an offset of GV, or it may be explicitly added. Also, it
|
||||||
// version so that the value itself doesn't get selected.
|
// is possible and fine if either GV or C are missing.
|
||||||
if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(Op)) {
|
ConstantSDNode *C = dyn_cast<ConstantSDNode>(Op);
|
||||||
|
GlobalAddressSDNode *GA = dyn_cast<GlobalAddressSDNode>(Op);
|
||||||
|
|
||||||
|
// If we have "(add GV, C)", pull out GV/C
|
||||||
|
if (Op.getOpcode() == ISD::ADD) {
|
||||||
|
C = dyn_cast<ConstantSDNode>(Op.getOperand(1));
|
||||||
|
GA = dyn_cast<GlobalAddressSDNode>(Op.getOperand(0));
|
||||||
|
if (C == 0 || GA == 0) {
|
||||||
|
C = dyn_cast<ConstantSDNode>(Op.getOperand(0));
|
||||||
|
GA = dyn_cast<GlobalAddressSDNode>(Op.getOperand(1));
|
||||||
|
}
|
||||||
|
if (C == 0 || GA == 0)
|
||||||
|
C = 0, GA = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we find a valid operand, map to the TargetXXX version so that the
|
||||||
|
// value itself doesn't get selected.
|
||||||
|
if (GA) { // Either &GV or &GV+C
|
||||||
|
if (ConstraintLetter != 'n') {
|
||||||
|
int64_t Offs = GA->getOffset();
|
||||||
|
if (C) Offs += C->getValue();
|
||||||
|
return DAG.getTargetGlobalAddress(GA->getGlobal(), Op.getValueType(),
|
||||||
|
Offs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (C) { // just C, no GV.
|
||||||
// Simple constants are not allowed for 's'.
|
// Simple constants are not allowed for 's'.
|
||||||
if (ConstraintLetter != 's')
|
if (ConstraintLetter != 's')
|
||||||
return DAG.getTargetConstant(C->getValue(), Op.getValueType());
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return SDOperand(0,0);
|
return SDOperand(0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user