When folding memory operands in machine instructions be careful to

leave register operands with the same use/def flags as the original
instruction.

llvm-svn: 11709
This commit is contained in:
Alkis Evlogimenos 2004-02-22 06:54:26 +00:00
parent d25dfe43b9
commit de51c65299
2 changed files with 11 additions and 2 deletions

View File

@ -197,6 +197,13 @@ public:
///
MachineOperandType getType() const { return opType; }
/// getUseType - Returns the MachineOperandUseType of this operand.
///
MOTy::UseType getUseType() const {
return isUse() ^ isDef() ? MOTy::UseAndDef :
(isUse() ? MOTy::Use : MOTy::Def);
}
/// isPCRelative - This returns the value of the PCRELATIVE flag, which
/// indicates whether this operand should be emitted as a PC relative value
/// instead of a global address. This is used for operands of the forms:

View File

@ -112,13 +112,15 @@ static MachineInstr *MakeMIInst(unsigned Opcode, unsigned FrameIndex,
static MachineInstr *MakeRMInst(unsigned Opcode, unsigned FrameIndex,
MachineInstr *MI) {
return addFrameReference(BuildMI(Opcode, 5, MI->getOperand(0).getReg()),
const MachineOperand& op = MI->getOperand(0);
return addFrameReference(BuildMI(Opcode, 5, op.getReg(), op.getUseType()),
FrameIndex);
}
static MachineInstr *MakeRMIInst(unsigned Opcode, unsigned FrameIndex,
MachineInstr *MI) {
return addFrameReference(BuildMI(Opcode, 5, MI->getOperand(0).getReg()),
const MachineOperand& op = MI->getOperand(0);
return addFrameReference(BuildMI(Opcode, 5, op.getReg(), op.getUseType()),
FrameIndex).addZImm(MI->getOperand(2).getImmedValue());
}