Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 1 | //===- SPUNodes.td - Specialized SelectionDAG nodes used for CellSPU ------===// |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 2 | // |
Scott Michel | 2466c37 | 2007-12-05 01:40:25 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 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, []>; |
Scott Michel | 7a1c9e9 | 2008-11-22 23:50:42 +0000 | [diff] [blame] | 19 | def SPUshufmask : SDNode<"SPUISD::SHUFFLE_MASK", SPU_GenControl, []>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 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, [ |
Scott Michel | a59d469 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 35 | SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2> |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 36 | ]>; |
| 37 | |
| 38 | // Unary, binary v16i8 operator type constraints: |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 39 | def SPUv16i8_binop: SDTypeProfile<1, 2, [ |
| 40 | SDTCisVT<0, v16i8>, SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>]>; |
| 41 | |
| 42 | // Binary v8i16 operator type constraints: |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 43 | def SPUv8i16_binop: SDTypeProfile<1, 2, [ |
| 44 | SDTCisVT<0, v8i16>, SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>]>; |
| 45 | |
| 46 | // Binary v4i32 operator type constraints: |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 47 | def SPUv4i32_binop: SDTypeProfile<1, 2, [ |
| 48 | SDTCisVT<0, v4i32>, SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>]>; |
| 49 | |
Scott Michel | 8bf61e8 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 50 | // Trinary operators, e.g., addx, carry generate |
| 51 | def 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 Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 56 | // vector types (this avoids having to bit_convert all over the place.) |
Scott Michel | 8bf61e8 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 57 | def SPUselmask_type: SDTypeProfile<1, 1, [ |
Scott Michel | 203b2d6 | 2008-04-30 00:30:08 +0000 | [diff] [blame] | 58 | SDTCisInt<1> |
| 59 | ]>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 60 | |
| 61 | // SELB type constraints: |
Scott Michel | a59d469 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 62 | def SPUselb_type: SDTypeProfile<1, 3, [ |
| 63 | SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisSameAs<0, 3> ]>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 64 | |
| 65 | // SPU Vector shift pseudo-instruction type constraints |
Scott Michel | a59d469 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 66 | def SPUvecshift_type: SDTypeProfile<1, 2, [ |
| 67 | SDTCisSameAs<0, 1>, SDTCisInt<2>]>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 68 | |
Scott Michel | f0569be | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 69 | // SPU gather bits: |
| 70 | // This instruction looks at each vector (word|halfword|byte) slot's low bit |
| 71 | // and forms a mask in the low order bits of the first word's preferred slot. |
| 72 | def SPUgatherbits_type: SDTypeProfile<1, 1, [ |
| 73 | /* no type constraints defined */ |
| 74 | ]>; |
| 75 | |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 76 | //===----------------------------------------------------------------------===// |
| 77 | // Synthetic/pseudo-instructions |
| 78 | //===----------------------------------------------------------------------===// |
| 79 | |
Scott Michel | 8bf61e8 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 80 | /// Add extended, carry generate: |
| 81 | def SPUaddx : SDNode<"SPUISD::ADD_EXTENDED", SPUIntTrinaryOp, []>; |
| 82 | def SPUcarry_gen : SDNode<"SPUISD::CARRY_GENERATE", SDTIntBinOp, []>; |
| 83 | |
| 84 | // Subtract extended, borrow generate |
| 85 | def SPUsubx : SDNode<"SPUISD::SUB_EXTENDED", SPUIntTrinaryOp, []>; |
| 86 | def SPUborrow_gen : SDNode<"SPUISD::BORROW_GENERATE", SDTIntBinOp, []>; |
| 87 | |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 88 | // SPU CNTB: |
Scott Michel | 8bf61e8 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 89 | def SPUcntb : SDNode<"SPUISD::CNTB", SDTIntUnaryOp>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 90 | |
| 91 | // SPU vector shuffle node, matched by the SPUISD::SHUFB enum (see |
| 92 | // SPUISelLowering.h): |
| 93 | def SPUshuffle: SDNode<"SPUISD::SHUFB", SDT_SPUshuffle, []>; |
| 94 | |
| 95 | // SPU 16-bit multiply |
| 96 | def SPUmpy_v16i8: SDNode<"SPUISD::MPY", SPUv16i8_binop, []>; |
| 97 | def SPUmpy_v8i16: SDNode<"SPUISD::MPY", SPUv8i16_binop, []>; |
| 98 | def SPUmpy_v4i32: SDNode<"SPUISD::MPY", SPUv4i32_binop, []>; |
| 99 | |
| 100 | // SPU multiply unsigned, used in instruction lowering for v4i32 |
| 101 | // multiplies: |
| 102 | def SPUmpyu_v4i32: SDNode<"SPUISD::MPYU", SPUv4i32_binop, []>; |
| 103 | def SPUmpyu_i32: SDNode<"SPUISD::MPYU", SDTIntBinOp, []>; |
| 104 | |
| 105 | // SPU 16-bit multiply high x low, shift result 16-bits |
| 106 | // Used to compute intermediate products for 32-bit multiplies |
| 107 | def SPUmpyh_v4i32: SDNode<"SPUISD::MPYH", SPUv4i32_binop, []>; |
| 108 | def SPUmpyh_i32: SDNode<"SPUISD::MPYH", SDTIntBinOp, []>; |
| 109 | |
| 110 | // SPU 16-bit multiply high x high, 32-bit product |
| 111 | // Used to compute intermediate products for 16-bit multiplies |
| 112 | def SPUmpyhh_v8i16: SDNode<"SPUISD::MPYHH", SPUv8i16_binop, []>; |
| 113 | |
Scott Michel | a59d469 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 114 | // Shift left quadword by bits and bytes |
| 115 | def SPUshlquad_l_bits: SDNode<"SPUISD::SHLQUAD_L_BITS", SPUvecshift_type, []>; |
| 116 | def SPUshlquad_l_bytes: SDNode<"SPUISD::SHLQUAD_L_BYTES", SPUvecshift_type, []>; |
| 117 | |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 118 | // Vector shifts (ISD::SHL,SRL,SRA are for _integers_ only): |
Scott Michel | a59d469 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 119 | def SPUvec_shl: SDNode<"SPUISD::VEC_SHL", SPUvecshift_type, []>; |
| 120 | def SPUvec_srl: SDNode<"SPUISD::VEC_SRL", SPUvecshift_type, []>; |
| 121 | def SPUvec_sra: SDNode<"SPUISD::VEC_SRA", SPUvecshift_type, []>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 122 | |
Scott Michel | a59d469 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 123 | def SPUvec_rotl: SDNode<"SPUISD::VEC_ROTL", SPUvecshift_type, []>; |
| 124 | def SPUvec_rotr: SDNode<"SPUISD::VEC_ROTR", SPUvecshift_type, []>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 125 | |
Scott Michel | a59d469 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 126 | def SPUrotquad_rz_bytes: SDNode<"SPUISD::ROTQUAD_RZ_BYTES", |
| 127 | SPUvecshift_type, []>; |
| 128 | def SPUrotquad_rz_bits: SDNode<"SPUISD::ROTQUAD_RZ_BITS", |
| 129 | SPUvecshift_type, []>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 130 | |
Scott Michel | 8bf61e8 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 131 | // Vector rotate left, bits shifted out of the left are rotated in on the right |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 132 | def SPUrotbytes_left: SDNode<"SPUISD::ROTBYTES_LEFT", |
Scott Michel | a59d469 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 133 | SPUvecshift_type, []>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 134 | |
Scott Michel | 8bf61e8 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 135 | // Vector rotate left by bytes, but the count is given in bits and the SPU |
| 136 | // internally converts it to bytes (saves an instruction to mask off lower |
| 137 | // three bits) |
| 138 | def SPUrotbytes_left_bits : SDNode<"SPUISD::ROTBYTES_LEFT_BITS", |
| 139 | SPUvecshift_type>; |
| 140 | |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 141 | // SPU form select mask for bytes, immediate |
Scott Michel | 8bf61e8 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 142 | def SPUselmask: SDNode<"SPUISD::SELECT_MASK", SPUselmask_type, []>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 143 | |
| 144 | // SPU select bits instruction |
Scott Michel | a59d469 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 145 | def SPUselb: SDNode<"SPUISD::SELB", SPUselb_type, []>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 146 | |
Scott Michel | f0569be | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 147 | // SPU gather bits instruction: |
| 148 | def SPUgatherbits: SDNode<"SPUISD::GATHER_BITS", SPUgatherbits_type, []>; |
| 149 | |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 150 | // SPU floating point interpolate |
| 151 | def SPUinterpolate : SDNode<"SPUISD::FPInterp", SDTFPBinOp, []>; |
| 152 | |
| 153 | // SPU floating point reciprocal estimate (used for fdiv) |
| 154 | def SPUreciprocalEst: SDNode<"SPUISD::FPRecipEst", SDTFPUnaryOp, []>; |
| 155 | |
Scott Michel | f0569be | 2008-12-27 04:51:36 +0000 | [diff] [blame^] | 156 | def SDTprefslot2vec: SDTypeProfile<1, 1, []>; |
| 157 | def SPUprefslot2vec: SDNode<"SPUISD::PREFSLOT2VEC", SDTprefslot2vec, []>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 158 | |
| 159 | def SPU_vec_demote : SDTypeProfile<1, 1, []>; |
Scott Michel | 104de43 | 2008-11-24 17:11:17 +0000 | [diff] [blame] | 160 | def SPUvec2prefslot: SDNode<"SPUISD::VEC2PREFSLOT", SPU_vec_demote, []>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 161 | |
| 162 | // Address high and low components, used for [r+r] type addressing |
| 163 | def SPUhi : SDNode<"SPUISD::Hi", SDTIntBinOp, []>; |
| 164 | def SPUlo : SDNode<"SPUISD::Lo", SDTIntBinOp, []>; |
| 165 | |
| 166 | // PC-relative address |
| 167 | def SPUpcrel : SDNode<"SPUISD::PCRelAddr", SDTIntBinOp, []>; |
| 168 | |
Scott Michel | 9de5d0d | 2008-01-11 02:53:15 +0000 | [diff] [blame] | 169 | // A-Form local store addresses |
| 170 | def SPUaform : SDNode<"SPUISD::AFormAddr", SDTIntBinOp, []>; |
| 171 | |
Scott Michel | 053c1da | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 172 | // Indirect [D-Form "imm($reg)" and X-Form "$reg($reg)"] addresses |
| 173 | def SPUindirect : SDNode<"SPUISD::IndirectAddr", SDTIntBinOp, []>; |
Scott Michel | 9de5d0d | 2008-01-11 02:53:15 +0000 | [diff] [blame] | 174 | |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 175 | // SPU 32-bit sign-extension to 64-bits |
| 176 | def SPUsext32_to_64: SDNode<"SPUISD::SEXT32TO64", SDTIntExtendOp, []>; |
| 177 | |
| 178 | // Branches: |
| 179 | |
| 180 | def SPUbrnz : SDNode<"SPUISD::BR_NOTZERO", SDTBrcond, [SDNPHasChain]>; |
| 181 | def SPUbrz : SDNode<"SPUISD::BR_ZERO", SDTBrcond, [SDNPHasChain]>; |
| 182 | /* def SPUbinz : SDNode<"SPUISD::BR_NOTZERO", SDTBrind, [SDNPHasChain]>; |
| 183 | def SPUbiz : SDNode<"SPUISD::BR_ZERO", SPUBrind, [SDNPHasChain]>; */ |
| 184 | |
| 185 | //===----------------------------------------------------------------------===// |
| 186 | // Constraints: (taken from PPCInstrInfo.td) |
| 187 | //===----------------------------------------------------------------------===// |
| 188 | |
| 189 | class RegConstraint<string C> { |
| 190 | string Constraints = C; |
| 191 | } |
| 192 | |
| 193 | class NoEncode<string E> { |
| 194 | string DisableEncoding = E; |
| 195 | } |
| 196 | |
| 197 | //===----------------------------------------------------------------------===// |
| 198 | // Return (flag isn't quite what it means: the operations are flagged so that |
| 199 | // instruction scheduling doesn't disassociate them.) |
| 200 | //===----------------------------------------------------------------------===// |
| 201 | |
Chris Lattner | 48be23c | 2008-01-15 22:02:54 +0000 | [diff] [blame] | 202 | def retflag : SDNode<"SPUISD::RET_FLAG", SDTNone, |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 203 | [SDNPHasChain, SDNPOptInFlag]>; |