- Fix support for "special" i64 immediates that can be loaded
[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   SDTCisSameAs<0, 1>, SDTCisSameAs<1, 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> */ SDTCisInt<1>]>;
63
64 // SELB type constraints:
65 def SPUselb_type: SDTypeProfile<1, 3, [
66   SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisSameAs<0, 3> ]>;
67
68 // SPU Vector shift pseudo-instruction type constraints
69 def SPUvecshift_type: SDTypeProfile<1, 2, [
70   SDTCisSameAs<0, 1>, SDTCisInt<2>]>;
71
72 //===----------------------------------------------------------------------===//
73 // Synthetic/pseudo-instructions
74 //===----------------------------------------------------------------------===//
75
76 // SPU CNTB:
77 def SPUcntb_v16i8: SDNode<"SPUISD::CNTB", SPUv16i8_unop, []>;
78 def SPUcntb_v8i16: SDNode<"SPUISD::CNTB", SPUv8i16_unop, []>;
79 def SPUcntb_v4i32: SDNode<"SPUISD::CNTB", SPUv4i32_unop, []>;
80
81 // SPU vector shuffle node, matched by the SPUISD::SHUFB enum (see
82 // SPUISelLowering.h):
83 def SPUshuffle: SDNode<"SPUISD::SHUFB", SDT_SPUshuffle, []>;
84
85 // SPU 16-bit multiply
86 def SPUmpy_v16i8: SDNode<"SPUISD::MPY", SPUv16i8_binop, []>;
87 def SPUmpy_v8i16: SDNode<"SPUISD::MPY", SPUv8i16_binop, []>;
88 def SPUmpy_v4i32: SDNode<"SPUISD::MPY", SPUv4i32_binop, []>;
89
90 // SPU multiply unsigned, used in instruction lowering for v4i32
91 // multiplies:
92 def SPUmpyu_v4i32: SDNode<"SPUISD::MPYU", SPUv4i32_binop, []>;
93 def SPUmpyu_i32: SDNode<"SPUISD::MPYU", SDTIntBinOp, []>;
94
95 // SPU 16-bit multiply high x low, shift result 16-bits
96 // Used to compute intermediate products for 32-bit multiplies
97 def SPUmpyh_v4i32: SDNode<"SPUISD::MPYH", SPUv4i32_binop, []>;
98 def SPUmpyh_i32: SDNode<"SPUISD::MPYH", SDTIntBinOp, []>;
99
100 // SPU 16-bit multiply high x high, 32-bit product
101 // Used to compute intermediate products for 16-bit multiplies
102 def SPUmpyhh_v8i16: SDNode<"SPUISD::MPYHH", SPUv8i16_binop, []>;
103
104 // Shift left quadword by bits and bytes
105 def SPUshlquad_l_bits: SDNode<"SPUISD::SHLQUAD_L_BITS", SPUvecshift_type, []>;
106 def SPUshlquad_l_bytes: SDNode<"SPUISD::SHLQUAD_L_BYTES", SPUvecshift_type, []>;
107
108 // Vector shifts (ISD::SHL,SRL,SRA are for _integers_ only):
109 def SPUvec_shl: SDNode<"SPUISD::VEC_SHL", SPUvecshift_type, []>;
110 def SPUvec_srl: SDNode<"SPUISD::VEC_SRL", SPUvecshift_type, []>;
111 def SPUvec_sra: SDNode<"SPUISD::VEC_SRA", SPUvecshift_type, []>;
112
113 def SPUvec_rotl: SDNode<"SPUISD::VEC_ROTL", SPUvecshift_type, []>;
114 def SPUvec_rotr: SDNode<"SPUISD::VEC_ROTR", SPUvecshift_type, []>;
115
116 def SPUrotquad_rz_bytes: SDNode<"SPUISD::ROTQUAD_RZ_BYTES",
117                                     SPUvecshift_type, []>;
118 def SPUrotquad_rz_bits: SDNode<"SPUISD::ROTQUAD_RZ_BITS",
119                                     SPUvecshift_type, []>;
120
121 def SPUrotbytes_right_sfill: SDNode<"SPUISD::ROTBYTES_RIGHT_S",
122                                     SPUvecshift_type, []>;
123
124 def SPUrotbytes_left: SDNode<"SPUISD::ROTBYTES_LEFT",
125                              SPUvecshift_type, []>;
126
127 def SPUrotbytes_left_chained : SDNode<"SPUISD::ROTBYTES_LEFT_CHAINED",
128                                       SPUvecshift_type, [SDNPHasChain]>;
129
130 // SPU form select mask for bytes, immediate
131 def SPUfsmbi: SDNode<"SPUISD::FSMBI", SPUfsmbi_type, []>;
132
133 // SPU select bits instruction
134 def SPUselb: SDNode<"SPUISD::SELB", SPUselb_type, []>;
135
136 // SPU floating point interpolate
137 def SPUinterpolate : SDNode<"SPUISD::FPInterp", SDTFPBinOp, []>;
138
139 // SPU floating point reciprocal estimate (used for fdiv)
140 def SPUreciprocalEst: SDNode<"SPUISD::FPRecipEst", SDTFPUnaryOp, []>;
141
142 def SDTpromote_scalar: SDTypeProfile<1, 1, []>;
143 def SPUpromote_scalar: SDNode<"SPUISD::PROMOTE_SCALAR", SDTpromote_scalar, []>;
144
145 def SPU_vec_demote   : SDTypeProfile<1, 1, []>;
146 def SPUextract_elt0: SDNode<"SPUISD::EXTRACT_ELT0", SPU_vec_demote, []>;
147 def SPU_vec_demote_chained : SDTypeProfile<1, 2, []>;
148 def SPUextract_elt0_chained: SDNode<"SPUISD::EXTRACT_ELT0_CHAINED",
149                                     SPU_vec_demote_chained, [SDNPHasChain]>;
150 def SPUextract_i1_sext: SDNode<"SPUISD::EXTRACT_I1_SEXT", SPU_vec_demote, []>;
151 def SPUextract_i1_zext: SDNode<"SPUISD::EXTRACT_I1_ZEXT", SPU_vec_demote, []>;
152 def SPUextract_i8_sext: SDNode<"SPUISD::EXTRACT_I8_SEXT", SPU_vec_demote, []>;
153 def SPUextract_i8_zext: SDNode<"SPUISD::EXTRACT_I8_ZEXT", SPU_vec_demote, []>;
154
155 // Address high and low components, used for [r+r] type addressing
156 def SPUhi : SDNode<"SPUISD::Hi", SDTIntBinOp, []>;
157 def SPUlo : SDNode<"SPUISD::Lo", SDTIntBinOp, []>;
158
159 // PC-relative address
160 def SPUpcrel : SDNode<"SPUISD::PCRelAddr", SDTIntBinOp, []>;
161
162 // A-Form local store addresses
163 def SPUaform : SDNode<"SPUISD::AFormAddr", SDTIntBinOp, []>;
164
165 // Indirect [D-Form "imm($reg)" and X-Form "$reg($reg)"] addresses
166 def SPUindirect : SDNode<"SPUISD::IndirectAddr", SDTIntBinOp, []>;
167
168 // SPU 32-bit sign-extension to 64-bits
169 def SPUsext32_to_64: SDNode<"SPUISD::SEXT32TO64", SDTIntExtendOp, []>;
170
171 // Branches:
172
173 def SPUbrnz : SDNode<"SPUISD::BR_NOTZERO", SDTBrcond,  [SDNPHasChain]>;
174 def SPUbrz  : SDNode<"SPUISD::BR_ZERO",    SDTBrcond,  [SDNPHasChain]>;
175 /* def SPUbinz : SDNode<"SPUISD::BR_NOTZERO", SDTBrind,   [SDNPHasChain]>;
176 def SPUbiz  : SDNode<"SPUISD::BR_ZERO",    SPUBrind,   [SDNPHasChain]>; */
177
178 //===----------------------------------------------------------------------===//
179 // Constraints: (taken from PPCInstrInfo.td)
180 //===----------------------------------------------------------------------===//
181
182 class RegConstraint<string C> {
183   string Constraints = C;
184 }
185
186 class NoEncode<string E> {
187   string DisableEncoding = E;
188 }
189
190 //===----------------------------------------------------------------------===//
191 // Return (flag isn't quite what it means: the operations are flagged so that
192 // instruction scheduling doesn't disassociate them.)
193 //===----------------------------------------------------------------------===//
194
195 def retflag     : SDNode<"SPUISD::RET_FLAG", SDTNone,
196                          [SDNPHasChain, SDNPOptInFlag]>;