[llvm-commits] CVS: llvm/lib/CodeGen/MachineInstr.cpp
Evan Cheng
evan.cheng at apple.com
Mon May 14 18:26:27 PDT 2007
Changes in directory llvm/lib/CodeGen:
MachineInstr.cpp updated: 1.148 -> 1.149
---
Log message:
Added getNumExplicitOperands and findFirstPredOperand.
---
Diffs of the changes: (+46 -0)
MachineInstr.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 46 insertions(+)
Index: llvm/lib/CodeGen/MachineInstr.cpp
diff -u llvm/lib/CodeGen/MachineInstr.cpp:1.148 llvm/lib/CodeGen/MachineInstr.cpp:1.149
--- llvm/lib/CodeGen/MachineInstr.cpp:1.148 Tue May 1 00:57:02 2007
+++ llvm/lib/CodeGen/MachineInstr.cpp Mon May 14 20:26:09 2007
@@ -141,6 +141,21 @@
return false;
}
+/// getNumExplicitOperands - Returns the number of non-implicit operands.
+///
+unsigned MachineInstr::getNumExplicitOperands() const {
+ unsigned NumOperands = TID->numOperands;
+ if ((TID->Flags & M_VARIABLE_OPS) == 0)
+ return NumOperands;
+
+ for (unsigned e = getNumOperands(); NumOperands != e; ++NumOperands) {
+ const MachineOperand &MO = getOperand(NumOperands);
+ if (!MO.isRegister() || !MO.isImplicit())
+ NumOperands++;
+ }
+ return NumOperands;
+}
+
/// isIdenticalTo - Return true if this operand is identical to the specified
/// operand.
bool MachineOperand::isIdenticalTo(const MachineOperand &Other) const {
@@ -192,6 +207,19 @@
}
return NULL;
}
+
+/// findFirstPredOperand() - Find the first operand in the operand list that
+// is used to represent the predicate.
+MachineOperand *MachineInstr::findFirstPredOperand() {
+ const TargetInstrDescriptor *TID = getInstrDescriptor();
+ if (TID->Flags & M_PREDICATED) {
+ for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
+ if ((TID->OpInfo[i].Flags & M_PREDICATE_OPERAND))
+ return &getOperand(i);
+ }
+
+ return NULL;
+}
/// copyKillDeadInfo - Copies kill / dead operand properties from MI.
///
@@ -213,6 +241,24 @@
}
}
+/// copyPredicates - Copies predicate operand(s) from MI.
+void MachineInstr::copyPredicates(const MachineInstr *MI) {
+ const TargetInstrDescriptor *TID = MI->getInstrDescriptor();
+ if (TID->Flags & M_PREDICATED) {
+ for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
+ if ((TID->OpInfo[i].Flags & M_PREDICATE_OPERAND)) {
+ const MachineOperand &MO = MI->getOperand(i);
+ // Predicated operands must be last operands.
+ if (MO.isReg())
+ addRegOperand(MO.getReg(), false);
+ else {
+ addImmOperand(MO.getImm());
+ }
+ }
+ }
+ }
+}
+
void MachineInstr::dump() const {
cerr << " " << *this;
}
More information about the llvm-commits
mailing list