Added small section asm emition logic for mips.
[oota-llvm.git] / lib / Target / Mips / MipsInstrInfo.cpp
1 //===- MipsInstrInfo.cpp - Mips Instruction Information ---------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains the Mips implementation of the TargetInstrInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 //#include "Mips.h"
15 #include "MipsInstrInfo.h"
16 #include "MipsTargetMachine.h"
17 #include "llvm/ADT/STLExtras.h"
18 #include "llvm/CodeGen/MachineInstrBuilder.h"
19 #include "MipsGenInstrInfo.inc"
20
21 using namespace llvm;
22
23 MipsInstrInfo::MipsInstrInfo(MipsTargetMachine &tm)
24   : TargetInstrInfoImpl(MipsInsts, array_lengthof(MipsInsts)),
25     TM(tm), RI(*TM.getSubtargetImpl(), *this) {}
26
27 static bool isZeroImm(const MachineOperand &op) {
28   return op.isImmediate() && op.getImm() == 0;
29 }
30
31 /// Return true if the instruction is a register to register move and
32 /// leave the source and dest operands in the passed parameters.
33 bool MipsInstrInfo::
34 isMoveInstr(const MachineInstr &MI, unsigned &SrcReg, unsigned &DstReg) const 
35 {
36   //  addu  $dst, $src, $zero || addu  $dst, $zero, $src
37   //  or    $dst, $src, $zero || or    $dst, $zero, $src
38   if ((MI.getOpcode() == Mips::ADDu) || (MI.getOpcode() == Mips::OR)) {
39     if (MI.getOperand(1).getReg() == Mips::ZERO) {
40       DstReg = MI.getOperand(0).getReg();
41       SrcReg = MI.getOperand(2).getReg();
42       return true;
43     } else if (MI.getOperand(2).getReg() == Mips::ZERO) {
44       DstReg = MI.getOperand(0).getReg();
45       SrcReg = MI.getOperand(1).getReg();
46       return true;
47     }
48   }
49
50   // mov $fpDst, $fpSrc
51   // mfc $gpDst, $fpSrc
52   // mtc $fpDst, $gpSrc
53   if (MI.getOpcode() == Mips::FMOV_SO32 || MI.getOpcode() == Mips::FMOV_AS32 ||
54       MI.getOpcode() == Mips::FMOV_D32 || MI.getOpcode() == Mips::MFC1A ||
55       MI.getOpcode() == Mips::MFC1 || MI.getOpcode() == Mips::MTC1A ||
56       MI.getOpcode() == Mips::MTC1 ) {
57     DstReg = MI.getOperand(0).getReg();
58     SrcReg = MI.getOperand(1).getReg();
59     return true;
60   }
61
62   //  addiu $dst, $src, 0
63   if (MI.getOpcode() == Mips::ADDiu) {
64     if ((MI.getOperand(1).isRegister()) && (isZeroImm(MI.getOperand(2)))) {
65       DstReg = MI.getOperand(0).getReg();
66       SrcReg = MI.getOperand(1).getReg();
67       return true;
68     }
69   }
70   return false;
71 }
72
73 /// isLoadFromStackSlot - If the specified machine instruction is a direct
74 /// load from a stack slot, return the virtual or physical register number of
75 /// the destination along with the FrameIndex of the loaded stack slot.  If
76 /// not, return 0.  This predicate must return 0 if the instruction has
77 /// any side effects other than loading from the stack slot.
78 unsigned MipsInstrInfo::
79 isLoadFromStackSlot(MachineInstr *MI, int &FrameIndex) const 
80 {
81   if ((MI->getOpcode() == Mips::LW) || (MI->getOpcode() == Mips::LWC1) ||
82       (MI->getOpcode() == Mips::LWC1A) || (MI->getOpcode() == Mips::LDC1)) {
83     if ((MI->getOperand(2).isFrameIndex()) && // is a stack slot
84         (MI->getOperand(1).isImmediate()) &&  // the imm is zero
85         (isZeroImm(MI->getOperand(1)))) {
86       FrameIndex = MI->getOperand(2).getIndex();
87       return MI->getOperand(0).getReg();
88     }
89   }
90
91   return 0;
92 }
93
94 /// isStoreToStackSlot - If the specified machine instruction is a direct
95 /// store to a stack slot, return the virtual or physical register number of
96 /// the source reg along with the FrameIndex of the loaded stack slot.  If
97 /// not, return 0.  This predicate must return 0 if the instruction has
98 /// any side effects other than storing to the stack slot.
99 unsigned MipsInstrInfo::
100 isStoreToStackSlot(MachineInstr *MI, int &FrameIndex) const 
101 {
102   if ((MI->getOpcode() == Mips::SW) || (MI->getOpcode() == Mips::SWC1) ||
103       (MI->getOpcode() == Mips::SWC1A) || (MI->getOpcode() == Mips::SDC1)) {
104     if ((MI->getOperand(0).isFrameIndex()) && // is a stack slot
105         (MI->getOperand(1).isImmediate()) &&  // the imm is zero
106         (isZeroImm(MI->getOperand(1)))) {
107       FrameIndex = MI->getOperand(0).getIndex();
108       return MI->getOperand(2).getReg();
109     }
110   }
111   return 0;
112 }
113
114 /// insertNoop - If data hazard condition is found insert the target nop
115 /// instruction.
116 void MipsInstrInfo::
117 insertNoop(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const 
118 {
119   BuildMI(MBB, MI, get(Mips::NOP));
120 }
121
122 void MipsInstrInfo::
123 copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
124              unsigned DestReg, unsigned SrcReg,
125              const TargetRegisterClass *DestRC,
126              const TargetRegisterClass *SrcRC) const {
127   if (DestRC != SrcRC) {
128     if ((DestRC == Mips::CPURegsRegisterClass) && 
129         (SrcRC == Mips::FGR32RegisterClass))
130       BuildMI(MBB, I, get(Mips::MFC1), DestReg).addReg(SrcReg);
131     else if ((DestRC == Mips::CPURegsRegisterClass) && 
132              (SrcRC == Mips::AFGR32RegisterClass))
133       BuildMI(MBB, I, get(Mips::MFC1A), DestReg).addReg(SrcReg);
134     else if ((DestRC == Mips::FGR32RegisterClass) &&
135              (SrcRC == Mips::CPURegsRegisterClass))
136       BuildMI(MBB, I, get(Mips::MTC1), DestReg).addReg(SrcReg);
137     else if ((DestRC == Mips::AFGR32RegisterClass) &&
138              (SrcRC == Mips::CPURegsRegisterClass))
139       BuildMI(MBB, I, get(Mips::MTC1A), DestReg).addReg(SrcReg);
140     else 
141       assert (0 && "DestRC != SrcRC, Can't copy this register");
142   }
143
144   if (DestRC == Mips::CPURegsRegisterClass)
145     BuildMI(MBB, I, get(Mips::ADDu), DestReg).addReg(Mips::ZERO)
146       .addReg(SrcReg);
147   else if (DestRC == Mips::FGR32RegisterClass) 
148     BuildMI(MBB, I, get(Mips::FMOV_SO32), DestReg).addReg(SrcReg);
149   else if (DestRC == Mips::AFGR32RegisterClass)
150     BuildMI(MBB, I, get(Mips::FMOV_AS32), DestReg).addReg(SrcReg);
151   else if (DestRC == Mips::AFGR64RegisterClass)
152     BuildMI(MBB, I, get(Mips::FMOV_D32), DestReg).addReg(SrcReg);
153   else
154     assert (0 && "Can't copy this register");
155 }
156
157 void MipsInstrInfo::
158 storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
159           unsigned SrcReg, bool isKill, int FI, 
160           const TargetRegisterClass *RC) const 
161 {
162   unsigned Opc;
163   if (RC == Mips::CPURegsRegisterClass) 
164     Opc = Mips::SW;
165   else if (RC == Mips::FGR32RegisterClass)
166     Opc = Mips::SWC1;
167   else if (RC == Mips::AFGR32RegisterClass)
168     Opc = Mips::SWC1A;
169   else if (RC == Mips::AFGR64RegisterClass)
170     Opc = Mips::SDC1;
171   else 
172     assert(0 && "Can't store this register to stack slot");
173
174   BuildMI(MBB, I, get(Opc)).addReg(SrcReg, false, false, isKill)
175           .addImm(0).addFrameIndex(FI);
176 }
177
178 void MipsInstrInfo::storeRegToAddr(MachineFunction &MF, unsigned SrcReg,
179   bool isKill, SmallVectorImpl<MachineOperand> &Addr, 
180   const TargetRegisterClass *RC, SmallVectorImpl<MachineInstr*> &NewMIs) const 
181 {
182   unsigned Opc;
183   if (RC == Mips::CPURegsRegisterClass) 
184     Opc = Mips::SW;
185   else if (RC == Mips::FGR32RegisterClass)
186     Opc = Mips::SWC1;
187   else if (RC == Mips::AFGR32RegisterClass)
188     Opc = Mips::SWC1A;
189   else if (RC == Mips::AFGR64RegisterClass)
190     Opc = Mips::SDC1;
191   else 
192     assert(0 && "Can't store this register");
193
194   MachineInstrBuilder MIB = BuildMI(MF, get(Opc))
195     .addReg(SrcReg, false, false, isKill);
196   for (unsigned i = 0, e = Addr.size(); i != e; ++i) {
197     MachineOperand &MO = Addr[i];
198     if (MO.isRegister())
199       MIB.addReg(MO.getReg());
200     else if (MO.isImmediate())
201       MIB.addImm(MO.getImm());
202     else
203       MIB.addFrameIndex(MO.getIndex());
204   }
205   NewMIs.push_back(MIB);
206   return;
207 }
208
209 void MipsInstrInfo::
210 loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
211                      unsigned DestReg, int FI,
212                      const TargetRegisterClass *RC) const 
213 {
214   unsigned Opc;
215   if (RC == Mips::CPURegsRegisterClass) 
216     Opc = Mips::LW;
217   else if (RC == Mips::FGR32RegisterClass)
218     Opc = Mips::LWC1;
219   else if (RC == Mips::AFGR32RegisterClass)
220     Opc = Mips::LWC1A;
221   else if (RC == Mips::AFGR64RegisterClass)
222     Opc = Mips::LDC1;
223   else 
224     assert(0 && "Can't load this register from stack slot");
225     
226   BuildMI(MBB, I, get(Opc), DestReg).addImm(0).addFrameIndex(FI);
227 }
228
229 void MipsInstrInfo::loadRegFromAddr(MachineFunction &MF, unsigned DestReg,
230                                        SmallVectorImpl<MachineOperand> &Addr,
231                                        const TargetRegisterClass *RC,
232                                  SmallVectorImpl<MachineInstr*> &NewMIs) const {
233   unsigned Opc;
234   if (RC == Mips::CPURegsRegisterClass) 
235     Opc = Mips::LW;
236   else if (RC == Mips::FGR32RegisterClass)
237     Opc = Mips::LWC1;
238   else if (RC == Mips::AFGR32RegisterClass)
239     Opc = Mips::LWC1A;
240   else if (RC == Mips::AFGR64RegisterClass)
241     Opc = Mips::LDC1;
242   else 
243     assert(0 && "Can't load this register");
244
245   MachineInstrBuilder MIB = BuildMI(MF, get(Opc), DestReg);
246   for (unsigned i = 0, e = Addr.size(); i != e; ++i) {
247     MachineOperand &MO = Addr[i];
248     if (MO.isRegister())
249       MIB.addReg(MO.getReg());
250     else if (MO.isImmediate())
251       MIB.addImm(MO.getImm());
252     else
253       MIB.addFrameIndex(MO.getIndex());
254   }
255   NewMIs.push_back(MIB);
256   return;
257 }
258
259 MachineInstr *MipsInstrInfo::
260 foldMemoryOperand(MachineFunction &MF,
261                   MachineInstr* MI,
262                   SmallVectorImpl<unsigned> &Ops, int FI) const 
263 {
264   if (Ops.size() != 1) return NULL;
265
266   MachineInstr *NewMI = NULL;
267
268   switch (MI->getOpcode()) {
269   case Mips::ADDu:
270     if ((MI->getOperand(0).isRegister()) &&
271         (MI->getOperand(1).isRegister()) && 
272         (MI->getOperand(1).getReg() == Mips::ZERO) &&
273         (MI->getOperand(2).isRegister())) {
274       if (Ops[0] == 0) {    // COPY -> STORE
275         unsigned SrcReg = MI->getOperand(2).getReg();
276         bool isKill = MI->getOperand(2).isKill();
277         NewMI = BuildMI(MF, get(Mips::SW)).addFrameIndex(FI)
278           .addImm(0).addReg(SrcReg, false, false, isKill);
279       } else {              // COPY -> LOAD
280         unsigned DstReg = MI->getOperand(0).getReg();
281         bool isDead = MI->getOperand(0).isDead();
282         NewMI = BuildMI(MF, get(Mips::LW))
283           .addReg(DstReg, true, false, false, isDead)
284           .addImm(0).addFrameIndex(FI);
285       }
286     }
287     break;
288   case Mips::FMOV_SO32:
289   case Mips::FMOV_AS32:
290   case Mips::FMOV_D32:
291     if ((MI->getOperand(0).isRegister()) &&
292         (MI->getOperand(1).isRegister())) {
293       const TargetRegisterClass 
294         *RC = RI.getRegClass(MI->getOperand(0).getReg());
295       unsigned StoreOpc, LoadOpc;
296
297       if (RC == Mips::FGR32RegisterClass) {
298         LoadOpc = Mips::LWC1; StoreOpc = Mips::SWC1;
299       } else if (RC == Mips::AFGR32RegisterClass) {
300         LoadOpc = Mips::LWC1A; StoreOpc = Mips::SWC1A;
301       } else if (RC == Mips::AFGR64RegisterClass) {
302         LoadOpc = Mips::LDC1; StoreOpc = Mips::SDC1;
303       } else
304         assert(0 && "foldMemoryOperand register unknown");
305
306       if (Ops[0] == 0) {    // COPY -> STORE
307         unsigned SrcReg = MI->getOperand(1).getReg();
308         bool isKill = MI->getOperand(1).isKill();
309         NewMI = BuildMI(MF, get(StoreOpc)).addFrameIndex(FI)
310           .addImm(0).addReg(SrcReg, false, false, isKill);
311       } else {              // COPY -> LOAD
312         unsigned DstReg = MI->getOperand(0).getReg();
313         bool isDead = MI->getOperand(0).isDead();
314         NewMI = BuildMI(MF, get(LoadOpc))
315           .addReg(DstReg, true, false, false, isDead)
316           .addImm(0).addFrameIndex(FI);
317       }
318     }
319     break;
320   }
321
322   return NewMI;
323 }
324
325 //===----------------------------------------------------------------------===//
326 // Branch Analysis
327 //===----------------------------------------------------------------------===//
328
329 /// GetCondFromBranchOpc - Return the Mips CC that matches 
330 /// the correspondent Branch instruction opcode.
331 static Mips::CondCode GetCondFromBranchOpc(unsigned BrOpc) 
332 {
333   switch (BrOpc) {
334   default: return Mips::COND_INVALID;
335   case Mips::BEQ   : return Mips::COND_E;
336   case Mips::BNE   : return Mips::COND_NE;
337   case Mips::BGTZ  : return Mips::COND_GZ;
338   case Mips::BGEZ  : return Mips::COND_GEZ;
339   case Mips::BLTZ  : return Mips::COND_LZ;
340   case Mips::BLEZ  : return Mips::COND_LEZ;
341   }
342 }
343
344 /// GetCondBranchFromCond - Return the Branch instruction
345 /// opcode that matches the cc.
346 unsigned Mips::GetCondBranchFromCond(Mips::CondCode CC) 
347 {
348   switch (CC) {
349   default: assert(0 && "Illegal condition code!");
350   case Mips::COND_E   : return Mips::BEQ;
351   case Mips::COND_NE  : return Mips::BNE;
352   case Mips::COND_GZ  : return Mips::BGTZ;
353   case Mips::COND_GEZ : return Mips::BGEZ;
354   case Mips::COND_LZ  : return Mips::BLTZ;
355   case Mips::COND_LEZ : return Mips::BLEZ;
356   }
357 }
358
359 /// GetOppositeBranchCondition - Return the inverse of the specified 
360 /// condition, e.g. turning COND_E to COND_NE.
361 Mips::CondCode Mips::GetOppositeBranchCondition(Mips::CondCode CC) 
362 {
363   switch (CC) {
364   default: assert(0 && "Illegal condition code!");
365   case Mips::COND_E   : return Mips::COND_NE;
366   case Mips::COND_NE  : return Mips::COND_E;
367   case Mips::COND_GZ  : return Mips::COND_LEZ;
368   case Mips::COND_GEZ : return Mips::COND_LZ;
369   case Mips::COND_LZ  : return Mips::COND_GEZ;
370   case Mips::COND_LEZ : return Mips::COND_GZ;
371   case Mips::FCOND_F  : return Mips::FCOND_T;
372   case Mips::FCOND_UN : return Mips::FCOND_OR;
373   case Mips::FCOND_EQ : return Mips::FCOND_NEQ;
374   case Mips::FCOND_UEQ: return Mips::FCOND_OGL;
375   case Mips::FCOND_OLT: return Mips::FCOND_UGE;
376   case Mips::FCOND_ULT: return Mips::FCOND_OGE;
377   case Mips::FCOND_OLE: return Mips::FCOND_UGT;
378   case Mips::FCOND_ULE: return Mips::FCOND_OGT;
379   case Mips::FCOND_SF:  return Mips::FCOND_ST;
380   case Mips::FCOND_NGLE:return Mips::FCOND_GLE;
381   case Mips::FCOND_SEQ: return Mips::FCOND_SNE;
382   case Mips::FCOND_NGL: return Mips::FCOND_GL;
383   case Mips::FCOND_LT:  return Mips::FCOND_NLT;
384   case Mips::FCOND_NGE: return Mips::FCOND_GE;
385   case Mips::FCOND_LE:  return Mips::FCOND_NLE;
386   case Mips::FCOND_NGT: return Mips::FCOND_GT;
387   }
388 }
389
390 bool MipsInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB, 
391                                   MachineBasicBlock *&TBB,
392                                   MachineBasicBlock *&FBB,
393                                   std::vector<MachineOperand> &Cond) const 
394 {
395   // If the block has no terminators, it just falls into the block after it.
396   MachineBasicBlock::iterator I = MBB.end();
397   if (I == MBB.begin() || !isUnpredicatedTerminator(--I))
398     return false;
399   
400   // Get the last instruction in the block.
401   MachineInstr *LastInst = I;
402   
403   // If there is only one terminator instruction, process it.
404   unsigned LastOpc = LastInst->getOpcode();
405   if (I == MBB.begin() || !isUnpredicatedTerminator(--I)) {
406     if (!LastInst->getDesc().isBranch())
407       return true;
408
409     // Unconditional branch
410     if (LastOpc == Mips::J) {
411       TBB = LastInst->getOperand(0).getMBB();
412       return false;
413     }
414
415     Mips::CondCode BranchCode = GetCondFromBranchOpc(LastInst->getOpcode());
416     if (BranchCode == Mips::COND_INVALID)
417       return true;  // Can't handle indirect branch.
418
419     // Conditional branch
420     // Block ends with fall-through condbranch.
421     if (LastOpc != Mips::COND_INVALID) {
422       int LastNumOp = LastInst->getNumOperands();
423
424       TBB = LastInst->getOperand(LastNumOp-1).getMBB();
425       Cond.push_back(MachineOperand::CreateImm(BranchCode));
426
427       for (int i=0; i<LastNumOp-1; i++) {
428         Cond.push_back(LastInst->getOperand(i));
429       }
430
431       return false;
432     }
433   }
434   
435   // Get the instruction before it if it is a terminator.
436   MachineInstr *SecondLastInst = I;
437   
438   // If there are three terminators, we don't know what sort of block this is.
439   if (SecondLastInst && I != MBB.begin() && isUnpredicatedTerminator(--I))
440     return true;
441
442   // If the block ends with Mips::J and a Mips::BNE/Mips::BEQ, handle it.
443   unsigned SecondLastOpc    = SecondLastInst->getOpcode();
444   Mips::CondCode BranchCode = GetCondFromBranchOpc(SecondLastOpc);
445
446   if (SecondLastOpc != Mips::COND_INVALID && LastOpc == Mips::J) {
447     int SecondNumOp = SecondLastInst->getNumOperands();
448
449     TBB = SecondLastInst->getOperand(SecondNumOp-1).getMBB();
450     Cond.push_back(MachineOperand::CreateImm(BranchCode));
451
452     for (int i=0; i<SecondNumOp-1; i++) {
453       Cond.push_back(SecondLastInst->getOperand(i));
454     }
455
456     FBB = LastInst->getOperand(0).getMBB();
457     return false;
458   }
459   
460   // If the block ends with two unconditional branches, handle it. The last 
461   // one is not executed, so remove it.
462   if ((SecondLastOpc == Mips::J) && (LastOpc == Mips::J)) {
463     TBB = SecondLastInst->getOperand(0).getMBB();
464     I = LastInst;
465     I->eraseFromParent();
466     return false;
467   }
468
469   // Otherwise, can't handle this.
470   return true;
471 }
472
473 unsigned MipsInstrInfo::
474 InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, 
475              MachineBasicBlock *FBB, const std::vector<MachineOperand> &Cond)
476              const
477 {
478   // Shouldn't be a fall through.
479   assert(TBB && "InsertBranch must not be told to insert a fallthrough");
480   assert((Cond.size() == 3 || Cond.size() == 2 || Cond.size() == 0) &&
481          "Mips branch conditions can have two|three components!");
482
483   if (FBB == 0) { // One way branch.
484     if (Cond.empty()) {
485       // Unconditional branch?
486       BuildMI(&MBB, get(Mips::J)).addMBB(TBB);
487     } else {
488       // Conditional branch.
489       unsigned Opc = GetCondBranchFromCond((Mips::CondCode)Cond[0].getImm());
490       const TargetInstrDesc &TID = get(Opc);
491
492       if (TID.getNumOperands() == 3)
493         BuildMI(&MBB, TID).addReg(Cond[1].getReg())
494                           .addReg(Cond[2].getReg())
495                           .addMBB(TBB);
496       else
497         BuildMI(&MBB, TID).addReg(Cond[1].getReg())
498                           .addMBB(TBB);
499
500     }                             
501     return 1;
502   }
503   
504   // Two-way Conditional branch.
505   unsigned Opc = GetCondBranchFromCond((Mips::CondCode)Cond[0].getImm());
506   const TargetInstrDesc &TID = get(Opc);
507
508   if (TID.getNumOperands() == 3)
509     BuildMI(&MBB, TID).addReg(Cond[1].getReg()).addReg(Cond[2].getReg())
510                       .addMBB(TBB);
511   else
512     BuildMI(&MBB, TID).addReg(Cond[1].getReg()).addMBB(TBB);
513
514   BuildMI(&MBB, get(Mips::J)).addMBB(FBB);
515   return 2;
516 }
517
518 unsigned MipsInstrInfo::
519 RemoveBranch(MachineBasicBlock &MBB) const 
520 {
521   MachineBasicBlock::iterator I = MBB.end();
522   if (I == MBB.begin()) return 0;
523   --I;
524   if (I->getOpcode() != Mips::J && 
525       GetCondFromBranchOpc(I->getOpcode()) == Mips::COND_INVALID)
526     return 0;
527   
528   // Remove the branch.
529   I->eraseFromParent();
530   
531   I = MBB.end();
532   
533   if (I == MBB.begin()) return 1;
534   --I;
535   if (GetCondFromBranchOpc(I->getOpcode()) == Mips::COND_INVALID)
536     return 1;
537   
538   // Remove the branch.
539   I->eraseFromParent();
540   return 2;
541 }
542
543 /// BlockHasNoFallThrough - Analyse if MachineBasicBlock does not
544 /// fall-through into its successor block.
545 bool MipsInstrInfo::
546 BlockHasNoFallThrough(MachineBasicBlock &MBB) const 
547 {
548   if (MBB.empty()) return false;
549   
550   switch (MBB.back().getOpcode()) {
551   case Mips::RET:     // Return.
552   case Mips::JR:      // Indirect branch.
553   case Mips::J:       // Uncond branch.
554     return true;
555   default: return false;
556   }
557 }
558
559 /// ReverseBranchCondition - Return the inverse opcode of the 
560 /// specified Branch instruction.
561 bool MipsInstrInfo::
562 ReverseBranchCondition(std::vector<MachineOperand> &Cond) const 
563 {
564   assert( (Cond.size() == 3 || Cond.size() == 2) && 
565           "Invalid Mips branch condition!");
566   Cond[0].setImm(GetOppositeBranchCondition((Mips::CondCode)Cond[0].getImm()));
567   return false;
568 }