blob: 1ed1e3ba51efb0c5e76e86872737529f02ee733c [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, []>;
Scott Michel7a1c9e92008-11-22 23:50:42 +000019def SPUshufmask : SDNode<"SPUISD::SHUFFLE_MASK", SPU_GenControl, []>;
Scott Michel564427e2007-12-05 01:24:05 +000020
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:
Scott Michel564427e2007-12-05 01:24:05 +000039def SPUv16i8_binop: SDTypeProfile<1, 2, [
40 SDTCisVT<0, v16i8>, SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>]>;
41
42// Binary v8i16 operator type constraints:
Scott Michel564427e2007-12-05 01:24:05 +000043def SPUv8i16_binop: SDTypeProfile<1, 2, [
44 SDTCisVT<0, v8i16>, SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>]>;
45
46// Binary v4i32 operator type constraints:
Scott Michel564427e2007-12-05 01:24:05 +000047def SPUv4i32_binop: SDTypeProfile<1, 2, [
48 SDTCisVT<0, v4i32>, SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>]>;
49
Scott Michel8bf61e82008-06-02 22:18:03 +000050// Trinary operators, e.g., addx, carry generate
51def SPUIntTrinaryOp : SDTypeProfile<1, 3, [
52 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>, SDTCisInt<0>
53]>;
54
55// SELECT_MASK type constraints: There are several variations for the various
Scott Michel564427e2007-12-05 01:24:05 +000056// vector types (this avoids having to bit_convert all over the place.)
Scott Michel8bf61e82008-06-02 22:18:03 +000057def SPUselmask_type: SDTypeProfile<1, 1, [
Scott Michel203b2d62008-04-30 00:30:08 +000058 SDTCisInt<1>
59]>;
Scott Michel564427e2007-12-05 01:24:05 +000060
61// SELB type constraints:
Scott Michela59d4692008-02-23 18:41:37 +000062def SPUselb_type: SDTypeProfile<1, 3, [
63 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisSameAs<0, 3> ]>;
Scott Michel564427e2007-12-05 01:24:05 +000064
65// SPU Vector shift pseudo-instruction type constraints
Scott Michela59d4692008-02-23 18:41:37 +000066def SPUvecshift_type: SDTypeProfile<1, 2, [
67 SDTCisSameAs<0, 1>, SDTCisInt<2>]>;
Scott Michel564427e2007-12-05 01:24:05 +000068
69//===----------------------------------------------------------------------===//
70// Synthetic/pseudo-instructions
71//===----------------------------------------------------------------------===//
72
Scott Michel8bf61e82008-06-02 22:18:03 +000073/// Add extended, carry generate:
74def SPUaddx : SDNode<"SPUISD::ADD_EXTENDED", SPUIntTrinaryOp, []>;
75def SPUcarry_gen : SDNode<"SPUISD::CARRY_GENERATE", SDTIntBinOp, []>;
76
77// Subtract extended, borrow generate
78def SPUsubx : SDNode<"SPUISD::SUB_EXTENDED", SPUIntTrinaryOp, []>;
79def SPUborrow_gen : SDNode<"SPUISD::BORROW_GENERATE", SDTIntBinOp, []>;
80
Scott Michel564427e2007-12-05 01:24:05 +000081// SPU CNTB:
Scott Michel8bf61e82008-06-02 22:18:03 +000082def SPUcntb : SDNode<"SPUISD::CNTB", SDTIntUnaryOp>;
Scott Michel564427e2007-12-05 01:24:05 +000083
84// SPU vector shuffle node, matched by the SPUISD::SHUFB enum (see
85// SPUISelLowering.h):
86def SPUshuffle: SDNode<"SPUISD::SHUFB", SDT_SPUshuffle, []>;
87
88// SPU 16-bit multiply
89def SPUmpy_v16i8: SDNode<"SPUISD::MPY", SPUv16i8_binop, []>;
90def SPUmpy_v8i16: SDNode<"SPUISD::MPY", SPUv8i16_binop, []>;
91def SPUmpy_v4i32: SDNode<"SPUISD::MPY", SPUv4i32_binop, []>;
92
93// SPU multiply unsigned, used in instruction lowering for v4i32
94// multiplies:
95def SPUmpyu_v4i32: SDNode<"SPUISD::MPYU", SPUv4i32_binop, []>;
96def SPUmpyu_i32: 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
100def SPUmpyh_v4i32: SDNode<"SPUISD::MPYH", SPUv4i32_binop, []>;
101def SPUmpyh_i32: 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
105def SPUmpyhh_v8i16: SDNode<"SPUISD::MPYHH", SPUv8i16_binop, []>;
106
Scott Michela59d4692008-02-23 18:41:37 +0000107// Shift left quadword by bits and bytes
108def SPUshlquad_l_bits: SDNode<"SPUISD::SHLQUAD_L_BITS", SPUvecshift_type, []>;
109def SPUshlquad_l_bytes: SDNode<"SPUISD::SHLQUAD_L_BYTES", SPUvecshift_type, []>;
110
Scott Michel564427e2007-12-05 01:24:05 +0000111// Vector shifts (ISD::SHL,SRL,SRA are for _integers_ only):
Scott Michela59d4692008-02-23 18:41:37 +0000112def SPUvec_shl: SDNode<"SPUISD::VEC_SHL", SPUvecshift_type, []>;
113def SPUvec_srl: SDNode<"SPUISD::VEC_SRL", SPUvecshift_type, []>;
114def SPUvec_sra: SDNode<"SPUISD::VEC_SRA", SPUvecshift_type, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000115
Scott Michela59d4692008-02-23 18:41:37 +0000116def SPUvec_rotl: SDNode<"SPUISD::VEC_ROTL", SPUvecshift_type, []>;
117def SPUvec_rotr: SDNode<"SPUISD::VEC_ROTR", SPUvecshift_type, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000118
Scott Michela59d4692008-02-23 18:41:37 +0000119def SPUrotquad_rz_bytes: SDNode<"SPUISD::ROTQUAD_RZ_BYTES",
120 SPUvecshift_type, []>;
121def SPUrotquad_rz_bits: SDNode<"SPUISD::ROTQUAD_RZ_BITS",
122 SPUvecshift_type, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000123
Scott Michel8bf61e82008-06-02 22:18:03 +0000124// Vector rotate left, bits shifted out of the left are rotated in on the right
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
Scott Michel8bf61e82008-06-02 22:18:03 +0000128// Vector rotate left by bytes, but the count is given in bits and the SPU
129// internally converts it to bytes (saves an instruction to mask off lower
130// three bits)
131def SPUrotbytes_left_bits : SDNode<"SPUISD::ROTBYTES_LEFT_BITS",
132 SPUvecshift_type>;
133
Scott Michel564427e2007-12-05 01:24:05 +0000134// SPU form select mask for bytes, immediate
Scott Michel8bf61e82008-06-02 22:18:03 +0000135def SPUselmask: SDNode<"SPUISD::SELECT_MASK", SPUselmask_type, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000136
137// SPU select bits instruction
Scott Michela59d4692008-02-23 18:41:37 +0000138def SPUselb: SDNode<"SPUISD::SELB", SPUselb_type, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000139
140// SPU floating point interpolate
141def SPUinterpolate : SDNode<"SPUISD::FPInterp", SDTFPBinOp, []>;
142
143// SPU floating point reciprocal estimate (used for fdiv)
144def SPUreciprocalEst: SDNode<"SPUISD::FPRecipEst", SDTFPUnaryOp, []>;
145
Scott Michela59d4692008-02-23 18:41:37 +0000146def SDTpromote_scalar: SDTypeProfile<1, 1, []>;
147def SPUpromote_scalar: SDNode<"SPUISD::PROMOTE_SCALAR", SDTpromote_scalar, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000148
149def SPU_vec_demote : SDTypeProfile<1, 1, []>;
Scott Michel104de432008-11-24 17:11:17 +0000150def SPUvec2prefslot: SDNode<"SPUISD::VEC2PREFSLOT", SPU_vec_demote, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000151
152// Address high and low components, used for [r+r] type addressing
153def SPUhi : SDNode<"SPUISD::Hi", SDTIntBinOp, []>;
154def SPUlo : SDNode<"SPUISD::Lo", SDTIntBinOp, []>;
155
156// PC-relative address
157def SPUpcrel : SDNode<"SPUISD::PCRelAddr", SDTIntBinOp, []>;
158
Scott Michel9de5d0d2008-01-11 02:53:15 +0000159// A-Form local store addresses
160def SPUaform : SDNode<"SPUISD::AFormAddr", SDTIntBinOp, []>;
161
Scott Michel053c1da2008-01-29 02:16:57 +0000162// Indirect [D-Form "imm($reg)" and X-Form "$reg($reg)"] addresses
163def SPUindirect : SDNode<"SPUISD::IndirectAddr", SDTIntBinOp, []>;
Scott Michel9de5d0d2008-01-11 02:53:15 +0000164
Scott Michel564427e2007-12-05 01:24:05 +0000165// SPU 32-bit sign-extension to 64-bits
166def SPUsext32_to_64: SDNode<"SPUISD::SEXT32TO64", SDTIntExtendOp, []>;
167
168// Branches:
169
170def SPUbrnz : SDNode<"SPUISD::BR_NOTZERO", SDTBrcond, [SDNPHasChain]>;
171def SPUbrz : SDNode<"SPUISD::BR_ZERO", SDTBrcond, [SDNPHasChain]>;
172/* def SPUbinz : SDNode<"SPUISD::BR_NOTZERO", SDTBrind, [SDNPHasChain]>;
173def SPUbiz : SDNode<"SPUISD::BR_ZERO", SPUBrind, [SDNPHasChain]>; */
174
175//===----------------------------------------------------------------------===//
176// Constraints: (taken from PPCInstrInfo.td)
177//===----------------------------------------------------------------------===//
178
179class RegConstraint<string C> {
180 string Constraints = C;
181}
182
183class NoEncode<string E> {
184 string DisableEncoding = E;
185}
186
187//===----------------------------------------------------------------------===//
188// Return (flag isn't quite what it means: the operations are flagged so that
189// instruction scheduling doesn't disassociate them.)
190//===----------------------------------------------------------------------===//
191
Chris Lattner48be23c2008-01-15 22:02:54 +0000192def retflag : SDNode<"SPUISD::RET_FLAG", SDTNone,
Scott Michel564427e2007-12-05 01:24:05 +0000193 [SDNPHasChain, SDNPOptInFlag]>;