Add pass that expands pseudo instructions into target instructions after register...
[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 "llvm/CodeGen/SelectionDAG.h"
19 #include "llvm/Target/TargetLowering.h"
20 #include "Mips.h"
21 #include "MipsSubtarget.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       // Floating Point Branch Conditional
44       FPBrcond,
45
46       // Floating Point Compare
47       FPCmp,
48
49       // Floating Point Conditional Moves
50       CMovFP_T,
51       CMovFP_F,
52
53       // Floating Point Rounding
54       FPRound,
55
56       // Return
57       Ret,
58
59       // MAdd/Sub nodes
60       MAdd,
61       MAddu,
62       MSub,
63       MSubu,
64
65       // DivRem(u)
66       DivRem,
67       DivRemU,
68
69       BuildPairF64,
70       ExtractElementF64
71     };
72   }
73
74   //===--------------------------------------------------------------------===//
75   // TargetLowering Implementation
76   //===--------------------------------------------------------------------===//
77
78   class MipsTargetLowering : public TargetLowering  {
79   public:
80     explicit MipsTargetLowering(MipsTargetMachine &TM);
81
82     /// LowerOperation - Provide custom lowering hooks for some operations.
83     virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
84
85     /// getTargetNodeName - This method returns the name of a target specific
86     //  DAG node.
87     virtual const char *getTargetNodeName(unsigned Opcode) const;
88
89     /// getSetCCResultType - get the ISD::SETCC result ValueType
90     MVT::SimpleValueType getSetCCResultType(EVT VT) const;
91
92     /// getFunctionAlignment - Return the Log2 alignment of this function.
93     virtual unsigned getFunctionAlignment(const Function *F) const;
94
95     virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
96   private:
97     // Subtarget Info
98     const MipsSubtarget *Subtarget;
99
100
101     // Lower Operand helpers
102     SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
103                             CallingConv::ID CallConv, bool isVarArg,
104                             const SmallVectorImpl<ISD::InputArg> &Ins,
105                             DebugLoc dl, SelectionDAG &DAG,
106                             SmallVectorImpl<SDValue> &InVals) const;
107
108     // Lower Operand specifics
109     SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
110     SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
111     SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
112     SDValue LowerFP_TO_SINT(SDValue Op, SelectionDAG &DAG) const;
113     SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
114     SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
115     SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
116     SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
117     SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const;
118     SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
119
120     virtual SDValue
121       LowerFormalArguments(SDValue Chain,
122                            CallingConv::ID CallConv, bool isVarArg,
123                            const SmallVectorImpl<ISD::InputArg> &Ins,
124                            DebugLoc dl, SelectionDAG &DAG,
125                            SmallVectorImpl<SDValue> &InVals) const;
126
127     virtual SDValue
128       LowerCall(SDValue Chain, SDValue Callee,
129                 CallingConv::ID CallConv, bool isVarArg,
130                 bool &isTailCall,
131                 const SmallVectorImpl<ISD::OutputArg> &Outs,
132                 const SmallVectorImpl<SDValue> &OutVals,
133                 const SmallVectorImpl<ISD::InputArg> &Ins,
134                 DebugLoc dl, SelectionDAG &DAG,
135                 SmallVectorImpl<SDValue> &InVals) const;
136
137     virtual SDValue
138       LowerReturn(SDValue Chain,
139                   CallingConv::ID CallConv, bool isVarArg,
140                   const SmallVectorImpl<ISD::OutputArg> &Outs,
141                   const SmallVectorImpl<SDValue> &OutVals,
142                   DebugLoc dl, SelectionDAG &DAG) const;
143
144     virtual MachineBasicBlock *
145       EmitInstrWithCustomInserter(MachineInstr *MI,
146                                   MachineBasicBlock *MBB) const;
147
148     // Inline asm support
149     ConstraintType getConstraintType(const std::string &Constraint) const;
150
151     /// Examine constraint string and operand type and determine a weight value.
152     /// The operand object must already have been set up with the operand type.
153     ConstraintWeight getSingleConstraintMatchWeight(
154       AsmOperandInfo &info, const char *constraint) const;
155
156     std::pair<unsigned, const TargetRegisterClass*>
157               getRegForInlineAsmConstraint(const std::string &Constraint,
158               EVT VT) const;
159
160     std::vector<unsigned>
161     getRegClassForInlineAsmConstraint(const std::string &Constraint,
162               EVT VT) const;
163
164     virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const;
165
166     /// isFPImmLegal - Returns true if the target can instruction select the
167     /// specified FP immediate natively. If false, the legalizer will
168     /// materialize the FP immediate as a load from a constant pool.
169     virtual bool isFPImmLegal(const APFloat &Imm, EVT VT) const;
170   };
171 }
172
173 #endif // MipsISELLOWERING_H