diff options
author | Evan Cheng <evan.cheng@apple.com> | 2007-05-16 21:20:37 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2007-05-16 21:20:37 +0000 |
commit | 2eb80fa433fbc9257bb7ef236e48092981cc3b3c (patch) | |
tree | 9faa6c843ce96680c41af25c19e1f141ca06a267 /lib/Target/TargetInstrInfo.cpp | |
parent | c3a289c4b5a60a204363ba4ae9f017ba87b714f9 (diff) |
Add default implementation of PredicateInstruction().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37123 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/TargetInstrInfo.cpp')
-rw-r--r-- | lib/Target/TargetInstrInfo.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/Target/TargetInstrInfo.cpp b/lib/Target/TargetInstrInfo.cpp index b9fca8a1bf..fe5ee1d25e 100644 --- a/lib/Target/TargetInstrInfo.cpp +++ b/lib/Target/TargetInstrInfo.cpp @@ -59,3 +59,23 @@ MachineInstr *TargetInstrInfo::commuteInstruction(MachineInstr *MI) const { MI->getOperand(1).unsetIsKill(); return MI; } + +void TargetInstrInfo::PredicateInstruction(MachineInstr *MI, + std::vector<MachineOperand> &Cond) const { + const TargetInstrDescriptor *TID = MI->getInstrDescriptor(); + assert((TID->Flags & M_PREDICABLE) && + "Predicating an unpredicable instruction!"); + + for (unsigned j = 0, i = 0, e = MI->getNumOperands(); i != e; ++i) { + if ((TID->OpInfo[i].Flags & M_PREDICATE_OPERAND)) { + MachineOperand &MO = MI->getOperand(i); + if (MO.isReg()) + MO.setReg(Cond[j].getReg()); + else if (MO.isImm()) + MO.setImm(Cond[j].getImmedValue()); + else if (MO.isMBB()) + MO.setMachineBasicBlock(Cond[j].getMachineBasicBlock()); + ++j; + } + } +} |