More cleanups for CellSPU:
[oota-llvm.git] / lib / Target / CellSPU / SPUNodes.td
1 //===- SPUNodes.td - Specialized SelectionDAG nodes used for CellSPU ------===//
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 // Type profiles and SelectionDAG nodes used by CellSPU
11 //
12 //===----------------------------------------------------------------------===//
13
14 // Type profile for a call sequence
15 def SDT_SPUCallSeq : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
16
17 // SPU_GenControl: Type profile for generating control words for insertions
18 def SPU_GenControl : SDTypeProfile<1, 1, []>;
19 def SPUvecinsmask : SDNode<"SPUISD::INSERT_MASK", SPU_GenControl, []>;
20
21 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_SPUCallSeq,
22                            [SDNPHasChain, SDNPOutFlag]>;
23 def callseq_end   : SDNode<"ISD::CALLSEQ_END",   SDT_SPUCallSeq,
24                            [SDNPHasChain, SDNPOutFlag]>;
25 //===----------------------------------------------------------------------===//
26 // Operand constraints:
27 //===----------------------------------------------------------------------===//
28
29 def SDT_SPUCall   : SDTypeProfile<0, -1, [SDTCisInt<0>]>;
30 def SPUcall       : SDNode<"SPUISD::CALL", SDT_SPUCall,
31                            [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
32
33 // Operand type constraints for vector shuffle/permute operations
34 def SDT_SPUshuffle   : SDTypeProfile<1, 3, [
35   SDTCisVT<3, v16i8>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>
36 ]>;
37
38 // Unary, binary v16i8 operator type constraints:
39 def SPUv16i8_unop: SDTypeProfile<1, 1, [
40   SDTCisVT<0, v16i8>, SDTCisSameAs<0, 1>]>;
41
42 def SPUv16i8_binop: SDTypeProfile<1, 2, [
43   SDTCisVT<0, v16i8>, SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>]>;
44
45 // Binary v8i16 operator type constraints:
46 def SPUv8i16_unop: SDTypeProfile<1, 1, [
47   SDTCisVT<0, v8i16>, SDTCisSameAs<0, 1>]>;
48
49 def SPUv8i16_binop: SDTypeProfile<1, 2, [
50   SDTCisVT<0, v8i16>, SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>]>;
51
52 // Binary v4i32 operator type constraints:
53 def SPUv4i32_unop: SDTypeProfile<1, 1, [
54   SDTCisVT<0, v4i32>, SDTCisSameAs<0, 1>]>;
55
56 def SPUv4i32_binop: SDTypeProfile<1, 2, [
57   SDTCisVT<0, v4i32>, SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>]>;
58
59 // FSMBI type constraints: There are several variations for the various
60 // vector types (this avoids having to bit_convert all over the place.)
61 def SPUfsmbi_type: SDTypeProfile<1, 1, [
62   SDTCisVT<1, i32>]>;
63
64 // SELB type constraints:
65 def SPUselb_type_v16i8: SDTypeProfile<1, 3, [
66   SDTCisVT<0, v16i8>, SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
67   SDTCisSameAs<0, 3> ]>;
68
69 def SPUselb_type_v8i16: SDTypeProfile<1, 3, [
70   SDTCisVT<0, v8i16>, SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
71   SDTCisSameAs<0, 3> ]>;
72
73 def SPUselb_type_v4i32: SDTypeProfile<1, 3, [
74   SDTCisVT<0, v4i32>, SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
75   SDTCisSameAs<0, 3> ]>;
76
77 // SPU Vector shift pseudo-instruction type constraints
78 def SPUvecshift_type_v16i8: SDTypeProfile<1, 2, [
79   SDTCisVT<0, v16i8>, SDTCisSameAs<0, 1>, SDTCisInt<2>]>;
80
81 def SPUvecshift_type_v8i16: SDTypeProfile<1, 2, [
82   SDTCisVT<0, v8i16>, SDTCisSameAs<0, 1>, SDTCisInt<2>]>;
83
84 def SPUvecshift_type_v4i32: SDTypeProfile<1, 2, [
85   SDTCisVT<0, v4i32>, SDTCisSameAs<0, 1>, SDTCisInt<2>]>;
86
87 //===----------------------------------------------------------------------===//
88 // Synthetic/pseudo-instructions
89 //===----------------------------------------------------------------------===//
90
91 // SPU CNTB:
92 def SPUcntb_v16i8: SDNode<"SPUISD::CNTB", SPUv16i8_unop, []>;
93 def SPUcntb_v8i16: SDNode<"SPUISD::CNTB", SPUv8i16_unop, []>;
94 def SPUcntb_v4i32: SDNode<"SPUISD::CNTB", SPUv4i32_unop, []>;
95
96 // SPU vector shuffle node, matched by the SPUISD::SHUFB enum (see
97 // SPUISelLowering.h):
98 def SPUshuffle: SDNode<"SPUISD::SHUFB", SDT_SPUshuffle, []>;
99
100 // SPU 16-bit multiply
101 def SPUmpy_v16i8: SDNode<"SPUISD::MPY", SPUv16i8_binop, []>;
102 def SPUmpy_v8i16: SDNode<"SPUISD::MPY", SPUv8i16_binop, []>;
103 def SPUmpy_v4i32: SDNode<"SPUISD::MPY", SPUv4i32_binop, []>;
104
105 // SPU multiply unsigned, used in instruction lowering for v4i32
106 // multiplies:
107 def SPUmpyu_v4i32: SDNode<"SPUISD::MPYU", SPUv4i32_binop, []>;
108 def SPUmpyu_i32: SDNode<"SPUISD::MPYU", SDTIntBinOp, []>;
109
110 // SPU 16-bit multiply high x low, shift result 16-bits
111 // Used to compute intermediate products for 32-bit multiplies
112 def SPUmpyh_v4i32: SDNode<"SPUISD::MPYH", SPUv4i32_binop, []>;
113 def SPUmpyh_i32: SDNode<"SPUISD::MPYH", SDTIntBinOp, []>;
114
115 // SPU 16-bit multiply high x high, 32-bit product
116 // Used to compute intermediate products for 16-bit multiplies
117 def SPUmpyhh_v8i16: SDNode<"SPUISD::MPYHH", SPUv8i16_binop, []>;
118
119 // Vector shifts (ISD::SHL,SRL,SRA are for _integers_ only):
120 def SPUvec_shl_v8i16: SDNode<"SPUISD::VEC_SHL", SPUvecshift_type_v8i16, []>;
121 def SPUvec_srl_v8i16: SDNode<"SPUISD::VEC_SRL", SPUvecshift_type_v8i16, []>;
122 def SPUvec_sra_v8i16: SDNode<"SPUISD::VEC_SRA", SPUvecshift_type_v8i16, []>;
123
124 def SPUvec_shl_v4i32: SDNode<"SPUISD::VEC_SHL", SPUvecshift_type_v4i32, []>;
125 def SPUvec_srl_v4i32: SDNode<"SPUISD::VEC_SRL", SPUvecshift_type_v4i32, []>;
126 def SPUvec_sra_v4i32: SDNode<"SPUISD::VEC_SRA", SPUvecshift_type_v4i32, []>;
127
128 def SPUvec_rotl_v8i16: SDNode<"SPUISD::VEC_ROTL", SPUvecshift_type_v8i16, []>;
129 def SPUvec_rotl_v4i32: SDNode<"SPUISD::VEC_ROTL", SPUvecshift_type_v4i32, []>;
130
131 def SPUvec_rotr_v8i16: SDNode<"SPUISD::VEC_ROTR", SPUvecshift_type_v8i16, []>;
132 def SPUvec_rotr_v4i32: SDNode<"SPUISD::VEC_ROTR", SPUvecshift_type_v4i32, []>;
133
134 def SPUrotbytes_right_zfill: SDNode<"SPUISD::ROTBYTES_RIGHT_Z",
135                                     SPUvecshift_type_v16i8, []>;
136 def SPUrotbytes_right_sfill: SDNode<"SPUISD::ROTBYTES_RIGHT_S",
137                                     SPUvecshift_type_v16i8, []>;
138 def SPUrotbytes_left: SDNode<"SPUISD::ROTBYTES_LEFT",
139                              SPUvecshift_type_v16i8, []>;
140
141 def SPUrotbytes_left_chained : SDNode<"SPUISD::ROTBYTES_LEFT_CHAINED",
142                                       SPUvecshift_type_v16i8, [SDNPHasChain]>;
143
144 // SPU form select mask for bytes, immediate
145 def SPUfsmbi: SDNode<"SPUISD::FSMBI", SPUfsmbi_type, []>;
146
147 // SPU select bits instruction
148 def SPUselb_v16i8: SDNode<"SPUISD::SELB", SPUselb_type_v16i8, []>;
149 def SPUselb_v8i16: SDNode<"SPUISD::SELB", SPUselb_type_v8i16, []>;
150 def SPUselb_v4i32: SDNode<"SPUISD::SELB", SPUselb_type_v4i32, []>;
151
152 // SPU single precision floating point constant load
153 def SPUFPconstant: SDNode<"SPUISD::SFPConstant", SDTFPUnaryOp, []>;
154
155 // SPU floating point interpolate
156 def SPUinterpolate : SDNode<"SPUISD::FPInterp", SDTFPBinOp, []>;
157
158 // SPU floating point reciprocal estimate (used for fdiv)
159 def SPUreciprocalEst: SDNode<"SPUISD::FPRecipEst", SDTFPUnaryOp, []>;
160
161 def SDT_vec_promote   : SDTypeProfile<1, 1, []>;
162 def SPUpromote_scalar: SDNode<"SPUISD::PROMOTE_SCALAR", SDT_vec_promote, []>;
163
164 def SPU_vec_demote   : SDTypeProfile<1, 1, []>;
165 def SPUextract_elt0: SDNode<"SPUISD::EXTRACT_ELT0", SPU_vec_demote, []>;
166 def SPU_vec_demote_chained : SDTypeProfile<1, 2, []>;
167 def SPUextract_elt0_chained: SDNode<"SPUISD::EXTRACT_ELT0_CHAINED",
168                                     SPU_vec_demote_chained, [SDNPHasChain]>;
169 def SPUextract_i1_sext: SDNode<"SPUISD::EXTRACT_I1_SEXT", SPU_vec_demote, []>;
170 def SPUextract_i1_zext: SDNode<"SPUISD::EXTRACT_I1_ZEXT", SPU_vec_demote, []>;
171 def SPUextract_i8_sext: SDNode<"SPUISD::EXTRACT_I8_SEXT", SPU_vec_demote, []>;
172 def SPUextract_i8_zext: SDNode<"SPUISD::EXTRACT_I8_ZEXT", SPU_vec_demote, []>;
173
174 // Address high and low components, used for [r+r] type addressing
175 def SPUhi : SDNode<"SPUISD::Hi", SDTIntBinOp, []>;
176 def SPUlo : SDNode<"SPUISD::Lo", SDTIntBinOp, []>;
177
178 // PC-relative address
179 def SPUpcrel : SDNode<"SPUISD::PCRelAddr", SDTIntBinOp, []>;
180
181 // A-Form local store addresses
182 def SPUaform : SDNode<"SPUISD::AFormAddr", SDTIntBinOp, []>;
183
184 // Indirect [D-Form "imm($reg)" and X-Form "$reg($reg)"] addresses
185 def SPUindirect : SDNode<"SPUISD::IndirectAddr", SDTIntBinOp, []>;
186
187 // SPU 32-bit sign-extension to 64-bits
188 def SPUsext32_to_64: SDNode<"SPUISD::SEXT32TO64", SDTIntExtendOp, []>;
189
190 // Branches:
191
192 def SPUbrnz : SDNode<"SPUISD::BR_NOTZERO", SDTBrcond,  [SDNPHasChain]>;
193 def SPUbrz  : SDNode<"SPUISD::BR_ZERO",    SDTBrcond,  [SDNPHasChain]>;
194 /* def SPUbinz : SDNode<"SPUISD::BR_NOTZERO", SDTBrind,   [SDNPHasChain]>;
195 def SPUbiz  : SDNode<"SPUISD::BR_ZERO",    SPUBrind,   [SDNPHasChain]>; */
196
197 //===----------------------------------------------------------------------===//
198 // Constraints: (taken from PPCInstrInfo.td)
199 //===----------------------------------------------------------------------===//
200
201 class RegConstraint<string C> {
202   string Constraints = C;
203 }
204
205 class NoEncode<string E> {
206   string DisableEncoding = E;
207 }
208
209 //===----------------------------------------------------------------------===//
210 // Return (flag isn't quite what it means: the operations are flagged so that
211 // instruction scheduling doesn't disassociate them.)
212 //===----------------------------------------------------------------------===//
213
214 def retflag     : SDNode<"SPUISD::RET_FLAG", SDTNone,
215                          [SDNPHasChain, SDNPOptInFlag]>;