diff options
| author | Anton Korobeynikov <asl@math.spbu.ru> | 2009-07-16 14:00:10 +0000 |
|---|---|---|
| committer | Anton Korobeynikov <asl@math.spbu.ru> | 2009-07-16 14:00:10 +0000 |
| commit | ace2a02a8473e23e20ae25c52f859fff6bab2bd4 (patch) | |
| tree | a6b284cb9bb1ccf9d45210ba435b07125a8e7a06 /llvm/lib/Target | |
| parent | 73bf01f2367e52ed3674e9822a06135b2b739d6d (diff) | |
| download | bcm5719-llvm-ace2a02a8473e23e20ae25c52f859fff6bab2bd4.tar.gz bcm5719-llvm-ace2a02a8473e23e20ae25c52f859fff6bab2bd4.zip | |
Implement InsertBranch() hook
llvm-svn: 75966
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp b/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp index 0348e1e5ca8..90e77ffb18d 100644 --- a/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp +++ b/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp @@ -239,9 +239,32 @@ unsigned SystemZInstrInfo::InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, const SmallVectorImpl<MachineOperand> &Cond) const { - assert(0 && "Implement branches!"); + // FIXME this should probably have a DebugLoc operand + DebugLoc dl = DebugLoc::getUnknownLoc(); + // Shouldn't be a fall through. + assert(TBB && "InsertBranch must not be told to insert a fallthrough"); + assert((Cond.size() == 1 || Cond.size() == 0) && + "SystemZ branch conditions have one component!"); + + if (Cond.empty()) { + // Unconditional branch? + assert(!FBB && "Unconditional branch with multiple successors!"); + BuildMI(&MBB, dl, get(SystemZ::JMP)).addMBB(TBB); + return 1; + } + + // Conditional branch. + unsigned Count = 0; + SystemZCC::CondCodes CC = (SystemZCC::CondCodes)Cond[0].getImm(); + BuildMI(&MBB, dl, getBrCond(CC)).addMBB(TBB); + ++Count; - return 0; + if (FBB) { + // Two-way Conditional branch. Insert the second branch. + BuildMI(&MBB, dl, get(SystemZ::JMP)).addMBB(FBB); + ++Count; + } + return Count; } const TargetInstrDesc& |

