[XCore] Make LowerCallResult a static function.
[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 "XCore.h"
19 #include "llvm/CodeGen/SelectionDAG.h"
20 #include "llvm/Target/TargetLowering.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,
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       // Corresponds to LMUL instruction
58       LMUL,
59
60       // Corresponds to MACCU instruction
61       MACCU,
62
63       // Corresponds to MACCS instruction
64       MACCS,
65
66       // Corresponds to CRC8 instruction
67       CRC8,
68
69       // Jumptable branch.
70       BR_JT,
71
72       // Jumptable branch using long branches for each entry.
73       BR_JT32,
74
75       // Offset from frame pointer to the first (possible) on-stack argument
76       FRAME_TO_ARGS_OFFSET,
77
78       // Exception handler return. The stack is restored to the first
79       // followed by a jump to the second argument.
80       EH_RETURN,
81
82       // Memory barrier.
83       MEMBARRIER
84     };
85   }
86
87   //===--------------------------------------------------------------------===//
88   // TargetLowering Implementation
89   //===--------------------------------------------------------------------===//
90   class XCoreTargetLowering : public TargetLowering
91   {
92   public:
93
94     explicit XCoreTargetLowering(XCoreTargetMachine &TM);
95
96     using TargetLowering::isZExtFree;
97     virtual bool isZExtFree(SDValue Val, EVT VT2) const;
98
99
100     virtual unsigned getJumpTableEncoding() const;
101     virtual MVT getScalarShiftAmountTy(EVT LHSTy) const { return MVT::i32; }
102
103     /// LowerOperation - Provide custom lowering hooks for some operations.
104     virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
105
106     /// ReplaceNodeResults - Replace the results of node with an illegal result
107     /// type with new values built out of custom code.
108     ///
109     virtual void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results,
110                                     SelectionDAG &DAG) const;
111
112     /// getTargetNodeName - This method returns the name of a target specific
113     //  DAG node.
114     virtual const char *getTargetNodeName(unsigned Opcode) const;
115
116     virtual MachineBasicBlock *
117       EmitInstrWithCustomInserter(MachineInstr *MI,
118                                   MachineBasicBlock *MBB) const;
119
120     virtual bool isLegalAddressingMode(const AddrMode &AM,
121                                        Type *Ty) const;
122
123   private:
124     const XCoreTargetMachine &TM;
125     const XCoreSubtarget &Subtarget;
126
127     // Lower Operand helpers
128     SDValue LowerCCCArguments(SDValue Chain,
129                               CallingConv::ID CallConv,
130                               bool isVarArg,
131                               const SmallVectorImpl<ISD::InputArg> &Ins,
132                               SDLoc dl, SelectionDAG &DAG,
133                               SmallVectorImpl<SDValue> &InVals) const;
134     SDValue LowerCCCCallTo(SDValue Chain, SDValue Callee,
135                            CallingConv::ID CallConv, bool isVarArg,
136                            bool isTailCall,
137                            const SmallVectorImpl<ISD::OutputArg> &Outs,
138                            const SmallVectorImpl<SDValue> &OutVals,
139                            const SmallVectorImpl<ISD::InputArg> &Ins,
140                            SDLoc dl, SelectionDAG &DAG,
141                            SmallVectorImpl<SDValue> &InVals) const;
142     SDValue getReturnAddressFrameIndex(SelectionDAG &DAG) const;
143     SDValue getGlobalAddressWrapper(SDValue GA, const GlobalValue *GV,
144                                     SelectionDAG &DAG) const;
145     SDValue lowerLoadWordFromAlignedBasePlusOffset(SDLoc DL, SDValue Chain,
146                                                    SDValue Base, int64_t Offset,
147                                                    SelectionDAG &DAG) const;
148
149     // Lower Operand specifics
150     SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const;
151     SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
152     SDValue LowerEH_RETURN(SDValue Op, SelectionDAG &DAG) const;
153     SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
154     SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
155     SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
156     SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
157     SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
158     SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
159     SDValue LowerVAARG(SDValue Op, SelectionDAG &DAG) const;
160     SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
161     SDValue LowerUMUL_LOHI(SDValue Op, SelectionDAG &DAG) const;
162     SDValue LowerSMUL_LOHI(SDValue Op, SelectionDAG &DAG) const;
163     SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
164     SDValue LowerFRAME_TO_ARGS_OFFSET(SDValue Op, SelectionDAG &DAG) const;
165     SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
166     SDValue LowerINIT_TRAMPOLINE(SDValue Op, SelectionDAG &DAG) const;
167     SDValue LowerADJUST_TRAMPOLINE(SDValue Op, SelectionDAG &DAG) const;
168     SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
169     SDValue LowerATOMIC_FENCE(SDValue Op, SelectionDAG &DAG) const;
170     SDValue LowerATOMIC_LOAD(SDValue Op, SelectionDAG &DAG) const;
171     SDValue LowerATOMIC_STORE(SDValue Op, SelectionDAG &DAG) const;
172
173     // Inline asm support
174     std::pair<unsigned, const TargetRegisterClass*>
175     getRegForInlineAsmConstraint(const std::string &Constraint,
176                                  MVT VT) const;
177
178     // Expand specifics
179     SDValue TryExpandADDWithMul(SDNode *Op, SelectionDAG &DAG) const;
180     SDValue ExpandADDSUB(SDNode *Op, SelectionDAG &DAG) const;
181
182     virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
183
184     virtual void computeMaskedBitsForTargetNode(const SDValue Op,
185                                                 APInt &KnownZero,
186                                                 APInt &KnownOne,
187                                                 const SelectionDAG &DAG,
188                                                 unsigned Depth = 0) const;
189
190     virtual SDValue
191       LowerFormalArguments(SDValue Chain,
192                            CallingConv::ID CallConv,
193                            bool isVarArg,
194                            const SmallVectorImpl<ISD::InputArg> &Ins,
195                            SDLoc dl, SelectionDAG &DAG,
196                            SmallVectorImpl<SDValue> &InVals) const;
197
198     virtual SDValue
199       LowerCall(TargetLowering::CallLoweringInfo &CLI,
200                 SmallVectorImpl<SDValue> &InVals) const;
201
202     virtual SDValue
203       LowerReturn(SDValue Chain,
204                   CallingConv::ID CallConv, bool isVarArg,
205                   const SmallVectorImpl<ISD::OutputArg> &Outs,
206                   const SmallVectorImpl<SDValue> &OutVals,
207                   SDLoc dl, SelectionDAG &DAG) const;
208
209     virtual bool
210       CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
211                      bool isVarArg,
212                      const SmallVectorImpl<ISD::OutputArg> &ArgsFlags,
213                      LLVMContext &Context) const;
214   };
215 }
216
217 #endif // XCOREISELLOWERING_H