Akira Hatanaka | df98a7a | 2012-05-24 18:32:33 +0000 | [diff] [blame] | 1 | //===- Mips16InstrInfo.td - Target Description for Mips16 -*- tablegen -*-=// |
| 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 | // This file describes Mips16 instructions. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 14 | // |
| 15 | // RRR-type instruction format |
| 16 | // |
| 17 | |
| 18 | class FRRR16_ins<bits<2> _f, string asmstr, InstrItinClass itin> : |
| 19 | FRRR16<_f, (outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry), |
| 20 | !strconcat(asmstr, "\t$rz, $rx, $ry"), [], itin>; |
| 21 | |
| 22 | // |
Akira Hatanaka | 0fbaec2 | 2012-09-14 03:21:56 +0000 | [diff] [blame^] | 23 | // I8_MOVR32 instruction format (used only by the MOVR32 instructio |
| 24 | // |
| 25 | class FI8_MOVR3216_ins<string asmstr, InstrItinClass itin>: |
| 26 | FI8_MOVR3216<(outs CPU16Regs:$rz), (ins CPURegs:$r32), |
| 27 | !strconcat(asmstr, "\t$rz, $r32"), [], itin>; |
| 28 | |
| 29 | // |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 30 | // I8_MOV32R instruction format (used only by MOV32R instruction) |
| 31 | // |
| 32 | class FI8_MOV32R16_ins<string asmstr, InstrItinClass itin>: |
| 33 | FI8_MOV32R16<(outs CPURegs:$r32), (ins CPU16Regs:$rz), |
| 34 | !strconcat(asmstr, "\t$r32, $rz"), [], itin>; |
| 35 | |
| 36 | // |
| 37 | // EXT-RI instruction format |
| 38 | // |
| 39 | |
| 40 | class FEXT_RI16_ins_base<bits<5> _op, string asmstr, string asmstr2, |
| 41 | InstrItinClass itin>: |
| 42 | FEXT_RI16<_op, (outs CPU16Regs:$rx), (ins simm16:$imm), |
| 43 | !strconcat(asmstr, asmstr2), [], itin>; |
| 44 | |
| 45 | class FEXT_RI16_ins<bits<5> _op, string asmstr, |
| 46 | InstrItinClass itin>: |
| 47 | FEXT_RI16_ins_base<_op, asmstr, "\t$rx, $imm", itin>; |
| 48 | |
| 49 | class FEXT_RI16_PC_ins<bits<5> _op, string asmstr, InstrItinClass itin>: |
| 50 | FEXT_RI16_ins_base<_op, asmstr, "\t$rx, $$pc, $imm", itin>; |
| 51 | |
Akira Hatanaka | 64626fc | 2012-07-26 02:24:43 +0000 | [diff] [blame] | 52 | |
| 53 | class FEXT_2RI16_ins<bits<5> _op, string asmstr, |
| 54 | InstrItinClass itin>: |
| 55 | FEXT_RI16<_op, (outs CPU16Regs:$rx), (ins CPU16Regs:$rx_, simm16:$imm), |
| 56 | !strconcat(asmstr, "\t$rx, $imm"), [], itin> { |
| 57 | let Constraints = "$rx_ = $rx"; |
| 58 | } |
| 59 | |
| 60 | |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 61 | // |
| 62 | // RR-type instruction format |
| 63 | // |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 64 | |
| 65 | class FRR16_ins<bits<5> f, string asmstr, InstrItinClass itin> : |
| 66 | FRR16<f, (outs CPU16Regs:$rx), (ins CPU16Regs:$ry), |
| 67 | !strconcat(asmstr, "\t$rx, $ry"), [], itin> { |
| 68 | } |
| 69 | |
| 70 | class FRxRxRy16_ins<bits<5> f, string asmstr, |
| 71 | InstrItinClass itin> : |
| 72 | FRR16<f, (outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry), |
| 73 | !strconcat(asmstr, "\t$rz, $ry"), |
| 74 | [], itin> { |
| 75 | let Constraints = "$rx = $rz"; |
| 76 | } |
| 77 | |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 78 | let rx=0 in |
| 79 | class FRR16_JALRC_RA_only_ins<bits<1> nd_, bits<1> l_, |
| 80 | string asmstr, InstrItinClass itin>: |
| 81 | FRR16_JALRC<nd_, l_, 1, (outs), (ins), !strconcat(asmstr, "\t $$ra"), |
| 82 | [], itin> ; |
| 83 | |
| 84 | // |
| 85 | // EXT-RRI instruction format |
| 86 | // |
| 87 | |
| 88 | class FEXT_RRI16_mem_ins<bits<5> op, string asmstr, Operand MemOpnd, |
| 89 | InstrItinClass itin>: |
| 90 | FEXT_RRI16<op, (outs CPU16Regs:$ry), (ins MemOpnd:$addr), |
| 91 | !strconcat(asmstr, "\t$ry, $addr"), [], itin>; |
| 92 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 93 | class FEXT_RRI16_mem2_ins<bits<5> op, string asmstr, Operand MemOpnd, |
| 94 | InstrItinClass itin>: |
| 95 | FEXT_RRI16<op, (outs ), (ins CPU16Regs:$ry, MemOpnd:$addr), |
| 96 | !strconcat(asmstr, "\t$ry, $addr"), [], itin>; |
| 97 | |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 98 | // |
| 99 | // EXT-SHIFT instruction format |
| 100 | // |
| 101 | class FEXT_SHIFT16_ins<bits<2> _f, string asmstr, InstrItinClass itin>: |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 102 | FEXT_SHIFT16<_f, (outs CPU16Regs:$rx), (ins CPU16Regs:$ry, shamt:$sa), |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 103 | !strconcat(asmstr, "\t$rx, $ry, $sa"), [], itin>; |
| 104 | |
| 105 | // |
| 106 | // Address operand |
| 107 | def mem16 : Operand<i32> { |
| 108 | let PrintMethod = "printMemOperand"; |
| 109 | let MIOperandInfo = (ops CPU16Regs, simm16); |
| 110 | let EncoderMethod = "getMemEncoding"; |
| 111 | } |
| 112 | |
| 113 | // |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 114 | // Some general instruction class info |
| 115 | // |
| 116 | // |
| 117 | |
| 118 | class ArithLogic16Defs<bit isCom=0> { |
| 119 | bits<5> shamt = 0; |
| 120 | bit isCommutable = isCom; |
| 121 | bit isReMaterializable = 1; |
| 122 | bit neverHasSideEffects = 1; |
| 123 | } |
| 124 | |
| 125 | // |
Akira Hatanaka | 64626fc | 2012-07-26 02:24:43 +0000 | [diff] [blame] | 126 | |
| 127 | // Format: ADDIU rx, immediate MIPS16e |
| 128 | // Purpose: Add Immediate Unsigned Word (2-Operand, Extended) |
| 129 | // To add a constant to a 32-bit integer. |
| 130 | // |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 131 | def AddiuRxImmX16: FEXT_RI16_ins<0b01001, "addiu", IIAlu>; |
Akira Hatanaka | 64626fc | 2012-07-26 02:24:43 +0000 | [diff] [blame] | 132 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 133 | def AddiuRxRxImmX16: FEXT_2RI16_ins<0b01001, "addiu", IIAlu>, |
| 134 | ArithLogic16Defs<0>; |
Akira Hatanaka | 64626fc | 2012-07-26 02:24:43 +0000 | [diff] [blame] | 135 | |
| 136 | // |
| 137 | |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 138 | // Format: ADDIU rx, pc, immediate MIPS16e |
| 139 | // Purpose: Add Immediate Unsigned Word (3-Operand, PC-Relative, Extended) |
| 140 | // To add a constant to the program counter. |
| 141 | // |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 142 | def AddiuRxPcImmX16: FEXT_RI16_PC_ins<0b00001, "addiu", IIAlu>; |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 143 | // |
| 144 | // Format: ADDU rz, rx, ry MIPS16e |
| 145 | // Purpose: Add Unsigned Word (3-Operand) |
| 146 | // To add 32-bit integers. |
| 147 | // |
| 148 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 149 | def AdduRxRyRz16: FRRR16_ins<01, "addu", IIAlu>, ArithLogic16Defs<1>; |
| 150 | |
| 151 | // |
| 152 | // Format: AND rx, ry MIPS16e |
| 153 | // Purpose: AND |
| 154 | // To do a bitwise logical AND. |
| 155 | |
| 156 | def AndRxRxRy16: FRxRxRy16_ins<0b01100, "and", IIAlu>, ArithLogic16Defs<1>; |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 157 | |
| 158 | // |
| 159 | // Format: JR ra MIPS16e |
| 160 | // Purpose: Jump Register Through Register ra |
| 161 | // To execute a branch to the instruction address in the return |
| 162 | // address register. |
| 163 | // |
| 164 | |
| 165 | def JrRa16: FRR16_JALRC_RA_only_ins<0, 0, "jr", IIAlu>; |
| 166 | |
| 167 | // |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 168 | // Format: LB ry, offset(rx) MIPS16e |
| 169 | // Purpose: Load Byte (Extended) |
| 170 | // To load a byte from memory as a signed value. |
| 171 | // |
| 172 | def LbRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10011, "lb", mem16, IIAlu>; |
| 173 | |
| 174 | // |
| 175 | // Format: LBU ry, offset(rx) MIPS16e |
| 176 | // Purpose: Load Byte Unsigned (Extended) |
| 177 | // To load a byte from memory as a unsigned value. |
| 178 | // |
| 179 | def LbuRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10100, "lbu", mem16, IIAlu>; |
| 180 | |
| 181 | // |
| 182 | // Format: LH ry, offset(rx) MIPS16e |
| 183 | // Purpose: Load Halfword signed (Extended) |
| 184 | // To load a halfword from memory as a signed value. |
| 185 | // |
| 186 | def LhRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10100, "lh", mem16, IIAlu>; |
| 187 | |
| 188 | // |
| 189 | // Format: LHU ry, offset(rx) MIPS16e |
| 190 | // Purpose: Load Halfword unsigned (Extended) |
| 191 | // To load a halfword from memory as an unsigned value. |
| 192 | // |
| 193 | def LhuRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10100, "lhu", mem16, IIAlu>; |
| 194 | |
| 195 | // |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 196 | // Format: LI rx, immediate MIPS16e |
| 197 | // Purpose: Load Immediate (Extended) |
| 198 | // To load a constant into a GPR. |
| 199 | // |
| 200 | def LiRxImmX16: FEXT_RI16_ins<0b01101, "li", IIAlu>; |
| 201 | |
| 202 | // |
| 203 | // Format: LW ry, offset(rx) MIPS16e |
| 204 | // Purpose: Load Word (Extended) |
| 205 | // To load a word from memory as a signed value. |
| 206 | // |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 207 | def LwRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10011, "lw", mem16, IIAlu>; |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 208 | |
| 209 | // |
| 210 | // Format: MOVE r32, rz MIPS16e |
| 211 | // Purpose: Move |
| 212 | // To move the contents of a GPR to a GPR. |
| 213 | // |
Akira Hatanaka | 0fbaec2 | 2012-09-14 03:21:56 +0000 | [diff] [blame^] | 214 | def Move32R16: FI8_MOV32R16_ins<"move", IIAlu>; |
| 215 | |
| 216 | // |
| 217 | // Format: MOVE ry, r32 MIPS16e |
| 218 | //Purpose: Move |
| 219 | // To move the contents of a GPR to a GPR. |
| 220 | // |
| 221 | def MoveR3216: FI8_MOVR3216_ins<"move", IIAlu>; |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 222 | |
| 223 | // |
| 224 | // Format: NEG rx, ry MIPS16e |
| 225 | // Purpose: Negate |
| 226 | // To negate an integer value. |
| 227 | // |
| 228 | def NegRxRy16: FRR16_ins<0b11101, "neg", IIAlu>; |
| 229 | |
| 230 | // |
| 231 | // Format: NOT rx, ry MIPS16e |
| 232 | // Purpose: Not |
| 233 | // To complement an integer value |
| 234 | // |
| 235 | def NotRxRy16: FRR16_ins<0b01111, "not", IIAlu>; |
| 236 | |
| 237 | // |
| 238 | // Format: OR rx, ry MIPS16e |
| 239 | // Purpose: Or |
| 240 | // To do a bitwise logical OR. |
| 241 | // |
| 242 | def OrRxRxRy16: FRxRxRy16_ins<0b01101, "or", IIAlu>, ArithLogic16Defs<1>; |
| 243 | |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 244 | // |
| 245 | // Format: RESTORE {ra,}{s0/s1/s0-1,}{framesize} |
| 246 | // (All args are optional) MIPS16e |
| 247 | // Purpose: Restore Registers and Deallocate Stack Frame |
| 248 | // To deallocate a stack frame before exit from a subroutine, |
| 249 | // restoring return address and static registers, and adjusting |
| 250 | // stack |
| 251 | // |
| 252 | |
| 253 | // fixed form for restoring RA and the frame |
| 254 | // for direct object emitter, encoding needs to be adjusted for the |
| 255 | // frame size |
| 256 | // |
| 257 | let ra=1, s=0,s0=0,s1=0 in |
| 258 | def RestoreRaF16: |
| 259 | FI8_SVRS16<0b1, (outs), (ins uimm16:$frame_size), |
| 260 | "restore \t$$ra, $frame_size", [], IILoad >; |
| 261 | |
| 262 | // |
| 263 | // Format: SAVE {ra,}{s0/s1/s0-1,}{framesize} (All arguments are optional) |
| 264 | // MIPS16e |
| 265 | // Purpose: Save Registers and Set Up Stack Frame |
| 266 | // To set up a stack frame on entry to a subroutine, |
| 267 | // saving return address and static registers, and adjusting stack |
| 268 | // |
| 269 | let ra=1, s=1,s0=0,s1=0 in |
| 270 | def SaveRaF16: |
| 271 | FI8_SVRS16<0b1, (outs), (ins uimm16:$frame_size), |
| 272 | "save \t$$ra, $frame_size", [], IILoad >; |
| 273 | |
| 274 | // |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 275 | // Format: SB ry, offset(rx) MIPS16e |
| 276 | // Purpose: Store Byte (Extended) |
| 277 | // To store a byte to memory. |
| 278 | // |
| 279 | def SbRxRyOffMemX16: FEXT_RRI16_mem2_ins<0b11000, "sb", mem16, IIAlu>; |
| 280 | |
| 281 | // |
| 282 | // Format: SH ry, offset(rx) MIPS16e |
| 283 | // Purpose: Store Halfword (Extended) |
| 284 | // To store a halfword to memory. |
| 285 | // |
| 286 | def ShRxRyOffMemX16: FEXT_RRI16_mem2_ins<0b11001, "sh", mem16, IIAlu>; |
| 287 | |
| 288 | // |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 289 | // Format: SLL rx, ry, sa MIPS16e |
| 290 | // Purpose: Shift Word Left Logical (Extended) |
| 291 | // To execute a left-shift of a word by a fixed number of bits—0 to 31 bits. |
| 292 | // |
| 293 | def SllX16: FEXT_SHIFT16_ins<0b00, "sll", IIAlu>; |
| 294 | |
| 295 | // |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 296 | // Format: SLLV ry, rx MIPS16e |
| 297 | // Purpose: Shift Word Left Logical Variable |
| 298 | // To execute a left-shift of a word by a variable number of bits. |
| 299 | // |
| 300 | def SllvRxRy16 : FRxRxRy16_ins<0b00100, "sllv", IIAlu>; |
| 301 | |
| 302 | |
| 303 | // |
| 304 | // Format: SRAV ry, rx MIPS16e |
| 305 | // Purpose: Shift Word Right Arithmetic Variable |
| 306 | // To execute an arithmetic right-shift of a word by a variable |
| 307 | // number of bits. |
| 308 | // |
| 309 | def SravRxRy16: FRxRxRy16_ins<0b00111, "srav", IIAlu>; |
| 310 | |
| 311 | |
| 312 | // |
| 313 | // Format: SRA rx, ry, sa MIPS16e |
| 314 | // Purpose: Shift Word Right Arithmetic (Extended) |
| 315 | // To execute an arithmetic right-shift of a word by a fixed |
| 316 | // number of bits—1 to 8 bits. |
| 317 | // |
| 318 | def SraX16: FEXT_SHIFT16_ins<0b11, "sra", IIAlu>; |
| 319 | |
| 320 | |
| 321 | // |
| 322 | // Format: SRLV ry, rx MIPS16e |
| 323 | // Purpose: Shift Word Right Logical Variable |
| 324 | // To execute a logical right-shift of a word by a variable |
| 325 | // number of bits. |
| 326 | // |
| 327 | def SrlvRxRy16: FRxRxRy16_ins<0b00110, "srlv", IIAlu>; |
| 328 | |
| 329 | |
| 330 | // |
| 331 | // Format: SRL rx, ry, sa MIPS16e |
| 332 | // Purpose: Shift Word Right Logical (Extended) |
| 333 | // To execute a logical right-shift of a word by a fixed |
| 334 | // number of bits—1 to 31 bits. |
| 335 | // |
| 336 | def SrlX16: FEXT_SHIFT16_ins<0b10, "srl", IIAlu>; |
| 337 | |
| 338 | // |
| 339 | // Format: SUBU rz, rx, ry MIPS16e |
| 340 | // Purpose: Subtract Unsigned Word |
| 341 | // To subtract 32-bit integers |
| 342 | // |
| 343 | def SubuRxRyRz16: FRRR16_ins<0b11, "subu", IIAlu>, ArithLogic16Defs<0>; |
| 344 | |
| 345 | // |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 346 | // Format: SW ry, offset(rx) MIPS16e |
| 347 | // Purpose: Store Word (Extended) |
| 348 | // To store a word to memory. |
| 349 | // |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 350 | def SwRxRyOffMemX16: FEXT_RRI16_mem2_ins<0b11011, "sw", mem16, IIAlu>; |
| 351 | |
| 352 | // |
| 353 | // Format: XOR rx, ry MIPS16e |
| 354 | // Purpose: Xor |
| 355 | // To do a bitwise logical XOR. |
| 356 | // |
| 357 | def XorRxRxRy16: FRxRxRy16_ins<0b01110, "xor", IIAlu>, ArithLogic16Defs<1>; |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 358 | |
Akira Hatanaka | 765c312 | 2012-06-21 20:39:10 +0000 | [diff] [blame] | 359 | class Mips16Pat<dag pattern, dag result> : Pat<pattern, result> { |
| 360 | let Predicates = [InMips16Mode]; |
| 361 | } |
| 362 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 363 | // Unary Arith/Logic |
| 364 | // |
| 365 | class ArithLogicU_pat<PatFrag OpNode, Instruction I> : |
| 366 | Mips16Pat<(OpNode CPU16Regs:$r), |
| 367 | (I CPU16Regs:$r)>; |
Akira Hatanaka | bff8e31 | 2012-05-31 02:59:44 +0000 | [diff] [blame] | 368 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 369 | def: ArithLogicU_pat<not, NotRxRy16>; |
| 370 | def: ArithLogicU_pat<ineg, NegRxRy16>; |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 371 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 372 | class ArithLogic16_pat<SDNode OpNode, Instruction I> : |
| 373 | Mips16Pat<(OpNode CPU16Regs:$l, CPU16Regs:$r), |
| 374 | (I CPU16Regs:$l, CPU16Regs:$r)>; |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 375 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 376 | def: ArithLogic16_pat<add, AdduRxRyRz16>; |
| 377 | def: ArithLogic16_pat<and, AndRxRxRy16>; |
| 378 | def: ArithLogic16_pat<or, OrRxRxRy16>; |
| 379 | def: ArithLogic16_pat<sub, SubuRxRyRz16>; |
| 380 | def: ArithLogic16_pat<xor, XorRxRxRy16>; |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 381 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 382 | // Arithmetic and logical instructions with 2 register operands. |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 383 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 384 | class ArithLogicI16_pat<SDNode OpNode, PatFrag imm_type, Instruction I> : |
| 385 | Mips16Pat<(OpNode CPU16Regs:$in, imm_type:$imm), |
| 386 | (I CPU16Regs:$in, imm_type:$imm)>; |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 387 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 388 | def: ArithLogicI16_pat<add, immSExt16, AddiuRxRxImmX16>; |
| 389 | def: ArithLogicI16_pat<shl, immZExt5, SllX16>; |
| 390 | def: ArithLogicI16_pat<srl, immZExt5, SrlX16>; |
| 391 | def: ArithLogicI16_pat<sra, immZExt5, SraX16>; |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 392 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 393 | class shift_rotate_reg16_pat<SDNode OpNode, Instruction I> : |
| 394 | Mips16Pat<(OpNode CPU16Regs:$r, CPU16Regs:$ra), |
| 395 | (I CPU16Regs:$r, CPU16Regs:$ra)>; |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 396 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 397 | def: shift_rotate_reg16_pat<shl, SllvRxRy16>; |
| 398 | def: shift_rotate_reg16_pat<sra, SravRxRy16>; |
| 399 | def: shift_rotate_reg16_pat<srl, SrlvRxRy16>; |
| 400 | |
| 401 | class LoadM16_pat<PatFrag OpNode, Instruction I> : |
| 402 | Mips16Pat<(OpNode addr:$addr), (I addr:$addr)>; |
| 403 | |
| 404 | def: LoadM16_pat<sextloadi8, LbRxRyOffMemX16>; |
| 405 | def: LoadM16_pat<zextloadi8, LbuRxRyOffMemX16>; |
| 406 | def: LoadM16_pat<sextloadi16_a, LhRxRyOffMemX16>; |
| 407 | def: LoadM16_pat<zextloadi16_a, LhuRxRyOffMemX16>; |
| 408 | def: LoadM16_pat<load_a, LwRxRyOffMemX16>; |
| 409 | |
| 410 | class StoreM16_pat<PatFrag OpNode, Instruction I> : |
| 411 | Mips16Pat<(OpNode CPU16Regs:$r, addr:$addr), (I CPU16Regs:$r, addr:$addr)>; |
| 412 | |
| 413 | def: StoreM16_pat<truncstorei8, SbRxRyOffMemX16>; |
| 414 | def: StoreM16_pat<truncstorei16_a, ShRxRyOffMemX16>; |
| 415 | def: StoreM16_pat<store_a, SwRxRyOffMemX16>; |
| 416 | |
Akira Hatanaka | bff8e31 | 2012-05-31 02:59:44 +0000 | [diff] [blame] | 417 | |
| 418 | // Jump and Link (Call) |
Akira Hatanaka | f640f04 | 2012-07-17 22:55:34 +0000 | [diff] [blame] | 419 | let isCall=1, hasDelaySlot=1 in |
Akira Hatanaka | bff8e31 | 2012-05-31 02:59:44 +0000 | [diff] [blame] | 420 | def JumpLinkReg16: |
Akira Hatanaka | f640f04 | 2012-07-17 22:55:34 +0000 | [diff] [blame] | 421 | FRR16_JALRC<0, 0, 0, (outs), (ins CPU16Regs:$rs), |
| 422 | "jalr \t$rs", [(MipsJmpLink CPU16Regs:$rs)], IIBranch>; |
| 423 | |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 424 | // Mips16 pseudos |
| 425 | let isReturn=1, isTerminator=1, hasDelaySlot=1, isBarrier=1, hasCtrlDep=1, |
| 426 | hasExtraSrcRegAllocReq = 1 in |
| 427 | def RetRA16 : MipsPseudo16<(outs), (ins), "", [(MipsRet)]>; |
| 428 | |
Akira Hatanaka | 765c312 | 2012-06-21 20:39:10 +0000 | [diff] [blame] | 429 | // Small immediates |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 430 | def: Mips16Pat<(i32 immZExt16:$in), (LiRxImmX16 immZExt16:$in)>; |
Akira Hatanaka | 64626fc | 2012-07-26 02:24:43 +0000 | [diff] [blame] | 431 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 432 | def: Mips16Pat<(add CPU16Regs:$hi, (MipsLo tglobaladdr:$lo)), |
| 433 | (AddiuRxRxImmX16 CPU16Regs:$hi, tglobaladdr:$lo)>; |