[mips][microMIPSr6] Implement ADDIUPC and LWPC instructions
[oota-llvm.git] / lib / Target / Mips / MicroMips32r6InstrInfo.td
1 //=- MicroMips32r6InstrInfo.td - MicroMips r6 Instruction Information -*- tablegen -*-=//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file describes microMIPSr6 instructions.
11 //
12 //===----------------------------------------------------------------------===//
13
14 //===----------------------------------------------------------------------===//
15 //
16 // Instruction Encodings
17 //
18 //===----------------------------------------------------------------------===//
19 class ADD_MMR6_ENC : ARITH_FM_MMR6<"add", 0x110>;
20 class ADDIU_MMR6_ENC : ADDI_FM_MMR6<"addiu", 0xc>;
21 class ADDU_MMR6_ENC : ARITH_FM_MMR6<"addu", 0x150>;
22 class ADDIUPC_MMR6_ENC : PCREL19_FM_MMR6<0b00>;
23 class BALC_MMR6_ENC  : BRANCH_OFF26_FM<0b101101>;
24 class BC_MMR6_ENC : BRANCH_OFF26_FM<0b100101>;
25 class BITSWAP_MMR6_ENC : POOL32A_BITSWAP_FM_MMR6<0b101100>;
26 class CACHE_MMR6_ENC : CACHE_PREF_FM_MMR6<0b001000, 0b0110>;
27 class JIALC_MMR6_ENC : JMP_IDX_COMPACT_FM<0b100000>;
28 class JIC_MMR6_ENC   : JMP_IDX_COMPACT_FM<0b101000>;
29 class LWPC_MMR6_ENC  : PCREL19_FM_MMR6<0b01>;
30 class MUL_MMR6_ENC : ARITH_FM_MMR6<"mul", 0x18>;
31 class MUH_MMR6_ENC : ARITH_FM_MMR6<"muh", 0x58>;
32 class MULU_MMR6_ENC : ARITH_FM_MMR6<"mulu", 0x98>;
33 class MUHU_MMR6_ENC : ARITH_FM_MMR6<"muhu", 0xd8>;
34 class PREF_MMR6_ENC : CACHE_PREF_FM_MMR6<0b011000, 0b0010>;
35 class SUB_MMR6_ENC : ARITH_FM_MMR6<"sub", 0x190>;
36 class SUBU_MMR6_ENC : ARITH_FM_MMR6<"subu", 0x1d0>;
37
38 //===----------------------------------------------------------------------===//
39 //
40 // Instruction Descriptions
41 //
42 //===----------------------------------------------------------------------===//
43
44 class ADD_MMR6_DESC : ArithLogicR<"add", GPR32Opnd>;
45 class ADDIU_MMR6_DESC : ArithLogicI<"addiu", simm16, GPR32Opnd>;
46 class ADDU_MMR6_DESC : ArithLogicR<"addu", GPR32Opnd>;
47 class MUL_MMR6_DESC : ArithLogicR<"mul", GPR32Opnd>;
48 class MUH_MMR6_DESC : ArithLogicR<"muh", GPR32Opnd>;
49 class MULU_MMR6_DESC : ArithLogicR<"mulu", GPR32Opnd>;
50 class MUHU_MMR6_DESC : ArithLogicR<"muhu", GPR32Opnd>;
51
52 class BC_MMR6_DESC_BASE<string instr_asm, DAGOperand opnd>
53     : BRANCH_DESC_BASE, MMR6Arch<instr_asm> {
54   dag InOperandList = (ins opnd:$offset);
55   dag OutOperandList = (outs);
56   string AsmString = !strconcat(instr_asm, "\t$offset");
57   bit isBarrier = 1;
58 }
59
60 class BALC_MMR6_DESC : BC_MMR6_DESC_BASE<"balc", brtarget26> {
61   bit isCall = 1;
62   list<Register> Defs = [RA];
63 }
64 class BC_MMR6_DESC : BC_MMR6_DESC_BASE<"bc", brtarget26>;
65 class SUB_MMR6_DESC : ArithLogicR<"sub", GPR32Opnd>;
66 class SUBU_MMR6_DESC : ArithLogicR<"subu", GPR32Opnd>;
67
68 class BITSWAP_MMR6_DESC_BASE<string instr_asm, RegisterOperand GPROpnd>
69     : MMR6Arch<instr_asm> {
70   dag OutOperandList = (outs GPROpnd:$rd);
71   dag InOperandList = (ins GPROpnd:$rt);
72   string AsmString = !strconcat(instr_asm, "\t$rd, $rt");
73   list<dag> Pattern = [];
74 }
75
76 class BITSWAP_MMR6_DESC : BITSWAP_MMR6_DESC_BASE<"bitswap", GPR32Opnd>;
77
78 class CACHE_HINT_MMR6_DESC<string instr_asm, Operand MemOpnd,
79                            RegisterOperand GPROpnd> : MMR6Arch<instr_asm> {
80   dag OutOperandList = (outs);
81   dag InOperandList = (ins MemOpnd:$addr, uimm5:$hint);
82   string AsmString = !strconcat(instr_asm, "\t$hint, $addr");
83   list<dag> Pattern = [];
84   string DecoderMethod = "DecodeCacheOpMM";
85 }
86
87 class CACHE_MMR6_DESC : CACHE_HINT_MMR6_DESC<"cache", mem_mm_12, GPR32Opnd>;
88 class PREF_MMR6_DESC : CACHE_HINT_MMR6_DESC<"pref", mem_mm_12, GPR32Opnd>;
89
90 class JMP_MMR6_IDX_COMPACT_DESC_BASE<string opstr, DAGOperand opnd,
91                                      RegisterOperand GPROpnd>
92     : MMR6Arch<opstr> {
93   dag InOperandList = (ins GPROpnd:$rt, opnd:$offset);
94   string AsmString = !strconcat(opstr, "\t$rt, $offset");
95   list<dag> Pattern = [];
96   bit isTerminator = 1;
97   bit hasDelaySlot = 0;
98 }
99
100 class JIALC_MMR6_DESC : JMP_MMR6_IDX_COMPACT_DESC_BASE<"jialc", calloffset16,
101                                                        GPR32Opnd> {
102   bit isCall = 1;
103   list<Register> Defs = [RA];
104 }
105
106 class JIC_MMR6_DESC : JMP_MMR6_IDX_COMPACT_DESC_BASE<"jic", jmpoffset16,
107                                                      GPR32Opnd> {
108   bit isBarrier = 1;
109   list<Register> Defs = [AT];
110 }
111
112 class PCREL_MMR6_DESC_BASE<string instr_asm, RegisterOperand GPROpnd,
113                            Operand ImmOpnd> : MMR6Arch<instr_asm> {
114   dag OutOperandList = (outs GPROpnd:$rt);
115   dag InOperandList = (ins ImmOpnd:$imm);
116   string AsmString = !strconcat(instr_asm, "\t$rt, $imm");
117   list<dag> Pattern = [];
118 }
119
120 class ADDIUPC_MMR6_DESC : PCREL_MMR6_DESC_BASE<"addiupc", GPR32Opnd, simm19_lsl2>;
121 class LWPC_MMR6_DESC: PCREL_MMR6_DESC_BASE<"lwpc", GPR32Opnd, simm19_lsl2>;
122
123 //===----------------------------------------------------------------------===//
124 //
125 // Instruction Definitions
126 //
127 //===----------------------------------------------------------------------===//
128
129 let DecoderNamespace = "MicroMips32r6" in {
130 def ADD_MMR6 : StdMMR6Rel, ADD_MMR6_DESC, ADD_MMR6_ENC, ISA_MICROMIPS32R6;
131 def ADDIU_MMR6 : StdMMR6Rel, ADDIU_MMR6_DESC, ADDIU_MMR6_ENC, ISA_MICROMIPS32R6;
132 def ADDU_MMR6 : StdMMR6Rel, ADDU_MMR6_DESC, ADDU_MMR6_ENC, ISA_MICROMIPS32R6;
133 def ADDIUPC_MMR6 : R6MMR6Rel, ADDIUPC_MMR6_ENC, ADDIUPC_MMR6_DESC,
134                    ISA_MICROMIPS32R6;
135 def BALC_MMR6 : R6MMR6Rel, BALC_MMR6_ENC, BALC_MMR6_DESC, ISA_MICROMIPS32R6;
136 def BC_MMR6 : R6MMR6Rel, BC_MMR6_ENC, BC_MMR6_DESC, ISA_MICROMIPS32R6;
137 def BITSWAP_MMR6 : R6MMR6Rel, BITSWAP_MMR6_ENC, BITSWAP_MMR6_DESC,
138                    ISA_MICROMIPS32R6;
139 def CACHE_MMR6 : R6MMR6Rel, CACHE_MMR6_ENC, CACHE_MMR6_DESC, ISA_MICROMIPS32R6;
140 def JIALC_MMR6 : R6MMR6Rel, JIALC_MMR6_ENC, JIALC_MMR6_DESC, ISA_MICROMIPS32R6;
141 def JIC_MMR6 : R6MMR6Rel, JIC_MMR6_ENC, JIC_MMR6_DESC, ISA_MICROMIPS32R6;
142 def LWPC_MMR6 : R6MMR6Rel, LWPC_MMR6_ENC, LWPC_MMR6_DESC, ISA_MICROMIPS32R6;
143 def MUL_MMR6 : R6MMR6Rel, MUL_MMR6_DESC, MUL_MMR6_ENC, ISA_MICROMIPS32R6;
144 def MUH_MMR6 : R6MMR6Rel, MUH_MMR6_DESC, MUH_MMR6_ENC, ISA_MICROMIPS32R6;
145 def MULU_MMR6 : R6MMR6Rel, MULU_MMR6_DESC, MULU_MMR6_ENC, ISA_MICROMIPS32R6;
146 def MUHU_MMR6 : R6MMR6Rel, MUHU_MMR6_DESC, MUHU_MMR6_ENC, ISA_MICROMIPS32R6;
147 def PREF_MMR6 : R6MMR6Rel, PREF_MMR6_ENC, PREF_MMR6_DESC, ISA_MICROMIPS32R6;
148 def SUB_MMR6 : StdMMR6Rel, SUB_MMR6_DESC, SUB_MMR6_ENC, ISA_MICROMIPS32R6;
149 def SUBU_MMR6 : StdMMR6Rel, SUBU_MMR6_DESC, SUBU_MMR6_ENC, ISA_MICROMIPS32R6;
150 }