1 //===-- MBlazeISelLowering.h - MBlaze 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 MBlaze uses to lower LLVM code into a
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"
22 #include "MBlazeSubtarget.h"
36 inline static CC
getOppositeCondition(CC cc
) {
38 default: llvm_unreachable("Unknown condition code");
48 inline static const char *MBlazeCCToString(CC cc
) {
50 default: llvm_unreachable("Unknown condition code");
63 // Start the numbering from where ISD NodeType finishes.
64 FIRST_NUMBER
= ISD::BUILTIN_OP_END
,
66 // Jump and link (call)
69 // Handle gp_rel (small data/bss sections) relocation.
72 // Select CC Pseudo Instruction
75 // Wrap up multiple types of instructions
81 // Return from subroutine
84 // Return from interrupt
89 //===--------------------------------------------------------------------===//
90 // TargetLowering Implementation
91 //===--------------------------------------------------------------------===//
93 class MBlazeTargetLowering
: public TargetLowering
{
95 explicit MBlazeTargetLowering(MBlazeTargetMachine
&TM
);
97 /// LowerOperation - Provide custom lowering hooks for some operations.
98 virtual SDValue
LowerOperation(SDValue Op
, SelectionDAG
&DAG
) const;
100 /// getTargetNodeName - This method returns the name of a target specific
102 virtual const char *getTargetNodeName(unsigned Opcode
) const;
104 /// getSetCCResultType - get the ISD::SETCC result ValueType
105 MVT::SimpleValueType
getSetCCResultType(EVT VT
) const;
109 const MBlazeSubtarget
*Subtarget
;
112 // Lower Operand helpers
113 SDValue
LowerCallResult(SDValue Chain
, SDValue InFlag
,
114 CallingConv::ID CallConv
, bool isVarArg
,
115 const SmallVectorImpl
<ISD::InputArg
> &Ins
,
116 DebugLoc dl
, SelectionDAG
&DAG
,
117 SmallVectorImpl
<SDValue
> &InVals
) const;
119 // Lower Operand specifics
120 SDValue
LowerConstantPool(SDValue Op
, SelectionDAG
&DAG
) const;
121 SDValue
LowerGlobalAddress(SDValue Op
, SelectionDAG
&DAG
) const;
122 SDValue
LowerGlobalTLSAddress(SDValue Op
, SelectionDAG
&DAG
) const;
123 SDValue
LowerJumpTable(SDValue Op
, SelectionDAG
&DAG
) const;
124 SDValue
LowerSELECT_CC(SDValue Op
, SelectionDAG
&DAG
) const;
125 SDValue
LowerVASTART(SDValue Op
, SelectionDAG
&DAG
) const;
128 LowerFormalArguments(SDValue Chain
,
129 CallingConv::ID CallConv
, bool isVarArg
,
130 const SmallVectorImpl
<ISD::InputArg
> &Ins
,
131 DebugLoc dl
, SelectionDAG
&DAG
,
132 SmallVectorImpl
<SDValue
> &InVals
) const;
135 LowerCall(SDValue Chain
, SDValue Callee
,
136 CallingConv::ID CallConv
, bool isVarArg
,
138 const SmallVectorImpl
<ISD::OutputArg
> &Outs
,
139 const SmallVectorImpl
<SDValue
> &OutVals
,
140 const SmallVectorImpl
<ISD::InputArg
> &Ins
,
141 DebugLoc dl
, SelectionDAG
&DAG
,
142 SmallVectorImpl
<SDValue
> &InVals
) const;
145 LowerReturn(SDValue Chain
,
146 CallingConv::ID CallConv
, bool isVarArg
,
147 const SmallVectorImpl
<ISD::OutputArg
> &Outs
,
148 const SmallVectorImpl
<SDValue
> &OutVals
,
149 DebugLoc dl
, SelectionDAG
&DAG
) const;
151 virtual MachineBasicBlock
*
152 EmitCustomShift(MachineInstr
*MI
, MachineBasicBlock
*MBB
) const;
154 virtual MachineBasicBlock
*
155 EmitCustomSelect(MachineInstr
*MI
, MachineBasicBlock
*MBB
) const;
157 virtual MachineBasicBlock
*
158 EmitCustomAtomic(MachineInstr
*MI
, MachineBasicBlock
*MBB
) const;
160 virtual MachineBasicBlock
*
161 EmitInstrWithCustomInserter(MachineInstr
*MI
,
162 MachineBasicBlock
*MBB
) const;
164 // Inline asm support
165 ConstraintType
getConstraintType(const std::string
&Constraint
) const;
167 /// Examine constraint string and operand type and determine a weight value.
168 /// The operand object must already have been set up with the operand type.
169 ConstraintWeight
getSingleConstraintMatchWeight(
170 AsmOperandInfo
&info
, const char *constraint
) const;
172 std::pair
<unsigned, const TargetRegisterClass
*>
173 getRegForInlineAsmConstraint(const std::string
&Constraint
,
176 virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode
*GA
) const;
178 /// isFPImmLegal - Returns true if the target can instruction select the
179 /// specified FP immediate natively. If false, the legalizer will
180 /// materialize the FP immediate as a load from a constant pool.
181 virtual bool isFPImmLegal(const APFloat
&Imm
, EVT VT
) const;
185 #endif // MBlazeISELLOWERING_H