blob: 5f8af05f0c515d80c768f38b06b31750ff95a0df [file] [log] [blame]
Akira Hatanakadf98a7a2012-05-24 18:32:33 +00001//===- 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//===----------------------------------------------------------------------===//
Reed Kotler24032212012-10-05 18:27:54 +000013//
Reed Kotler3589dd72012-10-28 06:02:37 +000014//
15// Mips Address
16//
17def addr16 :
18 ComplexPattern<iPTR, 3, "SelectAddr16", [frameindex], [SDNPWantParent]>;
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +000019
20//
Reed Kotler0f2e44a2012-10-10 01:58:16 +000021// Address operand
22def mem16 : Operand<i32> {
23 let PrintMethod = "printMemOperand";
Reed Kotler3589dd72012-10-28 06:02:37 +000024 let MIOperandInfo = (ops CPU16Regs, simm16, CPU16Regs);
25 let EncoderMethod = "getMemEncoding";
26}
27
28def mem16_ea : Operand<i32> {
29 let PrintMethod = "printMemOperandEA";
Reed Kotler0f2e44a2012-10-10 01:58:16 +000030 let MIOperandInfo = (ops CPU16Regs, simm16);
31 let EncoderMethod = "getMemEncoding";
Akira Hatanaka22bec282012-08-03 22:57:02 +000032}
33
Reed Kotler0f2e44a2012-10-10 01:58:16 +000034//
Reed Kotler164bb372012-10-23 01:35:48 +000035// Compare a register and immediate and place result in CC
36// Implicit use of T8
37//
38// EXT-CCRR Instruction format
39//
40class FEXT_CCRXI16_ins<bits<5> _op, string asmstr,
41 InstrItinClass itin>:
42 FEXT_RI16<_op, (outs CPU16Regs:$cc), (ins CPU16Regs:$rx, simm16:$imm),
43 !strconcat(asmstr, "\t$rx, $imm\n\tmove\t$cc, $$t8"), [], itin> {
44 let isCodeGenOnly=1;
45}
46
47//
Reed Kotler67439242012-10-17 22:29:54 +000048// EXT-I instruction format
49//
50class FEXT_I16_ins<bits<5> eop, string asmstr, InstrItinClass itin> :
51 FEXT_I16<eop, (outs), (ins brtarget:$imm16),
52 !strconcat(asmstr, "\t$imm16"),[], itin>;
53
54//
55// EXT-I8 instruction format
56//
57
58class FEXT_I816_ins_base<bits<3> _func, string asmstr,
59 string asmstr2, InstrItinClass itin>:
60 FEXT_I816<_func, (outs), (ins uimm16:$imm), !strconcat(asmstr, asmstr2),
61 [], itin>;
62
63class FEXT_I816_ins<bits<3> _func, string asmstr,
64 InstrItinClass itin>:
65 FEXT_I816_ins_base<_func, asmstr, "\t$imm", itin>;
66
67//
Reed Kotler0f2e44a2012-10-10 01:58:16 +000068// Assembler formats in alphabetical order.
69// Natural and pseudos are mixed together.
70//
Reed Kotler164bb372012-10-23 01:35:48 +000071// Compare two registers and place result in CC
72// Implicit use of T8
73//
74// CC-RR Instruction format
75//
76class FCCRR16_ins<bits<5> f, string asmstr, InstrItinClass itin> :
77 FRR16<f, (outs CPU16Regs:$cc), (ins CPU16Regs:$rx, CPU16Regs:$ry),
78 !strconcat(asmstr, "\t$rx, $ry\n\tmove\t$cc, $$t8"), [], itin> {
79 let isCodeGenOnly=1;
80}
81
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +000082//
Reed Kotler210ebe92012-09-28 02:26:24 +000083// EXT-RI instruction format
84//
85
86class FEXT_RI16_ins_base<bits<5> _op, string asmstr, string asmstr2,
87 InstrItinClass itin>:
88 FEXT_RI16<_op, (outs CPU16Regs:$rx), (ins simm16:$imm),
89 !strconcat(asmstr, asmstr2), [], itin>;
90
91class FEXT_RI16_ins<bits<5> _op, string asmstr,
92 InstrItinClass itin>:
93 FEXT_RI16_ins_base<_op, asmstr, "\t$rx, $imm", itin>;
94
95class FEXT_RI16_PC_ins<bits<5> _op, string asmstr, InstrItinClass itin>:
96 FEXT_RI16_ins_base<_op, asmstr, "\t$rx, $$pc, $imm", itin>;
97
Reed Kotler67439242012-10-17 22:29:54 +000098class FEXT_RI16_B_ins<bits<5> _op, string asmstr,
99 InstrItinClass itin>:
100 FEXT_RI16<_op, (outs), (ins CPU16Regs:$rx, brtarget:$imm),
101 !strconcat(asmstr, "\t$rx, $imm"), [], itin>;
102
Reed Kotler210ebe92012-09-28 02:26:24 +0000103class FEXT_2RI16_ins<bits<5> _op, string asmstr,
104 InstrItinClass itin>:
105 FEXT_RI16<_op, (outs CPU16Regs:$rx), (ins CPU16Regs:$rx_, simm16:$imm),
106 !strconcat(asmstr, "\t$rx, $imm"), [], itin> {
107 let Constraints = "$rx_ = $rx";
108}
Reed Kotler24032212012-10-05 18:27:54 +0000109
Reed Kotler67439242012-10-17 22:29:54 +0000110
Reed Kotler210ebe92012-09-28 02:26:24 +0000111// this has an explicit sp argument that we ignore to work around a problem
112// in the compiler
113class FEXT_RI16_SP_explicit_ins<bits<5> _op, string asmstr,
114 InstrItinClass itin>:
115 FEXT_RI16<_op, (outs CPU16Regs:$rx), (ins CPUSPReg:$ry, simm16:$imm),
Reed Kotler24032212012-10-05 18:27:54 +0000116 !strconcat(asmstr, "\t$rx, $imm ( $ry ); "), [], itin>;
Reed Kotler210ebe92012-09-28 02:26:24 +0000117
118//
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000119// EXT-RRI instruction format
120//
121
122class FEXT_RRI16_mem_ins<bits<5> op, string asmstr, Operand MemOpnd,
123 InstrItinClass itin>:
124 FEXT_RRI16<op, (outs CPU16Regs:$ry), (ins MemOpnd:$addr),
125 !strconcat(asmstr, "\t$ry, $addr"), [], itin>;
126
Akira Hatanaka22bec282012-08-03 22:57:02 +0000127class FEXT_RRI16_mem2_ins<bits<5> op, string asmstr, Operand MemOpnd,
128 InstrItinClass itin>:
129 FEXT_RRI16<op, (outs ), (ins CPU16Regs:$ry, MemOpnd:$addr),
130 !strconcat(asmstr, "\t$ry, $addr"), [], itin>;
131
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000132//
Reed Kotler3589dd72012-10-28 06:02:37 +0000133//
134// EXT-RRI-A instruction format
135//
136
137class FEXT_RRI_A16_mem_ins<bits<1> op, string asmstr, Operand MemOpnd,
138 InstrItinClass itin>:
139 FEXT_RRI_A16<op, (outs CPU16Regs:$ry), (ins MemOpnd:$addr),
140 !strconcat(asmstr, "\t$ry, $addr"), [], itin>;
141
142//
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000143// EXT-SHIFT instruction format
144//
145class FEXT_SHIFT16_ins<bits<2> _f, string asmstr, InstrItinClass itin>:
Akira Hatanaka22bec282012-08-03 22:57:02 +0000146 FEXT_SHIFT16<_f, (outs CPU16Regs:$rx), (ins CPU16Regs:$ry, shamt:$sa),
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000147 !strconcat(asmstr, "\t$rx, $ry, $sa"), [], itin>;
148
Reed Kotler67439242012-10-17 22:29:54 +0000149//
150// EXT-T8I8
151//
152class FEXT_T8I816_ins<bits<3> _func, string asmstr, string asmstr2,
153 InstrItinClass itin>:
154 FEXT_I816<_func, (outs),
155 (ins CPU16Regs:$rx, CPU16Regs:$ry, brtarget:$imm),
156 !strconcat(asmstr2, !strconcat("\t$rx, $ry\n\t",
157 !strconcat(asmstr, "\t$imm"))),[], itin> {
158 let isCodeGenOnly=1;
159}
160
161//
162// EXT-T8I8I
163//
164class FEXT_T8I8I16_ins<bits<3> _func, string asmstr, string asmstr2,
165 InstrItinClass itin>:
166 FEXT_I816<_func, (outs),
167 (ins CPU16Regs:$rx, simm16:$imm, brtarget:$targ),
168 !strconcat(asmstr2, !strconcat("\t$rx, $imm\n\t",
169 !strconcat(asmstr, "\t$targ"))), [], itin> {
170 let isCodeGenOnly=1;
171}
172//
173
Reed Kotler0f2e44a2012-10-10 01:58:16 +0000174
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000175//
Reed Kotler0f2e44a2012-10-10 01:58:16 +0000176// I8_MOVR32 instruction format (used only by the MOVR32 instructio
177//
178class FI8_MOVR3216_ins<string asmstr, InstrItinClass itin>:
179 FI8_MOVR3216<(outs CPU16Regs:$rz), (ins CPURegs:$r32),
180 !strconcat(asmstr, "\t$rz, $r32"), [], itin>;
181
182//
183// I8_MOV32R instruction format (used only by MOV32R instruction)
184//
185
186class FI8_MOV32R16_ins<string asmstr, InstrItinClass itin>:
187 FI8_MOV32R16<(outs CPURegs:$r32), (ins CPU16Regs:$rz),
188 !strconcat(asmstr, "\t$r32, $rz"), [], itin>;
189
190//
191// This are pseudo formats for multiply
192// This first one can be changed to non pseudo now.
193//
194// MULT
195//
196class FMULT16_ins<string asmstr, InstrItinClass itin> :
197 MipsPseudo16<(outs), (ins CPU16Regs:$rx, CPU16Regs:$ry),
198 !strconcat(asmstr, "\t$rx, $ry"), []>;
199
200//
201// MULT-LO
202//
203class FMULT16_LO_ins<string asmstr, InstrItinClass itin> :
204 MipsPseudo16<(outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry),
205 !strconcat(asmstr, "\t$rx, $ry\n\tmflo\t$rz"), []> {
206 let isCodeGenOnly=1;
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000207}
208
209//
Reed Kotler0f2e44a2012-10-10 01:58:16 +0000210// RR-type instruction format
211//
212
213class FRR16_ins<bits<5> f, string asmstr, InstrItinClass itin> :
214 FRR16<f, (outs CPU16Regs:$rx), (ins CPU16Regs:$ry),
215 !strconcat(asmstr, "\t$rx, $ry"), [], itin> {
216}
Reed Kotlercf11c592012-10-12 02:01:09 +0000217
Reed Kotler287f0442012-10-26 04:46:26 +0000218class FRRTR16_ins<bits<5> f, string asmstr, InstrItinClass itin> :
219 FRR16<f, (outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry),
220 !strconcat(asmstr, "\t$rx, $ry\n\tmove\t$rz, $$t8"), [], itin> ;
221
Reed Kotlercf11c592012-10-12 02:01:09 +0000222//
223// maybe refactor but need a $zero as a dummy first parameter
224//
225class FRR16_div_ins<bits<5> f, string asmstr, InstrItinClass itin> :
226 FRR16<f, (outs ), (ins CPU16Regs:$rx, CPU16Regs:$ry),
227 !strconcat(asmstr, "\t$$zero, $rx, $ry"), [], itin> ;
228
Reed Kotler4e1c6292012-10-26 16:18:19 +0000229class FUnaryRR16_ins<bits<5> f, string asmstr, InstrItinClass itin> :
230 FRR16<f, (outs CPU16Regs:$rx), (ins CPU16Regs:$ry),
231 !strconcat(asmstr, "\t$rx, $ry"), [], itin> ;
232
233
Reed Kotler0f2e44a2012-10-10 01:58:16 +0000234class FRR16_M_ins<bits<5> f, string asmstr,
235 InstrItinClass itin> :
236 FRR16<f, (outs CPU16Regs:$rx), (ins),
237 !strconcat(asmstr, "\t$rx"), [], itin>;
238
239class FRxRxRy16_ins<bits<5> f, string asmstr,
240 InstrItinClass itin> :
241 FRR16<f, (outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry),
242 !strconcat(asmstr, "\t$rz, $ry"),
243 [], itin> {
244 let Constraints = "$rx = $rz";
245}
246
247let rx=0 in
248class FRR16_JALRC_RA_only_ins<bits<1> nd_, bits<1> l_,
249 string asmstr, InstrItinClass itin>:
250 FRR16_JALRC<nd_, l_, 1, (outs), (ins), !strconcat(asmstr, "\t $$ra"),
251 [], itin> ;
252
Reed Kotlere6c31572012-10-28 23:08:07 +0000253
254class FRR16_JALRC_ins<bits<1> nd, bits<1> l, bits<1> ra,
255 string asmstr, InstrItinClass itin>:
256 FRR16_JALRC<nd, l, ra, (outs), (ins CPU16Regs:$rx),
257 !strconcat(asmstr, "\t $rx"), [], itin> ;
258
Reed Kotler0f2e44a2012-10-10 01:58:16 +0000259//
260// RRR-type instruction format
261//
262
263class FRRR16_ins<bits<2> _f, string asmstr, InstrItinClass itin> :
264 FRRR16<_f, (outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry),
265 !strconcat(asmstr, "\t$rz, $rx, $ry"), [], itin>;
266
267//
Reed Kotler097556d2012-10-25 21:33:30 +0000268// These Sel patterns support the generation of conditional move
269// pseudo instructions.
270//
271// The nomenclature uses the components making up the pseudo and may
272// be a bit counter intuitive when compared with the end result we seek.
273// For example using a bqez in the example directly below results in the
274// conditional move being done if the tested register is not zero.
275// I considered in easier to check by keeping the pseudo consistent with
276// it's components but it could have been done differently.
277//
278// The simplest case is when can test and operand directly and do the
279// conditional move based on a simple mips16 conditional
280// branch instruction.
281// for example:
282// if $op == beqz or bnez:
283//
284// $op1 $rt, .+4
285// move $rd, $rs
286//
287// if $op == beqz, then if $rt != 0, then the conditional assignment
288// $rd = $rs is done.
289
290// if $op == bnez, then if $rt == 0, then the conditional assignment
291// $rd = $rs is done.
292//
293// So this pseudo class only has one operand, i.e. op
294//
295class Sel<bits<5> f1, string op, InstrItinClass itin>:
296 MipsInst16_32<(outs CPU16Regs:$rd_), (ins CPU16Regs:$rd, CPU16Regs:$rs,
297 CPU16Regs:$rt),
298 !strconcat(op, "\t$rt, .+4\n\t\n\tmove $rd, $rs"), [], itin,
299 Pseudo16> {
300 let isCodeGenOnly=1;
301 let Constraints = "$rd = $rd_";
302}
303
304//
305// The next two instruction classes allow for an operand which tests
306// two operands and returns a value in register T8 and
307//then does a conditional branch based on the value of T8
308//
309
310// op2 can be cmpi or slti/sltiu
311// op1 can bteqz or btnez
312// the operands for op2 are a register and a signed constant
313//
314// $op2 $t, $imm ;test register t and branch conditionally
315// $op1 .+4 ;op1 is a conditional branch
316// move $rd, $rs
317//
318//
319class SeliT<bits<5> f1, string op1, bits<5> f2, string op2,
320 InstrItinClass itin>:
321 MipsInst16_32<(outs CPU16Regs:$rd_), (ins CPU16Regs:$rd, CPU16Regs:$rs,
322 CPU16Regs:$rl, simm16:$imm),
323 !strconcat(op2,
324 !strconcat("\t$rl, $imm\n\t",
325 !strconcat(op1, "\t.+4\n\tmove $rd, $rs"))), [], itin,
326 Pseudo16> {
327 let isCodeGenOnly=1;
328 let Constraints = "$rd = $rd_";
329}
330
331//
332// op2 can be cmp or slt/sltu
333// op1 can be bteqz or btnez
334// the operands for op2 are two registers
335// op1 is a conditional branch
336//
337//
338// $op2 $rl, $rr ;test registers rl,rr
339// $op1 .+4 ;op2 is a conditional branch
340// move $rd, $rs
341//
342//
343class SelT<bits<5> f1, string op1, bits<5> f2, string op2,
344 InstrItinClass itin>:
345 MipsInst16_32<(outs CPU16Regs:$rd_), (ins CPU16Regs:$rd, CPU16Regs:$rs,
346 CPU16Regs:$rl, CPU16Regs:$rr),
347 !strconcat(op2,
348 !strconcat("\t$rl, $rr\n\t",
349 !strconcat(op1, "\t.+4\n\tmove $rd, $rs"))), [], itin,
350 Pseudo16> {
351 let isCodeGenOnly=1;
352 let Constraints = "$rd = $rd_";
353}
354
355
356//
Akira Hatanaka22bec282012-08-03 22:57:02 +0000357// Some general instruction class info
358//
359//
360
361class ArithLogic16Defs<bit isCom=0> {
362 bits<5> shamt = 0;
363 bit isCommutable = isCom;
364 bit isReMaterializable = 1;
365 bit neverHasSideEffects = 1;
366}
367
Reed Kotler67439242012-10-17 22:29:54 +0000368class branch16 {
369 bit isBranch = 1;
370 bit isTerminator = 1;
371 bit isBarrier = 1;
372}
373
374class cbranch16 {
375 bit isBranch = 1;
376 bit isTerminator = 1;
377}
378
Reed Kotler210ebe92012-09-28 02:26:24 +0000379class MayLoad {
380 bit mayLoad = 1;
381}
382
383class MayStore {
384 bit mayStore = 1;
385}
Akira Hatanaka22bec282012-08-03 22:57:02 +0000386//
Akira Hatanaka64626fc2012-07-26 02:24:43 +0000387
388// Format: ADDIU rx, immediate MIPS16e
389// Purpose: Add Immediate Unsigned Word (2-Operand, Extended)
390// To add a constant to a 32-bit integer.
391//
Akira Hatanaka22bec282012-08-03 22:57:02 +0000392def AddiuRxImmX16: FEXT_RI16_ins<0b01001, "addiu", IIAlu>;
Akira Hatanaka64626fc2012-07-26 02:24:43 +0000393
Akira Hatanaka22bec282012-08-03 22:57:02 +0000394def AddiuRxRxImmX16: FEXT_2RI16_ins<0b01001, "addiu", IIAlu>,
395 ArithLogic16Defs<0>;
Akira Hatanaka64626fc2012-07-26 02:24:43 +0000396
Reed Kotler3589dd72012-10-28 06:02:37 +0000397def AddiuRxRyOffMemX16:
398 FEXT_RRI_A16_mem_ins<0, "addiu", mem16_ea, IIAlu>;
399
Akira Hatanaka64626fc2012-07-26 02:24:43 +0000400//
401
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000402// Format: ADDIU rx, pc, immediate MIPS16e
403// Purpose: Add Immediate Unsigned Word (3-Operand, PC-Relative, Extended)
404// To add a constant to the program counter.
405//
Akira Hatanaka22bec282012-08-03 22:57:02 +0000406def AddiuRxPcImmX16: FEXT_RI16_PC_ins<0b00001, "addiu", IIAlu>;
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000407//
408// Format: ADDU rz, rx, ry MIPS16e
409// Purpose: Add Unsigned Word (3-Operand)
410// To add 32-bit integers.
411//
412
Akira Hatanaka22bec282012-08-03 22:57:02 +0000413def AdduRxRyRz16: FRRR16_ins<01, "addu", IIAlu>, ArithLogic16Defs<1>;
414
415//
416// Format: AND rx, ry MIPS16e
417// Purpose: AND
418// To do a bitwise logical AND.
419
420def AndRxRxRy16: FRxRxRy16_ins<0b01100, "and", IIAlu>, ArithLogic16Defs<1>;
Reed Kotler67439242012-10-17 22:29:54 +0000421
422
423//
424// Format: BEQZ rx, offset MIPS16e
425// Purpose: Branch on Equal to Zero (Extended)
426// To test a GPR then do a PC-relative conditional branch.
427//
428def BeqzRxImmX16: FEXT_RI16_B_ins<0b00100, "beqz", IIAlu>, cbranch16;
429
430// Format: B offset MIPS16e
431// Purpose: Unconditional Branch
432// To do an unconditional PC-relative branch.
433//
434def BimmX16: FEXT_I16_ins<0b00010, "b", IIAlu>, branch16;
435
436//
437// Format: BNEZ rx, offset MIPS16e
438// Purpose: Branch on Not Equal to Zero (Extended)
439// To test a GPR then do a PC-relative conditional branch.
440//
441def BnezRxImmX16: FEXT_RI16_B_ins<0b00101, "bnez", IIAlu>, cbranch16;
442
443//
444// Format: BTEQZ offset MIPS16e
445// Purpose: Branch on T Equal to Zero (Extended)
446// To test special register T then do a PC-relative conditional branch.
447//
448def BteqzX16: FEXT_I816_ins<0b000, "bteqz", IIAlu>, cbranch16;
449
450def BteqzT8CmpX16: FEXT_T8I816_ins<0b000, "bteqz", "cmp", IIAlu>, cbranch16;
451
452def BteqzT8CmpiX16: FEXT_T8I8I16_ins<0b000, "bteqz", "cmpi", IIAlu>,
453 cbranch16;
454
455def BteqzT8SltX16: FEXT_T8I816_ins<0b000, "bteqz", "slt", IIAlu>, cbranch16;
456
457def BteqzT8SltuX16: FEXT_T8I816_ins<0b000, "bteqz", "sltu", IIAlu>, cbranch16;
458
459def BteqzT8SltiX16: FEXT_T8I8I16_ins<0b000, "bteqz", "slti", IIAlu>, cbranch16;
460
461def BteqzT8SltiuX16: FEXT_T8I8I16_ins<0b000, "bteqz", "sltiu", IIAlu>,
462 cbranch16;
463
464//
465// Format: BTNEZ offset MIPS16e
466// Purpose: Branch on T Not Equal to Zero (Extended)
467// To test special register T then do a PC-relative conditional branch.
468//
469def BtnezX16: FEXT_I816_ins<0b001, "btnez", IIAlu> ,cbranch16;
470
471def BtnezT8CmpX16: FEXT_T8I816_ins<0b000, "btnez", "cmp", IIAlu>, cbranch16;
472
473def BtnezT8CmpiX16: FEXT_T8I8I16_ins<0b000, "btnez", "cmpi", IIAlu>, cbranch16;
474
475def BtnezT8SltX16: FEXT_T8I816_ins<0b000, "btnez", "slt", IIAlu>, cbranch16;
476
477def BtnezT8SltuX16: FEXT_T8I816_ins<0b000, "btnez", "sltu", IIAlu>, cbranch16;
478
479def BtnezT8SltiX16: FEXT_T8I8I16_ins<0b000, "btnez", "slti", IIAlu>, cbranch16;
480
481def BtnezT8SltiuX16: FEXT_T8I8I16_ins<0b000, "btnez", "sltiu", IIAlu>,
482 cbranch16;
483
Reed Kotlercf11c592012-10-12 02:01:09 +0000484//
485// Format: DIV rx, ry MIPS16e
486// Purpose: Divide Word
487// To divide 32-bit signed integers.
488//
489def DivRxRy16: FRR16_div_ins<0b11010, "div", IIAlu> {
490 let Defs = [HI, LO];
491}
492
493//
494// Format: DIVU rx, ry MIPS16e
495// Purpose: Divide Unsigned Word
496// To divide 32-bit unsigned integers.
497//
498def DivuRxRy16: FRR16_div_ins<0b11011, "divu", IIAlu> {
499 let Defs = [HI, LO];
500}
501
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000502
503//
504// Format: JR ra MIPS16e
505// Purpose: Jump Register Through Register ra
506// To execute a branch to the instruction address in the return
507// address register.
508//
509
Reed Kotler3589dd72012-10-28 06:02:37 +0000510def JrRa16: FRR16_JALRC_RA_only_ins<0, 0, "jr", IIAlu> {
511 let isBranch = 1;
512 let isIndirectBranch = 1;
513 let hasDelaySlot = 1;
514 let isTerminator=1;
515 let isBarrier=1;
516}
Reed Kotlere6c31572012-10-28 23:08:07 +0000517
Reed Kotlera8117532012-10-30 00:54:49 +0000518def JrcRa16: FRR16_JALRC_RA_only_ins<0, 0, "jrc", IIAlu> {
519 let isBranch = 1;
520 let isIndirectBranch = 1;
521 let isTerminator=1;
522 let isBarrier=1;
523}
524
Reed Kotlere6c31572012-10-28 23:08:07 +0000525def JrcRx16: FRR16_JALRC_ins<1, 1, 0, "jrc", IIAlu> {
526 let isBranch = 1;
527 let isIndirectBranch = 1;
528 let isTerminator=1;
529 let isBarrier=1;
530}
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000531//
Akira Hatanaka22bec282012-08-03 22:57:02 +0000532// Format: LB ry, offset(rx) MIPS16e
533// Purpose: Load Byte (Extended)
534// To load a byte from memory as a signed value.
535//
Reed Kotler210ebe92012-09-28 02:26:24 +0000536def LbRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10011, "lb", mem16, IILoad>, MayLoad;
Akira Hatanaka22bec282012-08-03 22:57:02 +0000537
538//
539// Format: LBU ry, offset(rx) MIPS16e
540// Purpose: Load Byte Unsigned (Extended)
541// To load a byte from memory as a unsigned value.
542//
Reed Kotler210ebe92012-09-28 02:26:24 +0000543def LbuRxRyOffMemX16:
544 FEXT_RRI16_mem_ins<0b10100, "lbu", mem16, IILoad>, MayLoad;
Akira Hatanaka22bec282012-08-03 22:57:02 +0000545
546//
547// Format: LH ry, offset(rx) MIPS16e
548// Purpose: Load Halfword signed (Extended)
549// To load a halfword from memory as a signed value.
550//
Reed Kotler210ebe92012-09-28 02:26:24 +0000551def LhRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10100, "lh", mem16, IILoad>, MayLoad;
Akira Hatanaka22bec282012-08-03 22:57:02 +0000552
553//
554// Format: LHU ry, offset(rx) MIPS16e
555// Purpose: Load Halfword unsigned (Extended)
556// To load a halfword from memory as an unsigned value.
557//
Reed Kotler210ebe92012-09-28 02:26:24 +0000558def LhuRxRyOffMemX16:
559 FEXT_RRI16_mem_ins<0b10100, "lhu", mem16, IILoad>, MayLoad;
Akira Hatanaka22bec282012-08-03 22:57:02 +0000560
561//
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000562// Format: LI rx, immediate MIPS16e
563// Purpose: Load Immediate (Extended)
564// To load a constant into a GPR.
565//
566def LiRxImmX16: FEXT_RI16_ins<0b01101, "li", IIAlu>;
567
568//
569// Format: LW ry, offset(rx) MIPS16e
570// Purpose: Load Word (Extended)
571// To load a word from memory as a signed value.
572//
Reed Kotler210ebe92012-09-28 02:26:24 +0000573def LwRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10011, "lw", mem16, IILoad>, MayLoad;
574
575// Format: LW rx, offset(sp) MIPS16e
576// Purpose: Load Word (SP-Relative, Extended)
577// To load an SP-relative word from memory as a signed value.
578//
579def LwRxSpImmX16: FEXT_RI16_SP_explicit_ins<0b10110, "lw", IILoad>, MayLoad;
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000580
581//
582// Format: MOVE r32, rz MIPS16e
583// Purpose: Move
584// To move the contents of a GPR to a GPR.
585//
Akira Hatanaka0fbaec22012-09-14 03:21:56 +0000586def Move32R16: FI8_MOV32R16_ins<"move", IIAlu>;
587
588//
589// Format: MOVE ry, r32 MIPS16e
590//Purpose: Move
591// To move the contents of a GPR to a GPR.
592//
593def MoveR3216: FI8_MOVR3216_ins<"move", IIAlu>;
Akira Hatanaka22bec282012-08-03 22:57:02 +0000594
595//
Reed Kotler24032212012-10-05 18:27:54 +0000596// Format: MFHI rx MIPS16e
597// Purpose: Move From HI Register
598// To copy the special purpose HI register to a GPR.
599//
600def Mfhi16: FRR16_M_ins<0b10000, "mfhi", IIAlu> {
601 let Uses = [HI];
602 let neverHasSideEffects = 1;
603}
604
605//
606// Format: MFLO rx MIPS16e
607// Purpose: Move From LO Register
608// To copy the special purpose LO register to a GPR.
609//
610def Mflo16: FRR16_M_ins<0b10010, "mflo", IIAlu> {
611 let Uses = [LO];
612 let neverHasSideEffects = 1;
613}
614
615//
616// Pseudo Instruction for mult
617//
618def MultRxRy16: FMULT16_ins<"mult", IIAlu> {
619 let isCommutable = 1;
620 let neverHasSideEffects = 1;
621 let Defs = [HI, LO];
622}
623
624def MultuRxRy16: FMULT16_ins<"multu", IIAlu> {
625 let isCommutable = 1;
626 let neverHasSideEffects = 1;
627 let Defs = [HI, LO];
628}
629
630//
631// Format: MULT rx, ry MIPS16e
632// Purpose: Multiply Word
633// To multiply 32-bit signed integers.
634//
635def MultRxRyRz16: FMULT16_LO_ins<"mult", IIAlu> {
636 let isCommutable = 1;
637 let neverHasSideEffects = 1;
638 let Defs = [HI, LO];
639}
640
641//
642// Format: MULTU rx, ry MIPS16e
643// Purpose: Multiply Unsigned Word
644// To multiply 32-bit unsigned integers.
645//
646def MultuRxRyRz16: FMULT16_LO_ins<"multu", IIAlu> {
647 let isCommutable = 1;
648 let neverHasSideEffects = 1;
649 let Defs = [HI, LO];
650}
651
652//
Akira Hatanaka22bec282012-08-03 22:57:02 +0000653// Format: NEG rx, ry MIPS16e
654// Purpose: Negate
655// To negate an integer value.
656//
Reed Kotler4e1c6292012-10-26 16:18:19 +0000657def NegRxRy16: FUnaryRR16_ins<0b11101, "neg", IIAlu>;
Akira Hatanaka22bec282012-08-03 22:57:02 +0000658
659//
660// Format: NOT rx, ry MIPS16e
661// Purpose: Not
662// To complement an integer value
663//
Reed Kotler4e1c6292012-10-26 16:18:19 +0000664def NotRxRy16: FUnaryRR16_ins<0b01111, "not", IIAlu>;
Akira Hatanaka22bec282012-08-03 22:57:02 +0000665
666//
667// Format: OR rx, ry MIPS16e
668// Purpose: Or
669// To do a bitwise logical OR.
670//
671def OrRxRxRy16: FRxRxRy16_ins<0b01101, "or", IIAlu>, ArithLogic16Defs<1>;
672
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000673//
674// Format: RESTORE {ra,}{s0/s1/s0-1,}{framesize}
675// (All args are optional) MIPS16e
676// Purpose: Restore Registers and Deallocate Stack Frame
677// To deallocate a stack frame before exit from a subroutine,
678// restoring return address and static registers, and adjusting
679// stack
680//
681
682// fixed form for restoring RA and the frame
683// for direct object emitter, encoding needs to be adjusted for the
684// frame size
685//
Akira Hatanakacd04e2b2012-09-21 01:08:16 +0000686let ra=1, s=0,s0=1,s1=1 in
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000687def RestoreRaF16:
688 FI8_SVRS16<0b1, (outs), (ins uimm16:$frame_size),
Reed Kotler210ebe92012-09-28 02:26:24 +0000689 "restore \t$$ra, $$s0, $$s1, $frame_size", [], IILoad >, MayLoad {
Akira Hatanakacd04e2b2012-09-21 01:08:16 +0000690 let isCodeGenOnly = 1;
691}
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000692
693//
694// Format: SAVE {ra,}{s0/s1/s0-1,}{framesize} (All arguments are optional)
695// MIPS16e
696// Purpose: Save Registers and Set Up Stack Frame
697// To set up a stack frame on entry to a subroutine,
698// saving return address and static registers, and adjusting stack
699//
Akira Hatanakacd04e2b2012-09-21 01:08:16 +0000700let ra=1, s=1,s0=1,s1=1 in
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000701def SaveRaF16:
702 FI8_SVRS16<0b1, (outs), (ins uimm16:$frame_size),
Reed Kotler210ebe92012-09-28 02:26:24 +0000703 "save \t$$ra, $$s0, $$s1, $frame_size", [], IIStore >, MayStore {
Akira Hatanakacd04e2b2012-09-21 01:08:16 +0000704 let isCodeGenOnly = 1;
705}
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000706//
Akira Hatanaka22bec282012-08-03 22:57:02 +0000707// Format: SB ry, offset(rx) MIPS16e
708// Purpose: Store Byte (Extended)
709// To store a byte to memory.
710//
Reed Kotler210ebe92012-09-28 02:26:24 +0000711def SbRxRyOffMemX16:
712 FEXT_RRI16_mem2_ins<0b11000, "sb", mem16, IIStore>, MayStore;
Akira Hatanaka22bec282012-08-03 22:57:02 +0000713
714//
Reed Kotler097556d2012-10-25 21:33:30 +0000715// The Sel(T) instructions are pseudos
716// T means that they use T8 implicitly.
717//
718//
719// Format: SelBeqZ rd, rs, rt
720// Purpose: if rt==0, do nothing
721// else rs = rt
722//
723def SelBeqZ: Sel<0b00100, "beqz", IIAlu>;
724
725//
726// Format: SelTBteqZCmp rd, rs, rl, rr
727// Purpose: b = Cmp rl, rr.
728// If b==0 then do nothing.
729// if b!=0 then rd = rs
730//
731def SelTBteqZCmp: SelT<0b000, "bteqz", 0b01010, "cmp", IIAlu>;
732
733//
734// Format: SelTBteqZCmpi rd, rs, rl, rr
735// Purpose: b = Cmpi rl, imm.
736// If b==0 then do nothing.
737// if b!=0 then rd = rs
738//
739def SelTBteqZCmpi: SeliT<0b000, "bteqz", 0b01110, "cmpi", IIAlu>;
740
741//
742// Format: SelTBteqZSlt rd, rs, rl, rr
743// Purpose: b = Slt rl, rr.
744// If b==0 then do nothing.
745// if b!=0 then rd = rs
746//
747def SelTBteqZSlt: SelT<0b000, "bteqz", 0b00010, "slt", IIAlu>;
748
749//
750// Format: SelTBteqZSlti rd, rs, rl, rr
751// Purpose: b = Slti rl, imm.
752// If b==0 then do nothing.
753// if b!=0 then rd = rs
754//
755def SelTBteqZSlti: SeliT<0b000, "bteqz", 0b01010, "slti", IIAlu>;
756
757//
758// Format: SelTBteqZSltu rd, rs, rl, rr
759// Purpose: b = Sltu rl, rr.
760// If b==0 then do nothing.
761// if b!=0 then rd = rs
762//
763def SelTBteqZSltu: SelT<0b000, "bteqz", 0b00011, "sltu", IIAlu>;
764
765//
766// Format: SelTBteqZSltiu rd, rs, rl, rr
767// Purpose: b = Sltiu rl, imm.
768// If b==0 then do nothing.
769// if b!=0 then rd = rs
770//
771def SelTBteqZSltiu: SeliT<0b000, "bteqz", 0b01011, "sltiu", IIAlu>;
772
773//
774// Format: SelBnez rd, rs, rt
775// Purpose: if rt!=0, do nothing
776// else rs = rt
777//
778def SelBneZ: Sel<0b00101, "bnez", IIAlu>;
779
780//
781// Format: SelTBtneZCmp rd, rs, rl, rr
782// Purpose: b = Cmp rl, rr.
783// If b!=0 then do nothing.
784// if b0=0 then rd = rs
785//
786def SelTBtneZCmp: SelT<0b001, "btnez", 0b01010, "cmp", IIAlu>;
787
788//
789// Format: SelTBtnezCmpi rd, rs, rl, rr
790// Purpose: b = Cmpi rl, imm.
791// If b!=0 then do nothing.
792// if b==0 then rd = rs
793//
794def SelTBtneZCmpi: SeliT<0b000, "btnez", 0b01110, "cmpi", IIAlu>;
795
796//
797// Format: SelTBtneZSlt rd, rs, rl, rr
798// Purpose: b = Slt rl, rr.
799// If b!=0 then do nothing.
800// if b==0 then rd = rs
801//
802def SelTBtneZSlt: SelT<0b001, "btnez", 0b00010, "slt", IIAlu>;
803
804//
805// Format: SelTBtneZSlti rd, rs, rl, rr
806// Purpose: b = Slti rl, imm.
807// If b!=0 then do nothing.
808// if b==0 then rd = rs
809//
810def SelTBtneZSlti: SeliT<0b001, "btnez", 0b01010, "slti", IIAlu>;
811
812//
813// Format: SelTBtneZSltu rd, rs, rl, rr
814// Purpose: b = Sltu rl, rr.
815// If b!=0 then do nothing.
816// if b==0 then rd = rs
817//
818def SelTBtneZSltu: SelT<0b001, "btnez", 0b00011, "sltu", IIAlu>;
819
820//
821// Format: SelTBtneZSltiu rd, rs, rl, rr
822// Purpose: b = Slti rl, imm.
823// If b!=0 then do nothing.
824// if b==0 then rd = rs
825//
826def SelTBtneZSltiu: SeliT<0b001, "btnez", 0b01011, "sltiu", IIAlu>;
827//
828//
Akira Hatanaka22bec282012-08-03 22:57:02 +0000829// Format: SH ry, offset(rx) MIPS16e
830// Purpose: Store Halfword (Extended)
831// To store a halfword to memory.
832//
Reed Kotler210ebe92012-09-28 02:26:24 +0000833def ShRxRyOffMemX16:
834 FEXT_RRI16_mem2_ins<0b11001, "sh", mem16, IIStore>, MayStore;
Akira Hatanaka22bec282012-08-03 22:57:02 +0000835
836//
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000837// Format: SLL rx, ry, sa MIPS16e
838// Purpose: Shift Word Left Logical (Extended)
839// To execute a left-shift of a word by a fixed number of bits—0 to 31 bits.
840//
841def SllX16: FEXT_SHIFT16_ins<0b00, "sll", IIAlu>;
842
843//
Akira Hatanaka22bec282012-08-03 22:57:02 +0000844// Format: SLLV ry, rx MIPS16e
845// Purpose: Shift Word Left Logical Variable
846// To execute a left-shift of a word by a variable number of bits.
847//
848def SllvRxRy16 : FRxRxRy16_ins<0b00100, "sllv", IIAlu>;
849
Reed Kotler164bb372012-10-23 01:35:48 +0000850//
851// Format: SLTI rx, immediate MIPS16e
852// Purpose: Set on Less Than Immediate (Extended)
853// To record the result of a less-than comparison with a constant.
854//
855def SltiCCRxImmX16: FEXT_CCRXI16_ins<0b01010, "slti", IIAlu>;
Akira Hatanaka22bec282012-08-03 22:57:02 +0000856
857//
Reed Kotler164bb372012-10-23 01:35:48 +0000858// Format: SLTIU rx, immediate MIPS16e
859// Purpose: Set on Less Than Immediate Unsigned (Extended)
860// To record the result of a less-than comparison with a constant.
861//
862def SltiuCCRxImmX16: FEXT_CCRXI16_ins<0b01011, "sltiu", IIAlu>;
863
864//
865// Format: SLT rx, ry MIPS16e
866// Purpose: Set on Less Than
867// To record the result of a less-than comparison.
868//
869def SltRxRy16: FRR16_ins<0b00010, "slt", IIAlu>;
870
871def SltCCRxRy16: FCCRR16_ins<0b00010, "slt", IIAlu>;
872
873// Format: SLTU rx, ry MIPS16e
874// Purpose: Set on Less Than Unsigned
875// To record the result of an unsigned less-than comparison.
876//
Reed Kotler287f0442012-10-26 04:46:26 +0000877def SltuRxRyRz16: FRRTR16_ins<0b00011, "sltu", IIAlu> {
878 let isCodeGenOnly=1;
879}
Reed Kotler164bb372012-10-23 01:35:48 +0000880
881
882def SltuCCRxRy16: FCCRR16_ins<0b00011, "sltu", IIAlu>;
883//
Akira Hatanaka22bec282012-08-03 22:57:02 +0000884// Format: SRAV ry, rx MIPS16e
885// Purpose: Shift Word Right Arithmetic Variable
886// To execute an arithmetic right-shift of a word by a variable
887// number of bits.
888//
889def SravRxRy16: FRxRxRy16_ins<0b00111, "srav", IIAlu>;
890
891
892//
893// Format: SRA rx, ry, sa MIPS16e
894// Purpose: Shift Word Right Arithmetic (Extended)
895// To execute an arithmetic right-shift of a word by a fixed
896// number of bits—1 to 8 bits.
897//
898def SraX16: FEXT_SHIFT16_ins<0b11, "sra", IIAlu>;
899
900
901//
902// Format: SRLV ry, rx MIPS16e
903// Purpose: Shift Word Right Logical Variable
904// To execute a logical right-shift of a word by a variable
905// number of bits.
906//
907def SrlvRxRy16: FRxRxRy16_ins<0b00110, "srlv", IIAlu>;
908
909
910//
911// Format: SRL rx, ry, sa MIPS16e
912// Purpose: Shift Word Right Logical (Extended)
913// To execute a logical right-shift of a word by a fixed
914// number of bits—1 to 31 bits.
915//
916def SrlX16: FEXT_SHIFT16_ins<0b10, "srl", IIAlu>;
917
918//
919// Format: SUBU rz, rx, ry MIPS16e
920// Purpose: Subtract Unsigned Word
921// To subtract 32-bit integers
922//
923def SubuRxRyRz16: FRRR16_ins<0b11, "subu", IIAlu>, ArithLogic16Defs<0>;
924
925//
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000926// Format: SW ry, offset(rx) MIPS16e
927// Purpose: Store Word (Extended)
928// To store a word to memory.
929//
Reed Kotler210ebe92012-09-28 02:26:24 +0000930def SwRxRyOffMemX16:
931 FEXT_RRI16_mem2_ins<0b11011, "sw", mem16, IIStore>, MayStore;
Akira Hatanaka22bec282012-08-03 22:57:02 +0000932
933//
Reed Kotler210ebe92012-09-28 02:26:24 +0000934// Format: SW rx, offset(sp) MIPS16e
935// Purpose: Store Word rx (SP-Relative)
936// To store an SP-relative word to memory.
937//
938def SwRxSpImmX16: FEXT_RI16_SP_explicit_ins<0b11010, "sw", IIStore>, MayStore;
939
940//
941//
Akira Hatanaka22bec282012-08-03 22:57:02 +0000942// Format: XOR rx, ry MIPS16e
943// Purpose: Xor
944// To do a bitwise logical XOR.
945//
946def XorRxRxRy16: FRxRxRy16_ins<0b01110, "xor", IIAlu>, ArithLogic16Defs<1>;
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000947
Akira Hatanaka765c3122012-06-21 20:39:10 +0000948class Mips16Pat<dag pattern, dag result> : Pat<pattern, result> {
949 let Predicates = [InMips16Mode];
950}
951
Akira Hatanaka22bec282012-08-03 22:57:02 +0000952// Unary Arith/Logic
953//
954class ArithLogicU_pat<PatFrag OpNode, Instruction I> :
955 Mips16Pat<(OpNode CPU16Regs:$r),
956 (I CPU16Regs:$r)>;
Akira Hatanakabff8e312012-05-31 02:59:44 +0000957
Akira Hatanaka22bec282012-08-03 22:57:02 +0000958def: ArithLogicU_pat<not, NotRxRy16>;
959def: ArithLogicU_pat<ineg, NegRxRy16>;
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000960
Akira Hatanaka22bec282012-08-03 22:57:02 +0000961class ArithLogic16_pat<SDNode OpNode, Instruction I> :
962 Mips16Pat<(OpNode CPU16Regs:$l, CPU16Regs:$r),
963 (I CPU16Regs:$l, CPU16Regs:$r)>;
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000964
Akira Hatanaka22bec282012-08-03 22:57:02 +0000965def: ArithLogic16_pat<add, AdduRxRyRz16>;
966def: ArithLogic16_pat<and, AndRxRxRy16>;
Reed Kotler24032212012-10-05 18:27:54 +0000967def: ArithLogic16_pat<mul, MultRxRyRz16>;
Akira Hatanaka22bec282012-08-03 22:57:02 +0000968def: ArithLogic16_pat<or, OrRxRxRy16>;
969def: ArithLogic16_pat<sub, SubuRxRyRz16>;
970def: ArithLogic16_pat<xor, XorRxRxRy16>;
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000971
Akira Hatanaka22bec282012-08-03 22:57:02 +0000972// Arithmetic and logical instructions with 2 register operands.
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000973
Akira Hatanaka22bec282012-08-03 22:57:02 +0000974class ArithLogicI16_pat<SDNode OpNode, PatFrag imm_type, Instruction I> :
975 Mips16Pat<(OpNode CPU16Regs:$in, imm_type:$imm),
976 (I CPU16Regs:$in, imm_type:$imm)>;
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000977
Akira Hatanaka22bec282012-08-03 22:57:02 +0000978def: ArithLogicI16_pat<add, immSExt16, AddiuRxRxImmX16>;
979def: ArithLogicI16_pat<shl, immZExt5, SllX16>;
980def: ArithLogicI16_pat<srl, immZExt5, SrlX16>;
981def: ArithLogicI16_pat<sra, immZExt5, SraX16>;
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000982
Akira Hatanaka22bec282012-08-03 22:57:02 +0000983class shift_rotate_reg16_pat<SDNode OpNode, Instruction I> :
984 Mips16Pat<(OpNode CPU16Regs:$r, CPU16Regs:$ra),
985 (I CPU16Regs:$r, CPU16Regs:$ra)>;
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +0000986
Akira Hatanaka22bec282012-08-03 22:57:02 +0000987def: shift_rotate_reg16_pat<shl, SllvRxRy16>;
988def: shift_rotate_reg16_pat<sra, SravRxRy16>;
989def: shift_rotate_reg16_pat<srl, SrlvRxRy16>;
990
991class LoadM16_pat<PatFrag OpNode, Instruction I> :
Reed Kotler3589dd72012-10-28 06:02:37 +0000992 Mips16Pat<(OpNode addr16:$addr), (I addr16:$addr)>;
Akira Hatanaka22bec282012-08-03 22:57:02 +0000993
994def: LoadM16_pat<sextloadi8, LbRxRyOffMemX16>;
995def: LoadM16_pat<zextloadi8, LbuRxRyOffMemX16>;
Akira Hatanaka3e7ba762012-09-15 01:52:08 +0000996def: LoadM16_pat<sextloadi16, LhRxRyOffMemX16>;
997def: LoadM16_pat<zextloadi16, LhuRxRyOffMemX16>;
998def: LoadM16_pat<load, LwRxRyOffMemX16>;
Akira Hatanaka22bec282012-08-03 22:57:02 +0000999
1000class StoreM16_pat<PatFrag OpNode, Instruction I> :
Reed Kotler3589dd72012-10-28 06:02:37 +00001001 Mips16Pat<(OpNode CPU16Regs:$r, addr16:$addr),
1002 (I CPU16Regs:$r, addr16:$addr)>;
Akira Hatanaka22bec282012-08-03 22:57:02 +00001003
1004def: StoreM16_pat<truncstorei8, SbRxRyOffMemX16>;
Akira Hatanaka3e7ba762012-09-15 01:52:08 +00001005def: StoreM16_pat<truncstorei16, ShRxRyOffMemX16>;
1006def: StoreM16_pat<store, SwRxRyOffMemX16>;
Akira Hatanaka22bec282012-08-03 22:57:02 +00001007
Reed Kotler67439242012-10-17 22:29:54 +00001008// Unconditional branch
1009class UncondBranch16_pat<SDNode OpNode, Instruction I>:
1010 Mips16Pat<(OpNode bb:$imm16), (I bb:$imm16)> {
1011 let Predicates = [RelocPIC, InMips16Mode];
1012 }
Akira Hatanakabff8e312012-05-31 02:59:44 +00001013
Reed Kotlere6c31572012-10-28 23:08:07 +00001014// Indirect branch
1015def: Mips16Pat<
1016 (brind CPU16Regs:$rs),
1017 (JrcRx16 CPU16Regs:$rs)>;
1018
1019
Akira Hatanakabff8e312012-05-31 02:59:44 +00001020// Jump and Link (Call)
Reed Kotlera8117532012-10-30 00:54:49 +00001021let isCall=1, hasDelaySlot=0 in
Akira Hatanakabff8e312012-05-31 02:59:44 +00001022def JumpLinkReg16:
Akira Hatanakaf640f042012-07-17 22:55:34 +00001023 FRR16_JALRC<0, 0, 0, (outs), (ins CPU16Regs:$rs),
Reed Kotlera8117532012-10-30 00:54:49 +00001024 "jalrc \t$rs", [(MipsJmpLink CPU16Regs:$rs)], IIBranch>;
Akira Hatanakaf640f042012-07-17 22:55:34 +00001025
Akira Hatanaka26e9ecb2012-07-23 23:45:54 +00001026// Mips16 pseudos
1027let isReturn=1, isTerminator=1, hasDelaySlot=1, isBarrier=1, hasCtrlDep=1,
1028 hasExtraSrcRegAllocReq = 1 in
1029def RetRA16 : MipsPseudo16<(outs), (ins), "", [(MipsRet)]>;
1030
Reed Kotler67439242012-10-17 22:29:54 +00001031
Reed Kotler164bb372012-10-23 01:35:48 +00001032// setcc patterns
1033
1034class SetCC_R16<PatFrag cond_op, Instruction I>:
1035 Mips16Pat<(cond_op CPU16Regs:$rx, CPU16Regs:$ry),
1036 (I CPU16Regs:$rx, CPU16Regs:$ry)>;
1037
1038class SetCC_I16<PatFrag cond_op, PatLeaf imm_type, Instruction I>:
1039 Mips16Pat<(cond_op CPU16Regs:$rx, imm_type:$imm16),
Reed Kotler097556d2012-10-25 21:33:30 +00001040 (I CPU16Regs:$rx, imm_type:$imm16)>;
Reed Kotler164bb372012-10-23 01:35:48 +00001041
Reed Kotler3589dd72012-10-28 06:02:37 +00001042
1043def: Mips16Pat<(i32 addr16:$addr),
1044 (AddiuRxRyOffMemX16 addr16:$addr)>;
1045
1046
Reed Kotlere47873a2012-10-26 03:09:34 +00001047// Large (>16 bit) immediate loads
1048def : Mips16Pat<(i32 imm:$imm),
1049 (OrRxRxRy16 (SllX16 (LiRxImmX16 (HI16 imm:$imm)), 16),
1050 (LiRxImmX16 (LO16 imm:$imm)))>;
Reed Kotler164bb372012-10-23 01:35:48 +00001051
Reed Kotler287f0442012-10-26 04:46:26 +00001052// Carry MipsPatterns
1053def : Mips16Pat<(subc CPU16Regs:$lhs, CPU16Regs:$rhs),
1054 (SubuRxRyRz16 CPU16Regs:$lhs, CPU16Regs:$rhs)>;
1055def : Mips16Pat<(addc CPU16Regs:$lhs, CPU16Regs:$rhs),
1056 (AdduRxRyRz16 CPU16Regs:$lhs, CPU16Regs:$rhs)>;
1057def : Mips16Pat<(addc CPU16Regs:$src, immSExt16:$imm),
1058 (AddiuRxRxImmX16 CPU16Regs:$src, imm:$imm)>;
1059
Reed Kotler67439242012-10-17 22:29:54 +00001060//
1061// Some branch conditional patterns are not generated by llvm at this time.
1062// Some are for seemingly arbitrary reasons not used: i.e. with signed number
1063// comparison they are used and for unsigned a different pattern is used.
1064// I am pushing upstream from the full mips16 port and it seemed that I needed
1065// these earlier and the mips32 port has these but now I cannot create test
1066// cases that use these patterns. While I sort this all out I will leave these
1067// extra patterns commented out and if I can be sure they are really not used,
1068// I will delete the code. I don't want to check the code in uncommented without
1069// a valid test case. In some cases, the compiler is generating patterns with
1070// setcc instead and earlier I had implemented setcc first so may have masked
1071// the problem. The setcc variants are suboptimal for mips16 so I may wantto
1072// figure out how to enable the brcond patterns or else possibly new
1073// combinations of of brcond and setcc.
1074//
1075//
1076// bcond-seteq
1077//
1078def: Mips16Pat
1079 <(brcond (i32 (seteq CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
1080 (BteqzT8CmpX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16)
1081 >;
1082
1083
1084def: Mips16Pat
1085 <(brcond (i32 (seteq CPU16Regs:$rx, immZExt16:$imm)), bb:$targ16),
1086 (BteqzT8CmpiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$targ16)
1087 >;
1088
1089def: Mips16Pat
1090 <(brcond (i32 (seteq CPU16Regs:$rx, 0)), bb:$targ16),
1091 (BeqzRxImmX16 CPU16Regs:$rx, bb:$targ16)
1092 >;
1093
1094//
1095// bcond-setgt (do we need to have this pair of setlt, setgt??)
1096//
1097def: Mips16Pat
1098 <(brcond (i32 (setgt CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
1099 (BtnezT8SltX16 CPU16Regs:$ry, CPU16Regs:$rx, bb:$imm16)
1100 >;
1101
1102//
1103// bcond-setge
1104//
1105def: Mips16Pat
1106 <(brcond (i32 (setge CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
1107 (BteqzT8SltX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16)
1108 >;
1109
1110//
1111// never called because compiler transforms a >= k to a > (k-1)
Reed Kotler164bb372012-10-23 01:35:48 +00001112def: Mips16Pat
1113 <(brcond (i32 (setge CPU16Regs:$rx, immSExt16:$imm)), bb:$imm16),
1114 (BteqzT8SltiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$imm16)
1115 >;
Reed Kotler67439242012-10-17 22:29:54 +00001116
1117//
1118// bcond-setlt
1119//
1120def: Mips16Pat
1121 <(brcond (i32 (setlt CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
1122 (BtnezT8SltX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16)
1123 >;
1124
1125def: Mips16Pat
1126 <(brcond (i32 (setlt CPU16Regs:$rx, immSExt16:$imm)), bb:$imm16),
1127 (BtnezT8SltiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$imm16)
1128 >;
1129
1130//
1131// bcond-setle
1132//
1133def: Mips16Pat
1134 <(brcond (i32 (setle CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
1135 (BteqzT8SltX16 CPU16Regs:$ry, CPU16Regs:$rx, bb:$imm16)
1136 >;
1137
1138//
1139// bcond-setne
1140//
1141def: Mips16Pat
1142 <(brcond (i32 (setne CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
1143 (BtnezT8CmpX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16)
1144 >;
1145
1146def: Mips16Pat
1147 <(brcond (i32 (setne CPU16Regs:$rx, immZExt16:$imm)), bb:$targ16),
1148 (BtnezT8CmpiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$targ16)
1149 >;
1150
1151def: Mips16Pat
1152 <(brcond (i32 (setne CPU16Regs:$rx, 0)), bb:$targ16),
1153 (BnezRxImmX16 CPU16Regs:$rx, bb:$targ16)
1154 >;
1155
1156//
1157// This needs to be there but I forget which code will generate it
1158//
1159def: Mips16Pat
1160 <(brcond CPU16Regs:$rx, bb:$targ16),
1161 (BnezRxImmX16 CPU16Regs:$rx, bb:$targ16)
1162 >;
1163
1164//
1165
1166//
1167// bcond-setugt
1168//
1169//def: Mips16Pat
1170// <(brcond (i32 (setugt CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
1171// (BtnezT8SltuX16 CPU16Regs:$ry, CPU16Regs:$rx, bb:$imm16)
1172// >;
1173
1174//
1175// bcond-setuge
1176//
1177//def: Mips16Pat
1178// <(brcond (i32 (setuge CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
1179// (BteqzT8SltuX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16)
1180// >;
1181
1182
1183//
1184// bcond-setult
1185//
1186//def: Mips16Pat
1187// <(brcond (i32 (setult CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
1188// (BtnezT8SltuX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16)
1189// >;
1190
1191def: UncondBranch16_pat<br, BimmX16>;
1192
Akira Hatanaka765c3122012-06-21 20:39:10 +00001193// Small immediates
Reed Kotler67439242012-10-17 22:29:54 +00001194def: Mips16Pat<(i32 immSExt16:$in),
1195 (AddiuRxRxImmX16 (Move32R16 ZERO), immSExt16:$in)>;
1196
Akira Hatanaka22bec282012-08-03 22:57:02 +00001197def: Mips16Pat<(i32 immZExt16:$in), (LiRxImmX16 immZExt16:$in)>;
Akira Hatanaka64626fc2012-07-26 02:24:43 +00001198
Reed Kotlercf11c592012-10-12 02:01:09 +00001199//
1200// MipsDivRem
1201//
1202def: Mips16Pat
1203 <(MipsDivRem CPU16Regs:$rx, CPU16Regs:$ry),
1204 (DivRxRy16 CPU16Regs:$rx, CPU16Regs:$ry)>;
1205
1206//
1207// MipsDivRemU
1208//
1209def: Mips16Pat
1210 <(MipsDivRemU CPU16Regs:$rx, CPU16Regs:$ry),
1211 (DivuRxRy16 CPU16Regs:$rx, CPU16Regs:$ry)>;
1212
Reed Kotler097556d2012-10-25 21:33:30 +00001213// signed a,b
1214// x = (a>=b)?x:y
1215//
1216// if !(a < b) x = y
1217//
1218def : Mips16Pat<(select (i32 (setge CPU16Regs:$a, CPU16Regs:$b)),
1219 CPU16Regs:$x, CPU16Regs:$y),
1220 (SelTBteqZSlt CPU16Regs:$x, CPU16Regs:$y,
1221 CPU16Regs:$a, CPU16Regs:$b)>;
1222
1223// signed a,b
1224// x = (a>b)?x:y
1225//
1226// if (b < a) x = y
1227//
1228def : Mips16Pat<(select (i32 (setgt CPU16Regs:$a, CPU16Regs:$b)),
1229 CPU16Regs:$x, CPU16Regs:$y),
1230 (SelTBtneZSlt CPU16Regs:$x, CPU16Regs:$y,
1231 CPU16Regs:$b, CPU16Regs:$a)>;
1232
1233// unsigned a,b
1234// x = (a>=b)?x:y
1235//
1236// if !(a < b) x = y;
1237//
1238def : Mips16Pat<
1239 (select (i32 (setuge CPU16Regs:$a, CPU16Regs:$b)),
1240 CPU16Regs:$x, CPU16Regs:$y),
1241 (SelTBteqZSltu CPU16Regs:$x, CPU16Regs:$y,
1242 CPU16Regs:$a, CPU16Regs:$b)>;
1243
1244// unsigned a,b
1245// x = (a>b)?x:y
1246//
1247// if (b < a) x = y
1248//
1249def : Mips16Pat<(select (i32 (setugt CPU16Regs:$a, CPU16Regs:$b)),
1250 CPU16Regs:$x, CPU16Regs:$y),
1251 (SelTBtneZSltu CPU16Regs:$x, CPU16Regs:$y,
1252 CPU16Regs:$b, CPU16Regs:$a)>;
1253
1254// signed
1255// x = (a >= k)?x:y
1256// due to an llvm optimization, i don't think that this will ever
1257// be used. This is transformed into x = (a > k-1)?x:y
1258//
1259//
1260
1261//def : Mips16Pat<
1262// (select (i32 (setge CPU16Regs:$lhs, immSExt16:$rhs)),
1263// CPU16Regs:$T, CPU16Regs:$F),
1264// (SelTBteqZSlti CPU16Regs:$T, CPU16Regs:$F,
1265// CPU16Regs:$lhs, immSExt16:$rhs)>;
1266
1267//def : Mips16Pat<
1268// (select (i32 (setuge CPU16Regs:$lhs, immSExt16:$rhs)),
1269// CPU16Regs:$T, CPU16Regs:$F),
1270// (SelTBteqZSltiu CPU16Regs:$T, CPU16Regs:$F,
1271// CPU16Regs:$lhs, immSExt16:$rhs)>;
1272
1273// signed
1274// x = (a < k)?x:y
1275//
1276// if !(a < k) x = y;
1277//
1278def : Mips16Pat<
1279 (select (i32 (setlt CPU16Regs:$a, immSExt16:$b)),
1280 CPU16Regs:$x, CPU16Regs:$y),
1281 (SelTBtneZSlti CPU16Regs:$x, CPU16Regs:$y,
1282 CPU16Regs:$a, immSExt16:$b)>;
1283
1284
1285//
1286//
1287// signed
1288// x = (a <= b)? x : y
1289//
1290// if (b < a) x = y
1291//
1292def : Mips16Pat<(select (i32 (setle CPU16Regs:$a, CPU16Regs:$b)),
1293 CPU16Regs:$x, CPU16Regs:$y),
1294 (SelTBteqZSlt CPU16Regs:$x, CPU16Regs:$y,
1295 CPU16Regs:$b, CPU16Regs:$a)>;
1296
1297//
1298// unnsigned
1299// x = (a <= b)? x : y
1300//
1301// if (b < a) x = y
1302//
1303def : Mips16Pat<(select (i32 (setule CPU16Regs:$a, CPU16Regs:$b)),
1304 CPU16Regs:$x, CPU16Regs:$y),
1305 (SelTBteqZSltu CPU16Regs:$x, CPU16Regs:$y,
1306 CPU16Regs:$b, CPU16Regs:$a)>;
1307
1308//
1309// signed/unsigned
1310// x = (a == b)? x : y
1311//
1312// if (a != b) x = y
1313//
1314def : Mips16Pat<(select (i32 (seteq CPU16Regs:$a, CPU16Regs:$b)),
1315 CPU16Regs:$x, CPU16Regs:$y),
1316 (SelTBteqZCmp CPU16Regs:$x, CPU16Regs:$y,
1317 CPU16Regs:$b, CPU16Regs:$a)>;
1318
1319//
1320// signed/unsigned
1321// x = (a == 0)? x : y
1322//
1323// if (a != 0) x = y
1324//
1325def : Mips16Pat<(select (i32 (seteq CPU16Regs:$a, 0)),
1326 CPU16Regs:$x, CPU16Regs:$y),
1327 (SelBeqZ CPU16Regs:$x, CPU16Regs:$y,
1328 CPU16Regs:$a)>;
1329
1330
1331//
1332// signed/unsigned
1333// x = (a == k)? x : y
1334//
1335// if (a != k) x = y
1336//
1337def : Mips16Pat<(select (i32 (seteq CPU16Regs:$a, immZExt16:$k)),
1338 CPU16Regs:$x, CPU16Regs:$y),
1339 (SelTBteqZCmpi CPU16Regs:$x, CPU16Regs:$y,
1340 CPU16Regs:$a, immZExt16:$k)>;
1341
1342
1343//
1344// signed/unsigned
1345// x = (a != b)? x : y
1346//
1347// if (a == b) x = y
1348//
1349//
1350def : Mips16Pat<(select (i32 (setne CPU16Regs:$a, CPU16Regs:$b)),
1351 CPU16Regs:$x, CPU16Regs:$y),
1352 (SelTBtneZCmp CPU16Regs:$x, CPU16Regs:$y,
1353 CPU16Regs:$b, CPU16Regs:$a)>;
1354
1355//
1356// signed/unsigned
1357// x = (a != 0)? x : y
1358//
1359// if (a == 0) x = y
1360//
1361def : Mips16Pat<(select (i32 (setne CPU16Regs:$a, 0)),
1362 CPU16Regs:$x, CPU16Regs:$y),
1363 (SelBneZ CPU16Regs:$x, CPU16Regs:$y,
1364 CPU16Regs:$a)>;
1365
1366// signed/unsigned
1367// x = (a)? x : y
1368//
1369// if (!a) x = y
1370//
1371def : Mips16Pat<(select CPU16Regs:$a,
1372 CPU16Regs:$x, CPU16Regs:$y),
1373 (SelBneZ CPU16Regs:$x, CPU16Regs:$y,
1374 CPU16Regs:$a)>;
1375
1376
1377//
1378// signed/unsigned
1379// x = (a != k)? x : y
1380//
1381// if (a == k) x = y
1382//
1383def : Mips16Pat<(select (i32 (setne CPU16Regs:$a, immZExt16:$k)),
1384 CPU16Regs:$x, CPU16Regs:$y),
1385 (SelTBtneZCmpi CPU16Regs:$x, CPU16Regs:$y,
1386 CPU16Regs:$a, immZExt16:$k)>;
Reed Kotlercf11c592012-10-12 02:01:09 +00001387
Reed Kotler164bb372012-10-23 01:35:48 +00001388//
1389// When writing C code to test setxx these patterns,
1390// some will be transformed into
1391// other things. So we test using C code but using -O3 and -O0
1392//
1393// seteq
1394//
1395def : Mips16Pat
1396 <(seteq CPU16Regs:$lhs,CPU16Regs:$rhs),
1397 (SltiuCCRxImmX16 (XorRxRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs), 1)>;
1398
1399def : Mips16Pat
1400 <(seteq CPU16Regs:$lhs, 0),
1401 (SltiuCCRxImmX16 CPU16Regs:$lhs, 1)>;
1402
1403
1404//
1405// setge
1406//
1407
1408def: Mips16Pat
1409 <(setge CPU16Regs:$lhs, CPU16Regs:$rhs),
1410 (XorRxRxRy16 (SltCCRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs),
1411 (LiRxImmX16 1))>;
1412
1413//
1414// For constants, llvm transforms this to:
1415// x > (k -1) and then reverses the operands to use setlt. So this pattern
1416// is not used now by the compiler. (Presumably checking that k-1 does not
1417// overflow). The compiler never uses this at a the current time, due to
1418// other optimizations.
1419//
1420//def: Mips16Pat
1421// <(setge CPU16Regs:$lhs, immSExt16:$rhs),
1422// (XorRxRxRy16 (SltiCCRxImmX16 CPU16Regs:$lhs, immSExt16:$rhs),
1423// (LiRxImmX16 1))>;
1424
1425// This catches the x >= -32768 case by transforming it to x > -32769
1426//
1427def: Mips16Pat
1428 <(setgt CPU16Regs:$lhs, -32769),
1429 (XorRxRxRy16 (SltiCCRxImmX16 CPU16Regs:$lhs, -32768),
1430 (LiRxImmX16 1))>;
1431
1432//
1433// setgt
1434//
1435//
1436
1437def: Mips16Pat
1438 <(setgt CPU16Regs:$lhs, CPU16Regs:$rhs),
1439 (SltCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs)>;
1440
1441//
1442// setle
1443//
1444def: Mips16Pat
1445 <(setle CPU16Regs:$lhs, CPU16Regs:$rhs),
1446 (XorRxRxRy16 (SltCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs), (LiRxImmX16 1))>;
1447
1448//
1449// setlt
1450//
1451def: SetCC_R16<setlt, SltCCRxRy16>;
1452
1453def: SetCC_I16<setlt, immSExt16, SltiCCRxImmX16>;
1454
1455//
1456// setne
1457//
1458def : Mips16Pat
1459 <(setne CPU16Regs:$lhs,CPU16Regs:$rhs),
1460 (SltuCCRxRy16 (LiRxImmX16 0),
1461 (XorRxRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs))>;
1462
1463
1464//
1465// setuge
1466//
1467def: Mips16Pat
1468 <(setuge CPU16Regs:$lhs, CPU16Regs:$rhs),
1469 (XorRxRxRy16 (SltuCCRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs),
1470 (LiRxImmX16 1))>;
1471
1472// this pattern will never be used because the compiler will transform
1473// x >= k to x > (k - 1) and then use SLT
1474//
1475//def: Mips16Pat
1476// <(setuge CPU16Regs:$lhs, immZExt16:$rhs),
1477// (XorRxRxRy16 (SltiuCCRxImmX16 CPU16Regs:$lhs, immZExt16:$rhs),
Reed Kotler097556d2012-10-25 21:33:30 +00001478// (LiRxImmX16 1))>;
Reed Kotler164bb372012-10-23 01:35:48 +00001479
1480//
1481// setugt
1482//
1483def: Mips16Pat
1484 <(setugt CPU16Regs:$lhs, CPU16Regs:$rhs),
1485 (SltuCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs)>;
1486
1487//
1488// setule
1489//
1490def: Mips16Pat
1491 <(setule CPU16Regs:$lhs, CPU16Regs:$rhs),
1492 (XorRxRxRy16 (SltuCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs), (LiRxImmX16 1))>;
1493
1494//
1495// setult
1496//
1497def: SetCC_R16<setult, SltuCCRxRy16>;
1498
1499def: SetCC_I16<setult, immSExt16, SltiuCCRxImmX16>;
1500
Reed Kotler7e4d9962012-10-27 00:57:14 +00001501def: Mips16Pat<(add CPU16Regs:$hi, (MipsLo tglobaladdr:$lo)),
1502 (AddiuRxRxImmX16 CPU16Regs:$hi, tglobaladdr:$lo)>;
1503
1504// hi/lo relocs
1505
1506def : Mips16Pat<(MipsHi tglobaltlsaddr:$in),
1507 (SllX16 (LiRxImmX16 tglobaltlsaddr:$in), 16)>;
1508
Reed Kotlerb650f6b2012-10-26 22:57:32 +00001509// wrapper_pic
1510class Wrapper16Pat<SDNode node, Instruction ADDiuOp, RegisterClass RC>:
1511 Mips16Pat<(MipsWrapper RC:$gp, node:$in),
1512 (ADDiuOp RC:$gp, node:$in)>;
1513
1514
Reed Kotler3589dd72012-10-28 06:02:37 +00001515def : Wrapper16Pat<tglobaladdr, AddiuRxRxImmX16, CPU16Regs>;
Reed Kotlerb650f6b2012-10-26 22:57:32 +00001516def : Wrapper16Pat<tglobaltlsaddr, AddiuRxRxImmX16, CPU16Regs>;
1517
Reed Kotler740981e2012-10-29 19:39:04 +00001518def : Mips16Pat<(i32 (extloadi8 addr16:$src)),
1519 (LbuRxRyOffMemX16 addr16:$src)>;
1520def : Mips16Pat<(i32 (extloadi16 addr16:$src)),
1521 (LhuRxRyOffMemX16 addr16:$src)>;