blob: 0725d72e0f38992fd37a156f347bbddec4aefc82 [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
Scott Michel1df30c42008-12-29 03:23:36 +000038// Vector binary operator type constraints (needs a further constraint to
39// ensure that operand 0 is a vector...):
Scott Michel564427e2007-12-05 01:24:05 +000040
Scott Michel1df30c42008-12-29 03:23:36 +000041def SPUVecBinop: SDTypeProfile<1, 2, [
42 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>
43]>;
Scott Michel564427e2007-12-05 01:24:05 +000044
Scott Michel8bf61e82008-06-02 22:18:03 +000045// Trinary operators, e.g., addx, carry generate
46def 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
Scott Michel564427e2007-12-05 01:24:05 +000051// vector types (this avoids having to bit_convert all over the place.)
Scott Michel8bf61e82008-06-02 22:18:03 +000052def SPUselmask_type: SDTypeProfile<1, 1, [
Scott Michel203b2d62008-04-30 00:30:08 +000053 SDTCisInt<1>
54]>;
Scott Michel564427e2007-12-05 01:24:05 +000055
56// SELB type constraints:
Scott Michela59d4692008-02-23 18:41:37 +000057def SPUselb_type: SDTypeProfile<1, 3, [
58 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisSameAs<0, 3> ]>;
Scott Michel564427e2007-12-05 01:24:05 +000059
60// SPU Vector shift pseudo-instruction type constraints
Scott Michela59d4692008-02-23 18:41:37 +000061def SPUvecshift_type: SDTypeProfile<1, 2, [
62 SDTCisSameAs<0, 1>, SDTCisInt<2>]>;
Scott Michel564427e2007-12-05 01:24:05 +000063
Scott Michelf0569be2008-12-27 04:51:36 +000064// 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.
67def SPUgatherbits_type: SDTypeProfile<1, 1, [
68 /* no type constraints defined */
69]>;
70
Scott Michel564427e2007-12-05 01:24:05 +000071//===----------------------------------------------------------------------===//
72// Synthetic/pseudo-instructions
73//===----------------------------------------------------------------------===//
74
Scott Michel8bf61e82008-06-02 22:18:03 +000075/// Add extended, carry generate:
76def SPUaddx : SDNode<"SPUISD::ADD_EXTENDED", SPUIntTrinaryOp, []>;
77def SPUcarry_gen : SDNode<"SPUISD::CARRY_GENERATE", SDTIntBinOp, []>;
78
79// Subtract extended, borrow generate
80def SPUsubx : SDNode<"SPUISD::SUB_EXTENDED", SPUIntTrinaryOp, []>;
81def SPUborrow_gen : SDNode<"SPUISD::BORROW_GENERATE", SDTIntBinOp, []>;
82
Scott Michel564427e2007-12-05 01:24:05 +000083// SPU CNTB:
Scott Michel8bf61e82008-06-02 22:18:03 +000084def SPUcntb : SDNode<"SPUISD::CNTB", SDTIntUnaryOp>;
Scott Michel564427e2007-12-05 01:24:05 +000085
86// SPU vector shuffle node, matched by the SPUISD::SHUFB enum (see
87// SPUISelLowering.h):
88def SPUshuffle: SDNode<"SPUISD::SHUFB", SDT_SPUshuffle, []>;
89
Scott Michela59d4692008-02-23 18:41:37 +000090// Shift left quadword by bits and bytes
91def SPUshlquad_l_bits: SDNode<"SPUISD::SHLQUAD_L_BITS", SPUvecshift_type, []>;
92def SPUshlquad_l_bytes: SDNode<"SPUISD::SHLQUAD_L_BYTES", SPUvecshift_type, []>;
93
Scott Michel564427e2007-12-05 01:24:05 +000094// Vector shifts (ISD::SHL,SRL,SRA are for _integers_ only):
Scott Michela59d4692008-02-23 18:41:37 +000095def SPUvec_shl: SDNode<"SPUISD::VEC_SHL", SPUvecshift_type, []>;
96def SPUvec_srl: SDNode<"SPUISD::VEC_SRL", SPUvecshift_type, []>;
97def SPUvec_sra: SDNode<"SPUISD::VEC_SRA", SPUvecshift_type, []>;
Scott Michel564427e2007-12-05 01:24:05 +000098
Scott Michela59d4692008-02-23 18:41:37 +000099def SPUvec_rotl: SDNode<"SPUISD::VEC_ROTL", SPUvecshift_type, []>;
100def SPUvec_rotr: SDNode<"SPUISD::VEC_ROTR", SPUvecshift_type, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000101
Scott Michel8bf61e82008-06-02 22:18:03 +0000102// Vector rotate left, bits shifted out of the left are rotated in on the right
Scott Michel564427e2007-12-05 01:24:05 +0000103def SPUrotbytes_left: SDNode<"SPUISD::ROTBYTES_LEFT",
Scott Michela59d4692008-02-23 18:41:37 +0000104 SPUvecshift_type, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000105
Scott Michel8bf61e82008-06-02 22:18:03 +0000106// Vector rotate left by bytes, but the count is given in bits and the SPU
107// internally converts it to bytes (saves an instruction to mask off lower
108// three bits)
109def SPUrotbytes_left_bits : SDNode<"SPUISD::ROTBYTES_LEFT_BITS",
110 SPUvecshift_type>;
111
Scott Michel564427e2007-12-05 01:24:05 +0000112// SPU form select mask for bytes, immediate
Scott Michel8bf61e82008-06-02 22:18:03 +0000113def SPUselmask: SDNode<"SPUISD::SELECT_MASK", SPUselmask_type, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000114
115// SPU select bits instruction
Scott Michela59d4692008-02-23 18:41:37 +0000116def SPUselb: SDNode<"SPUISD::SELB", SPUselb_type, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000117
Scott Michelf0569be2008-12-27 04:51:36 +0000118// SPU gather bits instruction:
119def SPUgatherbits: SDNode<"SPUISD::GATHER_BITS", SPUgatherbits_type, []>;
120
Scott Michelf0569be2008-12-27 04:51:36 +0000121def SDTprefslot2vec: SDTypeProfile<1, 1, []>;
122def SPUprefslot2vec: SDNode<"SPUISD::PREFSLOT2VEC", SDTprefslot2vec, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000123
124def SPU_vec_demote : SDTypeProfile<1, 1, []>;
Scott Michel104de432008-11-24 17:11:17 +0000125def SPUvec2prefslot: SDNode<"SPUISD::VEC2PREFSLOT", SPU_vec_demote, []>;
Scott Michel564427e2007-12-05 01:24:05 +0000126
127// Address high and low components, used for [r+r] type addressing
128def SPUhi : SDNode<"SPUISD::Hi", SDTIntBinOp, []>;
129def SPUlo : SDNode<"SPUISD::Lo", SDTIntBinOp, []>;
130
131// PC-relative address
132def SPUpcrel : SDNode<"SPUISD::PCRelAddr", SDTIntBinOp, []>;
133
Scott Michel9de5d0d2008-01-11 02:53:15 +0000134// A-Form local store addresses
135def SPUaform : SDNode<"SPUISD::AFormAddr", SDTIntBinOp, []>;
136
Scott Michel053c1da2008-01-29 02:16:57 +0000137// Indirect [D-Form "imm($reg)" and X-Form "$reg($reg)"] addresses
138def SPUindirect : SDNode<"SPUISD::IndirectAddr", SDTIntBinOp, []>;
Scott Michel9de5d0d2008-01-11 02:53:15 +0000139
Scott Michel564427e2007-12-05 01:24:05 +0000140//===----------------------------------------------------------------------===//
141// Constraints: (taken from PPCInstrInfo.td)
142//===----------------------------------------------------------------------===//
143
144class RegConstraint<string C> {
145 string Constraints = C;
146}
147
148class NoEncode<string E> {
149 string DisableEncoding = E;
150}
151
152//===----------------------------------------------------------------------===//
153// Return (flag isn't quite what it means: the operations are flagged so that
154// instruction scheduling doesn't disassociate them.)
155//===----------------------------------------------------------------------===//
156
Chris Lattner48be23c2008-01-15 22:02:54 +0000157def retflag : SDNode<"SPUISD::RET_FLAG", SDTNone,
Scott Michel564427e2007-12-05 01:24:05 +0000158 [SDNPHasChain, SDNPOptInFlag]>;