Rewrite FP stackifier support in the X86InstrInfo.td file, splitting patterns
[oota-llvm.git] / lib / Target / X86 / X86ISelLowering.cpp
1 //===-- X86ISelLowering.h - X86 DAG Lowering Interface ----------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by Chris Lattner and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the interfaces that X86 uses to lower LLVM code into a
11 // selection DAG.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "X86.h"
16 #include "X86ISelLowering.h"
17 #include "X86TargetMachine.h"
18 #include "llvm/CallingConv.h"
19 #include "llvm/Function.h"
20 #include "llvm/CodeGen/MachineFunction.h"
21 #include "llvm/CodeGen/MachineFrameInfo.h"
22 #include "llvm/CodeGen/SelectionDAG.h"
23 #include "llvm/CodeGen/SSARegMap.h"
24 #include "llvm/Target/TargetOptions.h"
25 using namespace llvm;
26
27 // FIXME: temporary.
28 #include "llvm/Support/CommandLine.h"
29 static cl::opt<bool> EnableFastCC("enable-x86-fastcc", cl::Hidden,
30                                   cl::desc("Enable fastcc on X86"));
31
32 X86TargetLowering::X86TargetLowering(TargetMachine &TM)
33   : TargetLowering(TM) {
34   // Set up the TargetLowering object.
35
36   // X86 is weird, it always uses i8 for shift amounts and setcc results.
37   setShiftAmountType(MVT::i8);
38   setSetCCResultType(MVT::i8);
39   setSetCCResultContents(ZeroOrOneSetCCResult);
40   setShiftAmountFlavor(Mask);   // shl X, 32 == shl X, 0
41
42   // Set up the register classes.
43   addRegisterClass(MVT::i8, X86::R8RegisterClass);
44   addRegisterClass(MVT::i16, X86::R16RegisterClass);
45   addRegisterClass(MVT::i32, X86::R32RegisterClass);
46
47   // Promote all UINT_TO_FP to larger SINT_TO_FP's, as X86 doesn't have this
48   // operation.
49   setOperationAction(ISD::UINT_TO_FP       , MVT::i1   , Promote);
50   setOperationAction(ISD::UINT_TO_FP       , MVT::i8   , Promote);
51   setOperationAction(ISD::UINT_TO_FP       , MVT::i16  , Promote);
52   setOperationAction(ISD::UINT_TO_FP       , MVT::i32  , Promote);
53
54   // Promote i1/i8 SINT_TO_FP to larger SINT_TO_FP's, as X86 doesn't have
55   // this operation.
56   setOperationAction(ISD::SINT_TO_FP       , MVT::i1   , Promote);
57   setOperationAction(ISD::SINT_TO_FP       , MVT::i8   , Promote);
58
59   if (!X86ScalarSSE) {
60     // We can handle SINT_TO_FP and FP_TO_SINT from/TO i64 even though i64
61     // isn't legal.
62     setOperationAction(ISD::SINT_TO_FP     , MVT::i64  , Custom);
63     setOperationAction(ISD::FP_TO_SINT     , MVT::i64  , Custom);
64     setOperationAction(ISD::FP_TO_SINT     , MVT::i32  , Custom);
65     setOperationAction(ISD::FP_TO_SINT     , MVT::i16  , Custom);
66   }
67
68   // Handle FP_TO_UINT by promoting the destination to a larger signed
69   // conversion.
70   setOperationAction(ISD::FP_TO_UINT       , MVT::i1   , Promote);
71   setOperationAction(ISD::FP_TO_UINT       , MVT::i8   , Promote);
72   setOperationAction(ISD::FP_TO_UINT       , MVT::i16  , Promote);
73
74   if (!X86ScalarSSE)
75     setOperationAction(ISD::FP_TO_UINT     , MVT::i32  , Promote);
76
77   // Promote i1/i8 FP_TO_SINT to larger FP_TO_SINTS's, as X86 doesn't have
78   // this operation.
79   setOperationAction(ISD::FP_TO_SINT       , MVT::i1   , Promote);
80   setOperationAction(ISD::FP_TO_SINT       , MVT::i8   , Promote);
81   setOperationAction(ISD::FP_TO_SINT       , MVT::i16  , Promote);
82
83   if (X86DAGIsel) {
84     setOperationAction(ISD::BRCOND         , MVT::Other, Custom);
85   }
86   setOperationAction(ISD::BRCONDTWOWAY     , MVT::Other, Expand);
87   setOperationAction(ISD::BRTWOWAY_CC      , MVT::Other, Expand);
88   setOperationAction(ISD::MEMMOVE          , MVT::Other, Expand);
89   setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i16  , Expand);
90   setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i8   , Expand);
91   setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i1   , Expand);
92   setOperationAction(ISD::FP_ROUND_INREG   , MVT::f32  , Expand);
93   setOperationAction(ISD::SEXTLOAD         , MVT::i1   , Expand);
94   setOperationAction(ISD::FREM             , MVT::f64  , Expand);
95   setOperationAction(ISD::CTPOP            , MVT::i8   , Expand);
96   setOperationAction(ISD::CTTZ             , MVT::i8   , Expand);
97   setOperationAction(ISD::CTLZ             , MVT::i8   , Expand);
98   setOperationAction(ISD::CTPOP            , MVT::i16  , Expand);
99   setOperationAction(ISD::CTTZ             , MVT::i16  , Expand);
100   setOperationAction(ISD::CTLZ             , MVT::i16  , Expand);
101   setOperationAction(ISD::CTPOP            , MVT::i32  , Expand);
102   setOperationAction(ISD::CTTZ             , MVT::i32  , Expand);
103   setOperationAction(ISD::CTLZ             , MVT::i32  , Expand);
104   setOperationAction(ISD::READCYCLECOUNTER , MVT::i64  , Custom);
105
106   setOperationAction(ISD::READIO           , MVT::i1   , Expand);
107   setOperationAction(ISD::READIO           , MVT::i8   , Expand);
108   setOperationAction(ISD::READIO           , MVT::i16  , Expand);
109   setOperationAction(ISD::READIO           , MVT::i32  , Expand);
110   setOperationAction(ISD::WRITEIO          , MVT::i1   , Expand);
111   setOperationAction(ISD::WRITEIO          , MVT::i8   , Expand);
112   setOperationAction(ISD::WRITEIO          , MVT::i16  , Expand);
113   setOperationAction(ISD::WRITEIO          , MVT::i32  , Expand);
114
115   // These should be promoted to a larger select which is supported.
116   setOperationAction(ISD::SELECT           , MVT::i1   , Promote);
117   setOperationAction(ISD::SELECT           , MVT::i8   , Promote);
118   // X86 wants to expand cmov itself.
119   if (X86DAGIsel) {
120     setOperationAction(ISD::SELECT         , MVT::i16  , Custom);
121     setOperationAction(ISD::SELECT         , MVT::i32  , Custom);
122   }
123
124   // We don't have line number support yet.
125   setOperationAction(ISD::LOCATION, MVT::Other, Expand);
126
127   if (X86ScalarSSE) {
128     // Set up the FP register classes.
129     addRegisterClass(MVT::f32, X86::V4F4RegisterClass);
130     addRegisterClass(MVT::f64, X86::V2F8RegisterClass);
131
132     // SSE has no load+extend ops
133     setOperationAction(ISD::EXTLOAD,  MVT::f32, Expand);
134     setOperationAction(ISD::ZEXTLOAD, MVT::f32, Expand);
135
136     // SSE has no i16 to fp conversion, only i32
137     setOperationAction(ISD::SINT_TO_FP, MVT::i16, Promote);
138     setOperationAction(ISD::FP_TO_SINT, MVT::i16, Promote);
139
140     // Expand FP_TO_UINT into a select.
141     // FIXME: We would like to use a Custom expander here eventually to do
142     // the optimal thing for SSE vs. the default expansion in the legalizer.
143     setOperationAction(ISD::FP_TO_UINT       , MVT::i32  , Expand);
144         
145     // We don't support sin/cos/sqrt/fmod
146     setOperationAction(ISD::FSIN , MVT::f64, Expand);
147     setOperationAction(ISD::FCOS , MVT::f64, Expand);
148     setOperationAction(ISD::FABS , MVT::f64, Expand);
149     setOperationAction(ISD::FNEG , MVT::f64, Expand);
150     setOperationAction(ISD::FREM , MVT::f64, Expand);
151     setOperationAction(ISD::FSIN , MVT::f32, Expand);
152     setOperationAction(ISD::FCOS , MVT::f32, Expand);
153     setOperationAction(ISD::FABS , MVT::f32, Expand);
154     setOperationAction(ISD::FNEG , MVT::f32, Expand);
155     setOperationAction(ISD::FREM , MVT::f32, Expand);
156
157     addLegalFPImmediate(+0.0); // xorps / xorpd
158   } else {
159     // Set up the FP register classes.
160     addRegisterClass(MVT::f64, X86::RFPRegisterClass);
161
162     if (!UnsafeFPMath) {
163       setOperationAction(ISD::FSIN           , MVT::f64  , Expand);
164       setOperationAction(ISD::FCOS           , MVT::f64  , Expand);
165     }
166
167     addLegalFPImmediate(+0.0); // FLD0
168     addLegalFPImmediate(+1.0); // FLD1
169     addLegalFPImmediate(-0.0); // FLD0/FCHS
170     addLegalFPImmediate(-1.0); // FLD1/FCHS
171   }
172   computeRegisterProperties();
173
174   maxStoresPerMemSet = 8; // For %llvm.memset -> sequence of stores
175   maxStoresPerMemCpy = 8; // For %llvm.memcpy -> sequence of stores
176   maxStoresPerMemMove = 8; // For %llvm.memmove -> sequence of stores
177   allowUnalignedMemoryAccesses = true; // x86 supports it!
178 }
179
180 std::vector<SDOperand>
181 X86TargetLowering::LowerArguments(Function &F, SelectionDAG &DAG) {
182   if (F.getCallingConv() == CallingConv::Fast && EnableFastCC)
183     return LowerFastCCArguments(F, DAG);
184   return LowerCCCArguments(F, DAG);
185 }
186
187 std::pair<SDOperand, SDOperand>
188 X86TargetLowering::LowerCallTo(SDOperand Chain, const Type *RetTy,
189                                bool isVarArg, unsigned CallingConv,
190                                bool isTailCall,
191                                SDOperand Callee, ArgListTy &Args,
192                                SelectionDAG &DAG) {
193   assert((!isVarArg || CallingConv == CallingConv::C) &&
194          "Only C takes varargs!");
195   if (CallingConv == CallingConv::Fast && EnableFastCC)
196     return LowerFastCCCallTo(Chain, RetTy, isTailCall, Callee, Args, DAG);
197   return  LowerCCCCallTo(Chain, RetTy, isVarArg, isTailCall, Callee, Args, DAG);
198 }
199
200 SDOperand X86TargetLowering::LowerReturnTo(SDOperand Chain, SDOperand Op,
201                                            SelectionDAG &DAG) {
202   if (!X86DAGIsel)
203     return DAG.getNode(ISD::RET, MVT::Other, Chain, Op);
204
205   SDOperand Copy;
206   MVT::ValueType OpVT = Op.getValueType();
207   switch (OpVT) {
208     default: assert(0 && "Unknown type to return!");
209     case MVT::i32:
210       Copy = DAG.getCopyToReg(Chain, X86::EAX, Op, SDOperand());
211       break;
212     case MVT::i64: {
213       SDOperand Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, MVT::i32, Op, 
214                                  DAG.getConstant(1, MVT::i32));
215       SDOperand Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, MVT::i32, Op,
216                                  DAG.getConstant(0, MVT::i32));
217       Copy = DAG.getCopyToReg(Chain, X86::EAX, Hi, SDOperand());
218       Copy = DAG.getCopyToReg(Copy,  X86::EDX, Lo, Copy.getValue(1));
219       break;
220     }
221     case MVT::f32:
222       assert(X86ScalarSSE && "MVT::f32 only legal with scalar sse fp");
223       // Fallthrough intended
224     case MVT::f64:
225       if (!X86ScalarSSE) {
226         std::vector<MVT::ValueType> Tys;
227         Tys.push_back(MVT::Other);
228         Tys.push_back(MVT::Flag);
229         std::vector<SDOperand> Ops;
230         Ops.push_back(Chain);
231         Ops.push_back(Op);
232         Copy = DAG.getNode(X86ISD::FP_SET_RESULT, Tys, Ops);
233       } else {
234         // Spill the value to memory and reload it into top of stack.
235         unsigned Size = MVT::getSizeInBits(OpVT)/8;
236         MachineFunction &MF = DAG.getMachineFunction();
237         int SSFI = MF.getFrameInfo()->CreateStackObject(Size, Size);
238         SDOperand StackSlot = DAG.getFrameIndex(SSFI, getPointerTy());
239         Chain = DAG.getNode(ISD::STORE, MVT::Other, Chain, Op,
240                             StackSlot, DAG.getSrcValue(NULL));
241         std::vector<MVT::ValueType> Tys;
242         Tys.push_back(MVT::f64);
243         Tys.push_back(MVT::Other);
244         std::vector<SDOperand> Ops;
245         Ops.push_back(Chain);
246         Ops.push_back(StackSlot);
247         Ops.push_back(DAG.getValueType(OpVT));
248         Copy = DAG.getNode(X86ISD::FLD, Tys, Ops);
249         Tys.clear();
250         Tys.push_back(MVT::Other);
251         Tys.push_back(MVT::Flag);
252         Ops.clear();
253         Ops.push_back(Copy.getValue(1));
254         Ops.push_back(Copy);
255         Copy = DAG.getNode(X86ISD::FP_SET_RESULT, Tys, Ops);
256       }
257       break;
258   }
259   return DAG.getNode(X86ISD::RET_FLAG, MVT::Other, Copy, Copy.getValue(1));
260 }
261
262 //===----------------------------------------------------------------------===//
263 //                    C Calling Convention implementation
264 //===----------------------------------------------------------------------===//
265
266 std::vector<SDOperand>
267 X86TargetLowering::LowerCCCArguments(Function &F, SelectionDAG &DAG) {
268   std::vector<SDOperand> ArgValues;
269
270   MachineFunction &MF = DAG.getMachineFunction();
271   MachineFrameInfo *MFI = MF.getFrameInfo();
272
273   // Add DAG nodes to load the arguments...  On entry to a function on the X86,
274   // the stack frame looks like this:
275   //
276   // [ESP] -- return address
277   // [ESP + 4] -- first argument (leftmost lexically)
278   // [ESP + 8] -- second argument, if first argument is four bytes in size
279   //    ...
280   //
281   unsigned ArgOffset = 0;   // Frame mechanisms handle retaddr slot
282   for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I) {
283     MVT::ValueType ObjectVT = getValueType(I->getType());
284     unsigned ArgIncrement = 4;
285     unsigned ObjSize;
286     switch (ObjectVT) {
287     default: assert(0 && "Unhandled argument type!");
288     case MVT::i1:
289     case MVT::i8:  ObjSize = 1;                break;
290     case MVT::i16: ObjSize = 2;                break;
291     case MVT::i32: ObjSize = 4;                break;
292     case MVT::i64: ObjSize = ArgIncrement = 8; break;
293     case MVT::f32: ObjSize = 4;                break;
294     case MVT::f64: ObjSize = ArgIncrement = 8; break;
295     }
296     // Create the frame index object for this incoming parameter...
297     int FI = MFI->CreateFixedObject(ObjSize, ArgOffset);
298
299     // Create the SelectionDAG nodes corresponding to a load from this parameter
300     SDOperand FIN = DAG.getFrameIndex(FI, MVT::i32);
301
302     // Don't codegen dead arguments.  FIXME: remove this check when we can nuke
303     // dead loads.
304     SDOperand ArgValue;
305     if (!I->use_empty())
306       ArgValue = DAG.getLoad(ObjectVT, DAG.getEntryNode(), FIN,
307                              DAG.getSrcValue(NULL));
308     else {
309       if (MVT::isInteger(ObjectVT))
310         ArgValue = DAG.getConstant(0, ObjectVT);
311       else
312         ArgValue = DAG.getConstantFP(0, ObjectVT);
313     }
314     ArgValues.push_back(ArgValue);
315
316     ArgOffset += ArgIncrement;   // Move on to the next argument...
317   }
318
319   // If the function takes variable number of arguments, make a frame index for
320   // the start of the first vararg value... for expansion of llvm.va_start.
321   if (F.isVarArg())
322     VarArgsFrameIndex = MFI->CreateFixedObject(1, ArgOffset);
323   ReturnAddrIndex = 0;     // No return address slot generated yet.
324   BytesToPopOnReturn = 0;  // Callee pops nothing.
325   BytesCallerReserves = ArgOffset;
326
327   // Finally, inform the code generator which regs we return values in.
328   switch (getValueType(F.getReturnType())) {
329   default: assert(0 && "Unknown type!");
330   case MVT::isVoid: break;
331   case MVT::i1:
332   case MVT::i8:
333   case MVT::i16:
334   case MVT::i32:
335     MF.addLiveOut(X86::EAX);
336     break;
337   case MVT::i64:
338     MF.addLiveOut(X86::EAX);
339     MF.addLiveOut(X86::EDX);
340     break;
341   case MVT::f32:
342   case MVT::f64:
343     MF.addLiveOut(X86::ST0);
344     break;
345   }
346   return ArgValues;
347 }
348
349 std::pair<SDOperand, SDOperand>
350 X86TargetLowering::LowerCCCCallTo(SDOperand Chain, const Type *RetTy,
351                                   bool isVarArg, bool isTailCall,
352                                   SDOperand Callee, ArgListTy &Args,
353                                   SelectionDAG &DAG) {
354   // Count how many bytes are to be pushed on the stack.
355   unsigned NumBytes = 0;
356
357   if (Args.empty()) {
358     // Save zero bytes.
359     Chain = DAG.getNode(ISD::CALLSEQ_START, MVT::Other, Chain,
360                         DAG.getConstant(0, getPointerTy()));
361   } else {
362     for (unsigned i = 0, e = Args.size(); i != e; ++i)
363       switch (getValueType(Args[i].second)) {
364       default: assert(0 && "Unknown value type!");
365       case MVT::i1:
366       case MVT::i8:
367       case MVT::i16:
368       case MVT::i32:
369       case MVT::f32:
370         NumBytes += 4;
371         break;
372       case MVT::i64:
373       case MVT::f64:
374         NumBytes += 8;
375         break;
376       }
377
378     Chain = DAG.getNode(ISD::CALLSEQ_START, MVT::Other, Chain,
379                         DAG.getConstant(NumBytes, getPointerTy()));
380
381     // Arguments go on the stack in reverse order, as specified by the ABI.
382     unsigned ArgOffset = 0;
383     SDOperand StackPtr = DAG.getCopyFromReg(DAG.getEntryNode(),
384                                             X86::ESP, MVT::i32);
385     std::vector<SDOperand> Stores;
386
387     for (unsigned i = 0, e = Args.size(); i != e; ++i) {
388       SDOperand PtrOff = DAG.getConstant(ArgOffset, getPointerTy());
389       PtrOff = DAG.getNode(ISD::ADD, MVT::i32, StackPtr, PtrOff);
390
391       switch (getValueType(Args[i].second)) {
392       default: assert(0 && "Unexpected ValueType for argument!");
393       case MVT::i1:
394       case MVT::i8:
395       case MVT::i16:
396         // Promote the integer to 32 bits.  If the input type is signed use a
397         // sign extend, otherwise use a zero extend.
398         if (Args[i].second->isSigned())
399           Args[i].first =DAG.getNode(ISD::SIGN_EXTEND, MVT::i32, Args[i].first);
400         else
401           Args[i].first =DAG.getNode(ISD::ZERO_EXTEND, MVT::i32, Args[i].first);
402
403         // FALL THROUGH
404       case MVT::i32:
405       case MVT::f32:
406         Stores.push_back(DAG.getNode(ISD::STORE, MVT::Other, Chain,
407                                      Args[i].first, PtrOff,
408                                      DAG.getSrcValue(NULL)));
409         ArgOffset += 4;
410         break;
411       case MVT::i64:
412       case MVT::f64:
413         Stores.push_back(DAG.getNode(ISD::STORE, MVT::Other, Chain,
414                                      Args[i].first, PtrOff,
415                                      DAG.getSrcValue(NULL)));
416         ArgOffset += 8;
417         break;
418       }
419     }
420     Chain = DAG.getNode(ISD::TokenFactor, MVT::Other, Stores);
421   }
422
423   std::vector<MVT::ValueType> RetVals;
424   MVT::ValueType RetTyVT = getValueType(RetTy);
425   RetVals.push_back(MVT::Other);
426
427   // The result values produced have to be legal.  Promote the result.
428   switch (RetTyVT) {
429   case MVT::isVoid: break;
430   default:
431     RetVals.push_back(RetTyVT);
432     break;
433   case MVT::i1:
434   case MVT::i8:
435   case MVT::i16:
436     RetVals.push_back(MVT::i32);
437     break;
438   case MVT::f32:
439     if (X86ScalarSSE)
440       RetVals.push_back(MVT::f32);
441     else
442       RetVals.push_back(MVT::f64);
443     break;
444   case MVT::i64:
445     RetVals.push_back(MVT::i32);
446     RetVals.push_back(MVT::i32);
447     break;
448   }
449   std::vector<SDOperand> Ops;
450   Ops.push_back(Chain);
451   Ops.push_back(Callee);
452   Ops.push_back(DAG.getConstant(NumBytes, getPointerTy()));
453   Ops.push_back(DAG.getConstant(0, getPointerTy()));
454   SDOperand TheCall = DAG.getNode(isTailCall ? X86ISD::TAILCALL : X86ISD::CALL,
455                                   RetVals, Ops);
456   Chain = DAG.getNode(ISD::CALLSEQ_END, MVT::Other, TheCall);
457
458   SDOperand ResultVal;
459   switch (RetTyVT) {
460   case MVT::isVoid: break;
461   default:
462     ResultVal = TheCall.getValue(1);
463     break;
464   case MVT::i1:
465   case MVT::i8:
466   case MVT::i16:
467     ResultVal = DAG.getNode(ISD::TRUNCATE, RetTyVT, TheCall.getValue(1));
468     break;
469   case MVT::f32:
470     // FIXME: we would really like to remember that this FP_ROUND operation is
471     // okay to eliminate if we allow excess FP precision.
472     ResultVal = DAG.getNode(ISD::FP_ROUND, MVT::f32, TheCall.getValue(1));
473     break;
474   case MVT::i64:
475     ResultVal = DAG.getNode(ISD::BUILD_PAIR, MVT::i64, TheCall.getValue(1),
476                             TheCall.getValue(2));
477     break;
478   }
479
480   return std::make_pair(ResultVal, Chain);
481 }
482
483 SDOperand
484 X86TargetLowering::LowerVAStart(SDOperand Chain, SDOperand VAListP,
485                                 Value *VAListV, SelectionDAG &DAG) {
486   // vastart just stores the address of the VarArgsFrameIndex slot.
487   SDOperand FR = DAG.getFrameIndex(VarArgsFrameIndex, MVT::i32);
488   return DAG.getNode(ISD::STORE, MVT::Other, Chain, FR, VAListP,
489                      DAG.getSrcValue(VAListV));
490 }
491
492
493 std::pair<SDOperand,SDOperand>
494 X86TargetLowering::LowerVAArg(SDOperand Chain, SDOperand VAListP,
495                               Value *VAListV, const Type *ArgTy,
496                               SelectionDAG &DAG) {
497   MVT::ValueType ArgVT = getValueType(ArgTy);
498   SDOperand Val = DAG.getLoad(MVT::i32, Chain,
499                               VAListP, DAG.getSrcValue(VAListV));
500   SDOperand Result = DAG.getLoad(ArgVT, Chain, Val,
501                                  DAG.getSrcValue(NULL));
502   unsigned Amt;
503   if (ArgVT == MVT::i32)
504     Amt = 4;
505   else {
506     assert((ArgVT == MVT::i64 || ArgVT == MVT::f64) &&
507            "Other types should have been promoted for varargs!");
508     Amt = 8;
509   }
510   Val = DAG.getNode(ISD::ADD, Val.getValueType(), Val,
511                     DAG.getConstant(Amt, Val.getValueType()));
512   Chain = DAG.getNode(ISD::STORE, MVT::Other, Chain,
513                       Val, VAListP, DAG.getSrcValue(VAListV));
514   return std::make_pair(Result, Chain);
515 }
516
517 //===----------------------------------------------------------------------===//
518 //                    Fast Calling Convention implementation
519 //===----------------------------------------------------------------------===//
520 //
521 // The X86 'fast' calling convention passes up to two integer arguments in
522 // registers (an appropriate portion of EAX/EDX), passes arguments in C order,
523 // and requires that the callee pop its arguments off the stack (allowing proper
524 // tail calls), and has the same return value conventions as C calling convs.
525 //
526 // This calling convention always arranges for the callee pop value to be 8n+4
527 // bytes, which is needed for tail recursion elimination and stack alignment
528 // reasons.
529 //
530 // Note that this can be enhanced in the future to pass fp vals in registers
531 // (when we have a global fp allocator) and do other tricks.
532 //
533
534 /// AddLiveIn - This helper function adds the specified physical register to the
535 /// MachineFunction as a live in value.  It also creates a corresponding virtual
536 /// register for it.
537 static unsigned AddLiveIn(MachineFunction &MF, unsigned PReg,
538                           TargetRegisterClass *RC) {
539   assert(RC->contains(PReg) && "Not the correct regclass!");
540   unsigned VReg = MF.getSSARegMap()->createVirtualRegister(RC);
541   MF.addLiveIn(PReg, VReg);
542   return VReg;
543 }
544
545
546 std::vector<SDOperand>
547 X86TargetLowering::LowerFastCCArguments(Function &F, SelectionDAG &DAG) {
548   std::vector<SDOperand> ArgValues;
549
550   MachineFunction &MF = DAG.getMachineFunction();
551   MachineFrameInfo *MFI = MF.getFrameInfo();
552
553   // Add DAG nodes to load the arguments...  On entry to a function the stack
554   // frame looks like this:
555   //
556   // [ESP] -- return address
557   // [ESP + 4] -- first nonreg argument (leftmost lexically)
558   // [ESP + 8] -- second nonreg argument, if first argument is 4 bytes in size
559   //    ...
560   unsigned ArgOffset = 0;   // Frame mechanisms handle retaddr slot
561
562   // Keep track of the number of integer regs passed so far.  This can be either
563   // 0 (neither EAX or EDX used), 1 (EAX is used) or 2 (EAX and EDX are both
564   // used).
565   unsigned NumIntRegs = 0;
566
567   for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I) {
568     MVT::ValueType ObjectVT = getValueType(I->getType());
569     unsigned ArgIncrement = 4;
570     unsigned ObjSize = 0;
571     SDOperand ArgValue;
572
573     switch (ObjectVT) {
574     default: assert(0 && "Unhandled argument type!");
575     case MVT::i1:
576     case MVT::i8:
577       if (NumIntRegs < 2) {
578         if (!I->use_empty()) {
579           unsigned VReg = AddLiveIn(MF, NumIntRegs ? X86::DL : X86::AL,
580                                     X86::R8RegisterClass);
581           ArgValue = DAG.getCopyFromReg(DAG.getRoot(), VReg, MVT::i8);
582           DAG.setRoot(ArgValue.getValue(1));
583         }
584         ++NumIntRegs;
585         break;
586       }
587
588       ObjSize = 1;
589       break;
590     case MVT::i16:
591       if (NumIntRegs < 2) {
592         if (!I->use_empty()) {
593           unsigned VReg = AddLiveIn(MF, NumIntRegs ? X86::DX : X86::AX,
594                                     X86::R16RegisterClass);
595           ArgValue = DAG.getCopyFromReg(DAG.getRoot(), VReg, MVT::i16);
596           DAG.setRoot(ArgValue.getValue(1));
597         }
598         ++NumIntRegs;
599         break;
600       }
601       ObjSize = 2;
602       break;
603     case MVT::i32:
604       if (NumIntRegs < 2) {
605         if (!I->use_empty()) {
606           unsigned VReg = AddLiveIn(MF,NumIntRegs ? X86::EDX : X86::EAX,
607                                     X86::R32RegisterClass);
608           ArgValue = DAG.getCopyFromReg(DAG.getRoot(), VReg, MVT::i32);
609           DAG.setRoot(ArgValue.getValue(1));
610         }
611         ++NumIntRegs;
612         break;
613       }
614       ObjSize = 4;
615       break;
616     case MVT::i64:
617       if (NumIntRegs == 0) {
618         if (!I->use_empty()) {
619           unsigned BotReg = AddLiveIn(MF, X86::EAX, X86::R32RegisterClass);
620           unsigned TopReg = AddLiveIn(MF, X86::EDX, X86::R32RegisterClass);
621
622           SDOperand Low = DAG.getCopyFromReg(DAG.getRoot(), BotReg, MVT::i32);
623           SDOperand Hi  = DAG.getCopyFromReg(Low.getValue(1), TopReg, MVT::i32);
624           DAG.setRoot(Hi.getValue(1));
625
626           ArgValue = DAG.getNode(ISD::BUILD_PAIR, MVT::i64, Low, Hi);
627         }
628         NumIntRegs = 2;
629         break;
630       } else if (NumIntRegs == 1) {
631         if (!I->use_empty()) {
632           unsigned BotReg = AddLiveIn(MF, X86::EDX, X86::R32RegisterClass);
633           SDOperand Low = DAG.getCopyFromReg(DAG.getRoot(), BotReg, MVT::i32);
634           DAG.setRoot(Low.getValue(1));
635
636           // Load the high part from memory.
637           // Create the frame index object for this incoming parameter...
638           int FI = MFI->CreateFixedObject(4, ArgOffset);
639           SDOperand FIN = DAG.getFrameIndex(FI, MVT::i32);
640           SDOperand Hi = DAG.getLoad(MVT::i32, DAG.getEntryNode(), FIN,
641                                      DAG.getSrcValue(NULL));
642           ArgValue = DAG.getNode(ISD::BUILD_PAIR, MVT::i64, Low, Hi);
643         }
644         ArgOffset += 4;
645         NumIntRegs = 2;
646         break;
647       }
648       ObjSize = ArgIncrement = 8;
649       break;
650     case MVT::f32: ObjSize = 4;                break;
651     case MVT::f64: ObjSize = ArgIncrement = 8; break;
652     }
653
654     // Don't codegen dead arguments.  FIXME: remove this check when we can nuke
655     // dead loads.
656     if (ObjSize && !I->use_empty()) {
657       // Create the frame index object for this incoming parameter...
658       int FI = MFI->CreateFixedObject(ObjSize, ArgOffset);
659
660       // Create the SelectionDAG nodes corresponding to a load from this
661       // parameter.
662       SDOperand FIN = DAG.getFrameIndex(FI, MVT::i32);
663
664       ArgValue = DAG.getLoad(ObjectVT, DAG.getEntryNode(), FIN,
665                              DAG.getSrcValue(NULL));
666     } else if (ArgValue.Val == 0) {
667       if (MVT::isInteger(ObjectVT))
668         ArgValue = DAG.getConstant(0, ObjectVT);
669       else
670         ArgValue = DAG.getConstantFP(0, ObjectVT);
671     }
672     ArgValues.push_back(ArgValue);
673
674     if (ObjSize)
675       ArgOffset += ArgIncrement;   // Move on to the next argument.
676   }
677
678   // Make sure the instruction takes 8n+4 bytes to make sure the start of the
679   // arguments and the arguments after the retaddr has been pushed are aligned.
680   if ((ArgOffset & 7) == 0)
681     ArgOffset += 4;
682
683   VarArgsFrameIndex = 0xAAAAAAA;   // fastcc functions can't have varargs.
684   ReturnAddrIndex = 0;             // No return address slot generated yet.
685   BytesToPopOnReturn = ArgOffset;  // Callee pops all stack arguments.
686   BytesCallerReserves = 0;
687
688   // Finally, inform the code generator which regs we return values in.
689   switch (getValueType(F.getReturnType())) {
690   default: assert(0 && "Unknown type!");
691   case MVT::isVoid: break;
692   case MVT::i1:
693   case MVT::i8:
694   case MVT::i16:
695   case MVT::i32:
696     MF.addLiveOut(X86::EAX);
697     break;
698   case MVT::i64:
699     MF.addLiveOut(X86::EAX);
700     MF.addLiveOut(X86::EDX);
701     break;
702   case MVT::f32:
703   case MVT::f64:
704     MF.addLiveOut(X86::ST0);
705     break;
706   }
707   return ArgValues;
708 }
709
710 std::pair<SDOperand, SDOperand>
711 X86TargetLowering::LowerFastCCCallTo(SDOperand Chain, const Type *RetTy,
712                                      bool isTailCall, SDOperand Callee,
713                                      ArgListTy &Args, SelectionDAG &DAG) {
714   // Count how many bytes are to be pushed on the stack.
715   unsigned NumBytes = 0;
716
717   // Keep track of the number of integer regs passed so far.  This can be either
718   // 0 (neither EAX or EDX used), 1 (EAX is used) or 2 (EAX and EDX are both
719   // used).
720   unsigned NumIntRegs = 0;
721
722   for (unsigned i = 0, e = Args.size(); i != e; ++i)
723     switch (getValueType(Args[i].second)) {
724     default: assert(0 && "Unknown value type!");
725     case MVT::i1:
726     case MVT::i8:
727     case MVT::i16:
728     case MVT::i32:
729       if (NumIntRegs < 2) {
730         ++NumIntRegs;
731         break;
732       }
733       // fall through
734     case MVT::f32:
735       NumBytes += 4;
736       break;
737     case MVT::i64:
738       if (NumIntRegs == 0) {
739         NumIntRegs = 2;
740         break;
741       } else if (NumIntRegs == 1) {
742         NumIntRegs = 2;
743         NumBytes += 4;
744         break;
745       }
746
747       // fall through
748     case MVT::f64:
749       NumBytes += 8;
750       break;
751     }
752
753   // Make sure the instruction takes 8n+4 bytes to make sure the start of the
754   // arguments and the arguments after the retaddr has been pushed are aligned.
755   if ((NumBytes & 7) == 0)
756     NumBytes += 4;
757
758   Chain = DAG.getNode(ISD::CALLSEQ_START, MVT::Other, Chain,
759                       DAG.getConstant(NumBytes, getPointerTy()));
760
761   // Arguments go on the stack in reverse order, as specified by the ABI.
762   unsigned ArgOffset = 0;
763   SDOperand StackPtr = DAG.getCopyFromReg(DAG.getEntryNode(),
764                                           X86::ESP, MVT::i32);
765   NumIntRegs = 0;
766   std::vector<SDOperand> Stores;
767   std::vector<SDOperand> RegValuesToPass;
768   for (unsigned i = 0, e = Args.size(); i != e; ++i) {
769     switch (getValueType(Args[i].second)) {
770     default: assert(0 && "Unexpected ValueType for argument!");
771     case MVT::i1:
772     case MVT::i8:
773     case MVT::i16:
774     case MVT::i32:
775       if (NumIntRegs < 2) {
776         RegValuesToPass.push_back(Args[i].first);
777         ++NumIntRegs;
778         break;
779       }
780       // Fall through
781     case MVT::f32: {
782       SDOperand PtrOff = DAG.getConstant(ArgOffset, getPointerTy());
783       PtrOff = DAG.getNode(ISD::ADD, MVT::i32, StackPtr, PtrOff);
784       Stores.push_back(DAG.getNode(ISD::STORE, MVT::Other, Chain,
785                                    Args[i].first, PtrOff,
786                                    DAG.getSrcValue(NULL)));
787       ArgOffset += 4;
788       break;
789     }
790     case MVT::i64:
791       if (NumIntRegs < 2) {    // Can pass part of it in regs?
792         SDOperand Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, MVT::i32,
793                                    Args[i].first, DAG.getConstant(1, MVT::i32));
794         SDOperand Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, MVT::i32,
795                                    Args[i].first, DAG.getConstant(0, MVT::i32));
796         RegValuesToPass.push_back(Lo);
797         ++NumIntRegs;
798         if (NumIntRegs < 2) {   // Pass both parts in regs?
799           RegValuesToPass.push_back(Hi);
800           ++NumIntRegs;
801         } else {
802           // Pass the high part in memory.
803           SDOperand PtrOff = DAG.getConstant(ArgOffset, getPointerTy());
804           PtrOff = DAG.getNode(ISD::ADD, MVT::i32, StackPtr, PtrOff);
805           Stores.push_back(DAG.getNode(ISD::STORE, MVT::Other, Chain,
806                                        Hi, PtrOff, DAG.getSrcValue(NULL)));
807           ArgOffset += 4;
808         }
809         break;
810       }
811       // Fall through
812     case MVT::f64:
813       SDOperand PtrOff = DAG.getConstant(ArgOffset, getPointerTy());
814       PtrOff = DAG.getNode(ISD::ADD, MVT::i32, StackPtr, PtrOff);
815       Stores.push_back(DAG.getNode(ISD::STORE, MVT::Other, Chain,
816                                    Args[i].first, PtrOff,
817                                    DAG.getSrcValue(NULL)));
818       ArgOffset += 8;
819       break;
820     }
821   }
822   if (!Stores.empty())
823     Chain = DAG.getNode(ISD::TokenFactor, MVT::Other, Stores);
824
825   // Make sure the instruction takes 8n+4 bytes to make sure the start of the
826   // arguments and the arguments after the retaddr has been pushed are aligned.
827   if ((ArgOffset & 7) == 0)
828     ArgOffset += 4;
829
830   std::vector<MVT::ValueType> RetVals;
831   MVT::ValueType RetTyVT = getValueType(RetTy);
832
833   RetVals.push_back(MVT::Other);
834
835   // The result values produced have to be legal.  Promote the result.
836   switch (RetTyVT) {
837   case MVT::isVoid: break;
838   default:
839     RetVals.push_back(RetTyVT);
840     break;
841   case MVT::i1:
842   case MVT::i8:
843   case MVT::i16:
844     RetVals.push_back(MVT::i32);
845     break;
846   case MVT::f32:
847     if (X86ScalarSSE)
848       RetVals.push_back(MVT::f32);
849     else
850       RetVals.push_back(MVT::f64);
851     break;
852   case MVT::i64:
853     RetVals.push_back(MVT::i32);
854     RetVals.push_back(MVT::i32);
855     break;
856   }
857
858   std::vector<SDOperand> Ops;
859   Ops.push_back(Chain);
860   Ops.push_back(Callee);
861   Ops.push_back(DAG.getConstant(ArgOffset, getPointerTy()));
862   // Callee pops all arg values on the stack.
863   Ops.push_back(DAG.getConstant(ArgOffset, getPointerTy()));
864
865   // Pass register arguments as needed.
866   Ops.insert(Ops.end(), RegValuesToPass.begin(), RegValuesToPass.end());
867
868   SDOperand TheCall = DAG.getNode(isTailCall ? X86ISD::TAILCALL : X86ISD::CALL,
869                                   RetVals, Ops);
870   Chain = DAG.getNode(ISD::CALLSEQ_END, MVT::Other, TheCall);
871
872   SDOperand ResultVal;
873   switch (RetTyVT) {
874   case MVT::isVoid: break;
875   default:
876     ResultVal = TheCall.getValue(1);
877     break;
878   case MVT::i1:
879   case MVT::i8:
880   case MVT::i16:
881     ResultVal = DAG.getNode(ISD::TRUNCATE, RetTyVT, TheCall.getValue(1));
882     break;
883   case MVT::f32:
884     // FIXME: we would really like to remember that this FP_ROUND operation is
885     // okay to eliminate if we allow excess FP precision.
886     ResultVal = DAG.getNode(ISD::FP_ROUND, MVT::f32, TheCall.getValue(1));
887     break;
888   case MVT::i64:
889     ResultVal = DAG.getNode(ISD::BUILD_PAIR, MVT::i64, TheCall.getValue(1),
890                             TheCall.getValue(2));
891     break;
892   }
893
894   return std::make_pair(ResultVal, Chain);
895 }
896
897 SDOperand X86TargetLowering::getReturnAddressFrameIndex(SelectionDAG &DAG) {
898   if (ReturnAddrIndex == 0) {
899     // Set up a frame object for the return address.
900     MachineFunction &MF = DAG.getMachineFunction();
901     ReturnAddrIndex = MF.getFrameInfo()->CreateFixedObject(4, -4);
902   }
903
904   return DAG.getFrameIndex(ReturnAddrIndex, MVT::i32);
905 }
906
907
908
909 std::pair<SDOperand, SDOperand> X86TargetLowering::
910 LowerFrameReturnAddress(bool isFrameAddress, SDOperand Chain, unsigned Depth,
911                         SelectionDAG &DAG) {
912   SDOperand Result;
913   if (Depth)        // Depths > 0 not supported yet!
914     Result = DAG.getConstant(0, getPointerTy());
915   else {
916     SDOperand RetAddrFI = getReturnAddressFrameIndex(DAG);
917     if (!isFrameAddress)
918       // Just load the return address
919       Result = DAG.getLoad(MVT::i32, DAG.getEntryNode(), RetAddrFI,
920                            DAG.getSrcValue(NULL));
921     else
922       Result = DAG.getNode(ISD::SUB, MVT::i32, RetAddrFI,
923                            DAG.getConstant(4, MVT::i32));
924   }
925   return std::make_pair(Result, Chain);
926 }
927
928 //===----------------------------------------------------------------------===//
929 //                           X86 Custom Lowering Hooks
930 //===----------------------------------------------------------------------===//
931
932 /// LowerOperation - Provide custom lowering hooks for some operations.
933 ///
934 SDOperand X86TargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
935   switch (Op.getOpcode()) {
936   default: assert(0 && "Should not custom lower this!");
937   case ISD::SINT_TO_FP: {
938     assert(Op.getValueType() == MVT::f64 &&
939            Op.getOperand(0).getValueType() == MVT::i64 &&
940            "Unknown SINT_TO_FP to lower!");
941     // We lower sint64->FP into a store to a temporary stack slot, followed by a
942     // FILD64m node.
943     MachineFunction &MF = DAG.getMachineFunction();
944     int SSFI = MF.getFrameInfo()->CreateStackObject(8, 8);
945     SDOperand StackSlot = DAG.getFrameIndex(SSFI, getPointerTy());
946     SDOperand Store = DAG.getNode(ISD::STORE, MVT::Other, DAG.getEntryNode(),
947                            Op.getOperand(0), StackSlot, DAG.getSrcValue(NULL));
948     std::vector<MVT::ValueType> RTs;
949     RTs.push_back(MVT::f64);
950     RTs.push_back(MVT::Other);
951     std::vector<SDOperand> Ops;
952     Ops.push_back(Store);
953     Ops.push_back(StackSlot);
954     return DAG.getNode(X86ISD::FILD64m, RTs, Ops);
955   }
956   case ISD::FP_TO_SINT: {
957     assert(Op.getValueType() <= MVT::i64 && Op.getValueType() >= MVT::i16 &&
958            Op.getOperand(0).getValueType() == MVT::f64 &&
959            "Unknown FP_TO_SINT to lower!");
960     // We lower FP->sint64 into FISTP64, followed by a load, all to a temporary
961     // stack slot.
962     MachineFunction &MF = DAG.getMachineFunction();
963     unsigned MemSize = MVT::getSizeInBits(Op.getValueType())/8;
964     int SSFI = MF.getFrameInfo()->CreateStackObject(MemSize, MemSize);
965     SDOperand StackSlot = DAG.getFrameIndex(SSFI, getPointerTy());
966
967     unsigned Opc;
968     switch (Op.getValueType()) {
969     default: assert(0 && "Invalid FP_TO_SINT to lower!");
970     case MVT::i16: Opc = X86ISD::FP_TO_INT16_IN_MEM; break;
971     case MVT::i32: Opc = X86ISD::FP_TO_INT32_IN_MEM; break;
972     case MVT::i64: Opc = X86ISD::FP_TO_INT64_IN_MEM; break;
973     }
974
975     // Build the FP_TO_INT*_IN_MEM
976     std::vector<SDOperand> Ops;
977     Ops.push_back(DAG.getEntryNode());
978     Ops.push_back(Op.getOperand(0));
979     Ops.push_back(StackSlot);
980     SDOperand FIST = DAG.getNode(Opc, MVT::Other, Ops);
981
982     // Load the result.
983     return DAG.getLoad(Op.getValueType(), FIST, StackSlot,
984                        DAG.getSrcValue(NULL));
985   }
986   case ISD::READCYCLECOUNTER: {
987     std::vector<MVT::ValueType> Tys;
988     Tys.push_back(MVT::Other);
989     Tys.push_back(MVT::Flag);
990     std::vector<SDOperand> Ops;
991     Ops.push_back(Op.getOperand(0));
992     SDOperand rd = DAG.getNode(X86ISD::RDTSC_DAG, Tys, Ops);
993     Ops.clear();
994     Ops.push_back(DAG.getCopyFromReg(rd, X86::EAX, MVT::i32, rd.getValue(1)));
995     Ops.push_back(DAG.getCopyFromReg(Ops[0].getValue(1), X86::EDX, 
996                                      MVT::i32, Ops[0].getValue(2)));
997     Ops.push_back(Ops[1].getValue(1));
998     Tys[0] = Tys[1] = MVT::i32;
999     Tys.push_back(MVT::Other);
1000     return DAG.getNode(ISD::MERGE_VALUES, Tys, Ops);
1001   }
1002   case ISD::SELECT: {
1003     SDOperand Cond  = Op.getOperand(0);
1004     SDOperand CC;
1005     if (Cond.getOpcode() == ISD::SETCC) {
1006       CC = Cond.getOperand(2);
1007       Cond = DAG.getNode(X86ISD::CMP, MVT::Flag,
1008                          Cond.getOperand(0), Cond.getOperand(1));
1009     } else {
1010       CC = DAG.getCondCode(ISD::SETEQ);
1011       Cond = DAG.getNode(X86ISD::TEST, MVT::Flag, Cond, Cond);
1012     }
1013     return DAG.getNode(X86ISD::CMOV, Op.getValueType(),
1014                        Op.getOperand(1), Op.getOperand(2), CC, Cond);
1015   }
1016   case ISD::BRCOND: {
1017     SDOperand Chain = Op.getOperand(0);
1018     SDOperand Cond  = Op.getOperand(1);
1019     SDOperand Dest  = Op.getOperand(2);
1020     SDOperand CC;
1021     // TODO: handle Cond == OR / AND / XOR
1022     if (Cond.getOpcode() == ISD::SETCC) {
1023       CC = Cond.getOperand(2);
1024       Cond = DAG.getNode(X86ISD::CMP, MVT::Flag,
1025                          Cond.getOperand(0), Cond.getOperand(1));
1026     } else {
1027       CC = DAG.getCondCode(ISD::SETNE);
1028       Cond = DAG.getNode(X86ISD::TEST, MVT::Flag, Cond, Cond);
1029     }
1030     return DAG.getNode(X86ISD::BRCOND, Op.getValueType(),
1031                        Op.getOperand(0), Op.getOperand(2), CC, Cond);
1032   }
1033   case ISD::GlobalAddress:
1034     GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
1035     // For Darwin, external and weak symbols are indirect, so we want to load
1036     // the value at address GV, not the value of GV itself.  This means that
1037     // the GlobalAddress must be in the base or index register of the address,
1038     // not the GV offset field.
1039     if (getTargetMachine().
1040         getSubtarget<X86Subtarget>().getIndirectExternAndWeakGlobals() &&
1041         (GV->hasWeakLinkage() || GV->isExternal()))
1042       return DAG.getLoad(MVT::i32, DAG.getEntryNode(), Op,
1043                          DAG.getSrcValue(NULL));
1044     else
1045       return Op;
1046     break;
1047   }
1048 }
1049
1050 const char *X86TargetLowering::getTargetNodeName(unsigned Opcode) const {
1051   switch (Opcode) {
1052   default: return NULL;
1053   case X86ISD::FILD64m:            return "X86ISD::FILD64m";
1054   case X86ISD::FP_TO_INT16_IN_MEM: return "X86ISD::FP_TO_INT16_IN_MEM";
1055   case X86ISD::FP_TO_INT32_IN_MEM: return "X86ISD::FP_TO_INT32_IN_MEM";
1056   case X86ISD::FP_TO_INT64_IN_MEM: return "X86ISD::FP_TO_INT64_IN_MEM";
1057   case X86ISD::FLD:                return "X86ISD::FLD";
1058   case X86ISD::FP_SET_RESULT:      return "X86ISD::FP_SET_RESULT";
1059   case X86ISD::CALL:               return "X86ISD::CALL";
1060   case X86ISD::TAILCALL:           return "X86ISD::TAILCALL";
1061   case X86ISD::RDTSC_DAG:          return "X86ISD::RDTSC_DAG";
1062   case X86ISD::CMP:                return "X86ISD::CMP";
1063   case X86ISD::TEST:               return "X86ISD::TEST";
1064   case X86ISD::CMOV:               return "X86ISD::CMOV";
1065   case X86ISD::BRCOND:             return "X86ISD::BRCOND";
1066   case X86ISD::RET_FLAG:           return "X86ISD::RET_FLAG";
1067   }
1068 }