SelectionDAG node enums for MIPS DSP nodes.
[oota-llvm.git] / lib / Target / Mips / MipsISelLowering.h
1 //===-- MipsISelLowering.h - Mips 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 Mips uses to lower LLVM code into a
11 // selection DAG.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef MipsISELLOWERING_H
16 #define MipsISELLOWERING_H
17
18 #include "Mips.h"
19 #include "MipsSubtarget.h"
20 #include "llvm/CodeGen/SelectionDAG.h"
21 #include "llvm/Target/TargetLowering.h"
22
23 namespace llvm {
24   namespace MipsISD {
25     enum NodeType {
26       // Start the numbering from where ISD NodeType finishes.
27       FIRST_NUMBER = ISD::BUILTIN_OP_END,
28
29       // Jump and link (call)
30       JmpLink,
31
32       // Get the Higher 16 bits from a 32-bit immediate
33       // No relation with Mips Hi register
34       Hi,
35
36       // Get the Lower 16 bits from a 32-bit immediate
37       // No relation with Mips Lo register
38       Lo,
39
40       // Handle gp_rel (small data/bss sections) relocation.
41       GPRel,
42
43       // Thread Pointer
44       ThreadPointer,
45
46       // Floating Point Branch Conditional
47       FPBrcond,
48
49       // Floating Point Compare
50       FPCmp,
51
52       // Floating Point Conditional Moves
53       CMovFP_T,
54       CMovFP_F,
55
56       // Floating Point Rounding
57       FPRound,
58
59       // Return
60       Ret,
61
62       // MAdd/Sub nodes
63       MAdd,
64       MAddu,
65       MSub,
66       MSubu,
67
68       // DivRem(u)
69       DivRem,
70       DivRemU,
71
72       BuildPairF64,
73       ExtractElementF64,
74
75       Wrapper,
76
77       DynAlloc,
78
79       Sync,
80
81       Ext,
82       Ins,
83
84       // EXTR.W instrinsic nodes.
85       EXTP,
86       EXTPDP,
87       EXTR_S_H,
88       EXTR_W,
89       EXTR_R_W,
90       EXTR_RS_W,
91       SHILO,
92       MTHLIP,
93
94       // DPA.W intrinsic nodes.
95       MULSAQ_S_W_PH,
96       MAQ_S_W_PHL,
97       MAQ_S_W_PHR,
98       MAQ_SA_W_PHL,
99       MAQ_SA_W_PHR,
100       DPAU_H_QBL,
101       DPAU_H_QBR,
102       DPSU_H_QBL,
103       DPSU_H_QBR,
104       DPAQ_S_W_PH,
105       DPSQ_S_W_PH,
106       DPAQ_SA_L_W,
107       DPSQ_SA_L_W,
108       DPA_W_PH,
109       DPS_W_PH,
110       DPAQX_S_W_PH,
111       DPAQX_SA_W_PH,
112       DPAX_W_PH,
113       DPSX_W_PH,
114       DPSQX_S_W_PH,
115       DPSQX_SA_W_PH,
116       MULSA_W_PH,
117
118       MULT,
119       MULTU,
120       MADD_DSP,
121       MADDU_DSP,
122       MSUB_DSP,
123       MSUBU_DSP,
124
125       // Load/Store Left/Right nodes.
126       LWL = ISD::FIRST_TARGET_MEMORY_OPCODE,
127       LWR,
128       SWL,
129       SWR,
130       LDL,
131       LDR,
132       SDL,
133       SDR
134     };
135   }
136
137   //===--------------------------------------------------------------------===//
138   // TargetLowering Implementation
139   //===--------------------------------------------------------------------===//
140
141   class MipsTargetLowering : public TargetLowering  {
142   public:
143     explicit MipsTargetLowering(MipsTargetMachine &TM);
144
145     virtual MVT getShiftAmountTy(EVT LHSTy) const { return MVT::i32; }
146
147     virtual bool allowsUnalignedMemoryAccesses (EVT VT) const;
148
149     /// LowerOperation - Provide custom lowering hooks for some operations.
150     virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
151
152     /// getTargetNodeName - This method returns the name of a target specific
153     //  DAG node.
154     virtual const char *getTargetNodeName(unsigned Opcode) const;
155
156     /// getSetCCResultType - get the ISD::SETCC result ValueType
157     EVT getSetCCResultType(EVT VT) const;
158
159     virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
160   private:
161     // Subtarget Info
162     const MipsSubtarget *Subtarget;
163
164     bool HasMips64, IsN64, IsO32;
165
166     // Lower Operand helpers
167     SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
168                             CallingConv::ID CallConv, bool isVarArg,
169                             const SmallVectorImpl<ISD::InputArg> &Ins,
170                             DebugLoc dl, SelectionDAG &DAG,
171                             SmallVectorImpl<SDValue> &InVals) const;
172
173     // Lower Operand specifics
174     SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
175     SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
176     SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
177     SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
178     SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
179     SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
180     SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const;
181     SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
182     SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const;
183     SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
184     SDValue LowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG) const;
185     SDValue LowerFABS(SDValue Op, SelectionDAG &DAG) const;
186     SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
187     SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
188     SDValue LowerMEMBARRIER(SDValue Op, SelectionDAG& DAG) const;
189     SDValue LowerATOMIC_FENCE(SDValue Op, SelectionDAG& DAG) const;
190     SDValue LowerShiftLeftParts(SDValue Op, SelectionDAG& DAG) const;
191     SDValue LowerShiftRightParts(SDValue Op, SelectionDAG& DAG,
192                                  bool IsSRA) const;
193     SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const;
194     SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
195
196     virtual SDValue
197       LowerFormalArguments(SDValue Chain,
198                            CallingConv::ID CallConv, bool isVarArg,
199                            const SmallVectorImpl<ISD::InputArg> &Ins,
200                            DebugLoc dl, SelectionDAG &DAG,
201                            SmallVectorImpl<SDValue> &InVals) const;
202
203     virtual SDValue
204       LowerCall(TargetLowering::CallLoweringInfo &CLI,
205                 SmallVectorImpl<SDValue> &InVals) const;
206
207     virtual SDValue
208       LowerReturn(SDValue Chain,
209                   CallingConv::ID CallConv, bool isVarArg,
210                   const SmallVectorImpl<ISD::OutputArg> &Outs,
211                   const SmallVectorImpl<SDValue> &OutVals,
212                   DebugLoc dl, SelectionDAG &DAG) const;
213
214     virtual MachineBasicBlock *
215       EmitInstrWithCustomInserter(MachineInstr *MI,
216                                   MachineBasicBlock *MBB) const;
217
218     // Inline asm support
219     ConstraintType getConstraintType(const std::string &Constraint) const;
220
221     /// Examine constraint string and operand type and determine a weight value.
222     /// The operand object must already have been set up with the operand type.
223     ConstraintWeight getSingleConstraintMatchWeight(
224       AsmOperandInfo &info, const char *constraint) const;
225
226     std::pair<unsigned, const TargetRegisterClass*>
227               getRegForInlineAsmConstraint(const std::string &Constraint,
228               EVT VT) const;
229
230     /// LowerAsmOperandForConstraint - Lower the specified operand into the Ops
231     /// vector.  If it is invalid, don't add anything to Ops. If hasMemory is
232     /// true it means one of the asm constraint of the inline asm instruction
233     /// being processed is 'm'.
234     virtual void LowerAsmOperandForConstraint(SDValue Op,
235                                               std::string &Constraint,
236                                               std::vector<SDValue> &Ops,
237                                               SelectionDAG &DAG) const;
238
239     virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const;
240
241     virtual EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign,
242                                     unsigned SrcAlign, bool IsZeroVal,
243                                     bool MemcpyStrSrc,
244                                     MachineFunction &MF) const;
245
246     /// isFPImmLegal - Returns true if the target can instruction select the
247     /// specified FP immediate natively. If false, the legalizer will
248     /// materialize the FP immediate as a load from a constant pool.
249     virtual bool isFPImmLegal(const APFloat &Imm, EVT VT) const;
250
251     virtual unsigned getJumpTableEncoding() const;
252
253     MachineBasicBlock *EmitAtomicBinary(MachineInstr *MI, MachineBasicBlock *BB,
254                     unsigned Size, unsigned BinOpcode, bool Nand = false) const;
255     MachineBasicBlock *EmitAtomicBinaryPartword(MachineInstr *MI,
256                     MachineBasicBlock *BB, unsigned Size, unsigned BinOpcode,
257                     bool Nand = false) const;
258     MachineBasicBlock *EmitAtomicCmpSwap(MachineInstr *MI,
259                                   MachineBasicBlock *BB, unsigned Size) const;
260     MachineBasicBlock *EmitAtomicCmpSwapPartword(MachineInstr *MI,
261                                   MachineBasicBlock *BB, unsigned Size) const;
262   };
263 }
264
265 #endif // MipsISELLOWERING_H