mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Add MachineInstr::tieOperands, remove setIsTied().
Manage tied operands entirely internally to MachineInstr. This makes it possible to change the representation of tied operands, as I will do shortly. The constraint that tied uses and defs must be in the same order was too restrictive. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163021 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -782,6 +782,14 @@ public:
|
|||||||
const TargetInstrInfo *TII,
|
const TargetInstrInfo *TII,
|
||||||
const TargetRegisterInfo *TRI) const;
|
const TargetRegisterInfo *TRI) const;
|
||||||
|
|
||||||
|
/// tieOperands - Add a tie between the register operands at DefIdx and
|
||||||
|
/// UseIdx. The tie will cause the register allocator to ensure that the two
|
||||||
|
/// operands are assigned the same physical register.
|
||||||
|
///
|
||||||
|
/// Tied operands are managed automatically for explicit operands in the
|
||||||
|
/// MCInstrDesc. This method is for exceptional cases like inline asm.
|
||||||
|
void tieOperands(unsigned DefIdx, unsigned UseIdx);
|
||||||
|
|
||||||
/// findTiedOperandIdx - Given the index of a tied register operand, find the
|
/// findTiedOperandIdx - Given the index of a tied register operand, find the
|
||||||
/// operand it is tied to. Defs are tied to uses and vice versa. Returns the
|
/// operand it is tied to. Defs are tied to uses and vice versa. Returns the
|
||||||
/// index of the tied operand which must exist.
|
/// index of the tied operand which must exist.
|
||||||
@@ -942,9 +950,11 @@ private:
|
|||||||
|
|
||||||
/// untieRegOperand - Break any tie involving OpIdx.
|
/// untieRegOperand - Break any tie involving OpIdx.
|
||||||
void untieRegOperand(unsigned OpIdx) {
|
void untieRegOperand(unsigned OpIdx) {
|
||||||
const MachineOperand &MO = getOperand(OpIdx);
|
MachineOperand &MO = getOperand(OpIdx);
|
||||||
if (MO.isReg() && MO.isTied())
|
if (MO.isReg() && MO.isTied()) {
|
||||||
getOperand(findTiedOperandIdx(OpIdx)).setIsTied(false);
|
getOperand(findTiedOperandIdx(OpIdx)).IsTied = false;
|
||||||
|
MO.IsTied = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// addImplicitDefUseOperands - Add all implicit def and use operands to
|
/// addImplicitDefUseOperands - Add all implicit def and use operands to
|
||||||
|
@@ -390,11 +390,6 @@ public:
|
|||||||
IsEarlyClobber = Val;
|
IsEarlyClobber = Val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setIsTied(bool Val = true) {
|
|
||||||
assert(isReg() && "Wrong MachineOperand accessor");
|
|
||||||
IsTied = Val;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setIsDebug(bool Val = true) {
|
void setIsDebug(bool Val = true) {
|
||||||
assert(isReg() && IsDef && "Wrong MachineOperand accessor");
|
assert(isReg() && IsDef && "Wrong MachineOperand accessor");
|
||||||
IsDebug = Val;
|
IsDebug = Val;
|
||||||
|
@@ -728,12 +728,8 @@ void MachineInstr::addOperand(const MachineOperand &Op) {
|
|||||||
// Set the IsTied bit if MC indicates this use is tied to a def.
|
// Set the IsTied bit if MC indicates this use is tied to a def.
|
||||||
if (Operands[OpNo].isUse()) {
|
if (Operands[OpNo].isUse()) {
|
||||||
int DefIdx = MCID->getOperandConstraint(OpNo, MCOI::TIED_TO);
|
int DefIdx = MCID->getOperandConstraint(OpNo, MCOI::TIED_TO);
|
||||||
if (DefIdx != -1) {
|
if (DefIdx != -1)
|
||||||
MachineOperand &DefMO = getOperand(DefIdx);
|
tieOperands(DefIdx, OpNo);
|
||||||
assert(DefMO.isDef() && "Use tied to operand that isn't a def");
|
|
||||||
DefMO.IsTied = true;
|
|
||||||
Operands[OpNo].IsTied = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// If the register operand is flagged as early, mark the operand as such.
|
// If the register operand is flagged as early, mark the operand as such.
|
||||||
if (MCID->getOperandConstraint(OpNo, MCOI::EARLY_CLOBBER) != -1)
|
if (MCID->getOperandConstraint(OpNo, MCOI::EARLY_CLOBBER) != -1)
|
||||||
@@ -1140,6 +1136,20 @@ int MachineInstr::findFirstPredOperandIdx() const {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Mark operands at DefIdx and UseIdx as tied to each other.
|
||||||
|
void MachineInstr::tieOperands(unsigned DefIdx, unsigned UseIdx) {
|
||||||
|
assert(DefIdx < UseIdx && "Tied defs must precede the use");
|
||||||
|
MachineOperand &DefMO = getOperand(DefIdx);
|
||||||
|
MachineOperand &UseMO = getOperand(UseIdx);
|
||||||
|
assert(DefMO.isDef() && "DefIdx must be a def operand");
|
||||||
|
assert(UseMO.isUse() && "UseIdx must be a use operand");
|
||||||
|
assert(!DefMO.isTied() && "Def is already tied to another use");
|
||||||
|
assert(!UseMO.isTied() && "Use is already tied to another def");
|
||||||
|
|
||||||
|
DefMO.IsTied = true;
|
||||||
|
UseMO.IsTied = true;
|
||||||
|
}
|
||||||
|
|
||||||
/// Given the index of a tied register operand, find the operand it is tied to.
|
/// Given the index of a tied register operand, find the operand it is tied to.
|
||||||
/// Defs are tied to uses and vice versa. Returns the index of the tied operand
|
/// Defs are tied to uses and vice versa. Returns the index of the tied operand
|
||||||
/// which must exist.
|
/// which must exist.
|
||||||
|
@@ -945,12 +945,8 @@ EmitSpecialNode(SDNode *Node, bool IsClone, bool IsCloned,
|
|||||||
if (InlineAsm::isUseOperandTiedToDef(Flags, DefGroup)) {
|
if (InlineAsm::isUseOperandTiedToDef(Flags, DefGroup)) {
|
||||||
unsigned DefIdx = GroupIdx[DefGroup] + 1;
|
unsigned DefIdx = GroupIdx[DefGroup] + 1;
|
||||||
unsigned UseIdx = GroupIdx.back() + 1;
|
unsigned UseIdx = GroupIdx.back() + 1;
|
||||||
for (unsigned j = 0; j != NumVals; ++j) {
|
for (unsigned j = 0; j != NumVals; ++j)
|
||||||
assert(!MI->getOperand(DefIdx + j).isTied() &&
|
MI->tieOperands(DefIdx + j, UseIdx + j);
|
||||||
"Def is already tied to another use");
|
|
||||||
MI->getOperand(DefIdx + j).setIsTied();
|
|
||||||
MI->getOperand(UseIdx + j).setIsTied();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user