Christian Konig | 72d5d5c | 2013-02-21 15:16:44 +0000 | [diff] [blame] | 1 | //===-- SIInstrInfo.td - SI Instruction Infos -------------*- tablegen -*--===// |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 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 | //===----------------------------------------------------------------------===// |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 11 | // SI DAG Nodes |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Tom Stellard | 8909380 | 2013-02-07 19:39:40 +0000 | [diff] [blame] | 14 | // SMRD takes a 64bit memory address and can only add an 32bit offset |
| 15 | def SIadd64bit32bit : SDNode<"ISD::ADD", |
| 16 | SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>, SDTCisVT<0, i64>, SDTCisVT<2, i32>]> |
| 17 | >; |
| 18 | |
Tom Stellard | 26075d5 | 2013-02-07 19:39:38 +0000 | [diff] [blame] | 19 | // Transformation function, extract the lower 32bit of a 64bit immediate |
| 20 | def LO32 : SDNodeXForm<imm, [{ |
| 21 | return CurDAG->getTargetConstant(N->getZExtValue() & 0xffffffff, MVT::i32); |
| 22 | }]>; |
| 23 | |
| 24 | // Transformation function, extract the upper 32bit of a 64bit immediate |
| 25 | def HI32 : SDNodeXForm<imm, [{ |
| 26 | return CurDAG->getTargetConstant(N->getZExtValue() >> 32, MVT::i32); |
| 27 | }]>; |
| 28 | |
Tom Stellard | 8909380 | 2013-02-07 19:39:40 +0000 | [diff] [blame] | 29 | def IMM8bitDWORD : ImmLeaf < |
| 30 | i32, [{ |
| 31 | return (Imm & ~0x3FC) == 0; |
| 32 | }], SDNodeXForm<imm, [{ |
| 33 | return CurDAG->getTargetConstant( |
| 34 | N->getZExtValue() >> 2, MVT::i32); |
| 35 | }]> |
| 36 | >; |
| 37 | |
| 38 | def IMM12bit : ImmLeaf < |
| 39 | i16, |
| 40 | [{return isUInt<12>(Imm);}] |
| 41 | >; |
| 42 | |
Christian Konig | b559b07 | 2013-02-16 11:28:36 +0000 | [diff] [blame] | 43 | class InlineImm <ValueType vt> : ImmLeaf <vt, [{ |
| 44 | return -16 <= Imm && Imm <= 64; |
| 45 | }]>; |
| 46 | |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 47 | |
Christian Konig | 72d5d5c | 2013-02-21 15:16:44 +0000 | [diff] [blame] | 48 | //===----------------------------------------------------------------------===// |
| 49 | // SI assembler operands |
| 50 | //===----------------------------------------------------------------------===// |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 51 | |
Christian Konig | eabf833 | 2013-02-21 15:16:49 +0000 | [diff] [blame] | 52 | def SIOperand { |
| 53 | int ZERO = 0x80; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 54 | } |
| 55 | |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 56 | class GPR4Align <RegisterClass rc> : Operand <vAny> { |
| 57 | let EncoderMethod = "GPR4AlignEncode"; |
| 58 | let MIOperandInfo = (ops rc:$reg); |
| 59 | } |
| 60 | |
Tom Stellard | 8909380 | 2013-02-07 19:39:40 +0000 | [diff] [blame] | 61 | class GPR2Align <RegisterClass rc> : Operand <iPTR> { |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 62 | let EncoderMethod = "GPR2AlignEncode"; |
| 63 | let MIOperandInfo = (ops rc:$reg); |
| 64 | } |
| 65 | |
Christian Konig | 72d5d5c | 2013-02-21 15:16:44 +0000 | [diff] [blame] | 66 | include "SIInstrFormats.td" |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 67 | |
Christian Konig | 72d5d5c | 2013-02-21 15:16:44 +0000 | [diff] [blame] | 68 | //===----------------------------------------------------------------------===// |
| 69 | // |
| 70 | // SI Instruction multiclass helpers. |
| 71 | // |
| 72 | // Instructions with _32 take 32-bit operands. |
| 73 | // Instructions with _64 take 64-bit operands. |
| 74 | // |
| 75 | // VOP_* instructions can use either a 32-bit or 64-bit encoding. The 32-bit |
| 76 | // encoding is the standard encoding, but instruction that make use of |
| 77 | // any of the instruction modifiers must use the 64-bit encoding. |
| 78 | // |
| 79 | // Instructions with _e32 use the 32-bit encoding. |
| 80 | // Instructions with _e64 use the 64-bit encoding. |
| 81 | // |
| 82 | //===----------------------------------------------------------------------===// |
| 83 | |
| 84 | //===----------------------------------------------------------------------===// |
| 85 | // Scalar classes |
| 86 | //===----------------------------------------------------------------------===// |
| 87 | |
| 88 | class SOP1_32 <bits<8> op, string opName, list<dag> pattern> |
| 89 | : SOP1 <op, (outs SReg_32:$dst), (ins SSrc_32:$src0), opName, pattern>; |
| 90 | |
| 91 | class SOP1_64 <bits<8> op, string opName, list<dag> pattern> |
| 92 | : SOP1 <op, (outs SReg_64:$dst), (ins SSrc_64:$src0), opName, pattern>; |
| 93 | |
| 94 | class SOP2_32 <bits<7> op, string opName, list<dag> pattern> |
| 95 | : SOP2 <op, (outs SReg_32:$dst), (ins SSrc_32:$src0, SSrc_32:$src1), opName, pattern>; |
| 96 | |
| 97 | class SOP2_64 <bits<7> op, string opName, list<dag> pattern> |
| 98 | : SOP2 <op, (outs SReg_64:$dst), (ins SSrc_64:$src0, SSrc_64:$src1), opName, pattern>; |
| 99 | |
| 100 | class SOPC_32 <bits<7> op, string opName, list<dag> pattern> |
| 101 | : SOPC <op, (outs SCCReg:$dst), (ins SSrc_32:$src0, SSrc_32:$src1), opName, pattern>; |
| 102 | |
| 103 | class SOPC_64 <bits<7> op, string opName, list<dag> pattern> |
| 104 | : SOPC <op, (outs SCCReg:$dst), (ins SSrc_64:$src0, SSrc_64:$src1), opName, pattern>; |
| 105 | |
| 106 | class SOPK_32 <bits<5> op, string opName, list<dag> pattern> |
| 107 | : SOPK <op, (outs SReg_32:$dst), (ins i16imm:$src0), opName, pattern>; |
| 108 | |
| 109 | class SOPK_64 <bits<5> op, string opName, list<dag> pattern> |
| 110 | : SOPK <op, (outs SReg_64:$dst), (ins i16imm:$src0), opName, pattern>; |
| 111 | |
| 112 | multiclass SMRD_Helper <bits<5> op, string asm, RegisterClass dstClass> { |
| 113 | def _IMM : SMRD < |
| 114 | op, 1, (outs dstClass:$dst), |
| 115 | (ins GPR2Align<SReg_64>:$sbase, i32imm:$offset), |
| 116 | asm, [] |
| 117 | >; |
| 118 | |
| 119 | def _SGPR : SMRD < |
| 120 | op, 0, (outs dstClass:$dst), |
| 121 | (ins GPR2Align<SReg_64>:$sbase, SReg_32:$soff), |
| 122 | asm, [] |
| 123 | >; |
| 124 | } |
| 125 | |
| 126 | //===----------------------------------------------------------------------===// |
| 127 | // Vector ALU classes |
| 128 | //===----------------------------------------------------------------------===// |
| 129 | |
| 130 | class VOP3_32 <bits<9> op, string opName, list<dag> pattern> : VOP3 < |
| 131 | op, (outs VReg_32:$dst), |
| 132 | (ins VSrc_32:$src0, VReg_32:$src1, VReg_32:$src2, i32imm:$src3, |
| 133 | i32imm:$src4, i32imm:$src5, i32imm:$src6), |
| 134 | opName, pattern |
| 135 | >; |
| 136 | |
| 137 | class VOP3_64 <bits<9> op, string opName, list<dag> pattern> : VOP3 < |
| 138 | op, (outs VReg_64:$dst), |
| 139 | (ins VSrc_64:$src0, VReg_64:$src1, VReg_64:$src2, |
| 140 | i32imm:$src3, i32imm:$src4, i32imm:$src5, i32imm:$src6), |
| 141 | opName, pattern |
| 142 | >; |
| 143 | |
Christian Konig | 3da7017 | 2013-02-21 15:16:53 +0000 | [diff] [blame^] | 144 | multiclass VOP1_Helper <bits<8> op, RegisterClass drc, RegisterClass src, |
| 145 | string opName, list<dag> pattern> { |
| 146 | |
| 147 | def _e32: VOP1 < |
| 148 | op, (outs drc:$dst), (ins src:$src0), |
| 149 | opName#"_e32 $dst, $src0", pattern |
Christian Konig | 72d5d5c | 2013-02-21 15:16:44 +0000 | [diff] [blame] | 150 | >; |
| 151 | |
Christian Konig | 3da7017 | 2013-02-21 15:16:53 +0000 | [diff] [blame^] | 152 | def _e64 : VOP3 < |
Christian Konig | 72d5d5c | 2013-02-21 15:16:44 +0000 | [diff] [blame] | 153 | {1, 1, op{6}, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}}, |
Christian Konig | 3da7017 | 2013-02-21 15:16:53 +0000 | [diff] [blame^] | 154 | (outs drc:$dst), |
| 155 | (ins src:$src0, |
| 156 | i32imm:$abs, i32imm:$clamp, |
| 157 | i32imm:$omod, i32imm:$neg), |
| 158 | opName#"_e64 $dst, $src0, $abs, $clamp, $omod, $neg", [] |
| 159 | > { |
| 160 | let SRC1 = SIOperand.ZERO; |
| 161 | let SRC2 = SIOperand.ZERO; |
| 162 | } |
Christian Konig | 72d5d5c | 2013-02-21 15:16:44 +0000 | [diff] [blame] | 163 | } |
| 164 | |
Christian Konig | 3da7017 | 2013-02-21 15:16:53 +0000 | [diff] [blame^] | 165 | multiclass VOP1_32 <bits<8> op, string opName, list<dag> pattern> |
| 166 | : VOP1_Helper <op, VReg_32, VSrc_32, opName, pattern>; |
| 167 | |
| 168 | multiclass VOP1_64 <bits<8> op, string opName, list<dag> pattern> |
| 169 | : VOP1_Helper <op, VReg_64, VSrc_64, opName, pattern>; |
| 170 | |
Christian Konig | 72d5d5c | 2013-02-21 15:16:44 +0000 | [diff] [blame] | 171 | class VOP2_Helper <bits<6> op, RegisterClass vrc, RegisterClass arc, |
| 172 | string opName, list<dag> pattern> : |
| 173 | VOP2 < |
| 174 | op, (outs vrc:$dst), (ins arc:$src0, vrc:$src1), opName, pattern |
| 175 | >; |
| 176 | |
| 177 | multiclass VOP2_32 <bits<6> op, string opName, list<dag> pattern> { |
| 178 | |
| 179 | def _e32 : VOP2_Helper <op, VReg_32, VSrc_32, opName, pattern>; |
| 180 | |
| 181 | def _e64 : VOP3_32 <{1, 0, 0, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}}, |
| 182 | opName, [] |
| 183 | >; |
| 184 | } |
| 185 | |
| 186 | multiclass VOP2_64 <bits<6> op, string opName, list<dag> pattern> { |
| 187 | def _e32: VOP2_Helper <op, VReg_64, VSrc_64, opName, pattern>; |
| 188 | |
| 189 | def _e64 : VOP3_64 < |
| 190 | {1, 0, 0, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}}, |
| 191 | opName, [] |
| 192 | >; |
| 193 | } |
| 194 | |
| 195 | multiclass VOPC_Helper <bits<8> op, RegisterClass vrc, RegisterClass arc, |
| 196 | string opName, list<dag> pattern> { |
| 197 | |
| 198 | def _e32 : VOPC <op, (ins arc:$src0, vrc:$src1), opName, pattern>; |
| 199 | def _e64 : VOP3 < |
| 200 | {0, op{7}, op{6}, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}}, |
| 201 | (outs SReg_64:$dst), |
| 202 | (ins arc:$src0, vrc:$src1, |
| 203 | InstFlag:$abs, InstFlag:$clamp, |
| 204 | InstFlag:$omod, InstFlag:$neg), |
| 205 | opName, pattern |
| 206 | > { |
Christian Konig | eabf833 | 2013-02-21 15:16:49 +0000 | [diff] [blame] | 207 | let SRC2 = SIOperand.ZERO; |
Christian Konig | 72d5d5c | 2013-02-21 15:16:44 +0000 | [diff] [blame] | 208 | } |
| 209 | } |
| 210 | |
| 211 | multiclass VOPC_32 <bits<8> op, string opName, list<dag> pattern> |
| 212 | : VOPC_Helper <op, VReg_32, VSrc_32, opName, pattern>; |
| 213 | |
| 214 | multiclass VOPC_64 <bits<8> op, string opName, list<dag> pattern> |
| 215 | : VOPC_Helper <op, VReg_64, VSrc_64, opName, pattern>; |
| 216 | |
| 217 | //===----------------------------------------------------------------------===// |
| 218 | // Vector I/O classes |
| 219 | //===----------------------------------------------------------------------===// |
| 220 | |
| 221 | class MTBUF_Store_Helper <bits<3> op, string asm, RegisterClass regClass> : MTBUF < |
| 222 | op, |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 223 | (outs), |
Christian Konig | 72d5d5c | 2013-02-21 15:16:44 +0000 | [diff] [blame] | 224 | (ins regClass:$vdata, i16imm:$offset, i1imm:$offen, i1imm:$idxen, i1imm:$glc, |
| 225 | i1imm:$addr64, i8imm:$dfmt, i8imm:$nfmt, VReg_32:$vaddr, |
| 226 | GPR4Align<SReg_128>:$srsrc, i1imm:$slc, i1imm:$tfe, SSrc_32:$soffset), |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 227 | asm, |
Christian Konig | 72d5d5c | 2013-02-21 15:16:44 +0000 | [diff] [blame] | 228 | []> { |
| 229 | let mayStore = 1; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 230 | let mayLoad = 0; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 231 | } |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 232 | |
Christian Konig | 72d5d5c | 2013-02-21 15:16:44 +0000 | [diff] [blame] | 233 | class MUBUF_Load_Helper <bits<7> op, string asm, RegisterClass regClass> : MUBUF < |
| 234 | op, |
| 235 | (outs regClass:$dst), |
| 236 | (ins i16imm:$offset, i1imm:$offen, i1imm:$idxen, i1imm:$glc, i1imm:$addr64, |
| 237 | i1imm:$lds, VReg_32:$vaddr, GPR4Align<SReg_128>:$srsrc, i1imm:$slc, |
| 238 | i1imm:$tfe, SSrc_32:$soffset), |
| 239 | asm, |
| 240 | []> { |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 241 | let mayLoad = 1; |
| 242 | let mayStore = 0; |
| 243 | } |
| 244 | |
Christian Konig | 72d5d5c | 2013-02-21 15:16:44 +0000 | [diff] [blame] | 245 | class MTBUF_Load_Helper <bits<3> op, string asm, RegisterClass regClass> : MTBUF < |
| 246 | op, |
| 247 | (outs regClass:$dst), |
| 248 | (ins i16imm:$offset, i1imm:$offen, i1imm:$idxen, i1imm:$glc, i1imm:$addr64, |
| 249 | i8imm:$dfmt, i8imm:$nfmt, VReg_32:$vaddr, GPR4Align<SReg_128>:$srsrc, |
| 250 | i1imm:$slc, i1imm:$tfe, SSrc_32:$soffset), |
| 251 | asm, |
| 252 | []> { |
| 253 | let mayLoad = 1; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 254 | let mayStore = 0; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 255 | } |
| 256 | |
Christian Konig | 72d5d5c | 2013-02-21 15:16:44 +0000 | [diff] [blame] | 257 | class MIMG_Load_Helper <bits<7> op, string asm> : MIMG < |
| 258 | op, |
| 259 | (outs VReg_128:$vdata), |
| 260 | (ins i32imm:$dmask, i1imm:$unorm, i1imm:$glc, i1imm:$da, i1imm:$r128, |
| 261 | i1imm:$tfe, i1imm:$lwe, i1imm:$slc, VReg_32:$vaddr, |
| 262 | GPR4Align<SReg_256>:$srsrc, GPR4Align<SReg_128>:$ssamp), |
| 263 | asm, |
| 264 | []> { |
| 265 | let mayLoad = 1; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 266 | let mayStore = 0; |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 267 | } |
| 268 | |
Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 269 | include "SIInstructions.td" |