xref: /freebsd/contrib/llvm-project/llvm/lib/Target/Mips/MicroMipsInstrInfo.td (revision 8bcb0991864975618c09697b1aca10683346d9f0)
10b57cec5SDimitry Andric//===--- MicroMipsInstrFormats.td - microMIPS Inst Defs -*- tablegen -*----===//
20b57cec5SDimitry Andric//
30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric//
70b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric//
90b57cec5SDimitry Andric// This files describes the defintions of the microMIPSr3 instructions.
100b57cec5SDimitry Andric//
110b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric
130b57cec5SDimitry Andricdef addrimm11 : ComplexPattern<iPTR, 2, "selectIntAddr11MM", [frameindex]>;
140b57cec5SDimitry Andricdef addrimm12 : ComplexPattern<iPTR, 2, "selectIntAddr12MM", [frameindex]>;
150b57cec5SDimitry Andricdef addrimm16 : ComplexPattern<iPTR, 2, "selectIntAddr16MM", [frameindex]>;
160b57cec5SDimitry Andricdef addrimm4lsl2 : ComplexPattern<iPTR, 2, "selectIntAddrLSL2MM", [frameindex]>;
170b57cec5SDimitry Andric
180b57cec5SDimitry Andricdef simm9_addiusp : Operand<i32> {
190b57cec5SDimitry Andric  let EncoderMethod = "getSImm9AddiuspValue";
200b57cec5SDimitry Andric  let DecoderMethod = "DecodeSimm9SP";
210b57cec5SDimitry Andric}
220b57cec5SDimitry Andric
230b57cec5SDimitry Andricdef uimm3_shift : Operand<i32> {
240b57cec5SDimitry Andric  let EncoderMethod = "getUImm3Mod8Encoding";
250b57cec5SDimitry Andric  let DecoderMethod = "DecodePOOL16BEncodedField";
260b57cec5SDimitry Andric}
270b57cec5SDimitry Andric
280b57cec5SDimitry Andricdef simm3_lsa2 : Operand<i32> {
290b57cec5SDimitry Andric  let EncoderMethod = "getSImm3Lsa2Value";
300b57cec5SDimitry Andric  let DecoderMethod = "DecodeAddiur2Simm7";
310b57cec5SDimitry Andric}
320b57cec5SDimitry Andric
330b57cec5SDimitry Andricdef uimm4_andi : Operand<i32> {
340b57cec5SDimitry Andric  let EncoderMethod = "getUImm4AndValue";
350b57cec5SDimitry Andric  let DecoderMethod = "DecodeANDI16Imm";
360b57cec5SDimitry Andric}
370b57cec5SDimitry Andric
380b57cec5SDimitry Andricdef immSExtAddiur2 : ImmLeaf<i32, [{return Imm == 1 || Imm == -1 ||
390b57cec5SDimitry Andric                                           ((Imm % 4 == 0) &&
400b57cec5SDimitry Andric                                            Imm < 28 && Imm > 0);}]>;
410b57cec5SDimitry Andric
420b57cec5SDimitry Andricdef immSExtAddius5 : ImmLeaf<i32, [{return Imm >= -8 && Imm <= 7;}]>;
430b57cec5SDimitry Andric
440b57cec5SDimitry Andricdef immZExtAndi16 : ImmLeaf<i32,
450b57cec5SDimitry Andric  [{return (Imm == 128 || (Imm >= 1 && Imm <= 4) || Imm == 7 || Imm == 8 ||
460b57cec5SDimitry Andric            Imm == 15 || Imm == 16 || Imm == 31 || Imm == 32 || Imm == 63 ||
470b57cec5SDimitry Andric            Imm == 64 || Imm == 255 || Imm == 32768 || Imm == 65535 );}]>;
480b57cec5SDimitry Andric
490b57cec5SDimitry Andricdef immZExt2Shift : ImmLeaf<i32, [{return Imm >= 1 && Imm <= 8;}]>;
500b57cec5SDimitry Andric
510b57cec5SDimitry Andricdef immLi16 : ImmLeaf<i32, [{return Imm >= -1 && Imm <= 126;}]>;
520b57cec5SDimitry Andric
530b57cec5SDimitry Andricdef MicroMipsMemGPRMM16AsmOperand : AsmOperandClass {
540b57cec5SDimitry Andric  let Name = "MicroMipsMem";
550b57cec5SDimitry Andric  let RenderMethod = "addMicroMipsMemOperands";
560b57cec5SDimitry Andric  let ParserMethod = "parseMemOperand";
570b57cec5SDimitry Andric  let PredicateMethod = "isMemWithGRPMM16Base";
580b57cec5SDimitry Andric}
590b57cec5SDimitry Andric
600b57cec5SDimitry Andric// Define the classes of pointers used by microMIPS.
610b57cec5SDimitry Andric// The numbers must match those in MipsRegisterInfo::MipsPtrClass.
620b57cec5SDimitry Andricdef ptr_gpr16mm_rc : PointerLikeRegClass<1>;
630b57cec5SDimitry Andricdef ptr_sp_rc : PointerLikeRegClass<2>;
640b57cec5SDimitry Andricdef ptr_gp_rc : PointerLikeRegClass<3>;
650b57cec5SDimitry Andric
660b57cec5SDimitry Andricclass mem_mm_4_generic : Operand<i32> {
670b57cec5SDimitry Andric  let PrintMethod = "printMemOperand";
680b57cec5SDimitry Andric  let MIOperandInfo = (ops ptr_gpr16mm_rc, simm4);
690b57cec5SDimitry Andric  let OperandType = "OPERAND_MEMORY";
700b57cec5SDimitry Andric  let ParserMatchClass = MicroMipsMemGPRMM16AsmOperand;
710b57cec5SDimitry Andric}
720b57cec5SDimitry Andric
730b57cec5SDimitry Andricdef mem_mm_4 : mem_mm_4_generic {
740b57cec5SDimitry Andric  let EncoderMethod = "getMemEncodingMMImm4";
750b57cec5SDimitry Andric}
760b57cec5SDimitry Andric
770b57cec5SDimitry Andricdef mem_mm_4_lsl1 : mem_mm_4_generic {
780b57cec5SDimitry Andric  let EncoderMethod = "getMemEncodingMMImm4Lsl1";
790b57cec5SDimitry Andric}
800b57cec5SDimitry Andric
810b57cec5SDimitry Andricdef mem_mm_4_lsl2 : mem_mm_4_generic {
820b57cec5SDimitry Andric  let EncoderMethod = "getMemEncodingMMImm4Lsl2";
830b57cec5SDimitry Andric}
840b57cec5SDimitry Andric
850b57cec5SDimitry Andricdef MicroMipsMemSPAsmOperand : AsmOperandClass {
860b57cec5SDimitry Andric  let Name = "MicroMipsMemSP";
870b57cec5SDimitry Andric  let RenderMethod = "addMemOperands";
880b57cec5SDimitry Andric  let ParserMethod = "parseMemOperand";
890b57cec5SDimitry Andric  let PredicateMethod = "isMemWithUimmWordAlignedOffsetSP<7>";
900b57cec5SDimitry Andric}
910b57cec5SDimitry Andric
920b57cec5SDimitry Andricdef MicroMipsMemGPAsmOperand : AsmOperandClass {
930b57cec5SDimitry Andric  let Name = "MicroMipsMemGP";
940b57cec5SDimitry Andric  let RenderMethod = "addMemOperands";
950b57cec5SDimitry Andric  let ParserMethod = "parseMemOperand";
960b57cec5SDimitry Andric  let PredicateMethod = "isMemWithSimmWordAlignedOffsetGP<9>";
970b57cec5SDimitry Andric}
980b57cec5SDimitry Andric
990b57cec5SDimitry Andricdef mem_mm_sp_imm5_lsl2 : Operand<i32> {
1000b57cec5SDimitry Andric  let PrintMethod = "printMemOperand";
1010b57cec5SDimitry Andric  let MIOperandInfo = (ops ptr_sp_rc:$base, simm5:$offset);
1020b57cec5SDimitry Andric  let OperandType = "OPERAND_MEMORY";
1030b57cec5SDimitry Andric  let ParserMatchClass = MicroMipsMemSPAsmOperand;
1040b57cec5SDimitry Andric  let EncoderMethod = "getMemEncodingMMSPImm5Lsl2";
1050b57cec5SDimitry Andric}
1060b57cec5SDimitry Andric
1070b57cec5SDimitry Andricdef mem_mm_gp_simm7_lsl2 : Operand<i32> {
1080b57cec5SDimitry Andric  let PrintMethod = "printMemOperand";
1090b57cec5SDimitry Andric  let MIOperandInfo = (ops ptr_gp_rc:$base, simm7_lsl2:$offset);
1100b57cec5SDimitry Andric  let OperandType = "OPERAND_MEMORY";
1110b57cec5SDimitry Andric  let ParserMatchClass = MicroMipsMemGPAsmOperand;
1120b57cec5SDimitry Andric  let EncoderMethod = "getMemEncodingMMGPImm7Lsl2";
1130b57cec5SDimitry Andric}
1140b57cec5SDimitry Andric
1150b57cec5SDimitry Andricdef mem_mm_9 : Operand<i32> {
1160b57cec5SDimitry Andric  let PrintMethod = "printMemOperand";
1170b57cec5SDimitry Andric  let MIOperandInfo = (ops ptr_rc, simm9);
1180b57cec5SDimitry Andric  let EncoderMethod = "getMemEncodingMMImm9";
1190b57cec5SDimitry Andric  let ParserMatchClass = MipsMemSimm9AsmOperand;
1200b57cec5SDimitry Andric  let OperandType = "OPERAND_MEMORY";
1210b57cec5SDimitry Andric}
1220b57cec5SDimitry Andric
1230b57cec5SDimitry Andricdef mem_mm_11 : Operand<i32> {
1240b57cec5SDimitry Andric  let PrintMethod = "printMemOperand";
1250b57cec5SDimitry Andric  let MIOperandInfo = (ops GPR32, simm11);
1260b57cec5SDimitry Andric  let EncoderMethod = "getMemEncodingMMImm11";
1270b57cec5SDimitry Andric  let ParserMatchClass = MipsMemSimm11AsmOperand;
1280b57cec5SDimitry Andric  let OperandType = "OPERAND_MEMORY";
1290b57cec5SDimitry Andric}
1300b57cec5SDimitry Andric
1310b57cec5SDimitry Andricdef mem_mm_12 : Operand<i32> {
1320b57cec5SDimitry Andric  let PrintMethod = "printMemOperand";
1330b57cec5SDimitry Andric  let MIOperandInfo = (ops ptr_rc, simm12);
1340b57cec5SDimitry Andric  let EncoderMethod = "getMemEncodingMMImm12";
1350b57cec5SDimitry Andric  let ParserMatchClass = MipsMemAsmOperand;
1360b57cec5SDimitry Andric  let OperandType = "OPERAND_MEMORY";
1370b57cec5SDimitry Andric}
1380b57cec5SDimitry Andric
1390b57cec5SDimitry Andricdef mem_mm_16 : Operand<i32> {
1400b57cec5SDimitry Andric  let PrintMethod = "printMemOperand";
1410b57cec5SDimitry Andric  let MIOperandInfo = (ops ptr_rc, simm16);
1420b57cec5SDimitry Andric  let EncoderMethod = "getMemEncodingMMImm16";
1430b57cec5SDimitry Andric  let DecoderMethod = "DecodeMemMMImm16";
1440b57cec5SDimitry Andric  let ParserMatchClass = MipsMemSimm16AsmOperand;
1450b57cec5SDimitry Andric  let OperandType = "OPERAND_MEMORY";
1460b57cec5SDimitry Andric}
1470b57cec5SDimitry Andric
1480b57cec5SDimitry Andricdef MipsMemUimm4AsmOperand : AsmOperandClass {
1490b57cec5SDimitry Andric  let Name = "MemOffsetUimm4";
1500b57cec5SDimitry Andric  let SuperClasses = [MipsMemAsmOperand];
1510b57cec5SDimitry Andric  let RenderMethod = "addMemOperands";
1520b57cec5SDimitry Andric  let ParserMethod = "parseMemOperand";
1530b57cec5SDimitry Andric  let PredicateMethod = "isMemWithUimmOffsetSP<6>";
1540b57cec5SDimitry Andric}
1550b57cec5SDimitry Andric
1560b57cec5SDimitry Andricdef mem_mm_4sp : Operand<i32> {
1570b57cec5SDimitry Andric  let PrintMethod = "printMemOperand";
1580b57cec5SDimitry Andric  let MIOperandInfo = (ops ptr_sp_rc, uimm8);
1590b57cec5SDimitry Andric  let EncoderMethod = "getMemEncodingMMImm4sp";
1600b57cec5SDimitry Andric  let ParserMatchClass = MipsMemUimm4AsmOperand;
1610b57cec5SDimitry Andric  let OperandType = "OPERAND_MEMORY";
1620b57cec5SDimitry Andric}
1630b57cec5SDimitry Andric
1640b57cec5SDimitry Andricdef jmptarget_mm : Operand<OtherVT> {
1650b57cec5SDimitry Andric  let EncoderMethod = "getJumpTargetOpValueMM";
1660b57cec5SDimitry Andric}
1670b57cec5SDimitry Andric
1680b57cec5SDimitry Andricdef calltarget_mm : Operand<iPTR> {
1690b57cec5SDimitry Andric  let EncoderMethod = "getJumpTargetOpValueMM";
1700b57cec5SDimitry Andric}
1710b57cec5SDimitry Andric
1720b57cec5SDimitry Andricdef brtarget7_mm : Operand<OtherVT> {
1730b57cec5SDimitry Andric  let EncoderMethod = "getBranchTarget7OpValueMM";
1740b57cec5SDimitry Andric  let OperandType   = "OPERAND_PCREL";
1750b57cec5SDimitry Andric  let DecoderMethod = "DecodeBranchTarget7MM";
1760b57cec5SDimitry Andric  let ParserMatchClass = MipsJumpTargetAsmOperand;
1770b57cec5SDimitry Andric}
1780b57cec5SDimitry Andric
1790b57cec5SDimitry Andricdef brtarget10_mm : Operand<OtherVT> {
1800b57cec5SDimitry Andric  let EncoderMethod = "getBranchTargetOpValueMMPC10";
1810b57cec5SDimitry Andric  let OperandType   = "OPERAND_PCREL";
1820b57cec5SDimitry Andric  let DecoderMethod = "DecodeBranchTarget10MM";
1830b57cec5SDimitry Andric  let ParserMatchClass = MipsJumpTargetAsmOperand;
1840b57cec5SDimitry Andric}
1850b57cec5SDimitry Andric
1860b57cec5SDimitry Andricdef brtarget_mm : Operand<OtherVT> {
1870b57cec5SDimitry Andric  let EncoderMethod = "getBranchTargetOpValueMM";
1880b57cec5SDimitry Andric  let OperandType   = "OPERAND_PCREL";
1890b57cec5SDimitry Andric  let DecoderMethod = "DecodeBranchTargetMM";
1900b57cec5SDimitry Andric  let ParserMatchClass = MipsJumpTargetAsmOperand;
1910b57cec5SDimitry Andric}
1920b57cec5SDimitry Andric
1930b57cec5SDimitry Andricdef simm23_lsl2 : Operand<i32> {
1940b57cec5SDimitry Andric  let EncoderMethod = "getSimm23Lsl2Encoding";
1950b57cec5SDimitry Andric  let DecoderMethod = "DecodeSimm23Lsl2";
1960b57cec5SDimitry Andric}
1970b57cec5SDimitry Andric
1980b57cec5SDimitry Andricclass CompactBranchMM<string opstr, DAGOperand opnd, PatFrag cond_op,
1990b57cec5SDimitry Andric                      RegisterOperand RO> :
2000b57cec5SDimitry Andric  InstSE<(outs), (ins RO:$rs, opnd:$offset),
2010b57cec5SDimitry Andric         !strconcat(opstr, "\t$rs, $offset"), [], II_BCCZC, FrmI> {
2020b57cec5SDimitry Andric  let isBranch = 1;
2030b57cec5SDimitry Andric  let isTerminator = 1;
2040b57cec5SDimitry Andric  let hasDelaySlot = 0;
2050b57cec5SDimitry Andric  let Defs = [AT];
2060b57cec5SDimitry Andric}
2070b57cec5SDimitry Andric
2080b57cec5SDimitry Andriclet canFoldAsLoad = 1 in
2090b57cec5SDimitry Andricclass LoadLeftRightMM<string opstr, SDNode OpNode, RegisterOperand RO,
2100b57cec5SDimitry Andric                      Operand MemOpnd, InstrItinClass Itin> :
2110b57cec5SDimitry Andric  InstSE<(outs RO:$rt), (ins MemOpnd:$addr, RO:$src),
2120b57cec5SDimitry Andric         !strconcat(opstr, "\t$rt, $addr"),
2130b57cec5SDimitry Andric         [(set RO:$rt, (OpNode addrimm12:$addr, RO:$src))],
2140b57cec5SDimitry Andric         Itin, FrmI> {
2150b57cec5SDimitry Andric  let DecoderMethod = "DecodeMemMMImm12";
2160b57cec5SDimitry Andric  string Constraints = "$src = $rt";
2170b57cec5SDimitry Andric  let BaseOpcode = opstr;
2180b57cec5SDimitry Andric  bit mayLoad = 1;
2190b57cec5SDimitry Andric  bit mayStore = 0;
2200b57cec5SDimitry Andric}
2210b57cec5SDimitry Andric
2220b57cec5SDimitry Andricclass StoreLeftRightMM<string opstr, SDNode OpNode, RegisterOperand RO,
2230b57cec5SDimitry Andric                       Operand MemOpnd, InstrItinClass Itin>:
2240b57cec5SDimitry Andric  InstSE<(outs), (ins RO:$rt, MemOpnd:$addr),
2250b57cec5SDimitry Andric         !strconcat(opstr, "\t$rt, $addr"),
2260b57cec5SDimitry Andric         [(OpNode RO:$rt, addrimm12:$addr)], Itin, FrmI> {
2270b57cec5SDimitry Andric  let DecoderMethod = "DecodeMemMMImm12";
2280b57cec5SDimitry Andric  let BaseOpcode = opstr;
2290b57cec5SDimitry Andric  bit mayLoad = 0;
2300b57cec5SDimitry Andric  bit mayStore = 1;
2310b57cec5SDimitry Andric}
2320b57cec5SDimitry Andric
2330b57cec5SDimitry Andricclass MovePMM16<string opstr, RegisterOperand RO1, RegisterOperand RO2,
2340b57cec5SDimitry Andric                RegisterOperand RO3> :
2350b57cec5SDimitry AndricMicroMipsInst16<(outs RO1:$rd1, RO2:$rd2), (ins RO3:$rs, RO3:$rt),
2360b57cec5SDimitry Andric                 !strconcat(opstr, "\t$rd1, $rd2, $rs, $rt"), [],
2370b57cec5SDimitry Andric                 NoItinerary, FrmR> {
2380b57cec5SDimitry Andric  let isReMaterializable = 1;
2390b57cec5SDimitry Andric  let isMoveReg = 1;
2400b57cec5SDimitry Andric  let DecoderMethod = "DecodeMovePOperands";
2410b57cec5SDimitry Andric}
2420b57cec5SDimitry Andric
2430b57cec5SDimitry Andricclass StorePairMM<string opstr, ComplexPattern Addr = addr>
2440b57cec5SDimitry Andric    :  InstSE<(outs), (ins GPR32Opnd:$rt, GPR32Opnd:$rt2, mem_simm12:$addr),
2450b57cec5SDimitry Andric         !strconcat(opstr, "\t$rt, $addr"), [], II_SWP, FrmI, opstr> {
2460b57cec5SDimitry Andric  let DecoderMethod = "DecodeMemMMImm12";
2470b57cec5SDimitry Andric  let mayStore = 1;
2480b57cec5SDimitry Andric  let AsmMatchConverter = "ConvertXWPOperands";
2490b57cec5SDimitry Andric}
2500b57cec5SDimitry Andric
2510b57cec5SDimitry Andricclass LoadPairMM<string opstr, ComplexPattern Addr = addr>
2520b57cec5SDimitry Andric    : InstSE<(outs GPR32Opnd:$rt, GPR32Opnd:$rt2), (ins mem_simm12:$addr),
2530b57cec5SDimitry Andric          !strconcat(opstr, "\t$rt, $addr"), [], II_LWP, FrmI, opstr> {
2540b57cec5SDimitry Andric  let DecoderMethod = "DecodeMemMMImm12";
2550b57cec5SDimitry Andric  let mayLoad = 1;
2560b57cec5SDimitry Andric  let AsmMatchConverter = "ConvertXWPOperands";
2570b57cec5SDimitry Andric}
2580b57cec5SDimitry Andric
2590b57cec5SDimitry Andricclass LLBaseMM<string opstr, RegisterOperand RO> :
2600b57cec5SDimitry Andric  InstSE<(outs RO:$rt), (ins mem_mm_12:$addr),
2610b57cec5SDimitry Andric         !strconcat(opstr, "\t$rt, $addr"), [], II_LL, FrmI> {
2620b57cec5SDimitry Andric  let DecoderMethod = "DecodeMemMMImm12";
2630b57cec5SDimitry Andric  let mayLoad = 1;
2640b57cec5SDimitry Andric}
2650b57cec5SDimitry Andric
2660b57cec5SDimitry Andricclass LLEBaseMM<string opstr, RegisterOperand RO> :
2670b57cec5SDimitry Andric  InstSE<(outs RO:$rt), (ins mem_simm9:$addr),
2680b57cec5SDimitry Andric         !strconcat(opstr, "\t$rt, $addr"), [], II_LLE, FrmI> {
2690b57cec5SDimitry Andric  let DecoderMethod = "DecodeMemMMImm9";
2700b57cec5SDimitry Andric  string BaseOpcode = opstr;
2710b57cec5SDimitry Andric  let mayLoad = 1;
2720b57cec5SDimitry Andric}
2730b57cec5SDimitry Andric
2740b57cec5SDimitry Andricclass SCBaseMM<string opstr, RegisterOperand RO> :
2750b57cec5SDimitry Andric  InstSE<(outs RO:$dst), (ins RO:$rt, mem_mm_12:$addr),
2760b57cec5SDimitry Andric         !strconcat(opstr, "\t$rt, $addr"), [], II_SC, FrmI> {
2770b57cec5SDimitry Andric  let DecoderMethod = "DecodeMemMMImm12";
2780b57cec5SDimitry Andric  let mayStore = 1;
2790b57cec5SDimitry Andric  let Constraints = "$rt = $dst";
2800b57cec5SDimitry Andric}
2810b57cec5SDimitry Andric
2820b57cec5SDimitry Andricclass SCEBaseMM<string opstr, RegisterOperand RO> :
2830b57cec5SDimitry Andric  InstSE<(outs RO:$dst), (ins RO:$rt, mem_simm9:$addr),
2840b57cec5SDimitry Andric         !strconcat(opstr, "\t$rt, $addr"), [], II_SCE, FrmI> {
2850b57cec5SDimitry Andric  let DecoderMethod = "DecodeMemMMImm9";
2860b57cec5SDimitry Andric  string BaseOpcode = opstr;
2870b57cec5SDimitry Andric  let mayStore = 1;
2880b57cec5SDimitry Andric  let Constraints = "$rt = $dst";
2890b57cec5SDimitry Andric}
2900b57cec5SDimitry Andric
2910b57cec5SDimitry Andricclass LoadMM<string opstr, DAGOperand RO, SDPatternOperator OpNode = null_frag,
2920b57cec5SDimitry Andric             InstrItinClass Itin = NoItinerary, DAGOperand MO = mem_mm_12> :
2930b57cec5SDimitry Andric  InstSE<(outs RO:$rt), (ins MO:$addr),
2940b57cec5SDimitry Andric         !strconcat(opstr, "\t$rt, $addr"),
2950b57cec5SDimitry Andric         [(set RO:$rt, (OpNode addrimm12:$addr))], Itin, FrmI, opstr> {
2960b57cec5SDimitry Andric  let DecoderMethod = "DecodeMemMMImm12";
2970b57cec5SDimitry Andric  let canFoldAsLoad = 1;
2980b57cec5SDimitry Andric  let mayLoad = 1;
2990b57cec5SDimitry Andric}
3000b57cec5SDimitry Andric
3010b57cec5SDimitry Andricclass ArithRMM16<string opstr, RegisterOperand RO, bit isComm = 0,
3020b57cec5SDimitry Andric                 InstrItinClass Itin = NoItinerary,
3030b57cec5SDimitry Andric                 SDPatternOperator OpNode = null_frag> :
3040b57cec5SDimitry Andric  MicroMipsInst16<(outs RO:$rd), (ins RO:$rs, RO:$rt),
3050b57cec5SDimitry Andric                  !strconcat(opstr, "\t$rd, $rs, $rt"),
3060b57cec5SDimitry Andric                  [(set RO:$rd, (OpNode RO:$rs, RO:$rt))], Itin, FrmR> {
3070b57cec5SDimitry Andric  let isCommutable = isComm;
3080b57cec5SDimitry Andric}
3090b57cec5SDimitry Andric
3100b57cec5SDimitry Andricclass AndImmMM16<string opstr, RegisterOperand RO,
3110b57cec5SDimitry Andric                 InstrItinClass Itin = NoItinerary> :
3120b57cec5SDimitry Andric  MicroMipsInst16<(outs RO:$rd), (ins RO:$rs, uimm4_andi:$imm),
3130b57cec5SDimitry Andric                  !strconcat(opstr, "\t$rd, $rs, $imm"), [], Itin, FrmI>;
3140b57cec5SDimitry Andric
3150b57cec5SDimitry Andricclass LogicRMM16<string opstr, RegisterOperand RO,
3160b57cec5SDimitry Andric                 InstrItinClass Itin = NoItinerary,
3170b57cec5SDimitry Andric                 SDPatternOperator OpNode = null_frag> :
3180b57cec5SDimitry Andric  MicroMipsInst16<(outs RO:$dst), (ins RO:$rs, RO:$rt),
3190b57cec5SDimitry Andric         !strconcat(opstr, "\t$rt, $rs"),
3200b57cec5SDimitry Andric         [(set RO:$dst, (OpNode RO:$rs, RO:$rt))], Itin, FrmR> {
3210b57cec5SDimitry Andric  let isCommutable = 1;
3220b57cec5SDimitry Andric  let Constraints = "$rt = $dst";
3230b57cec5SDimitry Andric}
3240b57cec5SDimitry Andric
3250b57cec5SDimitry Andricclass NotMM16<string opstr, RegisterOperand RO> :
3260b57cec5SDimitry Andric  MicroMipsInst16<(outs RO:$rt), (ins RO:$rs),
3270b57cec5SDimitry Andric         !strconcat(opstr, "\t$rt, $rs"),
3280b57cec5SDimitry Andric         [(set RO:$rt, (not RO:$rs))], II_NOT, FrmR>;
3290b57cec5SDimitry Andric
3300b57cec5SDimitry Andricclass ShiftIMM16<string opstr, Operand ImmOpnd, RegisterOperand RO,
3310b57cec5SDimitry Andric                 InstrItinClass Itin = NoItinerary> :
3320b57cec5SDimitry Andric  MicroMipsInst16<(outs RO:$rd), (ins RO:$rt, ImmOpnd:$shamt),
3330b57cec5SDimitry Andric                  !strconcat(opstr, "\t$rd, $rt, $shamt"), [], Itin, FrmR>;
3340b57cec5SDimitry Andric
3350b57cec5SDimitry Andricclass LoadMM16<string opstr, DAGOperand RO, SDPatternOperator OpNode,
3360b57cec5SDimitry Andric               InstrItinClass Itin, Operand MemOpnd> :
3370b57cec5SDimitry Andric  MicroMipsInst16<(outs RO:$rt), (ins MemOpnd:$addr),
3380b57cec5SDimitry Andric                  !strconcat(opstr, "\t$rt, $addr"), [], Itin, FrmI> {
3390b57cec5SDimitry Andric  let DecoderMethod = "DecodeMemMMImm4";
3400b57cec5SDimitry Andric  let canFoldAsLoad = 1;
3410b57cec5SDimitry Andric  let mayLoad = 1;
3420b57cec5SDimitry Andric}
3430b57cec5SDimitry Andric
3440b57cec5SDimitry Andricclass StoreMM16<string opstr, DAGOperand RTOpnd, DAGOperand RO,
3450b57cec5SDimitry Andric                SDPatternOperator OpNode, InstrItinClass Itin,
3460b57cec5SDimitry Andric                Operand MemOpnd> :
3470b57cec5SDimitry Andric  MicroMipsInst16<(outs), (ins RTOpnd:$rt, MemOpnd:$addr),
3480b57cec5SDimitry Andric                  !strconcat(opstr, "\t$rt, $addr"), [], Itin, FrmI> {
3490b57cec5SDimitry Andric  let DecoderMethod = "DecodeMemMMImm4";
3500b57cec5SDimitry Andric  let mayStore = 1;
3510b57cec5SDimitry Andric}
3520b57cec5SDimitry Andric
3530b57cec5SDimitry Andricclass LoadSPMM16<string opstr, DAGOperand RO, InstrItinClass Itin,
3540b57cec5SDimitry Andric                 Operand MemOpnd> :
3550b57cec5SDimitry Andric  MicroMipsInst16<(outs RO:$rt), (ins MemOpnd:$offset),
3560b57cec5SDimitry Andric                  !strconcat(opstr, "\t$rt, $offset"), [], Itin, FrmI> {
3570b57cec5SDimitry Andric  let DecoderMethod = "DecodeMemMMSPImm5Lsl2";
3580b57cec5SDimitry Andric  let canFoldAsLoad = 1;
3590b57cec5SDimitry Andric  let mayLoad = 1;
3600b57cec5SDimitry Andric}
3610b57cec5SDimitry Andric
3620b57cec5SDimitry Andricclass StoreSPMM16<string opstr, DAGOperand RO, InstrItinClass Itin,
3630b57cec5SDimitry Andric                  Operand MemOpnd> :
3640b57cec5SDimitry Andric  MicroMipsInst16<(outs), (ins RO:$rt, MemOpnd:$offset),
3650b57cec5SDimitry Andric                  !strconcat(opstr, "\t$rt, $offset"), [], Itin, FrmI> {
3660b57cec5SDimitry Andric  let DecoderMethod = "DecodeMemMMSPImm5Lsl2";
3670b57cec5SDimitry Andric  let mayStore = 1;
3680b57cec5SDimitry Andric}
3690b57cec5SDimitry Andric
3700b57cec5SDimitry Andricclass LoadGPMM16<string opstr, DAGOperand RO, InstrItinClass Itin,
3710b57cec5SDimitry Andric                 Operand MemOpnd> :
3720b57cec5SDimitry Andric  MicroMipsInst16<(outs RO:$rt), (ins MemOpnd:$offset),
3730b57cec5SDimitry Andric                  !strconcat(opstr, "\t$rt, $offset"), [], Itin, FrmI> {
3740b57cec5SDimitry Andric  let DecoderMethod = "DecodeMemMMGPImm7Lsl2";
3750b57cec5SDimitry Andric  let canFoldAsLoad = 1;
3760b57cec5SDimitry Andric  let mayLoad = 1;
3770b57cec5SDimitry Andric}
3780b57cec5SDimitry Andric
3790b57cec5SDimitry Andricclass AddImmUR2<string opstr, RegisterOperand RO> :
3800b57cec5SDimitry Andric  MicroMipsInst16<(outs RO:$rd), (ins RO:$rs, simm3_lsa2:$imm),
3810b57cec5SDimitry Andric                  !strconcat(opstr, "\t$rd, $rs, $imm"),
3820b57cec5SDimitry Andric                  [], II_ADDIU, FrmR> {
3830b57cec5SDimitry Andric  let isCommutable = 1;
3840b57cec5SDimitry Andric}
3850b57cec5SDimitry Andric
3860b57cec5SDimitry Andricclass AddImmUS5<string opstr, RegisterOperand RO> :
3870b57cec5SDimitry Andric  MicroMipsInst16<(outs RO:$dst), (ins RO:$rd, simm4:$imm),
3880b57cec5SDimitry Andric                  !strconcat(opstr, "\t$rd, $imm"), [], II_ADDIU, FrmR> {
3890b57cec5SDimitry Andric  let Constraints = "$rd = $dst";
3900b57cec5SDimitry Andric}
3910b57cec5SDimitry Andric
3920b57cec5SDimitry Andricclass AddImmUR1SP<string opstr, RegisterOperand RO> :
3930b57cec5SDimitry Andric  MicroMipsInst16<(outs RO:$rd), (ins uimm6_lsl2:$imm),
3940b57cec5SDimitry Andric                  !strconcat(opstr, "\t$rd, $imm"), [], II_ADDIU, FrmR>;
3950b57cec5SDimitry Andric
3960b57cec5SDimitry Andricclass AddImmUSP<string opstr> :
3970b57cec5SDimitry Andric  MicroMipsInst16<(outs), (ins simm9_addiusp:$imm),
3980b57cec5SDimitry Andric                  !strconcat(opstr, "\t$imm"), [], II_ADDIU, FrmI>;
3990b57cec5SDimitry Andric
4000b57cec5SDimitry Andricclass MoveFromHILOMM<string opstr, RegisterOperand RO, Register UseReg> :
4010b57cec5SDimitry Andric      MicroMipsInst16<(outs RO:$rd), (ins), !strconcat(opstr, "\t$rd"),
4020b57cec5SDimitry Andric  [], II_MFHI_MFLO, FrmR> {
4030b57cec5SDimitry Andric  let Uses = [UseReg];
4040b57cec5SDimitry Andric  let hasSideEffects = 0;
4050b57cec5SDimitry Andric  let isMoveReg = 1;
4060b57cec5SDimitry Andric}
4070b57cec5SDimitry Andric
4080b57cec5SDimitry Andricclass MoveMM16<string opstr, RegisterOperand RO>
4090b57cec5SDimitry Andric    :  MicroMipsInst16<(outs RO:$rd), (ins RO:$rs),
4100b57cec5SDimitry Andric                       !strconcat(opstr, "\t$rd, $rs"), [], II_MOVE, FrmR> {
4110b57cec5SDimitry Andric  let isReMaterializable = 1;
4120b57cec5SDimitry Andric  let isMoveReg = 1;
4130b57cec5SDimitry Andric}
4140b57cec5SDimitry Andric
4150b57cec5SDimitry Andricclass LoadImmMM16<string opstr, Operand Od, RegisterOperand RO> :
4160b57cec5SDimitry Andric  MicroMipsInst16<(outs RO:$rd), (ins Od:$imm),
4170b57cec5SDimitry Andric                  !strconcat(opstr, "\t$rd, $imm"), [], II_LI, FrmI> {
4180b57cec5SDimitry Andric  let isReMaterializable = 1;
4190b57cec5SDimitry Andric}
4200b57cec5SDimitry Andric
4210b57cec5SDimitry Andric// 16-bit Jump and Link (Call)
4220b57cec5SDimitry Andricclass JumpLinkRegMM16<string opstr, RegisterOperand RO> :
4230b57cec5SDimitry Andric  MicroMipsInst16<(outs), (ins RO:$rs), !strconcat(opstr, "\t$rs"),
4240b57cec5SDimitry Andric           [(MipsJmpLink RO:$rs)], II_JALR, FrmR> {
4250b57cec5SDimitry Andric  let isCall = 1;
4260b57cec5SDimitry Andric  let hasDelaySlot = 1;
4270b57cec5SDimitry Andric  let Defs = [RA];
4280b57cec5SDimitry Andric  let hasPostISelHook = 1;
4290b57cec5SDimitry Andric}
4300b57cec5SDimitry Andric
4310b57cec5SDimitry Andric// 16-bit Jump Reg
4320b57cec5SDimitry Andricclass JumpRegMM16<string opstr, RegisterOperand RO> :
4330b57cec5SDimitry Andric  MicroMipsInst16<(outs), (ins RO:$rs), !strconcat(opstr, "\t$rs"),
4340b57cec5SDimitry Andric           [], II_JR, FrmR> {
4350b57cec5SDimitry Andric  let hasDelaySlot = 1;
4360b57cec5SDimitry Andric  let isBranch = 1;
4370b57cec5SDimitry Andric  let isIndirectBranch = 1;
4380b57cec5SDimitry Andric}
4390b57cec5SDimitry Andric
4400b57cec5SDimitry Andric// Base class for JRADDIUSP instruction.
4410b57cec5SDimitry Andricclass JumpRAddiuStackMM16 :
4420b57cec5SDimitry Andric  MicroMipsInst16<(outs), (ins uimm5_lsl2:$imm), "jraddiusp\t$imm",
4430b57cec5SDimitry Andric                  [], II_JRADDIUSP, FrmR> {
4440b57cec5SDimitry Andric  let isTerminator = 1;
4450b57cec5SDimitry Andric  let isBarrier = 1;
4460b57cec5SDimitry Andric  let isBranch = 1;
4470b57cec5SDimitry Andric  let isIndirectBranch = 1;
4480b57cec5SDimitry Andric}
4490b57cec5SDimitry Andric
4500b57cec5SDimitry Andric// 16-bit Jump and Link (Call) - Short Delay Slot
4510b57cec5SDimitry Andricclass JumpLinkRegSMM16<string opstr, RegisterOperand RO> :
4520b57cec5SDimitry Andric  MicroMipsInst16<(outs), (ins RO:$rs), !strconcat(opstr, "\t$rs"),
4530b57cec5SDimitry Andric           [], II_JALRS, FrmR> {
4540b57cec5SDimitry Andric  let isCall = 1;
4550b57cec5SDimitry Andric  let hasDelaySlot = 1;
4560b57cec5SDimitry Andric  let Defs = [RA];
4570b57cec5SDimitry Andric}
4580b57cec5SDimitry Andric
4590b57cec5SDimitry Andric// 16-bit Jump Register Compact - No delay slot
4600b57cec5SDimitry Andricclass JumpRegCMM16<string opstr, RegisterOperand RO> :
4610b57cec5SDimitry Andric  MicroMipsInst16<(outs), (ins RO:$rs), !strconcat(opstr, "\t$rs"),
4620b57cec5SDimitry Andric                  [], II_JRC, FrmR> {
4630b57cec5SDimitry Andric  let isTerminator = 1;
4640b57cec5SDimitry Andric  let isBarrier = 1;
4650b57cec5SDimitry Andric  let isBranch = 1;
4660b57cec5SDimitry Andric  let isIndirectBranch = 1;
4670b57cec5SDimitry Andric}
4680b57cec5SDimitry Andric
4690b57cec5SDimitry Andric// Break16 and Sdbbp16
4700b57cec5SDimitry Andricclass BrkSdbbp16MM<string opstr, InstrItinClass Itin> :
4710b57cec5SDimitry Andric  MicroMipsInst16<(outs), (ins uimm4:$code_),
4720b57cec5SDimitry Andric                  !strconcat(opstr, "\t$code_"),
4730b57cec5SDimitry Andric                  [], Itin, FrmOther>;
4740b57cec5SDimitry Andric
4750b57cec5SDimitry Andricclass CBranchZeroMM<string opstr, DAGOperand opnd, RegisterOperand RO> :
4760b57cec5SDimitry Andric  MicroMipsInst16<(outs), (ins RO:$rs, opnd:$offset),
4770b57cec5SDimitry Andric                  !strconcat(opstr, "\t$rs, $offset"), [], II_BCCZ, FrmI> {
4780b57cec5SDimitry Andric  let isBranch = 1;
4790b57cec5SDimitry Andric  let isTerminator = 1;
4800b57cec5SDimitry Andric  let hasDelaySlot = 1;
4810b57cec5SDimitry Andric  let Defs = [AT];
4820b57cec5SDimitry Andric}
4830b57cec5SDimitry Andric
4840b57cec5SDimitry Andric// MicroMIPS Jump and Link (Call) - Short Delay Slot
4850b57cec5SDimitry Andriclet isCall = 1, hasDelaySlot = 1, Defs = [RA] in {
4860b57cec5SDimitry Andric  class JumpLinkMM<string opstr, DAGOperand opnd> :
4870b57cec5SDimitry Andric    InstSE<(outs), (ins opnd:$target), !strconcat(opstr, "\t$target"),
4880b57cec5SDimitry Andric           [], II_JALS, FrmJ, opstr> {
4890b57cec5SDimitry Andric    let DecoderMethod = "DecodeJumpTargetMM";
4900b57cec5SDimitry Andric  }
4910b57cec5SDimitry Andric
4920b57cec5SDimitry Andric  class JumpLinkRegMM<string opstr, RegisterOperand RO>:
4930b57cec5SDimitry Andric    InstSE<(outs RO:$rd), (ins RO:$rs), !strconcat(opstr, "\t$rd, $rs"),
4940b57cec5SDimitry Andric            [], II_JALRS, FrmR>;
4950b57cec5SDimitry Andric
4960b57cec5SDimitry Andric  class BranchCompareToZeroLinkMM<string opstr, DAGOperand opnd,
4970b57cec5SDimitry Andric                                  RegisterOperand RO> :
4980b57cec5SDimitry Andric    InstSE<(outs), (ins RO:$rs, opnd:$offset),
4990b57cec5SDimitry Andric           !strconcat(opstr, "\t$rs, $offset"), [], II_BCCZALS, FrmI, opstr>;
5000b57cec5SDimitry Andric}
5010b57cec5SDimitry Andric
5020b57cec5SDimitry Andricclass LoadWordIndexedScaledMM<string opstr, RegisterOperand RO,
5030b57cec5SDimitry Andric                              SDPatternOperator OpNode = null_frag> :
5040b57cec5SDimitry Andric  InstSE<(outs RO:$rd), (ins PtrRC:$base, PtrRC:$index),
5050b57cec5SDimitry Andric         !strconcat(opstr, "\t$rd, ${index}(${base})"), [], II_LWXS, FrmFI>;
5060b57cec5SDimitry Andric
5070b57cec5SDimitry Andricclass PrefetchIndexed<string opstr> :
5080b57cec5SDimitry Andric  InstSE<(outs), (ins PtrRC:$base, PtrRC:$index, uimm5:$hint),
5090b57cec5SDimitry Andric         !strconcat(opstr, "\t$hint, ${index}(${base})"), [], II_PREF, FrmOther>;
5100b57cec5SDimitry Andric
5110b57cec5SDimitry Andricclass AddImmUPC<string opstr, RegisterOperand RO> :
5120b57cec5SDimitry Andric  InstSE<(outs RO:$rs), (ins simm23_lsl2:$imm),
5130b57cec5SDimitry Andric         !strconcat(opstr, "\t$rs, $imm"), [], II_ADDIU, FrmR>;
5140b57cec5SDimitry Andric
5150b57cec5SDimitry Andric/// A list of registers used by load/store multiple instructions.
5160b57cec5SDimitry Andricdef RegListAsmOperand : AsmOperandClass {
5170b57cec5SDimitry Andric  let Name = "RegList";
5180b57cec5SDimitry Andric  let ParserMethod = "parseRegisterList";
5190b57cec5SDimitry Andric}
5200b57cec5SDimitry Andric
5210b57cec5SDimitry Andricdef reglist : Operand<i32> {
5220b57cec5SDimitry Andric  let EncoderMethod = "getRegisterListOpValue";
5230b57cec5SDimitry Andric  let ParserMatchClass = RegListAsmOperand;
5240b57cec5SDimitry Andric  let PrintMethod = "printRegisterList";
5250b57cec5SDimitry Andric  let DecoderMethod = "DecodeRegListOperand";
5260b57cec5SDimitry Andric}
5270b57cec5SDimitry Andric
5280b57cec5SDimitry Andricdef RegList16AsmOperand : AsmOperandClass {
5290b57cec5SDimitry Andric  let Name = "RegList16";
5300b57cec5SDimitry Andric  let ParserMethod = "parseRegisterList";
5310b57cec5SDimitry Andric  let PredicateMethod = "isRegList16";
5320b57cec5SDimitry Andric  let RenderMethod = "addRegListOperands";
5330b57cec5SDimitry Andric}
5340b57cec5SDimitry Andric
5350b57cec5SDimitry Andricdef reglist16 : Operand<i32> {
5360b57cec5SDimitry Andric  let EncoderMethod = "getRegisterListOpValue16";
5370b57cec5SDimitry Andric  let DecoderMethod = "DecodeRegListOperand16";
5380b57cec5SDimitry Andric  let PrintMethod = "printRegisterList";
5390b57cec5SDimitry Andric  let ParserMatchClass = RegList16AsmOperand;
5400b57cec5SDimitry Andric}
5410b57cec5SDimitry Andric
5420b57cec5SDimitry Andricclass StoreMultMM<string opstr,
5430b57cec5SDimitry Andric            InstrItinClass Itin = NoItinerary, ComplexPattern Addr = addr> :
5440b57cec5SDimitry Andric  InstSE<(outs), (ins reglist:$rt, mem_mm_12:$addr),
5450b57cec5SDimitry Andric         !strconcat(opstr, "\t$rt, $addr"), [], Itin, FrmI, opstr> {
5460b57cec5SDimitry Andric  let DecoderMethod = "DecodeMemMMImm12";
5470b57cec5SDimitry Andric  let mayStore = 1;
5480b57cec5SDimitry Andric}
5490b57cec5SDimitry Andric
5500b57cec5SDimitry Andricclass LoadMultMM<string opstr,
5510b57cec5SDimitry Andric            InstrItinClass Itin = NoItinerary, ComplexPattern Addr = addr> :
5520b57cec5SDimitry Andric  InstSE<(outs reglist:$rt), (ins mem_mm_12:$addr),
5530b57cec5SDimitry Andric          !strconcat(opstr, "\t$rt, $addr"), [], Itin, FrmI, opstr> {
5540b57cec5SDimitry Andric  let DecoderMethod = "DecodeMemMMImm12";
5550b57cec5SDimitry Andric  let mayLoad = 1;
5560b57cec5SDimitry Andric}
5570b57cec5SDimitry Andric
5580b57cec5SDimitry Andricclass StoreMultMM16<string opstr,
5590b57cec5SDimitry Andric                    InstrItinClass Itin = NoItinerary,
5600b57cec5SDimitry Andric                    ComplexPattern Addr = addr> :
5610b57cec5SDimitry Andric  MicroMipsInst16<(outs), (ins reglist16:$rt, mem_mm_4sp:$addr),
5620b57cec5SDimitry Andric                  !strconcat(opstr, "\t$rt, $addr"), [], Itin, FrmI> {
5630b57cec5SDimitry Andric  let DecoderMethod = "DecodeMemMMReglistImm4Lsl2";
5640b57cec5SDimitry Andric  let mayStore = 1;
5650b57cec5SDimitry Andric}
5660b57cec5SDimitry Andric
5670b57cec5SDimitry Andricclass LoadMultMM16<string opstr,
5680b57cec5SDimitry Andric                   InstrItinClass Itin = NoItinerary,
5690b57cec5SDimitry Andric                   ComplexPattern Addr = addr> :
5700b57cec5SDimitry Andric  MicroMipsInst16<(outs reglist16:$rt), (ins mem_mm_4sp:$addr),
5710b57cec5SDimitry Andric                  !strconcat(opstr, "\t$rt, $addr"), [], Itin, FrmI> {
5720b57cec5SDimitry Andric  let DecoderMethod = "DecodeMemMMReglistImm4Lsl2";
5730b57cec5SDimitry Andric  let mayLoad = 1;
5740b57cec5SDimitry Andric}
5750b57cec5SDimitry Andric
5760b57cec5SDimitry Andricclass UncondBranchMM16<string opstr> :
5770b57cec5SDimitry Andric  MicroMipsInst16<(outs), (ins brtarget10_mm:$offset),
5780b57cec5SDimitry Andric                  !strconcat(opstr, "\t$offset"),
5790b57cec5SDimitry Andric                  [], II_B, FrmI> {
5800b57cec5SDimitry Andric  let isBranch = 1;
5810b57cec5SDimitry Andric  let isTerminator = 1;
5820b57cec5SDimitry Andric  let isBarrier = 1;
5830b57cec5SDimitry Andric  let hasDelaySlot = 1;
5840b57cec5SDimitry Andric  let Predicates = [RelocPIC, InMicroMips];
5850b57cec5SDimitry Andric  let Defs = [AT];
5860b57cec5SDimitry Andric}
5870b57cec5SDimitry Andric
5880b57cec5SDimitry Andricclass HypcallMM<string opstr> :
5890b57cec5SDimitry Andric  InstSE<(outs), (ins uimm10:$code_),
5900b57cec5SDimitry Andric          !strconcat(opstr, "\t$code_"), [], II_HYPCALL, FrmOther> {
5910b57cec5SDimitry Andric  let BaseOpcode = opstr;
5920b57cec5SDimitry Andric}
5930b57cec5SDimitry Andric
5940b57cec5SDimitry Andricclass TLBINVMM<string opstr, InstrItinClass Itin> :
5950b57cec5SDimitry Andric  InstSE<(outs), (ins), opstr, [], Itin, FrmOther> {
5960b57cec5SDimitry Andric  let BaseOpcode = opstr;
5970b57cec5SDimitry Andric}
5980b57cec5SDimitry Andric
5990b57cec5SDimitry Andricclass MfCop0MM<string opstr, RegisterOperand DstRC,
6000b57cec5SDimitry Andric               RegisterOperand SrcRC, InstrItinClass Itin> :
6010b57cec5SDimitry Andric  InstSE<(outs DstRC:$rt), (ins SrcRC:$rs, uimm3:$sel),
6020b57cec5SDimitry Andric          !strconcat(opstr, "\t$rt, $rs, $sel"), [], Itin, FrmR> {
6030b57cec5SDimitry Andric  let BaseOpcode = opstr;
6040b57cec5SDimitry Andric}
6050b57cec5SDimitry Andric
6060b57cec5SDimitry Andricclass MtCop0MM<string opstr, RegisterOperand DstRC,
6070b57cec5SDimitry Andric               RegisterOperand SrcRC, InstrItinClass Itin> :
6080b57cec5SDimitry Andric  InstSE<(outs DstRC:$rs), (ins SrcRC:$rt, uimm3:$sel),
6090b57cec5SDimitry Andric          !strconcat(opstr, "\t$rt, $rs, $sel"), [], Itin, FrmR> {
6100b57cec5SDimitry Andric  let BaseOpcode = opstr;
6110b57cec5SDimitry Andric}
6120b57cec5SDimitry Andric
6130b57cec5SDimitry Andriclet FastISelShouldIgnore = 1 in {
6140b57cec5SDimitry Andric  def ADDU16_MM : ArithRMM16<"addu16", GPRMM16Opnd, 1, II_ADDU, add>,
6150b57cec5SDimitry Andric      ARITH_FM_MM16<0>, ISA_MICROMIPS32_NOT_MIPS32R6;
6160b57cec5SDimitry Andric  def AND16_MM : LogicRMM16<"and16", GPRMM16Opnd, II_AND, and>,
6170b57cec5SDimitry Andric      LOGIC_FM_MM16<0x2>, ISA_MICROMIPS32_NOT_MIPS32R6;
6180b57cec5SDimitry Andric}
6190b57cec5SDimitry Andric
6200b57cec5SDimitry Andricdef ANDI16_MM : AndImmMM16<"andi16", GPRMM16Opnd, II_AND>, ANDI_FM_MM16<0x0b>,
6210b57cec5SDimitry Andric                ISA_MICROMIPS32_NOT_MIPS32R6;
6220b57cec5SDimitry Andricdef NOT16_MM : NotMM16<"not16", GPRMM16Opnd>, LOGIC_FM_MM16<0x0>,
6230b57cec5SDimitry Andric               ISA_MICROMIPS32_NOT_MIPS32R6;
6240b57cec5SDimitry Andriclet FastISelShouldIgnore = 1 in
6250b57cec5SDimitry Andric  def OR16_MM : LogicRMM16<"or16", GPRMM16Opnd, II_OR, or>, LOGIC_FM_MM16<0x3>,
6260b57cec5SDimitry Andric                ISA_MICROMIPS32_NOT_MIPS32R6;
6270b57cec5SDimitry Andricdef SLL16_MM : ShiftIMM16<"sll16", uimm3_shift, GPRMM16Opnd, II_SLL>,
6280b57cec5SDimitry Andric    SHIFT_FM_MM16<0>, ISA_MICROMIPS32_NOT_MIPS32R6;
6290b57cec5SDimitry Andricdef SRL16_MM : ShiftIMM16<"srl16", uimm3_shift, GPRMM16Opnd, II_SRL>,
6300b57cec5SDimitry Andric    SHIFT_FM_MM16<1>, ISA_MICROMIPS32_NOT_MIPS32R6;
6310b57cec5SDimitry Andric
6320b57cec5SDimitry Andriclet FastISelShouldIgnore = 1 in {
6330b57cec5SDimitry Andric  def SUBU16_MM : ArithRMM16<"subu16", GPRMM16Opnd, 0, II_SUBU, sub>,
6340b57cec5SDimitry Andric                  ARITH_FM_MM16<1>, ISA_MICROMIPS32_NOT_MIPS32R6;
6350b57cec5SDimitry Andric  def XOR16_MM : LogicRMM16<"xor16", GPRMM16Opnd, II_XOR, xor>,
6360b57cec5SDimitry Andric                 LOGIC_FM_MM16<0x1>, ISA_MICROMIPS32_NOT_MIPS32R6;
6370b57cec5SDimitry Andric}
6380b57cec5SDimitry Andricdef LBU16_MM : LoadMM16<"lbu16", GPRMM16Opnd, zextloadi8, II_LBU,
6390b57cec5SDimitry Andric                        mem_mm_4>, LOAD_STORE_FM_MM16<0x02>, ISA_MICROMIPS;
6400b57cec5SDimitry Andricdef LHU16_MM : LoadMM16<"lhu16", GPRMM16Opnd, zextloadi16, II_LHU,
6410b57cec5SDimitry Andric                        mem_mm_4_lsl1>, LOAD_STORE_FM_MM16<0x0a>, ISA_MICROMIPS;
6420b57cec5SDimitry Andricdef LW16_MM : LoadMM16<"lw16", GPRMM16Opnd, load, II_LW, mem_mm_4_lsl2>,
6430b57cec5SDimitry Andric                      LOAD_STORE_FM_MM16<0x1a>, ISA_MICROMIPS;
6440b57cec5SDimitry Andricdef SB16_MM : StoreMM16<"sb16", GPRMM16OpndZero, GPRMM16Opnd, truncstorei8,
6450b57cec5SDimitry Andric                        II_SB, mem_mm_4>, LOAD_STORE_FM_MM16<0x22>,
6460b57cec5SDimitry Andric                        ISA_MICROMIPS32_NOT_MIPS32R6;
6470b57cec5SDimitry Andricdef SH16_MM : StoreMM16<"sh16", GPRMM16OpndZero, GPRMM16Opnd, truncstorei16,
6480b57cec5SDimitry Andric                        II_SH, mem_mm_4_lsl1>,
6490b57cec5SDimitry Andric                        LOAD_STORE_FM_MM16<0x2a>, ISA_MICROMIPS32_NOT_MIPS32R6;
6500b57cec5SDimitry Andricdef SW16_MM : StoreMM16<"sw16", GPRMM16OpndZero, GPRMM16Opnd, store, II_SW,
6510b57cec5SDimitry Andric                        mem_mm_4_lsl2>, LOAD_STORE_FM_MM16<0x3a>,
6520b57cec5SDimitry Andric                        ISA_MICROMIPS32_NOT_MIPS32R6;
6530b57cec5SDimitry Andricdef LWGP_MM : LoadGPMM16<"lw", GPRMM16Opnd, II_LW, mem_mm_gp_simm7_lsl2>,
6540b57cec5SDimitry Andric                         LOAD_GP_FM_MM16<0x19>, ISA_MICROMIPS;
6550b57cec5SDimitry Andricdef LWSP_MM : LoadSPMM16<"lw", GPR32Opnd, II_LW, mem_mm_sp_imm5_lsl2>,
6560b57cec5SDimitry Andric              LOAD_STORE_SP_FM_MM16<0x12>, ISA_MICROMIPS;
6570b57cec5SDimitry Andricdef SWSP_MM : StoreSPMM16<"swsp", GPR32Opnd, II_SW, mem_mm_sp_imm5_lsl2>,
6580b57cec5SDimitry Andric              LOAD_STORE_SP_FM_MM16<0x32>, ISA_MICROMIPS32_NOT_MIPS32R6;
6590b57cec5SDimitry Andricdef ADDIUR1SP_MM : AddImmUR1SP<"addiur1sp", GPRMM16Opnd>, ADDIUR1SP_FM_MM16,
6600b57cec5SDimitry Andric                   ISA_MICROMIPS;
6610b57cec5SDimitry Andricdef ADDIUR2_MM : AddImmUR2<"addiur2", GPRMM16Opnd>, ADDIUR2_FM_MM16,
6620b57cec5SDimitry Andric                 ISA_MICROMIPS;
6630b57cec5SDimitry Andricdef ADDIUS5_MM : AddImmUS5<"addius5", GPR32Opnd>, ADDIUS5_FM_MM16,
6640b57cec5SDimitry Andric                 ISA_MICROMIPS;
6650b57cec5SDimitry Andricdef ADDIUSP_MM : AddImmUSP<"addiusp">, ADDIUSP_FM_MM16, ISA_MICROMIPS;
6660b57cec5SDimitry Andricdef MFHI16_MM : MoveFromHILOMM<"mfhi16", GPR32Opnd, AC0>,
6670b57cec5SDimitry Andric                MFHILO_FM_MM16<0x10>, ISA_MICROMIPS32_NOT_MIPS32R6;
6680b57cec5SDimitry Andricdef MFLO16_MM : MoveFromHILOMM<"mflo16", GPR32Opnd, AC0>,
6690b57cec5SDimitry Andric                MFHILO_FM_MM16<0x12>, ISA_MICROMIPS32_NOT_MIPS32R6;
6700b57cec5SDimitry Andricdef MOVE16_MM : MoveMM16<"move", GPR32Opnd>, MOVE_FM_MM16<0x03>,
6710b57cec5SDimitry Andric                ISA_MICROMIPS32_NOT_MIPS32R6;
6720b57cec5SDimitry Andricdef MOVEP_MM : MovePMM16<"movep", GPRMM16OpndMovePPairFirst,
6730b57cec5SDimitry Andric                         GPRMM16OpndMovePPairSecond, GPRMM16OpndMoveP>,
6740b57cec5SDimitry Andric               MOVEP_FM_MM16, ISA_MICROMIPS32_NOT_MIPS32R6;
6750b57cec5SDimitry Andricdef LI16_MM : LoadImmMM16<"li16", li16_imm, GPRMM16Opnd>, LI_FM_MM16,
6760b57cec5SDimitry Andric              IsAsCheapAsAMove, ISA_MICROMIPS32_NOT_MIPS32R6;
6770b57cec5SDimitry Andricdef JALR16_MM : JumpLinkRegMM16<"jalr", GPR32Opnd>, JALR_FM_MM16<0x0e>,
6780b57cec5SDimitry Andric                ISA_MICROMIPS32_NOT_MIPS32R6;
6790b57cec5SDimitry Andricdef JALRS16_MM : JumpLinkRegSMM16<"jalrs16", GPR32Opnd>, JALR_FM_MM16<0x0f>,
6800b57cec5SDimitry Andric                 ISA_MICROMIPS32_NOT_MIPS32R6;
6810b57cec5SDimitry Andricdef JRC16_MM : JumpRegCMM16<"jrc", GPR32Opnd>, JALR_FM_MM16<0x0d>,
6820b57cec5SDimitry Andric               ISA_MICROMIPS32_NOT_MIPS32R6;
6830b57cec5SDimitry Andricdef JRADDIUSP : JumpRAddiuStackMM16, JRADDIUSP_FM_MM16<0x18>,
6840b57cec5SDimitry Andric                ISA_MICROMIPS32_NOT_MIPS32R6;
6850b57cec5SDimitry Andricdef JR16_MM : JumpRegMM16<"jr16", GPR32Opnd>, JALR_FM_MM16<0x0c>,
6860b57cec5SDimitry Andric              ISA_MICROMIPS32_NOT_MIPS32R6;
6870b57cec5SDimitry Andricdef BEQZ16_MM : CBranchZeroMM<"beqz16", brtarget7_mm, GPRMM16Opnd>,
6880b57cec5SDimitry Andric                BEQNEZ_FM_MM16<0x23>, ISA_MICROMIPS32_NOT_MIPS32R6;
6890b57cec5SDimitry Andricdef BNEZ16_MM : CBranchZeroMM<"bnez16", brtarget7_mm, GPRMM16Opnd>,
6900b57cec5SDimitry Andric                BEQNEZ_FM_MM16<0x2b>, ISA_MICROMIPS32_NOT_MIPS32R6;
6910b57cec5SDimitry Andricdef B16_MM : UncondBranchMM16<"b16">, B16_FM, ISA_MICROMIPS32_NOT_MIPS32R6;
6920b57cec5SDimitry Andricdef BREAK16_MM : BrkSdbbp16MM<"break16", II_BREAK>, BRKSDBBP16_FM_MM<0x28>,
6930b57cec5SDimitry Andric                 ISA_MICROMIPS32_NOT_MIPS32R6;
6940b57cec5SDimitry Andricdef SDBBP16_MM : BrkSdbbp16MM<"sdbbp16", II_SDBBP>, BRKSDBBP16_FM_MM<0x2C>,
6950b57cec5SDimitry Andric                 ISA_MICROMIPS32_NOT_MIPS32R6;
6960b57cec5SDimitry Andric
6970b57cec5SDimitry Andricclass WaitMM<string opstr> :
6980b57cec5SDimitry Andric  InstSE<(outs), (ins uimm10:$code_), !strconcat(opstr, "\t$code_"), [],
6990b57cec5SDimitry Andric         II_WAIT, FrmOther, opstr>;
7000b57cec5SDimitry Andric
7010b57cec5SDimitry Andriclet DecoderNamespace = "MicroMips" in {
7020b57cec5SDimitry Andric  /// Load and Store Instructions - multiple
7030b57cec5SDimitry Andric  def SWM16_MM : StoreMultMM16<"swm16", II_SWM>, LWM_FM_MM16<0x5>,
7040b57cec5SDimitry Andric                 ISA_MICROMIPS32_NOT_MIPS32R6;
7050b57cec5SDimitry Andric  def LWM16_MM : LoadMultMM16<"lwm16", II_LWM>, LWM_FM_MM16<0x4>,
7060b57cec5SDimitry Andric                 ISA_MICROMIPS32_NOT_MIPS32R6;
7070b57cec5SDimitry Andric  def CFC2_MM : InstSE<(outs GPR32Opnd:$rt), (ins COP2Opnd:$impl),
7080b57cec5SDimitry Andric                       "cfc2\t$rt, $impl", [], II_CFC2, FrmFR, "cfc2">,
7090b57cec5SDimitry Andric                POOL32A_CFTC2_FM_MM<0b1100110100>, ISA_MICROMIPS;
7100b57cec5SDimitry Andric  def CTC2_MM : InstSE<(outs COP2Opnd:$impl), (ins GPR32Opnd:$rt),
7110b57cec5SDimitry Andric                       "ctc2\t$rt, $impl", [], II_CTC2, FrmFR, "ctc2">,
7120b57cec5SDimitry Andric                POOL32A_CFTC2_FM_MM<0b1101110100>, ISA_MICROMIPS;
7130b57cec5SDimitry Andric
7140b57cec5SDimitry Andric  /// Compact Branch Instructions
7150b57cec5SDimitry Andric  def BEQZC_MM : CompactBranchMM<"beqzc", brtarget_mm, seteq, GPR32Opnd>,
7160b57cec5SDimitry Andric                 COMPACT_BRANCH_FM_MM<0x7>, ISA_MICROMIPS32_NOT_MIPS32R6;
7170b57cec5SDimitry Andric  def BNEZC_MM : CompactBranchMM<"bnezc", brtarget_mm, setne, GPR32Opnd>,
7180b57cec5SDimitry Andric                 COMPACT_BRANCH_FM_MM<0x5>, ISA_MICROMIPS32_NOT_MIPS32R6;
7190b57cec5SDimitry Andric
7200b57cec5SDimitry Andric  /// Arithmetic Instructions (ALU Immediate)
7210b57cec5SDimitry Andric  def ADDiu_MM : MMRel, ArithLogicI<"addiu", simm16, GPR32Opnd, II_ADDIU>,
7220b57cec5SDimitry Andric                 ADDI_FM_MM<0xc>, ISA_MICROMIPS32_NOT_MIPS32R6;
7230b57cec5SDimitry Andric  def ADDi_MM  : MMRel, ArithLogicI<"addi", simm16, GPR32Opnd, II_ADDI>,
7240b57cec5SDimitry Andric                 ADDI_FM_MM<0x4>, ISA_MICROMIPS32_NOT_MIPS32R6;
7250b57cec5SDimitry Andric  def SLTi_MM  : MMRel, SetCC_I<"slti", setlt, simm16, immSExt16, GPR32Opnd>,
7260b57cec5SDimitry Andric                 SLTI_FM_MM<0x24>, ISA_MICROMIPS;
7270b57cec5SDimitry Andric  def SLTiu_MM : MMRel, SetCC_I<"sltiu", setult, simm16, immSExt16, GPR32Opnd>,
7280b57cec5SDimitry Andric                 SLTI_FM_MM<0x2c>, ISA_MICROMIPS;
7290b57cec5SDimitry Andric  def ANDi_MM  : MMRel, ArithLogicI<"andi", uimm16, GPR32Opnd, II_ANDI>,
7300b57cec5SDimitry Andric                 ADDI_FM_MM<0x34>, ISA_MICROMIPS32_NOT_MIPS32R6;
7310b57cec5SDimitry Andric  def ORi_MM   : MMRel, ArithLogicI<"ori", uimm16, GPR32Opnd, II_ORI, immZExt16,
7320b57cec5SDimitry Andric                                    or>, ADDI_FM_MM<0x14>,
7330b57cec5SDimitry Andric                 ISA_MICROMIPS32_NOT_MIPS32R6;
7340b57cec5SDimitry Andric  def XORi_MM  : MMRel, ArithLogicI<"xori", uimm16, GPR32Opnd, II_XORI,
7350b57cec5SDimitry Andric                                    immZExt16, xor>, ADDI_FM_MM<0x1c>,
7360b57cec5SDimitry Andric                 ISA_MICROMIPS32_NOT_MIPS32R6;
7370b57cec5SDimitry Andric  def LUi_MM   : MMRel, LoadUpper<"lui", GPR32Opnd, uimm16_relaxed>, LUI_FM_MM,
7380b57cec5SDimitry Andric                 ISA_MICROMIPS32_NOT_MIPS32R6;
7390b57cec5SDimitry Andric
7400b57cec5SDimitry Andric  def LEA_ADDiu_MM : MMRel, EffectiveAddress<"addiu", GPR32Opnd>,
7410b57cec5SDimitry Andric                     LW_FM_MM<0xc>, ISA_MICROMIPS;
7420b57cec5SDimitry Andric
7430b57cec5SDimitry Andric  /// Arithmetic Instructions (3-Operand, R-Type)
7440b57cec5SDimitry Andric  def ADDu_MM  : MMRel, ArithLogicR<"addu", GPR32Opnd, 1, II_ADDU, add>,
7450b57cec5SDimitry Andric                 ADD_FM_MM<0, 0x150>, ISA_MICROMIPS32_NOT_MIPS32R6;
7460b57cec5SDimitry Andric  def SUBu_MM  : MMRel, ArithLogicR<"subu", GPR32Opnd, 0, II_SUBU, sub>,
7470b57cec5SDimitry Andric                 ADD_FM_MM<0, 0x1d0>, ISA_MICROMIPS32_NOT_MIPS32R6;
7480b57cec5SDimitry Andric  let Defs = [HI0, LO0] in
7490b57cec5SDimitry Andric    def MUL_MM   : MMRel, ArithLogicR<"mul", GPR32Opnd, 1, II_MUL, mul>,
7500b57cec5SDimitry Andric                   ADD_FM_MM<0, 0x210>, ISA_MICROMIPS32_NOT_MIPS32R6;
7510b57cec5SDimitry Andric  def ADD_MM   : MMRel, ArithLogicR<"add", GPR32Opnd, 1, II_ADD>,
7520b57cec5SDimitry Andric                 ADD_FM_MM<0, 0x110>, ISA_MICROMIPS32_NOT_MIPS32R6;
7530b57cec5SDimitry Andric  def SUB_MM   : MMRel, ArithLogicR<"sub", GPR32Opnd, 0, II_SUB>,
7540b57cec5SDimitry Andric                 ADD_FM_MM<0, 0x190>, ISA_MICROMIPS32_NOT_MIPS32R6;
7550b57cec5SDimitry Andric  def SLT_MM   : MMRel, SetCC_R<"slt", setlt, GPR32Opnd>, ADD_FM_MM<0, 0x350>,
7560b57cec5SDimitry Andric                 ISA_MICROMIPS;
7570b57cec5SDimitry Andric  def SLTu_MM  : MMRel, SetCC_R<"sltu", setult, GPR32Opnd>,
7580b57cec5SDimitry Andric                 ADD_FM_MM<0, 0x390>, ISA_MICROMIPS;
7590b57cec5SDimitry Andric  def AND_MM   : MMRel, ArithLogicR<"and", GPR32Opnd, 1, II_AND, and>,
7600b57cec5SDimitry Andric                 ADD_FM_MM<0, 0x250>, ISA_MICROMIPS32_NOT_MIPS32R6;
7610b57cec5SDimitry Andric  def OR_MM    : MMRel, ArithLogicR<"or", GPR32Opnd, 1, II_OR, or>,
7620b57cec5SDimitry Andric                 ADD_FM_MM<0, 0x290>, ISA_MICROMIPS32_NOT_MIPS32R6;
7630b57cec5SDimitry Andric  def XOR_MM   : MMRel, ArithLogicR<"xor", GPR32Opnd, 1, II_XOR, xor>,
7640b57cec5SDimitry Andric                 ADD_FM_MM<0, 0x310>, ISA_MICROMIPS32_NOT_MIPS32R6;
7650b57cec5SDimitry Andric  def NOR_MM   : MMRel, LogicNOR<"nor", GPR32Opnd>, ADD_FM_MM<0, 0x2d0>,
7660b57cec5SDimitry Andric                 ISA_MICROMIPS32_NOT_MIPS32R6;
7670b57cec5SDimitry Andric  def MULT_MM  : MMRel, Mult<"mult", II_MULT, GPR32Opnd, [HI0, LO0]>,
7680b57cec5SDimitry Andric                 MULT_FM_MM<0x22c>, ISA_MICROMIPS32_NOT_MIPS32R6;
7690b57cec5SDimitry Andric  def MULTu_MM : MMRel, Mult<"multu", II_MULTU, GPR32Opnd, [HI0, LO0]>,
7700b57cec5SDimitry Andric                 MULT_FM_MM<0x26c>, ISA_MICROMIPS32_NOT_MIPS32R6;
7710b57cec5SDimitry Andric  def SDIV_MM  : MMRel, Div<"div", II_DIV, GPR32Opnd, [HI0, LO0]>,
7720b57cec5SDimitry Andric                 MULT_FM_MM<0x2ac>, ISA_MICROMIPS32_NOT_MIPS32R6;
7730b57cec5SDimitry Andric  def UDIV_MM  : MMRel, Div<"divu", II_DIVU, GPR32Opnd, [HI0, LO0]>,
7740b57cec5SDimitry Andric                 MULT_FM_MM<0x2ec>, ISA_MICROMIPS32_NOT_MIPS32R6;
7750b57cec5SDimitry Andric
7760b57cec5SDimitry Andric  /// Arithmetic Instructions with PC and Immediate
7770b57cec5SDimitry Andric  def ADDIUPC_MM : AddImmUPC<"addiupc", GPRMM16Opnd>, ADDIUPC_FM_MM,
7780b57cec5SDimitry Andric                   ISA_MICROMIPS32_NOT_MIPS32R6;
7790b57cec5SDimitry Andric
7800b57cec5SDimitry Andric  /// Shift Instructions
7810b57cec5SDimitry Andric  def SLL_MM   : MMRel, shift_rotate_imm<"sll", uimm5, GPR32Opnd, II_SLL>,
7820b57cec5SDimitry Andric                 SRA_FM_MM<0, 0>, ISA_MICROMIPS;
7830b57cec5SDimitry Andric  def SRL_MM   : MMRel, shift_rotate_imm<"srl", uimm5, GPR32Opnd, II_SRL>,
7840b57cec5SDimitry Andric                 SRA_FM_MM<0x40, 0>, ISA_MICROMIPS;
7850b57cec5SDimitry Andric  def SRA_MM   : MMRel, shift_rotate_imm<"sra", uimm5, GPR32Opnd, II_SRA>,
7860b57cec5SDimitry Andric                 SRA_FM_MM<0x80, 0>, ISA_MICROMIPS;
7870b57cec5SDimitry Andric  def SLLV_MM  : MMRel, shift_rotate_reg<"sllv", GPR32Opnd, II_SLLV>,
7880b57cec5SDimitry Andric                 SRLV_FM_MM<0x10, 0>, ISA_MICROMIPS;
7890b57cec5SDimitry Andric  def SRLV_MM  : MMRel, shift_rotate_reg<"srlv", GPR32Opnd, II_SRLV>,
7900b57cec5SDimitry Andric                 SRLV_FM_MM<0x50, 0>, ISA_MICROMIPS;
7910b57cec5SDimitry Andric  def SRAV_MM  : MMRel, shift_rotate_reg<"srav", GPR32Opnd, II_SRAV>,
7920b57cec5SDimitry Andric                 SRLV_FM_MM<0x90, 0>, ISA_MICROMIPS;
7930b57cec5SDimitry Andric  def ROTR_MM  : MMRel, shift_rotate_imm<"rotr", uimm5, GPR32Opnd, II_ROTR>,
7940b57cec5SDimitry Andric                 SRA_FM_MM<0xc0, 0>, ISA_MICROMIPS {
7950b57cec5SDimitry Andric    list<dag> Pattern = [(set GPR32Opnd:$rd,
7960b57cec5SDimitry Andric                          (rotr GPR32Opnd:$rt, immZExt5:$shamt))];
7970b57cec5SDimitry Andric  }
7980b57cec5SDimitry Andric  def ROTRV_MM : MMRel, shift_rotate_reg<"rotrv", GPR32Opnd, II_ROTRV>,
7990b57cec5SDimitry Andric                 SRLV_FM_MM<0xd0, 0>, ISA_MICROMIPS {
8000b57cec5SDimitry Andric    list<dag> Pattern = [(set GPR32Opnd:$rd,
8010b57cec5SDimitry Andric                          (rotr GPR32Opnd:$rt, GPR32Opnd:$rs))];
8020b57cec5SDimitry Andric  }
8030b57cec5SDimitry Andric
8040b57cec5SDimitry Andric  /// Load and Store Instructions - aligned
8050b57cec5SDimitry Andric  let DecoderMethod = "DecodeMemMMImm16" in {
8060b57cec5SDimitry Andric    def LB_MM  : LoadMemory<"lb", GPR32Opnd, mem_mm_16, sextloadi8, II_LB>,
8070b57cec5SDimitry Andric                 MMRel, LW_FM_MM<0x7>, ISA_MICROMIPS;
8080b57cec5SDimitry Andric    def LBu_MM : LoadMemory<"lbu", GPR32Opnd, mem_mm_16, zextloadi8, II_LBU>,
8090b57cec5SDimitry Andric                 MMRel, LW_FM_MM<0x5>, ISA_MICROMIPS;
8100b57cec5SDimitry Andric    def LH_MM  : LoadMemory<"lh", GPR32Opnd, mem_simmptr, sextloadi16, II_LH,
8110b57cec5SDimitry Andric                            addrDefault>, MMRel, LW_FM_MM<0xf>, ISA_MICROMIPS;
8120b57cec5SDimitry Andric    def LHu_MM : LoadMemory<"lhu", GPR32Opnd, mem_simmptr, zextloadi16, II_LHU>,
8130b57cec5SDimitry Andric                 MMRel, LW_FM_MM<0xd>, ISA_MICROMIPS;
8140b57cec5SDimitry Andric    def LW_MM  : Load<"lw", GPR32Opnd, null_frag, II_LW>, MMRel, LW_FM_MM<0x3f>,
8150b57cec5SDimitry Andric                 ISA_MICROMIPS;
8160b57cec5SDimitry Andric    def SB_MM  : Store<"sb", GPR32Opnd, truncstorei8, II_SB>, MMRel,
8170b57cec5SDimitry Andric                 LW_FM_MM<0x6>, ISA_MICROMIPS;
8180b57cec5SDimitry Andric    def SH_MM  : Store<"sh", GPR32Opnd, truncstorei16, II_SH>, MMRel,
8190b57cec5SDimitry Andric                 LW_FM_MM<0xe>, ISA_MICROMIPS;
8200b57cec5SDimitry Andric    def SW_MM  : Store<"sw", GPR32Opnd, null_frag, II_SW>, MMRel,
8210b57cec5SDimitry Andric                 LW_FM_MM<0x3e>, ISA_MICROMIPS;
8220b57cec5SDimitry Andric  }
8230b57cec5SDimitry Andric
8240b57cec5SDimitry Andric  let DecoderMethod = "DecodeMemMMImm9" in {
8250b57cec5SDimitry Andric    def LBE_MM  : MMRel, Load<"lbe", GPR32Opnd, null_frag, II_LBE>,
8260b57cec5SDimitry Andric                  POOL32C_LHUE_FM_MM<0x18, 0x6, 0x4>, ISA_MICROMIPS, ASE_EVA;
8270b57cec5SDimitry Andric    def LBuE_MM : MMRel, Load<"lbue", GPR32Opnd, null_frag, II_LBUE>,
8280b57cec5SDimitry Andric                  POOL32C_LHUE_FM_MM<0x18, 0x6, 0x0>, ISA_MICROMIPS, ASE_EVA;
8290b57cec5SDimitry Andric    def LHE_MM  : MMRel, LoadMemory<"lhe", GPR32Opnd, mem_simm9, null_frag,
8300b57cec5SDimitry Andric                                    II_LHE>,
8310b57cec5SDimitry Andric                  POOL32C_LHUE_FM_MM<0x18, 0x6, 0x5>, ISA_MICROMIPS, ASE_EVA;
8320b57cec5SDimitry Andric    def LHuE_MM : MMRel, LoadMemory<"lhue", GPR32Opnd, mem_simm9, null_frag,
8330b57cec5SDimitry Andric                                    II_LHUE>,
8340b57cec5SDimitry Andric                  POOL32C_LHUE_FM_MM<0x18, 0x6, 0x1>, ISA_MICROMIPS, ASE_EVA;
8350b57cec5SDimitry Andric    def LWE_MM  : MMRel, LoadMemory<"lwe", GPR32Opnd, mem_simm9, null_frag,
8360b57cec5SDimitry Andric                                    II_LWE>,
8370b57cec5SDimitry Andric                  POOL32C_LHUE_FM_MM<0x18, 0x6, 0x7>, ISA_MICROMIPS, ASE_EVA;
8380b57cec5SDimitry Andric    def SBE_MM  : MMRel, StoreMemory<"sbe", GPR32Opnd, mem_simm9, null_frag,
8390b57cec5SDimitry Andric                                     II_SBE>,
8400b57cec5SDimitry Andric                  POOL32C_LHUE_FM_MM<0x18, 0xa, 0x4>, ISA_MICROMIPS, ASE_EVA;
8410b57cec5SDimitry Andric    def SHE_MM  : MMRel, StoreMemory<"she", GPR32Opnd, mem_simm9, null_frag,
8420b57cec5SDimitry Andric                                     II_SHE>,
8430b57cec5SDimitry Andric                  POOL32C_LHUE_FM_MM<0x18, 0xa, 0x5>, ISA_MICROMIPS, ASE_EVA;
8440b57cec5SDimitry Andric    def SWE_MM  : MMRel, StoreMemory<"swe", GPR32Opnd, mem_simm9, null_frag,
8450b57cec5SDimitry Andric                                     II_SWE>,
8460b57cec5SDimitry Andric                  POOL32C_LHUE_FM_MM<0x18, 0xa, 0x7>, ISA_MICROMIPS, ASE_EVA;
8470b57cec5SDimitry Andric    def LWLE_MM : MMRel, LoadLeftRightMM<"lwle", MipsLWL, GPR32Opnd, mem_mm_9,
8480b57cec5SDimitry Andric                                         II_LWLE>,
8490b57cec5SDimitry Andric                  POOL32C_STEVA_LDEVA_FM_MM<0x6, 0x2>,
8500b57cec5SDimitry Andric                  ISA_MICROMIPS32_NOT_MIPS32R6, ASE_EVA;
8510b57cec5SDimitry Andric    def LWRE_MM : MMRel, LoadLeftRightMM<"lwre", MipsLWR, GPR32Opnd, mem_mm_9,
8520b57cec5SDimitry Andric                                         II_LWRE>,
8530b57cec5SDimitry Andric                  POOL32C_STEVA_LDEVA_FM_MM<0x6, 0x3>,
8540b57cec5SDimitry Andric                  ISA_MICROMIPS32_NOT_MIPS32R6, ASE_EVA;
8550b57cec5SDimitry Andric    def SWLE_MM : MMRel, StoreLeftRightMM<"swle", MipsSWL, GPR32Opnd, mem_mm_9,
8560b57cec5SDimitry Andric                                          II_SWLE>,
8570b57cec5SDimitry Andric                  POOL32C_STEVA_LDEVA_FM_MM<0xa, 0x0>,
8580b57cec5SDimitry Andric                  ISA_MICROMIPS32_NOT_MIPS32R6, ASE_EVA;
8590b57cec5SDimitry Andric    def SWRE_MM : MMRel, StoreLeftRightMM<"swre", MipsSWR, GPR32Opnd, mem_mm_9,
8600b57cec5SDimitry Andric                                          II_SWRE>,
8610b57cec5SDimitry Andric                  POOL32C_STEVA_LDEVA_FM_MM<0xa, 0x1>,
8620b57cec5SDimitry Andric                  ISA_MICROMIPS32_NOT_MIPS32R6, ASE_EVA;
8630b57cec5SDimitry Andric  }
8640b57cec5SDimitry Andric
8650b57cec5SDimitry Andric  def LWXS_MM : LoadWordIndexedScaledMM<"lwxs", GPR32Opnd>, LWXS_FM_MM<0x118>,
8660b57cec5SDimitry Andric                ISA_MICROMIPS;
8670b57cec5SDimitry Andric
8680b57cec5SDimitry Andric  /// Load and Store Instructions - unaligned
8690b57cec5SDimitry Andric  def LWL_MM : MMRel, LoadLeftRightMM<"lwl", MipsLWL, GPR32Opnd, mem_mm_12,
8700b57cec5SDimitry Andric                                      II_LWL>, LWL_FM_MM<0x0>,
8710b57cec5SDimitry Andric               ISA_MICROMIPS32_NOT_MIPS32R6;
8720b57cec5SDimitry Andric  def LWR_MM : MMRel, LoadLeftRightMM<"lwr", MipsLWR, GPR32Opnd, mem_mm_12,
8730b57cec5SDimitry Andric                                      II_LWR>, LWL_FM_MM<0x1>,
8740b57cec5SDimitry Andric               ISA_MICROMIPS32_NOT_MIPS32R6;
8750b57cec5SDimitry Andric  def SWL_MM : MMRel, StoreLeftRightMM<"swl", MipsSWL, GPR32Opnd, mem_mm_12,
8760b57cec5SDimitry Andric                                       II_SWL>, LWL_FM_MM<0x8>,
8770b57cec5SDimitry Andric               ISA_MICROMIPS32_NOT_MIPS32R6;
8780b57cec5SDimitry Andric  def SWR_MM : MMRel, StoreLeftRightMM<"swr", MipsSWR, GPR32Opnd, mem_mm_12,
8790b57cec5SDimitry Andric                                       II_SWR>, LWL_FM_MM<0x9>,
8800b57cec5SDimitry Andric               ISA_MICROMIPS32_NOT_MIPS32R6;
8810b57cec5SDimitry Andric
8820b57cec5SDimitry Andric  /// Load and Store Instructions - multiple
8830b57cec5SDimitry Andric  def SWM32_MM  : StoreMultMM<"swm32", II_SWM>, LWM_FM_MM<0xd>, ISA_MICROMIPS;
8840b57cec5SDimitry Andric  def LWM32_MM  : LoadMultMM<"lwm32", II_LWM>, LWM_FM_MM<0x5>, ISA_MICROMIPS;
8850b57cec5SDimitry Andric
8860b57cec5SDimitry Andric  /// Load and Store Pair Instructions
8870b57cec5SDimitry Andric  def SWP_MM  : StorePairMM<"swp">, LWM_FM_MM<0x9>, ISA_MICROMIPS;
8880b57cec5SDimitry Andric  def LWP_MM  : LoadPairMM<"lwp">, LWM_FM_MM<0x1>, ISA_MICROMIPS;
8890b57cec5SDimitry Andric
8900b57cec5SDimitry Andric  /// Load and Store multiple pseudo Instructions
8910b57cec5SDimitry Andric  class LoadWordMultMM<string instr_asm > :
8920b57cec5SDimitry Andric    MipsAsmPseudoInst<(outs reglist:$rt), (ins mem_mm_12:$addr),
8930b57cec5SDimitry Andric                      !strconcat(instr_asm, "\t$rt, $addr")> ;
8940b57cec5SDimitry Andric
8950b57cec5SDimitry Andric  class StoreWordMultMM<string instr_asm > :
8960b57cec5SDimitry Andric    MipsAsmPseudoInst<(outs), (ins reglist:$rt, mem_mm_12:$addr),
8970b57cec5SDimitry Andric                      !strconcat(instr_asm, "\t$rt, $addr")> ;
8980b57cec5SDimitry Andric
8990b57cec5SDimitry Andric
9000b57cec5SDimitry Andric  def SWM_MM  : StoreWordMultMM<"swm">, ISA_MICROMIPS;
9010b57cec5SDimitry Andric  def LWM_MM  : LoadWordMultMM<"lwm">, ISA_MICROMIPS;
9020b57cec5SDimitry Andric
9030b57cec5SDimitry Andric  /// Move Conditional
9040b57cec5SDimitry Andric  def MOVZ_I_MM : MMRel, CMov_I_I_FT<"movz", GPR32Opnd, GPR32Opnd,
9050b57cec5SDimitry Andric                                     II_MOVZ>, ADD_FM_MM<0, 0x58>,
9060b57cec5SDimitry Andric                  ISA_MICROMIPS32_NOT_MIPS32R6;
9070b57cec5SDimitry Andric  def MOVN_I_MM : MMRel, CMov_I_I_FT<"movn", GPR32Opnd, GPR32Opnd,
9080b57cec5SDimitry Andric                                     II_MOVN>, ADD_FM_MM<0, 0x18>,
9090b57cec5SDimitry Andric                  ISA_MICROMIPS32_NOT_MIPS32R6;
9100b57cec5SDimitry Andric  def MOVT_I_MM : MMRel, CMov_F_I_FT<"movt", GPR32Opnd, II_MOVT, MipsCMovFP_T>,
9110b57cec5SDimitry Andric                  CMov_F_I_FM_MM<0x25>, ISA_MICROMIPS32_NOT_MIPS32R6;
9120b57cec5SDimitry Andric  def MOVF_I_MM : MMRel, CMov_F_I_FT<"movf", GPR32Opnd, II_MOVF, MipsCMovFP_F>,
9130b57cec5SDimitry Andric                  CMov_F_I_FM_MM<0x5>, ISA_MICROMIPS32_NOT_MIPS32R6;
9140b57cec5SDimitry Andric  /// Move to/from HI/LO
9150b57cec5SDimitry Andric  def MTHI_MM : MMRel, MoveToLOHI<"mthi", GPR32Opnd, [HI0]>,
9160b57cec5SDimitry Andric                MTLO_FM_MM<0x0b5>, ISA_MICROMIPS32_NOT_MIPS32R6;
9170b57cec5SDimitry Andric  def MTLO_MM : MMRel, MoveToLOHI<"mtlo", GPR32Opnd, [LO0]>,
9180b57cec5SDimitry Andric                MTLO_FM_MM<0x0f5>, ISA_MICROMIPS32_NOT_MIPS32R6;
9190b57cec5SDimitry Andric  def MFHI_MM : MMRel, MoveFromLOHI<"mfhi", GPR32Opnd, AC0>,
9200b57cec5SDimitry Andric                MFLO_FM_MM<0x035>, ISA_MICROMIPS32_NOT_MIPS32R6;
9210b57cec5SDimitry Andric  def MFLO_MM : MMRel, MoveFromLOHI<"mflo", GPR32Opnd, AC0>,
9220b57cec5SDimitry Andric                MFLO_FM_MM<0x075>, ISA_MICROMIPS32_NOT_MIPS32R6;
9230b57cec5SDimitry Andric
9240b57cec5SDimitry Andric  /// Multiply Add/Sub Instructions
9250b57cec5SDimitry Andric  def MADD_MM  : MMRel, MArithR<"madd", II_MADD, 1>, MULT_FM_MM<0x32c>,
9260b57cec5SDimitry Andric                 ISA_MICROMIPS32_NOT_MIPS32R6;
9270b57cec5SDimitry Andric  def MADDU_MM : MMRel, MArithR<"maddu", II_MADDU, 1>, MULT_FM_MM<0x36c>,
9280b57cec5SDimitry Andric                 ISA_MICROMIPS32_NOT_MIPS32R6;
9290b57cec5SDimitry Andric  def MSUB_MM  : MMRel, MArithR<"msub", II_MSUB>, MULT_FM_MM<0x3ac>,
9300b57cec5SDimitry Andric                 ISA_MICROMIPS32_NOT_MIPS32R6;
9310b57cec5SDimitry Andric  def MSUBU_MM : MMRel, MArithR<"msubu", II_MSUBU>, MULT_FM_MM<0x3ec>,
9320b57cec5SDimitry Andric                 ISA_MICROMIPS32_NOT_MIPS32R6;
9330b57cec5SDimitry Andric
9340b57cec5SDimitry Andric  /// Count Leading
9350b57cec5SDimitry Andric  def CLZ_MM : MMRel, CountLeading0<"clz", GPR32Opnd, II_CLZ>, CLO_FM_MM<0x16c>,
9360b57cec5SDimitry Andric               ISA_MICROMIPS;
9370b57cec5SDimitry Andric  def CLO_MM : MMRel, CountLeading1<"clo", GPR32Opnd, II_CLO>, CLO_FM_MM<0x12c>,
9380b57cec5SDimitry Andric               ISA_MICROMIPS;
9390b57cec5SDimitry Andric
9400b57cec5SDimitry Andric  /// Sign Ext In Register Instructions.
9410b57cec5SDimitry Andric  def SEB_MM : MMRel, SignExtInReg<"seb", i8, GPR32Opnd, II_SEB>,
9420b57cec5SDimitry Andric               SEB_FM_MM<0x0ac>, ISA_MICROMIPS;
9430b57cec5SDimitry Andric  def SEH_MM : MMRel, SignExtInReg<"seh", i16, GPR32Opnd, II_SEH>,
9440b57cec5SDimitry Andric               SEB_FM_MM<0x0ec>, ISA_MICROMIPS;
9450b57cec5SDimitry Andric
9460b57cec5SDimitry Andric  /// Word Swap Bytes Within Halfwords
9470b57cec5SDimitry Andric  def WSBH_MM : MMRel, SubwordSwap<"wsbh", GPR32Opnd, II_WSBH>,
9480b57cec5SDimitry Andric                SEB_FM_MM<0x1ec>, ISA_MICROMIPS;
9490b57cec5SDimitry Andric  // TODO: Add '0 < pos+size <= 32' constraint check to ext instruction
9500b57cec5SDimitry Andric  def EXT_MM : MMRel, ExtBase<"ext", GPR32Opnd, uimm5, uimm5_plus1, immZExt5,
9510b57cec5SDimitry Andric                              immZExt5Plus1, MipsExt>, EXT_FM_MM<0x2c>,
9520b57cec5SDimitry Andric               ISA_MICROMIPS32_NOT_MIPS32R6;
9530b57cec5SDimitry Andric  def INS_MM : MMRel, InsBase<"ins", GPR32Opnd, uimm5, uimm5_inssize_plus1,
9540b57cec5SDimitry Andric                              immZExt5, immZExt5Plus1>,
9550b57cec5SDimitry Andric               EXT_FM_MM<0x0c>, ISA_MICROMIPS32_NOT_MIPS32R6;
9560b57cec5SDimitry Andric
9570b57cec5SDimitry Andric  /// Jump Instructions
958*8bcb0991SDimitry Andric  let DecoderMethod = "DecodeJumpTargetMM" in {
9590b57cec5SDimitry Andric    def J_MM          : MMRel, JumpFJ<jmptarget_mm, "j", br, bb, "j">,
9600b57cec5SDimitry Andric                        J_FM_MM<0x35>, AdditionalRequires<[RelocNotPIC]>,
9610b57cec5SDimitry Andric                        IsBranch, ISA_MICROMIPS32_NOT_MIPS32R6;
9620b57cec5SDimitry Andric    def JAL_MM      : MMRel, JumpLink<"jal", calltarget_mm>, J_FM_MM<0x3d>,
9630b57cec5SDimitry Andric                      ISA_MICROMIPS32_NOT_MIPS32R6;
964*8bcb0991SDimitry Andric  }
965*8bcb0991SDimitry Andric
966*8bcb0991SDimitry Andric  let DecoderMethod = "DecodeJumpTargetXMM" in
9670b57cec5SDimitry Andric    def JALX_MM     : MMRel, JumpLink<"jalx", calltarget>, J_FM_MM<0x3c>,
9680b57cec5SDimitry Andric                      ISA_MICROMIPS32_NOT_MIPS32R6;
969*8bcb0991SDimitry Andric
9700b57cec5SDimitry Andric  def JR_MM : MMRel, IndirectBranch<"jr", GPR32Opnd>, JR_FM_MM<0x3c>,
9710b57cec5SDimitry Andric              ISA_MICROMIPS32_NOT_MIPS32R6;
9720b57cec5SDimitry Andric  def JALR_MM : JumpLinkReg<"jalr", GPR32Opnd>, JALR_FM_MM<0x03c>,
9730b57cec5SDimitry Andric                ISA_MICROMIPS32_NOT_MIPS32R6;
9740b57cec5SDimitry Andric
9750b57cec5SDimitry Andric  /// Jump Instructions - Short Delay Slot
9760b57cec5SDimitry Andric  def JALS_MM   : JumpLinkMM<"jals", calltarget_mm>, J_FM_MM<0x1d>,
9770b57cec5SDimitry Andric                  ISA_MICROMIPS32_NOT_MIPS32R6;
9780b57cec5SDimitry Andric  def JALRS_MM  : JumpLinkRegMM<"jalrs", GPR32Opnd>, JALR_FM_MM<0x13c>,
9790b57cec5SDimitry Andric                  ISA_MICROMIPS32_NOT_MIPS32R6;
9800b57cec5SDimitry Andric
9810b57cec5SDimitry Andric  /// Branch Instructions
9820b57cec5SDimitry Andric  def BEQ_MM  : MMRel, CBranch<"beq", brtarget_mm, seteq, GPR32Opnd>,
9830b57cec5SDimitry Andric                BEQ_FM_MM<0x25>, ISA_MICROMIPS32_NOT_MIPS32R6;
9840b57cec5SDimitry Andric  def BNE_MM  : MMRel, CBranch<"bne", brtarget_mm, setne, GPR32Opnd>,
9850b57cec5SDimitry Andric                BEQ_FM_MM<0x2d>, ISA_MICROMIPS32_NOT_MIPS32R6;
9860b57cec5SDimitry Andric  def BGEZ_MM : MMRel, CBranchZero<"bgez", brtarget_mm, setge, GPR32Opnd>,
9870b57cec5SDimitry Andric                BGEZ_FM_MM<0x2>, ISA_MICROMIPS32_NOT_MIPS32R6;
9880b57cec5SDimitry Andric  def BGTZ_MM : MMRel, CBranchZero<"bgtz", brtarget_mm, setgt, GPR32Opnd>,
9890b57cec5SDimitry Andric                BGEZ_FM_MM<0x6>, ISA_MICROMIPS32_NOT_MIPS32R6;
9900b57cec5SDimitry Andric  def BLEZ_MM : MMRel, CBranchZero<"blez", brtarget_mm, setle, GPR32Opnd>,
9910b57cec5SDimitry Andric                BGEZ_FM_MM<0x4>, ISA_MICROMIPS32_NOT_MIPS32R6;
9920b57cec5SDimitry Andric  def BLTZ_MM : MMRel, CBranchZero<"bltz", brtarget_mm, setlt, GPR32Opnd>,
9930b57cec5SDimitry Andric                BGEZ_FM_MM<0x0>, ISA_MICROMIPS32_NOT_MIPS32R6;
9940b57cec5SDimitry Andric  def BGEZAL_MM : MMRel, BGEZAL_FT<"bgezal", brtarget_mm, GPR32Opnd>,
9950b57cec5SDimitry Andric                  BGEZAL_FM_MM<0x03>, ISA_MICROMIPS32_NOT_MIPS32R6;
9960b57cec5SDimitry Andric  def BLTZAL_MM : MMRel, BGEZAL_FT<"bltzal", brtarget_mm, GPR32Opnd>,
9970b57cec5SDimitry Andric                  BGEZAL_FM_MM<0x01>, ISA_MICROMIPS32_NOT_MIPS32R6;
9980b57cec5SDimitry Andric  def BAL_BR_MM : BAL_BR_Pseudo<BGEZAL_MM, brtarget_mm>,
9990b57cec5SDimitry Andric                  ISA_MICROMIPS32_NOT_MIPS32R6;
10000b57cec5SDimitry Andric
10010b57cec5SDimitry Andric  /// Branch Instructions - Short Delay Slot
10020b57cec5SDimitry Andric  def BGEZALS_MM : BranchCompareToZeroLinkMM<"bgezals", brtarget_mm,
10030b57cec5SDimitry Andric                                             GPR32Opnd>, BGEZAL_FM_MM<0x13>,
10040b57cec5SDimitry Andric                   ISA_MICROMIPS32_NOT_MIPS32R6;
10050b57cec5SDimitry Andric  def BLTZALS_MM : BranchCompareToZeroLinkMM<"bltzals", brtarget_mm,
10060b57cec5SDimitry Andric                                             GPR32Opnd>, BGEZAL_FM_MM<0x11>,
10070b57cec5SDimitry Andric                   ISA_MICROMIPS32_NOT_MIPS32R6;
10080b57cec5SDimitry Andric  def B_MM    : UncondBranch<BEQ_MM, brtarget_mm>, IsBranch,
10090b57cec5SDimitry Andric                ISA_MICROMIPS32_NOT_MIPS32R6;
10100b57cec5SDimitry Andric
10110b57cec5SDimitry Andric  /// Control Instructions
10120b57cec5SDimitry Andric  def SYNC_MM    : MMRel, SYNC_FT<"sync">, SYNC_FM_MM, ISA_MICROMIPS;
10130b57cec5SDimitry Andric  let DecoderMethod = "DecodeSyncI_MM" in
10140b57cec5SDimitry Andric    def SYNCI_MM   : MMRel, SYNCI_FT<"synci", mem_mm_16>, SYNCI_FM_MM,
10150b57cec5SDimitry Andric                     ISA_MICROMIPS32_NOT_MIPS32R6;
10160b57cec5SDimitry Andric  def BREAK_MM   : MMRel, BRK_FT<"break">, BRK_FM_MM, ISA_MICROMIPS;
10170b57cec5SDimitry Andric  def SYSCALL_MM : MMRel, SYS_FT<"syscall", uimm10, II_SYSCALL>, SYS_FM_MM,
10180b57cec5SDimitry Andric                   ISA_MICROMIPS;
10190b57cec5SDimitry Andric  def WAIT_MM    : MMRel, WaitMM<"wait">, WAIT_FM_MM, ISA_MICROMIPS;
10200b57cec5SDimitry Andric  def ERET_MM    : MMRel, ER_FT<"eret", II_ERET>, ER_FM_MM<0x3cd>,
10210b57cec5SDimitry Andric                   ISA_MICROMIPS;
10220b57cec5SDimitry Andric  def DERET_MM   : MMRel, ER_FT<"deret", II_DERET>, ER_FM_MM<0x38d>,
10230b57cec5SDimitry Andric                   ISA_MICROMIPS;
10240b57cec5SDimitry Andric  def EI_MM      : MMRel, DEI_FT<"ei", GPR32Opnd, II_EI>, EI_FM_MM<0x15d>,
10250b57cec5SDimitry Andric                   ISA_MICROMIPS;
10260b57cec5SDimitry Andric  def DI_MM      : MMRel, DEI_FT<"di", GPR32Opnd, II_DI>, EI_FM_MM<0x11d>,
10270b57cec5SDimitry Andric                   ISA_MICROMIPS;
10280b57cec5SDimitry Andric  def TRAP_MM    : TrapBase<BREAK_MM>, ISA_MICROMIPS;
10290b57cec5SDimitry Andric
10300b57cec5SDimitry Andric  /// Trap Instructions
10310b57cec5SDimitry Andric  def TEQ_MM  : MMRel, TEQ_FT<"teq", GPR32Opnd, uimm4, II_TEQ>, TEQ_FM_MM<0x0>,
10320b57cec5SDimitry Andric                ISA_MICROMIPS;
10330b57cec5SDimitry Andric  def TGE_MM  : MMRel, TEQ_FT<"tge", GPR32Opnd, uimm4, II_TGE>, TEQ_FM_MM<0x08>,
10340b57cec5SDimitry Andric                ISA_MICROMIPS;
10350b57cec5SDimitry Andric  def TGEU_MM : MMRel, TEQ_FT<"tgeu", GPR32Opnd, uimm4, II_TGEU>,
10360b57cec5SDimitry Andric                TEQ_FM_MM<0x10>, ISA_MICROMIPS;
10370b57cec5SDimitry Andric  def TLT_MM  : MMRel, TEQ_FT<"tlt", GPR32Opnd, uimm4, II_TLT>, TEQ_FM_MM<0x20>,
10380b57cec5SDimitry Andric                ISA_MICROMIPS;
10390b57cec5SDimitry Andric  def TLTU_MM : MMRel, TEQ_FT<"tltu", GPR32Opnd, uimm4, II_TLTU>,
10400b57cec5SDimitry Andric                TEQ_FM_MM<0x28>, ISA_MICROMIPS;
10410b57cec5SDimitry Andric  def TNE_MM  : MMRel, TEQ_FT<"tne", GPR32Opnd, uimm4, II_TNE>, TEQ_FM_MM<0x30>,
10420b57cec5SDimitry Andric                ISA_MICROMIPS;
10430b57cec5SDimitry Andric
10440b57cec5SDimitry Andric  def TEQI_MM  : MMRel, TEQI_FT<"teqi", GPR32Opnd, II_TEQI>, TEQI_FM_MM<0x0e>,
10450b57cec5SDimitry Andric                 ISA_MICROMIPS32_NOT_MIPS32R6;
10460b57cec5SDimitry Andric  def TGEI_MM  : MMRel, TEQI_FT<"tgei", GPR32Opnd, II_TGEI>, TEQI_FM_MM<0x09>,
10470b57cec5SDimitry Andric                 ISA_MICROMIPS32_NOT_MIPS32R6;
10480b57cec5SDimitry Andric  def TGEIU_MM : MMRel, TEQI_FT<"tgeiu", GPR32Opnd, II_TGEIU>,
10490b57cec5SDimitry Andric                 TEQI_FM_MM<0x0b>, ISA_MICROMIPS32_NOT_MIPS32R6;
10500b57cec5SDimitry Andric  def TLTI_MM  : MMRel, TEQI_FT<"tlti", GPR32Opnd, II_TLTI>, TEQI_FM_MM<0x08>,
10510b57cec5SDimitry Andric                 ISA_MICROMIPS32_NOT_MIPS32R6;
10520b57cec5SDimitry Andric  def TLTIU_MM : MMRel, TEQI_FT<"tltiu", GPR32Opnd, II_TTLTIU>,
10530b57cec5SDimitry Andric                 TEQI_FM_MM<0x0a>, ISA_MICROMIPS32_NOT_MIPS32R6;
10540b57cec5SDimitry Andric  def TNEI_MM  : MMRel, TEQI_FT<"tnei", GPR32Opnd, II_TNEI>, TEQI_FM_MM<0x0c>,
10550b57cec5SDimitry Andric                 ISA_MICROMIPS32_NOT_MIPS32R6;
10560b57cec5SDimitry Andric
10570b57cec5SDimitry Andric  /// Load-linked, Store-conditional
10580b57cec5SDimitry Andric  def LL_MM : LLBaseMM<"ll", GPR32Opnd>, LL_FM_MM<0x3>,
10590b57cec5SDimitry Andric              ISA_MICROMIPS32_NOT_MIPS32R6;
10600b57cec5SDimitry Andric  def SC_MM : SCBaseMM<"sc", GPR32Opnd>, LL_FM_MM<0xb>,
10610b57cec5SDimitry Andric              ISA_MICROMIPS32_NOT_MIPS32R6;
10620b57cec5SDimitry Andric
10630b57cec5SDimitry Andric  def LLE_MM : MMRel, LLEBaseMM<"lle", GPR32Opnd>, LLE_FM_MM<0x6>,
10640b57cec5SDimitry Andric               ISA_MICROMIPS, ASE_EVA;
10650b57cec5SDimitry Andric  def SCE_MM : MMRel, SCEBaseMM<"sce", GPR32Opnd>, LLE_FM_MM<0xA>,
10660b57cec5SDimitry Andric               ISA_MICROMIPS, ASE_EVA;
10670b57cec5SDimitry Andric
10680b57cec5SDimitry Andric  let DecoderMethod = "DecodeCacheOpMM" in {
10690b57cec5SDimitry Andric    def CACHE_MM : MMRel, CacheOp<"cache", mem_mm_12, II_CACHE>,
10700b57cec5SDimitry Andric                   CACHE_PREF_FM_MM<0x08, 0x6>, ISA_MICROMIPS32_NOT_MIPS32R6;
10710b57cec5SDimitry Andric    def PREF_MM  : MMRel, CacheOp<"pref", mem_mm_12, II_PREF>,
10720b57cec5SDimitry Andric                   CACHE_PREF_FM_MM<0x18, 0x2>, ISA_MICROMIPS32_NOT_MIPS32R6;
10730b57cec5SDimitry Andric  }
10740b57cec5SDimitry Andric
10750b57cec5SDimitry Andric  let DecoderMethod = "DecodePrefeOpMM" in {
10760b57cec5SDimitry Andric    def PREFE_MM  : MMRel, CacheOp<"prefe", mem_mm_9, II_PREFE>,
10770b57cec5SDimitry Andric                    CACHE_PREFE_FM_MM<0x18, 0x2>, ISA_MICROMIPS, ASE_EVA;
10780b57cec5SDimitry Andric    def CACHEE_MM : MMRel, CacheOp<"cachee", mem_mm_9, II_CACHEE>,
10790b57cec5SDimitry Andric                    CACHE_PREFE_FM_MM<0x18, 0x3>, ISA_MICROMIPS, ASE_EVA;
10800b57cec5SDimitry Andric  }
10810b57cec5SDimitry Andric  def SSNOP_MM : MMRel, Barrier<"ssnop", II_SSNOP>, BARRIER_FM_MM<0x1>,
10820b57cec5SDimitry Andric                 ISA_MICROMIPS;
10830b57cec5SDimitry Andric  def EHB_MM   : MMRel, Barrier<"ehb", II_EHB>, BARRIER_FM_MM<0x3>,
10840b57cec5SDimitry Andric                 ISA_MICROMIPS;
10850b57cec5SDimitry Andric  def PAUSE_MM : MMRel, Barrier<"pause", II_PAUSE>, BARRIER_FM_MM<0x5>,
10860b57cec5SDimitry Andric                 ISA_MICROMIPS;
10870b57cec5SDimitry Andric
10880b57cec5SDimitry Andric  def TLBP_MM : MMRel, TLB<"tlbp", II_TLBP>, COP0_TLB_FM_MM<0x0d>,
10890b57cec5SDimitry Andric                ISA_MICROMIPS;
10900b57cec5SDimitry Andric  def TLBR_MM : MMRel, TLB<"tlbr", II_TLBR>, COP0_TLB_FM_MM<0x4d>,
10910b57cec5SDimitry Andric                ISA_MICROMIPS;
10920b57cec5SDimitry Andric  def TLBWI_MM : MMRel, TLB<"tlbwi", II_TLBWI>, COP0_TLB_FM_MM<0x8d>,
10930b57cec5SDimitry Andric                 ISA_MICROMIPS;
10940b57cec5SDimitry Andric  def TLBWR_MM : MMRel, TLB<"tlbwr", II_TLBWR>, COP0_TLB_FM_MM<0xcd>,
10950b57cec5SDimitry Andric                 ISA_MICROMIPS;
10960b57cec5SDimitry Andric
10970b57cec5SDimitry Andric  def SDBBP_MM : MMRel, SYS_FT<"sdbbp", uimm10, II_SDBBP>, SDBBP_FM_MM,
10980b57cec5SDimitry Andric                 ISA_MICROMIPS;
10990b57cec5SDimitry Andric
11000b57cec5SDimitry Andric  def PREFX_MM : PrefetchIndexed<"prefx">, POOL32F_PREFX_FM_MM<0x15, 0x1A0>,
11010b57cec5SDimitry Andric                 ISA_MICROMIPS32_NOT_MIPS32R6;
11020b57cec5SDimitry Andric}
11030b57cec5SDimitry Andric
11040b57cec5SDimitry Andriclet AdditionalPredicates = [NotDSP] in {
11050b57cec5SDimitry Andric  def PseudoMULT_MM : MultDivPseudo<MULT, ACC64, GPR32Opnd, MipsMult, II_MULT>,
11060b57cec5SDimitry Andric                      ISA_MICROMIPS32_NOT_MIPS32R6;
11070b57cec5SDimitry Andric  def PseudoMULTu_MM : MultDivPseudo<MULTu, ACC64, GPR32Opnd, MipsMultu, II_MULTU>,
11080b57cec5SDimitry Andric                       ISA_MICROMIPS32_NOT_MIPS32R6;
11090b57cec5SDimitry Andric  def PseudoMFHI_MM : PseudoMFLOHI<GPR32, ACC64, MipsMFHI>,
11100b57cec5SDimitry Andric                      ISA_MICROMIPS32_NOT_MIPS32R6;
11110b57cec5SDimitry Andric  def PseudoMFLO_MM : PseudoMFLOHI<GPR32, ACC64, MipsMFLO>,
11120b57cec5SDimitry Andric                      ISA_MICROMIPS32_NOT_MIPS32R6;
11130b57cec5SDimitry Andric  def PseudoMTLOHI_MM : PseudoMTLOHI<ACC64, GPR32>,
11140b57cec5SDimitry Andric                        ISA_MICROMIPS32_NOT_MIPS32R6;
11150b57cec5SDimitry Andric  def PseudoMADD_MM : MAddSubPseudo<MADD, MipsMAdd, II_MADD>,
11160b57cec5SDimitry Andric                      ISA_MICROMIPS32_NOT_MIPS32R6;
11170b57cec5SDimitry Andric  def PseudoMADDU_MM : MAddSubPseudo<MADDU, MipsMAddu, II_MADDU>,
11180b57cec5SDimitry Andric                       ISA_MICROMIPS32_NOT_MIPS32R6;
11190b57cec5SDimitry Andric  def PseudoMSUB_MM : MAddSubPseudo<MSUB, MipsMSub, II_MSUB>,
11200b57cec5SDimitry Andric                      ISA_MICROMIPS32_NOT_MIPS32R6;
11210b57cec5SDimitry Andric  def PseudoMSUBU_MM : MAddSubPseudo<MSUBU, MipsMSubu, II_MSUBU>,
11220b57cec5SDimitry Andric                       ISA_MICROMIPS32_NOT_MIPS32R6;
11230b57cec5SDimitry Andric}
11240b57cec5SDimitry Andric
11250b57cec5SDimitry Andricdef TAILCALL_MM : TailCall<J_MM, jmptarget_mm>,
11260b57cec5SDimitry Andric                  ISA_MICROMIPS32_NOT_MIPS32R6;
11270b57cec5SDimitry Andric
11280b57cec5SDimitry Andricdef TAILCALLREG_MM  : TailCallReg<JRC16_MM, GPR32Opnd>,
11290b57cec5SDimitry Andric                      ISA_MICROMIPS32_NOT_MIPS32R6;
11300b57cec5SDimitry Andric
11310b57cec5SDimitry Andricdef PseudoIndirectBranch_MM : PseudoIndirectBranchBase<JR_MM, GPR32Opnd>,
11320b57cec5SDimitry Andric                              ISA_MICROMIPS32_NOT_MIPS32R6;
11330b57cec5SDimitry Andric
11340b57cec5SDimitry Andriclet DecoderNamespace = "MicroMips" in {
11350b57cec5SDimitry Andric  def RDHWR_MM : MMRel, R6MMR6Rel, ReadHardware<GPR32Opnd, HWRegsOpnd>,
11360b57cec5SDimitry Andric                 RDHWR_FM_MM, ISA_MICROMIPS32_NOT_MIPS32R6;
11370b57cec5SDimitry Andric  def LWU_MM : MMRel, LoadMM<"lwu", GPR32Opnd, zextloadi32, II_LWU,
11380b57cec5SDimitry Andric                             mem_simm12>, LL_FM_MM<0xe>,
11390b57cec5SDimitry Andric               ISA_MICROMIPS32_NOT_MIPS32R6;
11400b57cec5SDimitry Andric
11410b57cec5SDimitry Andric  def MFGC0_MM    : MMRel, MfCop0MM<"mfgc0", GPR32Opnd, COP0Opnd, II_MFGC0>,
11420b57cec5SDimitry Andric                    POOL32A_MFTC0_FM_MM<0b10011, 0b111100>,
11430b57cec5SDimitry Andric                    ISA_MICROMIPS32R5, ASE_VIRT;
11440b57cec5SDimitry Andric  def MFHGC0_MM   : MMRel, MfCop0MM<"mfhgc0", GPR32Opnd, COP0Opnd, II_MFHGC0>,
11450b57cec5SDimitry Andric                    POOL32A_MFTC0_FM_MM<0b10011, 0b110100>,
11460b57cec5SDimitry Andric                    ISA_MICROMIPS32R5, ASE_VIRT;
11470b57cec5SDimitry Andric  def MTGC0_MM    : MMRel, MtCop0MM<"mtgc0", COP0Opnd, GPR32Opnd, II_MTGC0>,
11480b57cec5SDimitry Andric                    POOL32A_MFTC0_FM_MM<0b11011, 0b111100>,
11490b57cec5SDimitry Andric                    ISA_MICROMIPS32R5, ASE_VIRT;
11500b57cec5SDimitry Andric  def MTHGC0_MM   : MMRel, MtCop0MM<"mthgc0", COP0Opnd, GPR32Opnd, II_MTHGC0>,
11510b57cec5SDimitry Andric                    POOL32A_MFTC0_FM_MM<0b11011, 0b110100>,
11520b57cec5SDimitry Andric                    ISA_MICROMIPS32R5, ASE_VIRT;
11530b57cec5SDimitry Andric  def HYPCALL_MM  : MMRel, HypcallMM<"hypcall">, POOL32A_HYPCALL_FM_MM,
11540b57cec5SDimitry Andric                    ISA_MICROMIPS32R5, ASE_VIRT;
11550b57cec5SDimitry Andric  def TLBGINV_MM  : MMRel, TLBINVMM<"tlbginv", II_TLBGINV>,
11560b57cec5SDimitry Andric                    POOL32A_TLBINV_FM_MM<0x105>, ISA_MICROMIPS32R5, ASE_VIRT;
11570b57cec5SDimitry Andric  def TLBGINVF_MM : MMRel, TLBINVMM<"tlbginvf", II_TLBGINVF>,
11580b57cec5SDimitry Andric                    POOL32A_TLBINV_FM_MM<0x145>, ISA_MICROMIPS32R5, ASE_VIRT;
11590b57cec5SDimitry Andric  def TLBGP_MM    : MMRel, TLBINVMM<"tlbgp", II_TLBGP>,
11600b57cec5SDimitry Andric                    POOL32A_TLBINV_FM_MM<0x5>, ISA_MICROMIPS32R5, ASE_VIRT;
11610b57cec5SDimitry Andric  def TLBGR_MM    : MMRel, TLBINVMM<"tlbgr", II_TLBGR>,
11620b57cec5SDimitry Andric                    POOL32A_TLBINV_FM_MM<0x45>, ISA_MICROMIPS32R5, ASE_VIRT;
11630b57cec5SDimitry Andric  def TLBGWI_MM   : MMRel, TLBINVMM<"tlbgwi", II_TLBGWI>,
11640b57cec5SDimitry Andric                    POOL32A_TLBINV_FM_MM<0x85>, ISA_MICROMIPS32R5, ASE_VIRT;
11650b57cec5SDimitry Andric  def TLBGWR_MM   : MMRel, TLBINVMM<"tlbgwr", II_TLBGWR>,
11660b57cec5SDimitry Andric                    POOL32A_TLBINV_FM_MM<0xc5>, ISA_MICROMIPS32R5, ASE_VIRT;
11670b57cec5SDimitry Andric}
11680b57cec5SDimitry Andric
11690b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
11700b57cec5SDimitry Andric// MicroMips arbitrary patterns that map to one or more instructions
11710b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
11720b57cec5SDimitry Andric
11730b57cec5SDimitry Andricdefm : MipsHiLoRelocs<LUi_MM, ADDiu_MM, ZERO, GPR32Opnd>, ISA_MICROMIPS;
11740b57cec5SDimitry Andric
11750b57cec5SDimitry Andricdef : MipsPat<(MipsGotHi tglobaladdr:$in), (LUi_MM tglobaladdr:$in)>,
11760b57cec5SDimitry Andric      ISA_MICROMIPS;
11770b57cec5SDimitry Andricdef : MipsPat<(MipsGotHi texternalsym:$in), (LUi_MM texternalsym:$in)>,
11780b57cec5SDimitry Andric      ISA_MICROMIPS;
11790b57cec5SDimitry Andric
11800b57cec5SDimitry Andricdef : MipsPat<(MipsTlsHi tglobaltlsaddr:$in), (LUi_MM tglobaltlsaddr:$in)>,
11810b57cec5SDimitry Andric      ISA_MICROMIPS;
11820b57cec5SDimitry Andric
11830b57cec5SDimitry Andric// gp_rel relocs
11840b57cec5SDimitry Andricdef : MipsPat<(add GPR32:$gp, (MipsGPRel tglobaladdr:$in)),
11850b57cec5SDimitry Andric              (ADDiu_MM GPR32:$gp, tglobaladdr:$in)>, ISA_MICROMIPS;
11860b57cec5SDimitry Andricdef : MipsPat<(add GPR32:$gp, (MipsGPRel tconstpool:$in)),
11870b57cec5SDimitry Andric              (ADDiu_MM GPR32:$gp, tconstpool:$in)>, ISA_MICROMIPS;
11880b57cec5SDimitry Andric
11890b57cec5SDimitry Andricdef : WrapperPat<tglobaladdr, ADDiu_MM, GPR32>, ISA_MICROMIPS;
11900b57cec5SDimitry Andricdef : WrapperPat<tconstpool, ADDiu_MM, GPR32>, ISA_MICROMIPS;
11910b57cec5SDimitry Andricdef : WrapperPat<texternalsym, ADDiu_MM, GPR32>, ISA_MICROMIPS;
11920b57cec5SDimitry Andricdef : WrapperPat<tblockaddress, ADDiu_MM, GPR32>, ISA_MICROMIPS;
11930b57cec5SDimitry Andricdef : WrapperPat<tjumptable, ADDiu_MM, GPR32>, ISA_MICROMIPS;
11940b57cec5SDimitry Andricdef : WrapperPat<tglobaltlsaddr, ADDiu_MM, GPR32>, ISA_MICROMIPS;
11950b57cec5SDimitry Andric
11960b57cec5SDimitry Andricdef : MipsPat<(atomic_load_8 addr:$a), (LB_MM addr:$a)>, ISA_MICROMIPS;
11970b57cec5SDimitry Andricdef : MipsPat<(atomic_load_16 addr:$a), (LH_MM addr:$a)>, ISA_MICROMIPS;
11980b57cec5SDimitry Andricdef : MipsPat<(atomic_load_32 addr:$a), (LW_MM addr:$a)>, ISA_MICROMIPS;
11990b57cec5SDimitry Andric
12000b57cec5SDimitry Andricdef : MipsPat<(i32 immLi16:$imm),
12010b57cec5SDimitry Andric              (LI16_MM immLi16:$imm)>, ISA_MICROMIPS;
12020b57cec5SDimitry Andric
12030b57cec5SDimitry Andricdefm : MaterializeImms<i32, ZERO, ADDiu_MM, LUi_MM, ORi_MM>, ISA_MICROMIPS;
12040b57cec5SDimitry Andric
12050b57cec5SDimitry Andricdef : MipsPat<(not GPRMM16:$in),
12060b57cec5SDimitry Andric              (NOT16_MM GPRMM16:$in)>, ISA_MICROMIPS;
12070b57cec5SDimitry Andricdef : MipsPat<(not GPR32:$in),
12080b57cec5SDimitry Andric              (NOR_MM GPR32Opnd:$in, ZERO)>, ISA_MICROMIPS;
12090b57cec5SDimitry Andric
12100b57cec5SDimitry Andricdef : MipsPat<(add GPRMM16:$src, immSExtAddiur2:$imm),
12110b57cec5SDimitry Andric              (ADDIUR2_MM GPRMM16:$src, immSExtAddiur2:$imm)>, ISA_MICROMIPS;
12120b57cec5SDimitry Andricdef : MipsPat<(add GPR32:$src, immSExtAddius5:$imm),
12130b57cec5SDimitry Andric              (ADDIUS5_MM GPR32:$src, immSExtAddius5:$imm)>, ISA_MICROMIPS;
12140b57cec5SDimitry Andricdef : MipsPat<(add GPR32:$src, immSExt16:$imm),
12150b57cec5SDimitry Andric              (ADDiu_MM GPR32:$src, immSExt16:$imm)>, ISA_MICROMIPS;
12160b57cec5SDimitry Andric
12170b57cec5SDimitry Andricdef : MipsPat<(and GPRMM16:$src, immZExtAndi16:$imm),
12180b57cec5SDimitry Andric              (ANDI16_MM GPRMM16:$src, immZExtAndi16:$imm)>, ISA_MICROMIPS;
12190b57cec5SDimitry Andricdef : MipsPat<(and GPR32:$src, immZExt16:$imm),
12200b57cec5SDimitry Andric              (ANDi_MM GPR32:$src, immZExt16:$imm)>, ISA_MICROMIPS;
12210b57cec5SDimitry Andric
12220b57cec5SDimitry Andricdef : MipsPat<(shl GPRMM16:$src, immZExt2Shift:$imm),
12230b57cec5SDimitry Andric              (SLL16_MM GPRMM16:$src, immZExt2Shift:$imm)>, ISA_MICROMIPS;
12240b57cec5SDimitry Andricdef : MipsPat<(shl GPR32:$src, immZExt5:$imm),
12250b57cec5SDimitry Andric              (SLL_MM GPR32:$src, immZExt5:$imm)>, ISA_MICROMIPS;
12260b57cec5SDimitry Andricdef : MipsPat<(shl GPR32:$lhs, GPR32:$rhs),
12270b57cec5SDimitry Andric              (SLLV_MM GPR32:$lhs, GPR32:$rhs)>, ISA_MICROMIPS;
12280b57cec5SDimitry Andric
12290b57cec5SDimitry Andricdef : MipsPat<(srl GPRMM16:$src, immZExt2Shift:$imm),
12300b57cec5SDimitry Andric              (SRL16_MM GPRMM16:$src, immZExt2Shift:$imm)>, ISA_MICROMIPS;
12310b57cec5SDimitry Andricdef : MipsPat<(srl GPR32:$src, immZExt5:$imm),
12320b57cec5SDimitry Andric              (SRL_MM GPR32:$src, immZExt5:$imm)>, ISA_MICROMIPS;
12330b57cec5SDimitry Andricdef : MipsPat<(srl GPR32:$lhs, GPR32:$rhs),
12340b57cec5SDimitry Andric              (SRLV_MM GPR32:$lhs, GPR32:$rhs)>, ISA_MICROMIPS;
12350b57cec5SDimitry Andric
12360b57cec5SDimitry Andricdef : MipsPat<(sra GPR32:$src, immZExt5:$imm),
12370b57cec5SDimitry Andric              (SRA_MM GPR32:$src, immZExt5:$imm)>, ISA_MICROMIPS;
12380b57cec5SDimitry Andricdef : MipsPat<(sra GPR32:$lhs, GPR32:$rhs),
12390b57cec5SDimitry Andric              (SRAV_MM GPR32:$lhs, GPR32:$rhs)>, ISA_MICROMIPS;
12400b57cec5SDimitry Andric
12410b57cec5SDimitry Andricdef : MipsPat<(store GPRMM16:$src, addrimm4lsl2:$addr),
12420b57cec5SDimitry Andric              (SW16_MM GPRMM16:$src, addrimm4lsl2:$addr)>, ISA_MICROMIPS;
12430b57cec5SDimitry Andricdef : MipsPat<(store GPR32:$src, addr:$addr),
12440b57cec5SDimitry Andric              (SW_MM GPR32:$src, addr:$addr)>, ISA_MICROMIPS;
12450b57cec5SDimitry Andric
12460b57cec5SDimitry Andricdef : MipsPat<(load addrimm4lsl2:$addr),
12470b57cec5SDimitry Andric              (LW16_MM addrimm4lsl2:$addr)>, ISA_MICROMIPS;
12480b57cec5SDimitry Andricdef : MipsPat<(load addr:$addr),
12490b57cec5SDimitry Andric              (LW_MM addr:$addr)>, ISA_MICROMIPS;
12500b57cec5SDimitry Andricdef : MipsPat<(subc GPR32:$lhs, GPR32:$rhs),
12510b57cec5SDimitry Andric              (SUBu_MM GPR32:$lhs, GPR32:$rhs)>, ISA_MICROMIPS;
12520b57cec5SDimitry Andric
12530b57cec5SDimitry Andricdef : MipsPat<(i32 (extloadi1  addr:$src)), (LBu_MM addr:$src)>,
12540b57cec5SDimitry Andric      ISA_MICROMIPS;
12550b57cec5SDimitry Andric
12560b57cec5SDimitry Andricdef : MipsPat<(i32 (extloadi8  addr:$src)), (LBu_MM addr:$src)>,
12570b57cec5SDimitry Andric      ISA_MICROMIPS;
12580b57cec5SDimitry Andric
12590b57cec5SDimitry Andricdef : MipsPat<(i32 (extloadi16 addr:$src)), (LHu_MM addr:$src)>,
12600b57cec5SDimitry Andric      ISA_MICROMIPS;
12610b57cec5SDimitry Andric
12620b57cec5SDimitry Andriclet AddedComplexity = 40 in
12630b57cec5SDimitry Andric  def : MipsPat<(i32 (sextloadi16 addrRegImm:$a)),
12640b57cec5SDimitry Andric                (LH_MM addrRegImm:$a)>, ISA_MICROMIPS;
12650b57cec5SDimitry Andric
12660b57cec5SDimitry Andric
12670b57cec5SDimitry Andricdef : MipsPat<(bswap GPR32:$rt), (ROTR_MM (WSBH_MM GPR32:$rt), 16)>,
12680b57cec5SDimitry Andric      ISA_MICROMIPS;
12690b57cec5SDimitry Andric
12700b57cec5SDimitry Andricdef : MipsPat<(MipsJmpLink (i32 texternalsym:$dst)),
12710b57cec5SDimitry Andric              (JAL_MM texternalsym:$dst)>, ISA_MICROMIPS32_NOT_MIPS32R6;
12720b57cec5SDimitry Andricdef : MipsPat<(MipsTailCall (iPTR tglobaladdr:$dst)),
12730b57cec5SDimitry Andric              (TAILCALL_MM tglobaladdr:$dst)>, ISA_MICROMIPS32_NOT_MIPS32R6;
12740b57cec5SDimitry Andricdef : MipsPat<(MipsTailCall (iPTR texternalsym:$dst)),
12750b57cec5SDimitry Andric              (TAILCALL_MM texternalsym:$dst)>, ISA_MICROMIPS32_NOT_MIPS32R6;
12760b57cec5SDimitry Andric
12770b57cec5SDimitry Andricdefm : BrcondPats<GPR32, BEQ_MM, BEQ_MM, BNE_MM, SLT_MM, SLTu_MM, SLTi_MM,
12780b57cec5SDimitry Andric                  SLTiu_MM, ZERO>, ISA_MICROMIPS32_NOT_MIPS32R6;
12790b57cec5SDimitry Andric
12800b57cec5SDimitry Andricdef : MipsPat<(brcond (i32 (setlt i32:$lhs, 1)), bb:$dst),
12810b57cec5SDimitry Andric              (BLEZ_MM i32:$lhs, bb:$dst)>, ISA_MICROMIPS32_NOT_MIPS32R6;
12820b57cec5SDimitry Andricdef : MipsPat<(brcond (i32 (setgt i32:$lhs, -1)), bb:$dst),
12830b57cec5SDimitry Andric              (BGEZ_MM i32:$lhs, bb:$dst)>, ISA_MICROMIPS32_NOT_MIPS32R6;
12840b57cec5SDimitry Andric
12850b57cec5SDimitry Andricdefm : SeteqPats<GPR32, SLTiu_MM, XOR_MM, SLTu_MM, ZERO>, ISA_MICROMIPS;
12860b57cec5SDimitry Andricdefm : SetlePats<GPR32, XORi_MM, SLT_MM, SLTu_MM>, ISA_MICROMIPS;
12870b57cec5SDimitry Andricdefm : SetgtPats<GPR32, SLT_MM, SLTu_MM>, ISA_MICROMIPS;
12880b57cec5SDimitry Andricdefm : SetgePats<GPR32, XORi_MM, SLT_MM, SLTu_MM>, ISA_MICROMIPS;
12890b57cec5SDimitry Andricdefm : SetgeImmPats<GPR32, XORi_MM, SLTi_MM, SLTiu_MM>, ISA_MICROMIPS;
12900b57cec5SDimitry Andric
12910b57cec5SDimitry Andric// Select patterns
12920b57cec5SDimitry Andric
12930b57cec5SDimitry Andric// Instantiation of conditional move patterns.
12940b57cec5SDimitry Andricdefm : MovzPats0<GPR32, GPR32, MOVZ_I_MM, SLT_MM, SLTu_MM, SLTi_MM, SLTiu_MM>,
12950b57cec5SDimitry Andric       ISA_MICROMIPS32_NOT_MIPS32R6;
12960b57cec5SDimitry Andricdefm : MovzPats1<GPR32, GPR32, MOVZ_I_MM, XOR_MM>,
12970b57cec5SDimitry Andric       ISA_MICROMIPS32_NOT_MIPS32R6;
12980b57cec5SDimitry Andricdefm : MovzPats2<GPR32, GPR32, MOVZ_I_MM, XORi_MM>,
12990b57cec5SDimitry Andric       ISA_MICROMIPS32_NOT_MIPS32R6;
13000b57cec5SDimitry Andric
13010b57cec5SDimitry Andric
13020b57cec5SDimitry Andricdefm : MovnPats<GPR32, GPR32, MOVN_I_MM, XOR_MM>, INSN_MIPS4_32_NOT_32R6_64R6;
13030b57cec5SDimitry Andric
13040b57cec5SDimitry Andric// Instantiation of conditional move patterns.
13050b57cec5SDimitry Andricdefm : MovzPats0<GPR32, GPR32, MOVZ_I_MM, SLT_MM, SLTu_MM, SLTi_MM, SLTiu_MM>,
13060b57cec5SDimitry Andric       ISA_MICROMIPS32_NOT_MIPS32R6;
13070b57cec5SDimitry Andricdefm : MovzPats1<GPR32, GPR32, MOVZ_I_MM, XOR_MM>,
13080b57cec5SDimitry Andric       ISA_MICROMIPS32_NOT_MIPS32R6;
13090b57cec5SDimitry Andricdefm : MovzPats2<GPR32, GPR32, MOVZ_I_MM, XORi_MM>,
13100b57cec5SDimitry Andric       ISA_MICROMIPS32_NOT_MIPS32R6;
13110b57cec5SDimitry Andric
13120b57cec5SDimitry Andricdefm : MovnPats<GPR32, GPR32, MOVN_I_MM, XOR_MM>, ISA_MICROMIPS32_NOT_MIPS32R6;
13130b57cec5SDimitry Andric
13140b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
13150b57cec5SDimitry Andric// MicroMips instruction aliases
13160b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
13170b57cec5SDimitry Andric
13180b57cec5SDimitry Andricclass UncondBranchMMPseudo<string opstr> :
13190b57cec5SDimitry Andric  MipsAsmPseudoInst<(outs), (ins brtarget_mm:$offset),
13200b57cec5SDimitry Andric                    !strconcat(opstr, "\t$offset")>;
13210b57cec5SDimitry Andric
13220b57cec5SDimitry Andricdef B_MM_Pseudo : UncondBranchMMPseudo<"b">, ISA_MICROMIPS;
13230b57cec5SDimitry Andric
13240b57cec5SDimitry Andriclet EncodingPredicates = [InMicroMips] in {
13250b57cec5SDimitry Andric  def SDIV_MM_Pseudo : MultDivPseudo<SDIV_MM, ACC64, GPR32Opnd, MipsDivRem,
13260b57cec5SDimitry Andric                                     II_DIV, 0, 1, 1>, ISA_MIPS1_NOT_32R6_64R6;
13270b57cec5SDimitry Andric  def UDIV_MM_Pseudo : MultDivPseudo<UDIV_MM, ACC64, GPR32Opnd, MipsDivRemU,
13280b57cec5SDimitry Andric                                     II_DIVU, 0, 1, 1>, ISA_MIPS1_NOT_32R6_64R6;
13290b57cec5SDimitry Andric
13300b57cec5SDimitry Andric  def : MipsInstAlias<"wait", (WAIT_MM 0x0), 1>, ISA_MICROMIPS;
13310b57cec5SDimitry Andric  def : MipsInstAlias<"nop", (SLL_MM ZERO, ZERO, 0), 1>, ISA_MICROMIPS;
13320b57cec5SDimitry Andric  def : MipsInstAlias<"nop", (MOVE16_MM ZERO, ZERO), 1>, ISA_MICROMIPS;
13330b57cec5SDimitry Andric  def : MipsInstAlias<"ei", (EI_MM ZERO), 1>, ISA_MICROMIPS;
13340b57cec5SDimitry Andric  def : MipsInstAlias<"di", (DI_MM ZERO), 1>, ISA_MICROMIPS;
13350b57cec5SDimitry Andric  def : MipsInstAlias<"neg $rt, $rs",
13360b57cec5SDimitry Andric                      (SUB_MM GPR32Opnd:$rt, ZERO, GPR32Opnd:$rs), 1>,
13370b57cec5SDimitry Andric        ISA_MICROMIPS32_NOT_MIPS32R6;
13380b57cec5SDimitry Andric  def : MipsInstAlias<"neg $rt",
13390b57cec5SDimitry Andric                      (SUB_MM GPR32Opnd:$rt, ZERO, GPR32Opnd:$rt), 1>,
13400b57cec5SDimitry Andric        ISA_MICROMIPS32_NOT_MIPS32R6;
13410b57cec5SDimitry Andric  def : MipsInstAlias<"negu $rt, $rs",
13420b57cec5SDimitry Andric                      (SUBu_MM GPR32Opnd:$rt, ZERO, GPR32Opnd:$rs), 1>,
13430b57cec5SDimitry Andric        ISA_MICROMIPS32_NOT_MIPS32R6;
13440b57cec5SDimitry Andric  def : MipsInstAlias<"negu $rt",
13450b57cec5SDimitry Andric                      (SUBu_MM GPR32Opnd:$rt, ZERO, GPR32Opnd:$rt), 1>,
13460b57cec5SDimitry Andric        ISA_MICROMIPS32_NOT_MIPS32R6;
13470b57cec5SDimitry Andric  def : MipsInstAlias<"teq $rs, $rt",
13480b57cec5SDimitry Andric                      (TEQ_MM GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>;
13490b57cec5SDimitry Andric  def : MipsInstAlias<"tge $rs, $rt",
13500b57cec5SDimitry Andric                      (TGE_MM GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>;
13510b57cec5SDimitry Andric  def : MipsInstAlias<"tgeu $rs, $rt",
13520b57cec5SDimitry Andric                      (TGEU_MM GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>;
13530b57cec5SDimitry Andric  def : MipsInstAlias<"tlt $rs, $rt",
13540b57cec5SDimitry Andric                      (TLT_MM GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>;
13550b57cec5SDimitry Andric  def : MipsInstAlias<"tltu $rs, $rt",
13560b57cec5SDimitry Andric                      (TLTU_MM GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>;
13570b57cec5SDimitry Andric  def : MipsInstAlias<"tne $rs, $rt",
13580b57cec5SDimitry Andric                      (TNE_MM GPR32Opnd:$rs, GPR32Opnd:$rt, 0), 1>;
13590b57cec5SDimitry Andric  def : MipsInstAlias<
13600b57cec5SDimitry Andric          "sgt $rd, $rs, $rt",
13610b57cec5SDimitry Andric          (SLT_MM GPR32Opnd:$rd, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>;
13620b57cec5SDimitry Andric  def : MipsInstAlias<
13630b57cec5SDimitry Andric          "sgt $rs, $rt",
13640b57cec5SDimitry Andric          (SLT_MM GPR32Opnd:$rs, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>;
13650b57cec5SDimitry Andric  def : MipsInstAlias<
13660b57cec5SDimitry Andric          "sgtu $rd, $rs, $rt",
13670b57cec5SDimitry Andric          (SLTu_MM GPR32Opnd:$rd, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>;
13680b57cec5SDimitry Andric  def : MipsInstAlias<
13690b57cec5SDimitry Andric          "sgtu $rs, $rt",
13700b57cec5SDimitry Andric          (SLTu_MM GPR32Opnd:$rs, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>;
13710b57cec5SDimitry Andric  def : MipsInstAlias<"sll $rd, $rt, $rs",
13720b57cec5SDimitry Andric                      (SLLV_MM GPR32Opnd:$rd, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>;
13730b57cec5SDimitry Andric  def : MipsInstAlias<"sra $rd, $rt, $rs",
13740b57cec5SDimitry Andric                      (SRAV_MM GPR32Opnd:$rd, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>;
13750b57cec5SDimitry Andric  def : MipsInstAlias<"srl $rd, $rt, $rs",
13760b57cec5SDimitry Andric                      (SRLV_MM GPR32Opnd:$rd, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>;
13770b57cec5SDimitry Andric  def : MipsInstAlias<"sll $rd, $rt",
13780b57cec5SDimitry Andric                      (SLLV_MM GPR32Opnd:$rd, GPR32Opnd:$rd, GPR32Opnd:$rt), 0>;
13790b57cec5SDimitry Andric  def : MipsInstAlias<"sra $rd, $rt",
13800b57cec5SDimitry Andric                      (SRAV_MM GPR32Opnd:$rd, GPR32Opnd:$rd, GPR32Opnd:$rt), 0>;
13810b57cec5SDimitry Andric  def : MipsInstAlias<"srl $rd, $rt",
13820b57cec5SDimitry Andric                      (SRLV_MM GPR32Opnd:$rd, GPR32Opnd:$rd, GPR32Opnd:$rt), 0>;
13830b57cec5SDimitry Andric  def : MipsInstAlias<"sll $rd, $shamt",
13840b57cec5SDimitry Andric                      (SLL_MM GPR32Opnd:$rd, GPR32Opnd:$rd, uimm5:$shamt), 0>;
13850b57cec5SDimitry Andric  def : MipsInstAlias<"sra $rd, $shamt",
13860b57cec5SDimitry Andric                      (SRA_MM GPR32Opnd:$rd, GPR32Opnd:$rd, uimm5:$shamt), 0>;
13870b57cec5SDimitry Andric  def : MipsInstAlias<"srl $rd, $shamt",
13880b57cec5SDimitry Andric                      (SRL_MM GPR32Opnd:$rd, GPR32Opnd:$rd, uimm5:$shamt), 0>;
13890b57cec5SDimitry Andric  def : MipsInstAlias<"rotr $rt, $imm",
13900b57cec5SDimitry Andric                      (ROTR_MM GPR32Opnd:$rt, GPR32Opnd:$rt, uimm5:$imm), 0>;
13910b57cec5SDimitry Andric  def : MipsInstAlias<"syscall", (SYSCALL_MM 0), 1>, ISA_MICROMIPS;
13920b57cec5SDimitry Andric
13930b57cec5SDimitry Andric  def : MipsInstAlias<"sync", (SYNC_MM 0), 1>, ISA_MICROMIPS;
13940b57cec5SDimitry Andric
13950b57cec5SDimitry Andric  defm : OneOrTwoOperandMacroImmediateAlias<"add", ADDi_MM>, ISA_MICROMIPS;
13960b57cec5SDimitry Andric
13970b57cec5SDimitry Andric  defm : OneOrTwoOperandMacroImmediateAlias<"addu", ADDiu_MM>, ISA_MICROMIPS;
13980b57cec5SDimitry Andric
13990b57cec5SDimitry Andric  defm : OneOrTwoOperandMacroImmediateAlias<"and", ANDi_MM>, ISA_MICROMIPS;
14000b57cec5SDimitry Andric
14010b57cec5SDimitry Andric  defm : OneOrTwoOperandMacroImmediateAlias<"or", ORi_MM>, ISA_MICROMIPS;
14020b57cec5SDimitry Andric
14030b57cec5SDimitry Andric  defm : OneOrTwoOperandMacroImmediateAlias<"xor", XORi_MM>, ISA_MICROMIPS;
14040b57cec5SDimitry Andric
14050b57cec5SDimitry Andric  defm : OneOrTwoOperandMacroImmediateAlias<"slt", SLTi_MM>, ISA_MICROMIPS;
14060b57cec5SDimitry Andric
14070b57cec5SDimitry Andric  defm : OneOrTwoOperandMacroImmediateAlias<"sltu", SLTiu_MM>, ISA_MICROMIPS;
14080b57cec5SDimitry Andric
14090b57cec5SDimitry Andric  def : MipsInstAlias<"not $rt, $rs",
14100b57cec5SDimitry Andric                      (NOR_MM GPR32Opnd:$rt, GPR32Opnd:$rs, ZERO), 0>,
14110b57cec5SDimitry Andric        ISA_MICROMIPS32_NOT_MIPS32R6;
14120b57cec5SDimitry Andric  def : MipsInstAlias<"not $rt",
14130b57cec5SDimitry Andric                      (NOR_MM GPR32Opnd:$rt, GPR32Opnd:$rt, ZERO), 0>,
14140b57cec5SDimitry Andric        ISA_MICROMIPS32_NOT_MIPS32R6;
14150b57cec5SDimitry Andric  def : MipsInstAlias<"bnez $rs,$offset",
14160b57cec5SDimitry Andric                      (BNE_MM GPR32Opnd:$rs, ZERO, brtarget:$offset), 0>,
14170b57cec5SDimitry Andric        ISA_MICROMIPS;
14180b57cec5SDimitry Andric  def : MipsInstAlias<"beqz $rs,$offset",
14190b57cec5SDimitry Andric                      (BEQ_MM GPR32Opnd:$rs, ZERO, brtarget:$offset), 0>,
14200b57cec5SDimitry Andric        ISA_MICROMIPS;
14210b57cec5SDimitry Andric  def : MipsInstAlias<"seh $rd", (SEH_MM GPR32Opnd:$rd, GPR32Opnd:$rd), 0>,
14220b57cec5SDimitry Andric                     ISA_MICROMIPS;
14230b57cec5SDimitry Andric  def : MipsInstAlias<"seb $rd", (SEB_MM GPR32Opnd:$rd, GPR32Opnd:$rd), 0>,
14240b57cec5SDimitry Andric                     ISA_MICROMIPS;
14250b57cec5SDimitry Andric  def : MipsInstAlias<"break", (BREAK_MM 0, 0), 1>, ISA_MICROMIPS;
14260b57cec5SDimitry Andric  def : MipsInstAlias<"break $imm", (BREAK_MM uimm10:$imm, 0), 1>,
14270b57cec5SDimitry Andric        ISA_MICROMIPS;
14280b57cec5SDimitry Andric  def : MipsInstAlias<"bal $offset", (BGEZAL_MM ZERO, brtarget_mm:$offset), 1>,
14290b57cec5SDimitry Andric        ISA_MICROMIPS32_NOT_MIPS32R6;
14300b57cec5SDimitry Andric
14310b57cec5SDimitry Andric  def : MipsInstAlias<"j $rs", (JR_MM GPR32Opnd:$rs), 0>,
14320b57cec5SDimitry Andric        ISA_MICROMIPS32_NOT_MIPS32R6;
14330b57cec5SDimitry Andric}
14340b57cec5SDimitry Andricdef : MipsInstAlias<"rdhwr $rt, $rs",
14350b57cec5SDimitry Andric                    (RDHWR_MM GPR32Opnd:$rt, HWRegsOpnd:$rs, 0), 1>,
14360b57cec5SDimitry Andric      ISA_MICROMIPS32_NOT_MIPS32R6;
14370b57cec5SDimitry Andric
14380b57cec5SDimitry Andricdef : MipsInstAlias<"hypcall", (HYPCALL_MM 0), 1>,
14390b57cec5SDimitry Andric                    ISA_MICROMIPS32R5, ASE_VIRT;
14400b57cec5SDimitry Andricdef : MipsInstAlias<"mfgc0 $rt, $rs",
14410b57cec5SDimitry Andric                    (MFGC0_MM GPR32Opnd:$rt, COP0Opnd:$rs, 0), 0>,
14420b57cec5SDimitry Andric                    ISA_MICROMIPS32R5, ASE_VIRT;
14430b57cec5SDimitry Andricdef : MipsInstAlias<"mfhgc0 $rt, $rs",
14440b57cec5SDimitry Andric                    (MFHGC0_MM GPR32Opnd:$rt, COP0Opnd:$rs, 0), 0>,
14450b57cec5SDimitry Andric                    ISA_MICROMIPS32R5, ASE_VIRT;
14460b57cec5SDimitry Andricdef : MipsInstAlias<"mtgc0 $rt, $rs",
14470b57cec5SDimitry Andric                    (MTGC0_MM COP0Opnd:$rs, GPR32Opnd:$rt, 0), 0>,
14480b57cec5SDimitry Andric                    ISA_MICROMIPS32R5, ASE_VIRT;
14490b57cec5SDimitry Andricdef : MipsInstAlias<"mthgc0 $rt, $rs",
14500b57cec5SDimitry Andric                    (MTHGC0_MM COP0Opnd:$rs, GPR32Opnd:$rt, 0), 0>,
14510b57cec5SDimitry Andric                    ISA_MICROMIPS32R5, ASE_VIRT;
14520b57cec5SDimitry Andricdef : MipsInstAlias<"sw $rt, $offset",
14530b57cec5SDimitry Andric                    (SWSP_MM GPR32Opnd:$rt, mem_mm_sp_imm5_lsl2:$offset), 1>,
14540b57cec5SDimitry Andric                    ISA_MICROMIPS;
1455