Scott Michel | 8efdca4 | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 1 | //==== SPUInstrFormats.td - Cell SPU Instruction Formats ---*- tablegen -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Scott Michel | 43e7c5e | 2007-12-05 01:40:25 +0000 | [diff] [blame] | 5 | // This file was developed by a team from the Computer Systems Research |
| 6 | // Department at The Aerospace Corporation and is distributed under the |
| 7 | // University of Illinois Open Source License. See LICENSE.TXT for details. |
Scott Michel | 8efdca4 | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | // |
| 13 | // Cell SPU instruction formats. Note that these are notationally similar to |
| 14 | // PowerPC, like "A-Form". But the sizes of operands and fields differ. |
| 15 | |
| 16 | // This was kiped from the PPC instruction formats (seemed like a good idea...) |
| 17 | |
| 18 | class I<dag OOL, dag IOL, string asmstr, InstrItinClass itin> |
| 19 | : Instruction { |
| 20 | field bits<32> Inst; |
| 21 | |
| 22 | let Name = ""; |
| 23 | let Namespace = "SPU"; |
| 24 | let OutOperandList = OOL; |
| 25 | let InOperandList = IOL; |
| 26 | let AsmString = asmstr; |
| 27 | let Itinerary = itin; |
| 28 | } |
| 29 | |
| 30 | // RR Format |
| 31 | class RRForm<bits<11> opcode, dag OOL, dag IOL, string asmstr, |
| 32 | InstrItinClass itin, list<dag> pattern> |
| 33 | : I<OOL, IOL, asmstr, itin> { |
| 34 | bits<7> RA; |
| 35 | bits<7> RB; |
| 36 | bits<7> RT; |
| 37 | |
| 38 | let Pattern = pattern; |
| 39 | |
| 40 | let Inst{0-10} = opcode; |
| 41 | let Inst{11-17} = RB; |
| 42 | let Inst{18-24} = RA; |
| 43 | let Inst{25-31} = RT; |
| 44 | } |
| 45 | |
| 46 | let RB = 0 in { |
| 47 | // RR Format, where RB is zeroed (dont care): |
| 48 | class RRForm_1<bits<11> opcode, dag OOL, dag IOL, string asmstr, |
| 49 | InstrItinClass itin, list<dag> pattern> |
| 50 | : RRForm<opcode, OOL, IOL, asmstr, itin, pattern> |
| 51 | { } |
| 52 | |
| 53 | let RA = 0 in { |
| 54 | // RR Format, where RA and RB are zeroed (dont care): |
| 55 | // Used for reads from status control registers (see FPSCRRr32) |
| 56 | class RRForm_2<bits<11> opcode, dag OOL, dag IOL, string asmstr, |
| 57 | InstrItinClass itin, list<dag> pattern> |
| 58 | : RRForm<opcode, OOL, IOL, asmstr, itin, pattern> |
| 59 | { } |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | let RT = 0 in { |
| 64 | // RR Format, where RT is zeroed (don't care), or as the instruction handbook |
| 65 | // says, "RT is a false target." Used in "Halt if" instructions |
| 66 | class RRForm_3<bits<11> opcode, dag OOL, dag IOL, string asmstr, |
| 67 | InstrItinClass itin, list<dag> pattern> |
| 68 | : RRForm<opcode, OOL, IOL, asmstr, itin, pattern> |
| 69 | { } |
| 70 | } |
| 71 | |
| 72 | // RRR Format |
| 73 | class RRRForm<bits<4> opcode, dag OOL, dag IOL, string asmstr, |
| 74 | InstrItinClass itin, list<dag> pattern> |
| 75 | : I<OOL, IOL, asmstr, itin> |
| 76 | { |
| 77 | bits<7> RA; |
| 78 | bits<7> RB; |
| 79 | bits<7> RC; |
| 80 | bits<7> RT; |
| 81 | |
| 82 | let Pattern = pattern; |
| 83 | |
| 84 | let Inst{0-3} = opcode; |
| 85 | let Inst{4-10} = RT; |
| 86 | let Inst{11-17} = RB; |
| 87 | let Inst{18-24} = RA; |
| 88 | let Inst{25-31} = RC; |
| 89 | } |
| 90 | |
| 91 | // RI7 Format |
| 92 | class RI7Form<bits<11> opcode, dag OOL, dag IOL, string asmstr, |
| 93 | InstrItinClass itin, list<dag> pattern> |
| 94 | : I<OOL, IOL, asmstr, itin> |
| 95 | { |
| 96 | bits<7> i7; |
| 97 | bits<7> RA; |
| 98 | bits<7> RT; |
| 99 | |
| 100 | let Pattern = pattern; |
| 101 | |
| 102 | let Inst{0-10} = opcode; |
| 103 | let Inst{11-17} = i7; |
| 104 | let Inst{18-24} = RA; |
| 105 | let Inst{25-31} = RT; |
| 106 | } |
| 107 | |
| 108 | // CVTIntFp Format |
| 109 | class CVTIntFPForm<bits<10> opcode, dag OOL, dag IOL, string asmstr, |
| 110 | InstrItinClass itin, list<dag> pattern> |
| 111 | : I<OOL, IOL, asmstr, itin> |
| 112 | { |
| 113 | bits<7> RA; |
| 114 | bits<7> RT; |
| 115 | |
| 116 | let Pattern = pattern; |
| 117 | |
| 118 | let Inst{0-9} = opcode; |
| 119 | let Inst{10-17} = 0; |
| 120 | let Inst{18-24} = RA; |
| 121 | let Inst{25-31} = RT; |
| 122 | } |
| 123 | |
| 124 | let RA = 0 in { |
| 125 | class BICondForm<bits<11> opcode, string asmstr, list<dag> pattern> |
| 126 | : RRForm<opcode, (outs), (ins R32C:$rA, R32C:$func), asmstr, |
| 127 | BranchResolv, pattern> |
| 128 | { } |
| 129 | |
| 130 | let RT = 0 in { |
| 131 | // Branch instruction format (without D/E flag settings) |
| 132 | class BRForm<bits<11> opcode, dag OOL, dag IOL, string asmstr, |
| 133 | InstrItinClass itin, list<dag> pattern> |
| 134 | : RRForm<opcode, OOL, IOL, asmstr, itin, pattern> |
| 135 | { } |
| 136 | |
| 137 | class BIForm<bits<11> opcode, string asmstr, list<dag> pattern> |
| 138 | : RRForm<opcode, (outs), (ins R32C:$func), asmstr, BranchResolv, |
| 139 | pattern> |
| 140 | { } |
| 141 | |
| 142 | let RB = 0 in { |
| 143 | // Return instruction (bi, branch indirect), RA is zero (LR): |
| 144 | class RETForm<string asmstr, list<dag> pattern> |
| 145 | : BRForm<0b00010101100, (outs), (ins), asmstr, BranchResolv, |
| 146 | pattern> |
| 147 | { } |
| 148 | } |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | // Branch indirect external data forms: |
| 153 | class BISLEDForm<bits<2> DE_flag, string asmstr, list<dag> pattern> |
| 154 | : I<(outs), (ins indcalltarget:$func), asmstr, BranchResolv> |
| 155 | { |
| 156 | bits<7> Rcalldest; |
| 157 | |
| 158 | let Pattern = pattern; |
| 159 | |
| 160 | let Inst{0-10} = 0b11010101100; |
| 161 | let Inst{11} = 0; |
| 162 | let Inst{12-13} = DE_flag; |
| 163 | let Inst{14-17} = 0b0000; |
| 164 | let Inst{18-24} = Rcalldest; |
| 165 | let Inst{25-31} = 0b0000000; |
| 166 | } |
| 167 | |
| 168 | // RI10 Format |
| 169 | class RI10Form<bits<8> opcode, dag OOL, dag IOL, string asmstr, |
| 170 | InstrItinClass itin, list<dag> pattern> |
| 171 | : I<OOL, IOL, asmstr, itin> |
| 172 | { |
| 173 | bits<10> i10; |
| 174 | bits<7> RA; |
| 175 | bits<7> RT; |
| 176 | |
| 177 | let Pattern = pattern; |
| 178 | |
| 179 | let Inst{0-7} = opcode; |
| 180 | let Inst{8-17} = i10; |
| 181 | let Inst{18-24} = RA; |
| 182 | let Inst{25-31} = RT; |
| 183 | } |
| 184 | |
| 185 | // RI10 Format, where the constant is zero (or effectively ignored by the |
| 186 | // SPU) |
| 187 | class RI10Form_1<bits<8> opcode, dag OOL, dag IOL, string asmstr, |
| 188 | InstrItinClass itin, list<dag> pattern> |
| 189 | : I<OOL, IOL, asmstr, itin> |
| 190 | { |
| 191 | bits<7> RA; |
| 192 | bits<7> RT; |
| 193 | |
| 194 | let Pattern = pattern; |
| 195 | |
| 196 | let Inst{0-7} = opcode; |
| 197 | let Inst{8-17} = 0; |
| 198 | let Inst{18-24} = RA; |
| 199 | let Inst{25-31} = RT; |
| 200 | } |
| 201 | |
| 202 | // RI10 Format, where RT is ignored. |
| 203 | // This format is used primarily by the Halt If ... Immediate set of |
| 204 | // instructions |
| 205 | class RI10Form_2<bits<8> opcode, dag OOL, dag IOL, string asmstr, |
| 206 | InstrItinClass itin, list<dag> pattern> |
| 207 | : I<OOL, IOL, asmstr, itin> |
| 208 | { |
| 209 | bits<10> i10; |
| 210 | bits<7> RA; |
| 211 | |
| 212 | let Pattern = pattern; |
| 213 | |
| 214 | let Inst{0-7} = opcode; |
| 215 | let Inst{8-17} = i10; |
| 216 | let Inst{18-24} = RA; |
| 217 | let Inst{25-31} = 0; |
| 218 | } |
| 219 | |
| 220 | // RI16 Format |
| 221 | class RI16Form<bits<9> opcode, dag OOL, dag IOL, string asmstr, |
| 222 | InstrItinClass itin, list<dag> pattern> |
| 223 | : I<OOL, IOL, asmstr, itin> |
| 224 | { |
| 225 | bits<16> i16; |
| 226 | bits<7> RT; |
| 227 | |
| 228 | let Pattern = pattern; |
| 229 | |
| 230 | let Inst{0-8} = opcode; |
| 231 | let Inst{9-24} = i16; |
| 232 | let Inst{25-31} = RT; |
| 233 | } |
| 234 | |
| 235 | // Specialized version of the RI16 Format for unconditional branch relative and |
| 236 | // branch absolute, branch and set link. Note that for branch and set link, the |
| 237 | // link register doesn't have to be $lr, but this is actually hard coded into |
| 238 | // the instruction pattern. |
| 239 | |
| 240 | let RT = 0 in { |
| 241 | class UncondBranch<bits<9> opcode, dag OOL, dag IOL, string asmstr, |
| 242 | list<dag> pattern> |
| 243 | : RI16Form<opcode, OOL, IOL, asmstr, BranchResolv, pattern> |
| 244 | { } |
| 245 | |
| 246 | class BranchSetLink<bits<9> opcode, dag OOL, dag IOL, string asmstr, |
| 247 | list<dag> pattern> |
| 248 | : RI16Form<opcode, OOL, IOL, asmstr, BranchResolv, pattern> |
| 249 | { } |
| 250 | } |
| 251 | |
| 252 | // RI18 Format |
| 253 | class RI18Form<bits<7> opcode, dag OOL, dag IOL, string asmstr, |
| 254 | InstrItinClass itin, list<dag> pattern> |
| 255 | : I<OOL, IOL, asmstr, itin> |
| 256 | { |
| 257 | bits<18> i18; |
| 258 | bits<7> RT; |
| 259 | |
| 260 | let Pattern = pattern; |
| 261 | |
| 262 | let Inst{0-6} = opcode; |
| 263 | let Inst{7-24} = i18; |
| 264 | let Inst{25-31} = RT; |
| 265 | } |
| 266 | |
| 267 | //===----------------------------------------------------------------------===// |
| 268 | // Instruction formats for intrinsics: |
| 269 | //===----------------------------------------------------------------------===// |
| 270 | |
| 271 | // RI10 Format for v8i16 intrinsics |
| 272 | class RI10_Int_v8i16<bits<8> opcode, string opc, InstrItinClass itin, |
| 273 | Intrinsic IntID> : |
| 274 | RI10Form<opcode, (outs VECREG:$rT), (ins s10imm:$val, VECREG:$rA), |
| 275 | !strconcat(opc, " $rT, $rA, $val"), itin, |
| 276 | [(set (v8i16 VECREG:$rT), (IntID (v8i16 VECREG:$rA), |
| 277 | i16ImmSExt10:$val))] >; |
| 278 | |
| 279 | class RI10_Int_v4i32<bits<8> opcode, string opc, InstrItinClass itin, |
| 280 | Intrinsic IntID> : |
| 281 | RI10Form<opcode, (outs VECREG:$rT), (ins s10imm:$val, VECREG:$rA), |
| 282 | !strconcat(opc, " $rT, $rA, $val"), itin, |
| 283 | [(set (v4i32 VECREG:$rT), (IntID (v4i32 VECREG:$rA), |
| 284 | i32ImmSExt10:$val))] >; |
| 285 | |
| 286 | // RR Format for v8i16 intrinsics |
| 287 | class RR_Int_v8i16<bits<11> opcode, string opc, InstrItinClass itin, |
| 288 | Intrinsic IntID> : |
| 289 | RRForm<opcode, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 290 | !strconcat(opc, " $rT, $rA, $rB"), itin, |
| 291 | [(set (v8i16 VECREG:$rT), (IntID (v8i16 VECREG:$rA), |
| 292 | (v8i16 VECREG:$rB)))] >; |
| 293 | |
| 294 | // RR Format for v4i32 intrinsics |
| 295 | class RR_Int_v4i32<bits<11> opcode, string opc, InstrItinClass itin, |
| 296 | Intrinsic IntID> : |
| 297 | RRForm<opcode, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB), |
| 298 | !strconcat(opc, " $rT, $rA, $rB"), itin, |
| 299 | [(set (v4i32 VECREG:$rT), (IntID (v4i32 VECREG:$rA), |
| 300 | (v4i32 VECREG:$rB)))] >; |
| 301 | |
| 302 | //===----------------------------------------------------------------------===// |
| 303 | // Pseudo instructions, like call frames: |
| 304 | //===----------------------------------------------------------------------===// |
| 305 | |
| 306 | class Pseudo<dag OOL, dag IOL, string asmstr, list<dag> pattern> |
| 307 | : I<OOL, IOL, asmstr, NoItinerary> { |
| 308 | let Pattern = pattern; |
| 309 | let Inst{31-0} = 0; |
| 310 | } |