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 | |
Chris Lattner | dd6fbd1 | 2010-03-08 18:59:49 +0000 | [diff] [blame] | 29 | def SDT_SPUCall : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 30 | def SPUcall : SDNode<"SPUISD::CALL", SDT_SPUCall, |
Chris Lattner | 60e9eac | 2010-03-19 05:33:51 +0000 | [diff] [blame] | 31 | [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag, |
| 32 | SDNPVariadic]>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 33 | |
| 34 | // Operand type constraints for vector shuffle/permute operations |
| 35 | def SDT_SPUshuffle : SDTypeProfile<1, 3, [ |
Scott Michel | a59d469 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 36 | SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2> |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 37 | ]>; |
| 38 | |
Scott Michel | 1df30c4 | 2008-12-29 03:23:36 +0000 | [diff] [blame] | 39 | // Vector binary operator type constraints (needs a further constraint to |
| 40 | // ensure that operand 0 is a vector...): |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 41 | |
Scott Michel | 1df30c4 | 2008-12-29 03:23:36 +0000 | [diff] [blame] | 42 | def SPUVecBinop: SDTypeProfile<1, 2, [ |
| 43 | SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2> |
| 44 | ]>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 45 | |
Scott Michel | 8bf61e8 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 46 | // Trinary operators, e.g., addx, carry generate |
| 47 | def 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 Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 52 | // vector types (this avoids having to bit_convert all over the place.) |
Scott Michel | 8bf61e8 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 53 | def SPUselmask_type: SDTypeProfile<1, 1, [ |
Scott Michel | 203b2d6 | 2008-04-30 00:30:08 +0000 | [diff] [blame] | 54 | SDTCisInt<1> |
| 55 | ]>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 56 | |
| 57 | // SELB type constraints: |
Scott Michel | a59d469 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 58 | def SPUselb_type: SDTypeProfile<1, 3, [ |
| 59 | SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisSameAs<0, 3> ]>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 60 | |
| 61 | // SPU Vector shift pseudo-instruction type constraints |
Scott Michel | a59d469 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 62 | def SPUvecshift_type: SDTypeProfile<1, 2, [ |
| 63 | SDTCisSameAs<0, 1>, SDTCisInt<2>]>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 64 | |
Scott Michel | 94bd57e | 2009-01-15 04:41:47 +0000 | [diff] [blame] | 65 | // "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 | |
| 72 | def SPUmarker_type : SDTypeProfile<1, 3, [ |
| 73 | SDTCisInt<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2> ]>; |
| 74 | |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 75 | //===----------------------------------------------------------------------===// |
| 76 | // Synthetic/pseudo-instructions |
| 77 | //===----------------------------------------------------------------------===// |
| 78 | |
| 79 | // SPU CNTB: |
Scott Michel | 8bf61e8 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 80 | def SPUcntb : SDNode<"SPUISD::CNTB", SDTIntUnaryOp>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 81 | |
| 82 | // SPU vector shuffle node, matched by the SPUISD::SHUFB enum (see |
| 83 | // SPUISelLowering.h): |
| 84 | def SPUshuffle: SDNode<"SPUISD::SHUFB", SDT_SPUshuffle, []>; |
| 85 | |
Scott Michel | a59d469 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 86 | // Shift left quadword by bits and bytes |
| 87 | def SPUshlquad_l_bits: SDNode<"SPUISD::SHLQUAD_L_BITS", SPUvecshift_type, []>; |
| 88 | def SPUshlquad_l_bytes: SDNode<"SPUISD::SHLQUAD_L_BYTES", SPUvecshift_type, []>; |
| 89 | |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 90 | // Vector shifts (ISD::SHL,SRL,SRA are for _integers_ only): |
Scott Michel | f1fa4fd | 2009-08-24 22:28:53 +0000 | [diff] [blame] | 91 | def SPUvec_shl: SDNode<"ISD::SHL", SPUvecshift_type, []>; |
| 92 | def SPUvec_srl: SDNode<"ISD::SRL", SPUvecshift_type, []>; |
| 93 | def SPUvec_sra: SDNode<"ISD::SRA", SPUvecshift_type, []>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 94 | |
Scott Michel | a59d469 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 95 | def SPUvec_rotl: SDNode<"SPUISD::VEC_ROTL", SPUvecshift_type, []>; |
| 96 | def SPUvec_rotr: SDNode<"SPUISD::VEC_ROTR", SPUvecshift_type, []>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 97 | |
Scott Michel | 8bf61e8 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 98 | // 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] | 99 | def SPUrotbytes_left: SDNode<"SPUISD::ROTBYTES_LEFT", |
Scott Michel | a59d469 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 100 | SPUvecshift_type, []>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 101 | |
Scott Michel | 8bf61e8 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 102 | // Vector rotate left by bytes, but the count is given in bits and the SPU |
| 103 | // internally converts it to bytes (saves an instruction to mask off lower |
| 104 | // three bits) |
| 105 | def SPUrotbytes_left_bits : SDNode<"SPUISD::ROTBYTES_LEFT_BITS", |
| 106 | SPUvecshift_type>; |
| 107 | |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 108 | // SPU form select mask for bytes, immediate |
Scott Michel | 8bf61e8 | 2008-06-02 22:18:03 +0000 | [diff] [blame] | 109 | def SPUselmask: SDNode<"SPUISD::SELECT_MASK", SPUselmask_type, []>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 110 | |
| 111 | // SPU select bits instruction |
Scott Michel | a59d469 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 112 | def SPUselb: SDNode<"SPUISD::SELB", SPUselb_type, []>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 113 | |
Scott Michel | f0569be | 2008-12-27 04:51:36 +0000 | [diff] [blame] | 114 | def SDTprefslot2vec: SDTypeProfile<1, 1, []>; |
| 115 | def SPUprefslot2vec: SDNode<"SPUISD::PREFSLOT2VEC", SDTprefslot2vec, []>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 116 | |
| 117 | def SPU_vec_demote : SDTypeProfile<1, 1, []>; |
Scott Michel | 104de43 | 2008-11-24 17:11:17 +0000 | [diff] [blame] | 118 | def SPUvec2prefslot: SDNode<"SPUISD::VEC2PREFSLOT", SPU_vec_demote, []>; |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 119 | |
| 120 | // Address high and low components, used for [r+r] type addressing |
| 121 | def SPUhi : SDNode<"SPUISD::Hi", SDTIntBinOp, []>; |
| 122 | def SPUlo : SDNode<"SPUISD::Lo", SDTIntBinOp, []>; |
| 123 | |
| 124 | // PC-relative address |
| 125 | def SPUpcrel : SDNode<"SPUISD::PCRelAddr", SDTIntBinOp, []>; |
| 126 | |
Scott Michel | 9de5d0d | 2008-01-11 02:53:15 +0000 | [diff] [blame] | 127 | // A-Form local store addresses |
| 128 | def SPUaform : SDNode<"SPUISD::AFormAddr", SDTIntBinOp, []>; |
| 129 | |
Scott Michel | 053c1da | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 130 | // Indirect [D-Form "imm($reg)" and X-Form "$reg($reg)"] addresses |
| 131 | def SPUindirect : SDNode<"SPUISD::IndirectAddr", SDTIntBinOp, []>; |
Scott Michel | 9de5d0d | 2008-01-11 02:53:15 +0000 | [diff] [blame] | 132 | |
Scott Michel | 94bd57e | 2009-01-15 04:41:47 +0000 | [diff] [blame] | 133 | // i64 markers: supplies extra operands used to generate the i64 operator |
| 134 | // instruction sequences |
| 135 | def SPUadd64 : SDNode<"SPUISD::ADD64_MARKER", SPUmarker_type, []>; |
| 136 | def SPUsub64 : SDNode<"SPUISD::SUB64_MARKER", SPUmarker_type, []>; |
| 137 | def SPUmul64 : SDNode<"SPUISD::MUL64_MARKER", SPUmarker_type, []>; |
| 138 | |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 139 | //===----------------------------------------------------------------------===// |
| 140 | // Constraints: (taken from PPCInstrInfo.td) |
| 141 | //===----------------------------------------------------------------------===// |
| 142 | |
| 143 | class RegConstraint<string C> { |
| 144 | string Constraints = C; |
| 145 | } |
| 146 | |
| 147 | class NoEncode<string E> { |
| 148 | string DisableEncoding = E; |
| 149 | } |
| 150 | |
| 151 | //===----------------------------------------------------------------------===// |
| 152 | // Return (flag isn't quite what it means: the operations are flagged so that |
| 153 | // instruction scheduling doesn't disassociate them.) |
| 154 | //===----------------------------------------------------------------------===// |
| 155 | |
Chris Lattner | 48be23c | 2008-01-15 22:02:54 +0000 | [diff] [blame] | 156 | def retflag : SDNode<"SPUISD::RET_FLAG", SDTNone, |
Scott Michel | 564427e | 2007-12-05 01:24:05 +0000 | [diff] [blame] | 157 | [SDNPHasChain, SDNPOptInFlag]>; |