Revert r124611 - "Keep track of incoming argument's location while emitting LiveIns."
[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/Support/ErrorHandling.h"
19 #include "llvm/CodeGen/SelectionDAG.h"
20 #include "llvm/Target/TargetLowering.h"
21 #include "MBlaze.h"
22 #include "MBlazeSubtarget.h"
23
24 namespace llvm {
25   namespace MBlazeCC {
26     enum CC {
27       FIRST = 0,
28       EQ,
29       NE,
30       GT,
31       LT,
32       GE,
33       LE
34     };
35
36     inline static CC getOppositeCondition(CC cc) {
37       switch (cc) {
38       default: llvm_unreachable("Unknown condition code");
39       case EQ: return NE;
40       case NE: return EQ;
41       case GT: return LE;
42       case LT: return GE;
43       case GE: return LT;
44       case LE: return GE;
45       }
46     }
47
48     inline static const char *MBlazeCCToString(CC cc) {
49       switch (cc) {
50       default: llvm_unreachable("Unknown condition code");
51       case EQ: return "eq";
52       case NE: return "ne";
53       case GT: return "gt";
54       case LT: return "lt";
55       case GE: return "ge";
56       case LE: return "le";
57       }
58     }
59   }
60
61   namespace MBlazeISD {
62     enum NodeType {
63       // Start the numbering from where ISD NodeType finishes.
64       FIRST_NUMBER = ISD::BUILTIN_OP_END,
65
66       // Jump and link (call)
67       JmpLink,
68
69       // Handle gp_rel (small data/bss sections) relocation.
70       GPRel,
71
72       // Select CC Pseudo Instruction
73       Select_CC,
74
75       // Wrap up multiple types of instructions
76       Wrap,
77
78       // Integer Compare
79       ICmp,
80
81       // Return from subroutine
82       Ret,
83
84       // Return from interrupt
85       IRet
86     };
87   }
88
89   //===--------------------------------------------------------------------===//
90   // TargetLowering Implementation
91   //===--------------------------------------------------------------------===//
92
93   class MBlazeTargetLowering : public TargetLowering  {
94   public:
95     explicit MBlazeTargetLowering(MBlazeTargetMachine &TM);
96
97     /// LowerOperation - Provide custom lowering hooks for some operations.
98     virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
99
100     /// getTargetNodeName - This method returns the name of a target specific
101     //  DAG node.
102     virtual const char *getTargetNodeName(unsigned Opcode) const;
103
104     /// getSetCCResultType - get the ISD::SETCC result ValueType
105     MVT::SimpleValueType getSetCCResultType(EVT VT) const;
106
107     virtual unsigned getFunctionAlignment(const Function *F) const;
108   private:
109     // Subtarget Info
110     const MBlazeSubtarget *Subtarget;
111
112
113     // Lower Operand helpers
114     SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
115                             CallingConv::ID CallConv, bool isVarArg,
116                             const SmallVectorImpl<ISD::InputArg> &Ins,
117                             DebugLoc dl, SelectionDAG &DAG,
118                             SmallVectorImpl<SDValue> &InVals) const;
119
120     // Lower Operand specifics
121     SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
122     SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
123     SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
124     SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
125     SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
126     SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
127
128     virtual SDValue
129       LowerFormalArguments(SDValue Chain,
130                            CallingConv::ID CallConv, bool isVarArg,
131                            const SmallVectorImpl<ISD::InputArg> &Ins,
132                            DebugLoc dl, SelectionDAG &DAG,
133                            SmallVectorImpl<SDValue> &InVals) const;
134
135     virtual SDValue
136       LowerCall(SDValue Chain, SDValue Callee,
137                 CallingConv::ID CallConv, bool isVarArg,
138                 bool &isTailCall,
139                 const SmallVectorImpl<ISD::OutputArg> &Outs,
140                 const SmallVectorImpl<SDValue> &OutVals,
141                 const SmallVectorImpl<ISD::InputArg> &Ins,
142                 DebugLoc dl, SelectionDAG &DAG,
143                 SmallVectorImpl<SDValue> &InVals) const;
144
145     virtual SDValue
146       LowerReturn(SDValue Chain,
147                   CallingConv::ID CallConv, bool isVarArg,
148                   const SmallVectorImpl<ISD::OutputArg> &Outs,
149                   const SmallVectorImpl<SDValue> &OutVals,
150                   DebugLoc dl, SelectionDAG &DAG) const;
151
152     virtual MachineBasicBlock*
153       EmitCustomShift(MachineInstr *MI, MachineBasicBlock *MBB) const;
154
155     virtual MachineBasicBlock*
156       EmitCustomSelect(MachineInstr *MI, MachineBasicBlock *MBB) const;
157
158     virtual MachineBasicBlock*
159             EmitCustomAtomic(MachineInstr *MI, MachineBasicBlock *MBB) const;
160
161     virtual MachineBasicBlock *
162       EmitInstrWithCustomInserter(MachineInstr *MI,
163                                   MachineBasicBlock *MBB) const;
164
165     // Inline asm support
166     ConstraintType getConstraintType(const std::string &Constraint) const;
167
168     /// Examine constraint string and operand type and determine a weight value.
169     /// The operand object must already have been set up with the operand type.
170     ConstraintWeight getSingleConstraintMatchWeight(
171       AsmOperandInfo &info, const char *constraint) const;
172
173     std::pair<unsigned, const TargetRegisterClass*>
174               getRegForInlineAsmConstraint(const std::string &Constraint,
175               EVT VT) const;
176
177     std::vector<unsigned>
178     getRegClassForInlineAsmConstraint(const std::string &Constraint,
179               EVT VT) const;
180
181     virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const;
182
183     /// isFPImmLegal - Returns true if the target can instruction select the
184     /// specified FP immediate natively. If false, the legalizer will
185     /// materialize the FP immediate as a load from a constant pool.
186     virtual bool isFPImmLegal(const APFloat &Imm, EVT VT) const;
187   };
188 }
189
190 #endif // MBlazeISELLOWERING_H