2012-05-25 02:32:33 +08:00
|
|
|
//===- Mips16InstrInfo.td - Target Description for Mips16 -*- tablegen -*-=//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file describes Mips16 instructions.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2012-10-06 02:27:54 +08:00
|
|
|
//
|
2012-10-28 14:02:37 +08:00
|
|
|
//
|
|
|
|
// Mips Address
|
|
|
|
//
|
2016-06-16 18:20:59 +08:00
|
|
|
def addr16 : ComplexPattern<iPTR, 2, "selectAddr16", [frameindex]>;
|
|
|
|
def addr16sp : ComplexPattern<iPTR, 2, "selectAddr16SP", [frameindex]>;
|
2012-07-24 07:45:54 +08:00
|
|
|
|
2012-09-14 11:21:56 +08:00
|
|
|
//
|
2012-10-10 09:58:16 +08:00
|
|
|
// Address operand
|
|
|
|
def mem16 : Operand<i32> {
|
|
|
|
let PrintMethod = "printMemOperand";
|
2016-06-16 18:20:59 +08:00
|
|
|
let MIOperandInfo = (ops CPU16Regs, simm16);
|
|
|
|
let EncoderMethod = "getMemEncoding";
|
|
|
|
}
|
|
|
|
|
|
|
|
def mem16sp : Operand<i32> {
|
|
|
|
let PrintMethod = "printMemOperand";
|
|
|
|
// This should be CPUSPReg but the MIPS16 subtarget isn't good enough at
|
|
|
|
// keeping the sp-relative load and the other varieties separate at the
|
|
|
|
// moment. This lie fixes the problem sufficiently well to fix the errors
|
|
|
|
// emitted by -verify-machineinstrs and the output ends up correct as long
|
|
|
|
// as we use an external assembler (which is already a requirement for MIPS16
|
|
|
|
// for several other reasons).
|
|
|
|
let MIOperandInfo = (ops CPU16RegsPlusSP, simm16);
|
2012-10-28 14:02:37 +08:00
|
|
|
let EncoderMethod = "getMemEncoding";
|
|
|
|
}
|
|
|
|
|
|
|
|
def mem16_ea : Operand<i32> {
|
|
|
|
let PrintMethod = "printMemOperandEA";
|
2013-08-04 09:13:25 +08:00
|
|
|
let MIOperandInfo = (ops CPU16RegsPlusSP, simm16);
|
2012-10-10 09:58:16 +08:00
|
|
|
let EncoderMethod = "getMemEncoding";
|
|
|
|
}
|
2012-09-28 10:26:24 +08:00
|
|
|
|
2016-04-11 23:20:40 +08:00
|
|
|
def pcrel16 : Operand<i32>;
|
|
|
|
|
2013-11-12 10:27:12 +08:00
|
|
|
//
|
|
|
|
// I-type instruction format
|
|
|
|
//
|
|
|
|
// this is only used by bimm. the actual assembly value is a 12 bit signed
|
|
|
|
// number
|
|
|
|
//
|
|
|
|
class FI16_ins<bits<5> op, string asmstr, InstrItinClass itin>:
|
|
|
|
FI16<op, (outs), (ins brtarget:$imm16),
|
|
|
|
!strconcat(asmstr, "\t$imm16 # 16 bit inst"), [], itin>;
|
|
|
|
|
2013-02-14 04:28:27 +08:00
|
|
|
//
|
|
|
|
//
|
|
|
|
// I8 instruction format
|
|
|
|
//
|
|
|
|
|
|
|
|
class FI816_ins_base<bits<3> _func, string asmstr,
|
|
|
|
string asmstr2, InstrItinClass itin>:
|
|
|
|
FI816<_func, (outs), (ins simm16:$imm), !strconcat(asmstr, asmstr2),
|
|
|
|
[], itin>;
|
|
|
|
|
2013-11-15 10:21:52 +08:00
|
|
|
class FI816_ins<bits<3> _func, string asmstr,
|
|
|
|
InstrItinClass itin>:
|
|
|
|
FI816_ins_base<_func, asmstr, "\t$imm # 16 bit inst", itin>;
|
|
|
|
|
2013-02-14 04:28:27 +08:00
|
|
|
class FI816_SP_ins<bits<3> _func, string asmstr,
|
|
|
|
InstrItinClass itin>:
|
|
|
|
FI816_ins_base<_func, asmstr, "\t$$sp, $imm # 16 bit inst", itin>;
|
|
|
|
|
2013-02-09 05:42:56 +08:00
|
|
|
//
|
|
|
|
// RI instruction format
|
|
|
|
//
|
|
|
|
|
|
|
|
|
2013-02-19 08:20:58 +08:00
|
|
|
class FRI16_ins_base<bits<5> op, string asmstr, string asmstr2,
|
|
|
|
InstrItinClass itin>:
|
|
|
|
FRI16<op, (outs CPU16Regs:$rx), (ins simm16:$imm),
|
|
|
|
!strconcat(asmstr, asmstr2), [], itin>;
|
|
|
|
|
|
|
|
class FRI16_ins<bits<5> op, string asmstr,
|
|
|
|
InstrItinClass itin>:
|
|
|
|
FRI16_ins_base<op, asmstr, "\t$rx, $imm \t# 16 bit inst", itin>;
|
2013-02-20 13:45:15 +08:00
|
|
|
|
2013-11-05 16:14:14 +08:00
|
|
|
class FRI16_TCP_ins<bits<5> _op, string asmstr,
|
|
|
|
InstrItinClass itin>:
|
|
|
|
FRI16<_op, (outs CPU16Regs:$rx), (ins pcrel16:$imm, i32imm:$size),
|
|
|
|
!strconcat(asmstr, "\t$rx, $imm\t# 16 bit inst"), [], itin>;
|
|
|
|
|
2013-02-20 13:45:15 +08:00
|
|
|
class FRI16R_ins_base<bits<5> op, string asmstr, string asmstr2,
|
|
|
|
InstrItinClass itin>:
|
|
|
|
FRI16<op, (outs), (ins CPU16Regs:$rx, simm16:$imm),
|
|
|
|
!strconcat(asmstr, asmstr2), [], itin>;
|
|
|
|
|
|
|
|
class FRI16R_ins<bits<5> op, string asmstr,
|
|
|
|
InstrItinClass itin>:
|
|
|
|
FRI16R_ins_base<op, asmstr, "\t$rx, $imm \t# 16 bit inst", itin>;
|
|
|
|
|
2013-02-09 05:42:56 +08:00
|
|
|
class F2RI16_ins<bits<5> _op, string asmstr,
|
|
|
|
InstrItinClass itin>:
|
|
|
|
FRI16<_op, (outs CPU16Regs:$rx), (ins CPU16Regs:$rx_, simm16:$imm),
|
|
|
|
!strconcat(asmstr, "\t$rx, $imm\t# 16 bit inst"), [], itin> {
|
|
|
|
let Constraints = "$rx_ = $rx";
|
|
|
|
}
|
|
|
|
|
2013-02-21 12:22:38 +08:00
|
|
|
class FRI16_B_ins<bits<5> _op, string asmstr,
|
|
|
|
InstrItinClass itin>:
|
|
|
|
FRI16<_op, (outs), (ins CPU16Regs:$rx, brtarget:$imm),
|
|
|
|
!strconcat(asmstr, "\t$rx, $imm # 16 bit inst"), [], itin>;
|
2012-10-23 09:35:48 +08:00
|
|
|
//
|
|
|
|
// Compare a register and immediate and place result in CC
|
|
|
|
// Implicit use of T8
|
|
|
|
//
|
|
|
|
// EXT-CCRR Instruction format
|
|
|
|
//
|
2013-02-17 07:39:52 +08:00
|
|
|
class FEXT_CCRXI16_ins<string asmstr>:
|
|
|
|
MipsPseudo16<(outs CPU16Regs:$cc), (ins CPU16Regs:$rx, simm16:$imm),
|
|
|
|
!strconcat(asmstr, "\t$rx, $imm\n\tmove\t$cc, $$t8"), []> {
|
2012-10-23 09:35:48 +08:00
|
|
|
let isCodeGenOnly=1;
|
2013-02-25 10:25:47 +08:00
|
|
|
let usesCustomInserter = 1;
|
2012-10-23 09:35:48 +08:00
|
|
|
}
|
|
|
|
|
2013-02-02 12:07:35 +08:00
|
|
|
// JAL and JALX instruction format
|
|
|
|
//
|
|
|
|
class FJAL16_ins<bits<1> _X, string asmstr,
|
|
|
|
InstrItinClass itin>:
|
2016-03-29 17:40:38 +08:00
|
|
|
FJAL16<_X, (outs), (ins uimm26:$imm),
|
2013-02-02 12:07:35 +08:00
|
|
|
!strconcat(asmstr, "\t$imm\n\tnop"),[],
|
|
|
|
itin> {
|
|
|
|
let isCodeGenOnly=1;
|
2014-01-16 08:47:46 +08:00
|
|
|
let Size=6;
|
2013-02-02 12:07:35 +08:00
|
|
|
}
|
2013-11-30 06:32:56 +08:00
|
|
|
|
|
|
|
class FJALB16_ins<bits<1> _X, string asmstr,
|
|
|
|
InstrItinClass itin>:
|
2016-03-29 17:40:38 +08:00
|
|
|
FJAL16<_X, (outs), (ins uimm26:$imm),
|
2013-11-30 06:32:56 +08:00
|
|
|
!strconcat(asmstr, "\t$imm\t# branch\n\tnop"),[],
|
|
|
|
itin> {
|
|
|
|
let isCodeGenOnly=1;
|
2014-01-16 08:47:46 +08:00
|
|
|
let Size=6;
|
2013-11-30 06:32:56 +08:00
|
|
|
}
|
|
|
|
|
2012-10-18 06:29:54 +08:00
|
|
|
//
|
|
|
|
// EXT-I instruction format
|
|
|
|
//
|
|
|
|
class FEXT_I16_ins<bits<5> eop, string asmstr, InstrItinClass itin> :
|
|
|
|
FEXT_I16<eop, (outs), (ins brtarget:$imm16),
|
|
|
|
!strconcat(asmstr, "\t$imm16"),[], itin>;
|
|
|
|
|
|
|
|
//
|
|
|
|
// EXT-I8 instruction format
|
|
|
|
//
|
|
|
|
|
|
|
|
class FEXT_I816_ins_base<bits<3> _func, string asmstr,
|
|
|
|
string asmstr2, InstrItinClass itin>:
|
2012-12-20 12:07:42 +08:00
|
|
|
FEXT_I816<_func, (outs), (ins simm16:$imm), !strconcat(asmstr, asmstr2),
|
2012-10-18 06:29:54 +08:00
|
|
|
[], itin>;
|
|
|
|
|
|
|
|
class FEXT_I816_ins<bits<3> _func, string asmstr,
|
|
|
|
InstrItinClass itin>:
|
|
|
|
FEXT_I816_ins_base<_func, asmstr, "\t$imm", itin>;
|
|
|
|
|
2012-12-20 12:07:42 +08:00
|
|
|
class FEXT_I816_SP_ins<bits<3> _func, string asmstr,
|
|
|
|
InstrItinClass itin>:
|
|
|
|
FEXT_I816_ins_base<_func, asmstr, "\t$$sp, $imm", itin>;
|
|
|
|
|
2012-09-28 10:26:24 +08:00
|
|
|
//
|
2012-10-10 09:58:16 +08:00
|
|
|
// Assembler formats in alphabetical order.
|
|
|
|
// Natural and pseudos are mixed together.
|
2012-09-28 10:26:24 +08:00
|
|
|
//
|
2012-10-23 09:35:48 +08:00
|
|
|
// Compare two registers and place result in CC
|
|
|
|
// Implicit use of T8
|
|
|
|
//
|
|
|
|
// CC-RR Instruction format
|
|
|
|
//
|
2013-02-17 07:39:52 +08:00
|
|
|
class FCCRR16_ins<string asmstr> :
|
|
|
|
MipsPseudo16<(outs CPU16Regs:$cc), (ins CPU16Regs:$rx, CPU16Regs:$ry),
|
|
|
|
!strconcat(asmstr, "\t$rx, $ry\n\tmove\t$cc, $$t8"), []> {
|
2012-10-23 09:35:48 +08:00
|
|
|
let isCodeGenOnly=1;
|
2013-02-25 10:25:47 +08:00
|
|
|
let usesCustomInserter = 1;
|
2012-10-23 09:35:48 +08:00
|
|
|
}
|
|
|
|
|
2012-07-24 07:45:54 +08:00
|
|
|
//
|
|
|
|
// EXT-RI instruction format
|
|
|
|
//
|
|
|
|
|
|
|
|
class FEXT_RI16_ins_base<bits<5> _op, string asmstr, string asmstr2,
|
|
|
|
InstrItinClass itin>:
|
|
|
|
FEXT_RI16<_op, (outs CPU16Regs:$rx), (ins simm16:$imm),
|
|
|
|
!strconcat(asmstr, asmstr2), [], itin>;
|
|
|
|
|
|
|
|
class FEXT_RI16_ins<bits<5> _op, string asmstr,
|
|
|
|
InstrItinClass itin>:
|
|
|
|
FEXT_RI16_ins_base<_op, asmstr, "\t$rx, $imm", itin>;
|
|
|
|
|
2013-02-20 13:45:15 +08:00
|
|
|
class FEXT_RI16R_ins_base<bits<5> _op, string asmstr, string asmstr2,
|
|
|
|
InstrItinClass itin>:
|
|
|
|
FEXT_RI16<_op, (outs ), (ins CPU16Regs:$rx, simm16:$imm),
|
|
|
|
!strconcat(asmstr, asmstr2), [], itin>;
|
|
|
|
|
|
|
|
class FEXT_RI16R_ins<bits<5> _op, string asmstr,
|
|
|
|
InstrItinClass itin>:
|
|
|
|
FEXT_RI16R_ins_base<_op, asmstr, "\t$rx, $imm", itin>;
|
|
|
|
|
2012-07-24 07:45:54 +08:00
|
|
|
class FEXT_RI16_PC_ins<bits<5> _op, string asmstr, InstrItinClass itin>:
|
|
|
|
FEXT_RI16_ins_base<_op, asmstr, "\t$rx, $$pc, $imm", itin>;
|
|
|
|
|
2012-10-18 06:29:54 +08:00
|
|
|
class FEXT_RI16_B_ins<bits<5> _op, string asmstr,
|
|
|
|
InstrItinClass itin>:
|
|
|
|
FEXT_RI16<_op, (outs), (ins CPU16Regs:$rx, brtarget:$imm),
|
|
|
|
!strconcat(asmstr, "\t$rx, $imm"), [], itin>;
|
|
|
|
|
2013-10-28 05:57:36 +08:00
|
|
|
class FEXT_RI16_TCP_ins<bits<5> _op, string asmstr,
|
|
|
|
InstrItinClass itin>:
|
2013-11-05 16:14:14 +08:00
|
|
|
FEXT_RI16<_op, (outs CPU16Regs:$rx), (ins pcrel16:$imm, i32imm:$size),
|
2013-10-28 05:57:36 +08:00
|
|
|
!strconcat(asmstr, "\t$rx, $imm"), [], itin>;
|
|
|
|
|
2012-07-26 10:24:43 +08:00
|
|
|
class FEXT_2RI16_ins<bits<5> _op, string asmstr,
|
|
|
|
InstrItinClass itin>:
|
|
|
|
FEXT_RI16<_op, (outs CPU16Regs:$rx), (ins CPU16Regs:$rx_, simm16:$imm),
|
|
|
|
!strconcat(asmstr, "\t$rx, $imm"), [], itin> {
|
|
|
|
let Constraints = "$rx_ = $rx";
|
|
|
|
}
|
2012-10-06 02:27:54 +08:00
|
|
|
|
2012-07-24 07:45:54 +08:00
|
|
|
//
|
|
|
|
// EXT-RRI instruction format
|
|
|
|
//
|
|
|
|
|
|
|
|
class FEXT_RRI16_mem_ins<bits<5> op, string asmstr, Operand MemOpnd,
|
|
|
|
InstrItinClass itin>:
|
|
|
|
FEXT_RRI16<op, (outs CPU16Regs:$ry), (ins MemOpnd:$addr),
|
|
|
|
!strconcat(asmstr, "\t$ry, $addr"), [], itin>;
|
|
|
|
|
2012-08-04 06:57:02 +08:00
|
|
|
class FEXT_RRI16_mem2_ins<bits<5> op, string asmstr, Operand MemOpnd,
|
|
|
|
InstrItinClass itin>:
|
|
|
|
FEXT_RRI16<op, (outs ), (ins CPU16Regs:$ry, MemOpnd:$addr),
|
|
|
|
!strconcat(asmstr, "\t$ry, $addr"), [], itin>;
|
|
|
|
|
2012-10-28 14:02:37 +08:00
|
|
|
//
|
|
|
|
//
|
|
|
|
// EXT-RRI-A instruction format
|
|
|
|
//
|
|
|
|
|
|
|
|
class FEXT_RRI_A16_mem_ins<bits<1> op, string asmstr, Operand MemOpnd,
|
|
|
|
InstrItinClass itin>:
|
|
|
|
FEXT_RRI_A16<op, (outs CPU16Regs:$ry), (ins MemOpnd:$addr),
|
|
|
|
!strconcat(asmstr, "\t$ry, $addr"), [], itin>;
|
|
|
|
|
2012-07-24 07:45:54 +08:00
|
|
|
//
|
|
|
|
// EXT-SHIFT instruction format
|
|
|
|
//
|
|
|
|
class FEXT_SHIFT16_ins<bits<2> _f, string asmstr, InstrItinClass itin>:
|
2013-09-07 08:02:02 +08:00
|
|
|
FEXT_SHIFT16<_f, (outs CPU16Regs:$rx), (ins CPU16Regs:$ry, uimm5:$sa),
|
2012-07-24 07:45:54 +08:00
|
|
|
!strconcat(asmstr, "\t$rx, $ry, $sa"), [], itin>;
|
|
|
|
|
2012-10-18 06:29:54 +08:00
|
|
|
//
|
|
|
|
// EXT-T8I8
|
|
|
|
//
|
2013-02-17 07:39:52 +08:00
|
|
|
class FEXT_T8I816_ins<string asmstr, string asmstr2>:
|
|
|
|
MipsPseudo16<(outs),
|
|
|
|
(ins CPU16Regs:$rx, CPU16Regs:$ry, brtarget:$imm),
|
|
|
|
!strconcat(asmstr2, !strconcat("\t$rx, $ry\n\t",
|
|
|
|
!strconcat(asmstr, "\t$imm"))),[]> {
|
2012-10-18 06:29:54 +08:00
|
|
|
let isCodeGenOnly=1;
|
2013-02-24 14:16:39 +08:00
|
|
|
let usesCustomInserter = 1;
|
2012-10-18 06:29:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// EXT-T8I8I
|
|
|
|
//
|
2013-02-17 07:39:52 +08:00
|
|
|
class FEXT_T8I8I16_ins<string asmstr, string asmstr2>:
|
|
|
|
MipsPseudo16<(outs),
|
|
|
|
(ins CPU16Regs:$rx, simm16:$imm, brtarget:$targ),
|
|
|
|
!strconcat(asmstr2, !strconcat("\t$rx, $imm\n\t",
|
|
|
|
!strconcat(asmstr, "\t$targ"))), []> {
|
2012-10-18 06:29:54 +08:00
|
|
|
let isCodeGenOnly=1;
|
2013-02-25 07:17:51 +08:00
|
|
|
let usesCustomInserter = 1;
|
2012-10-18 06:29:54 +08:00
|
|
|
}
|
|
|
|
//
|
|
|
|
|
2012-10-10 09:58:16 +08:00
|
|
|
|
2012-07-24 07:45:54 +08:00
|
|
|
//
|
2012-10-10 09:58:16 +08:00
|
|
|
// I8_MOVR32 instruction format (used only by the MOVR32 instructio
|
|
|
|
//
|
|
|
|
class FI8_MOVR3216_ins<string asmstr, InstrItinClass itin>:
|
2013-08-07 07:08:38 +08:00
|
|
|
FI8_MOVR3216<(outs CPU16Regs:$rz), (ins GPR32:$r32),
|
2012-10-10 09:58:16 +08:00
|
|
|
!strconcat(asmstr, "\t$rz, $r32"), [], itin>;
|
|
|
|
|
|
|
|
//
|
|
|
|
// I8_MOV32R instruction format (used only by MOV32R instruction)
|
|
|
|
//
|
|
|
|
|
|
|
|
class FI8_MOV32R16_ins<string asmstr, InstrItinClass itin>:
|
2013-08-07 07:08:38 +08:00
|
|
|
FI8_MOV32R16<(outs GPR32:$r32), (ins CPU16Regs:$rz),
|
2012-10-10 09:58:16 +08:00
|
|
|
!strconcat(asmstr, "\t$r32, $rz"), [], itin>;
|
|
|
|
|
|
|
|
//
|
|
|
|
// This are pseudo formats for multiply
|
2013-12-05 13:44:44 +08:00
|
|
|
// This first one can be changed to non-pseudo now.
|
2012-10-10 09:58:16 +08:00
|
|
|
//
|
|
|
|
// MULT
|
|
|
|
//
|
|
|
|
class FMULT16_ins<string asmstr, InstrItinClass itin> :
|
|
|
|
MipsPseudo16<(outs), (ins CPU16Regs:$rx, CPU16Regs:$ry),
|
|
|
|
!strconcat(asmstr, "\t$rx, $ry"), []>;
|
|
|
|
|
|
|
|
//
|
|
|
|
// MULT-LO
|
|
|
|
//
|
|
|
|
class FMULT16_LO_ins<string asmstr, InstrItinClass itin> :
|
|
|
|
MipsPseudo16<(outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry),
|
|
|
|
!strconcat(asmstr, "\t$rx, $ry\n\tmflo\t$rz"), []> {
|
|
|
|
let isCodeGenOnly=1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// RR-type instruction format
|
|
|
|
//
|
|
|
|
|
|
|
|
class FRR16_ins<bits<5> f, string asmstr, InstrItinClass itin> :
|
|
|
|
FRR16<f, (outs CPU16Regs:$rx), (ins CPU16Regs:$ry),
|
|
|
|
!strconcat(asmstr, "\t$rx, $ry"), [], itin> {
|
2012-07-24 07:45:54 +08:00
|
|
|
}
|
2012-10-12 10:01:09 +08:00
|
|
|
|
2013-08-07 12:00:26 +08:00
|
|
|
class FRRBreakNull16_ins<string asmstr, InstrItinClass itin> :
|
|
|
|
FRRBreak16<(outs), (ins), asmstr, [], itin> {
|
|
|
|
let Code=0;
|
|
|
|
}
|
|
|
|
|
2013-02-24 07:37:03 +08:00
|
|
|
class FRR16R_ins<bits<5> f, string asmstr, InstrItinClass itin> :
|
|
|
|
FRR16<f, (outs), (ins CPU16Regs:$rx, CPU16Regs:$ry),
|
|
|
|
!strconcat(asmstr, "\t$rx, $ry"), [], itin> {
|
|
|
|
}
|
|
|
|
|
2013-02-17 07:39:52 +08:00
|
|
|
class FRRTR16_ins<string asmstr> :
|
|
|
|
MipsPseudo16<(outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry),
|
|
|
|
!strconcat(asmstr, "\t$rx, $ry\n\tmove\t$rz, $$t8"), []> ;
|
2012-10-26 12:46:26 +08:00
|
|
|
|
2012-10-12 10:01:09 +08:00
|
|
|
//
|
|
|
|
// maybe refactor but need a $zero as a dummy first parameter
|
|
|
|
//
|
|
|
|
class FRR16_div_ins<bits<5> f, string asmstr, InstrItinClass itin> :
|
|
|
|
FRR16<f, (outs ), (ins CPU16Regs:$rx, CPU16Regs:$ry),
|
|
|
|
!strconcat(asmstr, "\t$$zero, $rx, $ry"), [], itin> ;
|
|
|
|
|
2012-10-27 00:18:19 +08:00
|
|
|
class FUnaryRR16_ins<bits<5> f, string asmstr, InstrItinClass itin> :
|
|
|
|
FRR16<f, (outs CPU16Regs:$rx), (ins CPU16Regs:$ry),
|
|
|
|
!strconcat(asmstr, "\t$rx, $ry"), [], itin> ;
|
|
|
|
|
|
|
|
|
2012-10-10 09:58:16 +08:00
|
|
|
class FRR16_M_ins<bits<5> f, string asmstr,
|
|
|
|
InstrItinClass itin> :
|
|
|
|
FRR16<f, (outs CPU16Regs:$rx), (ins),
|
|
|
|
!strconcat(asmstr, "\t$rx"), [], itin>;
|
|
|
|
|
|
|
|
class FRxRxRy16_ins<bits<5> f, string asmstr,
|
|
|
|
InstrItinClass itin> :
|
|
|
|
FRR16<f, (outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry),
|
|
|
|
!strconcat(asmstr, "\t$rz, $ry"),
|
|
|
|
[], itin> {
|
|
|
|
let Constraints = "$rx = $rz";
|
|
|
|
}
|
|
|
|
|
|
|
|
let rx=0 in
|
|
|
|
class FRR16_JALRC_RA_only_ins<bits<1> nd_, bits<1> l_,
|
|
|
|
string asmstr, InstrItinClass itin>:
|
2017-11-27 22:25:36 +08:00
|
|
|
FRR16_JALRC<nd_, l_, 1, (outs), (ins), !strconcat(asmstr, "\t$$ra"),
|
2012-10-10 09:58:16 +08:00
|
|
|
[], itin> ;
|
|
|
|
|
2012-10-29 07:08:07 +08:00
|
|
|
|
|
|
|
class FRR16_JALRC_ins<bits<1> nd, bits<1> l, bits<1> ra,
|
|
|
|
string asmstr, InstrItinClass itin>:
|
2013-01-19 10:00:40 +08:00
|
|
|
FRR16_JALRC<nd, l, ra, (outs), (ins CPU16Regs:$rx),
|
2017-11-27 22:25:36 +08:00
|
|
|
!strconcat(asmstr, "\t$rx"), [], itin> ;
|
2012-10-29 07:08:07 +08:00
|
|
|
|
2013-10-08 04:46:19 +08:00
|
|
|
class FRR_SF16_ins
|
|
|
|
<bits<5> _funct, bits<3> _subfunc,
|
|
|
|
string asmstr, InstrItinClass itin>:
|
|
|
|
FRR_SF16<_funct, _subfunc, (outs CPU16Regs:$rx), (ins CPU16Regs:$rx_),
|
|
|
|
!strconcat(asmstr, "\t $rx"),
|
|
|
|
[], itin> {
|
|
|
|
let Constraints = "$rx_ = $rx";
|
|
|
|
}
|
2012-10-10 09:58:16 +08:00
|
|
|
//
|
|
|
|
// RRR-type instruction format
|
|
|
|
//
|
|
|
|
|
|
|
|
class FRRR16_ins<bits<2> _f, string asmstr, InstrItinClass itin> :
|
|
|
|
FRRR16<_f, (outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry),
|
|
|
|
!strconcat(asmstr, "\t$rz, $rx, $ry"), [], itin>;
|
2012-07-24 07:45:54 +08:00
|
|
|
|
2012-10-26 05:33:30 +08:00
|
|
|
//
|
|
|
|
// These Sel patterns support the generation of conditional move
|
|
|
|
// pseudo instructions.
|
|
|
|
//
|
|
|
|
// The nomenclature uses the components making up the pseudo and may
|
|
|
|
// be a bit counter intuitive when compared with the end result we seek.
|
|
|
|
// For example using a bqez in the example directly below results in the
|
|
|
|
// conditional move being done if the tested register is not zero.
|
|
|
|
// I considered in easier to check by keeping the pseudo consistent with
|
|
|
|
// it's components but it could have been done differently.
|
|
|
|
//
|
|
|
|
// The simplest case is when can test and operand directly and do the
|
|
|
|
// conditional move based on a simple mips16 conditional
|
|
|
|
// branch instruction.
|
|
|
|
// for example:
|
|
|
|
// if $op == beqz or bnez:
|
|
|
|
//
|
|
|
|
// $op1 $rt, .+4
|
|
|
|
// move $rd, $rs
|
|
|
|
//
|
|
|
|
// if $op == beqz, then if $rt != 0, then the conditional assignment
|
|
|
|
// $rd = $rs is done.
|
|
|
|
|
|
|
|
// if $op == bnez, then if $rt == 0, then the conditional assignment
|
|
|
|
// $rd = $rs is done.
|
|
|
|
//
|
|
|
|
// So this pseudo class only has one operand, i.e. op
|
|
|
|
//
|
2013-02-17 07:39:52 +08:00
|
|
|
class Sel<string op>:
|
|
|
|
MipsPseudo16<(outs CPU16Regs:$rd_), (ins CPU16Regs:$rd, CPU16Regs:$rs,
|
|
|
|
CPU16Regs:$rt),
|
|
|
|
!strconcat(op, "\t$rt, .+4\n\t\n\tmove $rd, $rs"), []> {
|
|
|
|
//let isCodeGenOnly=1;
|
2012-10-26 05:33:30 +08:00
|
|
|
let Constraints = "$rd = $rd_";
|
2013-02-21 12:22:38 +08:00
|
|
|
let usesCustomInserter = 1;
|
2012-10-26 05:33:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// The next two instruction classes allow for an operand which tests
|
|
|
|
// two operands and returns a value in register T8 and
|
|
|
|
//then does a conditional branch based on the value of T8
|
|
|
|
//
|
|
|
|
|
|
|
|
// op2 can be cmpi or slti/sltiu
|
|
|
|
// op1 can bteqz or btnez
|
|
|
|
// the operands for op2 are a register and a signed constant
|
|
|
|
//
|
|
|
|
// $op2 $t, $imm ;test register t and branch conditionally
|
|
|
|
// $op1 .+4 ;op1 is a conditional branch
|
|
|
|
// move $rd, $rs
|
|
|
|
//
|
|
|
|
//
|
2013-02-17 07:39:52 +08:00
|
|
|
class SeliT<string op1, string op2>:
|
|
|
|
MipsPseudo16<(outs CPU16Regs:$rd_), (ins CPU16Regs:$rd, CPU16Regs:$rs,
|
|
|
|
CPU16Regs:$rl, simm16:$imm),
|
|
|
|
!strconcat(op2,
|
|
|
|
!strconcat("\t$rl, $imm\n\t",
|
|
|
|
!strconcat(op1, "\t.+4\n\tmove $rd, $rs"))), []> {
|
2012-10-26 05:33:30 +08:00
|
|
|
let isCodeGenOnly=1;
|
|
|
|
let Constraints = "$rd = $rd_";
|
2013-02-22 13:10:51 +08:00
|
|
|
let usesCustomInserter = 1;
|
2012-10-26 05:33:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// op2 can be cmp or slt/sltu
|
|
|
|
// op1 can be bteqz or btnez
|
|
|
|
// the operands for op2 are two registers
|
|
|
|
// op1 is a conditional branch
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// $op2 $rl, $rr ;test registers rl,rr
|
|
|
|
// $op1 .+4 ;op2 is a conditional branch
|
|
|
|
// move $rd, $rs
|
|
|
|
//
|
|
|
|
//
|
2013-02-17 07:39:52 +08:00
|
|
|
class SelT<string op1, string op2>:
|
2013-02-20 13:45:15 +08:00
|
|
|
MipsPseudo16<(outs CPU16Regs:$rd_),
|
2013-02-17 07:39:52 +08:00
|
|
|
(ins CPU16Regs:$rd, CPU16Regs:$rs,
|
2012-10-26 05:33:30 +08:00
|
|
|
CPU16Regs:$rl, CPU16Regs:$rr),
|
2013-02-17 07:39:52 +08:00
|
|
|
!strconcat(op2,
|
|
|
|
!strconcat("\t$rl, $rr\n\t",
|
|
|
|
!strconcat(op1, "\t.+4\n\tmove $rd, $rs"))), []> {
|
2012-10-26 05:33:30 +08:00
|
|
|
let isCodeGenOnly=1;
|
|
|
|
let Constraints = "$rd = $rd_";
|
2013-02-23 11:09:56 +08:00
|
|
|
let usesCustomInserter = 1;
|
2012-10-26 05:33:30 +08:00
|
|
|
}
|
|
|
|
|
2012-12-20 12:07:42 +08:00
|
|
|
//
|
|
|
|
// 32 bit constant
|
|
|
|
//
|
|
|
|
def Constant32:
|
2016-04-04 23:32:49 +08:00
|
|
|
MipsPseudo16<(outs), (ins simm32:$imm), "\t.word $imm", []>;
|
2013-01-19 10:00:40 +08:00
|
|
|
|
2012-12-20 12:07:42 +08:00
|
|
|
def LwConstant32:
|
2016-04-04 23:32:49 +08:00
|
|
|
MipsPseudo16<(outs CPU16Regs:$rx), (ins simm32:$imm, simm32:$constid),
|
2012-12-20 12:07:42 +08:00
|
|
|
"lw\t$rx, 1f\n\tb\t2f\n\t.align\t2\n1: \t.word\t$imm\n2:", []>;
|
|
|
|
|
2012-10-26 05:33:30 +08:00
|
|
|
|
2012-08-04 06:57:02 +08:00
|
|
|
//
|
|
|
|
// Some general instruction class info
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
class ArithLogic16Defs<bit isCom=0> {
|
|
|
|
bits<5> shamt = 0;
|
|
|
|
bit isCommutable = isCom;
|
|
|
|
bit isReMaterializable = 1;
|
2014-11-26 08:46:26 +08:00
|
|
|
bit hasSideEffects = 0;
|
2012-08-04 06:57:02 +08:00
|
|
|
}
|
|
|
|
|
2012-10-18 06:29:54 +08:00
|
|
|
class branch16 {
|
|
|
|
bit isBranch = 1;
|
|
|
|
bit isTerminator = 1;
|
|
|
|
bit isBarrier = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
class cbranch16 {
|
|
|
|
bit isBranch = 1;
|
|
|
|
bit isTerminator = 1;
|
|
|
|
}
|
|
|
|
|
2012-09-28 10:26:24 +08:00
|
|
|
class MayLoad {
|
|
|
|
bit mayLoad = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
class MayStore {
|
|
|
|
bit mayStore = 1;
|
|
|
|
}
|
2012-07-24 07:45:54 +08:00
|
|
|
//
|
2012-07-26 10:24:43 +08:00
|
|
|
|
2013-02-17 07:39:52 +08:00
|
|
|
|
2012-07-26 10:24:43 +08:00
|
|
|
// Format: ADDIU rx, immediate MIPS16e
|
|
|
|
// Purpose: Add Immediate Unsigned Word (2-Operand, Extended)
|
|
|
|
// To add a constant to a 32-bit integer.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def AddiuRxImmX16: FEXT_RI16_ins<0b01001, "addiu", IIM16Alu>;
|
2012-07-26 10:24:43 +08:00
|
|
|
|
2015-09-22 20:36:28 +08:00
|
|
|
def AddiuRxRxImm16: F2RI16_ins<0b01001, "addiu", IIM16Alu>,
|
2013-02-09 05:42:56 +08:00
|
|
|
ArithLogic16Defs<0> {
|
|
|
|
let AddedComplexity = 5;
|
|
|
|
}
|
2015-09-22 20:36:28 +08:00
|
|
|
def AddiuRxRxImmX16: FEXT_2RI16_ins<0b01001, "addiu", IIM16Alu>,
|
2013-02-14 11:05:25 +08:00
|
|
|
ArithLogic16Defs<0> {
|
|
|
|
let isCodeGenOnly = 1;
|
|
|
|
}
|
2012-07-26 10:24:43 +08:00
|
|
|
|
2012-10-28 14:02:37 +08:00
|
|
|
def AddiuRxRyOffMemX16:
|
2015-09-22 20:36:28 +08:00
|
|
|
FEXT_RRI_A16_mem_ins<0, "addiu", mem16_ea, IIM16Alu>;
|
2012-10-28 14:02:37 +08:00
|
|
|
|
2012-07-26 10:24:43 +08:00
|
|
|
//
|
|
|
|
|
2012-07-24 07:45:54 +08:00
|
|
|
// Format: ADDIU rx, pc, immediate MIPS16e
|
|
|
|
// Purpose: Add Immediate Unsigned Word (3-Operand, PC-Relative, Extended)
|
|
|
|
// To add a constant to the program counter.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def AddiuRxPcImmX16: FEXT_RI16_PC_ins<0b00001, "addiu", IIM16Alu>;
|
2012-12-20 12:07:42 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: ADDIU sp, immediate MIPS16e
|
|
|
|
// Purpose: Add Immediate Unsigned Word (2-Operand, SP-Relative, Extended)
|
|
|
|
// To add a constant to the stack pointer.
|
|
|
|
//
|
2013-02-14 04:28:27 +08:00
|
|
|
def AddiuSpImm16
|
2015-09-22 20:36:28 +08:00
|
|
|
: FI816_SP_ins<0b011, "addiu", IIM16Alu> {
|
2013-02-14 04:28:27 +08:00
|
|
|
let Defs = [SP];
|
|
|
|
let Uses = [SP];
|
|
|
|
let AddedComplexity = 5;
|
|
|
|
}
|
|
|
|
|
2012-12-20 12:07:42 +08:00
|
|
|
def AddiuSpImmX16
|
2015-09-22 20:36:28 +08:00
|
|
|
: FEXT_I816_SP_ins<0b011, "addiu", IIM16Alu> {
|
2012-12-20 12:07:42 +08:00
|
|
|
let Defs = [SP];
|
|
|
|
let Uses = [SP];
|
2013-01-19 10:00:40 +08:00
|
|
|
}
|
2012-12-20 12:07:42 +08:00
|
|
|
|
2012-07-24 07:45:54 +08:00
|
|
|
//
|
|
|
|
// Format: ADDU rz, rx, ry MIPS16e
|
|
|
|
// Purpose: Add Unsigned Word (3-Operand)
|
|
|
|
// To add 32-bit integers.
|
|
|
|
//
|
|
|
|
|
2015-09-22 20:36:28 +08:00
|
|
|
def AdduRxRyRz16: FRRR16_ins<01, "addu", IIM16Alu>, ArithLogic16Defs<1>;
|
2012-08-04 06:57:02 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: AND rx, ry MIPS16e
|
|
|
|
// Purpose: AND
|
|
|
|
// To do a bitwise logical AND.
|
|
|
|
|
2015-09-22 20:36:28 +08:00
|
|
|
def AndRxRxRy16: FRxRxRy16_ins<0b01100, "and", IIM16Alu>, ArithLogic16Defs<1>;
|
2012-10-18 06:29:54 +08:00
|
|
|
|
|
|
|
|
2013-02-21 12:22:38 +08:00
|
|
|
//
|
|
|
|
// Format: BEQZ rx, offset MIPS16e
|
|
|
|
// Purpose: Branch on Equal to Zero
|
|
|
|
// To test a GPR then do a PC-relative conditional branch.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def BeqzRxImm16: FRI16_B_ins<0b00100, "beqz", IIM16Alu>, cbranch16;
|
2013-02-21 12:22:38 +08:00
|
|
|
|
|
|
|
|
2012-10-18 06:29:54 +08:00
|
|
|
//
|
|
|
|
// Format: BEQZ rx, offset MIPS16e
|
|
|
|
// Purpose: Branch on Equal to Zero (Extended)
|
|
|
|
// To test a GPR then do a PC-relative conditional branch.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def BeqzRxImmX16: FEXT_RI16_B_ins<0b00100, "beqz", IIM16Alu>, cbranch16;
|
2012-10-18 06:29:54 +08:00
|
|
|
|
2013-11-12 10:27:12 +08:00
|
|
|
//
|
|
|
|
// Format: B offset MIPS16e
|
|
|
|
// Purpose: Unconditional Branch (Extended)
|
|
|
|
// To do an unconditional PC-relative branch.
|
|
|
|
//
|
|
|
|
|
2015-09-22 20:36:28 +08:00
|
|
|
def Bimm16: FI16_ins<0b00010, "b", IIM16Alu>, branch16;
|
2013-11-12 10:27:12 +08:00
|
|
|
|
2012-10-18 06:29:54 +08:00
|
|
|
// Format: B offset MIPS16e
|
|
|
|
// Purpose: Unconditional Branch
|
|
|
|
// To do an unconditional PC-relative branch.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def BimmX16: FEXT_I16_ins<0b00010, "b", IIM16Alu>, branch16;
|
2012-10-18 06:29:54 +08:00
|
|
|
|
2013-02-21 12:22:38 +08:00
|
|
|
//
|
|
|
|
// Format: BNEZ rx, offset MIPS16e
|
|
|
|
// Purpose: Branch on Not Equal to Zero
|
|
|
|
// To test a GPR then do a PC-relative conditional branch.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def BnezRxImm16: FRI16_B_ins<0b00101, "bnez", IIM16Alu>, cbranch16;
|
2013-02-21 12:22:38 +08:00
|
|
|
|
2012-10-18 06:29:54 +08:00
|
|
|
//
|
|
|
|
// Format: BNEZ rx, offset MIPS16e
|
|
|
|
// Purpose: Branch on Not Equal to Zero (Extended)
|
|
|
|
// To test a GPR then do a PC-relative conditional branch.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def BnezRxImmX16: FEXT_RI16_B_ins<0b00101, "bnez", IIM16Alu>, cbranch16;
|
2012-10-18 06:29:54 +08:00
|
|
|
|
2013-08-07 12:00:26 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
//Format: BREAK immediate
|
|
|
|
// Purpose: Breakpoint
|
|
|
|
// To cause a Breakpoint exception.
|
|
|
|
|
2016-06-14 17:35:29 +08:00
|
|
|
def Break16: FRRBreakNull16_ins<"break 0", IIM16Alu>;
|
2012-10-18 06:29:54 +08:00
|
|
|
//
|
|
|
|
// Format: BTEQZ offset MIPS16e
|
|
|
|
// Purpose: Branch on T Equal to Zero (Extended)
|
|
|
|
// To test special register T then do a PC-relative conditional branch.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def Bteqz16: FI816_ins<0b000, "bteqz", IIM16Alu>, cbranch16 {
|
2013-11-15 10:21:52 +08:00
|
|
|
let Uses = [T8];
|
|
|
|
}
|
|
|
|
|
2015-09-22 20:36:28 +08:00
|
|
|
def BteqzX16: FEXT_I816_ins<0b000, "bteqz", IIM16Alu>, cbranch16 {
|
2013-02-18 08:59:04 +08:00
|
|
|
let Uses = [T8];
|
|
|
|
}
|
2012-10-18 06:29:54 +08:00
|
|
|
|
2013-02-17 07:39:52 +08:00
|
|
|
def BteqzT8CmpX16: FEXT_T8I816_ins<"bteqz", "cmp">, cbranch16;
|
2012-10-18 06:29:54 +08:00
|
|
|
|
2013-02-17 07:39:52 +08:00
|
|
|
def BteqzT8CmpiX16: FEXT_T8I8I16_ins<"bteqz", "cmpi">,
|
2012-10-18 06:29:54 +08:00
|
|
|
cbranch16;
|
|
|
|
|
2013-02-17 07:39:52 +08:00
|
|
|
def BteqzT8SltX16: FEXT_T8I816_ins<"bteqz", "slt">, cbranch16;
|
2012-10-18 06:29:54 +08:00
|
|
|
|
2013-02-17 07:39:52 +08:00
|
|
|
def BteqzT8SltuX16: FEXT_T8I816_ins<"bteqz", "sltu">, cbranch16;
|
2012-10-18 06:29:54 +08:00
|
|
|
|
2013-02-17 07:39:52 +08:00
|
|
|
def BteqzT8SltiX16: FEXT_T8I8I16_ins<"bteqz", "slti">, cbranch16;
|
2012-10-18 06:29:54 +08:00
|
|
|
|
2013-02-17 07:39:52 +08:00
|
|
|
def BteqzT8SltiuX16: FEXT_T8I8I16_ins<"bteqz", "sltiu">,
|
2012-10-18 06:29:54 +08:00
|
|
|
cbranch16;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Format: BTNEZ offset MIPS16e
|
|
|
|
// Purpose: Branch on T Not Equal to Zero (Extended)
|
|
|
|
// To test special register T then do a PC-relative conditional branch.
|
|
|
|
//
|
2013-11-15 10:21:52 +08:00
|
|
|
|
2015-09-22 20:36:28 +08:00
|
|
|
def Btnez16: FI816_ins<0b001, "btnez", IIM16Alu>, cbranch16 {
|
2013-11-15 10:21:52 +08:00
|
|
|
let Uses = [T8];
|
|
|
|
}
|
|
|
|
|
2015-09-22 20:36:28 +08:00
|
|
|
def BtnezX16: FEXT_I816_ins<0b001, "btnez", IIM16Alu> ,cbranch16 {
|
2013-02-18 08:59:04 +08:00
|
|
|
let Uses = [T8];
|
|
|
|
}
|
2012-10-18 06:29:54 +08:00
|
|
|
|
2013-02-17 07:39:52 +08:00
|
|
|
def BtnezT8CmpX16: FEXT_T8I816_ins<"btnez", "cmp">, cbranch16;
|
2012-10-18 06:29:54 +08:00
|
|
|
|
2013-02-17 07:39:52 +08:00
|
|
|
def BtnezT8CmpiX16: FEXT_T8I8I16_ins<"btnez", "cmpi">, cbranch16;
|
2012-10-18 06:29:54 +08:00
|
|
|
|
2013-02-17 07:39:52 +08:00
|
|
|
def BtnezT8SltX16: FEXT_T8I816_ins<"btnez", "slt">, cbranch16;
|
2012-10-18 06:29:54 +08:00
|
|
|
|
2013-02-17 07:39:52 +08:00
|
|
|
def BtnezT8SltuX16: FEXT_T8I816_ins<"btnez", "sltu">, cbranch16;
|
2012-10-18 06:29:54 +08:00
|
|
|
|
2013-02-17 07:39:52 +08:00
|
|
|
def BtnezT8SltiX16: FEXT_T8I8I16_ins<"btnez", "slti">, cbranch16;
|
2012-10-18 06:29:54 +08:00
|
|
|
|
2013-02-17 07:39:52 +08:00
|
|
|
def BtnezT8SltiuX16: FEXT_T8I8I16_ins<"btnez", "sltiu">,
|
2012-10-18 06:29:54 +08:00
|
|
|
cbranch16;
|
|
|
|
|
2013-02-18 08:59:04 +08:00
|
|
|
//
|
|
|
|
// Format: CMP rx, ry MIPS16e
|
|
|
|
// Purpose: Compare
|
|
|
|
// To compare the contents of two GPRs.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def CmpRxRy16: FRR16R_ins<0b01010, "cmp", IIM16Alu> {
|
2013-02-18 08:59:04 +08:00
|
|
|
let Defs = [T8];
|
|
|
|
}
|
|
|
|
|
2013-02-19 08:20:58 +08:00
|
|
|
//
|
|
|
|
// Format: CMPI rx, immediate MIPS16e
|
|
|
|
// Purpose: Compare Immediate
|
|
|
|
// To compare a constant with the contents of a GPR.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def CmpiRxImm16: FRI16R_ins<0b01110, "cmpi", IIM16Alu> {
|
2013-02-19 08:20:58 +08:00
|
|
|
let Defs = [T8];
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Format: CMPI rx, immediate MIPS16e
|
|
|
|
// Purpose: Compare Immediate (Extended)
|
|
|
|
// To compare a constant with the contents of a GPR.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def CmpiRxImmX16: FEXT_RI16R_ins<0b01110, "cmpi", IIM16Alu> {
|
2013-02-19 08:20:58 +08:00
|
|
|
let Defs = [T8];
|
|
|
|
}
|
|
|
|
|
2013-02-18 08:59:04 +08:00
|
|
|
|
2012-10-12 10:01:09 +08:00
|
|
|
//
|
|
|
|
// Format: DIV rx, ry MIPS16e
|
|
|
|
// Purpose: Divide Word
|
|
|
|
// To divide 32-bit signed integers.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def DivRxRy16: FRR16_div_ins<0b11010, "div", IIM16Alu> {
|
2013-08-14 08:47:08 +08:00
|
|
|
let Defs = [HI0, LO0];
|
2012-10-12 10:01:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Format: DIVU rx, ry MIPS16e
|
|
|
|
// Purpose: Divide Unsigned Word
|
|
|
|
// To divide 32-bit unsigned integers.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def DivuRxRy16: FRR16_div_ins<0b11011, "divu", IIM16Alu> {
|
2013-08-14 08:47:08 +08:00
|
|
|
let Defs = [HI0, LO0];
|
2012-10-12 10:01:09 +08:00
|
|
|
}
|
2013-02-02 12:07:35 +08:00
|
|
|
//
|
|
|
|
// Format: JAL target MIPS16e
|
|
|
|
// Purpose: Jump and Link
|
|
|
|
// To execute a procedure call within the current 256 MB-aligned
|
|
|
|
// region and preserve the current ISA.
|
|
|
|
//
|
2012-10-12 10:01:09 +08:00
|
|
|
|
2015-09-22 20:36:28 +08:00
|
|
|
def Jal16 : FJAL16_ins<0b0, "jal", IIM16Alu> {
|
2013-02-02 12:07:35 +08:00
|
|
|
let hasDelaySlot = 0; // not true, but we add the nop for now
|
2013-08-01 08:59:06 +08:00
|
|
|
let isCall=1;
|
2013-11-21 13:13:23 +08:00
|
|
|
let Defs = [RA];
|
2013-02-02 12:07:35 +08:00
|
|
|
}
|
2012-07-24 07:45:54 +08:00
|
|
|
|
2015-09-22 20:36:28 +08:00
|
|
|
def JalB16 : FJALB16_ins<0b0, "jal", IIM16Alu>, branch16 {
|
2013-11-30 06:32:56 +08:00
|
|
|
let hasDelaySlot = 0; // not true, but we add the nop for now
|
|
|
|
let isBranch=1;
|
|
|
|
let Defs = [RA];
|
|
|
|
}
|
|
|
|
|
2012-07-24 07:45:54 +08:00
|
|
|
//
|
|
|
|
// Format: JR ra MIPS16e
|
|
|
|
// Purpose: Jump Register Through Register ra
|
|
|
|
// To execute a branch to the instruction address in the return
|
|
|
|
// address register.
|
|
|
|
//
|
|
|
|
|
2015-09-22 20:36:28 +08:00
|
|
|
def JrRa16: FRR16_JALRC_RA_only_ins<0, 0, "jr", IIM16Alu> {
|
2012-10-28 14:02:37 +08:00
|
|
|
let isBranch = 1;
|
|
|
|
let isIndirectBranch = 1;
|
|
|
|
let hasDelaySlot = 1;
|
|
|
|
let isTerminator=1;
|
|
|
|
let isBarrier=1;
|
2017-02-15 05:53:23 +08:00
|
|
|
let isReturn=1;
|
2012-10-28 14:02:37 +08:00
|
|
|
}
|
2012-10-29 07:08:07 +08:00
|
|
|
|
2015-09-22 20:36:28 +08:00
|
|
|
def JrcRa16: FRR16_JALRC_RA_only_ins<1, 1, "jrc", IIM16Alu> {
|
2012-10-30 08:54:49 +08:00
|
|
|
let isBranch = 1;
|
|
|
|
let isIndirectBranch = 1;
|
|
|
|
let isTerminator=1;
|
|
|
|
let isBarrier=1;
|
2017-02-15 05:53:23 +08:00
|
|
|
let isReturn=1;
|
2012-10-30 08:54:49 +08:00
|
|
|
}
|
|
|
|
|
2015-09-22 20:36:28 +08:00
|
|
|
def JrcRx16: FRR16_JALRC_ins<1, 1, 0, "jrc", IIM16Alu> {
|
2012-10-29 07:08:07 +08:00
|
|
|
let isBranch = 1;
|
|
|
|
let isIndirectBranch = 1;
|
|
|
|
let isTerminator=1;
|
|
|
|
let isBarrier=1;
|
|
|
|
}
|
2012-08-04 06:57:02 +08:00
|
|
|
//
|
|
|
|
// Format: LB ry, offset(rx) MIPS16e
|
|
|
|
// Purpose: Load Byte (Extended)
|
|
|
|
// To load a byte from memory as a signed value.
|
|
|
|
//
|
2014-01-21 23:21:14 +08:00
|
|
|
def LbRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10011, "lb", mem16, II_LB>, MayLoad{
|
2013-02-14 11:05:25 +08:00
|
|
|
let isCodeGenOnly = 1;
|
|
|
|
}
|
2012-08-04 06:57:02 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: LBU ry, offset(rx) MIPS16e
|
|
|
|
// Purpose: Load Byte Unsigned (Extended)
|
|
|
|
// To load a byte from memory as a unsigned value.
|
|
|
|
//
|
2012-09-28 10:26:24 +08:00
|
|
|
def LbuRxRyOffMemX16:
|
2014-01-21 23:21:14 +08:00
|
|
|
FEXT_RRI16_mem_ins<0b10100, "lbu", mem16, II_LBU>, MayLoad {
|
2013-02-14 11:05:25 +08:00
|
|
|
let isCodeGenOnly = 1;
|
|
|
|
}
|
2012-08-04 06:57:02 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: LH ry, offset(rx) MIPS16e
|
|
|
|
// Purpose: Load Halfword signed (Extended)
|
|
|
|
// To load a halfword from memory as a signed value.
|
|
|
|
//
|
2014-01-21 23:21:14 +08:00
|
|
|
def LhRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10100, "lh", mem16, II_LH>, MayLoad{
|
2013-02-14 11:05:25 +08:00
|
|
|
let isCodeGenOnly = 1;
|
|
|
|
}
|
2012-08-04 06:57:02 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: LHU ry, offset(rx) MIPS16e
|
|
|
|
// Purpose: Load Halfword unsigned (Extended)
|
|
|
|
// To load a halfword from memory as an unsigned value.
|
|
|
|
//
|
2012-09-28 10:26:24 +08:00
|
|
|
def LhuRxRyOffMemX16:
|
2014-01-21 23:21:14 +08:00
|
|
|
FEXT_RRI16_mem_ins<0b10100, "lhu", mem16, II_LHU>, MayLoad {
|
2013-02-14 11:05:25 +08:00
|
|
|
let isCodeGenOnly = 1;
|
|
|
|
}
|
2012-08-04 06:57:02 +08:00
|
|
|
|
2013-02-20 13:45:15 +08:00
|
|
|
//
|
|
|
|
// Format: LI rx, immediate MIPS16e
|
|
|
|
// Purpose: Load Immediate
|
|
|
|
// To load a constant into a GPR.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def LiRxImm16: FRI16_ins<0b01101, "li", IIM16Alu>;
|
2013-02-20 13:45:15 +08:00
|
|
|
|
2012-07-24 07:45:54 +08:00
|
|
|
//
|
|
|
|
// Format: LI rx, immediate MIPS16e
|
|
|
|
// Purpose: Load Immediate (Extended)
|
|
|
|
// To load a constant into a GPR.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def LiRxImmX16: FEXT_RI16_ins<0b01101, "li", IIM16Alu>;
|
2012-07-24 07:45:54 +08:00
|
|
|
|
2015-09-22 20:36:28 +08:00
|
|
|
def LiRxImmAlignX16: FEXT_RI16_ins<0b01101, ".align 2\n\tli", IIM16Alu> {
|
2013-09-19 06:46:09 +08:00
|
|
|
let isCodeGenOnly = 1;
|
|
|
|
}
|
|
|
|
|
2012-07-24 07:45:54 +08:00
|
|
|
//
|
|
|
|
// Format: LW ry, offset(rx) MIPS16e
|
|
|
|
// Purpose: Load Word (Extended)
|
|
|
|
// To load a word from memory as a signed value.
|
|
|
|
//
|
2014-01-21 23:21:14 +08:00
|
|
|
def LwRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10011, "lw", mem16, II_LW>, MayLoad{
|
2013-02-14 11:05:25 +08:00
|
|
|
let isCodeGenOnly = 1;
|
|
|
|
}
|
2012-09-28 10:26:24 +08:00
|
|
|
|
|
|
|
// Format: LW rx, offset(sp) MIPS16e
|
|
|
|
// Purpose: Load Word (SP-Relative, Extended)
|
|
|
|
// To load an SP-relative word from memory as a signed value.
|
|
|
|
//
|
2016-06-16 18:20:59 +08:00
|
|
|
def LwRxSpImmX16: FEXT_RRI16_mem_ins<0b10010, "lw", mem16sp, II_LW>, MayLoad;
|
2012-07-24 07:45:54 +08:00
|
|
|
|
2014-01-21 23:21:14 +08:00
|
|
|
def LwRxPcTcp16: FRI16_TCP_ins<0b10110, "lw", II_LW>, MayLoad;
|
2013-11-05 16:14:14 +08:00
|
|
|
|
2014-01-21 23:21:14 +08:00
|
|
|
def LwRxPcTcpX16: FEXT_RI16_TCP_ins<0b10110, "lw", II_LW>, MayLoad;
|
2012-07-24 07:45:54 +08:00
|
|
|
//
|
|
|
|
// Format: MOVE r32, rz MIPS16e
|
|
|
|
// Purpose: Move
|
|
|
|
// To move the contents of a GPR to a GPR.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def Move32R16: FI8_MOV32R16_ins<"move", IIM16Alu>;
|
2012-09-14 11:21:56 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: MOVE ry, r32 MIPS16e
|
|
|
|
//Purpose: Move
|
|
|
|
// To move the contents of a GPR to a GPR.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def MoveR3216: FI8_MOVR3216_ins<"move", IIM16Alu>;
|
2012-08-04 06:57:02 +08:00
|
|
|
|
2012-10-06 02:27:54 +08:00
|
|
|
//
|
|
|
|
// Format: MFHI rx MIPS16e
|
|
|
|
// Purpose: Move From HI Register
|
|
|
|
// To copy the special purpose HI register to a GPR.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def Mfhi16: FRR16_M_ins<0b10000, "mfhi", IIM16Alu> {
|
2013-08-14 08:47:08 +08:00
|
|
|
let Uses = [HI0];
|
2014-11-26 08:46:26 +08:00
|
|
|
let hasSideEffects = 0;
|
2012-10-06 02:27:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Format: MFLO rx MIPS16e
|
|
|
|
// Purpose: Move From LO Register
|
|
|
|
// To copy the special purpose LO register to a GPR.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def Mflo16: FRR16_M_ins<0b10010, "mflo", IIM16Alu> {
|
2013-08-14 08:47:08 +08:00
|
|
|
let Uses = [LO0];
|
2014-11-26 08:46:26 +08:00
|
|
|
let hasSideEffects = 0;
|
2012-10-06 02:27:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Pseudo Instruction for mult
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def MultRxRy16: FMULT16_ins<"mult", IIM16Alu> {
|
2012-10-06 02:27:54 +08:00
|
|
|
let isCommutable = 1;
|
2014-11-26 08:46:26 +08:00
|
|
|
let hasSideEffects = 0;
|
2013-08-14 08:47:08 +08:00
|
|
|
let Defs = [HI0, LO0];
|
2012-10-06 02:27:54 +08:00
|
|
|
}
|
|
|
|
|
2015-09-22 20:36:28 +08:00
|
|
|
def MultuRxRy16: FMULT16_ins<"multu", IIM16Alu> {
|
2012-10-06 02:27:54 +08:00
|
|
|
let isCommutable = 1;
|
2014-11-26 08:46:26 +08:00
|
|
|
let hasSideEffects = 0;
|
2013-08-14 08:47:08 +08:00
|
|
|
let Defs = [HI0, LO0];
|
2012-10-06 02:27:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Format: MULT rx, ry MIPS16e
|
|
|
|
// Purpose: Multiply Word
|
|
|
|
// To multiply 32-bit signed integers.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def MultRxRyRz16: FMULT16_LO_ins<"mult", IIM16Alu> {
|
2012-10-06 02:27:54 +08:00
|
|
|
let isCommutable = 1;
|
2014-11-26 08:46:26 +08:00
|
|
|
let hasSideEffects = 0;
|
2013-08-14 08:47:08 +08:00
|
|
|
let Defs = [HI0, LO0];
|
2012-10-06 02:27:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Format: MULTU rx, ry MIPS16e
|
|
|
|
// Purpose: Multiply Unsigned Word
|
|
|
|
// To multiply 32-bit unsigned integers.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def MultuRxRyRz16: FMULT16_LO_ins<"multu", IIM16Alu> {
|
2012-10-06 02:27:54 +08:00
|
|
|
let isCommutable = 1;
|
2014-11-26 08:46:26 +08:00
|
|
|
let hasSideEffects = 0;
|
2013-08-14 08:47:08 +08:00
|
|
|
let Defs = [HI0, LO0];
|
2012-10-06 02:27:54 +08:00
|
|
|
}
|
|
|
|
|
2012-08-04 06:57:02 +08:00
|
|
|
//
|
|
|
|
// Format: NEG rx, ry MIPS16e
|
|
|
|
// Purpose: Negate
|
|
|
|
// To negate an integer value.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def NegRxRy16: FUnaryRR16_ins<0b11101, "neg", IIM16Alu>;
|
2012-08-04 06:57:02 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: NOT rx, ry MIPS16e
|
|
|
|
// Purpose: Not
|
|
|
|
// To complement an integer value
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def NotRxRy16: FUnaryRR16_ins<0b01111, "not", IIM16Alu>;
|
2012-08-04 06:57:02 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: OR rx, ry MIPS16e
|
|
|
|
// Purpose: Or
|
|
|
|
// To do a bitwise logical OR.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def OrRxRxRy16: FRxRxRy16_ins<0b01101, "or", IIM16Alu>, ArithLogic16Defs<1>;
|
2012-08-04 06:57:02 +08:00
|
|
|
|
2012-07-24 07:45:54 +08:00
|
|
|
//
|
|
|
|
// Format: RESTORE {ra,}{s0/s1/s0-1,}{framesize}
|
|
|
|
// (All args are optional) MIPS16e
|
|
|
|
// Purpose: Restore Registers and Deallocate Stack Frame
|
|
|
|
// To deallocate a stack frame before exit from a subroutine,
|
|
|
|
// restoring return address and static registers, and adjusting
|
|
|
|
// stack
|
|
|
|
//
|
|
|
|
|
2013-12-09 00:51:52 +08:00
|
|
|
def Restore16:
|
|
|
|
FI8_SVRS16<0b1, (outs), (ins variable_ops),
|
2014-01-21 23:21:14 +08:00
|
|
|
"", [], II_RESTORE >, MayLoad {
|
2012-10-31 13:21:10 +08:00
|
|
|
let isCodeGenOnly = 1;
|
2013-12-09 00:51:52 +08:00
|
|
|
let Defs = [SP];
|
2012-12-19 12:06:15 +08:00
|
|
|
let Uses = [SP];
|
2012-10-31 13:21:10 +08:00
|
|
|
}
|
|
|
|
|
2013-12-09 00:51:52 +08:00
|
|
|
|
|
|
|
def RestoreX16:
|
|
|
|
FI8_SVRS16<0b1, (outs), (ins variable_ops),
|
2014-01-21 23:21:14 +08:00
|
|
|
"", [], II_RESTORE >, MayLoad {
|
2012-09-21 09:08:16 +08:00
|
|
|
let isCodeGenOnly = 1;
|
2012-12-19 12:06:15 +08:00
|
|
|
let Defs = [SP];
|
|
|
|
let Uses = [SP];
|
2012-09-21 09:08:16 +08:00
|
|
|
}
|
2012-07-24 07:45:54 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: SAVE {ra,}{s0/s1/s0-1,}{framesize} (All arguments are optional)
|
|
|
|
// MIPS16e
|
|
|
|
// Purpose: Save Registers and Set Up Stack Frame
|
|
|
|
// To set up a stack frame on entry to a subroutine,
|
|
|
|
// saving return address and static registers, and adjusting stack
|
|
|
|
//
|
2013-12-09 00:51:52 +08:00
|
|
|
def Save16:
|
|
|
|
FI8_SVRS16<0b1, (outs), (ins variable_ops),
|
2014-01-23 18:31:31 +08:00
|
|
|
"", [], II_SAVE >, MayStore {
|
2012-10-31 13:21:10 +08:00
|
|
|
let isCodeGenOnly = 1;
|
2013-12-09 00:51:52 +08:00
|
|
|
let Uses = [SP];
|
2012-12-19 12:06:15 +08:00
|
|
|
let Defs = [SP];
|
2012-10-31 13:21:10 +08:00
|
|
|
}
|
|
|
|
|
2013-12-09 00:51:52 +08:00
|
|
|
def SaveX16:
|
|
|
|
FI8_SVRS16<0b1, (outs), (ins variable_ops),
|
2014-01-23 18:31:31 +08:00
|
|
|
"", [], II_SAVE >, MayStore {
|
2012-09-21 09:08:16 +08:00
|
|
|
let isCodeGenOnly = 1;
|
2012-12-19 12:06:15 +08:00
|
|
|
let Uses = [SP];
|
|
|
|
let Defs = [SP];
|
2012-09-21 09:08:16 +08:00
|
|
|
}
|
2012-08-04 06:57:02 +08:00
|
|
|
//
|
|
|
|
// Format: SB ry, offset(rx) MIPS16e
|
|
|
|
// Purpose: Store Byte (Extended)
|
|
|
|
// To store a byte to memory.
|
|
|
|
//
|
2012-09-28 10:26:24 +08:00
|
|
|
def SbRxRyOffMemX16:
|
2014-01-23 18:31:31 +08:00
|
|
|
FEXT_RRI16_mem2_ins<0b11000, "sb", mem16, II_SB>, MayStore;
|
2012-08-04 06:57:02 +08:00
|
|
|
|
2013-10-08 04:46:19 +08:00
|
|
|
//
|
|
|
|
// Format: SEB rx MIPS16e
|
|
|
|
// Purpose: Sign-Extend Byte
|
|
|
|
// Sign-extend least significant byte in register rx.
|
|
|
|
//
|
|
|
|
def SebRx16
|
2015-09-22 20:36:28 +08:00
|
|
|
: FRR_SF16_ins<0b10001, 0b100, "seb", IIM16Alu>;
|
2013-10-08 04:46:19 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: SEH rx MIPS16e
|
|
|
|
// Purpose: Sign-Extend Halfword
|
|
|
|
// Sign-extend least significant word in register rx.
|
|
|
|
//
|
|
|
|
def SehRx16
|
2015-09-22 20:36:28 +08:00
|
|
|
: FRR_SF16_ins<0b10001, 0b101, "seh", IIM16Alu>;
|
2013-10-08 04:46:19 +08:00
|
|
|
|
2012-10-26 05:33:30 +08:00
|
|
|
//
|
|
|
|
// The Sel(T) instructions are pseudos
|
|
|
|
// T means that they use T8 implicitly.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Format: SelBeqZ rd, rs, rt
|
|
|
|
// Purpose: if rt==0, do nothing
|
|
|
|
// else rs = rt
|
|
|
|
//
|
2013-02-17 07:39:52 +08:00
|
|
|
def SelBeqZ: Sel<"beqz">;
|
2012-10-26 05:33:30 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: SelTBteqZCmp rd, rs, rl, rr
|
|
|
|
// Purpose: b = Cmp rl, rr.
|
|
|
|
// If b==0 then do nothing.
|
|
|
|
// if b!=0 then rd = rs
|
|
|
|
//
|
2013-02-17 07:39:52 +08:00
|
|
|
def SelTBteqZCmp: SelT<"bteqz", "cmp">;
|
2012-10-26 05:33:30 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: SelTBteqZCmpi rd, rs, rl, rr
|
|
|
|
// Purpose: b = Cmpi rl, imm.
|
|
|
|
// If b==0 then do nothing.
|
|
|
|
// if b!=0 then rd = rs
|
|
|
|
//
|
2013-02-17 07:39:52 +08:00
|
|
|
def SelTBteqZCmpi: SeliT<"bteqz", "cmpi">;
|
2012-10-26 05:33:30 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: SelTBteqZSlt rd, rs, rl, rr
|
|
|
|
// Purpose: b = Slt rl, rr.
|
|
|
|
// If b==0 then do nothing.
|
|
|
|
// if b!=0 then rd = rs
|
|
|
|
//
|
2013-02-17 07:39:52 +08:00
|
|
|
def SelTBteqZSlt: SelT<"bteqz", "slt">;
|
2012-10-26 05:33:30 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: SelTBteqZSlti rd, rs, rl, rr
|
|
|
|
// Purpose: b = Slti rl, imm.
|
|
|
|
// If b==0 then do nothing.
|
|
|
|
// if b!=0 then rd = rs
|
|
|
|
//
|
2013-02-17 07:39:52 +08:00
|
|
|
def SelTBteqZSlti: SeliT<"bteqz", "slti">;
|
2012-10-26 05:33:30 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: SelTBteqZSltu rd, rs, rl, rr
|
|
|
|
// Purpose: b = Sltu rl, rr.
|
|
|
|
// If b==0 then do nothing.
|
|
|
|
// if b!=0 then rd = rs
|
|
|
|
//
|
2013-02-17 07:39:52 +08:00
|
|
|
def SelTBteqZSltu: SelT<"bteqz", "sltu">;
|
2012-10-26 05:33:30 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: SelTBteqZSltiu rd, rs, rl, rr
|
|
|
|
// Purpose: b = Sltiu rl, imm.
|
|
|
|
// If b==0 then do nothing.
|
|
|
|
// if b!=0 then rd = rs
|
|
|
|
//
|
2013-02-17 07:39:52 +08:00
|
|
|
def SelTBteqZSltiu: SeliT<"bteqz", "sltiu">;
|
2012-10-26 05:33:30 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: SelBnez rd, rs, rt
|
|
|
|
// Purpose: if rt!=0, do nothing
|
|
|
|
// else rs = rt
|
|
|
|
//
|
2013-02-17 07:39:52 +08:00
|
|
|
def SelBneZ: Sel<"bnez">;
|
2012-10-26 05:33:30 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: SelTBtneZCmp rd, rs, rl, rr
|
|
|
|
// Purpose: b = Cmp rl, rr.
|
|
|
|
// If b!=0 then do nothing.
|
|
|
|
// if b0=0 then rd = rs
|
|
|
|
//
|
2013-02-17 07:39:52 +08:00
|
|
|
def SelTBtneZCmp: SelT<"btnez", "cmp">;
|
2012-10-26 05:33:30 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: SelTBtnezCmpi rd, rs, rl, rr
|
|
|
|
// Purpose: b = Cmpi rl, imm.
|
|
|
|
// If b!=0 then do nothing.
|
|
|
|
// if b==0 then rd = rs
|
|
|
|
//
|
2013-02-17 07:39:52 +08:00
|
|
|
def SelTBtneZCmpi: SeliT<"btnez", "cmpi">;
|
2012-10-26 05:33:30 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: SelTBtneZSlt rd, rs, rl, rr
|
|
|
|
// Purpose: b = Slt rl, rr.
|
|
|
|
// If b!=0 then do nothing.
|
|
|
|
// if b==0 then rd = rs
|
|
|
|
//
|
2013-02-17 07:39:52 +08:00
|
|
|
def SelTBtneZSlt: SelT<"btnez", "slt">;
|
2012-10-26 05:33:30 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: SelTBtneZSlti rd, rs, rl, rr
|
|
|
|
// Purpose: b = Slti rl, imm.
|
|
|
|
// If b!=0 then do nothing.
|
|
|
|
// if b==0 then rd = rs
|
|
|
|
//
|
2013-02-17 07:39:52 +08:00
|
|
|
def SelTBtneZSlti: SeliT<"btnez", "slti">;
|
2012-10-26 05:33:30 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: SelTBtneZSltu rd, rs, rl, rr
|
|
|
|
// Purpose: b = Sltu rl, rr.
|
|
|
|
// If b!=0 then do nothing.
|
|
|
|
// if b==0 then rd = rs
|
|
|
|
//
|
2013-02-17 07:39:52 +08:00
|
|
|
def SelTBtneZSltu: SelT<"btnez", "sltu">;
|
2012-10-26 05:33:30 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: SelTBtneZSltiu rd, rs, rl, rr
|
|
|
|
// Purpose: b = Slti rl, imm.
|
|
|
|
// If b!=0 then do nothing.
|
|
|
|
// if b==0 then rd = rs
|
|
|
|
//
|
2013-02-17 07:39:52 +08:00
|
|
|
def SelTBtneZSltiu: SeliT<"btnez", "sltiu">;
|
2012-10-26 05:33:30 +08:00
|
|
|
//
|
2012-08-04 06:57:02 +08:00
|
|
|
//
|
|
|
|
// Format: SH ry, offset(rx) MIPS16e
|
|
|
|
// Purpose: Store Halfword (Extended)
|
|
|
|
// To store a halfword to memory.
|
|
|
|
//
|
2012-09-28 10:26:24 +08:00
|
|
|
def ShRxRyOffMemX16:
|
2014-01-23 18:31:31 +08:00
|
|
|
FEXT_RRI16_mem2_ins<0b11001, "sh", mem16, II_SH>, MayStore;
|
2012-08-04 06:57:02 +08:00
|
|
|
|
2012-07-24 07:45:54 +08:00
|
|
|
//
|
|
|
|
// Format: SLL rx, ry, sa MIPS16e
|
|
|
|
// Purpose: Shift Word Left Logical (Extended)
|
2013-10-28 12:07:38 +08:00
|
|
|
// To execute a left-shift of a word by a fixed number of bits-0 to 31 bits.
|
2012-07-24 07:45:54 +08:00
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def SllX16: FEXT_SHIFT16_ins<0b00, "sll", IIM16Alu>;
|
2012-07-24 07:45:54 +08:00
|
|
|
|
2012-08-04 06:57:02 +08:00
|
|
|
//
|
|
|
|
// Format: SLLV ry, rx MIPS16e
|
|
|
|
// Purpose: Shift Word Left Logical Variable
|
|
|
|
// To execute a left-shift of a word by a variable number of bits.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def SllvRxRy16 : FRxRxRy16_ins<0b00100, "sllv", IIM16Alu>;
|
2012-08-04 06:57:02 +08:00
|
|
|
|
2013-02-19 11:56:57 +08:00
|
|
|
// Format: SLTI rx, immediate MIPS16e
|
|
|
|
// Purpose: Set on Less Than Immediate
|
|
|
|
// To record the result of a less-than comparison with a constant.
|
|
|
|
//
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def SltiRxImm16: FRI16R_ins<0b01010, "slti", IIM16Alu> {
|
2013-02-19 11:56:57 +08:00
|
|
|
let Defs = [T8];
|
|
|
|
}
|
|
|
|
|
2012-10-23 09:35:48 +08:00
|
|
|
//
|
|
|
|
// Format: SLTI rx, immediate MIPS16e
|
|
|
|
// Purpose: Set on Less Than Immediate (Extended)
|
|
|
|
// To record the result of a less-than comparison with a constant.
|
|
|
|
//
|
2013-02-19 11:56:57 +08:00
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def SltiRxImmX16: FEXT_RI16R_ins<0b01010, "slti", IIM16Alu> {
|
2013-02-19 11:56:57 +08:00
|
|
|
let Defs = [T8];
|
|
|
|
}
|
|
|
|
|
2013-02-17 07:39:52 +08:00
|
|
|
def SltiCCRxImmX16: FEXT_CCRXI16_ins<"slti">;
|
2012-10-23 09:35:48 +08:00
|
|
|
|
2013-02-19 11:56:57 +08:00
|
|
|
// Format: SLTIU rx, immediate MIPS16e
|
|
|
|
// Purpose: Set on Less Than Immediate Unsigned
|
|
|
|
// To record the result of a less-than comparison with a constant.
|
|
|
|
//
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def SltiuRxImm16: FRI16R_ins<0b01011, "sltiu", IIM16Alu> {
|
2013-02-19 11:56:57 +08:00
|
|
|
let Defs = [T8];
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Format: SLTI rx, immediate MIPS16e
|
|
|
|
// Purpose: Set on Less Than Immediate Unsigned (Extended)
|
|
|
|
// To record the result of a less-than comparison with a constant.
|
|
|
|
//
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def SltiuRxImmX16: FEXT_RI16R_ins<0b01011, "sltiu", IIM16Alu> {
|
2013-02-19 11:56:57 +08:00
|
|
|
let Defs = [T8];
|
|
|
|
}
|
2012-10-23 09:35:48 +08:00
|
|
|
//
|
|
|
|
// Format: SLTIU rx, immediate MIPS16e
|
|
|
|
// Purpose: Set on Less Than Immediate Unsigned (Extended)
|
|
|
|
// To record the result of a less-than comparison with a constant.
|
|
|
|
//
|
2013-02-17 07:39:52 +08:00
|
|
|
def SltiuCCRxImmX16: FEXT_CCRXI16_ins<"sltiu">;
|
2012-10-23 09:35:48 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: SLT rx, ry MIPS16e
|
|
|
|
// Purpose: Set on Less Than
|
|
|
|
// To record the result of a less-than comparison.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def SltRxRy16: FRR16R_ins<0b00010, "slt", IIM16Alu>{
|
2013-02-20 13:45:15 +08:00
|
|
|
let Defs = [T8];
|
|
|
|
}
|
2012-10-23 09:35:48 +08:00
|
|
|
|
2013-02-17 07:39:52 +08:00
|
|
|
def SltCCRxRy16: FCCRR16_ins<"slt">;
|
2012-10-23 09:35:48 +08:00
|
|
|
|
|
|
|
// Format: SLTU rx, ry MIPS16e
|
|
|
|
// Purpose: Set on Less Than Unsigned
|
|
|
|
// To record the result of an unsigned less-than comparison.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def SltuRxRy16: FRR16R_ins<0b00011, "sltu", IIM16Alu>{
|
2013-02-20 13:45:15 +08:00
|
|
|
let Defs = [T8];
|
|
|
|
}
|
2013-02-18 12:55:38 +08:00
|
|
|
|
2013-02-17 07:39:52 +08:00
|
|
|
def SltuRxRyRz16: FRRTR16_ins<"sltu"> {
|
2012-10-26 12:46:26 +08:00
|
|
|
let isCodeGenOnly=1;
|
2013-02-20 13:45:15 +08:00
|
|
|
let Defs = [T8];
|
2012-10-26 12:46:26 +08:00
|
|
|
}
|
2012-10-23 09:35:48 +08:00
|
|
|
|
2012-08-04 06:57:02 +08:00
|
|
|
|
2013-02-17 07:39:52 +08:00
|
|
|
def SltuCCRxRy16: FCCRR16_ins<"sltu">;
|
2012-08-04 06:57:02 +08:00
|
|
|
//
|
|
|
|
// Format: SRAV ry, rx MIPS16e
|
|
|
|
// Purpose: Shift Word Right Arithmetic Variable
|
|
|
|
// To execute an arithmetic right-shift of a word by a variable
|
|
|
|
// number of bits.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def SravRxRy16: FRxRxRy16_ins<0b00111, "srav", IIM16Alu>;
|
2012-08-04 06:57:02 +08:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Format: SRA rx, ry, sa MIPS16e
|
|
|
|
// Purpose: Shift Word Right Arithmetic (Extended)
|
|
|
|
// To execute an arithmetic right-shift of a word by a fixed
|
2013-10-28 12:07:38 +08:00
|
|
|
// number of bits-1 to 8 bits.
|
2012-08-04 06:57:02 +08:00
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def SraX16: FEXT_SHIFT16_ins<0b11, "sra", IIM16Alu>;
|
2012-08-04 06:57:02 +08:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Format: SRLV ry, rx MIPS16e
|
|
|
|
// Purpose: Shift Word Right Logical Variable
|
|
|
|
// To execute a logical right-shift of a word by a variable
|
|
|
|
// number of bits.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def SrlvRxRy16: FRxRxRy16_ins<0b00110, "srlv", IIM16Alu>;
|
2012-08-04 06:57:02 +08:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Format: SRL rx, ry, sa MIPS16e
|
|
|
|
// Purpose: Shift Word Right Logical (Extended)
|
|
|
|
// To execute a logical right-shift of a word by a fixed
|
2013-10-28 12:07:38 +08:00
|
|
|
// number of bits-1 to 31 bits.
|
2012-08-04 06:57:02 +08:00
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def SrlX16: FEXT_SHIFT16_ins<0b10, "srl", IIM16Alu>;
|
2012-08-04 06:57:02 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: SUBU rz, rx, ry MIPS16e
|
|
|
|
// Purpose: Subtract Unsigned Word
|
|
|
|
// To subtract 32-bit integers
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def SubuRxRyRz16: FRRR16_ins<0b11, "subu", IIM16Alu>, ArithLogic16Defs<0>;
|
2012-08-04 06:57:02 +08:00
|
|
|
|
2012-07-24 07:45:54 +08:00
|
|
|
//
|
|
|
|
// Format: SW ry, offset(rx) MIPS16e
|
|
|
|
// Purpose: Store Word (Extended)
|
|
|
|
// To store a word to memory.
|
|
|
|
//
|
2016-06-16 18:20:59 +08:00
|
|
|
def SwRxRyOffMemX16: FEXT_RRI16_mem2_ins<0b11011, "sw", mem16, II_SW>, MayStore;
|
2012-09-28 10:26:24 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Format: SW rx, offset(sp) MIPS16e
|
|
|
|
// Purpose: Store Word rx (SP-Relative)
|
|
|
|
// To store an SP-relative word to memory.
|
|
|
|
//
|
2016-06-16 18:20:59 +08:00
|
|
|
def SwRxSpImmX16: FEXT_RRI16_mem2_ins<0b11010, "sw", mem16sp, II_SW>, MayStore;
|
2012-08-04 06:57:02 +08:00
|
|
|
|
2012-09-28 10:26:24 +08:00
|
|
|
//
|
2012-08-04 06:57:02 +08:00
|
|
|
//
|
|
|
|
// Format: XOR rx, ry MIPS16e
|
|
|
|
// Purpose: Xor
|
|
|
|
// To do a bitwise logical XOR.
|
|
|
|
//
|
2015-09-22 20:36:28 +08:00
|
|
|
def XorRxRxRy16: FRxRxRy16_ins<0b01110, "xor", IIM16Alu>, ArithLogic16Defs<1>;
|
2012-07-24 07:45:54 +08:00
|
|
|
|
2012-06-22 04:39:10 +08:00
|
|
|
class Mips16Pat<dag pattern, dag result> : Pat<pattern, result> {
|
|
|
|
let Predicates = [InMips16Mode];
|
|
|
|
}
|
|
|
|
|
2012-08-04 06:57:02 +08:00
|
|
|
// Unary Arith/Logic
|
|
|
|
//
|
|
|
|
class ArithLogicU_pat<PatFrag OpNode, Instruction I> :
|
|
|
|
Mips16Pat<(OpNode CPU16Regs:$r),
|
|
|
|
(I CPU16Regs:$r)>;
|
2012-07-21 10:15:19 +08:00
|
|
|
|
2012-08-04 06:57:02 +08:00
|
|
|
def: ArithLogicU_pat<not, NotRxRy16>;
|
|
|
|
def: ArithLogicU_pat<ineg, NegRxRy16>;
|
2012-07-21 10:15:19 +08:00
|
|
|
|
2012-08-04 06:57:02 +08:00
|
|
|
class ArithLogic16_pat<SDNode OpNode, Instruction I> :
|
|
|
|
Mips16Pat<(OpNode CPU16Regs:$l, CPU16Regs:$r),
|
|
|
|
(I CPU16Regs:$l, CPU16Regs:$r)>;
|
2012-07-21 10:15:19 +08:00
|
|
|
|
2012-08-04 06:57:02 +08:00
|
|
|
def: ArithLogic16_pat<add, AdduRxRyRz16>;
|
|
|
|
def: ArithLogic16_pat<and, AndRxRxRy16>;
|
2012-10-06 02:27:54 +08:00
|
|
|
def: ArithLogic16_pat<mul, MultRxRyRz16>;
|
2012-08-04 06:57:02 +08:00
|
|
|
def: ArithLogic16_pat<or, OrRxRxRy16>;
|
|
|
|
def: ArithLogic16_pat<sub, SubuRxRyRz16>;
|
|
|
|
def: ArithLogic16_pat<xor, XorRxRxRy16>;
|
2012-07-24 07:45:54 +08:00
|
|
|
|
2012-08-04 06:57:02 +08:00
|
|
|
// Arithmetic and logical instructions with 2 register operands.
|
2012-07-24 07:45:54 +08:00
|
|
|
|
2012-08-04 06:57:02 +08:00
|
|
|
class ArithLogicI16_pat<SDNode OpNode, PatFrag imm_type, Instruction I> :
|
|
|
|
Mips16Pat<(OpNode CPU16Regs:$in, imm_type:$imm),
|
|
|
|
(I CPU16Regs:$in, imm_type:$imm)>;
|
2012-07-24 07:45:54 +08:00
|
|
|
|
2013-02-09 05:42:56 +08:00
|
|
|
def: ArithLogicI16_pat<add, immSExt8, AddiuRxRxImm16>;
|
2012-08-04 06:57:02 +08:00
|
|
|
def: ArithLogicI16_pat<add, immSExt16, AddiuRxRxImmX16>;
|
|
|
|
def: ArithLogicI16_pat<shl, immZExt5, SllX16>;
|
|
|
|
def: ArithLogicI16_pat<srl, immZExt5, SrlX16>;
|
|
|
|
def: ArithLogicI16_pat<sra, immZExt5, SraX16>;
|
2012-07-24 07:45:54 +08:00
|
|
|
|
2012-08-04 06:57:02 +08:00
|
|
|
class shift_rotate_reg16_pat<SDNode OpNode, Instruction I> :
|
|
|
|
Mips16Pat<(OpNode CPU16Regs:$r, CPU16Regs:$ra),
|
|
|
|
(I CPU16Regs:$r, CPU16Regs:$ra)>;
|
|
|
|
|
|
|
|
def: shift_rotate_reg16_pat<shl, SllvRxRy16>;
|
|
|
|
def: shift_rotate_reg16_pat<sra, SravRxRy16>;
|
|
|
|
def: shift_rotate_reg16_pat<srl, SrlvRxRy16>;
|
|
|
|
|
2016-06-16 18:20:59 +08:00
|
|
|
class LoadM16_pat<PatFrag OpNode, Instruction I, ComplexPattern Addr> :
|
|
|
|
Mips16Pat<(OpNode Addr:$addr), (I Addr:$addr)>;
|
2012-08-04 06:57:02 +08:00
|
|
|
|
2016-06-16 18:20:59 +08:00
|
|
|
def: LoadM16_pat<sextloadi8, LbRxRyOffMemX16, addr16>;
|
|
|
|
def: LoadM16_pat<zextloadi8, LbuRxRyOffMemX16, addr16>;
|
|
|
|
def: LoadM16_pat<sextloadi16, LhRxRyOffMemX16, addr16>;
|
|
|
|
def: LoadM16_pat<zextloadi16, LhuRxRyOffMemX16, addr16>;
|
|
|
|
def: LoadM16_pat<load, LwRxSpImmX16, addr16sp>;
|
2012-08-04 06:57:02 +08:00
|
|
|
|
2016-06-16 18:20:59 +08:00
|
|
|
class StoreM16_pat<PatFrag OpNode, Instruction I, ComplexPattern Addr> :
|
|
|
|
Mips16Pat<(OpNode CPU16Regs:$r, Addr:$addr), (I CPU16Regs:$r, Addr:$addr)>;
|
2012-08-04 06:57:02 +08:00
|
|
|
|
2016-06-16 18:20:59 +08:00
|
|
|
def: StoreM16_pat<truncstorei8, SbRxRyOffMemX16, addr16>;
|
|
|
|
def: StoreM16_pat<truncstorei16, ShRxRyOffMemX16, addr16>;
|
|
|
|
def: StoreM16_pat<store, SwRxSpImmX16, addr16sp>;
|
2012-05-31 10:59:44 +08:00
|
|
|
|
2012-10-18 06:29:54 +08:00
|
|
|
// Unconditional branch
|
|
|
|
class UncondBranch16_pat<SDNode OpNode, Instruction I>:
|
|
|
|
Mips16Pat<(OpNode bb:$imm16), (I bb:$imm16)> {
|
2013-02-07 11:49:51 +08:00
|
|
|
let Predicates = [InMips16Mode];
|
2012-10-18 06:29:54 +08:00
|
|
|
}
|
2012-05-31 10:59:44 +08:00
|
|
|
|
2013-02-02 12:07:35 +08:00
|
|
|
def : Mips16Pat<(MipsJmpLink (i32 tglobaladdr:$dst)),
|
|
|
|
(Jal16 tglobaladdr:$dst)>;
|
|
|
|
|
2013-02-07 12:34:51 +08:00
|
|
|
def : Mips16Pat<(MipsJmpLink (i32 texternalsym:$dst)),
|
|
|
|
(Jal16 texternalsym:$dst)>;
|
|
|
|
|
2012-10-29 07:08:07 +08:00
|
|
|
// Indirect branch
|
2014-07-09 18:21:59 +08:00
|
|
|
def: Mips16Pat<(brind CPU16Regs:$rs), (JrcRx16 CPU16Regs:$rs)> {
|
|
|
|
// Ensure that the addition of MIPS32r6/MIPS64r6 support does not change
|
|
|
|
// MIPS16's behaviour.
|
|
|
|
let AddedComplexity = 1;
|
|
|
|
}
|
2012-10-29 07:08:07 +08:00
|
|
|
|
2012-05-31 10:59:44 +08:00
|
|
|
// Jump and Link (Call)
|
2012-10-30 08:54:49 +08:00
|
|
|
let isCall=1, hasDelaySlot=0 in
|
2012-05-31 10:59:44 +08:00
|
|
|
def JumpLinkReg16:
|
2012-07-18 06:55:34 +08:00
|
|
|
FRR16_JALRC<0, 0, 0, (outs), (ins CPU16Regs:$rs),
|
2017-11-27 22:25:36 +08:00
|
|
|
"jalrc\t$rs", [(MipsJmpLink CPU16Regs:$rs)], II_JALRC> {
|
2013-12-16 04:49:30 +08:00
|
|
|
let Defs = [RA];
|
|
|
|
}
|
2012-07-18 06:55:34 +08:00
|
|
|
|
2012-07-24 07:45:54 +08:00
|
|
|
// Mips16 pseudos
|
|
|
|
let isReturn=1, isTerminator=1, hasDelaySlot=1, isBarrier=1, hasCtrlDep=1,
|
|
|
|
hasExtraSrcRegAllocReq = 1 in
|
|
|
|
def RetRA16 : MipsPseudo16<(outs), (ins), "", [(MipsRet)]>;
|
|
|
|
|
2012-10-18 06:29:54 +08:00
|
|
|
|
2012-10-23 09:35:48 +08:00
|
|
|
// setcc patterns
|
|
|
|
|
|
|
|
class SetCC_R16<PatFrag cond_op, Instruction I>:
|
|
|
|
Mips16Pat<(cond_op CPU16Regs:$rx, CPU16Regs:$ry),
|
|
|
|
(I CPU16Regs:$rx, CPU16Regs:$ry)>;
|
|
|
|
|
|
|
|
class SetCC_I16<PatFrag cond_op, PatLeaf imm_type, Instruction I>:
|
|
|
|
Mips16Pat<(cond_op CPU16Regs:$rx, imm_type:$imm16),
|
2012-10-26 05:33:30 +08:00
|
|
|
(I CPU16Regs:$rx, imm_type:$imm16)>;
|
2012-10-23 09:35:48 +08:00
|
|
|
|
2012-10-28 14:02:37 +08:00
|
|
|
|
2016-06-16 18:20:59 +08:00
|
|
|
def: Mips16Pat<(i32 addr16sp:$addr), (AddiuRxRyOffMemX16 addr16sp:$addr)>;
|
2012-10-28 14:02:37 +08:00
|
|
|
|
|
|
|
|
2012-10-26 11:09:34 +08:00
|
|
|
// Large (>16 bit) immediate loads
|
2013-10-28 05:57:36 +08:00
|
|
|
def : Mips16Pat<(i32 imm:$imm), (LwConstant32 imm:$imm, -1)>;
|
2012-10-23 09:35:48 +08:00
|
|
|
|
2012-10-26 12:46:26 +08:00
|
|
|
// Carry MipsPatterns
|
|
|
|
def : Mips16Pat<(subc CPU16Regs:$lhs, CPU16Regs:$rhs),
|
|
|
|
(SubuRxRyRz16 CPU16Regs:$lhs, CPU16Regs:$rhs)>;
|
|
|
|
def : Mips16Pat<(addc CPU16Regs:$lhs, CPU16Regs:$rhs),
|
|
|
|
(AdduRxRyRz16 CPU16Regs:$lhs, CPU16Regs:$rhs)>;
|
|
|
|
def : Mips16Pat<(addc CPU16Regs:$src, immSExt16:$imm),
|
|
|
|
(AddiuRxRxImmX16 CPU16Regs:$src, imm:$imm)>;
|
|
|
|
|
2012-10-18 06:29:54 +08:00
|
|
|
//
|
|
|
|
// Some branch conditional patterns are not generated by llvm at this time.
|
|
|
|
// Some are for seemingly arbitrary reasons not used: i.e. with signed number
|
|
|
|
// comparison they are used and for unsigned a different pattern is used.
|
|
|
|
// I am pushing upstream from the full mips16 port and it seemed that I needed
|
|
|
|
// these earlier and the mips32 port has these but now I cannot create test
|
|
|
|
// cases that use these patterns. While I sort this all out I will leave these
|
|
|
|
// extra patterns commented out and if I can be sure they are really not used,
|
|
|
|
// I will delete the code. I don't want to check the code in uncommented without
|
|
|
|
// a valid test case. In some cases, the compiler is generating patterns with
|
|
|
|
// setcc instead and earlier I had implemented setcc first so may have masked
|
|
|
|
// the problem. The setcc variants are suboptimal for mips16 so I may wantto
|
|
|
|
// figure out how to enable the brcond patterns or else possibly new
|
|
|
|
// combinations of of brcond and setcc.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// bcond-seteq
|
|
|
|
//
|
|
|
|
def: Mips16Pat
|
|
|
|
<(brcond (i32 (seteq CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
|
|
|
|
(BteqzT8CmpX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16)
|
|
|
|
>;
|
|
|
|
|
|
|
|
|
|
|
|
def: Mips16Pat
|
|
|
|
<(brcond (i32 (seteq CPU16Regs:$rx, immZExt16:$imm)), bb:$targ16),
|
|
|
|
(BteqzT8CmpiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$targ16)
|
|
|
|
>;
|
|
|
|
|
|
|
|
def: Mips16Pat
|
|
|
|
<(brcond (i32 (seteq CPU16Regs:$rx, 0)), bb:$targ16),
|
2013-11-15 10:21:52 +08:00
|
|
|
(BeqzRxImm16 CPU16Regs:$rx, bb:$targ16)
|
2012-10-18 06:29:54 +08:00
|
|
|
>;
|
|
|
|
|
|
|
|
//
|
|
|
|
// bcond-setgt (do we need to have this pair of setlt, setgt??)
|
|
|
|
//
|
|
|
|
def: Mips16Pat
|
|
|
|
<(brcond (i32 (setgt CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
|
|
|
|
(BtnezT8SltX16 CPU16Regs:$ry, CPU16Regs:$rx, bb:$imm16)
|
|
|
|
>;
|
|
|
|
|
|
|
|
//
|
|
|
|
// bcond-setge
|
|
|
|
//
|
|
|
|
def: Mips16Pat
|
|
|
|
<(brcond (i32 (setge CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
|
|
|
|
(BteqzT8SltX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16)
|
|
|
|
>;
|
|
|
|
|
|
|
|
//
|
|
|
|
// never called because compiler transforms a >= k to a > (k-1)
|
2012-10-23 09:35:48 +08:00
|
|
|
def: Mips16Pat
|
|
|
|
<(brcond (i32 (setge CPU16Regs:$rx, immSExt16:$imm)), bb:$imm16),
|
|
|
|
(BteqzT8SltiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$imm16)
|
|
|
|
>;
|
2012-10-18 06:29:54 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// bcond-setlt
|
|
|
|
//
|
|
|
|
def: Mips16Pat
|
|
|
|
<(brcond (i32 (setlt CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
|
|
|
|
(BtnezT8SltX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16)
|
|
|
|
>;
|
|
|
|
|
|
|
|
def: Mips16Pat
|
|
|
|
<(brcond (i32 (setlt CPU16Regs:$rx, immSExt16:$imm)), bb:$imm16),
|
|
|
|
(BtnezT8SltiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$imm16)
|
|
|
|
>;
|
|
|
|
|
|
|
|
//
|
|
|
|
// bcond-setle
|
|
|
|
//
|
|
|
|
def: Mips16Pat
|
|
|
|
<(brcond (i32 (setle CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
|
|
|
|
(BteqzT8SltX16 CPU16Regs:$ry, CPU16Regs:$rx, bb:$imm16)
|
|
|
|
>;
|
|
|
|
|
|
|
|
//
|
|
|
|
// bcond-setne
|
|
|
|
//
|
|
|
|
def: Mips16Pat
|
|
|
|
<(brcond (i32 (setne CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
|
|
|
|
(BtnezT8CmpX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16)
|
|
|
|
>;
|
|
|
|
|
|
|
|
def: Mips16Pat
|
|
|
|
<(brcond (i32 (setne CPU16Regs:$rx, immZExt16:$imm)), bb:$targ16),
|
|
|
|
(BtnezT8CmpiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$targ16)
|
|
|
|
>;
|
|
|
|
|
|
|
|
def: Mips16Pat
|
|
|
|
<(brcond (i32 (setne CPU16Regs:$rx, 0)), bb:$targ16),
|
2013-11-15 10:21:52 +08:00
|
|
|
(BnezRxImm16 CPU16Regs:$rx, bb:$targ16)
|
2012-10-18 06:29:54 +08:00
|
|
|
>;
|
|
|
|
|
|
|
|
//
|
|
|
|
// This needs to be there but I forget which code will generate it
|
|
|
|
//
|
|
|
|
def: Mips16Pat
|
|
|
|
<(brcond CPU16Regs:$rx, bb:$targ16),
|
2013-11-15 10:21:52 +08:00
|
|
|
(BnezRxImm16 CPU16Regs:$rx, bb:$targ16)
|
2012-10-18 06:29:54 +08:00
|
|
|
>;
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// bcond-setugt
|
|
|
|
//
|
|
|
|
//def: Mips16Pat
|
|
|
|
// <(brcond (i32 (setugt CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
|
|
|
|
// (BtnezT8SltuX16 CPU16Regs:$ry, CPU16Regs:$rx, bb:$imm16)
|
|
|
|
// >;
|
|
|
|
|
|
|
|
//
|
|
|
|
// bcond-setuge
|
|
|
|
//
|
|
|
|
//def: Mips16Pat
|
|
|
|
// <(brcond (i32 (setuge CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
|
|
|
|
// (BteqzT8SltuX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16)
|
|
|
|
// >;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// bcond-setult
|
|
|
|
//
|
|
|
|
//def: Mips16Pat
|
|
|
|
// <(brcond (i32 (setult CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16),
|
|
|
|
// (BtnezT8SltuX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16)
|
|
|
|
// >;
|
|
|
|
|
2013-11-12 10:27:12 +08:00
|
|
|
def: UncondBranch16_pat<br, Bimm16>;
|
2012-10-18 06:29:54 +08:00
|
|
|
|
2012-06-22 04:39:10 +08:00
|
|
|
// Small immediates
|
2012-10-18 06:29:54 +08:00
|
|
|
def: Mips16Pat<(i32 immSExt16:$in),
|
2016-05-19 18:42:14 +08:00
|
|
|
(AddiuRxRxImmX16 (MoveR3216 ZERO), immSExt16:$in)>;
|
2012-10-18 06:29:54 +08:00
|
|
|
|
2012-08-04 06:57:02 +08:00
|
|
|
def: Mips16Pat<(i32 immZExt16:$in), (LiRxImmX16 immZExt16:$in)>;
|
2012-07-26 10:24:43 +08:00
|
|
|
|
2012-10-12 10:01:09 +08:00
|
|
|
//
|
|
|
|
// MipsDivRem
|
|
|
|
//
|
|
|
|
def: Mips16Pat
|
2013-03-30 09:36:35 +08:00
|
|
|
<(MipsDivRem16 CPU16Regs:$rx, CPU16Regs:$ry),
|
2012-10-12 10:01:09 +08:00
|
|
|
(DivRxRy16 CPU16Regs:$rx, CPU16Regs:$ry)>;
|
|
|
|
|
|
|
|
//
|
|
|
|
// MipsDivRemU
|
|
|
|
//
|
|
|
|
def: Mips16Pat
|
2013-03-30 09:36:35 +08:00
|
|
|
<(MipsDivRemU16 CPU16Regs:$rx, CPU16Regs:$ry),
|
2012-10-12 10:01:09 +08:00
|
|
|
(DivuRxRy16 CPU16Regs:$rx, CPU16Regs:$ry)>;
|
|
|
|
|
2012-10-26 05:33:30 +08:00
|
|
|
// signed a,b
|
|
|
|
// x = (a>=b)?x:y
|
|
|
|
//
|
|
|
|
// if !(a < b) x = y
|
|
|
|
//
|
|
|
|
def : Mips16Pat<(select (i32 (setge CPU16Regs:$a, CPU16Regs:$b)),
|
|
|
|
CPU16Regs:$x, CPU16Regs:$y),
|
|
|
|
(SelTBteqZSlt CPU16Regs:$x, CPU16Regs:$y,
|
|
|
|
CPU16Regs:$a, CPU16Regs:$b)>;
|
|
|
|
|
|
|
|
// signed a,b
|
|
|
|
// x = (a>b)?x:y
|
|
|
|
//
|
|
|
|
// if (b < a) x = y
|
|
|
|
//
|
|
|
|
def : Mips16Pat<(select (i32 (setgt CPU16Regs:$a, CPU16Regs:$b)),
|
|
|
|
CPU16Regs:$x, CPU16Regs:$y),
|
|
|
|
(SelTBtneZSlt CPU16Regs:$x, CPU16Regs:$y,
|
|
|
|
CPU16Regs:$b, CPU16Regs:$a)>;
|
|
|
|
|
|
|
|
// unsigned a,b
|
|
|
|
// x = (a>=b)?x:y
|
|
|
|
//
|
|
|
|
// if !(a < b) x = y;
|
|
|
|
//
|
|
|
|
def : Mips16Pat<
|
|
|
|
(select (i32 (setuge CPU16Regs:$a, CPU16Regs:$b)),
|
|
|
|
CPU16Regs:$x, CPU16Regs:$y),
|
|
|
|
(SelTBteqZSltu CPU16Regs:$x, CPU16Regs:$y,
|
|
|
|
CPU16Regs:$a, CPU16Regs:$b)>;
|
|
|
|
|
|
|
|
// unsigned a,b
|
|
|
|
// x = (a>b)?x:y
|
|
|
|
//
|
|
|
|
// if (b < a) x = y
|
|
|
|
//
|
|
|
|
def : Mips16Pat<(select (i32 (setugt CPU16Regs:$a, CPU16Regs:$b)),
|
|
|
|
CPU16Regs:$x, CPU16Regs:$y),
|
|
|
|
(SelTBtneZSltu CPU16Regs:$x, CPU16Regs:$y,
|
|
|
|
CPU16Regs:$b, CPU16Regs:$a)>;
|
|
|
|
|
|
|
|
// signed
|
|
|
|
// x = (a >= k)?x:y
|
|
|
|
// due to an llvm optimization, i don't think that this will ever
|
|
|
|
// be used. This is transformed into x = (a > k-1)?x:y
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
//def : Mips16Pat<
|
|
|
|
// (select (i32 (setge CPU16Regs:$lhs, immSExt16:$rhs)),
|
|
|
|
// CPU16Regs:$T, CPU16Regs:$F),
|
|
|
|
// (SelTBteqZSlti CPU16Regs:$T, CPU16Regs:$F,
|
|
|
|
// CPU16Regs:$lhs, immSExt16:$rhs)>;
|
|
|
|
|
|
|
|
//def : Mips16Pat<
|
|
|
|
// (select (i32 (setuge CPU16Regs:$lhs, immSExt16:$rhs)),
|
|
|
|
// CPU16Regs:$T, CPU16Regs:$F),
|
|
|
|
// (SelTBteqZSltiu CPU16Regs:$T, CPU16Regs:$F,
|
|
|
|
// CPU16Regs:$lhs, immSExt16:$rhs)>;
|
|
|
|
|
|
|
|
// signed
|
|
|
|
// x = (a < k)?x:y
|
|
|
|
//
|
|
|
|
// if !(a < k) x = y;
|
|
|
|
//
|
|
|
|
def : Mips16Pat<
|
|
|
|
(select (i32 (setlt CPU16Regs:$a, immSExt16:$b)),
|
|
|
|
CPU16Regs:$x, CPU16Regs:$y),
|
|
|
|
(SelTBtneZSlti CPU16Regs:$x, CPU16Regs:$y,
|
|
|
|
CPU16Regs:$a, immSExt16:$b)>;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// signed
|
|
|
|
// x = (a <= b)? x : y
|
|
|
|
//
|
|
|
|
// if (b < a) x = y
|
|
|
|
//
|
|
|
|
def : Mips16Pat<(select (i32 (setle CPU16Regs:$a, CPU16Regs:$b)),
|
|
|
|
CPU16Regs:$x, CPU16Regs:$y),
|
|
|
|
(SelTBteqZSlt CPU16Regs:$x, CPU16Regs:$y,
|
|
|
|
CPU16Regs:$b, CPU16Regs:$a)>;
|
|
|
|
|
|
|
|
//
|
|
|
|
// unnsigned
|
|
|
|
// x = (a <= b)? x : y
|
|
|
|
//
|
|
|
|
// if (b < a) x = y
|
|
|
|
//
|
|
|
|
def : Mips16Pat<(select (i32 (setule CPU16Regs:$a, CPU16Regs:$b)),
|
|
|
|
CPU16Regs:$x, CPU16Regs:$y),
|
|
|
|
(SelTBteqZSltu CPU16Regs:$x, CPU16Regs:$y,
|
|
|
|
CPU16Regs:$b, CPU16Regs:$a)>;
|
|
|
|
|
|
|
|
//
|
|
|
|
// signed/unsigned
|
|
|
|
// x = (a == b)? x : y
|
|
|
|
//
|
|
|
|
// if (a != b) x = y
|
|
|
|
//
|
|
|
|
def : Mips16Pat<(select (i32 (seteq CPU16Regs:$a, CPU16Regs:$b)),
|
|
|
|
CPU16Regs:$x, CPU16Regs:$y),
|
|
|
|
(SelTBteqZCmp CPU16Regs:$x, CPU16Regs:$y,
|
|
|
|
CPU16Regs:$b, CPU16Regs:$a)>;
|
|
|
|
|
|
|
|
//
|
|
|
|
// signed/unsigned
|
|
|
|
// x = (a == 0)? x : y
|
|
|
|
//
|
|
|
|
// if (a != 0) x = y
|
|
|
|
//
|
|
|
|
def : Mips16Pat<(select (i32 (seteq CPU16Regs:$a, 0)),
|
|
|
|
CPU16Regs:$x, CPU16Regs:$y),
|
|
|
|
(SelBeqZ CPU16Regs:$x, CPU16Regs:$y,
|
|
|
|
CPU16Regs:$a)>;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// signed/unsigned
|
|
|
|
// x = (a == k)? x : y
|
|
|
|
//
|
|
|
|
// if (a != k) x = y
|
|
|
|
//
|
|
|
|
def : Mips16Pat<(select (i32 (seteq CPU16Regs:$a, immZExt16:$k)),
|
|
|
|
CPU16Regs:$x, CPU16Regs:$y),
|
|
|
|
(SelTBteqZCmpi CPU16Regs:$x, CPU16Regs:$y,
|
|
|
|
CPU16Regs:$a, immZExt16:$k)>;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// signed/unsigned
|
|
|
|
// x = (a != b)? x : y
|
|
|
|
//
|
|
|
|
// if (a == b) x = y
|
|
|
|
//
|
|
|
|
//
|
|
|
|
def : Mips16Pat<(select (i32 (setne CPU16Regs:$a, CPU16Regs:$b)),
|
|
|
|
CPU16Regs:$x, CPU16Regs:$y),
|
|
|
|
(SelTBtneZCmp CPU16Regs:$x, CPU16Regs:$y,
|
|
|
|
CPU16Regs:$b, CPU16Regs:$a)>;
|
|
|
|
|
|
|
|
//
|
|
|
|
// signed/unsigned
|
|
|
|
// x = (a != 0)? x : y
|
|
|
|
//
|
|
|
|
// if (a == 0) x = y
|
|
|
|
//
|
|
|
|
def : Mips16Pat<(select (i32 (setne CPU16Regs:$a, 0)),
|
|
|
|
CPU16Regs:$x, CPU16Regs:$y),
|
|
|
|
(SelBneZ CPU16Regs:$x, CPU16Regs:$y,
|
|
|
|
CPU16Regs:$a)>;
|
|
|
|
|
|
|
|
// signed/unsigned
|
|
|
|
// x = (a)? x : y
|
|
|
|
//
|
|
|
|
// if (!a) x = y
|
|
|
|
//
|
|
|
|
def : Mips16Pat<(select CPU16Regs:$a,
|
|
|
|
CPU16Regs:$x, CPU16Regs:$y),
|
|
|
|
(SelBneZ CPU16Regs:$x, CPU16Regs:$y,
|
|
|
|
CPU16Regs:$a)>;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// signed/unsigned
|
|
|
|
// x = (a != k)? x : y
|
|
|
|
//
|
|
|
|
// if (a == k) x = y
|
|
|
|
//
|
|
|
|
def : Mips16Pat<(select (i32 (setne CPU16Regs:$a, immZExt16:$k)),
|
|
|
|
CPU16Regs:$x, CPU16Regs:$y),
|
|
|
|
(SelTBtneZCmpi CPU16Regs:$x, CPU16Regs:$y,
|
|
|
|
CPU16Regs:$a, immZExt16:$k)>;
|
2012-10-12 10:01:09 +08:00
|
|
|
|
2012-10-23 09:35:48 +08:00
|
|
|
//
|
|
|
|
// When writing C code to test setxx these patterns,
|
|
|
|
// some will be transformed into
|
|
|
|
// other things. So we test using C code but using -O3 and -O0
|
|
|
|
//
|
|
|
|
// seteq
|
|
|
|
//
|
|
|
|
def : Mips16Pat
|
|
|
|
<(seteq CPU16Regs:$lhs,CPU16Regs:$rhs),
|
|
|
|
(SltiuCCRxImmX16 (XorRxRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs), 1)>;
|
|
|
|
|
|
|
|
def : Mips16Pat
|
|
|
|
<(seteq CPU16Regs:$lhs, 0),
|
|
|
|
(SltiuCCRxImmX16 CPU16Regs:$lhs, 1)>;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// setge
|
|
|
|
//
|
|
|
|
|
|
|
|
def: Mips16Pat
|
|
|
|
<(setge CPU16Regs:$lhs, CPU16Regs:$rhs),
|
|
|
|
(XorRxRxRy16 (SltCCRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs),
|
|
|
|
(LiRxImmX16 1))>;
|
|
|
|
|
|
|
|
//
|
|
|
|
// For constants, llvm transforms this to:
|
2014-08-30 05:53:01 +08:00
|
|
|
// x > (k - 1) and then reverses the operands to use setlt. So this pattern
|
2012-10-23 09:35:48 +08:00
|
|
|
// is not used now by the compiler. (Presumably checking that k-1 does not
|
2014-08-30 05:53:01 +08:00
|
|
|
// overflow). The compiler never uses this at the current time, due to
|
2012-10-23 09:35:48 +08:00
|
|
|
// other optimizations.
|
|
|
|
//
|
|
|
|
//def: Mips16Pat
|
|
|
|
// <(setge CPU16Regs:$lhs, immSExt16:$rhs),
|
|
|
|
// (XorRxRxRy16 (SltiCCRxImmX16 CPU16Regs:$lhs, immSExt16:$rhs),
|
|
|
|
// (LiRxImmX16 1))>;
|
|
|
|
|
|
|
|
// This catches the x >= -32768 case by transforming it to x > -32769
|
|
|
|
//
|
|
|
|
def: Mips16Pat
|
|
|
|
<(setgt CPU16Regs:$lhs, -32769),
|
|
|
|
(XorRxRxRy16 (SltiCCRxImmX16 CPU16Regs:$lhs, -32768),
|
|
|
|
(LiRxImmX16 1))>;
|
|
|
|
|
|
|
|
//
|
|
|
|
// setgt
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
def: Mips16Pat
|
|
|
|
<(setgt CPU16Regs:$lhs, CPU16Regs:$rhs),
|
|
|
|
(SltCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs)>;
|
|
|
|
|
|
|
|
//
|
|
|
|
// setle
|
|
|
|
//
|
|
|
|
def: Mips16Pat
|
|
|
|
<(setle CPU16Regs:$lhs, CPU16Regs:$rhs),
|
2013-02-20 13:45:15 +08:00
|
|
|
(XorRxRxRy16 (SltCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs), (LiRxImm16 1))>;
|
2012-10-23 09:35:48 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// setlt
|
|
|
|
//
|
|
|
|
def: SetCC_R16<setlt, SltCCRxRy16>;
|
|
|
|
|
|
|
|
def: SetCC_I16<setlt, immSExt16, SltiCCRxImmX16>;
|
|
|
|
|
|
|
|
//
|
|
|
|
// setne
|
|
|
|
//
|
|
|
|
def : Mips16Pat
|
|
|
|
<(setne CPU16Regs:$lhs,CPU16Regs:$rhs),
|
|
|
|
(SltuCCRxRy16 (LiRxImmX16 0),
|
|
|
|
(XorRxRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs))>;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// setuge
|
|
|
|
//
|
|
|
|
def: Mips16Pat
|
|
|
|
<(setuge CPU16Regs:$lhs, CPU16Regs:$rhs),
|
|
|
|
(XorRxRxRy16 (SltuCCRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs),
|
|
|
|
(LiRxImmX16 1))>;
|
|
|
|
|
|
|
|
// this pattern will never be used because the compiler will transform
|
|
|
|
// x >= k to x > (k - 1) and then use SLT
|
|
|
|
//
|
|
|
|
//def: Mips16Pat
|
|
|
|
// <(setuge CPU16Regs:$lhs, immZExt16:$rhs),
|
|
|
|
// (XorRxRxRy16 (SltiuCCRxImmX16 CPU16Regs:$lhs, immZExt16:$rhs),
|
2012-10-26 05:33:30 +08:00
|
|
|
// (LiRxImmX16 1))>;
|
2012-10-23 09:35:48 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// setugt
|
|
|
|
//
|
|
|
|
def: Mips16Pat
|
|
|
|
<(setugt CPU16Regs:$lhs, CPU16Regs:$rhs),
|
|
|
|
(SltuCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs)>;
|
|
|
|
|
|
|
|
//
|
|
|
|
// setule
|
|
|
|
//
|
|
|
|
def: Mips16Pat
|
|
|
|
<(setule CPU16Regs:$lhs, CPU16Regs:$rhs),
|
|
|
|
(XorRxRxRy16 (SltuCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs), (LiRxImmX16 1))>;
|
|
|
|
|
|
|
|
//
|
|
|
|
// setult
|
|
|
|
//
|
|
|
|
def: SetCC_R16<setult, SltuCCRxRy16>;
|
|
|
|
|
|
|
|
def: SetCC_I16<setult, immSExt16, SltiuCCRxImmX16>;
|
|
|
|
|
2012-10-27 08:57:14 +08:00
|
|
|
def: Mips16Pat<(add CPU16Regs:$hi, (MipsLo tglobaladdr:$lo)),
|
|
|
|
(AddiuRxRxImmX16 CPU16Regs:$hi, tglobaladdr:$lo)>;
|
|
|
|
|
|
|
|
// hi/lo relocs
|
2013-10-05 06:01:40 +08:00
|
|
|
def : Mips16Pat<(MipsHi tblockaddress:$in),
|
|
|
|
(SllX16 (LiRxImmX16 tblockaddress:$in), 16)>;
|
2013-02-20 13:45:15 +08:00
|
|
|
def : Mips16Pat<(MipsHi tglobaladdr:$in),
|
2013-02-02 12:07:35 +08:00
|
|
|
(SllX16 (LiRxImmX16 tglobaladdr:$in), 16)>;
|
2013-02-13 16:32:14 +08:00
|
|
|
def : Mips16Pat<(MipsHi tjumptable:$in),
|
|
|
|
(SllX16 (LiRxImmX16 tjumptable:$in), 16)>;
|
2013-01-19 10:00:40 +08:00
|
|
|
def : Mips16Pat<(MipsHi tglobaltlsaddr:$in),
|
2012-10-27 08:57:14 +08:00
|
|
|
(SllX16 (LiRxImmX16 tglobaltlsaddr:$in), 16)>;
|
|
|
|
|
2013-10-05 06:01:40 +08:00
|
|
|
def : Mips16Pat<(MipsLo tblockaddress:$in), (LiRxImmX16 tblockaddress:$in)>;
|
|
|
|
|
2012-10-27 06:57:32 +08:00
|
|
|
// wrapper_pic
|
|
|
|
class Wrapper16Pat<SDNode node, Instruction ADDiuOp, RegisterClass RC>:
|
|
|
|
Mips16Pat<(MipsWrapper RC:$gp, node:$in),
|
|
|
|
(ADDiuOp RC:$gp, node:$in)>;
|
|
|
|
|
|
|
|
|
2012-10-28 14:02:37 +08:00
|
|
|
def : Wrapper16Pat<tglobaladdr, AddiuRxRxImmX16, CPU16Regs>;
|
2012-10-27 06:57:32 +08:00
|
|
|
def : Wrapper16Pat<tglobaltlsaddr, AddiuRxRxImmX16, CPU16Regs>;
|
|
|
|
|
2012-10-30 03:39:04 +08:00
|
|
|
def : Mips16Pat<(i32 (extloadi8 addr16:$src)),
|
|
|
|
(LbuRxRyOffMemX16 addr16:$src)>;
|
|
|
|
def : Mips16Pat<(i32 (extloadi16 addr16:$src)),
|
2012-11-30 19:45:22 +08:00
|
|
|
(LhuRxRyOffMemX16 addr16:$src)>;
|
2013-08-07 12:00:26 +08:00
|
|
|
|
|
|
|
def: Mips16Pat<(trap), (Break16)>;
|
|
|
|
|
2013-10-08 04:46:19 +08:00
|
|
|
def : Mips16Pat<(sext_inreg CPU16Regs:$val, i8),
|
|
|
|
(SebRx16 CPU16Regs:$val)>;
|
|
|
|
|
|
|
|
def : Mips16Pat<(sext_inreg CPU16Regs:$val, i16),
|
|
|
|
(SehRx16 CPU16Regs:$val)>;
|
|
|
|
|
2013-09-19 06:46:09 +08:00
|
|
|
def GotPrologue16:
|
|
|
|
MipsPseudo16<
|
|
|
|
(outs CPU16Regs:$rh, CPU16Regs:$rl),
|
|
|
|
(ins simm16:$immHi, simm16:$immLo),
|
2013-12-16 06:02:31 +08:00
|
|
|
"li\t$rh, $immHi\n\taddiu\t$rl, $$pc, $immLo\n ",[]> ;
|
2013-10-28 05:57:36 +08:00
|
|
|
|
|
|
|
// An operand for the CONSTPOOL_ENTRY pseudo-instruction.
|
|
|
|
def cpinst_operand : Operand<i32> {
|
|
|
|
// let PrintMethod = "printCPInstOperand";
|
|
|
|
}
|
|
|
|
|
|
|
|
// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
|
|
|
|
// the function. The first operand is the ID# for this instruction, the second
|
|
|
|
// is the index into the MachineConstantPool that this is, the third is the
|
|
|
|
// size in bytes of this constant pool entry.
|
|
|
|
//
|
2014-11-26 08:46:26 +08:00
|
|
|
let hasSideEffects = 0, isNotDuplicable = 1 in
|
2013-10-28 05:57:36 +08:00
|
|
|
def CONSTPOOL_ENTRY :
|
|
|
|
MipsPseudo16<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
|
|
|
|
i32imm:$size), "foo", []>;
|
2013-11-05 16:14:14 +08:00
|
|
|
|