Revert the earlier change that removed the M_REMATERIALIZABLE machine
[oota-llvm.git] / lib / Target / X86 / X86InstrInfo.cpp
1 //===- X86InstrInfo.cpp - X86 Instruction Information -----------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains the X86 implementation of the TargetInstrInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "X86InstrInfo.h"
15 #include "X86.h"
16 #include "X86GenInstrInfo.inc"
17 #include "X86InstrBuilder.h"
18 #include "X86Subtarget.h"
19 #include "X86TargetMachine.h"
20 #include "llvm/CodeGen/MachineInstrBuilder.h"
21 #include "llvm/CodeGen/LiveVariables.h"
22 using namespace llvm;
23
24 X86InstrInfo::X86InstrInfo(X86TargetMachine &tm)
25   : TargetInstrInfo(X86Insts, sizeof(X86Insts)/sizeof(X86Insts[0])),
26     TM(tm), RI(tm, *this) {
27 }
28
29 bool X86InstrInfo::isMoveInstr(const MachineInstr& MI,
30                                unsigned& sourceReg,
31                                unsigned& destReg) const {
32   MachineOpCode oc = MI.getOpcode();
33   if (oc == X86::MOV8rr || oc == X86::MOV16rr ||
34       oc == X86::MOV32rr || oc == X86::MOV64rr ||
35       oc == X86::MOV16to16_ || oc == X86::MOV32to32_ ||
36       oc == X86::FpMOV  || oc == X86::MOVSSrr || oc == X86::MOVSDrr ||
37       oc == X86::FsMOVAPSrr || oc == X86::FsMOVAPDrr ||
38       oc == X86::MOVAPSrr || oc == X86::MOVAPDrr ||
39       oc == X86::MOVSS2PSrr || oc == X86::MOVSD2PDrr ||
40       oc == X86::MOVPS2SSrr || oc == X86::MOVPD2SDrr ||
41       oc == X86::MMX_MOVD64rr || oc == X86::MMX_MOVQ64rr) {
42       assert(MI.getNumOperands() >= 2 &&
43              MI.getOperand(0).isRegister() &&
44              MI.getOperand(1).isRegister() &&
45              "invalid register-register move instruction");
46       sourceReg = MI.getOperand(1).getReg();
47       destReg = MI.getOperand(0).getReg();
48       return true;
49   }
50   return false;
51 }
52
53 unsigned X86InstrInfo::isLoadFromStackSlot(MachineInstr *MI, 
54                                            int &FrameIndex) const {
55   switch (MI->getOpcode()) {
56   default: break;
57   case X86::MOV8rm:
58   case X86::MOV16rm:
59   case X86::MOV16_rm:
60   case X86::MOV32rm:
61   case X86::MOV32_rm:
62   case X86::MOV64rm:
63   case X86::FpLD64m:
64   case X86::MOVSSrm:
65   case X86::MOVSDrm:
66   case X86::MOVAPSrm:
67   case X86::MOVAPDrm:
68   case X86::MMX_MOVD64rm:
69   case X86::MMX_MOVQ64rm:
70     if (MI->getOperand(1).isFrameIndex() && MI->getOperand(2).isImmediate() &&
71         MI->getOperand(3).isRegister() && MI->getOperand(4).isImmediate() &&
72         MI->getOperand(2).getImmedValue() == 1 &&
73         MI->getOperand(3).getReg() == 0 &&
74         MI->getOperand(4).getImmedValue() == 0) {
75       FrameIndex = MI->getOperand(1).getFrameIndex();
76       return MI->getOperand(0).getReg();
77     }
78     break;
79   }
80   return 0;
81 }
82
83 unsigned X86InstrInfo::isStoreToStackSlot(MachineInstr *MI,
84                                           int &FrameIndex) const {
85   switch (MI->getOpcode()) {
86   default: break;
87   case X86::MOV8mr:
88   case X86::MOV16mr:
89   case X86::MOV16_mr:
90   case X86::MOV32mr:
91   case X86::MOV32_mr:
92   case X86::MOV64mr:
93   case X86::FpSTP64m:
94   case X86::MOVSSmr:
95   case X86::MOVSDmr:
96   case X86::MOVAPSmr:
97   case X86::MOVAPDmr:
98   case X86::MMX_MOVD64mr:
99   case X86::MMX_MOVQ64mr:
100   case X86::MMX_MOVNTQmr:
101     if (MI->getOperand(0).isFrameIndex() && MI->getOperand(1).isImmediate() &&
102         MI->getOperand(2).isRegister() && MI->getOperand(3).isImmediate() &&
103         MI->getOperand(1).getImmedValue() == 1 &&
104         MI->getOperand(2).getReg() == 0 &&
105         MI->getOperand(3).getImmedValue() == 0) {
106       FrameIndex = MI->getOperand(0).getFrameIndex();
107       return MI->getOperand(4).getReg();
108     }
109     break;
110   }
111   return 0;
112 }
113
114
115 bool X86InstrInfo::isReallyTriviallyReMaterializable(MachineInstr *MI) const {
116   switch (MI->getOpcode()) {
117   default: break;
118   case X86::MOV8rm:
119   case X86::MOV16rm:
120   case X86::MOV16_rm:
121   case X86::MOV32rm:
122   case X86::MOV32_rm:
123   case X86::MOV64rm:
124   case X86::FpLD64m:
125   case X86::MOVSSrm:
126   case X86::MOVSDrm:
127   case X86::MOVAPSrm:
128   case X86::MOVAPDrm:
129   case X86::MMX_MOVD64rm:
130   case X86::MMX_MOVQ64rm:
131     // Loads from constant pools are trivially rematerializable.
132     return MI->getOperand(1).isRegister() && MI->getOperand(2).isImmediate() &&
133            MI->getOperand(3).isRegister() && MI->getOperand(4).isConstantPoolIndex() &&
134            MI->getOperand(1).getReg() == 0 &&
135            MI->getOperand(2).getImmedValue() == 1 &&
136            MI->getOperand(3).getReg() == 0;
137   }
138   // All other instructions marked M_REMATERIALIZABLE are always trivially
139   // rematerializable.
140   return true;
141 }
142
143 /// convertToThreeAddress - This method must be implemented by targets that
144 /// set the M_CONVERTIBLE_TO_3_ADDR flag.  When this flag is set, the target
145 /// may be able to convert a two-address instruction into a true
146 /// three-address instruction on demand.  This allows the X86 target (for
147 /// example) to convert ADD and SHL instructions into LEA instructions if they
148 /// would require register copies due to two-addressness.
149 ///
150 /// This method returns a null pointer if the transformation cannot be
151 /// performed, otherwise it returns the new instruction.
152 ///
153 MachineInstr *
154 X86InstrInfo::convertToThreeAddress(MachineFunction::iterator &MFI,
155                                     MachineBasicBlock::iterator &MBBI,
156                                     LiveVariables &LV) const {
157   MachineInstr *MI = MBBI;
158   // All instructions input are two-addr instructions.  Get the known operands.
159   unsigned Dest = MI->getOperand(0).getReg();
160   unsigned Src = MI->getOperand(1).getReg();
161
162   MachineInstr *NewMI = NULL;
163   // FIXME: 16-bit LEA's are really slow on Athlons, but not bad on P4's.  When
164   // we have better subtarget support, enable the 16-bit LEA generation here.
165   bool DisableLEA16 = true;
166
167   switch (MI->getOpcode()) {
168   default: return 0;
169   case X86::SHUFPSrri: {
170     assert(MI->getNumOperands() == 4 && "Unknown shufps instruction!");
171     if (!TM.getSubtarget<X86Subtarget>().hasSSE2()) return 0;
172     
173     unsigned A = MI->getOperand(0).getReg();
174     unsigned B = MI->getOperand(1).getReg();
175     unsigned C = MI->getOperand(2).getReg();
176     unsigned M = MI->getOperand(3).getImm();
177     if (B != C) return 0;
178     NewMI = BuildMI(get(X86::PSHUFDri), A).addReg(B).addImm(M);
179     break;
180   }
181   case X86::SHL64ri: {
182     assert(MI->getNumOperands() == 3 && "Unknown shift instruction!");
183     // NOTE: LEA doesn't produce flags like shift does, but LLVM never uses
184     // the flags produced by a shift yet, so this is safe.
185     unsigned Dest = MI->getOperand(0).getReg();
186     unsigned Src = MI->getOperand(1).getReg();
187     unsigned ShAmt = MI->getOperand(2).getImm();
188     if (ShAmt == 0 || ShAmt >= 4) return 0;
189     
190     NewMI = BuildMI(get(X86::LEA64r), Dest)
191       .addReg(0).addImm(1 << ShAmt).addReg(Src).addImm(0);
192     break;
193   }
194   case X86::SHL32ri: {
195     assert(MI->getNumOperands() == 3 && "Unknown shift instruction!");
196     // NOTE: LEA doesn't produce flags like shift does, but LLVM never uses
197     // the flags produced by a shift yet, so this is safe.
198     unsigned Dest = MI->getOperand(0).getReg();
199     unsigned Src = MI->getOperand(1).getReg();
200     unsigned ShAmt = MI->getOperand(2).getImm();
201     if (ShAmt == 0 || ShAmt >= 4) return 0;
202     
203     unsigned Opc = TM.getSubtarget<X86Subtarget>().is64Bit() ?
204       X86::LEA64_32r : X86::LEA32r;
205     NewMI = BuildMI(get(Opc), Dest)
206       .addReg(0).addImm(1 << ShAmt).addReg(Src).addImm(0);
207     break;
208   }
209   case X86::SHL16ri: {
210     assert(MI->getNumOperands() == 3 && "Unknown shift instruction!");
211     if (DisableLEA16) return 0;
212     
213     // NOTE: LEA doesn't produce flags like shift does, but LLVM never uses
214     // the flags produced by a shift yet, so this is safe.
215     unsigned Dest = MI->getOperand(0).getReg();
216     unsigned Src = MI->getOperand(1).getReg();
217     unsigned ShAmt = MI->getOperand(2).getImm();
218     if (ShAmt == 0 || ShAmt >= 4) return 0;
219     
220     NewMI = BuildMI(get(X86::LEA16r), Dest)
221       .addReg(0).addImm(1 << ShAmt).addReg(Src).addImm(0);
222     break;
223   }
224   }
225
226   // FIXME: None of these instructions are promotable to LEAs without
227   // additional information.  In particular, LEA doesn't set the flags that
228   // add and inc do.  :(
229   if (0)
230   switch (MI->getOpcode()) {
231   case X86::INC32r:
232   case X86::INC64_32r:
233     assert(MI->getNumOperands() == 2 && "Unknown inc instruction!");
234     NewMI = addRegOffset(BuildMI(get(X86::LEA32r), Dest), Src, 1);
235     break;
236   case X86::INC16r:
237   case X86::INC64_16r:
238     if (DisableLEA16) return 0;
239     assert(MI->getNumOperands() == 2 && "Unknown inc instruction!");
240     NewMI = addRegOffset(BuildMI(get(X86::LEA16r), Dest), Src, 1);
241     break;
242   case X86::DEC32r:
243   case X86::DEC64_32r:
244     assert(MI->getNumOperands() == 2 && "Unknown dec instruction!");
245     NewMI = addRegOffset(BuildMI(get(X86::LEA32r), Dest), Src, -1);
246     break;
247   case X86::DEC16r:
248   case X86::DEC64_16r:
249     if (DisableLEA16) return 0;
250     assert(MI->getNumOperands() == 2 && "Unknown dec instruction!");
251     NewMI = addRegOffset(BuildMI(get(X86::LEA16r), Dest), Src, -1);
252     break;
253   case X86::ADD32rr:
254     assert(MI->getNumOperands() == 3 && "Unknown add instruction!");
255     NewMI = addRegReg(BuildMI(get(X86::LEA32r), Dest), Src,
256                      MI->getOperand(2).getReg());
257     break;
258   case X86::ADD16rr:
259     if (DisableLEA16) return 0;
260     assert(MI->getNumOperands() == 3 && "Unknown add instruction!");
261     NewMI = addRegReg(BuildMI(get(X86::LEA16r), Dest), Src,
262                      MI->getOperand(2).getReg());
263     break;
264   case X86::ADD32ri:
265   case X86::ADD32ri8:
266     assert(MI->getNumOperands() == 3 && "Unknown add instruction!");
267     if (MI->getOperand(2).isImmediate())
268       NewMI = addRegOffset(BuildMI(get(X86::LEA32r), Dest), Src,
269                           MI->getOperand(2).getImmedValue());
270     break;
271   case X86::ADD16ri:
272   case X86::ADD16ri8:
273     if (DisableLEA16) return 0;
274     assert(MI->getNumOperands() == 3 && "Unknown add instruction!");
275     if (MI->getOperand(2).isImmediate())
276       NewMI = addRegOffset(BuildMI(get(X86::LEA16r), Dest), Src,
277                           MI->getOperand(2).getImmedValue());
278     break;
279   case X86::SHL16ri:
280     if (DisableLEA16) return 0;
281   case X86::SHL32ri:
282     assert(MI->getNumOperands() == 3 && MI->getOperand(2).isImmediate() &&
283            "Unknown shl instruction!");
284     unsigned ShAmt = MI->getOperand(2).getImmedValue();
285     if (ShAmt == 1 || ShAmt == 2 || ShAmt == 3) {
286       X86AddressMode AM;
287       AM.Scale = 1 << ShAmt;
288       AM.IndexReg = Src;
289       unsigned Opc = MI->getOpcode() == X86::SHL32ri ? X86::LEA32r :X86::LEA16r;
290       NewMI = addFullAddress(BuildMI(get(Opc), Dest), AM);
291     }
292     break;
293   }
294
295   if (NewMI) {
296     NewMI->copyKillDeadInfo(MI);
297     LV.instructionChanged(MI, NewMI);  // Update live variables
298     MFI->insert(MBBI, NewMI);          // Insert the new inst    
299   }
300   return NewMI;
301 }
302
303 /// commuteInstruction - We have a few instructions that must be hacked on to
304 /// commute them.
305 ///
306 MachineInstr *X86InstrInfo::commuteInstruction(MachineInstr *MI) const {
307   // FIXME: Can commute cmoves by changing the condition!
308   switch (MI->getOpcode()) {
309   case X86::SHRD16rri8: // A = SHRD16rri8 B, C, I -> A = SHLD16rri8 C, B, (16-I)
310   case X86::SHLD16rri8: // A = SHLD16rri8 B, C, I -> A = SHRD16rri8 C, B, (16-I)
311   case X86::SHRD32rri8: // A = SHRD32rri8 B, C, I -> A = SHLD32rri8 C, B, (32-I)
312   case X86::SHLD32rri8:{// A = SHLD32rri8 B, C, I -> A = SHRD32rri8 C, B, (32-I)
313     unsigned Opc;
314     unsigned Size;
315     switch (MI->getOpcode()) {
316     default: assert(0 && "Unreachable!");
317     case X86::SHRD16rri8: Size = 16; Opc = X86::SHLD16rri8; break;
318     case X86::SHLD16rri8: Size = 16; Opc = X86::SHRD16rri8; break;
319     case X86::SHRD32rri8: Size = 32; Opc = X86::SHLD32rri8; break;
320     case X86::SHLD32rri8: Size = 32; Opc = X86::SHRD32rri8; break;
321     }
322     unsigned Amt = MI->getOperand(3).getImmedValue();
323     unsigned A = MI->getOperand(0).getReg();
324     unsigned B = MI->getOperand(1).getReg();
325     unsigned C = MI->getOperand(2).getReg();
326     bool BisKill = MI->getOperand(1).isKill();
327     bool CisKill = MI->getOperand(2).isKill();
328     return BuildMI(get(Opc), A).addReg(C, false, false, CisKill)
329       .addReg(B, false, false, BisKill).addImm(Size-Amt);
330   }
331   default:
332     return TargetInstrInfo::commuteInstruction(MI);
333   }
334 }
335
336 static X86::CondCode GetCondFromBranchOpc(unsigned BrOpc) {
337   switch (BrOpc) {
338   default: return X86::COND_INVALID;
339   case X86::JE:  return X86::COND_E;
340   case X86::JNE: return X86::COND_NE;
341   case X86::JL:  return X86::COND_L;
342   case X86::JLE: return X86::COND_LE;
343   case X86::JG:  return X86::COND_G;
344   case X86::JGE: return X86::COND_GE;
345   case X86::JB:  return X86::COND_B;
346   case X86::JBE: return X86::COND_BE;
347   case X86::JA:  return X86::COND_A;
348   case X86::JAE: return X86::COND_AE;
349   case X86::JS:  return X86::COND_S;
350   case X86::JNS: return X86::COND_NS;
351   case X86::JP:  return X86::COND_P;
352   case X86::JNP: return X86::COND_NP;
353   case X86::JO:  return X86::COND_O;
354   case X86::JNO: return X86::COND_NO;
355   }
356 }
357
358 unsigned X86::GetCondBranchFromCond(X86::CondCode CC) {
359   switch (CC) {
360   default: assert(0 && "Illegal condition code!");
361   case X86::COND_E:  return X86::JE;
362   case X86::COND_NE: return X86::JNE;
363   case X86::COND_L:  return X86::JL;
364   case X86::COND_LE: return X86::JLE;
365   case X86::COND_G:  return X86::JG;
366   case X86::COND_GE: return X86::JGE;
367   case X86::COND_B:  return X86::JB;
368   case X86::COND_BE: return X86::JBE;
369   case X86::COND_A:  return X86::JA;
370   case X86::COND_AE: return X86::JAE;
371   case X86::COND_S:  return X86::JS;
372   case X86::COND_NS: return X86::JNS;
373   case X86::COND_P:  return X86::JP;
374   case X86::COND_NP: return X86::JNP;
375   case X86::COND_O:  return X86::JO;
376   case X86::COND_NO: return X86::JNO;
377   }
378 }
379
380 /// GetOppositeBranchCondition - Return the inverse of the specified condition,
381 /// e.g. turning COND_E to COND_NE.
382 X86::CondCode X86::GetOppositeBranchCondition(X86::CondCode CC) {
383   switch (CC) {
384   default: assert(0 && "Illegal condition code!");
385   case X86::COND_E:  return X86::COND_NE;
386   case X86::COND_NE: return X86::COND_E;
387   case X86::COND_L:  return X86::COND_GE;
388   case X86::COND_LE: return X86::COND_G;
389   case X86::COND_G:  return X86::COND_LE;
390   case X86::COND_GE: return X86::COND_L;
391   case X86::COND_B:  return X86::COND_AE;
392   case X86::COND_BE: return X86::COND_A;
393   case X86::COND_A:  return X86::COND_BE;
394   case X86::COND_AE: return X86::COND_B;
395   case X86::COND_S:  return X86::COND_NS;
396   case X86::COND_NS: return X86::COND_S;
397   case X86::COND_P:  return X86::COND_NP;
398   case X86::COND_NP: return X86::COND_P;
399   case X86::COND_O:  return X86::COND_NO;
400   case X86::COND_NO: return X86::COND_O;
401   }
402 }
403
404 // For purposes of branch analysis do not count FP_REG_KILL as a terminator.
405 bool X86InstrInfo::isUnpredicatedTerminator(const MachineInstr *MI) const {
406   const TargetInstrDescriptor *TID = MI->getInstrDescriptor();
407   if (MI->getOpcode() == X86::FP_REG_KILL)
408     return false;
409   if (TID->Flags & M_TERMINATOR_FLAG)
410     return !isPredicated(MI);
411   return false;
412 }
413
414 bool X86InstrInfo::AnalyzeBranch(MachineBasicBlock &MBB, 
415                                  MachineBasicBlock *&TBB,
416                                  MachineBasicBlock *&FBB,
417                                  std::vector<MachineOperand> &Cond) const {
418   // If the block has no terminators, it just falls into the block after it.
419   MachineBasicBlock::iterator I = MBB.end();
420   if (I == MBB.begin() || !isUnpredicatedTerminator(--I))
421     return false;
422
423   // Get the last instruction in the block.
424   MachineInstr *LastInst = I;
425   
426   // If there is only one terminator instruction, process it.
427   if (I == MBB.begin() || !isUnpredicatedTerminator(--I)) {
428     if (!isBranch(LastInst->getOpcode()))
429       return true;
430     
431     // If the block ends with a branch there are 3 possibilities:
432     // it's an unconditional, conditional, or indirect branch.
433     
434     if (LastInst->getOpcode() == X86::JMP) {
435       TBB = LastInst->getOperand(0).getMachineBasicBlock();
436       return false;
437     }
438     X86::CondCode BranchCode = GetCondFromBranchOpc(LastInst->getOpcode());
439     if (BranchCode == X86::COND_INVALID)
440       return true;  // Can't handle indirect branch.
441
442     // Otherwise, block ends with fall-through condbranch.
443     TBB = LastInst->getOperand(0).getMachineBasicBlock();
444     Cond.push_back(MachineOperand::CreateImm(BranchCode));
445     return false;
446   }
447   
448   // Get the instruction before it if it's a terminator.
449   MachineInstr *SecondLastInst = I;
450   
451   // If there are three terminators, we don't know what sort of block this is.
452   if (SecondLastInst && I != MBB.begin() && isUnpredicatedTerminator(--I))
453     return true;
454
455   // If the block ends with X86::JMP and a conditional branch, handle it.
456   X86::CondCode BranchCode = GetCondFromBranchOpc(SecondLastInst->getOpcode());
457   if (BranchCode != X86::COND_INVALID && LastInst->getOpcode() == X86::JMP) {
458     TBB = SecondLastInst->getOperand(0).getMachineBasicBlock();
459     Cond.push_back(MachineOperand::CreateImm(BranchCode));
460     FBB = LastInst->getOperand(0).getMachineBasicBlock();
461     return false;
462   }
463
464   // If the block ends with two X86::JMPs, handle it.  The second one is not
465   // executed, so remove it.
466   if (SecondLastInst->getOpcode() == X86::JMP && 
467       LastInst->getOpcode() == X86::JMP) {
468     TBB = SecondLastInst->getOperand(0).getMachineBasicBlock();
469     I = LastInst;
470     I->eraseFromParent();
471     return false;
472   }
473
474   // Otherwise, can't handle this.
475   return true;
476 }
477
478 unsigned X86InstrInfo::RemoveBranch(MachineBasicBlock &MBB) const {
479   MachineBasicBlock::iterator I = MBB.end();
480   if (I == MBB.begin()) return 0;
481   --I;
482   if (I->getOpcode() != X86::JMP && 
483       GetCondFromBranchOpc(I->getOpcode()) == X86::COND_INVALID)
484     return 0;
485   
486   // Remove the branch.
487   I->eraseFromParent();
488   
489   I = MBB.end();
490   
491   if (I == MBB.begin()) return 1;
492   --I;
493   if (GetCondFromBranchOpc(I->getOpcode()) == X86::COND_INVALID)
494     return 1;
495   
496   // Remove the branch.
497   I->eraseFromParent();
498   return 2;
499 }
500
501 unsigned
502 X86InstrInfo::InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
503                            MachineBasicBlock *FBB,
504                            const std::vector<MachineOperand> &Cond) const {
505   // Shouldn't be a fall through.
506   assert(TBB && "InsertBranch must not be told to insert a fallthrough");
507   assert((Cond.size() == 1 || Cond.size() == 0) &&
508          "X86 branch conditions have one component!");
509
510   if (FBB == 0) { // One way branch.
511     if (Cond.empty()) {
512       // Unconditional branch?
513       BuildMI(&MBB, get(X86::JMP)).addMBB(TBB);
514     } else {
515       // Conditional branch.
516       unsigned Opc = GetCondBranchFromCond((X86::CondCode)Cond[0].getImm());
517       BuildMI(&MBB, get(Opc)).addMBB(TBB);
518     }
519     return 1;
520   }
521   
522   // Two-way Conditional branch.
523   unsigned Opc = GetCondBranchFromCond((X86::CondCode)Cond[0].getImm());
524   BuildMI(&MBB, get(Opc)).addMBB(TBB);
525   BuildMI(&MBB, get(X86::JMP)).addMBB(FBB);
526   return 2;
527 }
528
529 bool X86InstrInfo::BlockHasNoFallThrough(MachineBasicBlock &MBB) const {
530   if (MBB.empty()) return false;
531   
532   switch (MBB.back().getOpcode()) {
533   case X86::RET:     // Return.
534   case X86::RETI:
535   case X86::TAILJMPd:
536   case X86::TAILJMPr:
537   case X86::TAILJMPm:
538   case X86::JMP:     // Uncond branch.
539   case X86::JMP32r:  // Indirect branch.
540   case X86::JMP32m:  // Indirect branch through mem.
541     return true;
542   default: return false;
543   }
544 }
545
546 bool X86InstrInfo::
547 ReverseBranchCondition(std::vector<MachineOperand> &Cond) const {
548   assert(Cond.size() == 1 && "Invalid X86 branch condition!");
549   Cond[0].setImm(GetOppositeBranchCondition((X86::CondCode)Cond[0].getImm()));
550   return false;
551 }
552
553 const TargetRegisterClass *X86InstrInfo::getPointerRegClass() const {
554   const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>();
555   if (Subtarget->is64Bit())
556     return &X86::GR64RegClass;
557   else
558     return &X86::GR32RegClass;
559 }