zpu: managed to compile program that writes constant to global variable
[llvm/zpu.git] / lib / Target / MBlaze / MBlazeISelLowering.h
blob4f09851e7f3ed2c6a7db922165c439b5d10cae15
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.
13 //===----------------------------------------------------------------------===//
15 #ifndef MBlazeISELLOWERING_H
16 #define MBlazeISELLOWERING_H
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"
24 namespace llvm {
25 namespace MBlazeCC {
26 enum CC {
27 FIRST = 0,
28 EQ,
29 NE,
30 GT,
31 LT,
32 GE,
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;
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";
61 namespace MBlazeISD {
62 enum NodeType {
63 // Start the numbering from where ISD NodeType finishes.
64 FIRST_NUMBER = ISD::BUILTIN_OP_END,
66 // Jump and link (call)
67 JmpLink,
69 // Handle gp_rel (small data/bss sections) relocation.
70 GPRel,
72 // Select CC Pseudo Instruction
73 Select_CC,
75 // Wrap up multiple types of instructions
76 Wrap,
78 // Integer Compare
79 ICmp,
81 // Return
82 Ret
86 //===--------------------------------------------------------------------===//
87 // TargetLowering Implementation
88 //===--------------------------------------------------------------------===//
90 class MBlazeTargetLowering : public TargetLowering {
91 public:
92 explicit MBlazeTargetLowering(MBlazeTargetMachine &TM);
94 /// LowerOperation - Provide custom lowering hooks for some operations.
95 virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
97 /// getTargetNodeName - This method returns the name of a target specific
98 // DAG node.
99 virtual const char *getTargetNodeName(unsigned Opcode) const;
101 /// getSetCCResultType - get the ISD::SETCC result ValueType
102 MVT::SimpleValueType getSetCCResultType(EVT VT) const;
104 virtual unsigned getFunctionAlignment(const Function *F) const;
105 private:
106 // Subtarget Info
107 const MBlazeSubtarget *Subtarget;
110 // Lower Operand helpers
111 SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
112 CallingConv::ID CallConv, bool isVarArg,
113 const SmallVectorImpl<ISD::InputArg> &Ins,
114 DebugLoc dl, SelectionDAG &DAG,
115 SmallVectorImpl<SDValue> &InVals) const;
117 // Lower Operand specifics
118 SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
119 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
120 SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
121 SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
122 SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
123 SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
125 virtual SDValue
126 LowerFormalArguments(SDValue Chain,
127 CallingConv::ID CallConv, bool isVarArg,
128 const SmallVectorImpl<ISD::InputArg> &Ins,
129 DebugLoc dl, SelectionDAG &DAG,
130 SmallVectorImpl<SDValue> &InVals) const;
132 virtual SDValue
133 LowerCall(SDValue Chain, SDValue Callee,
134 CallingConv::ID CallConv, bool isVarArg,
135 bool &isTailCall,
136 const SmallVectorImpl<ISD::OutputArg> &Outs,
137 const SmallVectorImpl<SDValue> &OutVals,
138 const SmallVectorImpl<ISD::InputArg> &Ins,
139 DebugLoc dl, SelectionDAG &DAG,
140 SmallVectorImpl<SDValue> &InVals) const;
142 virtual SDValue
143 LowerReturn(SDValue Chain,
144 CallingConv::ID CallConv, bool isVarArg,
145 const SmallVectorImpl<ISD::OutputArg> &Outs,
146 const SmallVectorImpl<SDValue> &OutVals,
147 DebugLoc dl, SelectionDAG &DAG) const;
149 virtual MachineBasicBlock *
150 EmitInstrWithCustomInserter(MachineInstr *MI,
151 MachineBasicBlock *MBB) const;
153 // Inline asm support
154 ConstraintType getConstraintType(const std::string &Constraint) const;
156 /// Examine constraint string and operand type and determine a weight value.
157 /// The operand object must already have been set up with the operand type.
158 ConstraintWeight getSingleConstraintMatchWeight(
159 AsmOperandInfo &info, const char *constraint) const;
161 std::pair<unsigned, const TargetRegisterClass*>
162 getRegForInlineAsmConstraint(const std::string &Constraint,
163 EVT VT) const;
165 std::vector<unsigned>
166 getRegClassForInlineAsmConstraint(const std::string &Constraint,
167 EVT VT) const;
169 virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const;
171 /// isFPImmLegal - Returns true if the target can instruction select the
172 /// specified FP immediate natively. If false, the legalizer will
173 /// materialize the FP immediate as a load from a constant pool.
174 virtual bool isFPImmLegal(const APFloat &Imm, EVT VT) const;
178 #endif // MBlazeISELLOWERING_H