1263508Sdimdef addrimm12 : ComplexPattern<iPTR, 2, "selectIntAddrMM", [frameindex]>; 2263508Sdim 3263508Sdimdef simm12 : Operand<i32> { 4263508Sdim let DecoderMethod = "DecodeSimm12"; 5263508Sdim} 6263508Sdim 7263508Sdimdef mem_mm_12 : Operand<i32> { 8263508Sdim let PrintMethod = "printMemOperand"; 9263508Sdim let MIOperandInfo = (ops GPR32, simm12); 10263508Sdim let EncoderMethod = "getMemEncodingMMImm12"; 11263508Sdim let ParserMatchClass = MipsMemAsmOperand; 12263508Sdim let OperandType = "OPERAND_MEMORY"; 13263508Sdim} 14263508Sdim 15263508Sdimdef jmptarget_mm : Operand<OtherVT> { 16263508Sdim let EncoderMethod = "getJumpTargetOpValueMM"; 17263508Sdim} 18263508Sdim 19263508Sdimdef calltarget_mm : Operand<iPTR> { 20263508Sdim let EncoderMethod = "getJumpTargetOpValueMM"; 21263508Sdim} 22263508Sdim 23263508Sdimdef brtarget_mm : Operand<OtherVT> { 24263508Sdim let EncoderMethod = "getBranchTargetOpValueMM"; 25263508Sdim let OperandType = "OPERAND_PCREL"; 26263508Sdim let DecoderMethod = "DecodeBranchTargetMM"; 27263508Sdim} 28263508Sdim 29263508Sdimlet canFoldAsLoad = 1 in 30263508Sdimclass LoadLeftRightMM<string opstr, SDNode OpNode, RegisterOperand RO, 31263508Sdim Operand MemOpnd> : 32263508Sdim InstSE<(outs RO:$rt), (ins MemOpnd:$addr, RO:$src), 33263508Sdim !strconcat(opstr, "\t$rt, $addr"), 34263508Sdim [(set RO:$rt, (OpNode addrimm12:$addr, RO:$src))], 35263508Sdim NoItinerary, FrmI> { 36263508Sdim let DecoderMethod = "DecodeMemMMImm12"; 37263508Sdim string Constraints = "$src = $rt"; 38263508Sdim} 39263508Sdim 40263508Sdimclass StoreLeftRightMM<string opstr, SDNode OpNode, RegisterOperand RO, 41263508Sdim Operand MemOpnd>: 42263508Sdim InstSE<(outs), (ins RO:$rt, MemOpnd:$addr), 43263508Sdim !strconcat(opstr, "\t$rt, $addr"), 44263508Sdim [(OpNode RO:$rt, addrimm12:$addr)], NoItinerary, FrmI> { 45263508Sdim let DecoderMethod = "DecodeMemMMImm12"; 46263508Sdim} 47263508Sdim 48263508Sdimlet DecoderNamespace = "MicroMips", Predicates = [InMicroMips] in { 49251607Sdim /// Arithmetic Instructions (ALU Immediate) 50263508Sdim def ADDiu_MM : MMRel, ArithLogicI<"addiu", simm16, GPR32Opnd>, 51251607Sdim ADDI_FM_MM<0xc>; 52263508Sdim def ADDi_MM : MMRel, ArithLogicI<"addi", simm16, GPR32Opnd>, 53251607Sdim ADDI_FM_MM<0x4>; 54263508Sdim def SLTi_MM : MMRel, SetCC_I<"slti", setlt, simm16, immSExt16, GPR32Opnd>, 55251607Sdim SLTI_FM_MM<0x24>; 56263508Sdim def SLTiu_MM : MMRel, SetCC_I<"sltiu", setult, simm16, immSExt16, GPR32Opnd>, 57251607Sdim SLTI_FM_MM<0x2c>; 58263508Sdim def ANDi_MM : MMRel, ArithLogicI<"andi", uimm16, GPR32Opnd>, 59251607Sdim ADDI_FM_MM<0x34>; 60263508Sdim def ORi_MM : MMRel, ArithLogicI<"ori", uimm16, GPR32Opnd>, 61251607Sdim ADDI_FM_MM<0x14>; 62263508Sdim def XORi_MM : MMRel, ArithLogicI<"xori", uimm16, GPR32Opnd>, 63251607Sdim ADDI_FM_MM<0x1c>; 64263508Sdim def LUi_MM : MMRel, LoadUpper<"lui", GPR32Opnd, uimm16>, LUI_FM_MM; 65251607Sdim 66251607Sdim /// Arithmetic Instructions (3-Operand, R-Type) 67263508Sdim def ADDu_MM : MMRel, ArithLogicR<"addu", GPR32Opnd>, ADD_FM_MM<0, 0x150>; 68263508Sdim def SUBu_MM : MMRel, ArithLogicR<"subu", GPR32Opnd>, ADD_FM_MM<0, 0x1d0>; 69263508Sdim def MUL_MM : MMRel, ArithLogicR<"mul", GPR32Opnd>, ADD_FM_MM<0, 0x210>; 70263508Sdim def ADD_MM : MMRel, ArithLogicR<"add", GPR32Opnd>, ADD_FM_MM<0, 0x110>; 71263508Sdim def SUB_MM : MMRel, ArithLogicR<"sub", GPR32Opnd>, ADD_FM_MM<0, 0x190>; 72263508Sdim def SLT_MM : MMRel, SetCC_R<"slt", setlt, GPR32Opnd>, ADD_FM_MM<0, 0x350>; 73263508Sdim def SLTu_MM : MMRel, SetCC_R<"sltu", setult, GPR32Opnd>, 74251607Sdim ADD_FM_MM<0, 0x390>; 75263508Sdim def AND_MM : MMRel, ArithLogicR<"and", GPR32Opnd, 1, IIAlu, and>, 76251607Sdim ADD_FM_MM<0, 0x250>; 77263508Sdim def OR_MM : MMRel, ArithLogicR<"or", GPR32Opnd, 1, IIAlu, or>, 78251607Sdim ADD_FM_MM<0, 0x290>; 79263508Sdim def XOR_MM : MMRel, ArithLogicR<"xor", GPR32Opnd, 1, IIAlu, xor>, 80251607Sdim ADD_FM_MM<0, 0x310>; 81263508Sdim def NOR_MM : MMRel, LogicNOR<"nor", GPR32Opnd>, ADD_FM_MM<0, 0x2d0>; 82263508Sdim def MULT_MM : MMRel, Mult<"mult", IIImul, GPR32Opnd, [HI0, LO0]>, 83251607Sdim MULT_FM_MM<0x22c>; 84263508Sdim def MULTu_MM : MMRel, Mult<"multu", IIImul, GPR32Opnd, [HI0, LO0]>, 85251607Sdim MULT_FM_MM<0x26c>; 86263508Sdim def SDIV_MM : MMRel, Div<"div", IIIdiv, GPR32Opnd, [HI0, LO0]>, 87263508Sdim MULT_FM_MM<0x2ac>; 88263508Sdim def UDIV_MM : MMRel, Div<"divu", IIIdiv, GPR32Opnd, [HI0, LO0]>, 89263508Sdim MULT_FM_MM<0x2ec>; 90251607Sdim 91251607Sdim /// Shift Instructions 92263508Sdim def SLL_MM : MMRel, shift_rotate_imm<"sll", uimm5, GPR32Opnd>, 93251607Sdim SRA_FM_MM<0, 0>; 94263508Sdim def SRL_MM : MMRel, shift_rotate_imm<"srl", uimm5, GPR32Opnd>, 95251607Sdim SRA_FM_MM<0x40, 0>; 96263508Sdim def SRA_MM : MMRel, shift_rotate_imm<"sra", uimm5, GPR32Opnd>, 97251607Sdim SRA_FM_MM<0x80, 0>; 98263508Sdim def SLLV_MM : MMRel, shift_rotate_reg<"sllv", GPR32Opnd>, 99251607Sdim SRLV_FM_MM<0x10, 0>; 100263508Sdim def SRLV_MM : MMRel, shift_rotate_reg<"srlv", GPR32Opnd>, 101251607Sdim SRLV_FM_MM<0x50, 0>; 102263508Sdim def SRAV_MM : MMRel, shift_rotate_reg<"srav", GPR32Opnd>, 103251607Sdim SRLV_FM_MM<0x90, 0>; 104263508Sdim def ROTR_MM : MMRel, shift_rotate_imm<"rotr", uimm5, GPR32Opnd>, 105251607Sdim SRA_FM_MM<0xc0, 0>; 106263508Sdim def ROTRV_MM : MMRel, shift_rotate_reg<"rotrv", GPR32Opnd>, 107251607Sdim SRLV_FM_MM<0xd0, 0>; 108251607Sdim 109251607Sdim /// Load and Store Instructions - aligned 110263508Sdim let DecoderMethod = "DecodeMemMMImm16" in { 111263508Sdim def LB_MM : Load<"lb", GPR32Opnd>, MMRel, LW_FM_MM<0x7>; 112263508Sdim def LBu_MM : Load<"lbu", GPR32Opnd>, MMRel, LW_FM_MM<0x5>; 113263508Sdim def LH_MM : Load<"lh", GPR32Opnd>, MMRel, LW_FM_MM<0xf>; 114263508Sdim def LHu_MM : Load<"lhu", GPR32Opnd>, MMRel, LW_FM_MM<0xd>; 115263508Sdim def LW_MM : Load<"lw", GPR32Opnd>, MMRel, LW_FM_MM<0x3f>; 116263508Sdim def SB_MM : Store<"sb", GPR32Opnd>, MMRel, LW_FM_MM<0x6>; 117263508Sdim def SH_MM : Store<"sh", GPR32Opnd>, MMRel, LW_FM_MM<0xe>; 118263508Sdim def SW_MM : Store<"sw", GPR32Opnd>, MMRel, LW_FM_MM<0x3e>; 119263508Sdim } 120263508Sdim 121263508Sdim /// Load and Store Instructions - unaligned 122263508Sdim def LWL_MM : LoadLeftRightMM<"lwl", MipsLWL, GPR32Opnd, mem_mm_12>, 123263508Sdim LWL_FM_MM<0x0>; 124263508Sdim def LWR_MM : LoadLeftRightMM<"lwr", MipsLWR, GPR32Opnd, mem_mm_12>, 125263508Sdim LWL_FM_MM<0x1>; 126263508Sdim def SWL_MM : StoreLeftRightMM<"swl", MipsSWL, GPR32Opnd, mem_mm_12>, 127263508Sdim LWL_FM_MM<0x8>; 128263508Sdim def SWR_MM : StoreLeftRightMM<"swr", MipsSWR, GPR32Opnd, mem_mm_12>, 129263508Sdim LWL_FM_MM<0x9>; 130263508Sdim 131263508Sdim /// Move Conditional 132263508Sdim def MOVZ_I_MM : MMRel, CMov_I_I_FT<"movz", GPR32Opnd, GPR32Opnd, 133263508Sdim NoItinerary>, ADD_FM_MM<0, 0x58>; 134263508Sdim def MOVN_I_MM : MMRel, CMov_I_I_FT<"movn", GPR32Opnd, GPR32Opnd, 135263508Sdim NoItinerary>, ADD_FM_MM<0, 0x18>; 136263508Sdim def MOVT_I_MM : MMRel, CMov_F_I_FT<"movt", GPR32Opnd, IIAlu>, 137263508Sdim CMov_F_I_FM_MM<0x25>; 138263508Sdim def MOVF_I_MM : MMRel, CMov_F_I_FT<"movf", GPR32Opnd, IIAlu>, 139263508Sdim CMov_F_I_FM_MM<0x5>; 140263508Sdim 141263508Sdim /// Move to/from HI/LO 142263508Sdim def MTHI_MM : MMRel, MoveToLOHI<"mthi", GPR32Opnd, [HI0]>, 143263508Sdim MTLO_FM_MM<0x0b5>; 144263508Sdim def MTLO_MM : MMRel, MoveToLOHI<"mtlo", GPR32Opnd, [LO0]>, 145263508Sdim MTLO_FM_MM<0x0f5>; 146263508Sdim def MFHI_MM : MMRel, MoveFromLOHI<"mfhi", GPR32Opnd, AC0>, 147263508Sdim MFLO_FM_MM<0x035>; 148263508Sdim def MFLO_MM : MMRel, MoveFromLOHI<"mflo", GPR32Opnd, AC0>, 149263508Sdim MFLO_FM_MM<0x075>; 150263508Sdim 151263508Sdim /// Multiply Add/Sub Instructions 152263508Sdim def MADD_MM : MMRel, MArithR<"madd", 1>, MULT_FM_MM<0x32c>; 153263508Sdim def MADDU_MM : MMRel, MArithR<"maddu", 1>, MULT_FM_MM<0x36c>; 154263508Sdim def MSUB_MM : MMRel, MArithR<"msub">, MULT_FM_MM<0x3ac>; 155263508Sdim def MSUBU_MM : MMRel, MArithR<"msubu">, MULT_FM_MM<0x3ec>; 156263508Sdim 157263508Sdim /// Count Leading 158263508Sdim def CLZ_MM : MMRel, CountLeading0<"clz", GPR32Opnd>, CLO_FM_MM<0x16c>; 159263508Sdim def CLO_MM : MMRel, CountLeading1<"clo", GPR32Opnd>, CLO_FM_MM<0x12c>; 160263508Sdim 161263508Sdim /// Sign Ext In Register Instructions. 162263508Sdim def SEB_MM : MMRel, SignExtInReg<"seb", i8, GPR32Opnd>, SEB_FM_MM<0x0ac>; 163263508Sdim def SEH_MM : MMRel, SignExtInReg<"seh", i16, GPR32Opnd>, SEB_FM_MM<0x0ec>; 164263508Sdim 165263508Sdim /// Word Swap Bytes Within Halfwords 166263508Sdim def WSBH_MM : MMRel, SubwordSwap<"wsbh", GPR32Opnd>, SEB_FM_MM<0x1ec>; 167263508Sdim 168263508Sdim def EXT_MM : MMRel, ExtBase<"ext", GPR32Opnd, uimm5, MipsExt>, 169263508Sdim EXT_FM_MM<0x2c>; 170263508Sdim def INS_MM : MMRel, InsBase<"ins", GPR32Opnd, uimm5, MipsIns>, 171263508Sdim EXT_FM_MM<0x0c>; 172263508Sdim 173263508Sdim /// Jump Instructions 174263508Sdim let DecoderMethod = "DecodeJumpTargetMM" in { 175263508Sdim def J_MM : MMRel, JumpFJ<jmptarget_mm, "j", br, bb, "j">, 176263508Sdim J_FM_MM<0x35>; 177263508Sdim def JAL_MM : MMRel, JumpLink<"jal", calltarget_mm>, J_FM_MM<0x3d>; 178263508Sdim def TAILCALL_MM : MMRel, JumpFJ<calltarget_mm, "j", MipsTailCall, imm, 179263508Sdim "tcall">, J_FM_MM<0x3d>, IsTailCall; 180263508Sdim } 181263508Sdim def JR_MM : MMRel, IndirectBranch<"jr", GPR32Opnd>, JR_FM_MM<0x3c>; 182263508Sdim def JALR_MM : MMRel, JumpLinkReg<"jalr", GPR32Opnd>, JALR_FM_MM<0x03c>; 183263508Sdim def TAILCALL_R_MM : MMRel, JumpFR<"tcallr", GPR32Opnd, MipsTailCall>, 184263508Sdim JR_FM_MM<0x3c>, IsTailCall; 185263508Sdim def RET_MM : MMRel, RetBase<"ret", GPR32Opnd>, JR_FM_MM<0x3c>; 186263508Sdim 187263508Sdim /// Branch Instructions 188263508Sdim def BEQ_MM : MMRel, CBranch<"beq", brtarget_mm, seteq, GPR32Opnd>, 189263508Sdim BEQ_FM_MM<0x25>; 190263508Sdim def BNE_MM : MMRel, CBranch<"bne", brtarget_mm, setne, GPR32Opnd>, 191263508Sdim BEQ_FM_MM<0x2d>; 192263508Sdim def BGEZ_MM : MMRel, CBranchZero<"bgez", brtarget_mm, setge, GPR32Opnd>, 193263508Sdim BGEZ_FM_MM<0x2>; 194263508Sdim def BGTZ_MM : MMRel, CBranchZero<"bgtz", brtarget_mm, setgt, GPR32Opnd>, 195263508Sdim BGEZ_FM_MM<0x6>; 196263508Sdim def BLEZ_MM : MMRel, CBranchZero<"blez", brtarget_mm, setle, GPR32Opnd>, 197263508Sdim BGEZ_FM_MM<0x4>; 198263508Sdim def BLTZ_MM : MMRel, CBranchZero<"bltz", brtarget_mm, setlt, GPR32Opnd>, 199263508Sdim BGEZ_FM_MM<0x0>; 200263508Sdim def BGEZAL_MM : MMRel, BGEZAL_FT<"bgezal", brtarget_mm, GPR32Opnd>, 201263508Sdim BGEZAL_FM_MM<0x03>; 202263508Sdim def BLTZAL_MM : MMRel, BGEZAL_FT<"bltzal", brtarget_mm, GPR32Opnd>, 203263508Sdim BGEZAL_FM_MM<0x01>; 204263508Sdim 205263508Sdim /// Trap Instructions 206263508Sdim def TEQ_MM : MMRel, TEQ_FT<"teq", GPR32Opnd>, TEQ_FM_MM<0x0>; 207263508Sdim def TGE_MM : MMRel, TEQ_FT<"tge", GPR32Opnd>, TEQ_FM_MM<0x08>; 208263508Sdim def TGEU_MM : MMRel, TEQ_FT<"tgeu", GPR32Opnd>, TEQ_FM_MM<0x10>; 209263508Sdim def TLT_MM : MMRel, TEQ_FT<"tlt", GPR32Opnd>, TEQ_FM_MM<0x20>; 210263508Sdim def TLTU_MM : MMRel, TEQ_FT<"tltu", GPR32Opnd>, TEQ_FM_MM<0x28>; 211263508Sdim def TNE_MM : MMRel, TEQ_FT<"tne", GPR32Opnd>, TEQ_FM_MM<0x30>; 212263508Sdim 213263508Sdim def TEQI_MM : MMRel, TEQI_FT<"teqi", GPR32Opnd>, TEQI_FM_MM<0x0e>; 214263508Sdim def TGEI_MM : MMRel, TEQI_FT<"tgei", GPR32Opnd>, TEQI_FM_MM<0x09>; 215263508Sdim def TGEIU_MM : MMRel, TEQI_FT<"tgeiu", GPR32Opnd>, TEQI_FM_MM<0x0b>; 216263508Sdim def TLTI_MM : MMRel, TEQI_FT<"tlti", GPR32Opnd>, TEQI_FM_MM<0x08>; 217263508Sdim def TLTIU_MM : MMRel, TEQI_FT<"tltiu", GPR32Opnd>, TEQI_FM_MM<0x0a>; 218263508Sdim def TNEI_MM : MMRel, TEQI_FT<"tnei", GPR32Opnd>, TEQI_FM_MM<0x0c>; 219251607Sdim} 220