[DAGCombiner] Eliminate dead stores to stack.
[llvm-complete.git] / lib / Target / Mips / Mips16InstrInfo.td
blobfff9f6ad02fbaf8d8e94f8d4470ab6f91b45022b
1 //===- Mips16InstrInfo.td - Target Description for Mips16  -*- tablegen -*-=//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file describes Mips16 instructions.
11 //===----------------------------------------------------------------------===//
14 // Mips Address
16 def addr16 : ComplexPattern<iPTR, 2, "selectAddr16", [frameindex]>;
17 def addr16sp : ComplexPattern<iPTR, 2, "selectAddr16SP", [frameindex]>;
20 // Address operand
21 def mem16 : Operand<i32> {
22   let PrintMethod = "printMemOperand";
23   let MIOperandInfo = (ops CPU16Regs, simm16);
24   let EncoderMethod = "getMemEncoding";
27 def mem16sp : Operand<i32> {
28   let PrintMethod = "printMemOperand";
29   // This should be CPUSPReg but the MIPS16 subtarget isn't good enough at
30   // keeping the sp-relative load and the other varieties separate at the
31   // moment. This lie fixes the problem sufficiently well to fix the errors
32   // emitted by -verify-machineinstrs and the output ends up correct as long
33   // as we use an external assembler (which is already a requirement for MIPS16
34   // for several other reasons).
35   let MIOperandInfo = (ops CPU16RegsPlusSP, simm16);
36   let EncoderMethod = "getMemEncoding";
39 def mem16_ea : Operand<i32> {
40   let PrintMethod = "printMemOperandEA";
41   let MIOperandInfo = (ops CPU16RegsPlusSP, simm16);
42   let EncoderMethod = "getMemEncoding";
45 def pcrel16 : Operand<i32>;
48 // I-type instruction format
50 // this is only used by bimm. the actual assembly value is a 12 bit signed
51 // number
53 class FI16_ins<bits<5> op, string asmstr, InstrItinClass itin>:
54   FI16<op, (outs), (ins brtarget:$imm16),
55             !strconcat(asmstr, "\t$imm16 # 16 bit inst"), [], itin>;
59 // I8 instruction format
62 class FI816_ins_base<bits<3> _func, string asmstr,
63                      string asmstr2, InstrItinClass itin>:
64   FI816<_func, (outs), (ins simm16:$imm), !strconcat(asmstr, asmstr2),
65         [], itin>;
67 class FI816_ins<bits<3> _func, string asmstr,
68                 InstrItinClass itin>:
69   FI816_ins_base<_func, asmstr, "\t$imm  # 16 bit inst", itin>;
71 class FI816_SP_ins<bits<3> _func, string asmstr,
72                    InstrItinClass itin>:
73   FI816_ins_base<_func, asmstr, "\t$$sp, $imm # 16 bit inst", itin>;
76 // RI instruction format
80 class FRI16_ins_base<bits<5> op, string asmstr, string asmstr2,
81                      InstrItinClass itin>:
82   FRI16<op, (outs CPU16Regs:$rx), (ins simm16:$imm),
83         !strconcat(asmstr, asmstr2), [], itin>;
85 class FRI16_ins<bits<5> op, string asmstr,
86                 InstrItinClass itin>:
87   FRI16_ins_base<op, asmstr, "\t$rx, $imm \t# 16 bit inst", itin>;
89 class FRI16_TCP_ins<bits<5> _op, string asmstr,
90                     InstrItinClass itin>:
91   FRI16<_op, (outs CPU16Regs:$rx), (ins pcrel16:$imm, i32imm:$size),
92             !strconcat(asmstr, "\t$rx, $imm\t# 16 bit inst"), [], itin>;
93             
94 class FRI16R_ins_base<bits<5> op, string asmstr, string asmstr2,
95                      InstrItinClass itin>:
96   FRI16<op, (outs), (ins CPU16Regs:$rx, simm16:$imm),
97         !strconcat(asmstr, asmstr2), [], itin>;
99 class FRI16R_ins<bits<5> op, string asmstr,
100                 InstrItinClass itin>:
101   FRI16R_ins_base<op, asmstr, "\t$rx, $imm \t# 16 bit inst", itin>;
103 class F2RI16_ins<bits<5> _op, string asmstr,
104                      InstrItinClass itin>:
105   FRI16<_op, (outs CPU16Regs:$rx), (ins CPU16Regs:$rx_, simm16:$imm),
106         !strconcat(asmstr, "\t$rx, $imm\t# 16 bit inst"), [], itin> {
107   let Constraints = "$rx_ = $rx";
110 class FRI16_B_ins<bits<5> _op, string asmstr,
111                   InstrItinClass itin>:
112   FRI16<_op, (outs), (ins  CPU16Regs:$rx, brtarget:$imm),
113         !strconcat(asmstr, "\t$rx, $imm  # 16 bit inst"), [], itin>;
115 // Compare a register and immediate and place result in CC
116 // Implicit use of T8
118 // EXT-CCRR Instruction format
120 class FEXT_CCRXI16_ins<string asmstr>:
121   MipsPseudo16<(outs CPU16Regs:$cc), (ins CPU16Regs:$rx, simm16:$imm),
122                !strconcat(asmstr, "\t$rx, $imm\n\tmove\t$cc, $$t8"), []> {
123   let isCodeGenOnly=1;
124   let usesCustomInserter = 1;
127 // JAL and JALX instruction format
129 class FJAL16_ins<bits<1> _X, string asmstr,
130                  InstrItinClass itin>:
131   FJAL16<_X, (outs), (ins uimm26:$imm),
132          !strconcat(asmstr, "\t$imm\n\tnop"),[],
133          itin>  {
134   let isCodeGenOnly=1;
135   let Size=6;
138 class FJALB16_ins<bits<1> _X, string asmstr,
139                  InstrItinClass itin>:
140   FJAL16<_X, (outs), (ins uimm26:$imm),
141          !strconcat(asmstr, "\t$imm\t# branch\n\tnop"),[],
142          itin>  {
143   let isCodeGenOnly=1;
144   let Size=6;
148 // EXT-I instruction format
150 class FEXT_I16_ins<bits<5> eop, string asmstr, InstrItinClass itin> :
151   FEXT_I16<eop, (outs), (ins brtarget:$imm16),
152            !strconcat(asmstr, "\t$imm16"),[], itin>;
155 // EXT-I8 instruction format
158 class FEXT_I816_ins_base<bits<3> _func, string asmstr,
159                          string asmstr2, InstrItinClass itin>:
160   FEXT_I816<_func, (outs), (ins simm16:$imm), !strconcat(asmstr, asmstr2),
161             [], itin>;
163 class FEXT_I816_ins<bits<3> _func, string asmstr,
164                     InstrItinClass itin>:
165   FEXT_I816_ins_base<_func, asmstr, "\t$imm", itin>;
167 class FEXT_I816_SP_ins<bits<3> _func, string asmstr,
168                        InstrItinClass itin>:
169       FEXT_I816_ins_base<_func, asmstr, "\t$$sp, $imm", itin>;
172 // Assembler formats in alphabetical order.
173 // Natural and pseudos are mixed together.
175 // Compare two registers and place result in CC
176 // Implicit use of T8
178 // CC-RR Instruction format
180 class FCCRR16_ins<string asmstr> :
181   MipsPseudo16<(outs CPU16Regs:$cc), (ins CPU16Regs:$rx, CPU16Regs:$ry),
182                !strconcat(asmstr, "\t$rx, $ry\n\tmove\t$cc, $$t8"), []> {
183   let isCodeGenOnly=1;
184   let usesCustomInserter = 1;
188 // EXT-RI instruction format
191 class FEXT_RI16_ins_base<bits<5> _op, string asmstr, string asmstr2,
192                          InstrItinClass itin>:
193   FEXT_RI16<_op, (outs CPU16Regs:$rx), (ins simm16:$imm),
194                   !strconcat(asmstr, asmstr2), [], itin>;
196 class FEXT_RI16_ins<bits<5> _op, string asmstr,
197                     InstrItinClass itin>:
198   FEXT_RI16_ins_base<_op, asmstr, "\t$rx, $imm", itin>;
200 class FEXT_RI16R_ins_base<bits<5> _op, string asmstr, string asmstr2,
201                          InstrItinClass itin>:
202   FEXT_RI16<_op, (outs ), (ins CPU16Regs:$rx, simm16:$imm),
203                   !strconcat(asmstr, asmstr2), [], itin>;
205 class FEXT_RI16R_ins<bits<5> _op, string asmstr,
206                     InstrItinClass itin>:
207   FEXT_RI16R_ins_base<_op, asmstr, "\t$rx, $imm", itin>;
209 class FEXT_RI16_PC_ins<bits<5> _op, string asmstr, InstrItinClass itin>:
210   FEXT_RI16_ins_base<_op, asmstr, "\t$rx, $$pc, $imm", itin>;
212 class FEXT_RI16_B_ins<bits<5> _op, string asmstr,
213                       InstrItinClass itin>:
214   FEXT_RI16<_op, (outs), (ins  CPU16Regs:$rx, brtarget:$imm),
215             !strconcat(asmstr, "\t$rx, $imm"), [], itin>;
217 class FEXT_RI16_TCP_ins<bits<5> _op, string asmstr,
218                         InstrItinClass itin>:
219   FEXT_RI16<_op, (outs CPU16Regs:$rx), (ins pcrel16:$imm, i32imm:$size),
220             !strconcat(asmstr, "\t$rx, $imm"), [], itin>;
222 class FEXT_2RI16_ins<bits<5> _op, string asmstr,
223                      InstrItinClass itin>:
224   FEXT_RI16<_op, (outs CPU16Regs:$rx), (ins CPU16Regs:$rx_, simm16:$imm),
225             !strconcat(asmstr, "\t$rx, $imm"), [], itin> {
226   let Constraints = "$rx_ = $rx";
230 // EXT-RRI instruction format
233 class FEXT_RRI16_mem_ins<bits<5> op, string asmstr, Operand MemOpnd,
234                          InstrItinClass itin>:
235   FEXT_RRI16<op, (outs CPU16Regs:$ry), (ins  MemOpnd:$addr),
236              !strconcat(asmstr, "\t$ry, $addr"), [], itin>;
238 class FEXT_RRI16_mem2_ins<bits<5> op, string asmstr, Operand MemOpnd,
239                           InstrItinClass itin>:
240   FEXT_RRI16<op, (outs ), (ins  CPU16Regs:$ry, MemOpnd:$addr),
241              !strconcat(asmstr, "\t$ry, $addr"), [], itin>;
245 // EXT-RRI-A instruction format
248 class FEXT_RRI_A16_mem_ins<bits<1> op, string asmstr, Operand MemOpnd,
249                            InstrItinClass itin>:
250   FEXT_RRI_A16<op, (outs CPU16Regs:$ry), (ins  MemOpnd:$addr),
251                !strconcat(asmstr, "\t$ry, $addr"), [], itin>;
254 // EXT-SHIFT instruction format
256 class FEXT_SHIFT16_ins<bits<2> _f, string asmstr, InstrItinClass itin>:
257   FEXT_SHIFT16<_f, (outs CPU16Regs:$rx), (ins CPU16Regs:$ry, uimm5:$sa),
258                !strconcat(asmstr, "\t$rx, $ry, $sa"), [], itin>;
261 // EXT-T8I8
263 class FEXT_T8I816_ins<string asmstr, string asmstr2>:
264   MipsPseudo16<(outs),
265                (ins CPU16Regs:$rx, CPU16Regs:$ry, brtarget:$imm),
266                !strconcat(asmstr2, !strconcat("\t$rx, $ry\n\t",
267                !strconcat(asmstr, "\t$imm"))),[]> {
268   let isCodeGenOnly=1;
269   let usesCustomInserter = 1;
273 // EXT-T8I8I
275 class FEXT_T8I8I16_ins<string asmstr, string asmstr2>:
276   MipsPseudo16<(outs),
277                (ins CPU16Regs:$rx, simm16:$imm, brtarget:$targ),
278                !strconcat(asmstr2, !strconcat("\t$rx, $imm\n\t",
279                !strconcat(asmstr, "\t$targ"))), []> {
280   let isCodeGenOnly=1;
281   let usesCustomInserter = 1;
287 // I8_MOVR32 instruction format (used only by the MOVR32 instructio
289 class FI8_MOVR3216_ins<string asmstr, InstrItinClass itin>:
290        FI8_MOVR3216<(outs CPU16Regs:$rz), (ins GPR32:$r32),
291        !strconcat(asmstr,  "\t$rz, $r32"), [], itin>;
294 // I8_MOV32R instruction format (used only by MOV32R instruction)
297 class FI8_MOV32R16_ins<string asmstr, InstrItinClass itin>:
298   FI8_MOV32R16<(outs GPR32:$r32), (ins CPU16Regs:$rz),
299                !strconcat(asmstr,  "\t$r32, $rz"), [], itin>;
302 // This are pseudo formats for multiply
303 // This first one can be changed to non-pseudo now.
305 // MULT
307 class FMULT16_ins<string asmstr, InstrItinClass itin> :
308   MipsPseudo16<(outs), (ins CPU16Regs:$rx, CPU16Regs:$ry),
309                !strconcat(asmstr, "\t$rx, $ry"), []>;
312 // MULT-LO
314 class FMULT16_LO_ins<string asmstr, InstrItinClass itin> :
315   MipsPseudo16<(outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry),
316                !strconcat(asmstr, "\t$rx, $ry\n\tmflo\t$rz"), []> {
317   let isCodeGenOnly=1;
321 // RR-type instruction format
324 class FRR16_ins<bits<5> f, string asmstr, InstrItinClass itin> :
325   FRR16<f, (outs CPU16Regs:$rx), (ins CPU16Regs:$ry),
326         !strconcat(asmstr, "\t$rx, $ry"), [], itin> {
329 class FRRBreakNull16_ins<string asmstr, InstrItinClass itin> :
330   FRRBreak16<(outs), (ins), asmstr, [], itin> {
331   let Code=0;
334 class FRR16R_ins<bits<5> f, string asmstr, InstrItinClass itin> :
335   FRR16<f, (outs), (ins  CPU16Regs:$rx, CPU16Regs:$ry),
336         !strconcat(asmstr, "\t$rx, $ry"), [], itin> {
339 class FRRTR16_ins<string asmstr> :
340   MipsPseudo16<(outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry),
341                !strconcat(asmstr, "\t$rx, $ry\n\tmove\t$rz, $$t8"), []> ;
344 // maybe refactor but need a $zero as a dummy first parameter
346 class FRR16_div_ins<bits<5> f, string asmstr, InstrItinClass itin> :
347   FRR16<f, (outs ), (ins CPU16Regs:$rx, CPU16Regs:$ry),
348         !strconcat(asmstr, "\t$$zero, $rx, $ry"), [], itin> ;
350 class FUnaryRR16_ins<bits<5> f, string asmstr, InstrItinClass itin> :
351   FRR16<f, (outs CPU16Regs:$rx), (ins CPU16Regs:$ry),
352         !strconcat(asmstr, "\t$rx, $ry"), [], itin> ;
355 class FRR16_M_ins<bits<5> f, string asmstr,
356                   InstrItinClass itin> :
357   FRR16<f, (outs CPU16Regs:$rx), (ins),
358         !strconcat(asmstr, "\t$rx"), [], itin>;
360 class FRxRxRy16_ins<bits<5> f, string asmstr,
361                     InstrItinClass itin> :
362   FRR16<f, (outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry),
363             !strconcat(asmstr, "\t$rz, $ry"),
364             [], itin> {
365   let Constraints = "$rx = $rz";
368 let rx=0 in
369 class FRR16_JALRC_RA_only_ins<bits<1> nd_, bits<1> l_,
370                               string asmstr, InstrItinClass itin>:
371   FRR16_JALRC<nd_, l_, 1, (outs), (ins), !strconcat(asmstr, "\t$$ra"),
372               [], itin> ;
375 class FRR16_JALRC_ins<bits<1> nd, bits<1> l, bits<1> ra,
376                       string asmstr, InstrItinClass itin>:
377   FRR16_JALRC<nd, l, ra, (outs), (ins CPU16Regs:$rx),
378               !strconcat(asmstr, "\t$rx"), [], itin> ;
380 class FRR_SF16_ins
381   <bits<5> _funct, bits<3> _subfunc,
382     string asmstr, InstrItinClass itin>:
383   FRR_SF16<_funct, _subfunc, (outs CPU16Regs:$rx), (ins CPU16Regs:$rx_),
384            !strconcat(asmstr, "\t $rx"),
385            [], itin> {
386   let Constraints = "$rx_ = $rx";
387   }
389 // RRR-type instruction format
392 class FRRR16_ins<bits<2> _f, string asmstr,  InstrItinClass itin> :
393   FRRR16<_f, (outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry),
394          !strconcat(asmstr, "\t$rz, $rx, $ry"), [], itin>;
397 // These Sel patterns support the generation of conditional move
398 // pseudo instructions.
400 // The nomenclature uses the components making up the pseudo and may
401 // be a bit counter intuitive when compared with the end result we seek.
402 // For example using a bqez in the example directly below results in the
403 // conditional move being done if the tested register is not zero.
404 // I considered in easier to check by keeping the pseudo consistent with
405 // it's components but it could have been done differently.
407 // The simplest case is when can test and operand directly and do the
408 // conditional move based on a simple mips16 conditional
409 //  branch instruction.
410 // for example:
411 // if $op == beqz or bnez:
413 // $op1 $rt, .+4
414 // move $rd, $rs
416 // if $op == beqz, then if $rt != 0, then the conditional assignment
417 // $rd = $rs is done.
419 // if $op == bnez, then if $rt == 0, then the conditional assignment
420 // $rd = $rs is done.
422 // So this pseudo class only has one operand, i.e. op
424 class Sel<string op>:
425   MipsPseudo16<(outs CPU16Regs:$rd_), (ins CPU16Regs:$rd, CPU16Regs:$rs,
426                CPU16Regs:$rt),
427                !strconcat(op, "\t$rt, .+4\n\t\n\tmove $rd, $rs"), []> {
428   //let isCodeGenOnly=1;
429   let Constraints = "$rd = $rd_";
430   let usesCustomInserter = 1;
434 // The next two instruction classes allow for an operand which tests
435 // two operands and returns a value in register T8 and
436 //then does a conditional branch based on the value of T8
439 // op2 can be cmpi or slti/sltiu
440 // op1 can bteqz or btnez
441 // the operands for op2 are a register and a signed constant
443 // $op2 $t, $imm  ;test register t and branch conditionally
444 // $op1 .+4       ;op1 is a conditional branch
445 // move $rd, $rs
448 class SeliT<string op1, string op2>:
449   MipsPseudo16<(outs CPU16Regs:$rd_), (ins CPU16Regs:$rd, CPU16Regs:$rs,
450                                        CPU16Regs:$rl, simm16:$imm),
451                !strconcat(op2,
452                !strconcat("\t$rl, $imm\n\t",
453                !strconcat(op1, "\t.+4\n\tmove $rd, $rs"))), []> {
454   let isCodeGenOnly=1;
455   let Constraints = "$rd = $rd_";
456   let usesCustomInserter = 1;
460 // op2 can be cmp or slt/sltu
461 // op1 can be bteqz or btnez
462 // the operands for op2 are two registers
463 // op1 is a conditional branch
466 // $op2 $rl, $rr  ;test registers rl,rr
467 // $op1 .+4       ;op2 is a conditional branch
468 // move $rd, $rs
471 class SelT<string op1, string op2>:
472   MipsPseudo16<(outs CPU16Regs:$rd_),
473                (ins CPU16Regs:$rd, CPU16Regs:$rs,
474                 CPU16Regs:$rl, CPU16Regs:$rr),
475                !strconcat(op2,
476                !strconcat("\t$rl, $rr\n\t",
477                !strconcat(op1, "\t.+4\n\tmove $rd, $rs"))), []> {
478   let isCodeGenOnly=1;
479   let Constraints = "$rd = $rd_";
480   let usesCustomInserter = 1;
484 // 32 bit constant
486 def Constant32:
487   MipsPseudo16<(outs), (ins simm32:$imm), "\t.word $imm", []>;
489 def LwConstant32:
490   MipsPseudo16<(outs CPU16Regs:$rx), (ins simm32:$imm, simm32:$constid),
491     "lw\t$rx, 1f\n\tb\t2f\n\t.align\t2\n1: \t.word\t$imm\n2:", []>;
495 // Some general instruction class info
499 class ArithLogic16Defs<bit isCom=0> {
500   bits<5> shamt = 0;
501   bit isCommutable = isCom;
502   bit isReMaterializable = 1;
503   bit hasSideEffects = 0;
506 class branch16 {
507   bit isBranch = 1;
508   bit isTerminator = 1;
509   bit isBarrier = 1;
512 class cbranch16 {
513   bit isBranch = 1;
514   bit isTerminator = 1;
517 class MayLoad {
518   bit mayLoad = 1;
521 class MayStore {
522   bit mayStore = 1;
527 // Format: ADDIU rx, immediate MIPS16e
528 // Purpose: Add Immediate Unsigned Word (2-Operand, Extended)
529 // To add a constant to a 32-bit integer.
531 def AddiuRxImmX16: FEXT_RI16_ins<0b01001, "addiu", IIM16Alu>;
533 def AddiuRxRxImm16: F2RI16_ins<0b01001, "addiu", IIM16Alu>,
534   ArithLogic16Defs<0> {
535   let AddedComplexity = 5;
537 def AddiuRxRxImmX16: FEXT_2RI16_ins<0b01001, "addiu", IIM16Alu>,
538   ArithLogic16Defs<0> {
539   let isCodeGenOnly = 1;
542 def AddiuRxRyOffMemX16:
543   FEXT_RRI_A16_mem_ins<0, "addiu", mem16_ea, IIM16Alu>;
547 // Format: ADDIU rx, pc, immediate MIPS16e
548 // Purpose: Add Immediate Unsigned Word (3-Operand, PC-Relative, Extended)
549 // To add a constant to the program counter.
551 def AddiuRxPcImmX16: FEXT_RI16_PC_ins<0b00001, "addiu", IIM16Alu>;
554 // Format: ADDIU sp, immediate MIPS16e
555 // Purpose: Add Immediate Unsigned Word (2-Operand, SP-Relative, Extended)
556 // To add a constant to the stack pointer.
558 def AddiuSpImm16
559   : FI816_SP_ins<0b011, "addiu", IIM16Alu> {
560   let Defs = [SP];
561   let Uses = [SP];
562   let AddedComplexity = 5;
565 def AddiuSpImmX16
566   : FEXT_I816_SP_ins<0b011, "addiu", IIM16Alu> {
567   let Defs = [SP];
568   let Uses = [SP];
572 // Format: ADDU rz, rx, ry MIPS16e
573 // Purpose: Add Unsigned Word (3-Operand)
574 // To add 32-bit integers.
577 def AdduRxRyRz16: FRRR16_ins<01, "addu", IIM16Alu>, ArithLogic16Defs<1>;
580 // Format: AND rx, ry MIPS16e
581 // Purpose: AND
582 // To do a bitwise logical AND.
584 def AndRxRxRy16: FRxRxRy16_ins<0b01100, "and", IIM16Alu>, ArithLogic16Defs<1>;
588 // Format: BEQZ rx, offset MIPS16e
589 // Purpose: Branch on Equal to Zero
590 // To test a GPR then do a PC-relative conditional branch.
592 def BeqzRxImm16: FRI16_B_ins<0b00100, "beqz", IIM16Alu>, cbranch16;
596 // Format: BEQZ rx, offset MIPS16e
597 // Purpose: Branch on Equal to Zero (Extended)
598 // To test a GPR then do a PC-relative conditional branch.
600 def BeqzRxImmX16: FEXT_RI16_B_ins<0b00100, "beqz", IIM16Alu>, cbranch16;
603 // Format: B offset MIPS16e
604 // Purpose: Unconditional Branch (Extended)
605 // To do an unconditional PC-relative branch.
608 def Bimm16: FI16_ins<0b00010, "b", IIM16Alu>, branch16;
610 // Format: B offset MIPS16e
611 // Purpose: Unconditional Branch
612 // To do an unconditional PC-relative branch.
614 def BimmX16: FEXT_I16_ins<0b00010, "b", IIM16Alu>, branch16;
617 // Format: BNEZ rx, offset MIPS16e
618 // Purpose: Branch on Not Equal to Zero
619 // To test a GPR then do a PC-relative conditional branch.
621 def BnezRxImm16: FRI16_B_ins<0b00101, "bnez", IIM16Alu>, cbranch16;
624 // Format: BNEZ rx, offset MIPS16e
625 // Purpose: Branch on Not Equal to Zero (Extended)
626 // To test a GPR then do a PC-relative conditional branch.
628 def BnezRxImmX16: FEXT_RI16_B_ins<0b00101, "bnez", IIM16Alu>, cbranch16;
632 //Format: BREAK immediate
633 // Purpose: Breakpoint
634 // To cause a Breakpoint exception.
636 def Break16: FRRBreakNull16_ins<"break 0", IIM16Alu>;
638 // Format: BTEQZ offset MIPS16e
639 // Purpose: Branch on T Equal to Zero (Extended)
640 // To test special register T then do a PC-relative conditional branch.
642 def Bteqz16: FI816_ins<0b000, "bteqz", IIM16Alu>, cbranch16 {
643   let Uses = [T8];
646 def BteqzX16: FEXT_I816_ins<0b000, "bteqz", IIM16Alu>, cbranch16 {
647   let Uses = [T8];
650 def BteqzT8CmpX16: FEXT_T8I816_ins<"bteqz", "cmp">, cbranch16;
652 def BteqzT8CmpiX16: FEXT_T8I8I16_ins<"bteqz", "cmpi">,
653   cbranch16;
655 def BteqzT8SltX16: FEXT_T8I816_ins<"bteqz", "slt">, cbranch16;
657 def BteqzT8SltuX16: FEXT_T8I816_ins<"bteqz", "sltu">, cbranch16;
659 def BteqzT8SltiX16: FEXT_T8I8I16_ins<"bteqz", "slti">, cbranch16;
661 def BteqzT8SltiuX16: FEXT_T8I8I16_ins<"bteqz", "sltiu">,
662   cbranch16;
665 // Format: BTNEZ offset MIPS16e
666 // Purpose: Branch on T Not Equal to Zero (Extended)
667 // To test special register T then do a PC-relative conditional branch.
670 def Btnez16: FI816_ins<0b001, "btnez", IIM16Alu>, cbranch16 {
671   let Uses = [T8];
674 def BtnezX16: FEXT_I816_ins<0b001, "btnez", IIM16Alu> ,cbranch16 {
675   let Uses = [T8];
678 def BtnezT8CmpX16: FEXT_T8I816_ins<"btnez", "cmp">, cbranch16;
680 def BtnezT8CmpiX16: FEXT_T8I8I16_ins<"btnez", "cmpi">, cbranch16;
682 def BtnezT8SltX16: FEXT_T8I816_ins<"btnez", "slt">, cbranch16;
684 def BtnezT8SltuX16: FEXT_T8I816_ins<"btnez", "sltu">, cbranch16;
686 def BtnezT8SltiX16: FEXT_T8I8I16_ins<"btnez", "slti">, cbranch16;
688 def BtnezT8SltiuX16: FEXT_T8I8I16_ins<"btnez", "sltiu">,
689   cbranch16;
692 // Format: CMP rx, ry MIPS16e
693 // Purpose: Compare
694 // To compare the contents of two GPRs.
696 def CmpRxRy16: FRR16R_ins<0b01010, "cmp", IIM16Alu> {
697   let Defs = [T8];
701 // Format: CMPI rx, immediate MIPS16e
702 // Purpose: Compare Immediate
703 // To compare a constant with the contents of a GPR.
705 def CmpiRxImm16: FRI16R_ins<0b01110, "cmpi", IIM16Alu> {
706   let Defs = [T8];
710 // Format: CMPI rx, immediate MIPS16e
711 // Purpose: Compare Immediate (Extended)
712 // To compare a constant with the contents of a GPR.
714 def CmpiRxImmX16: FEXT_RI16R_ins<0b01110, "cmpi", IIM16Alu> {
715   let Defs = [T8];
720 // Format: DIV rx, ry MIPS16e
721 // Purpose: Divide Word
722 // To divide 32-bit signed integers.
724 def DivRxRy16: FRR16_div_ins<0b11010, "div", IIM16Alu> {
725   let Defs = [HI0, LO0];
729 // Format: DIVU rx, ry MIPS16e
730 // Purpose: Divide Unsigned Word
731 // To divide 32-bit unsigned integers.
733 def DivuRxRy16: FRR16_div_ins<0b11011, "divu", IIM16Alu> {
734   let Defs = [HI0, LO0];
737 // Format: JAL target MIPS16e
738 // Purpose: Jump and Link
739 // To execute a procedure call within the current 256 MB-aligned
740 // region and preserve the current ISA.
743 def Jal16 : FJAL16_ins<0b0, "jal", IIM16Alu> {
744   let hasDelaySlot = 0;  // not true, but we add the nop for now
745   let isCall=1;
746   let Defs = [RA];
749 def JalB16 : FJALB16_ins<0b0, "jal", IIM16Alu>, branch16 {
750   let hasDelaySlot = 0;  // not true, but we add the nop for now
751   let isBranch=1;
752   let Defs = [RA];
756 // Format: JR ra MIPS16e
757 // Purpose: Jump Register Through Register ra
758 // To execute a branch to the instruction address in the return
759 // address register.
762 def JrRa16: FRR16_JALRC_RA_only_ins<0, 0, "jr", IIM16Alu> {
763   let isBranch = 1;
764   let isIndirectBranch = 1;
765   let hasDelaySlot = 1;
766   let isTerminator=1;
767   let isBarrier=1;
768   let isReturn=1;
771 def JrcRa16: FRR16_JALRC_RA_only_ins<1, 1, "jrc", IIM16Alu> {
772   let isBranch = 1;
773   let isIndirectBranch = 1;
774   let isTerminator=1;
775   let isBarrier=1;
776   let isReturn=1;
779 def JrcRx16: FRR16_JALRC_ins<1, 1, 0, "jrc", IIM16Alu> {
780   let isBranch = 1;
781   let isIndirectBranch = 1;
782   let isTerminator=1;
783   let isBarrier=1;
786 // Format: LB ry, offset(rx) MIPS16e
787 // Purpose: Load Byte (Extended)
788 // To load a byte from memory as a signed value.
790 def LbRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10011, "lb", mem16, II_LB>, MayLoad{
791   let isCodeGenOnly = 1;
795 // Format: LBU ry, offset(rx) MIPS16e
796 // Purpose: Load Byte Unsigned (Extended)
797 // To load a byte from memory as a unsigned value.
799 def LbuRxRyOffMemX16:
800   FEXT_RRI16_mem_ins<0b10100, "lbu", mem16, II_LBU>, MayLoad {
801   let isCodeGenOnly = 1;
805 // Format: LH ry, offset(rx) MIPS16e
806 // Purpose: Load Halfword signed (Extended)
807 // To load a halfword from memory as a signed value.
809 def LhRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10100, "lh", mem16, II_LH>, MayLoad{
810   let isCodeGenOnly = 1;
814 // Format: LHU ry, offset(rx) MIPS16e
815 // Purpose: Load Halfword unsigned (Extended)
816 // To load a halfword from memory as an unsigned value.
818 def LhuRxRyOffMemX16:
819   FEXT_RRI16_mem_ins<0b10100, "lhu", mem16, II_LHU>, MayLoad {
820   let isCodeGenOnly = 1;
824 // Format: LI rx, immediate MIPS16e
825 // Purpose: Load Immediate
826 // To load a constant into a GPR.
828 def LiRxImm16: FRI16_ins<0b01101, "li", IIM16Alu>;
831 // Format: LI rx, immediate MIPS16e
832 // Purpose: Load Immediate (Extended)
833 // To load a constant into a GPR.
835 def LiRxImmX16: FEXT_RI16_ins<0b01101, "li", IIM16Alu>;
837 def LiRxImmAlignX16: FEXT_RI16_ins<0b01101, ".align 2\n\tli", IIM16Alu> {
838   let isCodeGenOnly = 1;
842 // Format: LW ry, offset(rx) MIPS16e
843 // Purpose: Load Word (Extended)
844 // To load a word from memory as a signed value.
846 def LwRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10011, "lw", mem16, II_LW>, MayLoad{
847   let isCodeGenOnly = 1;
850 // Format: LW rx, offset(sp) MIPS16e
851 // Purpose: Load Word (SP-Relative, Extended)
852 // To load an SP-relative word from memory as a signed value.
854 def LwRxSpImmX16: FEXT_RRI16_mem_ins<0b10010, "lw", mem16sp, II_LW>, MayLoad;
856 def LwRxPcTcp16: FRI16_TCP_ins<0b10110, "lw", II_LW>, MayLoad;
858 def LwRxPcTcpX16: FEXT_RI16_TCP_ins<0b10110, "lw", II_LW>, MayLoad;
860 // Format: MOVE r32, rz MIPS16e
861 // Purpose: Move
862 // To move the contents of a GPR to a GPR.
864 def Move32R16: FI8_MOV32R16_ins<"move", IIM16Alu>;
867 // Format: MOVE ry, r32 MIPS16e
868 //Purpose: Move
869 // To move the contents of a GPR to a GPR.
871 def MoveR3216: FI8_MOVR3216_ins<"move", IIM16Alu> {
872   let isMoveReg = 1;
876 // Format: MFHI rx MIPS16e
877 // Purpose: Move From HI Register
878 // To copy the special purpose HI register to a GPR.
880 def Mfhi16: FRR16_M_ins<0b10000, "mfhi", IIM16Alu> {
881   let Uses = [HI0];
882   let hasSideEffects = 0;
883   let isMoveReg = 1;
887 // Format: MFLO rx MIPS16e
888 // Purpose: Move From LO Register
889 // To copy the special purpose LO register to a GPR.
891 def Mflo16: FRR16_M_ins<0b10010, "mflo", IIM16Alu> {
892   let Uses = [LO0];
893   let hasSideEffects = 0;
894   let isMoveReg = 0;
898 // Pseudo Instruction for mult
900 def MultRxRy16:  FMULT16_ins<"mult",  IIM16Alu> {
901   let isCommutable = 1;
902   let hasSideEffects = 0;
903   let Defs = [HI0, LO0];
906 def MultuRxRy16: FMULT16_ins<"multu", IIM16Alu> {
907   let isCommutable = 1;
908   let hasSideEffects = 0;
909   let Defs = [HI0, LO0];
913 // Format: MULT rx, ry MIPS16e
914 // Purpose: Multiply Word
915 // To multiply 32-bit signed integers.
917 def MultRxRyRz16: FMULT16_LO_ins<"mult", IIM16Alu> {
918   let isCommutable = 1;
919   let hasSideEffects = 0;
920   let Defs = [HI0, LO0];
924 // Format: MULTU rx, ry MIPS16e
925 // Purpose: Multiply Unsigned Word
926 // To multiply 32-bit unsigned integers.
928 def MultuRxRyRz16: FMULT16_LO_ins<"multu", IIM16Alu> {
929   let isCommutable = 1;
930   let hasSideEffects = 0;
931   let Defs = [HI0, LO0];
935 // Format: NEG rx, ry MIPS16e
936 // Purpose: Negate
937 // To negate an integer value.
939 def NegRxRy16: FUnaryRR16_ins<0b11101, "neg", IIM16Alu>;
942 // Format: NOT rx, ry MIPS16e
943 // Purpose: Not
944 // To complement an integer value
946 def NotRxRy16: FUnaryRR16_ins<0b01111, "not", IIM16Alu>;
949 // Format: OR rx, ry MIPS16e
950 // Purpose: Or
951 // To do a bitwise logical OR.
953 def OrRxRxRy16: FRxRxRy16_ins<0b01101, "or", IIM16Alu>, ArithLogic16Defs<1>;
956 // Format: RESTORE {ra,}{s0/s1/s0-1,}{framesize}
957 // (All args are optional) MIPS16e
958 // Purpose: Restore Registers and Deallocate Stack Frame
959 // To deallocate a stack frame before exit from a subroutine,
960 // restoring return address and static registers, and adjusting
961 // stack
964 def Restore16:
965   FI8_SVRS16<0b1, (outs), (ins variable_ops),
966              "", [], II_RESTORE >, MayLoad {
967   let isCodeGenOnly = 1;
968   let Defs = [SP];
969   let Uses = [SP];
973 def RestoreX16:
974   FI8_SVRS16<0b1, (outs), (ins variable_ops),
975              "", [], II_RESTORE >, MayLoad {
976   let isCodeGenOnly = 1;
977   let Defs = [SP];
978   let Uses = [SP];
982 // Format: SAVE {ra,}{s0/s1/s0-1,}{framesize} (All arguments are optional)
983 // MIPS16e
984 // Purpose: Save Registers and Set Up Stack Frame
985 // To set up a stack frame on entry to a subroutine,
986 // saving return address and static registers, and adjusting stack
988 def Save16: 
989   FI8_SVRS16<0b1, (outs), (ins variable_ops),
990              "", [], II_SAVE >, MayStore {
991   let isCodeGenOnly = 1;
992   let Uses = [SP];
993   let Defs = [SP];
996 def SaveX16:
997   FI8_SVRS16<0b1, (outs), (ins variable_ops),
998              "", [], II_SAVE >, MayStore {
999   let isCodeGenOnly = 1;
1000   let Uses = [SP];
1001   let Defs = [SP];
1004 // Format: SB ry, offset(rx) MIPS16e
1005 // Purpose: Store Byte (Extended)
1006 // To store a byte to memory.
1008 def SbRxRyOffMemX16:
1009   FEXT_RRI16_mem2_ins<0b11000, "sb", mem16, II_SB>, MayStore;
1012 // Format: SEB rx MIPS16e
1013 // Purpose: Sign-Extend Byte
1014 // Sign-extend least significant byte in register rx.
1016 def SebRx16
1017   : FRR_SF16_ins<0b10001, 0b100, "seb", IIM16Alu>;
1020 // Format: SEH rx MIPS16e
1021 // Purpose: Sign-Extend Halfword
1022 // Sign-extend least significant word in register rx.
1024 def SehRx16
1025   : FRR_SF16_ins<0b10001, 0b101, "seh", IIM16Alu>;
1028 // The Sel(T) instructions are pseudos
1029 // T means that they use T8 implicitly.
1032 // Format: SelBeqZ rd, rs, rt
1033 // Purpose: if rt==0, do nothing
1034 //          else rs = rt
1036 def SelBeqZ: Sel<"beqz">;
1039 // Format:  SelTBteqZCmp rd, rs, rl, rr
1040 // Purpose: b = Cmp rl, rr.
1041 //          If b==0 then do nothing.
1042 //          if b!=0 then rd = rs
1044 def SelTBteqZCmp: SelT<"bteqz", "cmp">;
1047 // Format:  SelTBteqZCmpi rd, rs, rl, rr
1048 // Purpose: b = Cmpi rl, imm.
1049 //          If b==0 then do nothing.
1050 //          if b!=0 then rd = rs
1052 def SelTBteqZCmpi: SeliT<"bteqz", "cmpi">;
1055 // Format:  SelTBteqZSlt rd, rs, rl, rr
1056 // Purpose: b = Slt rl, rr.
1057 //          If b==0 then do nothing.
1058 //          if b!=0 then rd = rs
1060 def SelTBteqZSlt: SelT<"bteqz", "slt">;
1063 // Format:  SelTBteqZSlti rd, rs, rl, rr
1064 // Purpose: b = Slti rl, imm.
1065 //          If b==0 then do nothing.
1066 //          if b!=0 then rd = rs
1068 def SelTBteqZSlti: SeliT<"bteqz", "slti">;
1071 // Format:  SelTBteqZSltu rd, rs, rl, rr
1072 // Purpose: b = Sltu rl, rr.
1073 //          If b==0 then do nothing.
1074 //          if b!=0 then rd = rs
1076 def SelTBteqZSltu: SelT<"bteqz", "sltu">;
1079 // Format:  SelTBteqZSltiu rd, rs, rl, rr
1080 // Purpose: b = Sltiu rl, imm.
1081 //          If b==0 then do nothing.
1082 //          if b!=0 then rd = rs
1084 def SelTBteqZSltiu: SeliT<"bteqz", "sltiu">;
1087 // Format: SelBnez rd, rs, rt
1088 // Purpose: if rt!=0, do nothing
1089 //          else rs = rt
1091 def SelBneZ: Sel<"bnez">;
1094 // Format:  SelTBtneZCmp rd, rs, rl, rr
1095 // Purpose: b = Cmp rl, rr.
1096 //          If b!=0 then do nothing.
1097 //          if b0=0 then rd = rs
1099 def SelTBtneZCmp: SelT<"btnez", "cmp">;
1102 // Format:  SelTBtnezCmpi rd, rs, rl, rr
1103 // Purpose: b = Cmpi rl, imm.
1104 //          If b!=0 then do nothing.
1105 //          if b==0 then rd = rs
1107 def SelTBtneZCmpi: SeliT<"btnez", "cmpi">;
1110 // Format:  SelTBtneZSlt rd, rs, rl, rr
1111 // Purpose: b = Slt rl, rr.
1112 //          If b!=0 then do nothing.
1113 //          if b==0 then rd = rs
1115 def SelTBtneZSlt: SelT<"btnez", "slt">;
1118 // Format:  SelTBtneZSlti rd, rs, rl, rr
1119 // Purpose: b = Slti rl, imm.
1120 //          If b!=0 then do nothing.
1121 //          if b==0 then rd = rs
1123 def SelTBtneZSlti: SeliT<"btnez", "slti">;
1126 // Format:  SelTBtneZSltu rd, rs, rl, rr
1127 // Purpose: b = Sltu rl, rr.
1128 //          If b!=0 then do nothing.
1129 //          if b==0 then rd = rs
1131 def SelTBtneZSltu: SelT<"btnez", "sltu">;
1134 // Format:  SelTBtneZSltiu rd, rs, rl, rr
1135 // Purpose: b = Slti rl, imm.
1136 //          If b!=0 then do nothing.
1137 //          if b==0 then rd = rs
1139 def SelTBtneZSltiu: SeliT<"btnez", "sltiu">;
1142 // Format: SH ry, offset(rx) MIPS16e
1143 // Purpose: Store Halfword (Extended)
1144 // To store a halfword to memory.
1146 def ShRxRyOffMemX16:
1147   FEXT_RRI16_mem2_ins<0b11001, "sh", mem16, II_SH>, MayStore;
1150 // Format: SLL rx, ry, sa MIPS16e
1151 // Purpose: Shift Word Left Logical (Extended)
1152 // To execute a left-shift of a word by a fixed number of bits-0 to 31 bits.
1154 def SllX16: FEXT_SHIFT16_ins<0b00, "sll", IIM16Alu>;
1157 // Format: SLLV ry, rx MIPS16e
1158 // Purpose: Shift Word Left Logical Variable
1159 // To execute a left-shift of a word by a variable number of bits.
1161 def SllvRxRy16 : FRxRxRy16_ins<0b00100, "sllv", IIM16Alu>;
1163 // Format: SLTI rx, immediate MIPS16e
1164 // Purpose: Set on Less Than Immediate
1165 // To record the result of a less-than comparison with a constant.
1168 def SltiRxImm16: FRI16R_ins<0b01010, "slti", IIM16Alu> {
1169   let Defs = [T8];
1173 // Format: SLTI rx, immediate MIPS16e
1174 // Purpose: Set on Less Than Immediate (Extended)
1175 // To record the result of a less-than comparison with a constant.
1178 def SltiRxImmX16: FEXT_RI16R_ins<0b01010, "slti", IIM16Alu> {
1179   let Defs = [T8];
1182 def SltiCCRxImmX16: FEXT_CCRXI16_ins<"slti">;
1184 // Format: SLTIU rx, immediate MIPS16e
1185 // Purpose: Set on Less Than Immediate Unsigned
1186 // To record the result of a less-than comparison with a constant.
1189 def SltiuRxImm16: FRI16R_ins<0b01011, "sltiu", IIM16Alu> {
1190   let Defs = [T8];
1194 // Format: SLTI rx, immediate MIPS16e
1195 // Purpose: Set on Less Than Immediate Unsigned (Extended)
1196 // To record the result of a less-than comparison with a constant.
1199 def SltiuRxImmX16: FEXT_RI16R_ins<0b01011, "sltiu", IIM16Alu> {
1200   let Defs = [T8];
1203 // Format: SLTIU rx, immediate MIPS16e
1204 // Purpose: Set on Less Than Immediate Unsigned (Extended)
1205 // To record the result of a less-than comparison with a constant.
1207 def SltiuCCRxImmX16: FEXT_CCRXI16_ins<"sltiu">;
1210 // Format: SLT rx, ry MIPS16e
1211 // Purpose: Set on Less Than
1212 // To record the result of a less-than comparison.
1214 def SltRxRy16: FRR16R_ins<0b00010, "slt", IIM16Alu>{
1215   let Defs = [T8];
1218 def SltCCRxRy16: FCCRR16_ins<"slt">;
1220 // Format: SLTU rx, ry MIPS16e
1221 // Purpose: Set on Less Than Unsigned
1222 // To record the result of an unsigned less-than comparison.
1224 def SltuRxRy16: FRR16R_ins<0b00011, "sltu", IIM16Alu>{
1225   let Defs = [T8];
1228 def SltuRxRyRz16: FRRTR16_ins<"sltu"> {
1229   let isCodeGenOnly=1;
1230   let Defs = [T8];
1234 def SltuCCRxRy16: FCCRR16_ins<"sltu">;
1236 // Format: SRAV ry, rx MIPS16e
1237 // Purpose: Shift Word Right Arithmetic Variable
1238 // To execute an arithmetic right-shift of a word by a variable
1239 // number of bits.
1241 def SravRxRy16: FRxRxRy16_ins<0b00111, "srav", IIM16Alu>;
1245 // Format: SRA rx, ry, sa MIPS16e
1246 // Purpose: Shift Word Right Arithmetic (Extended)
1247 // To execute an arithmetic right-shift of a word by a fixed
1248 // number of bits-1 to 8 bits.
1250 def SraX16: FEXT_SHIFT16_ins<0b11, "sra", IIM16Alu>;
1254 // Format: SRLV ry, rx MIPS16e
1255 // Purpose: Shift Word Right Logical Variable
1256 // To execute a logical right-shift of a word by a variable
1257 // number of bits.
1259 def SrlvRxRy16: FRxRxRy16_ins<0b00110, "srlv", IIM16Alu>;
1263 // Format: SRL rx, ry, sa MIPS16e
1264 // Purpose: Shift Word Right Logical (Extended)
1265 // To execute a logical right-shift of a word by a fixed
1266 // number of bits-1 to 31 bits.
1268 def SrlX16: FEXT_SHIFT16_ins<0b10, "srl", IIM16Alu>;
1271 // Format: SUBU rz, rx, ry MIPS16e
1272 // Purpose: Subtract Unsigned Word
1273 // To subtract 32-bit integers
1275 def SubuRxRyRz16: FRRR16_ins<0b11, "subu", IIM16Alu>, ArithLogic16Defs<0>;
1278 // Format: SW ry, offset(rx) MIPS16e
1279 // Purpose: Store Word (Extended)
1280 // To store a word to memory.
1282 def SwRxRyOffMemX16: FEXT_RRI16_mem2_ins<0b11011, "sw", mem16, II_SW>, MayStore;
1285 // Format: SW rx, offset(sp) MIPS16e
1286 // Purpose: Store Word rx (SP-Relative)
1287 // To store an SP-relative word to memory.
1289 def SwRxSpImmX16: FEXT_RRI16_mem2_ins<0b11010, "sw", mem16sp, II_SW>, MayStore;
1293 // Format: XOR rx, ry MIPS16e
1294 // Purpose: Xor
1295 // To do a bitwise logical XOR.
1297 def XorRxRxRy16: FRxRxRy16_ins<0b01110, "xor", IIM16Alu>, ArithLogic16Defs<1>;
1299 class Mips16Pat<dag pattern, dag result> : Pat<pattern, result> {
1300   let Predicates = [InMips16Mode];
1303 // Unary Arith/Logic
1305 class ArithLogicU_pat<PatFrag OpNode, Instruction I> :
1306   Mips16Pat<(OpNode CPU16Regs:$r),
1307             (I CPU16Regs:$r)>;
1309 def: ArithLogicU_pat<not, NotRxRy16>;
1310 def: ArithLogicU_pat<ineg, NegRxRy16>;
1312 class ArithLogic16_pat<SDNode OpNode, Instruction I> :
1313   Mips16Pat<(OpNode CPU16Regs:$l, CPU16Regs:$r),
1314             (I CPU16Regs:$l, CPU16Regs:$r)>;
1316 def: ArithLogic16_pat<add, AdduRxRyRz16>;
1317 def: ArithLogic16_pat<and, AndRxRxRy16>;
1318 def: ArithLogic16_pat<mul, MultRxRyRz16>;
1319 def: ArithLogic16_pat<or, OrRxRxRy16>;
1320 def: ArithLogic16_pat<sub, SubuRxRyRz16>;
1321 def: ArithLogic16_pat<xor, XorRxRxRy16>;
1323 // Arithmetic and logical instructions with 2 register operands.
1325 class ArithLogicI16_pat<SDNode OpNode, PatFrag imm_type, Instruction I> :
1326   Mips16Pat<(OpNode CPU16Regs:$in, imm_type:$imm),
1327             (I CPU16Regs:$in, imm_type:$imm)>;
1329 def: ArithLogicI16_pat<add, immSExt8, AddiuRxRxImm16>;
1330 def: ArithLogicI16_pat<add, immSExt16, AddiuRxRxImmX16>;
1331 def: ArithLogicI16_pat<shl, immZExt5, SllX16>;
1332 def: ArithLogicI16_pat<srl, immZExt5, SrlX16>;
1333 def: ArithLogicI16_pat<sra, immZExt5, SraX16>;
1335 class shift_rotate_reg16_pat<SDNode OpNode, Instruction I> :
1336   Mips16Pat<(OpNode CPU16Regs:$r, CPU16Regs:$ra),
1337             (I CPU16Regs:$r, CPU16Regs:$ra)>;
1339 def: shift_rotate_reg16_pat<shl, SllvRxRy16>;
1340 def: shift_rotate_reg16_pat<sra, SravRxRy16>;
1341 def: shift_rotate_reg16_pat<srl, SrlvRxRy16>;
1343 class LoadM16_pat<PatFrag OpNode, Instruction I, ComplexPattern Addr> :
1344   Mips16Pat<(OpNode Addr:$addr), (I Addr:$addr)>;
1346 def: LoadM16_pat<sextloadi8, LbRxRyOffMemX16, addr16>;
1347 def: LoadM16_pat<zextloadi8, LbuRxRyOffMemX16, addr16>;
1348 def: LoadM16_pat<sextloadi16, LhRxRyOffMemX16, addr16>;
1349 def: LoadM16_pat<zextloadi16, LhuRxRyOffMemX16, addr16>;
1350 def: LoadM16_pat<load, LwRxSpImmX16, addr16sp>;
1352 class StoreM16_pat<PatFrag OpNode, Instruction I, ComplexPattern Addr> :
1353   Mips16Pat<(OpNode CPU16Regs:$r, Addr:$addr), (I CPU16Regs:$r, Addr:$addr)>;
1355 def: StoreM16_pat<truncstorei8, SbRxRyOffMemX16, addr16>;
1356 def: StoreM16_pat<truncstorei16, ShRxRyOffMemX16, addr16>;
1357 def: StoreM16_pat<store, SwRxSpImmX16, addr16sp>;
1359 // Unconditional branch
1360 class UncondBranch16_pat<SDNode OpNode, Instruction I>:
1361   Mips16Pat<(OpNode bb:$imm16), (I bb:$imm16)> {
1362     let Predicates = [InMips16Mode];
1363   }
1365 def : Mips16Pat<(MipsJmpLink (i32 tglobaladdr:$dst)),
1366                 (Jal16 tglobaladdr:$dst)>;
1368 def : Mips16Pat<(MipsJmpLink (i32 texternalsym:$dst)),
1369                 (Jal16 texternalsym:$dst)>;
1371 // Indirect branch
1372 def: Mips16Pat<(brind CPU16Regs:$rs), (JrcRx16 CPU16Regs:$rs)> {
1373   // Ensure that the addition of MIPS32r6/MIPS64r6 support does not change
1374   // MIPS16's behaviour.
1375   let AddedComplexity = 1;
1378 // Jump and Link (Call)
1379 let isCall=1, hasDelaySlot=0 in
1380 def JumpLinkReg16:
1381   FRR16_JALRC<0, 0, 0, (outs), (ins CPU16Regs:$rs),
1382               "jalrc\t$rs", [(MipsJmpLink CPU16Regs:$rs)], II_JALRC> {
1383   let Defs = [RA];
1386 // Mips16 pseudos
1387 let isReturn=1, isTerminator=1, hasDelaySlot=1, isBarrier=1, hasCtrlDep=1,
1388   hasExtraSrcRegAllocReq = 1 in
1389 def RetRA16 : MipsPseudo16<(outs), (ins), "", [(MipsRet)]>;
1392 // setcc patterns
1394 class SetCC_R16<PatFrag cond_op, Instruction I>:
1395   Mips16Pat<(cond_op CPU16Regs:$rx, CPU16Regs:$ry),
1396             (I CPU16Regs:$rx, CPU16Regs:$ry)>;
1398 class SetCC_I16<PatFrag cond_op, PatLeaf imm_type, Instruction I>:
1399   Mips16Pat<(cond_op CPU16Regs:$rx, imm_type:$imm16),
1400             (I CPU16Regs:$rx, imm_type:$imm16)>;
1403 def: Mips16Pat<(i32 addr16sp:$addr), (AddiuRxRyOffMemX16 addr16sp:$addr)>;
1406 // Large (>16 bit) immediate loads
1407 def : Mips16Pat<(i32 imm:$imm), (LwConstant32 imm:$imm, -1)>;
1410 // Some branch conditional patterns are not generated by llvm at this time.
1411 // Some are for seemingly arbitrary reasons not used: i.e. with signed number
1412 // comparison they are used and for unsigned a different pattern is used.
1413 // I am pushing upstream from the full mips16 port and it seemed that I needed
1414 // these earlier and the mips32 port has these but now I cannot create test
1415 // cases that use these patterns. While I sort this all out I will leave these
1416 // extra patterns commented out and if I can be sure they are really not used,
1417 // I will delete the code. I don't want to check the code in uncommented without
1418 // a valid test case. In some cases, the compiler is generating patterns with
1419 // setcc instead and earlier I had implemented setcc first so may have masked
1420 // the problem. The setcc variants are suboptimal for mips16 so I may wantto
1421 // figure out how to enable the brcond patterns or else possibly new
1422 // combinations of brcond and setcc.
1425 // bcond-seteq
1427 def: Mips16Pat
1428   <(brcond (i32 (seteq CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
1429    (BteqzT8CmpX16 CPU16Regs:$rx, CPU16Regs:$ry,  bb:$imm16)
1430   >;
1433 def: Mips16Pat
1434   <(brcond (i32 (seteq CPU16Regs:$rx, immZExt16:$imm)), bb:$targ16),
1435    (BteqzT8CmpiX16 CPU16Regs:$rx, immSExt16:$imm,  bb:$targ16)
1436   >;
1438 def: Mips16Pat
1439   <(brcond (i32 (seteq CPU16Regs:$rx, 0)), bb:$targ16),
1440    (BeqzRxImm16 CPU16Regs:$rx, bb:$targ16)
1441   >;
1444 // bcond-setgt (do we need to have this pair of setlt, setgt??)
1446 def: Mips16Pat
1447   <(brcond (i32 (setgt CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
1448    (BtnezT8SltX16 CPU16Regs:$ry, CPU16Regs:$rx,  bb:$imm16)
1449   >;
1452 // bcond-setge
1454 def: Mips16Pat
1455   <(brcond (i32 (setge CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
1456    (BteqzT8SltX16 CPU16Regs:$rx, CPU16Regs:$ry,  bb:$imm16)
1457   >;
1460 // never called because compiler transforms a >= k to a > (k-1)
1461 def: Mips16Pat
1462   <(brcond (i32 (setge CPU16Regs:$rx, immSExt16:$imm)), bb:$imm16),
1463    (BteqzT8SltiX16 CPU16Regs:$rx, immSExt16:$imm,  bb:$imm16)
1464   >;
1467 // bcond-setlt
1469 def: Mips16Pat
1470   <(brcond (i32 (setlt CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
1471    (BtnezT8SltX16 CPU16Regs:$rx, CPU16Regs:$ry,  bb:$imm16)
1472   >;
1474 def: Mips16Pat
1475   <(brcond (i32 (setlt CPU16Regs:$rx, immSExt16:$imm)), bb:$imm16),
1476    (BtnezT8SltiX16 CPU16Regs:$rx, immSExt16:$imm,  bb:$imm16)
1477   >;
1480 // bcond-setle
1482 def: Mips16Pat
1483   <(brcond (i32 (setle CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
1484    (BteqzT8SltX16 CPU16Regs:$ry, CPU16Regs:$rx,  bb:$imm16)
1485   >;
1488 // bcond-setne
1490 def: Mips16Pat
1491   <(brcond (i32 (setne CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
1492    (BtnezT8CmpX16 CPU16Regs:$rx, CPU16Regs:$ry,  bb:$imm16)
1493   >;
1495 def: Mips16Pat
1496   <(brcond (i32 (setne CPU16Regs:$rx, immZExt16:$imm)), bb:$targ16),
1497    (BtnezT8CmpiX16 CPU16Regs:$rx, immSExt16:$imm,  bb:$targ16)
1498   >;
1500 def: Mips16Pat
1501   <(brcond (i32 (setne CPU16Regs:$rx, 0)), bb:$targ16),
1502    (BnezRxImm16 CPU16Regs:$rx, bb:$targ16)
1503   >;
1506 // This needs to be there but I forget which code will generate it
1508 def: Mips16Pat
1509   <(brcond CPU16Regs:$rx, bb:$targ16),
1510    (BnezRxImm16 CPU16Regs:$rx, bb:$targ16)
1511   >;
1516 // bcond-setugt
1518 //def: Mips16Pat
1519 //  <(brcond (i32 (setugt CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
1520 //   (BtnezT8SltuX16 CPU16Regs:$ry, CPU16Regs:$rx,  bb:$imm16)
1521 //  >;
1524 // bcond-setuge
1526 //def: Mips16Pat
1527 //  <(brcond (i32 (setuge CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
1528 //   (BteqzT8SltuX16 CPU16Regs:$rx, CPU16Regs:$ry,  bb:$imm16)
1529 //  >;
1533 // bcond-setult
1535 //def: Mips16Pat
1536 //  <(brcond (i32 (setult CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
1537 //   (BtnezT8SltuX16 CPU16Regs:$rx, CPU16Regs:$ry,  bb:$imm16)
1538 //  >;
1540 def: UncondBranch16_pat<br, Bimm16>;
1542 // Small immediates
1543 def: Mips16Pat<(i32 immSExt16:$in),
1544                (AddiuRxRxImmX16 (MoveR3216 ZERO), immSExt16:$in)>;
1546 def: Mips16Pat<(i32 immZExt16:$in), (LiRxImmX16 immZExt16:$in)>;
1549 // MipsDivRem
1551 def: Mips16Pat
1552   <(MipsDivRem16 CPU16Regs:$rx, CPU16Regs:$ry),
1553    (DivRxRy16 CPU16Regs:$rx, CPU16Regs:$ry)>;
1556 // MipsDivRemU
1558 def: Mips16Pat
1559   <(MipsDivRemU16 CPU16Regs:$rx, CPU16Regs:$ry),
1560    (DivuRxRy16 CPU16Regs:$rx, CPU16Regs:$ry)>;
1562 //  signed a,b
1563 //  x = (a>=b)?x:y
1565 //  if !(a < b) x = y
1567 def : Mips16Pat<(select (i32 (setge CPU16Regs:$a, CPU16Regs:$b)),
1568                  CPU16Regs:$x, CPU16Regs:$y),
1569                 (SelTBteqZSlt CPU16Regs:$x, CPU16Regs:$y,
1570                  CPU16Regs:$a, CPU16Regs:$b)>;
1572 //  signed a,b
1573 //  x = (a>b)?x:y
1575 //  if  (b < a) x = y
1577 def : Mips16Pat<(select (i32 (setgt CPU16Regs:$a, CPU16Regs:$b)),
1578                  CPU16Regs:$x, CPU16Regs:$y),
1579                 (SelTBtneZSlt CPU16Regs:$x, CPU16Regs:$y,
1580                  CPU16Regs:$b, CPU16Regs:$a)>;
1582 // unsigned a,b
1583 // x = (a>=b)?x:y
1585 // if !(a < b) x = y;
1587 def : Mips16Pat<
1588   (select (i32 (setuge CPU16Regs:$a, CPU16Regs:$b)),
1589    CPU16Regs:$x, CPU16Regs:$y),
1590   (SelTBteqZSltu CPU16Regs:$x, CPU16Regs:$y,
1591    CPU16Regs:$a, CPU16Regs:$b)>;
1593 //  unsigned a,b
1594 //  x = (a>b)?x:y
1596 //  if (b < a) x = y
1598 def : Mips16Pat<(select (i32 (setugt CPU16Regs:$a, CPU16Regs:$b)),
1599                  CPU16Regs:$x, CPU16Regs:$y),
1600                 (SelTBtneZSltu CPU16Regs:$x, CPU16Regs:$y,
1601                  CPU16Regs:$b, CPU16Regs:$a)>;
1603 // signed
1604 // x = (a >= k)?x:y
1605 // due to an llvm optimization, i don't think that this will ever
1606 // be used. This is transformed into x = (a > k-1)?x:y
1610 //def : Mips16Pat<
1611 //  (select (i32 (setge CPU16Regs:$lhs, immSExt16:$rhs)),
1612 //   CPU16Regs:$T, CPU16Regs:$F),
1613 //  (SelTBteqZSlti CPU16Regs:$T, CPU16Regs:$F,
1614 //   CPU16Regs:$lhs, immSExt16:$rhs)>;
1616 //def : Mips16Pat<
1617 //  (select (i32 (setuge CPU16Regs:$lhs, immSExt16:$rhs)),
1618 //   CPU16Regs:$T, CPU16Regs:$F),
1619 //  (SelTBteqZSltiu CPU16Regs:$T, CPU16Regs:$F,
1620 //   CPU16Regs:$lhs, immSExt16:$rhs)>;
1622 // signed
1623 // x = (a < k)?x:y
1625 // if !(a < k) x = y;
1627 def : Mips16Pat<
1628   (select (i32 (setlt CPU16Regs:$a, immSExt16:$b)),
1629    CPU16Regs:$x, CPU16Regs:$y),
1630   (SelTBtneZSlti CPU16Regs:$x, CPU16Regs:$y,
1631    CPU16Regs:$a, immSExt16:$b)>;
1636 // signed
1637 // x = (a <= b)? x : y
1639 // if  (b < a) x = y
1641 def : Mips16Pat<(select (i32 (setle CPU16Regs:$a, CPU16Regs:$b)),
1642                  CPU16Regs:$x, CPU16Regs:$y),
1643                 (SelTBteqZSlt CPU16Regs:$x, CPU16Regs:$y,
1644                  CPU16Regs:$b, CPU16Regs:$a)>;
1647 // unnsigned
1648 // x = (a <= b)? x : y
1650 // if  (b < a) x = y
1652 def : Mips16Pat<(select (i32 (setule CPU16Regs:$a, CPU16Regs:$b)),
1653                  CPU16Regs:$x, CPU16Regs:$y),
1654                 (SelTBteqZSltu CPU16Regs:$x, CPU16Regs:$y,
1655                  CPU16Regs:$b, CPU16Regs:$a)>;
1658 // signed/unsigned
1659 // x = (a == b)? x : y
1661 // if (a != b) x = y
1663 def : Mips16Pat<(select (i32 (seteq CPU16Regs:$a, CPU16Regs:$b)),
1664                  CPU16Regs:$x, CPU16Regs:$y),
1665                 (SelTBteqZCmp CPU16Regs:$x, CPU16Regs:$y,
1666                  CPU16Regs:$b, CPU16Regs:$a)>;
1669 // signed/unsigned
1670 // x = (a == 0)? x : y
1672 // if (a != 0) x = y
1674 def : Mips16Pat<(select (i32 (seteq CPU16Regs:$a, 0)),
1675                  CPU16Regs:$x, CPU16Regs:$y),
1676                 (SelBeqZ CPU16Regs:$x, CPU16Regs:$y,
1677                  CPU16Regs:$a)>;
1681 // signed/unsigned
1682 // x = (a == k)? x : y
1684 // if (a != k) x = y
1686 def : Mips16Pat<(select (i32 (seteq CPU16Regs:$a, immZExt16:$k)),
1687                  CPU16Regs:$x, CPU16Regs:$y),
1688                 (SelTBteqZCmpi CPU16Regs:$x, CPU16Regs:$y,
1689                  CPU16Regs:$a, immZExt16:$k)>;
1693 // signed/unsigned
1694 // x = (a != b)? x : y
1696 // if (a == b) x = y
1699 def : Mips16Pat<(select (i32 (setne CPU16Regs:$a, CPU16Regs:$b)),
1700                  CPU16Regs:$x, CPU16Regs:$y),
1701                 (SelTBtneZCmp CPU16Regs:$x, CPU16Regs:$y,
1702                  CPU16Regs:$b, CPU16Regs:$a)>;
1705 // signed/unsigned
1706 // x = (a != 0)? x : y
1708 // if (a == 0) x = y
1710 def : Mips16Pat<(select (i32 (setne CPU16Regs:$a, 0)),
1711                  CPU16Regs:$x, CPU16Regs:$y),
1712                 (SelBneZ CPU16Regs:$x, CPU16Regs:$y,
1713                  CPU16Regs:$a)>;
1715 // signed/unsigned
1716 // x = (a)? x : y
1718 // if (!a) x = y
1720 def : Mips16Pat<(select  CPU16Regs:$a,
1721                  CPU16Regs:$x, CPU16Regs:$y),
1722       (SelBneZ CPU16Regs:$x, CPU16Regs:$y,
1723        CPU16Regs:$a)>;
1727 // signed/unsigned
1728 // x = (a != k)? x : y
1730 // if (a == k) x = y
1732 def : Mips16Pat<(select (i32 (setne CPU16Regs:$a, immZExt16:$k)),
1733                  CPU16Regs:$x, CPU16Regs:$y),
1734                 (SelTBtneZCmpi CPU16Regs:$x, CPU16Regs:$y,
1735                  CPU16Regs:$a, immZExt16:$k)>;
1738 // When writing C code to test setxx these patterns,
1739 // some will be transformed into
1740 // other things. So we test using C code but using -O3 and -O0
1742 // seteq
1744 def : Mips16Pat
1745   <(seteq CPU16Regs:$lhs,CPU16Regs:$rhs),
1746    (SltiuCCRxImmX16 (XorRxRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs), 1)>;
1748 def : Mips16Pat
1749   <(seteq CPU16Regs:$lhs, 0),
1750    (SltiuCCRxImmX16 CPU16Regs:$lhs, 1)>;
1754 // setge
1757 def: Mips16Pat
1758   <(setge CPU16Regs:$lhs, CPU16Regs:$rhs),
1759    (XorRxRxRy16 (SltCCRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs),
1760    (LiRxImmX16 1))>;
1763 // For constants, llvm transforms this to:
1764 // x > (k - 1) and then reverses the operands to use setlt. So this pattern
1765 // is not used now by the compiler. (Presumably checking that k-1 does not
1766 // overflow). The compiler never uses this at the current time, due to
1767 // other optimizations.
1769 //def: Mips16Pat
1770 //  <(setge CPU16Regs:$lhs, immSExt16:$rhs),
1771 //   (XorRxRxRy16 (SltiCCRxImmX16 CPU16Regs:$lhs, immSExt16:$rhs),
1772 //   (LiRxImmX16 1))>;
1774 // This catches the x >= -32768 case by transforming it to  x > -32769
1776 def: Mips16Pat
1777   <(setgt CPU16Regs:$lhs, -32769),
1778    (XorRxRxRy16 (SltiCCRxImmX16 CPU16Regs:$lhs, -32768),
1779    (LiRxImmX16 1))>;
1782 // setgt
1786 def: Mips16Pat
1787   <(setgt CPU16Regs:$lhs, CPU16Regs:$rhs),
1788    (SltCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs)>;
1791 // setle
1793 def: Mips16Pat
1794   <(setle CPU16Regs:$lhs, CPU16Regs:$rhs),
1795    (XorRxRxRy16 (SltCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs), (LiRxImm16 1))>;
1798 // setlt
1800 def: SetCC_R16<setlt, SltCCRxRy16>;
1802 def: SetCC_I16<setlt, immSExt16, SltiCCRxImmX16>;
1805 // setne
1807 def : Mips16Pat
1808   <(setne CPU16Regs:$lhs,CPU16Regs:$rhs),
1809    (SltuCCRxRy16 (LiRxImmX16 0),
1810    (XorRxRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs))>;
1814 // setuge
1816 def: Mips16Pat
1817   <(setuge CPU16Regs:$lhs, CPU16Regs:$rhs),
1818    (XorRxRxRy16 (SltuCCRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs),
1819    (LiRxImmX16 1))>;
1821 // this pattern will never be used because the compiler will transform
1822 // x >= k to x > (k - 1) and then use SLT
1824 //def: Mips16Pat
1825 //  <(setuge CPU16Regs:$lhs, immZExt16:$rhs),
1826 //   (XorRxRxRy16 (SltiuCCRxImmX16 CPU16Regs:$lhs, immZExt16:$rhs),
1827 //   (LiRxImmX16 1))>;
1830 // setugt
1832 def: Mips16Pat
1833   <(setugt CPU16Regs:$lhs, CPU16Regs:$rhs),
1834    (SltuCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs)>;
1837 // setule
1839 def: Mips16Pat
1840   <(setule CPU16Regs:$lhs, CPU16Regs:$rhs),
1841    (XorRxRxRy16 (SltuCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs), (LiRxImmX16 1))>;
1844 // setult
1846 def: SetCC_R16<setult, SltuCCRxRy16>;
1848 def: SetCC_I16<setult, immSExt16, SltiuCCRxImmX16>;
1850 def: Mips16Pat<(add CPU16Regs:$hi, (MipsLo tglobaladdr:$lo)),
1851                (AddiuRxRxImmX16 CPU16Regs:$hi, tglobaladdr:$lo)>;
1853 // hi/lo relocs
1854 def : Mips16Pat<(MipsHi tblockaddress:$in),
1855                 (SllX16 (LiRxImmX16 tblockaddress:$in), 16)>;
1856 def : Mips16Pat<(MipsHi tglobaladdr:$in),
1857                 (SllX16 (LiRxImmX16 tglobaladdr:$in), 16)>;
1858 def : Mips16Pat<(MipsHi tjumptable:$in),
1859                 (SllX16 (LiRxImmX16 tjumptable:$in), 16)>;
1861 def : Mips16Pat<(MipsLo tblockaddress:$in), (LiRxImmX16 tblockaddress:$in)>;
1863 def : Mips16Pat<(MipsTlsHi tglobaltlsaddr:$in),
1864                 (SllX16 (LiRxImmX16 tglobaltlsaddr:$in), 16)>;
1866 // wrapper_pic
1867 class Wrapper16Pat<SDNode node, Instruction ADDiuOp, RegisterClass RC>:
1868   Mips16Pat<(MipsWrapper RC:$gp, node:$in),
1869             (ADDiuOp RC:$gp, node:$in)>;
1872 def : Wrapper16Pat<tglobaladdr, AddiuRxRxImmX16, CPU16Regs>;
1873 def : Wrapper16Pat<tglobaltlsaddr, AddiuRxRxImmX16, CPU16Regs>;
1875 def : Mips16Pat<(i32 (extloadi8   addr16:$src)),
1876                 (LbuRxRyOffMemX16  addr16:$src)>;
1877 def : Mips16Pat<(i32 (extloadi16  addr16:$src)),
1878                 (LhuRxRyOffMemX16  addr16:$src)>;
1880 def: Mips16Pat<(trap), (Break16)>;
1882 def : Mips16Pat<(sext_inreg CPU16Regs:$val, i8),
1883                 (SebRx16 CPU16Regs:$val)>;
1885 def : Mips16Pat<(sext_inreg CPU16Regs:$val, i16),
1886                 (SehRx16 CPU16Regs:$val)>;
1888 def GotPrologue16:   
1889   MipsPseudo16<
1890     (outs CPU16Regs:$rh, CPU16Regs:$rl),
1891     (ins simm16:$immHi, simm16:$immLo),
1892     "li\t$rh, $immHi\n\taddiu\t$rl, $$pc, $immLo\n ",[]> ;
1894 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
1895 def cpinst_operand : Operand<i32> {
1896   // let PrintMethod = "printCPInstOperand";
1899 // CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
1900 // the function.  The first operand is the ID# for this instruction, the second
1901 // is the index into the MachineConstantPool that this is, the third is the
1902 // size in bytes of this constant pool entry.
1904 let hasSideEffects = 0, isNotDuplicable = 1 in
1905 def CONSTPOOL_ENTRY :
1906 MipsPseudo16<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1907                       i32imm:$size), "foo", []>;
1909 // Instruction Aliases
1911 let EncodingPredicates = [InMips16Mode] in
1912 def : MipsInstAlias<"nop", (Move32R16 ZERO, S0)>;