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