1 //===-- SPUISelLowering.h - Cell SPU 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 Cell SPU uses to lower LLVM code into
13 //===----------------------------------------------------------------------===//
15 #ifndef SPU_ISELLOWERING_H
16 #define SPU_ISELLOWERING_H
18 #include "llvm/Target/TargetLowering.h"
19 #include "llvm/CodeGen/SelectionDAG.h"
25 // Start the numbering where the builting ops and target ops leave off.
26 FIRST_NUMBER
= ISD::BUILTIN_OP_END
,
28 // Pseudo instructions:
29 RET_FLAG
, ///< Return with flag, matched by bi instruction
31 Hi
, ///< High address component (upper 16)
32 Lo
, ///< Low address component (lower 16)
33 PCRelAddr
, ///< Program counter relative address
34 AFormAddr
, ///< A-form address (local store)
35 IndirectAddr
, ///< D-Form "imm($r)" and X-form "$r($r)"
37 LDRESULT
, ///< Load result (value, chain)
38 CALL
, ///< CALL instruction
39 SHUFB
, ///< Vector shuffle (permute)
40 SHUFFLE_MASK
, ///< Shuffle mask
41 CNTB
, ///< Count leading ones in bytes
42 PREFSLOT2VEC
, ///< Promote scalar->vector
43 VEC2PREFSLOT
, ///< Extract element 0
44 SHLQUAD_L_BITS
, ///< Rotate quad left, by bits
45 SHLQUAD_L_BYTES
, ///< Rotate quad left, by bytes
46 VEC_SHL
, ///< Vector shift left
47 VEC_SRL
, ///< Vector shift right (logical)
48 VEC_SRA
, ///< Vector shift right (arithmetic)
49 VEC_ROTL
, ///< Vector rotate left
50 VEC_ROTR
, ///< Vector rotate right
51 ROTBYTES_LEFT
, ///< Rotate bytes (loads -> ROTQBYI)
52 ROTBYTES_LEFT_BITS
, ///< Rotate bytes left by bit shift count
53 SELECT_MASK
, ///< Select Mask (FSM, FSMB, FSMH, FSMBI)
54 SELB
, ///< Select bits -> (b & mask) | (a & ~mask)
55 // Markers: These aren't used to generate target-dependent nodes, but
56 // are used during instruction selection.
57 ADD64_MARKER
, ///< i64 addition marker
58 SUB64_MARKER
, ///< i64 subtraction marker
59 MUL64_MARKER
, ///< i64 multiply marker
60 LAST_SPUISD
///< Last user-defined instruction
64 //! Utility functions specific to CellSPU:
66 SDValue
get_vec_u18imm(SDNode
*N
, SelectionDAG
&DAG
,
68 SDValue
get_vec_i16imm(SDNode
*N
, SelectionDAG
&DAG
,
70 SDValue
get_vec_i10imm(SDNode
*N
, SelectionDAG
&DAG
,
72 SDValue
get_vec_i8imm(SDNode
*N
, SelectionDAG
&DAG
,
74 SDValue
get_ILHUvec_imm(SDNode
*N
, SelectionDAG
&DAG
,
76 SDValue
get_v4i32_imm(SDNode
*N
, SelectionDAG
&DAG
);
77 SDValue
get_v2i64_imm(SDNode
*N
, SelectionDAG
&DAG
);
79 SDValue
LowerConstantPool(SDValue Op
, SelectionDAG
&DAG
,
80 const SPUTargetMachine
&TM
);
81 //! Simplify a EVT::v2i64 constant splat to CellSPU-ready form
82 SDValue
LowerV2I64Splat(EVT OpVT
, SelectionDAG
&DAG
, uint64_t splat
,
86 class SPUTargetMachine
; // forward dec'l.
88 class SPUTargetLowering
:
91 int VarArgsFrameIndex
; // FrameIndex for start of varargs area.
92 SPUTargetMachine
&SPUTM
;
95 //! The venerable constructor
97 This is where the CellSPU backend sets operation handling (i.e., legal,
98 custom, expand or promote.)
100 SPUTargetLowering(SPUTargetMachine
&TM
);
102 //! Get the target machine
103 SPUTargetMachine
&getSPUTargetMachine() {
107 /// getTargetNodeName() - This method returns the name of a target specific
109 virtual const char *getTargetNodeName(unsigned Opcode
) const;
111 /// getSetCCResultType - Return the ValueType for ISD::SETCC
112 virtual MVT::SimpleValueType
getSetCCResultType(EVT VT
) const;
114 //! Custom lowering hooks
115 virtual SDValue
LowerOperation(SDValue Op
, SelectionDAG
&DAG
);
117 //! Custom lowering hook for nodes with illegal result types.
118 virtual void ReplaceNodeResults(SDNode
*N
, SmallVectorImpl
<SDValue
>&Results
,
121 virtual SDValue
PerformDAGCombine(SDNode
*N
, DAGCombinerInfo
&DCI
) const;
123 virtual void computeMaskedBitsForTargetNode(const SDValue Op
,
127 const SelectionDAG
&DAG
,
128 unsigned Depth
= 0) const;
130 virtual unsigned ComputeNumSignBitsForTargetNode(SDValue Op
,
131 unsigned Depth
= 0) const;
133 ConstraintType
getConstraintType(const std::string
&ConstraintLetter
) const;
135 std::pair
<unsigned, const TargetRegisterClass
*>
136 getRegForInlineAsmConstraint(const std::string
&Constraint
,
139 void LowerAsmOperandForConstraint(SDValue Op
, char ConstraintLetter
,
141 std::vector
<SDValue
> &Ops
,
142 SelectionDAG
&DAG
) const;
144 /// isLegalAddressImmediate - Return true if the integer value can be used
145 /// as the offset of the target addressing mode.
146 virtual bool isLegalAddressImmediate(int64_t V
, const Type
*Ty
) const;
147 virtual bool isLegalAddressImmediate(GlobalValue
*) const;
149 virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode
*GA
) const;
151 /// getFunctionAlignment - Return the Log2 alignment of this function.
152 virtual unsigned getFunctionAlignment(const Function
*F
) const;
155 LowerFormalArguments(SDValue Chain
,
156 unsigned CallConv
, bool isVarArg
,
157 const SmallVectorImpl
<ISD::InputArg
> &Ins
,
158 DebugLoc dl
, SelectionDAG
&DAG
,
159 SmallVectorImpl
<SDValue
> &InVals
);
162 LowerCall(SDValue Chain
, SDValue Callee
,
163 unsigned CallConv
, bool isVarArg
,
165 const SmallVectorImpl
<ISD::OutputArg
> &Outs
,
166 const SmallVectorImpl
<ISD::InputArg
> &Ins
,
167 DebugLoc dl
, SelectionDAG
&DAG
,
168 SmallVectorImpl
<SDValue
> &InVals
);
171 LowerReturn(SDValue Chain
,
172 unsigned CallConv
, bool isVarArg
,
173 const SmallVectorImpl
<ISD::OutputArg
> &Outs
,
174 DebugLoc dl
, SelectionDAG
&DAG
);