Reworking the stack layout that the MicroBlaze backend generates.
[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     int VarArgsFrameIndex;            // FrameIndex for start of varargs area.
67
68   public:
69
70     explicit MBlazeTargetLowering(MBlazeTargetMachine &TM);
71
72     /// LowerOperation - Provide custom lowering hooks for some operations.
73     virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG);
74
75     /// getTargetNodeName - This method returns the name of a target specific
76     //  DAG node.
77     virtual const char *getTargetNodeName(unsigned Opcode) const;
78
79     /// getSetCCResultType - get the ISD::SETCC result ValueType
80     MVT::SimpleValueType getSetCCResultType(EVT VT) const;
81
82     virtual unsigned getFunctionAlignment(const Function *F) const;
83   private:
84     // Subtarget Info
85     const MBlazeSubtarget *Subtarget;
86
87
88     // Lower Operand helpers
89     SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
90                             CallingConv::ID CallConv, bool isVarArg,
91                             const SmallVectorImpl<ISD::InputArg> &Ins,
92                             DebugLoc dl, SelectionDAG &DAG,
93                             SmallVectorImpl<SDValue> &InVals);
94
95     // Lower Operand specifics
96     SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG);
97     SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG);
98     SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG);
99     SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG);
100     SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG);
101     SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG);
102
103     virtual SDValue
104       LowerFormalArguments(SDValue Chain,
105                            CallingConv::ID CallConv, bool isVarArg,
106                            const SmallVectorImpl<ISD::InputArg> &Ins,
107                            DebugLoc dl, SelectionDAG &DAG,
108                            SmallVectorImpl<SDValue> &InVals);
109
110     virtual SDValue
111       LowerCall(SDValue Chain, SDValue Callee,
112                 CallingConv::ID CallConv, bool isVarArg,
113                 bool &isTailCall,
114                 const SmallVectorImpl<ISD::OutputArg> &Outs,
115                 const SmallVectorImpl<ISD::InputArg> &Ins,
116                 DebugLoc dl, SelectionDAG &DAG,
117                 SmallVectorImpl<SDValue> &InVals);
118
119     virtual SDValue
120       LowerReturn(SDValue Chain,
121                   CallingConv::ID CallConv, bool isVarArg,
122                   const SmallVectorImpl<ISD::OutputArg> &Outs,
123                   DebugLoc dl, SelectionDAG &DAG);
124
125     virtual MachineBasicBlock *EmitInstrWithCustomInserter(MachineInstr *MI,
126                                                          MachineBasicBlock *MBB,
127                     DenseMap<MachineBasicBlock*, MachineBasicBlock*> *EM) const;
128
129     // Inline asm support
130     ConstraintType getConstraintType(const std::string &Constraint) const;
131
132     std::pair<unsigned, const TargetRegisterClass*>
133               getRegForInlineAsmConstraint(const std::string &Constraint,
134               EVT VT) const;
135
136     std::vector<unsigned>
137     getRegClassForInlineAsmConstraint(const std::string &Constraint,
138               EVT VT) const;
139
140     virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const;
141
142     /// isFPImmLegal - Returns true if the target can instruction select the
143     /// specified FP immediate natively. If false, the legalizer will
144     /// materialize the FP immediate as a load from a constant pool.
145     virtual bool isFPImmLegal(const APFloat &Imm, EVT VT) const;
146   };
147 }
148
149 #endif // MBlazeISELLOWERING_H