- Start moving target-dependent nodes that could be represented by an
[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 // Shift left quadword by bits and bytes
91 def SPUshlquad_l_bits: SDNode<"SPUISD::SHLQUAD_L_BITS", SPUvecshift_type, []>;
92 def SPUshlquad_l_bytes: SDNode<"SPUISD::SHLQUAD_L_BYTES", SPUvecshift_type, []>;
93
94 // Vector shifts (ISD::SHL,SRL,SRA are for _integers_ only):
95 def SPUvec_shl: SDNode<"SPUISD::VEC_SHL", SPUvecshift_type, []>;
96 def SPUvec_srl: SDNode<"SPUISD::VEC_SRL", SPUvecshift_type, []>;
97 def SPUvec_sra: SDNode<"SPUISD::VEC_SRA", SPUvecshift_type, []>;
98
99 def SPUvec_rotl: SDNode<"SPUISD::VEC_ROTL", SPUvecshift_type, []>;
100 def SPUvec_rotr: SDNode<"SPUISD::VEC_ROTR", SPUvecshift_type, []>;
101
102 // Vector rotate left, bits shifted out of the left are rotated in on the right
103 def SPUrotbytes_left: SDNode<"SPUISD::ROTBYTES_LEFT",
104                              SPUvecshift_type, []>;
105
106 // 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)
109 def SPUrotbytes_left_bits : SDNode<"SPUISD::ROTBYTES_LEFT_BITS",
110                                    SPUvecshift_type>;
111
112 // SPU form select mask for bytes, immediate
113 def SPUselmask: SDNode<"SPUISD::SELECT_MASK", SPUselmask_type, []>;
114
115 // SPU select bits instruction
116 def SPUselb: SDNode<"SPUISD::SELB", SPUselb_type, []>;
117
118 // SPU gather bits instruction:
119 def SPUgatherbits: SDNode<"SPUISD::GATHER_BITS", SPUgatherbits_type, []>;
120
121 def SDTprefslot2vec: SDTypeProfile<1, 1, []>;
122 def SPUprefslot2vec: SDNode<"SPUISD::PREFSLOT2VEC", SDTprefslot2vec, []>;
123
124 def SPU_vec_demote   : SDTypeProfile<1, 1, []>;
125 def SPUvec2prefslot: SDNode<"SPUISD::VEC2PREFSLOT", SPU_vec_demote, []>;
126
127 // Address high and low components, used for [r+r] type addressing
128 def SPUhi : SDNode<"SPUISD::Hi", SDTIntBinOp, []>;
129 def SPUlo : SDNode<"SPUISD::Lo", SDTIntBinOp, []>;
130
131 // PC-relative address
132 def SPUpcrel : SDNode<"SPUISD::PCRelAddr", SDTIntBinOp, []>;
133
134 // A-Form local store addresses
135 def SPUaform : SDNode<"SPUISD::AFormAddr", SDTIntBinOp, []>;
136
137 // Indirect [D-Form "imm($reg)" and X-Form "$reg($reg)"] addresses
138 def SPUindirect : SDNode<"SPUISD::IndirectAddr", SDTIntBinOp, []>;
139
140 // SPU 32-bit sign-extension to 64-bits
141 def SPUsext32_to_64: SDNode<"SPUISD::SEXT32TO64", SDTIntExtendOp, []>;
142
143 // Branches:
144
145 def SPUbrnz : SDNode<"SPUISD::BR_NOTZERO", SDTBrcond,  [SDNPHasChain]>;
146 def SPUbrz  : SDNode<"SPUISD::BR_ZERO",    SDTBrcond,  [SDNPHasChain]>;
147 /* def SPUbinz : SDNode<"SPUISD::BR_NOTZERO", SDTBrind,   [SDNPHasChain]>;
148 def SPUbiz  : SDNode<"SPUISD::BR_ZERO",    SPUBrind,   [SDNPHasChain]>; */
149
150 //===----------------------------------------------------------------------===//
151 // Constraints: (taken from PPCInstrInfo.td)
152 //===----------------------------------------------------------------------===//
153
154 class RegConstraint<string C> {
155   string Constraints = C;
156 }
157
158 class NoEncode<string E> {
159   string DisableEncoding = E;
160 }
161
162 //===----------------------------------------------------------------------===//
163 // Return (flag isn't quite what it means: the operations are flagged so that
164 // instruction scheduling doesn't disassociate them.)
165 //===----------------------------------------------------------------------===//
166
167 def retflag     : SDNode<"SPUISD::RET_FLAG", SDTNone,
168                          [SDNPHasChain, SDNPOptInFlag]>;