aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/PowerPC/PPCInstrInfo.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-10-21 05:36:13 +0000
committerChris Lattner <sabre@nondot.org>2006-10-21 05:36:13 +0000
commit54108068b71a7dbc48f4ebf1b2d7d87ca541070a (patch)
treeacd3ed5f264b0a3ea4dcdc07c2ee579cb62c0d06 /lib/Target/PowerPC/PPCInstrInfo.cpp
parent34a84ac81c1ab3cd017203f69ce74283f42be15a (diff)
implement support for inserting a cond branch
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31096 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PowerPC/PPCInstrInfo.cpp')
-rw-r--r--lib/Target/PowerPC/PPCInstrInfo.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/Target/PowerPC/PPCInstrInfo.cpp b/lib/Target/PowerPC/PPCInstrInfo.cpp
index 9bf0746a2a..941229dc38 100644
--- a/lib/Target/PowerPC/PPCInstrInfo.cpp
+++ b/lib/Target/PowerPC/PPCInstrInfo.cpp
@@ -240,15 +240,19 @@ void PPCInstrInfo::InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
const std::vector<MachineOperand> &Cond) const {
// Shouldn't be a fall through.
assert(TBB && "InsertBranch must not be told to insert a fallthrough");
+ assert((Cond.size() == 2 || Cond.size() == 0) &&
+ "PPC branch conditions have two components!");
- // Unconditional branch?
+ // One-way branch.
if (FBB == 0) {
- BuildMI(&MBB, PPC::B, 1).addMBB(TBB);
+ if (Cond.empty()) // Unconditional branch
+ BuildMI(&MBB, PPC::B, 1).addMBB(TBB);
+ else // Conditional branch
+ BuildMI(&MBB, PPC::COND_BRANCH, 3)
+ .addReg(Cond[0].getReg()).addImm(Cond[1].getImm()).addMBB(TBB);
return;
}
- assert(Cond.size() == 2 && "PPC branch conditions have two components!");
-
// Conditional branch
BuildMI(&MBB, PPC::COND_BRANCH, 3)
.addReg(Cond[0].getReg()).addImm(Cond[1].getImm()).addMBB(TBB);