Fixed spelling, removed trailing whitespace.
[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 SPUshufmask    : SDNode<"SPUISD::SHUFFLE_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 // Vector binary operator type constraints (needs a further constraint to
39 // ensure that operand 0 is a vector...):
40
41 def SPUVecBinop: SDTypeProfile<1, 2, [
42   SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>
43 ]>;
44
45 // Trinary operators, e.g., addx, carry generate
46 def SPUIntTrinaryOp : SDTypeProfile<1, 3, [
47   SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>, SDTCisInt<0>
48 ]>;
49
50 // SELECT_MASK type constraints: There are several variations for the various
51 // vector types (this avoids having to bit_convert all over the place.)
52 def SPUselmask_type: SDTypeProfile<1, 1, [
53   SDTCisInt<1>
54 ]>;
55
56 // SELB type constraints:
57 def SPUselb_type: SDTypeProfile<1, 3, [
58   SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisSameAs<0, 3> ]>;
59
60 // SPU Vector shift pseudo-instruction type constraints
61 def SPUvecshift_type: SDTypeProfile<1, 2, [
62   SDTCisSameAs<0, 1>, SDTCisInt<2>]>;
63
64 // SPU gather bits:
65 // This instruction looks at each vector (word|halfword|byte) slot's low bit
66 // and forms a mask in the low order bits of the first word's preferred slot.
67 def SPUgatherbits_type: SDTypeProfile<1, 1, [
68   /* no type constraints defined */
69 ]>;
70
71 //===----------------------------------------------------------------------===//
72 // Synthetic/pseudo-instructions
73 //===----------------------------------------------------------------------===//
74
75 /// Add extended, carry generate:
76 def SPUaddx : SDNode<"SPUISD::ADD_EXTENDED", SPUIntTrinaryOp, []>;
77 def SPUcarry_gen : SDNode<"SPUISD::CARRY_GENERATE", SDTIntBinOp, []>;
78
79 // Subtract extended, borrow generate
80 def SPUsubx : SDNode<"SPUISD::SUB_EXTENDED", SPUIntTrinaryOp, []>;
81 def SPUborrow_gen : SDNode<"SPUISD::BORROW_GENERATE", SDTIntBinOp, []>;
82
83 // SPU CNTB:
84 def SPUcntb : SDNode<"SPUISD::CNTB", SDTIntUnaryOp>;
85
86 // SPU vector shuffle node, matched by the SPUISD::SHUFB enum (see
87 // SPUISelLowering.h):
88 def SPUshuffle: SDNode<"SPUISD::SHUFB", SDT_SPUshuffle, []>;
89
90 // SPU 16-bit multiply
91 def SPUmpy_vec: SDNode<"SPUISD::MPY", SPUVecBinop, []>;
92
93 // SPU multiply unsigned, used in instruction lowering for v4i32
94 // multiplies:
95 def SPUmpyu_vec: SDNode<"SPUISD::MPYU", SPUVecBinop, []>;
96 def SPUmpyu_int: SDNode<"SPUISD::MPYU", SDTIntBinOp, []>;
97
98 // SPU 16-bit multiply high x low, shift result 16-bits
99 // Used to compute intermediate products for 32-bit multiplies
100 def SPUmpyh_vec: SDNode<"SPUISD::MPYH", SPUVecBinop, []>;
101 def SPUmpyh_int: SDNode<"SPUISD::MPYH", SDTIntBinOp, []>;
102
103 // SPU 16-bit multiply high x high, 32-bit product
104 // Used to compute intermediate products for 16-bit multiplies
105 def SPUmpyhh_vec: SDNode<"SPUISD::MPYHH", SPUVecBinop, []>;
106 def SPUmpyhh_int: SDNode<"SPUISD::MPYHH", SDTIntBinOp, []>;
107
108 // Shift left quadword by bits and bytes
109 def SPUshlquad_l_bits: SDNode<"SPUISD::SHLQUAD_L_BITS", SPUvecshift_type, []>;
110 def SPUshlquad_l_bytes: SDNode<"SPUISD::SHLQUAD_L_BYTES", SPUvecshift_type, []>;
111
112 // Vector shifts (ISD::SHL,SRL,SRA are for _integers_ only):
113 def SPUvec_shl: SDNode<"SPUISD::VEC_SHL", SPUvecshift_type, []>;
114 def SPUvec_srl: SDNode<"SPUISD::VEC_SRL", SPUvecshift_type, []>;
115 def SPUvec_sra: SDNode<"SPUISD::VEC_SRA", SPUvecshift_type, []>;
116
117 def SPUvec_rotl: SDNode<"SPUISD::VEC_ROTL", SPUvecshift_type, []>;
118 def SPUvec_rotr: SDNode<"SPUISD::VEC_ROTR", SPUvecshift_type, []>;
119
120 def SPUrotquad_rz_bytes: SDNode<"SPUISD::ROTQUAD_RZ_BYTES",
121                                     SPUvecshift_type, []>;
122 def SPUrotquad_rz_bits: SDNode<"SPUISD::ROTQUAD_RZ_BITS",
123                                     SPUvecshift_type, []>;
124
125 // Vector rotate left, bits shifted out of the left are rotated in on the right
126 def SPUrotbytes_left: SDNode<"SPUISD::ROTBYTES_LEFT",
127                              SPUvecshift_type, []>;
128
129 // Vector rotate left by bytes, but the count is given in bits and the SPU
130 // internally converts it to bytes (saves an instruction to mask off lower
131 // three bits)
132 def SPUrotbytes_left_bits : SDNode<"SPUISD::ROTBYTES_LEFT_BITS",
133                                    SPUvecshift_type>;
134
135 // SPU form select mask for bytes, immediate
136 def SPUselmask: SDNode<"SPUISD::SELECT_MASK", SPUselmask_type, []>;
137
138 // SPU select bits instruction
139 def SPUselb: SDNode<"SPUISD::SELB", SPUselb_type, []>;
140
141 // SPU gather bits instruction:
142 def SPUgatherbits: SDNode<"SPUISD::GATHER_BITS", SPUgatherbits_type, []>;
143
144 // SPU floating point interpolate
145 def SPUinterpolate : SDNode<"SPUISD::FPInterp", SDTFPBinOp, []>;
146
147 // SPU floating point reciprocal estimate (used for fdiv)
148 def SPUreciprocalEst: SDNode<"SPUISD::FPRecipEst", SDTFPUnaryOp, []>;
149
150 def SDTprefslot2vec: SDTypeProfile<1, 1, []>;
151 def SPUprefslot2vec: SDNode<"SPUISD::PREFSLOT2VEC", SDTprefslot2vec, []>;
152
153 def SPU_vec_demote   : SDTypeProfile<1, 1, []>;
154 def SPUvec2prefslot: SDNode<"SPUISD::VEC2PREFSLOT", SPU_vec_demote, []>;
155
156 // Address high and low components, used for [r+r] type addressing
157 def SPUhi : SDNode<"SPUISD::Hi", SDTIntBinOp, []>;
158 def SPUlo : SDNode<"SPUISD::Lo", SDTIntBinOp, []>;
159
160 // PC-relative address
161 def SPUpcrel : SDNode<"SPUISD::PCRelAddr", SDTIntBinOp, []>;
162
163 // A-Form local store addresses
164 def SPUaform : SDNode<"SPUISD::AFormAddr", SDTIntBinOp, []>;
165
166 // Indirect [D-Form "imm($reg)" and X-Form "$reg($reg)"] addresses
167 def SPUindirect : SDNode<"SPUISD::IndirectAddr", SDTIntBinOp, []>;
168
169 // SPU 32-bit sign-extension to 64-bits
170 def SPUsext32_to_64: SDNode<"SPUISD::SEXT32TO64", SDTIntExtendOp, []>;
171
172 // Branches:
173
174 def SPUbrnz : SDNode<"SPUISD::BR_NOTZERO", SDTBrcond,  [SDNPHasChain]>;
175 def SPUbrz  : SDNode<"SPUISD::BR_ZERO",    SDTBrcond,  [SDNPHasChain]>;
176 /* def SPUbinz : SDNode<"SPUISD::BR_NOTZERO", SDTBrind,   [SDNPHasChain]>;
177 def SPUbiz  : SDNode<"SPUISD::BR_ZERO",    SPUBrind,   [SDNPHasChain]>; */
178
179 //===----------------------------------------------------------------------===//
180 // Constraints: (taken from PPCInstrInfo.td)
181 //===----------------------------------------------------------------------===//
182
183 class RegConstraint<string C> {
184   string Constraints = C;
185 }
186
187 class NoEncode<string E> {
188   string DisableEncoding = E;
189 }
190
191 //===----------------------------------------------------------------------===//
192 // Return (flag isn't quite what it means: the operations are flagged so that
193 // instruction scheduling doesn't disassociate them.)
194 //===----------------------------------------------------------------------===//
195
196 def retflag     : SDNode<"SPUISD::RET_FLAG", SDTNone,
197                          [SDNPHasChain, SDNPOptInFlag]>;