[XCore] Fix expansion of 64 bit add/sub. Don't custom expand
[oota-llvm.git] / lib / Target / XCore / XCoreISelLowering.h
1 //===-- XCoreISelLowering.h - XCore DAG Lowering Interface ------*- 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 defines the interfaces that XCore uses to lower LLVM code into a
11 // selection DAG.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef XCOREISELLOWERING_H
16 #define XCOREISELLOWERING_H
17
18 #include "llvm/CodeGen/SelectionDAG.h"
19 #include "llvm/Target/TargetLowering.h"
20 #include "XCore.h"
21
22 namespace llvm {
23   
24   // Forward delcarations
25   class XCoreSubtarget;
26   class XCoreTargetMachine;
27   
28   namespace XCoreISD {
29     enum NodeType {
30       // Start the numbering where the builtin ops and target ops leave off.
31       FIRST_NUMBER = ISD::BUILTIN_OP_END+XCore::INSTRUCTION_LIST_END,
32
33       // Branch and link (call)
34       BL,
35
36       // pc relative address
37       PCRelativeWrapper,
38
39       // dp relative address
40       DPRelativeWrapper,
41       
42       // cp relative address
43       CPRelativeWrapper,
44       
45       // Store word to stack
46       STWSP,
47
48       // Corresponds to retsp instruction
49       RETSP,
50       
51       // Corresponds to LADD instruction
52       LADD,
53
54       // Corresponds to LSUB instruction
55       LSUB
56     };
57   }
58
59   //===--------------------------------------------------------------------===//
60   // TargetLowering Implementation
61   //===--------------------------------------------------------------------===//
62   class XCoreTargetLowering : public TargetLowering 
63   {
64   public:
65
66     explicit XCoreTargetLowering(XCoreTargetMachine &TM);
67
68     /// LowerOperation - Provide custom lowering hooks for some operations.
69     virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG);
70
71     virtual SDNode *ReplaceNodeResults(SDNode *N, SelectionDAG &DAG);
72
73     /// getTargetNodeName - This method returns the name of a target specific 
74     //  DAG node.
75     virtual const char *getTargetNodeName(unsigned Opcode) const;
76   
77     virtual MachineBasicBlock *EmitInstrWithCustomInserter(MachineInstr *MI,
78                                                         MachineBasicBlock *MBB);
79
80     virtual bool isLegalAddressingMode(const AddrMode &AM,
81                                        const Type *Ty) const;
82
83   private:
84     const XCoreTargetMachine &TM;
85     const XCoreSubtarget &Subtarget;
86   
87     // Lower Operand helpers
88     SDValue LowerCCCArguments(SDValue Op, SelectionDAG &DAG);
89     SDValue LowerCCCCallTo(SDValue Op, SelectionDAG &DAG, unsigned CC);
90     SDNode *LowerCallResult(SDValue Chain, SDValue InFlag, CallSDNode*TheCall,
91                             unsigned CallingConv, SelectionDAG &DAG);
92     SDValue getReturnAddressFrameIndex(SelectionDAG &DAG);
93     SDValue getGlobalAddressWrapper(SDValue GA, GlobalValue *GV,
94                                     SelectionDAG &DAG);
95
96     // Lower Operand specifics
97     SDValue LowerRET(SDValue Op, SelectionDAG &DAG);
98     SDValue LowerCALL(SDValue Op, SelectionDAG &DAG);
99     SDValue LowerFORMAL_ARGUMENTS(SDValue Op, SelectionDAG &DAG);
100     SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG);
101     SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG);
102     SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG);
103     SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG);
104     SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG);
105     SDValue LowerVAARG(SDValue Op, SelectionDAG &DAG);
106     SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG);
107     SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG);
108   
109     // Inline asm support
110     std::vector<unsigned>
111     getRegClassForInlineAsmConstraint(const std::string &Constraint,
112               MVT VT) const;
113   
114     // Expand specifics
115     SDNode *ExpandADDSUB(SDNode *Op, SelectionDAG &DAG);
116   };
117 }
118
119 #endif // XCOREISELLOWERING_H