1d2daf7bf46fcee314ccae6a44d2747c2f603831
[oota-llvm.git] / lib / Target / X86 / InstSelectSimple.cpp
1 //===-- InstSelectSimple.cpp - A simple instruction selector for x86 ------===//
2 //
3 // This file defines a simple peephole instruction selector for the x86 platform
4 //
5 //===----------------------------------------------------------------------===//
6
7 #include "X86.h"
8 #include "X86InstrInfo.h"
9 #include "llvm/Function.h"
10 #include "llvm/iTerminators.h"
11 #include "llvm/iOperators.h"
12 #include "llvm/iOther.h"
13 #include "llvm/iPHINode.h"
14 #include "llvm/Type.h"
15 #include "llvm/Constants.h"
16 #include "llvm/Pass.h"
17 #include "llvm/CodeGen/MachineFunction.h"
18 #include "llvm/CodeGen/MachineInstrBuilder.h"
19 #include "llvm/Support/InstVisitor.h"
20 #include <map>
21
22 namespace {
23   struct ISel : public FunctionPass, InstVisitor<ISel> {
24     TargetMachine &TM;
25     MachineFunction *F;                    // The function we are compiling into
26     MachineBasicBlock *BB;                 // The current MBB we are compiling
27
28     unsigned CurReg;
29     std::map<Value*, unsigned> RegMap;  // Mapping between Val's and SSA Regs
30
31     ISel(TargetMachine &tm)
32       : TM(tm), F(0), BB(0), CurReg(MRegisterInfo::FirstVirtualRegister) {}
33
34     /// runOnFunction - Top level implementation of instruction selection for
35     /// the entire function.
36     ///
37     bool runOnFunction(Function &Fn) {
38       F = &MachineFunction::construct(&Fn, TM);
39       visit(Fn);
40       RegMap.clear();
41       F = 0;
42       return false;  // We never modify the LLVM itself.
43     }
44
45     /// visitBasicBlock - This method is called when we are visiting a new basic
46     /// block.  This simply creates a new MachineBasicBlock to emit code into
47     /// and adds it to the current MachineFunction.  Subsequent visit* for
48     /// instructions will be invoked for all instructions in the basic block.
49     ///
50     void visitBasicBlock(BasicBlock &LLVM_BB) {
51       BB = new MachineBasicBlock(&LLVM_BB);
52       // FIXME: Use the auto-insert form when it's available
53       F->getBasicBlockList().push_back(BB);
54     }
55
56     // Visitation methods for various instructions.  These methods simply emit
57     // fixed X86 code for each instruction.
58     //
59     void visitReturnInst(ReturnInst &RI);
60     void visitBranchInst(BranchInst &BI);
61
62     // Arithmetic operators
63     void visitSimpleBinary(BinaryOperator &B, unsigned OpcodeClass);
64     void visitAdd(BinaryOperator &B) { visitSimpleBinary(B, 0); }
65     void visitSub(BinaryOperator &B) { visitSimpleBinary(B, 1); }
66     void visitMul(BinaryOperator &B);
67
68     void visitDiv(BinaryOperator &B) { visitDivRem(B); }
69     void visitRem(BinaryOperator &B) { visitDivRem(B); }
70     void visitDivRem(BinaryOperator &B);
71
72     // Bitwise operators
73     void visitAnd(BinaryOperator &B) { visitSimpleBinary(B, 2); }
74     void visitOr (BinaryOperator &B) { visitSimpleBinary(B, 3); }
75     void visitXor(BinaryOperator &B) { visitSimpleBinary(B, 4); }
76
77     // Binary comparison operators
78
79     // Other operators
80     void visitShiftInst(ShiftInst &I);
81     void visitSetCondInst(SetCondInst &I);
82     void visitPHINode(PHINode &I);
83
84     void visitInstruction(Instruction &I) {
85       std::cerr << "Cannot instruction select: " << I;
86       abort();
87     }
88
89     
90     /// copyConstantToRegister - Output the instructions required to put the
91     /// specified constant into the specified register.
92     ///
93     void copyConstantToRegister(Constant *C, unsigned Reg);
94
95     /// getReg - This method turns an LLVM value into a register number.  This
96     /// is guaranteed to produce the same register number for a particular value
97     /// every time it is queried.
98     ///
99     unsigned getReg(Value &V) { return getReg(&V); }  // Allow references
100     unsigned getReg(Value *V) {
101       unsigned &Reg = RegMap[V];
102       if (Reg == 0)
103         Reg = CurReg++;
104
105       // If this operand is a constant, emit the code to copy the constant into
106       // the register here...
107       //
108       if (Constant *C = dyn_cast<Constant>(V))
109         copyConstantToRegister(C, Reg);
110
111       return Reg;
112     }
113   };
114 }
115
116 /// getClass - Turn a primitive type into a "class" number which is based on the
117 /// size of the type, and whether or not it is floating point.
118 ///
119 static inline unsigned getClass(const Type *Ty) {
120   switch (Ty->getPrimitiveID()) {
121   case Type::SByteTyID:
122   case Type::UByteTyID:   return 0;          // Byte operands are class #0
123   case Type::ShortTyID:
124   case Type::UShortTyID:  return 1;          // Short operands are class #1
125   case Type::IntTyID:
126   case Type::UIntTyID:
127   case Type::PointerTyID: return 2;          // Int's and pointers are class #2
128
129   case Type::LongTyID:
130   case Type::ULongTyID:   return 3;          // Longs are class #3
131   case Type::FloatTyID:   return 4;          // Float is class #4
132   case Type::DoubleTyID:  return 5;          // Doubles are class #5
133   default:
134     assert(0 && "Invalid type to getClass!");
135     return 0;  // not reached
136   }
137 }
138
139 /// copyConstantToRegister - Output the instructions required to put the
140 /// specified constant into the specified register.
141 ///
142 void ISel::copyConstantToRegister(Constant *C, unsigned R) {
143   assert (!isa<ConstantExpr>(C) && "Constant expressions not yet handled!\n");
144
145   if (C->getType()->isIntegral()) {
146     unsigned Class = getClass(C->getType());
147     assert(Class != 3 && "Type not handled yet!");
148
149     static const unsigned IntegralOpcodeTab[] = {
150       X86::MOVir8, X86::MOVir16, X86::MOVir32
151     };
152
153     if (C->getType()->isSigned()) {
154       ConstantSInt *CSI = cast<ConstantSInt>(C);
155       BuildMI(BB, IntegralOpcodeTab[Class], 1, R).addSImm(CSI->getValue());
156     } else {
157       ConstantUInt *CUI = cast<ConstantUInt>(C);
158       BuildMI(BB, IntegralOpcodeTab[Class], 1, R).addZImm(CUI->getValue());
159     }
160   } else {
161     assert(0 && "Type not handled yet!");
162   }
163 }
164
165 /// SetCC instructions - Here we just emit boilerplate code to set a byte-sized
166 /// register, then move it to wherever the result should be. 
167 /// We handle FP setcc instructions by pushing them, doing a
168 /// compare-and-pop-twice, and then copying the concodes to the main
169 /// processor's concodes (I didn't make this up, it's in the Intel manual)
170 ///
171 void
172 ISel::visitSetCondInst (SetCondInst & I)
173 {
174   // The arguments are already supposed to be of the same type.
175   Value *var1 = I.getOperand (0);
176   Value *var2 = I.getOperand (1);
177   unsigned reg1 = getReg (var1);
178   unsigned reg2 = getReg (var2);
179   unsigned resultReg = getReg (I);
180   unsigned comparisonWidth = var1->getType ()->getPrimitiveSize ();
181   unsigned unsignedComparison = var1->getType ()->isUnsigned ();
182   unsigned resultWidth = I.getType ()->getPrimitiveSize ();
183   bool fpComparison = var1->getType ()->isFloatingPoint ();
184   if (fpComparison)
185     {
186       // Push the variables on the stack with fldl opcodes.
187       // FIXME: assuming var1, var2 are in memory, if not, spill to
188       // stack first
189       switch (comparisonWidth)
190         {
191         case 4:
192           BuildMI (BB, X86::FLDr4, 1, X86::NoReg).addReg (reg1);
193           break;
194         case 8:
195           BuildMI (BB, X86::FLDr8, 1, X86::NoReg).addReg (reg1);
196           break;
197         default:
198           visitInstruction (I);
199           break;
200         }
201       switch (comparisonWidth)
202         {
203         case 4:
204           BuildMI (BB, X86::FLDr4, 1, X86::NoReg).addReg (reg2);
205           break;
206         case 8:
207           BuildMI (BB, X86::FLDr8, 1, X86::NoReg).addReg (reg2);
208           break;
209         default:
210           visitInstruction (I);
211           break;
212         }
213       // (Non-trapping) compare and pop twice.
214       BuildMI (BB, X86::FUCOMPP, 0);
215       // Move fp status word (concodes) to ax.
216       BuildMI (BB, X86::FNSTSWr8, 1, X86::AX);
217       // Load real concodes from ax.
218       BuildMI (BB, X86::SAHF, 1, X86::EFLAGS).addReg(X86::AH);
219     }
220   else
221     {                           // integer comparison
222       // Emit: cmp <var1>, <var2> (do the comparison).  We can
223       // compare 8-bit with 8-bit, 16-bit with 16-bit, 32-bit with
224       // 32-bit.
225       switch (comparisonWidth)
226         {
227         case 1:
228           BuildMI (BB, X86::CMPrr8, 2,
229                    X86::EFLAGS).addReg (reg1).addReg (reg2);
230           break;
231         case 2:
232           BuildMI (BB, X86::CMPrr16, 2,
233                    X86::EFLAGS).addReg (reg1).addReg (reg2);
234           break;
235         case 4:
236           BuildMI (BB, X86::CMPrr32, 2,
237                    X86::EFLAGS).addReg (reg1).addReg (reg2);
238           break;
239         case 8:
240         default:
241           visitInstruction (I);
242           break;
243         }
244     }
245   // Emit setOp instruction (extract concode; clobbers ax),
246   // using the following mapping:
247   // LLVM  -> X86 signed  X86 unsigned
248   // -----    -----       -----
249   // seteq -> sete        sete
250   // setne -> setne       setne
251   // setlt -> setl        setb
252   // setgt -> setg        seta
253   // setle -> setle       setbe
254   // setge -> setge       setae
255   switch (I.getOpcode ())
256     {
257     case Instruction::SetEQ:
258       BuildMI (BB, X86::SETE, 0, X86::AL);
259       break;
260     case Instruction::SetGE:
261         if (unsignedComparison)
262           BuildMI (BB, X86::SETAE, 0, X86::AL);
263         else
264           BuildMI (BB, X86::SETGE, 0, X86::AL);
265       break;
266     case Instruction::SetGT:
267         if (unsignedComparison)
268           BuildMI (BB, X86::SETA, 0, X86::AL);
269         else
270           BuildMI (BB, X86::SETG, 0, X86::AL);
271       break;
272     case Instruction::SetLE:
273         if (unsignedComparison)
274           BuildMI (BB, X86::SETBE, 0, X86::AL);
275         else
276           BuildMI (BB, X86::SETLE, 0, X86::AL);
277       break;
278     case Instruction::SetLT:
279         if (unsignedComparison)
280           BuildMI (BB, X86::SETB, 0, X86::AL);
281         else
282           BuildMI (BB, X86::SETL, 0, X86::AL);
283       break;
284     case Instruction::SetNE:
285       BuildMI (BB, X86::SETNE, 0, X86::AL);
286       break;
287     default:
288       visitInstruction (I);
289       break;
290     }
291   // Put it in the result using a move.
292   switch (resultWidth)
293     {
294     case 1:
295       BuildMI (BB, X86::MOVrr8, 1, resultReg).addReg (X86::AL);
296       break;
297     case 2:
298       BuildMI (BB, X86::MOVZXr16r8, 1, resultReg).addReg (X86::AL);
299       break;
300     case 4:
301       BuildMI (BB, X86::MOVZXr32r8, 1, resultReg).addReg (X86::AL);
302       break;
303     case 8:
304     default:
305       visitInstruction (I);
306       break;
307     }
308 }
309
310
311 /// 'ret' instruction - Here we are interested in meeting the x86 ABI.  As such,
312 /// we have the following possibilities:
313 ///
314 ///   ret void: No return value, simply emit a 'ret' instruction
315 ///   ret sbyte, ubyte : Extend value into EAX and return
316 ///   ret short, ushort: Extend value into EAX and return
317 ///   ret int, uint    : Move value into EAX and return
318 ///   ret pointer      : Move value into EAX and return
319 ///   ret long, ulong  : Move value into EAX/EDX (?) and return
320 ///   ret float/double : ?  Top of FP stack?  XMM0?
321 ///
322 void
323 ISel::visitReturnInst (ReturnInst & I)
324 {
325   if (I.getNumOperands () == 1)
326     {
327       bool unsignedReturnValue = I.getOperand(0)->getType()->isUnsigned();
328       unsigned val = getReg (I.getOperand (0));
329       unsigned operandSize =
330         I.getOperand (0)->getType ()->getPrimitiveSize ();
331       bool isFP = I.getOperand (0)->getType ()->isFloatingPoint ();
332       if (isFP)
333         {
334           // ret float/double: top of FP stack
335           // FLD <val>
336           switch (operandSize)
337             {
338             case 4:
339               BuildMI (BB, X86::FLDr4, 1, X86::NoReg).addReg (val);
340               break;
341             case 8:
342               BuildMI (BB, X86::FLDr8, 1, X86::NoReg).addReg (val);
343               break;
344             default:
345               visitInstruction (I);
346               break;
347             }
348         }
349       else
350         {
351           switch (operandSize)
352             {
353             case 1:
354               // ret sbyte, ubyte: Extend value into EAX and return
355                 if (unsignedReturnValue) {
356                   BuildMI (BB, X86::MOVZXr32r8, 1, X86::EAX).addReg (val);
357                 } else {
358                   BuildMI (BB, X86::MOVSXr32r8, 1, X86::EAX).addReg (val);
359                 }
360               break;
361             case 2:
362               // ret short, ushort: Extend value into EAX and return
363                 if (unsignedReturnValue) {
364                   BuildMI (BB, X86::MOVZXr32r16, 1, X86::EAX).addReg (val);
365                 } else {
366                   BuildMI (BB, X86::MOVSXr32r16, 1, X86::EAX).addReg (val);
367                 }
368               break;
369             case 4:
370               // ret int, uint, ptr: Move value into EAX and return
371               BuildMI (BB, X86::MOVrr32, 1, X86::EAX).addReg (val);
372               break;
373             case 8:
374               // ret long: use EAX(least significant 32 bits)/EDX (most
375               // significant 32)...uh, I think so Brain, but how do i call
376               // up the two parts of the value from inside this mouse
377               // cage? *zort*
378             default:
379               // abort
380               visitInstruction (I);
381               break;
382             }
383         }
384     }
385   // Emit a 'ret' -- the 'leave' will be added by the reg allocator, I guess?
386   BuildMI (BB, X86::RET, 0);
387 }
388
389 /// visitBranchInst - Handle conditional and unconditional branches here.  Note
390 /// that since code layout is frozen at this point, that if we are trying to
391 /// jump to a block that is the immediate successor of the current block, we can
392 /// just make a fall-through. (but we don't currently).
393 ///
394 void ISel::visitBranchInst(BranchInst &BI) {
395   if (BI.isConditional())   // Only handles unconditional branches so far...
396     visitInstruction(BI);
397
398   BuildMI(BB, X86::JMP, 1).addPCDisp(BI.getSuccessor(0));
399 }
400
401
402 /// visitSimpleBinary - Implement simple binary operators for integral types...
403 /// OperatorClass is one of: 0 for Add, 1 for Sub, 2 for And, 3 for Or,
404 /// 4 for Xor.
405 ///
406 void ISel::visitSimpleBinary(BinaryOperator &B, unsigned OperatorClass) {
407   if (B.getType() == Type::BoolTy)  // FIXME: Handle bools for logicals
408     visitInstruction(B);
409
410   unsigned Class = getClass(B.getType());
411   if (Class > 2)  // FIXME: Handle longs
412     visitInstruction(B);
413
414   static const unsigned OpcodeTab[][4] = {
415     // Arithmetic operators
416     { X86::ADDrr8, X86::ADDrr16, X86::ADDrr32, 0 },  // ADD
417     { X86::SUBrr8, X86::SUBrr16, X86::SUBrr32, 0 },  // SUB
418
419     // Bitwise operators
420     { X86::ANDrr8, X86::ANDrr16, X86::ANDrr32, 0 },  // AND
421     { X86:: ORrr8, X86:: ORrr16, X86:: ORrr32, 0 },  // OR
422     { X86::XORrr8, X86::XORrr16, X86::XORrr32, 0 },  // XOR
423   };
424   
425   unsigned Opcode = OpcodeTab[OperatorClass][Class];
426   unsigned Op0r = getReg(B.getOperand(0));
427   unsigned Op1r = getReg(B.getOperand(1));
428   BuildMI(BB, Opcode, 2, getReg(B)).addReg(Op0r).addReg(Op1r);
429 }
430
431 /// visitMul - Multiplies are not simple binary operators because they must deal
432 /// with the EAX register explicitly.
433 ///
434 void ISel::visitMul(BinaryOperator &I) {
435   unsigned Class = getClass(I.getType());
436   if (Class > 2)  // FIXME: Handle longs
437     visitInstruction(I);
438
439   static const unsigned Regs[]     ={ X86::AL    , X86::AX     , X86::EAX     };
440   static const unsigned MulOpcode[]={ X86::MULrr8, X86::MULrr16, X86::MULrr32 };
441   static const unsigned MovOpcode[]={ X86::MOVrr8, X86::MOVrr16, X86::MOVrr32 };
442
443   unsigned Reg = Regs[Class];
444   unsigned Op0Reg = getReg(I.getOperand(1));
445   unsigned Op1Reg = getReg(I.getOperand(1));
446
447   // Put the first operand into one of the A registers...
448   BuildMI(BB, MovOpcode[Class], 1, Reg).addReg(Op0Reg);
449   
450   // Emit the appropriate multiple instruction...
451   // FIXME: We need to mark that this modified AH, DX, or EDX also!!
452   BuildMI(BB, MulOpcode[Class], 2, Reg).addReg(Reg).addReg(Op1Reg);
453
454   // Put the result into the destination register...
455   BuildMI(BB, MovOpcode[Class], 1, getReg(I)).addReg(Reg);
456 }
457
458 /// visitDivRem - Handle division and remainder instructions... these
459 /// instruction both require the same instructions to be generated, they just
460 /// select the result from a different register.  Note that both of these
461 /// instructions work differently for signed and unsigned operands.
462 ///
463 void ISel::visitDivRem(BinaryOperator &I) {
464   unsigned Class = getClass(I.getType());
465   if (Class > 2)  // FIXME: Handle longs
466     visitInstruction(I);
467
468   static const unsigned Regs[]     ={ X86::AL    , X86::AX     , X86::EAX     };
469   static const unsigned MovOpcode[]={ X86::MOVrr8, X86::MOVrr16, X86::MOVrr32 };
470   static const unsigned ExtOpcode[]={ X86::CBW   , X86::CWD    , X86::CDQ     };
471   static const unsigned ClrOpcode[]={ X86::XORrr8, X86::XORrr16, X86::XORrr32 };
472   static const unsigned ExtRegs[]  ={ X86::AH    , X86::DX     , X86::EDX     };
473
474   static const unsigned DivOpcode[][4] = {
475     { X86::DIVrr8 , X86::DIVrr16 , X86::DIVrr32 , 0 },  // Unsigned division
476     { X86::IDIVrr8, X86::IDIVrr16, X86::IDIVrr32, 0 },  // Signed division
477   };
478
479   bool isSigned   = I.getType()->isSigned();
480   unsigned Reg    = Regs[Class];
481   unsigned ExtReg = ExtRegs[Class];
482   unsigned Op0Reg = getReg(I.getOperand(1));
483   unsigned Op1Reg = getReg(I.getOperand(1));
484
485   // Put the first operand into one of the A registers...
486   BuildMI(BB, MovOpcode[Class], 1, Reg).addReg(Op0Reg);
487
488   if (isSigned) {
489     // Emit a sign extension instruction...
490     BuildMI(BB, ExtOpcode[Class], 1, ExtReg).addReg(Reg);
491   } else {
492     // If unsigned, emit a zeroing instruction... (reg = xor reg, reg)
493     BuildMI(BB, ClrOpcode[Class], 2, ExtReg).addReg(ExtReg).addReg(ExtReg);
494   }
495
496   // Figure out which register we want to pick the result out of...
497   unsigned DestReg = (I.getOpcode() == Instruction::Div) ? Reg : ExtReg;
498   
499   // Emit the appropriate divide or remainder instruction...
500   // FIXME: We need to mark that this modified AH, DX, or EDX also!!
501   BuildMI(BB,DivOpcode[isSigned][Class], 2, DestReg).addReg(Reg).addReg(Op1Reg);
502
503   // Put the result into the destination register...
504   BuildMI(BB, MovOpcode[Class], 1, getReg(I)).addReg(DestReg);
505 }
506
507 /// Shift instructions: 'shl', 'sar', 'shr' - Some special cases here
508 /// for constant immediate shift values, and for constant immediate
509 /// shift values equal to 1. Even the general case is sort of special,
510 /// because the shift amount has to be in CL, not just any old register.
511 ///
512 void ISel::visitShiftInst (ShiftInst &I) {
513   unsigned Op0r = getReg (I.getOperand(0));
514   unsigned DestReg = getReg(I);
515   bool isLeftShift = I.getOpcode() == Instruction::Shl;
516   bool isOperandSigned = I.getType()->isUnsigned();
517   unsigned OperandClass = getClass(I.getType());
518
519   if (OperandClass > 2)
520     visitInstruction(I); // Can't handle longs yet!
521
522   if (ConstantUInt *CUI = dyn_cast <ConstantUInt> (I.getOperand (1)))
523     {
524       // The shift amount is constant, guaranteed to be a ubyte. Get its value.
525       assert(CUI->getType() == Type::UByteTy && "Shift amount not a ubyte?");
526       unsigned char shAmt = CUI->getValue();
527
528       static const unsigned ConstantOperand[][4] = {
529         { X86::SHRir8, X86::SHRir16, X86::SHRir32, 0 },  // SHR
530         { X86::SARir8, X86::SARir16, X86::SARir32, 0 },  // SAR
531         { X86::SHLir8, X86::SHLir16, X86::SHLir32, 0 },  // SHL
532         { X86::SHLir8, X86::SHLir16, X86::SHLir32, 0 },  // SAL = SHL
533       };
534
535       const unsigned *OpTab = // Figure out the operand table to use
536         ConstantOperand[isLeftShift*2+isOperandSigned];
537
538       // Emit: <insn> reg, shamt  (shift-by-immediate opcode "ir" form.)
539       BuildMI(BB, OpTab[OperandClass], 2, DestReg).addReg(Op0r).addZImm(shAmt);
540     }
541   else
542     {
543       // The shift amount is non-constant.
544       //
545       // In fact, you can only shift with a variable shift amount if
546       // that amount is already in the CL register, so we have to put it
547       // there first.
548       //
549
550       // Emit: move cl, shiftAmount (put the shift amount in CL.)
551       BuildMI(BB, X86::MOVrr8, 1, X86::CL).addReg(getReg(I.getOperand(1)));
552
553       // This is a shift right (SHR).
554       static const unsigned NonConstantOperand[][4] = {
555         { X86::SHRrr8, X86::SHRrr16, X86::SHRrr32, 0 },  // SHR
556         { X86::SARrr8, X86::SARrr16, X86::SARrr32, 0 },  // SAR
557         { X86::SHLrr8, X86::SHLrr16, X86::SHLrr32, 0 },  // SHL
558         { X86::SHLrr8, X86::SHLrr16, X86::SHLrr32, 0 },  // SAL = SHL
559       };
560
561       const unsigned *OpTab = // Figure out the operand table to use
562         NonConstantOperand[isLeftShift*2+isOperandSigned];
563
564       BuildMI(BB, OpTab[OperandClass], 2, DestReg).addReg(Op0r).addReg(X86::CL);
565     }
566 }
567
568 /// visitPHINode - Turn an LLVM PHI node into an X86 PHI node...
569 ///
570 void ISel::visitPHINode(PHINode &PN) {
571   MachineInstr *MI = BuildMI(BB, X86::PHI, PN.getNumOperands(), getReg(PN));
572
573   for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) {
574     // FIXME: This will put constants after the PHI nodes in the block, which
575     // is invalid.  They should be put inline into the PHI node eventually.
576     //
577     MI->addRegOperand(getReg(PN.getIncomingValue(i)));
578     MI->addPCDispOperand(PN.getIncomingBlock(i));
579   }
580 }
581
582
583 /// createSimpleX86InstructionSelector - This pass converts an LLVM function
584 /// into a machine code representation is a very simple peep-hole fashion.  The
585 /// generated code sucks but the implementation is nice and simple.
586 ///
587 Pass *createSimpleX86InstructionSelector(TargetMachine &TM) {
588   return new ISel(TM);
589 }