summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2006-11-01 23:00:31 +0000
committerEvan Cheng <evan.cheng@apple.com>2006-11-01 23:00:31 +0000
commit1b2e60e9705d5ea1a58ca46223f0221643f9e9ae (patch)
treea6e47c28e7168b94bf34e4a830cdc0e2c188110d
parent1359196c4e617db3cbf19507ed2ac8a2160ca15e (diff)
downloadbcm5719-llvm-1b2e60e9705d5ea1a58ca46223f0221643f9e9ae.tar.gz
bcm5719-llvm-1b2e60e9705d5ea1a58ca46223f0221643f9e9ae.zip
Added getTiedToSrcOperand() to check for two-address'ness.
llvm-svn: 31360
-rw-r--r--llvm/include/llvm/Target/TargetInstrInfo.h6
-rw-r--r--llvm/lib/Target/TargetInstrInfo.cpp12
2 files changed, 17 insertions, 1 deletions
diff --git a/llvm/include/llvm/Target/TargetInstrInfo.h b/llvm/include/llvm/Target/TargetInstrInfo.h
index 0098870e66e..ead631578ca 100644
--- a/llvm/include/llvm/Target/TargetInstrInfo.h
+++ b/llvm/include/llvm/Target/TargetInstrInfo.h
@@ -230,7 +230,7 @@ public:
/// getOperandConstraint - Returns the value of the specific constraint if
/// it is set. Returns -1 if it is not set.
int getOperandConstraint(MachineOpCode Opcode, unsigned OpNum,
- OperandConstraint Constraint) {
+ OperandConstraint Constraint) const {
assert(OpNum < get(Opcode).numOperands &&
"Invalid operand # of TargetInstrInfo");
if (get(Opcode).OpInfo[OpNum].Constraints & (1 << Constraint)) {
@@ -240,6 +240,10 @@ public:
return -1;
}
+ /// getTiedToSrcOperand - Returns the operand that is tied to the specified
+ /// dest operand. Returns -1 if there isn't one.
+ int getTiedToSrcOperand(MachineOpCode Opcode, unsigned OpNum) const;
+
/// getDWARF_LABELOpcode - Return the opcode of the target's DWARF_LABEL
/// instruction if it has one. This is used by codegen passes that update
/// DWARF line number info as they modify the code.
diff --git a/llvm/lib/Target/TargetInstrInfo.cpp b/llvm/lib/Target/TargetInstrInfo.cpp
index 4346203d917..81759098ed8 100644
--- a/llvm/lib/Target/TargetInstrInfo.cpp
+++ b/llvm/lib/Target/TargetInstrInfo.cpp
@@ -38,6 +38,18 @@ TargetInstrInfo::~TargetInstrInfo() {
TargetInstrDescriptors = NULL; // reset global variable
}
+int
+TargetInstrInfo::getTiedToSrcOperand(MachineOpCode Opc, unsigned OpNum) const {
+ for (unsigned i = 0, e = getNumOperands(Opc); i != e; ++i) {
+ if (i == OpNum)
+ continue;
+ int ti = getOperandConstraint(Opc, i, TIED_TO);
+ if (ti == (int)OpNum)
+ return i;
+ }
+ return -1;
+}
+
// commuteInstruction - The default implementation of this method just exchanges
// operand 1 and 2.
OpenPOWER on IntegriCloud