blob: b0dc2e86218559f6ecf4dd7480e397fea924a3a6 [file] [log] [blame]
Jack Carter97700972013-08-13 20:19:16 +00001def addrimm12 : ComplexPattern<iPTR, 2, "selectIntAddrMM", [frameindex]>;
2
3def simm12 : Operand<i32> {
4 let DecoderMethod = "DecodeSimm12";
5}
6
7def mem_mm_12 : Operand<i32> {
8 let PrintMethod = "printMemOperand";
9 let MIOperandInfo = (ops GPR32, simm12);
10 let EncoderMethod = "getMemEncodingMMImm12";
11 let ParserMatchClass = MipsMemAsmOperand;
12 let OperandType = "OPERAND_MEMORY";
13}
14
15let canFoldAsLoad = 1 in
16class LoadLeftRightMM<string opstr, SDNode OpNode, RegisterOperand RO,
17 Operand MemOpnd> :
18 InstSE<(outs RO:$rt), (ins MemOpnd:$addr, RO:$src),
19 !strconcat(opstr, "\t$rt, $addr"),
20 [(set RO:$rt, (OpNode addrimm12:$addr, RO:$src))],
21 NoItinerary, FrmI> {
Vladimir Medicdde3d582013-09-06 12:30:36 +000022 let DecoderMethod = "DecodeMemMMImm12";
Jack Carter97700972013-08-13 20:19:16 +000023 string Constraints = "$src = $rt";
24}
25
26class StoreLeftRightMM<string opstr, SDNode OpNode, RegisterOperand RO,
27 Operand MemOpnd>:
28 InstSE<(outs), (ins RO:$rt, MemOpnd:$addr),
29 !strconcat(opstr, "\t$rt, $addr"),
Vladimir Medicdde3d582013-09-06 12:30:36 +000030 [(OpNode RO:$rt, addrimm12:$addr)], NoItinerary, FrmI> {
31 let DecoderMethod = "DecodeMemMMImm12";
32}
Jack Carter97700972013-08-13 20:19:16 +000033
Akira Hatanakaa43b56d2013-08-20 20:46:51 +000034let DecoderNamespace = "MicroMips", Predicates = [InMicroMips] in {
Akira Hatanakabe6a8182013-04-19 19:03:11 +000035 /// Arithmetic Instructions (ALU Immediate)
Akira Hatanaka13e6ccf2013-08-06 23:08:38 +000036 def ADDiu_MM : MMRel, ArithLogicI<"addiu", simm16, GPR32Opnd>,
Akira Hatanakabe6a8182013-04-19 19:03:11 +000037 ADDI_FM_MM<0xc>;
Akira Hatanaka13e6ccf2013-08-06 23:08:38 +000038 def ADDi_MM : MMRel, ArithLogicI<"addi", simm16, GPR32Opnd>,
Akira Hatanakabe6a8182013-04-19 19:03:11 +000039 ADDI_FM_MM<0x4>;
Akira Hatanaka13e6ccf2013-08-06 23:08:38 +000040 def SLTi_MM : MMRel, SetCC_I<"slti", setlt, simm16, immSExt16, GPR32Opnd>,
Akira Hatanakabe6a8182013-04-19 19:03:11 +000041 SLTI_FM_MM<0x24>;
Akira Hatanaka13e6ccf2013-08-06 23:08:38 +000042 def SLTiu_MM : MMRel, SetCC_I<"sltiu", setult, simm16, immSExt16, GPR32Opnd>,
Akira Hatanakabe6a8182013-04-19 19:03:11 +000043 SLTI_FM_MM<0x2c>;
Akira Hatanaka13e6ccf2013-08-06 23:08:38 +000044 def ANDi_MM : MMRel, ArithLogicI<"andi", uimm16, GPR32Opnd>,
Akira Hatanakabe6a8182013-04-19 19:03:11 +000045 ADDI_FM_MM<0x34>;
Akira Hatanaka13e6ccf2013-08-06 23:08:38 +000046 def ORi_MM : MMRel, ArithLogicI<"ori", uimm16, GPR32Opnd>,
Akira Hatanakabe6a8182013-04-19 19:03:11 +000047 ADDI_FM_MM<0x14>;
Akira Hatanaka13e6ccf2013-08-06 23:08:38 +000048 def XORi_MM : MMRel, ArithLogicI<"xori", uimm16, GPR32Opnd>,
Akira Hatanakabe6a8182013-04-19 19:03:11 +000049 ADDI_FM_MM<0x1c>;
Akira Hatanaka13e6ccf2013-08-06 23:08:38 +000050 def LUi_MM : MMRel, LoadUpper<"lui", GPR32Opnd, uimm16>, LUI_FM_MM;
Akira Hatanakabe6a8182013-04-19 19:03:11 +000051
52 /// Arithmetic Instructions (3-Operand, R-Type)
Akira Hatanaka13e6ccf2013-08-06 23:08:38 +000053 def ADDu_MM : MMRel, ArithLogicR<"addu", GPR32Opnd>, ADD_FM_MM<0, 0x150>;
54 def SUBu_MM : MMRel, ArithLogicR<"subu", GPR32Opnd>, ADD_FM_MM<0, 0x1d0>;
55 def MUL_MM : MMRel, ArithLogicR<"mul", GPR32Opnd>, ADD_FM_MM<0, 0x210>;
56 def ADD_MM : MMRel, ArithLogicR<"add", GPR32Opnd>, ADD_FM_MM<0, 0x110>;
57 def SUB_MM : MMRel, ArithLogicR<"sub", GPR32Opnd>, ADD_FM_MM<0, 0x190>;
58 def SLT_MM : MMRel, SetCC_R<"slt", setlt, GPR32Opnd>, ADD_FM_MM<0, 0x350>;
59 def SLTu_MM : MMRel, SetCC_R<"sltu", setult, GPR32Opnd>,
Akira Hatanakabe6a8182013-04-19 19:03:11 +000060 ADD_FM_MM<0, 0x390>;
Akira Hatanaka13e6ccf2013-08-06 23:08:38 +000061 def AND_MM : MMRel, ArithLogicR<"and", GPR32Opnd, 1, IIAlu, and>,
Akira Hatanakabe6a8182013-04-19 19:03:11 +000062 ADD_FM_MM<0, 0x250>;
Akira Hatanaka13e6ccf2013-08-06 23:08:38 +000063 def OR_MM : MMRel, ArithLogicR<"or", GPR32Opnd, 1, IIAlu, or>,
Akira Hatanakabe6a8182013-04-19 19:03:11 +000064 ADD_FM_MM<0, 0x290>;
Akira Hatanaka13e6ccf2013-08-06 23:08:38 +000065 def XOR_MM : MMRel, ArithLogicR<"xor", GPR32Opnd, 1, IIAlu, xor>,
Akira Hatanakabe6a8182013-04-19 19:03:11 +000066 ADD_FM_MM<0, 0x310>;
Akira Hatanaka13e6ccf2013-08-06 23:08:38 +000067 def NOR_MM : MMRel, LogicNOR<"nor", GPR32Opnd>, ADD_FM_MM<0, 0x2d0>;
Akira Hatanaka8002a3f2013-08-14 00:47:08 +000068 def MULT_MM : MMRel, Mult<"mult", IIImul, GPR32Opnd, [HI0, LO0]>,
Akira Hatanakabe6a8182013-04-19 19:03:11 +000069 MULT_FM_MM<0x22c>;
Akira Hatanaka8002a3f2013-08-14 00:47:08 +000070 def MULTu_MM : MMRel, Mult<"multu", IIImul, GPR32Opnd, [HI0, LO0]>,
Akira Hatanakabe6a8182013-04-19 19:03:11 +000071 MULT_FM_MM<0x26c>;
Akira Hatanakacd9b74a2013-04-25 01:11:15 +000072
73 /// Shift Instructions
Akira Hatanaka13e6ccf2013-08-06 23:08:38 +000074 def SLL_MM : MMRel, shift_rotate_imm<"sll", shamt, GPR32Opnd>,
Akira Hatanakacd9b74a2013-04-25 01:11:15 +000075 SRA_FM_MM<0, 0>;
Akira Hatanaka13e6ccf2013-08-06 23:08:38 +000076 def SRL_MM : MMRel, shift_rotate_imm<"srl", shamt, GPR32Opnd>,
Akira Hatanakacd9b74a2013-04-25 01:11:15 +000077 SRA_FM_MM<0x40, 0>;
Akira Hatanaka13e6ccf2013-08-06 23:08:38 +000078 def SRA_MM : MMRel, shift_rotate_imm<"sra", shamt, GPR32Opnd>,
Akira Hatanakacd9b74a2013-04-25 01:11:15 +000079 SRA_FM_MM<0x80, 0>;
Akira Hatanaka13e6ccf2013-08-06 23:08:38 +000080 def SLLV_MM : MMRel, shift_rotate_reg<"sllv", GPR32Opnd>,
Akira Hatanakacd9b74a2013-04-25 01:11:15 +000081 SRLV_FM_MM<0x10, 0>;
Akira Hatanaka13e6ccf2013-08-06 23:08:38 +000082 def SRLV_MM : MMRel, shift_rotate_reg<"srlv", GPR32Opnd>,
Akira Hatanakacd9b74a2013-04-25 01:11:15 +000083 SRLV_FM_MM<0x50, 0>;
Akira Hatanaka13e6ccf2013-08-06 23:08:38 +000084 def SRAV_MM : MMRel, shift_rotate_reg<"srav", GPR32Opnd>,
Akira Hatanakacd9b74a2013-04-25 01:11:15 +000085 SRLV_FM_MM<0x90, 0>;
Akira Hatanaka13e6ccf2013-08-06 23:08:38 +000086 def ROTR_MM : MMRel, shift_rotate_imm<"rotr", shamt, GPR32Opnd>,
Akira Hatanakacd9b74a2013-04-25 01:11:15 +000087 SRA_FM_MM<0xc0, 0>;
Akira Hatanaka13e6ccf2013-08-06 23:08:38 +000088 def ROTRV_MM : MMRel, shift_rotate_reg<"rotrv", GPR32Opnd>,
Akira Hatanakacd9b74a2013-04-25 01:11:15 +000089 SRLV_FM_MM<0xd0, 0>;
Akira Hatanakaf0aa6c92013-04-25 01:21:25 +000090
91 /// Load and Store Instructions - aligned
Vladimir Medicdde3d582013-09-06 12:30:36 +000092 let DecoderMethod = "DecodeMemMMImm16" in {
93 def LB_MM : Load<"lb", GPR32Opnd>, MMRel, LW_FM_MM<0x7>;
94 def LBu_MM : Load<"lbu", GPR32Opnd>, MMRel, LW_FM_MM<0x5>;
95 def LH_MM : Load<"lh", GPR32Opnd>, MMRel, LW_FM_MM<0xf>;
96 def LHu_MM : Load<"lhu", GPR32Opnd>, MMRel, LW_FM_MM<0xd>;
97 def LW_MM : Load<"lw", GPR32Opnd>, MMRel, LW_FM_MM<0x3f>;
98 def SB_MM : Store<"sb", GPR32Opnd>, MMRel, LW_FM_MM<0x6>;
99 def SH_MM : Store<"sh", GPR32Opnd>, MMRel, LW_FM_MM<0xe>;
100 def SW_MM : Store<"sw", GPR32Opnd>, MMRel, LW_FM_MM<0x3e>;
101 }
Jack Carter97700972013-08-13 20:19:16 +0000102
103 /// Load and Store Instructions - unaligned
Akira Hatanakaa43b56d2013-08-20 20:46:51 +0000104 def LWL_MM : LoadLeftRightMM<"lwl", MipsLWL, GPR32Opnd, mem_mm_12>,
105 LWL_FM_MM<0x0>;
106 def LWR_MM : LoadLeftRightMM<"lwr", MipsLWR, GPR32Opnd, mem_mm_12>,
107 LWL_FM_MM<0x1>;
108 def SWL_MM : StoreLeftRightMM<"swl", MipsSWL, GPR32Opnd, mem_mm_12>,
109 LWL_FM_MM<0x8>;
110 def SWR_MM : StoreLeftRightMM<"swr", MipsSWR, GPR32Opnd, mem_mm_12>,
111 LWL_FM_MM<0x9>;
Vladimir Medice0fbb442013-09-06 12:41:17 +0000112
113 /// Move Conditional
114 def MOVZ_I_MM : MMRel, CMov_I_I_FT<"movz", GPR32Opnd, GPR32Opnd,
115 NoItinerary>, ADD_FM_MM<0, 0x58>;
116 def MOVN_I_MM : MMRel, CMov_I_I_FT<"movn", GPR32Opnd, GPR32Opnd,
117 NoItinerary>, ADD_FM_MM<0, 0x18>;
118 def MOVT_I_MM : MMRel, CMov_F_I_FT<"movt", GPR32Opnd, IIAlu>,
119 CMov_F_I_FM_MM<0x25>;
120 def MOVF_I_MM : MMRel, CMov_F_I_FT<"movf", GPR32Opnd, IIAlu>,
121 CMov_F_I_FM_MM<0x5>;
Vladimir Medic457ba562013-09-06 12:53:21 +0000122
123 /// Move to/from HI/LO
124 def MTHI_MM : MMRel, MoveToLOHI<"mthi", GPR32Opnd, [HI0]>,
125 MTLO_FM_MM<0x0b5>;
126 def MTLO_MM : MMRel, MoveToLOHI<"mtlo", GPR32Opnd, [LO0]>,
127 MTLO_FM_MM<0x0f5>;
128 def MFHI_MM : MMRel, MoveFromLOHI<"mfhi", GPR32Opnd, [HI0]>,
129 MFLO_FM_MM<0x035>;
130 def MFLO_MM : MMRel, MoveFromLOHI<"mflo", GPR32Opnd, [LO0]>,
131 MFLO_FM_MM<0x075>;
Vladimir Medicb936da12013-09-06 13:08:00 +0000132
133 /// Multiply Add/Sub Instructions
134 def MADD_MM : MMRel, MArithR<"madd", 1>, MULT_FM_MM<0x32c>;
135 def MADDU_MM : MMRel, MArithR<"maddu", 1>, MULT_FM_MM<0x36c>;
136 def MSUB_MM : MMRel, MArithR<"msub">, MULT_FM_MM<0x3ac>;
137 def MSUBU_MM : MMRel, MArithR<"msubu">, MULT_FM_MM<0x3ec>;
Akira Hatanakabe6a8182013-04-19 19:03:11 +0000138}