summaryrefslogtreecommitdiff
path: root/lib/CodeGen/MachineInstr.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-08-31 20:50:53 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-08-31 20:50:53 +0000
commit94083149fd6891c8a72472cf1814fa6600a75979 (patch)
tree789b62b2c8d309986e5ce08490b80464556971b4 /lib/CodeGen/MachineInstr.cpp
parent265bcb1e5b106a7c5db2bfcfb13cceffe0c413be (diff)
downloadllvm-94083149fd6891c8a72472cf1814fa6600a75979.tar.gz
llvm-94083149fd6891c8a72472cf1814fa6600a75979.tar.bz2
llvm-94083149fd6891c8a72472cf1814fa6600a75979.tar.xz
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
Diffstat (limited to 'lib/CodeGen/MachineInstr.cpp')
-rw-r--r--lib/CodeGen/MachineInstr.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp
index ae205f6d10..5a395fddee 100644
--- a/lib/CodeGen/MachineInstr.cpp
+++ b/lib/CodeGen/MachineInstr.cpp
@@ -728,12 +728,8 @@ void MachineInstr::addOperand(const MachineOperand &Op) {
// Set the IsTied bit if MC indicates this use is tied to a def.
if (Operands[OpNo].isUse()) {
int DefIdx = MCID->getOperandConstraint(OpNo, MCOI::TIED_TO);
- if (DefIdx != -1) {
- MachineOperand &DefMO = getOperand(DefIdx);
- assert(DefMO.isDef() && "Use tied to operand that isn't a def");
- DefMO.IsTied = true;
- Operands[OpNo].IsTied = true;
- }
+ if (DefIdx != -1)
+ tieOperands(DefIdx, OpNo);
}
// If the register operand is flagged as early, mark the operand as such.
if (MCID->getOperandConstraint(OpNo, MCOI::EARLY_CLOBBER) != -1)
@@ -1140,6 +1136,20 @@ int MachineInstr::findFirstPredOperandIdx() const {
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.
/// Defs are tied to uses and vice versa. Returns the index of the tied operand
/// which must exist.