blob: a47e9ef0167c248533b315c9f0e9f9b358d39d72 [file] [log] [blame]
Jia Liu31d157a2012-02-18 12:03:15 +00001//=== SPUNodes.td - Specialized SelectionDAG nodes by CellSPU -*- tablegen -*-//
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,
Chris Lattner036609b2010-12-23 18:28:41 +000022 [SDNPHasChain, SDNPOutGlue]>;
Scott Michel564427e2007-12-05 01:24:05 +000023def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_SPUCallSeq,
Chris Lattner036609b2010-12-23 18:28:41 +000024 [SDNPHasChain, SDNPInGlue, SDNPOutGlue]>;
Scott Michel564427e2007-12-05 01:24:05 +000025//===----------------------------------------------------------------------===//
26// Operand constraints:
27//===----------------------------------------------------------------------===//
28
Chris Lattnerdd6fbd12010-03-08 18:59:49 +000029def SDT_SPUCall : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>;
Scott Michel564427e2007-12-05 01:24:05 +000030def SPUcall : SDNode<"SPUISD::CALL", SDT_SPUCall,
Chris Lattner036609b2010-12-23 18:28:41 +000031 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
Chris Lattner60e9eac2010-03-19 05:33:51 +000032 SDNPVariadic]>;
Scott Michel564427e2007-12-05 01:24:05 +000033
34// Operand type constraints for vector shuffle/permute operations
35def SDT_SPUshuffle : SDTypeProfile<1, 3, [
Scott Michela59d4692008-02-23 18:41:37 +000036 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>
Scott Michel564427e2007-12-05 01:24:05 +000037]>;
38
Scott Michel1df30c42008-12-29 03:23:36 +000039// Vector binary operator type constraints (needs a further constraint to
40// ensure that operand 0 is a vector...):
Scott Michel564427e2007-12-05 01:24:05 +000041
Scott Michel1df30c42008-12-29 03:23:36 +000042def SPUVecBinop: SDTypeProfile<1, 2, [
43 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>
44]>;
Scott Michel564427e2007-12-05 01:24:05 +000045
Scott Michel8bf61e82008-06-02 22:18:03 +000046// Trinary operators, e.g., addx, carry generate
47def SPUIntTrinaryOp : SDTypeProfile<1, 3, [
48 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>, SDTCisInt<0>
49]>;
50
51// SELECT_MASK type constraints: There are several variations for the various
Scott Michel564427e2007-12-05 01:24:05 +000052// vector types (this avoids having to bit_convert all over the place.)
Scott Michel8bf61e82008-06-02 22:18:03 +000053def SPUselmask_type: SDTypeProfile<1, 1, [
Scott Michel203b2d62008-04-30 00:30:08 +000054 SDTCisInt<1>
55]>;
Scott Michel564427e2007-12-05 01:24:05 +000056
57// SELB type constraints:
Scott Michela59d4692008-02-23 18:41:37 +000058def SPUselb_type: SDTypeProfile<1, 3, [
59 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisSameAs<0, 3> ]>;
Scott Michel564427e2007-12-05 01:24:05 +000060
61// SPU Vector shift pseudo-instruction type constraints
Scott Michela59d4692008-02-23 18:41:37 +000062def SPUvecshift_type: SDTypeProfile<1, 2, [
63 SDTCisSameAs<0, 1>, SDTCisInt<2>]>;
Scott Michel564427e2007-12-05 01:24:05 +000064
Scott Michel94bd57e2009-01-15 04:41:47 +000065// "marker" type for i64 operators that need a shuffle mask
66// (i.e., uses cg or bg or another instruction that needs to
67// use shufb to get things in the right place.)
68// Op0: The result
69// Op1, 2: LHS, RHS
70// Op3: Carry-generate shuffle mask
71
72def SPUmarker_type : SDTypeProfile<1, 3, [
73 SDTCisInt<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2> ]>;
74
Scott Michel564427e2007-12-05 01:24:05 +000075//===----------------------------------------------------------------------===//
76// Synthetic/pseudo-instructions
77//===----------------------------------------------------------------------===//
78
79// SPU CNTB:
Scott Michel8bf61e82008-06-02 22:18:03 +000080def SPUcntb : SDNode<"SPUISD::CNTB", SDTIntUnaryOp>;
Scott Michel564427e2007-12-05 01:24:05 +000081
82// SPU vector shuffle node, matched by the SPUISD::SHUFB enum (see
83// SPUISelLowering.h):
84def SPUshuffle: SDNode<"SPUISD::SHUFB", SDT_SPUshuffle, []>;
85
Scott Michel564427e2007-12-05 01:24:05 +000086// Vector shifts (ISD::SHL,SRL,SRA are for _integers_ only):
Scott Michelf1fa4fd2009-08-24 22:28:53 +000087def SPUvec_shl: SDNode<"ISD::SHL", SPUvecshift_type, []>;
88def SPUvec_srl: SDNode<"ISD::SRL", SPUvecshift_type, []>;
89def SPUvec_sra: SDNode<"ISD::SRA", SPUvecshift_type, []>;
Scott Michel564427e2007-12-05 01:24:05 +000090
Scott Michela59d4692008-02-23 18:41:37 +000091def SPUvec_rotl: SDNode<"SPUISD::VEC_ROTL", SPUvecshift_type, []>;
92def SPUvec_rotr: SDNode<"SPUISD::VEC_ROTR", SPUvecshift_type, []>;
Scott Michel564427e2007-12-05 01:24:05 +000093
Scott Michel8bf61e82008-06-02 22:18:03 +000094// Vector rotate left, bits shifted out of the left are rotated in on the right
Scott Michel564427e2007-12-05 01:24:05 +000095def SPUrotbytes_left: SDNode<"SPUISD::ROTBYTES_LEFT",
Scott Michela59d4692008-02-23 18:41:37 +000096 SPUvecshift_type, []>;
Scott Michel564427e2007-12-05 01:24:05 +000097
Scott Michel8bf61e82008-06-02 22:18:03 +000098// Vector rotate left by bytes, but the count is given in bits and the SPU
99// internally converts it to bytes (saves an instruction to mask off lower
100// three bits)
101def SPUrotbytes_left_bits : SDNode<"SPUISD::ROTBYTES_LEFT_BITS",
102 SPUvecshift_type>;
103
Kalle Raiskila7ea1ab52010-11-12 10:14:03 +0000104// Shift entire quad left by bytes/bits. Zeros are shifted in on the right
105// SHL_BITS the same as SHL for i128, but ISD::SHL is not implemented for i128
106def SPUshlquad_l_bytes: SDNode<"SPUISD::SHL_BYTES", SPUvecshift_type, []>;
107def SPUshlquad_l_bits: SDNode<"SPUISD::SHL_BITS", SPUvecshift_type, []>;
108def SPUsrl_bytes: SDNode<"SPUISD::SRL_BYTES", SPUvecshift_type, []>;
109
Scott Michel564427e2007-12-05 01:24:05 +0000110// SPU form select mask for bytes, immediate
Scott Michel8bf61e82008-06-02 22:18:03 +0000111def SPUselmask: SDNode<"SPUISD::SELECT_MASK", SPUselmask_type, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000112
113// SPU select bits instruction
Scott Michela59d4692008-02-23 18:41:37 +0000114def SPUselb: SDNode<"SPUISD::SELB", SPUselb_type, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000115
Scott Michelf0569be2008-12-27 04:51:36 +0000116def SDTprefslot2vec: SDTypeProfile<1, 1, []>;
117def SPUprefslot2vec: SDNode<"SPUISD::PREFSLOT2VEC", SDTprefslot2vec, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000118
119def SPU_vec_demote : SDTypeProfile<1, 1, []>;
Scott Michel104de432008-11-24 17:11:17 +0000120def SPUvec2prefslot: SDNode<"SPUISD::VEC2PREFSLOT", SPU_vec_demote, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000121
122// Address high and low components, used for [r+r] type addressing
123def SPUhi : SDNode<"SPUISD::Hi", SDTIntBinOp, []>;
124def SPUlo : SDNode<"SPUISD::Lo", SDTIntBinOp, []>;
125
126// PC-relative address
127def SPUpcrel : SDNode<"SPUISD::PCRelAddr", SDTIntBinOp, []>;
128
Scott Michel9de5d0d2008-01-11 02:53:15 +0000129// A-Form local store addresses
130def SPUaform : SDNode<"SPUISD::AFormAddr", SDTIntBinOp, []>;
131
Scott Michel053c1da2008-01-29 02:16:57 +0000132// Indirect [D-Form "imm($reg)" and X-Form "$reg($reg)"] addresses
133def SPUindirect : SDNode<"SPUISD::IndirectAddr", SDTIntBinOp, []>;
Scott Michel9de5d0d2008-01-11 02:53:15 +0000134
Scott Michel94bd57e2009-01-15 04:41:47 +0000135// i64 markers: supplies extra operands used to generate the i64 operator
136// instruction sequences
137def SPUadd64 : SDNode<"SPUISD::ADD64_MARKER", SPUmarker_type, []>;
138def SPUsub64 : SDNode<"SPUISD::SUB64_MARKER", SPUmarker_type, []>;
139def SPUmul64 : SDNode<"SPUISD::MUL64_MARKER", SPUmarker_type, []>;
140
Scott Michel564427e2007-12-05 01:24:05 +0000141//===----------------------------------------------------------------------===//
142// Constraints: (taken from PPCInstrInfo.td)
143//===----------------------------------------------------------------------===//
144
145class RegConstraint<string C> {
146 string Constraints = C;
147}
148
149class NoEncode<string E> {
150 string DisableEncoding = E;
151}
152
153//===----------------------------------------------------------------------===//
154// Return (flag isn't quite what it means: the operations are flagged so that
155// instruction scheduling doesn't disassociate them.)
156//===----------------------------------------------------------------------===//
157
Chris Lattner48be23c2008-01-15 22:02:54 +0000158def retflag : SDNode<"SPUISD::RET_FLAG", SDTNone,
Chris Lattner036609b2010-12-23 18:28:41 +0000159 [SDNPHasChain, SDNPOptInGlue]>;