1 //===-- ZPUISelLowering.h - ZPU DAG Lowering Interface --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the interfaces that ZPU uses to lower LLVM code into a
13 //===----------------------------------------------------------------------===//
15 #ifndef ZPUISELLOWERING_H
16 #define ZPUISELLOWERING_H
18 #include "llvm/CodeGen/SelectionDAG.h"
19 #include "llvm/Target/TargetLowering.h"
25 // Start the numbering from where ISD NodeType finishes.
26 FIRST_NUMBER
= ISD::BUILTIN_OP_END
,
28 // Jump and link (call)
31 // Get the Higher 16 bits from a 32-bit immediate
32 // No relation with ZPU Hi register
35 // Get the Lower 16 bits from a 32-bit immediate
36 // No relation with ZPU Lo register
39 // Handle gp_rel (small data/bss sections) relocation.
45 // Select CC Pseudo Instruction
48 // Floating Point Select CC Pseudo Instruction
51 // Floating Point Branch Conditional
54 // Floating Point Compare
57 // Floating Point Rounding
60 Wrapper
, // Address wrapper
79 //===--------------------------------------------------------------------===//
80 // TargetLowering Implementation
81 //===--------------------------------------------------------------------===//
83 class ZPUTargetLowering
: public TargetLowering
{
85 explicit ZPUTargetLowering(ZPUTargetMachine
&TM
);
87 /// LowerOperation - Provide custom lowering hooks for some operations.
88 virtual SDValue
LowerOperation(SDValue Op
, SelectionDAG
&DAG
) const;
90 /// getTargetNodeName - This method returns the name of a target specific
92 virtual const char *getTargetNodeName(unsigned Opcode
) const;
94 /// getSetCCResultType - get the ISD::SETCC result ValueType
95 MVT::SimpleValueType
getSetCCResultType(EVT VT
) const;
97 /// getFunctionAlignment - Return the Log2 alignment of this function.
98 virtual unsigned getFunctionAlignment(const Function
*F
) const;
102 // Lower Operand helpers
103 SDValue
LowerCallResult(SDValue Chain
, SDValue InFlag
,
104 CallingConv::ID CallConv
, bool isVarArg
,
105 const SmallVectorImpl
<ISD::InputArg
> &Ins
,
106 DebugLoc dl
, SelectionDAG
&DAG
,
107 SmallVectorImpl
<SDValue
> &InVals
) const;
110 // Lower Operand specifics
111 SDValue
LowerANDOR(SDValue Op
, SelectionDAG
&DAG
) const;
112 SDValue
LowerBRCOND(SDValue Op
, SelectionDAG
&DAG
) const;
113 SDValue
LowerConstantPool(SDValue Op
, SelectionDAG
&DAG
) const;
114 SDValue
LowerDYNAMIC_STACKALLOC(SDValue Op
, SelectionDAG
&DAG
) const;
115 SDValue
LowerFP_TO_SINT(SDValue Op
, SelectionDAG
&DAG
) const;
116 SDValue
LowerGlobalAddress(SDValue Op
, SelectionDAG
&DAG
) const;
117 SDValue
LowerGlobalTLSAddress(SDValue Op
, SelectionDAG
&DAG
) const;
118 SDValue
LowerJumpTable(SDValue Op
, SelectionDAG
&DAG
) const;
119 SDValue
LowerSELECT(SDValue Op
, SelectionDAG
&DAG
) const;
120 SDValue
LowerVASTART(SDValue Op
, SelectionDAG
&DAG
) const;
122 SDValue
LowerSETCC(SDValue Op
, SelectionDAG
&DAG
) const;
125 LowerFormalArguments(SDValue Chain
,
126 CallingConv::ID CallConv
, bool isVarArg
,
127 const SmallVectorImpl
<ISD::InputArg
> &Ins
,
128 DebugLoc dl
, SelectionDAG
&DAG
,
129 SmallVectorImpl
<SDValue
> &InVals
) const;
132 LowerCall(SDValue Chain
, SDValue Callee
,
133 CallingConv::ID CallConv
, bool isVarArg
,
135 const SmallVectorImpl
<ISD::OutputArg
> &Outs
,
136 const SmallVectorImpl
<SDValue
> &OutVals
,
137 const SmallVectorImpl
<ISD::InputArg
> &Ins
,
138 DebugLoc dl
, SelectionDAG
&DAG
,
139 SmallVectorImpl
<SDValue
> &InVals
) const;
142 LowerReturn(SDValue Chain
,
143 CallingConv::ID CallConv
, bool isVarArg
,
144 const SmallVectorImpl
<ISD::OutputArg
> &Outs
,
145 const SmallVectorImpl
<SDValue
> &OutVals
,
146 DebugLoc dl
, SelectionDAG
&DAG
) const;
148 virtual MachineBasicBlock
*
149 EmitInstrWithCustomInserter(MachineInstr
*MI
,
150 MachineBasicBlock
*MBB
) const;
152 // Inline asm support
153 ConstraintType
getConstraintType(const std::string
&Constraint
) const;
155 /// Examine constraint string and operand type and determine a weight value.
156 /// The operand object must already have been set up with the operand type.
157 ConstraintWeight
getSingleConstraintMatchWeight(
158 AsmOperandInfo
&info
, const char *constraint
) const;
160 std::pair
<unsigned, const TargetRegisterClass
*>
161 getRegForInlineAsmConstraint(const std::string
&Constraint
,
164 std::vector
<unsigned>
165 getRegClassForInlineAsmConstraint(const std::string
&Constraint
,
168 virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode
*GA
) const;
170 /// isFPImmLegal - Returns true if the target can instruction select the
171 /// specified FP immediate natively. If false, the legalizer will
172 /// materialize the FP immediate as a load from a constant pool.
173 virtual bool isFPImmLegal(const APFloat
&Imm
, EVT VT
) const;
174 SDValue
LowerGlobalAddress(SDValue Op
,
175 SelectionDAG
&DAG
) const;
179 #endif // ZPUISELLOWERING_H