9f9ac899c6fc66e97715ee772cede067a7a3a3a1
[oota-llvm.git] / lib / Target / MBlaze / MBlazeISelLowering.h
1 //===-- MBlazeISelLowering.h - MBlaze 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 MBlaze uses to lower LLVM code into a
11 // selection DAG.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef MBlazeISELLOWERING_H
16 #define MBlazeISELLOWERING_H
17
18 #include "llvm/CodeGen/SelectionDAG.h"
19 #include "llvm/Target/TargetLowering.h"
20 #include "MBlaze.h"
21 #include "MBlazeSubtarget.h"
22
23 namespace llvm {
24   namespace MBlazeCC {
25     enum CC {
26       FIRST = 0,
27       EQ,
28       NE,
29       GT,
30       LT,
31       GE,
32       LE
33     };
34   }
35
36   namespace MBlazeISD {
37     enum NodeType {
38       // Start the numbering from where ISD NodeType finishes.
39       FIRST_NUMBER = ISD::BUILTIN_OP_END,
40
41       // Jump and link (call)
42       JmpLink,
43
44       // Handle gp_rel (small data/bss sections) relocation.
45       GPRel,
46
47       // Select CC Pseudo Instruction
48       Select_CC,
49
50       // Wrap up multiple types of instructions
51       Wrap,
52
53       // Integer Compare
54       ICmp,
55
56       // Return
57       Ret
58     };
59   }
60
61   //===--------------------------------------------------------------------===//
62   // TargetLowering Implementation
63   //===--------------------------------------------------------------------===//
64
65   class MBlazeTargetLowering : public TargetLowering  {
66   public:
67     explicit MBlazeTargetLowering(MBlazeTargetMachine &TM);
68
69     /// LowerOperation - Provide custom lowering hooks for some operations.
70     virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
71
72     /// getTargetNodeName - This method returns the name of a target specific
73     //  DAG node.
74     virtual const char *getTargetNodeName(unsigned Opcode) const;
75
76     /// getSetCCResultType - get the ISD::SETCC result ValueType
77     MVT::SimpleValueType getSetCCResultType(EVT VT) const;
78
79     virtual unsigned getFunctionAlignment(const Function *F) const;
80   private:
81     // Subtarget Info
82     const MBlazeSubtarget *Subtarget;
83
84
85     // Lower Operand helpers
86     SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
87                             CallingConv::ID CallConv, bool isVarArg,
88                             const SmallVectorImpl<ISD::InputArg> &Ins,
89                             DebugLoc dl, SelectionDAG &DAG,
90                             SmallVectorImpl<SDValue> &InVals) const;
91
92     // Lower Operand specifics
93     SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
94     SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
95     SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
96     SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
97     SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
98     SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
99
100     virtual SDValue
101       LowerFormalArguments(SDValue Chain,
102                            CallingConv::ID CallConv, bool isVarArg,
103                            const SmallVectorImpl<ISD::InputArg> &Ins,
104                            DebugLoc dl, SelectionDAG &DAG,
105                            SmallVectorImpl<SDValue> &InVals) const;
106
107     virtual SDValue
108       LowerCall(SDValue Chain, SDValue Callee,
109                 CallingConv::ID CallConv, bool isVarArg,
110                 bool &isTailCall,
111                 const SmallVectorImpl<ISD::OutputArg> &Outs,
112                 const SmallVectorImpl<ISD::InputArg> &Ins,
113                 DebugLoc dl, SelectionDAG &DAG,
114                 SmallVectorImpl<SDValue> &InVals) const;
115
116     virtual SDValue
117       LowerReturn(SDValue Chain,
118                   CallingConv::ID CallConv, bool isVarArg,
119                   const SmallVectorImpl<ISD::OutputArg> &Outs,
120                   DebugLoc dl, SelectionDAG &DAG) const;
121
122     virtual MachineBasicBlock *
123       EmitInstrWithCustomInserter(MachineInstr *MI,
124                                   MachineBasicBlock *MBB) const;
125
126     // Inline asm support
127     ConstraintType getConstraintType(const std::string &Constraint) const;
128
129     std::pair<unsigned, const TargetRegisterClass*>
130               getRegForInlineAsmConstraint(const std::string &Constraint,
131               EVT VT) const;
132
133     std::vector<unsigned>
134     getRegClassForInlineAsmConstraint(const std::string &Constraint,
135               EVT VT) const;
136
137     virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const;
138
139     /// isFPImmLegal - Returns true if the target can instruction select the
140     /// specified FP immediate natively. If false, the legalizer will
141     /// materialize the FP immediate as a load from a constant pool.
142     virtual bool isFPImmLegal(const APFloat &Imm, EVT VT) const;
143   };
144 }
145
146 #endif // MBlazeISELLOWERING_H