diff options
author | Chris Lattner <sabre@nondot.org> | 2006-10-21 05:34:23 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-10-21 05:34:23 +0000 |
commit | 6fca75ec0525e29e6fd06eee1dbaf3de244ba44f (patch) | |
tree | 02f9dc5d82c996f053523eeeb1be84b09aea839b /llvm/lib | |
parent | 4fe01c42caafa7ca74361ee543c65b433b076eff (diff) | |
download | bcm5719-llvm-6fca75ec0525e29e6fd06eee1dbaf3de244ba44f.tar.gz bcm5719-llvm-6fca75ec0525e29e6fd06eee1dbaf3de244ba44f.zip |
allow insertion of a conditional branch with fall-through
llvm-svn: 31095
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/X86/X86InstrInfo.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/llvm/lib/Target/X86/X86InstrInfo.cpp b/llvm/lib/Target/X86/X86InstrInfo.cpp index b2b9d557e1a..0cc4c39cfb5 100644 --- a/llvm/lib/Target/X86/X86InstrInfo.cpp +++ b/llvm/lib/Target/X86/X86InstrInfo.cpp @@ -374,15 +374,21 @@ void X86InstrInfo::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"); - - // Unconditional branch? - if (FBB == 0) { - BuildMI(&MBB, X86::JMP, 1).addMBB(TBB); + assert((Cond.size() == 1 || Cond.size() == 0) && + "X86 branch conditions have one component!"); + + if (FBB == 0) { // One way branch. + if (Cond.empty()) { + // Unconditional branch? + BuildMI(&MBB, X86::JMP, 1).addMBB(TBB); + } else { + // Conditional branch. + unsigned Opc = GetCondBranchFromCond((X86::CondCode)Cond[0].getImm()); + BuildMI(&MBB, Opc, 1).addMBB(TBB); + } return; } - assert(Cond.size() == 1 && "X86 branch conditions have one component!"); - // Conditional branch. unsigned Opc = GetCondBranchFromCond((X86::CondCode)Cond[0].getImm()); BuildMI(&MBB, Opc, 1).addMBB(TBB); |