1 //===- Mips16InstrInfo.td - Target Description for Mips16 -*- tablegen -*-=//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes Mips16 instructions.
12 //===----------------------------------------------------------------------===//
17 def mem16 : Operand<i32> {
18 let PrintMethod = "printMemOperand";
19 let MIOperandInfo = (ops CPU16Regs, simm16);
20 let EncoderMethod = "getMemEncoding";
24 // EXT-I instruction format
26 class FEXT_I16_ins<bits<5> eop, string asmstr, InstrItinClass itin> :
27 FEXT_I16<eop, (outs), (ins brtarget:$imm16),
28 !strconcat(asmstr, "\t$imm16"),[], itin>;
31 // EXT-I8 instruction format
34 class FEXT_I816_ins_base<bits<3> _func, string asmstr,
35 string asmstr2, InstrItinClass itin>:
36 FEXT_I816<_func, (outs), (ins uimm16:$imm), !strconcat(asmstr, asmstr2),
39 class FEXT_I816_ins<bits<3> _func, string asmstr,
41 FEXT_I816_ins_base<_func, asmstr, "\t$imm", itin>;
44 // Assembler formats in alphabetical order.
45 // Natural and pseudos are mixed together.
48 // EXT-RI instruction format
51 class FEXT_RI16_ins_base<bits<5> _op, string asmstr, string asmstr2,
53 FEXT_RI16<_op, (outs CPU16Regs:$rx), (ins simm16:$imm),
54 !strconcat(asmstr, asmstr2), [], itin>;
56 class FEXT_RI16_ins<bits<5> _op, string asmstr,
58 FEXT_RI16_ins_base<_op, asmstr, "\t$rx, $imm", itin>;
60 class FEXT_RI16_PC_ins<bits<5> _op, string asmstr, InstrItinClass itin>:
61 FEXT_RI16_ins_base<_op, asmstr, "\t$rx, $$pc, $imm", itin>;
63 class FEXT_RI16_B_ins<bits<5> _op, string asmstr,
65 FEXT_RI16<_op, (outs), (ins CPU16Regs:$rx, brtarget:$imm),
66 !strconcat(asmstr, "\t$rx, $imm"), [], itin>;
68 class FEXT_2RI16_ins<bits<5> _op, string asmstr,
70 FEXT_RI16<_op, (outs CPU16Regs:$rx), (ins CPU16Regs:$rx_, simm16:$imm),
71 !strconcat(asmstr, "\t$rx, $imm"), [], itin> {
72 let Constraints = "$rx_ = $rx";
76 // this has an explicit sp argument that we ignore to work around a problem
78 class FEXT_RI16_SP_explicit_ins<bits<5> _op, string asmstr,
80 FEXT_RI16<_op, (outs CPU16Regs:$rx), (ins CPUSPReg:$ry, simm16:$imm),
81 !strconcat(asmstr, "\t$rx, $imm ( $ry ); "), [], itin>;
84 // EXT-RRI instruction format
87 class FEXT_RRI16_mem_ins<bits<5> op, string asmstr, Operand MemOpnd,
89 FEXT_RRI16<op, (outs CPU16Regs:$ry), (ins MemOpnd:$addr),
90 !strconcat(asmstr, "\t$ry, $addr"), [], itin>;
92 class FEXT_RRI16_mem2_ins<bits<5> op, string asmstr, Operand MemOpnd,
94 FEXT_RRI16<op, (outs ), (ins CPU16Regs:$ry, MemOpnd:$addr),
95 !strconcat(asmstr, "\t$ry, $addr"), [], itin>;
98 // EXT-SHIFT instruction format
100 class FEXT_SHIFT16_ins<bits<2> _f, string asmstr, InstrItinClass itin>:
101 FEXT_SHIFT16<_f, (outs CPU16Regs:$rx), (ins CPU16Regs:$ry, shamt:$sa),
102 !strconcat(asmstr, "\t$rx, $ry, $sa"), [], itin>;
107 class FEXT_T8I816_ins<bits<3> _func, string asmstr, string asmstr2,
108 InstrItinClass itin>:
109 FEXT_I816<_func, (outs),
110 (ins CPU16Regs:$rx, CPU16Regs:$ry, brtarget:$imm),
111 !strconcat(asmstr2, !strconcat("\t$rx, $ry\n\t",
112 !strconcat(asmstr, "\t$imm"))),[], itin> {
119 class FEXT_T8I8I16_ins<bits<3> _func, string asmstr, string asmstr2,
120 InstrItinClass itin>:
121 FEXT_I816<_func, (outs),
122 (ins CPU16Regs:$rx, simm16:$imm, brtarget:$targ),
123 !strconcat(asmstr2, !strconcat("\t$rx, $imm\n\t",
124 !strconcat(asmstr, "\t$targ"))), [], itin> {
131 // I8_MOVR32 instruction format (used only by the MOVR32 instructio
133 class FI8_MOVR3216_ins<string asmstr, InstrItinClass itin>:
134 FI8_MOVR3216<(outs CPU16Regs:$rz), (ins CPURegs:$r32),
135 !strconcat(asmstr, "\t$rz, $r32"), [], itin>;
138 // I8_MOV32R instruction format (used only by MOV32R instruction)
141 class FI8_MOV32R16_ins<string asmstr, InstrItinClass itin>:
142 FI8_MOV32R16<(outs CPURegs:$r32), (ins CPU16Regs:$rz),
143 !strconcat(asmstr, "\t$r32, $rz"), [], itin>;
146 // This are pseudo formats for multiply
147 // This first one can be changed to non pseudo now.
151 class FMULT16_ins<string asmstr, InstrItinClass itin> :
152 MipsPseudo16<(outs), (ins CPU16Regs:$rx, CPU16Regs:$ry),
153 !strconcat(asmstr, "\t$rx, $ry"), []>;
158 class FMULT16_LO_ins<string asmstr, InstrItinClass itin> :
159 MipsPseudo16<(outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry),
160 !strconcat(asmstr, "\t$rx, $ry\n\tmflo\t$rz"), []> {
165 // RR-type instruction format
168 class FRR16_ins<bits<5> f, string asmstr, InstrItinClass itin> :
169 FRR16<f, (outs CPU16Regs:$rx), (ins CPU16Regs:$ry),
170 !strconcat(asmstr, "\t$rx, $ry"), [], itin> {
174 // maybe refactor but need a $zero as a dummy first parameter
176 class FRR16_div_ins<bits<5> f, string asmstr, InstrItinClass itin> :
177 FRR16<f, (outs ), (ins CPU16Regs:$rx, CPU16Regs:$ry),
178 !strconcat(asmstr, "\t$$zero, $rx, $ry"), [], itin> ;
180 class FRR16_M_ins<bits<5> f, string asmstr,
181 InstrItinClass itin> :
182 FRR16<f, (outs CPU16Regs:$rx), (ins),
183 !strconcat(asmstr, "\t$rx"), [], itin>;
185 class FRxRxRy16_ins<bits<5> f, string asmstr,
186 InstrItinClass itin> :
187 FRR16<f, (outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry),
188 !strconcat(asmstr, "\t$rz, $ry"),
190 let Constraints = "$rx = $rz";
194 class FRR16_JALRC_RA_only_ins<bits<1> nd_, bits<1> l_,
195 string asmstr, InstrItinClass itin>:
196 FRR16_JALRC<nd_, l_, 1, (outs), (ins), !strconcat(asmstr, "\t $$ra"),
200 // RRR-type instruction format
203 class FRRR16_ins<bits<2> _f, string asmstr, InstrItinClass itin> :
204 FRRR16<_f, (outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry),
205 !strconcat(asmstr, "\t$rz, $rx, $ry"), [], itin>;
208 // Some general instruction class info
212 class ArithLogic16Defs<bit isCom=0> {
214 bit isCommutable = isCom;
215 bit isReMaterializable = 1;
216 bit neverHasSideEffects = 1;
221 bit isTerminator = 1;
227 bit isTerminator = 1;
239 // Format: ADDIU rx, immediate MIPS16e
240 // Purpose: Add Immediate Unsigned Word (2-Operand, Extended)
241 // To add a constant to a 32-bit integer.
243 def AddiuRxImmX16: FEXT_RI16_ins<0b01001, "addiu", IIAlu>;
245 def AddiuRxRxImmX16: FEXT_2RI16_ins<0b01001, "addiu", IIAlu>,
250 // Format: ADDIU rx, pc, immediate MIPS16e
251 // Purpose: Add Immediate Unsigned Word (3-Operand, PC-Relative, Extended)
252 // To add a constant to the program counter.
254 def AddiuRxPcImmX16: FEXT_RI16_PC_ins<0b00001, "addiu", IIAlu>;
256 // Format: ADDU rz, rx, ry MIPS16e
257 // Purpose: Add Unsigned Word (3-Operand)
258 // To add 32-bit integers.
261 def AdduRxRyRz16: FRRR16_ins<01, "addu", IIAlu>, ArithLogic16Defs<1>;
264 // Format: AND rx, ry MIPS16e
266 // To do a bitwise logical AND.
268 def AndRxRxRy16: FRxRxRy16_ins<0b01100, "and", IIAlu>, ArithLogic16Defs<1>;
272 // Format: BEQZ rx, offset MIPS16e
273 // Purpose: Branch on Equal to Zero (Extended)
274 // To test a GPR then do a PC-relative conditional branch.
276 def BeqzRxImmX16: FEXT_RI16_B_ins<0b00100, "beqz", IIAlu>, cbranch16;
278 // Format: B offset MIPS16e
279 // Purpose: Unconditional Branch
280 // To do an unconditional PC-relative branch.
282 def BimmX16: FEXT_I16_ins<0b00010, "b", IIAlu>, branch16;
285 // Format: BNEZ rx, offset MIPS16e
286 // Purpose: Branch on Not Equal to Zero (Extended)
287 // To test a GPR then do a PC-relative conditional branch.
289 def BnezRxImmX16: FEXT_RI16_B_ins<0b00101, "bnez", IIAlu>, cbranch16;
292 // Format: BTEQZ offset MIPS16e
293 // Purpose: Branch on T Equal to Zero (Extended)
294 // To test special register T then do a PC-relative conditional branch.
296 def BteqzX16: FEXT_I816_ins<0b000, "bteqz", IIAlu>, cbranch16;
298 def BteqzT8CmpX16: FEXT_T8I816_ins<0b000, "bteqz", "cmp", IIAlu>, cbranch16;
300 def BteqzT8CmpiX16: FEXT_T8I8I16_ins<0b000, "bteqz", "cmpi", IIAlu>,
303 def BteqzT8SltX16: FEXT_T8I816_ins<0b000, "bteqz", "slt", IIAlu>, cbranch16;
305 def BteqzT8SltuX16: FEXT_T8I816_ins<0b000, "bteqz", "sltu", IIAlu>, cbranch16;
307 def BteqzT8SltiX16: FEXT_T8I8I16_ins<0b000, "bteqz", "slti", IIAlu>, cbranch16;
309 def BteqzT8SltiuX16: FEXT_T8I8I16_ins<0b000, "bteqz", "sltiu", IIAlu>,
313 // Format: BTNEZ offset MIPS16e
314 // Purpose: Branch on T Not Equal to Zero (Extended)
315 // To test special register T then do a PC-relative conditional branch.
317 def BtnezX16: FEXT_I816_ins<0b001, "btnez", IIAlu> ,cbranch16;
319 def BtnezT8CmpX16: FEXT_T8I816_ins<0b000, "btnez", "cmp", IIAlu>, cbranch16;
321 def BtnezT8CmpiX16: FEXT_T8I8I16_ins<0b000, "btnez", "cmpi", IIAlu>, cbranch16;
323 def BtnezT8SltX16: FEXT_T8I816_ins<0b000, "btnez", "slt", IIAlu>, cbranch16;
325 def BtnezT8SltuX16: FEXT_T8I816_ins<0b000, "btnez", "sltu", IIAlu>, cbranch16;
327 def BtnezT8SltiX16: FEXT_T8I8I16_ins<0b000, "btnez", "slti", IIAlu>, cbranch16;
329 def BtnezT8SltiuX16: FEXT_T8I8I16_ins<0b000, "btnez", "sltiu", IIAlu>,
333 // Format: DIV rx, ry MIPS16e
334 // Purpose: Divide Word
335 // To divide 32-bit signed integers.
337 def DivRxRy16: FRR16_div_ins<0b11010, "div", IIAlu> {
342 // Format: DIVU rx, ry MIPS16e
343 // Purpose: Divide Unsigned Word
344 // To divide 32-bit unsigned integers.
346 def DivuRxRy16: FRR16_div_ins<0b11011, "divu", IIAlu> {
352 // Format: JR ra MIPS16e
353 // Purpose: Jump Register Through Register ra
354 // To execute a branch to the instruction address in the return
358 def JrRa16: FRR16_JALRC_RA_only_ins<0, 0, "jr", IIAlu>;
361 // Format: LB ry, offset(rx) MIPS16e
362 // Purpose: Load Byte (Extended)
363 // To load a byte from memory as a signed value.
365 def LbRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10011, "lb", mem16, IILoad>, MayLoad;
368 // Format: LBU ry, offset(rx) MIPS16e
369 // Purpose: Load Byte Unsigned (Extended)
370 // To load a byte from memory as a unsigned value.
372 def LbuRxRyOffMemX16:
373 FEXT_RRI16_mem_ins<0b10100, "lbu", mem16, IILoad>, MayLoad;
376 // Format: LH ry, offset(rx) MIPS16e
377 // Purpose: Load Halfword signed (Extended)
378 // To load a halfword from memory as a signed value.
380 def LhRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10100, "lh", mem16, IILoad>, MayLoad;
383 // Format: LHU ry, offset(rx) MIPS16e
384 // Purpose: Load Halfword unsigned (Extended)
385 // To load a halfword from memory as an unsigned value.
387 def LhuRxRyOffMemX16:
388 FEXT_RRI16_mem_ins<0b10100, "lhu", mem16, IILoad>, MayLoad;
391 // Format: LI rx, immediate MIPS16e
392 // Purpose: Load Immediate (Extended)
393 // To load a constant into a GPR.
395 def LiRxImmX16: FEXT_RI16_ins<0b01101, "li", IIAlu>;
398 // Format: LW ry, offset(rx) MIPS16e
399 // Purpose: Load Word (Extended)
400 // To load a word from memory as a signed value.
402 def LwRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10011, "lw", mem16, IILoad>, MayLoad;
404 // Format: LW rx, offset(sp) MIPS16e
405 // Purpose: Load Word (SP-Relative, Extended)
406 // To load an SP-relative word from memory as a signed value.
408 def LwRxSpImmX16: FEXT_RI16_SP_explicit_ins<0b10110, "lw", IILoad>, MayLoad;
411 // Format: MOVE r32, rz MIPS16e
413 // To move the contents of a GPR to a GPR.
415 def Move32R16: FI8_MOV32R16_ins<"move", IIAlu>;
418 // Format: MOVE ry, r32 MIPS16e
420 // To move the contents of a GPR to a GPR.
422 def MoveR3216: FI8_MOVR3216_ins<"move", IIAlu>;
425 // Format: MFHI rx MIPS16e
426 // Purpose: Move From HI Register
427 // To copy the special purpose HI register to a GPR.
429 def Mfhi16: FRR16_M_ins<0b10000, "mfhi", IIAlu> {
431 let neverHasSideEffects = 1;
435 // Format: MFLO rx MIPS16e
436 // Purpose: Move From LO Register
437 // To copy the special purpose LO register to a GPR.
439 def Mflo16: FRR16_M_ins<0b10010, "mflo", IIAlu> {
441 let neverHasSideEffects = 1;
445 // Pseudo Instruction for mult
447 def MultRxRy16: FMULT16_ins<"mult", IIAlu> {
448 let isCommutable = 1;
449 let neverHasSideEffects = 1;
453 def MultuRxRy16: FMULT16_ins<"multu", IIAlu> {
454 let isCommutable = 1;
455 let neverHasSideEffects = 1;
460 // Format: MULT rx, ry MIPS16e
461 // Purpose: Multiply Word
462 // To multiply 32-bit signed integers.
464 def MultRxRyRz16: FMULT16_LO_ins<"mult", IIAlu> {
465 let isCommutable = 1;
466 let neverHasSideEffects = 1;
471 // Format: MULTU rx, ry MIPS16e
472 // Purpose: Multiply Unsigned Word
473 // To multiply 32-bit unsigned integers.
475 def MultuRxRyRz16: FMULT16_LO_ins<"multu", IIAlu> {
476 let isCommutable = 1;
477 let neverHasSideEffects = 1;
482 // Format: NEG rx, ry MIPS16e
484 // To negate an integer value.
486 def NegRxRy16: FRR16_ins<0b11101, "neg", IIAlu>;
489 // Format: NOT rx, ry MIPS16e
491 // To complement an integer value
493 def NotRxRy16: FRR16_ins<0b01111, "not", IIAlu>;
496 // Format: OR rx, ry MIPS16e
498 // To do a bitwise logical OR.
500 def OrRxRxRy16: FRxRxRy16_ins<0b01101, "or", IIAlu>, ArithLogic16Defs<1>;
503 // Format: RESTORE {ra,}{s0/s1/s0-1,}{framesize}
504 // (All args are optional) MIPS16e
505 // Purpose: Restore Registers and Deallocate Stack Frame
506 // To deallocate a stack frame before exit from a subroutine,
507 // restoring return address and static registers, and adjusting
511 // fixed form for restoring RA and the frame
512 // for direct object emitter, encoding needs to be adjusted for the
515 let ra=1, s=0,s0=1,s1=1 in
517 FI8_SVRS16<0b1, (outs), (ins uimm16:$frame_size),
518 "restore \t$$ra, $$s0, $$s1, $frame_size", [], IILoad >, MayLoad {
519 let isCodeGenOnly = 1;
523 // Format: SAVE {ra,}{s0/s1/s0-1,}{framesize} (All arguments are optional)
525 // Purpose: Save Registers and Set Up Stack Frame
526 // To set up a stack frame on entry to a subroutine,
527 // saving return address and static registers, and adjusting stack
529 let ra=1, s=1,s0=1,s1=1 in
531 FI8_SVRS16<0b1, (outs), (ins uimm16:$frame_size),
532 "save \t$$ra, $$s0, $$s1, $frame_size", [], IIStore >, MayStore {
533 let isCodeGenOnly = 1;
536 // Format: SB ry, offset(rx) MIPS16e
537 // Purpose: Store Byte (Extended)
538 // To store a byte to memory.
541 FEXT_RRI16_mem2_ins<0b11000, "sb", mem16, IIStore>, MayStore;
544 // Format: SH ry, offset(rx) MIPS16e
545 // Purpose: Store Halfword (Extended)
546 // To store a halfword to memory.
549 FEXT_RRI16_mem2_ins<0b11001, "sh", mem16, IIStore>, MayStore;
552 // Format: SLL rx, ry, sa MIPS16e
553 // Purpose: Shift Word Left Logical (Extended)
554 // To execute a left-shift of a word by a fixed number of bits—0 to 31 bits.
556 def SllX16: FEXT_SHIFT16_ins<0b00, "sll", IIAlu>;
559 // Format: SLLV ry, rx MIPS16e
560 // Purpose: Shift Word Left Logical Variable
561 // To execute a left-shift of a word by a variable number of bits.
563 def SllvRxRy16 : FRxRxRy16_ins<0b00100, "sllv", IIAlu>;
567 // Format: SRAV ry, rx MIPS16e
568 // Purpose: Shift Word Right Arithmetic Variable
569 // To execute an arithmetic right-shift of a word by a variable
572 def SravRxRy16: FRxRxRy16_ins<0b00111, "srav", IIAlu>;
576 // Format: SRA rx, ry, sa MIPS16e
577 // Purpose: Shift Word Right Arithmetic (Extended)
578 // To execute an arithmetic right-shift of a word by a fixed
579 // number of bits—1 to 8 bits.
581 def SraX16: FEXT_SHIFT16_ins<0b11, "sra", IIAlu>;
585 // Format: SRLV ry, rx MIPS16e
586 // Purpose: Shift Word Right Logical Variable
587 // To execute a logical right-shift of a word by a variable
590 def SrlvRxRy16: FRxRxRy16_ins<0b00110, "srlv", IIAlu>;
594 // Format: SRL rx, ry, sa MIPS16e
595 // Purpose: Shift Word Right Logical (Extended)
596 // To execute a logical right-shift of a word by a fixed
597 // number of bits—1 to 31 bits.
599 def SrlX16: FEXT_SHIFT16_ins<0b10, "srl", IIAlu>;
602 // Format: SUBU rz, rx, ry MIPS16e
603 // Purpose: Subtract Unsigned Word
604 // To subtract 32-bit integers
606 def SubuRxRyRz16: FRRR16_ins<0b11, "subu", IIAlu>, ArithLogic16Defs<0>;
609 // Format: SW ry, offset(rx) MIPS16e
610 // Purpose: Store Word (Extended)
611 // To store a word to memory.
614 FEXT_RRI16_mem2_ins<0b11011, "sw", mem16, IIStore>, MayStore;
617 // Format: SW rx, offset(sp) MIPS16e
618 // Purpose: Store Word rx (SP-Relative)
619 // To store an SP-relative word to memory.
621 def SwRxSpImmX16: FEXT_RI16_SP_explicit_ins<0b11010, "sw", IIStore>, MayStore;
625 // Format: XOR rx, ry MIPS16e
627 // To do a bitwise logical XOR.
629 def XorRxRxRy16: FRxRxRy16_ins<0b01110, "xor", IIAlu>, ArithLogic16Defs<1>;
631 class Mips16Pat<dag pattern, dag result> : Pat<pattern, result> {
632 let Predicates = [InMips16Mode];
637 class ArithLogicU_pat<PatFrag OpNode, Instruction I> :
638 Mips16Pat<(OpNode CPU16Regs:$r),
641 def: ArithLogicU_pat<not, NotRxRy16>;
642 def: ArithLogicU_pat<ineg, NegRxRy16>;
644 class ArithLogic16_pat<SDNode OpNode, Instruction I> :
645 Mips16Pat<(OpNode CPU16Regs:$l, CPU16Regs:$r),
646 (I CPU16Regs:$l, CPU16Regs:$r)>;
648 def: ArithLogic16_pat<add, AdduRxRyRz16>;
649 def: ArithLogic16_pat<and, AndRxRxRy16>;
650 def: ArithLogic16_pat<mul, MultRxRyRz16>;
651 def: ArithLogic16_pat<or, OrRxRxRy16>;
652 def: ArithLogic16_pat<sub, SubuRxRyRz16>;
653 def: ArithLogic16_pat<xor, XorRxRxRy16>;
655 // Arithmetic and logical instructions with 2 register operands.
657 class ArithLogicI16_pat<SDNode OpNode, PatFrag imm_type, Instruction I> :
658 Mips16Pat<(OpNode CPU16Regs:$in, imm_type:$imm),
659 (I CPU16Regs:$in, imm_type:$imm)>;
661 def: ArithLogicI16_pat<add, immSExt16, AddiuRxRxImmX16>;
662 def: ArithLogicI16_pat<shl, immZExt5, SllX16>;
663 def: ArithLogicI16_pat<srl, immZExt5, SrlX16>;
664 def: ArithLogicI16_pat<sra, immZExt5, SraX16>;
666 class shift_rotate_reg16_pat<SDNode OpNode, Instruction I> :
667 Mips16Pat<(OpNode CPU16Regs:$r, CPU16Regs:$ra),
668 (I CPU16Regs:$r, CPU16Regs:$ra)>;
670 def: shift_rotate_reg16_pat<shl, SllvRxRy16>;
671 def: shift_rotate_reg16_pat<sra, SravRxRy16>;
672 def: shift_rotate_reg16_pat<srl, SrlvRxRy16>;
674 class LoadM16_pat<PatFrag OpNode, Instruction I> :
675 Mips16Pat<(OpNode addr:$addr), (I addr:$addr)>;
677 def: LoadM16_pat<sextloadi8, LbRxRyOffMemX16>;
678 def: LoadM16_pat<zextloadi8, LbuRxRyOffMemX16>;
679 def: LoadM16_pat<sextloadi16, LhRxRyOffMemX16>;
680 def: LoadM16_pat<zextloadi16, LhuRxRyOffMemX16>;
681 def: LoadM16_pat<load, LwRxRyOffMemX16>;
683 class StoreM16_pat<PatFrag OpNode, Instruction I> :
684 Mips16Pat<(OpNode CPU16Regs:$r, addr:$addr), (I CPU16Regs:$r, addr:$addr)>;
686 def: StoreM16_pat<truncstorei8, SbRxRyOffMemX16>;
687 def: StoreM16_pat<truncstorei16, ShRxRyOffMemX16>;
688 def: StoreM16_pat<store, SwRxRyOffMemX16>;
690 // Unconditional branch
691 class UncondBranch16_pat<SDNode OpNode, Instruction I>:
692 Mips16Pat<(OpNode bb:$imm16), (I bb:$imm16)> {
693 let Predicates = [RelocPIC, InMips16Mode];
696 // Jump and Link (Call)
697 let isCall=1, hasDelaySlot=1 in
699 FRR16_JALRC<0, 0, 0, (outs), (ins CPU16Regs:$rs),
700 "jalr \t$rs", [(MipsJmpLink CPU16Regs:$rs)], IIBranch>;
703 let isReturn=1, isTerminator=1, hasDelaySlot=1, isBarrier=1, hasCtrlDep=1,
704 hasExtraSrcRegAllocReq = 1 in
705 def RetRA16 : MipsPseudo16<(outs), (ins), "", [(MipsRet)]>;
709 // Some branch conditional patterns are not generated by llvm at this time.
710 // Some are for seemingly arbitrary reasons not used: i.e. with signed number
711 // comparison they are used and for unsigned a different pattern is used.
712 // I am pushing upstream from the full mips16 port and it seemed that I needed
713 // these earlier and the mips32 port has these but now I cannot create test
714 // cases that use these patterns. While I sort this all out I will leave these
715 // extra patterns commented out and if I can be sure they are really not used,
716 // I will delete the code. I don't want to check the code in uncommented without
717 // a valid test case. In some cases, the compiler is generating patterns with
718 // setcc instead and earlier I had implemented setcc first so may have masked
719 // the problem. The setcc variants are suboptimal for mips16 so I may wantto
720 // figure out how to enable the brcond patterns or else possibly new
721 // combinations of of brcond and setcc.
727 <(brcond (i32 (seteq CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
728 (BteqzT8CmpX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16)
733 <(brcond (i32 (seteq CPU16Regs:$rx, immZExt16:$imm)), bb:$targ16),
734 (BteqzT8CmpiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$targ16)
738 <(brcond (i32 (seteq CPU16Regs:$rx, 0)), bb:$targ16),
739 (BeqzRxImmX16 CPU16Regs:$rx, bb:$targ16)
743 // bcond-setgt (do we need to have this pair of setlt, setgt??)
746 <(brcond (i32 (setgt CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
747 (BtnezT8SltX16 CPU16Regs:$ry, CPU16Regs:$rx, bb:$imm16)
754 <(brcond (i32 (setge CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
755 (BteqzT8SltX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16)
759 // never called because compiler transforms a >= k to a > (k-1)
761 // <(brcond (i32 (setge CPU16Regs:$rx, immSExt16:$imm)), bb:$imm16),
762 // (BteqzT8SltiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$imm16)
769 <(brcond (i32 (setlt CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
770 (BtnezT8SltX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16)
774 <(brcond (i32 (setlt CPU16Regs:$rx, immSExt16:$imm)), bb:$imm16),
775 (BtnezT8SltiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$imm16)
782 <(brcond (i32 (setle CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
783 (BteqzT8SltX16 CPU16Regs:$ry, CPU16Regs:$rx, bb:$imm16)
790 <(brcond (i32 (setne CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
791 (BtnezT8CmpX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16)
795 <(brcond (i32 (setne CPU16Regs:$rx, immZExt16:$imm)), bb:$targ16),
796 (BtnezT8CmpiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$targ16)
800 <(brcond (i32 (setne CPU16Regs:$rx, 0)), bb:$targ16),
801 (BnezRxImmX16 CPU16Regs:$rx, bb:$targ16)
805 // This needs to be there but I forget which code will generate it
808 <(brcond CPU16Regs:$rx, bb:$targ16),
809 (BnezRxImmX16 CPU16Regs:$rx, bb:$targ16)
818 // <(brcond (i32 (setugt CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
819 // (BtnezT8SltuX16 CPU16Regs:$ry, CPU16Regs:$rx, bb:$imm16)
826 // <(brcond (i32 (setuge CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
827 // (BteqzT8SltuX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16)
835 // <(brcond (i32 (setult CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
836 // (BtnezT8SltuX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16)
839 def: UncondBranch16_pat<br, BimmX16>;
842 def: Mips16Pat<(i32 immSExt16:$in),
843 (AddiuRxRxImmX16 (Move32R16 ZERO), immSExt16:$in)>;
845 def: Mips16Pat<(i32 immZExt16:$in), (LiRxImmX16 immZExt16:$in)>;
851 <(MipsDivRem CPU16Regs:$rx, CPU16Regs:$ry),
852 (DivRxRy16 CPU16Regs:$rx, CPU16Regs:$ry)>;
858 <(MipsDivRemU CPU16Regs:$rx, CPU16Regs:$ry),
859 (DivuRxRy16 CPU16Regs:$rx, CPU16Regs:$ry)>;
862 def: Mips16Pat<(add CPU16Regs:$hi, (MipsLo tglobaladdr:$lo)),
863 (AddiuRxRxImmX16 CPU16Regs:$hi, tglobaladdr:$lo)>;