blob: 00d0f94212a446f332c998db6dbfcf07a7599ff7 [file] [log] [blame]
Chris Lattner4ee451d2007-12-29 20:36:04 +00001//===- SPUNodes.td - Specialized SelectionDAG nodes used for CellSPU ------===//
Scott Michel564427e2007-12-05 01:24:05 +00002//
Scott Michel2466c372007-12-05 01:40:25 +00003// The LLVM Compiler Infrastructure
Scott Michel564427e2007-12-05 01:24:05 +00004//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
Scott Michel564427e2007-12-05 01:24:05 +00008//===----------------------------------------------------------------------===//
9//
10// Type profiles and SelectionDAG nodes used by CellSPU
11//
12//===----------------------------------------------------------------------===//
13
14// Type profile for a call sequence
15def SDT_SPUCallSeq : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
16
17// SPU_GenControl: Type profile for generating control words for insertions
18def SPU_GenControl : SDTypeProfile<1, 1, []>;
19def SPUvecinsmask : SDNode<"SPUISD::INSERT_MASK", SPU_GenControl, []>;
20
21def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_SPUCallSeq,
22 [SDNPHasChain, SDNPOutFlag]>;
23def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_SPUCallSeq,
24 [SDNPHasChain, SDNPOutFlag]>;
25//===----------------------------------------------------------------------===//
26// Operand constraints:
27//===----------------------------------------------------------------------===//
28
29def SDT_SPUCall : SDTypeProfile<0, -1, [SDTCisInt<0>]>;
30def SPUcall : SDNode<"SPUISD::CALL", SDT_SPUCall,
31 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
32
33// Operand type constraints for vector shuffle/permute operations
34def SDT_SPUshuffle : SDTypeProfile<1, 3, [
Scott Michela59d4692008-02-23 18:41:37 +000035 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>
Scott Michel564427e2007-12-05 01:24:05 +000036]>;
37
38// Unary, binary v16i8 operator type constraints:
39def SPUv16i8_unop: SDTypeProfile<1, 1, [
40 SDTCisVT<0, v16i8>, SDTCisSameAs<0, 1>]>;
41
42def SPUv16i8_binop: SDTypeProfile<1, 2, [
43 SDTCisVT<0, v16i8>, SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>]>;
44
45// Binary v8i16 operator type constraints:
46def SPUv8i16_unop: SDTypeProfile<1, 1, [
47 SDTCisVT<0, v8i16>, SDTCisSameAs<0, 1>]>;
48
49def SPUv8i16_binop: SDTypeProfile<1, 2, [
50 SDTCisVT<0, v8i16>, SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>]>;
51
52// Binary v4i32 operator type constraints:
53def SPUv4i32_unop: SDTypeProfile<1, 1, [
54 SDTCisVT<0, v4i32>, SDTCisSameAs<0, 1>]>;
55
56def 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.)
Scott Michel053c1da2008-01-29 02:16:57 +000061def SPUfsmbi_type: SDTypeProfile<1, 1, [
Scott Michel203b2d62008-04-30 00:30:08 +000062 SDTCisInt<1>
63]>;
Scott Michel564427e2007-12-05 01:24:05 +000064
65// SELB type constraints:
Scott Michela59d4692008-02-23 18:41:37 +000066def SPUselb_type: SDTypeProfile<1, 3, [
67 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisSameAs<0, 3> ]>;
Scott Michel564427e2007-12-05 01:24:05 +000068
69// SPU Vector shift pseudo-instruction type constraints
Scott Michela59d4692008-02-23 18:41:37 +000070def SPUvecshift_type: SDTypeProfile<1, 2, [
71 SDTCisSameAs<0, 1>, SDTCisInt<2>]>;
Scott Michel564427e2007-12-05 01:24:05 +000072
73//===----------------------------------------------------------------------===//
74// Synthetic/pseudo-instructions
75//===----------------------------------------------------------------------===//
76
77// SPU CNTB:
78def SPUcntb_v16i8: SDNode<"SPUISD::CNTB", SPUv16i8_unop, []>;
79def SPUcntb_v8i16: SDNode<"SPUISD::CNTB", SPUv8i16_unop, []>;
80def SPUcntb_v4i32: SDNode<"SPUISD::CNTB", SPUv4i32_unop, []>;
81
82// SPU vector shuffle node, matched by the SPUISD::SHUFB enum (see
83// SPUISelLowering.h):
84def SPUshuffle: SDNode<"SPUISD::SHUFB", SDT_SPUshuffle, []>;
85
86// SPU 16-bit multiply
87def SPUmpy_v16i8: SDNode<"SPUISD::MPY", SPUv16i8_binop, []>;
88def SPUmpy_v8i16: SDNode<"SPUISD::MPY", SPUv8i16_binop, []>;
89def SPUmpy_v4i32: SDNode<"SPUISD::MPY", SPUv4i32_binop, []>;
90
91// SPU multiply unsigned, used in instruction lowering for v4i32
92// multiplies:
93def SPUmpyu_v4i32: SDNode<"SPUISD::MPYU", SPUv4i32_binop, []>;
94def SPUmpyu_i32: SDNode<"SPUISD::MPYU", SDTIntBinOp, []>;
95
96// SPU 16-bit multiply high x low, shift result 16-bits
97// Used to compute intermediate products for 32-bit multiplies
98def SPUmpyh_v4i32: SDNode<"SPUISD::MPYH", SPUv4i32_binop, []>;
99def SPUmpyh_i32: SDNode<"SPUISD::MPYH", SDTIntBinOp, []>;
100
101// SPU 16-bit multiply high x high, 32-bit product
102// Used to compute intermediate products for 16-bit multiplies
103def SPUmpyhh_v8i16: SDNode<"SPUISD::MPYHH", SPUv8i16_binop, []>;
104
Scott Michela59d4692008-02-23 18:41:37 +0000105// Shift left quadword by bits and bytes
106def SPUshlquad_l_bits: SDNode<"SPUISD::SHLQUAD_L_BITS", SPUvecshift_type, []>;
107def SPUshlquad_l_bytes: SDNode<"SPUISD::SHLQUAD_L_BYTES", SPUvecshift_type, []>;
108
Scott Michel564427e2007-12-05 01:24:05 +0000109// Vector shifts (ISD::SHL,SRL,SRA are for _integers_ only):
Scott Michela59d4692008-02-23 18:41:37 +0000110def SPUvec_shl: SDNode<"SPUISD::VEC_SHL", SPUvecshift_type, []>;
111def SPUvec_srl: SDNode<"SPUISD::VEC_SRL", SPUvecshift_type, []>;
112def SPUvec_sra: SDNode<"SPUISD::VEC_SRA", SPUvecshift_type, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000113
Scott Michela59d4692008-02-23 18:41:37 +0000114def SPUvec_rotl: SDNode<"SPUISD::VEC_ROTL", SPUvecshift_type, []>;
115def SPUvec_rotr: SDNode<"SPUISD::VEC_ROTR", SPUvecshift_type, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000116
Scott Michela59d4692008-02-23 18:41:37 +0000117def SPUrotquad_rz_bytes: SDNode<"SPUISD::ROTQUAD_RZ_BYTES",
118 SPUvecshift_type, []>;
119def SPUrotquad_rz_bits: SDNode<"SPUISD::ROTQUAD_RZ_BITS",
120 SPUvecshift_type, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000121
Scott Michel564427e2007-12-05 01:24:05 +0000122def SPUrotbytes_right_sfill: SDNode<"SPUISD::ROTBYTES_RIGHT_S",
Scott Michela59d4692008-02-23 18:41:37 +0000123 SPUvecshift_type, []>;
124
Scott Michel564427e2007-12-05 01:24:05 +0000125def SPUrotbytes_left: SDNode<"SPUISD::ROTBYTES_LEFT",
Scott Michela59d4692008-02-23 18:41:37 +0000126 SPUvecshift_type, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000127
128def SPUrotbytes_left_chained : SDNode<"SPUISD::ROTBYTES_LEFT_CHAINED",
Scott Michela59d4692008-02-23 18:41:37 +0000129 SPUvecshift_type, [SDNPHasChain]>;
Scott Michel564427e2007-12-05 01:24:05 +0000130
131// SPU form select mask for bytes, immediate
Scott Michel053c1da2008-01-29 02:16:57 +0000132def SPUfsmbi: SDNode<"SPUISD::FSMBI", SPUfsmbi_type, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000133
134// SPU select bits instruction
Scott Michela59d4692008-02-23 18:41:37 +0000135def SPUselb: SDNode<"SPUISD::SELB", SPUselb_type, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000136
137// SPU floating point interpolate
138def SPUinterpolate : SDNode<"SPUISD::FPInterp", SDTFPBinOp, []>;
139
140// SPU floating point reciprocal estimate (used for fdiv)
141def SPUreciprocalEst: SDNode<"SPUISD::FPRecipEst", SDTFPUnaryOp, []>;
142
Scott Michela59d4692008-02-23 18:41:37 +0000143def SDTpromote_scalar: SDTypeProfile<1, 1, []>;
144def SPUpromote_scalar: SDNode<"SPUISD::PROMOTE_SCALAR", SDTpromote_scalar, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000145
146def SPU_vec_demote : SDTypeProfile<1, 1, []>;
147def SPUextract_elt0: SDNode<"SPUISD::EXTRACT_ELT0", SPU_vec_demote, []>;
148def SPU_vec_demote_chained : SDTypeProfile<1, 2, []>;
149def SPUextract_elt0_chained: SDNode<"SPUISD::EXTRACT_ELT0_CHAINED",
150 SPU_vec_demote_chained, [SDNPHasChain]>;
151def SPUextract_i1_sext: SDNode<"SPUISD::EXTRACT_I1_SEXT", SPU_vec_demote, []>;
152def SPUextract_i1_zext: SDNode<"SPUISD::EXTRACT_I1_ZEXT", SPU_vec_demote, []>;
153def SPUextract_i8_sext: SDNode<"SPUISD::EXTRACT_I8_SEXT", SPU_vec_demote, []>;
154def SPUextract_i8_zext: SDNode<"SPUISD::EXTRACT_I8_ZEXT", SPU_vec_demote, []>;
155
156// Address high and low components, used for [r+r] type addressing
157def SPUhi : SDNode<"SPUISD::Hi", SDTIntBinOp, []>;
158def SPUlo : SDNode<"SPUISD::Lo", SDTIntBinOp, []>;
159
160// PC-relative address
161def SPUpcrel : SDNode<"SPUISD::PCRelAddr", SDTIntBinOp, []>;
162
Scott Michel9de5d0d2008-01-11 02:53:15 +0000163// A-Form local store addresses
164def SPUaform : SDNode<"SPUISD::AFormAddr", SDTIntBinOp, []>;
165
Scott Michel053c1da2008-01-29 02:16:57 +0000166// Indirect [D-Form "imm($reg)" and X-Form "$reg($reg)"] addresses
167def SPUindirect : SDNode<"SPUISD::IndirectAddr", SDTIntBinOp, []>;
Scott Michel9de5d0d2008-01-11 02:53:15 +0000168
Scott Michel564427e2007-12-05 01:24:05 +0000169// SPU 32-bit sign-extension to 64-bits
170def SPUsext32_to_64: SDNode<"SPUISD::SEXT32TO64", SDTIntExtendOp, []>;
171
172// Branches:
173
174def SPUbrnz : SDNode<"SPUISD::BR_NOTZERO", SDTBrcond, [SDNPHasChain]>;
175def SPUbrz : SDNode<"SPUISD::BR_ZERO", SDTBrcond, [SDNPHasChain]>;
176/* def SPUbinz : SDNode<"SPUISD::BR_NOTZERO", SDTBrind, [SDNPHasChain]>;
177def SPUbiz : SDNode<"SPUISD::BR_ZERO", SPUBrind, [SDNPHasChain]>; */
178
179//===----------------------------------------------------------------------===//
180// Constraints: (taken from PPCInstrInfo.td)
181//===----------------------------------------------------------------------===//
182
183class RegConstraint<string C> {
184 string Constraints = C;
185}
186
187class 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
Chris Lattner48be23c2008-01-15 22:02:54 +0000196def retflag : SDNode<"SPUISD::RET_FLAG", SDTNone,
Scott Michel564427e2007-12-05 01:24:05 +0000197 [SDNPHasChain, SDNPOptInFlag]>;