[mips][mips64r6] Add bitswap, and dbitswap
[oota-llvm.git] / lib / Target / Mips / Mips32r6InstrInfo.td
1 //=- Mips32r6InstrInfo.td - Mips32r6 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 Mips32r6 instructions.
11 //
12 //===----------------------------------------------------------------------===//
13
14 include "Mips32r6InstrFormats.td"
15
16 // Notes about removals/changes from MIPS32r6:
17 // Unclear: ssnop
18 // Reencoded: cache, pref
19 // Reencoded: clo, clz
20 // Reencoded: jr -> jalr
21 // Reencoded: jr.hb -> jalr.hb
22 // Reencoded: ldc2
23 // Reencoded: ll, sc
24 // Reencoded: lwc2
25 // Reencoded: sdbbp
26 // Reencoded: sdc2
27 // Reencoded: swc2
28 // Removed: /.ps$/, cvt.ps.s, cvt.ps.pw
29 // Removed: addi
30 // Removed: bc1any2, bc1any4
31 // Removed: bc2[ft]
32 // Removed: bc2f, bc2t
33 // Removed: bgezal
34 // Removed: bltzal
35 // Removed: c.cond.fmt, bc1[ft]
36 // Removed: div, divu
37 // Removed: jalx
38 // Removed: ldxc1
39 // Removed: luxc1
40 // Removed: lwl, lwr, lwle, lwre, swl, swr, swle, swre
41 // Removed: lwxc1
42 // Removed: madd.[ds], nmadd.[ds], nmsub.[ds], sub.[ds]
43 // Removed: mfhi, mflo, mthi, mtlo, madd, maddu, msub, msubu, mul
44 // Removed: movf, movt
45 // Removed: movf.fmt, movt.fmt, movn.fmt, movz.fmt
46 // Removed: movn, movz
47 // Removed: mult, multu
48 // Removed: prefx
49 // Removed: sdxc1
50 // Removed: suxc1
51 // Removed: swxc1
52 // Removed: teqi, tgei, tgeiu, tlti, tltiu, tnei
53 // Rencoded: [ls][wd]c2
54
55 //===----------------------------------------------------------------------===//
56 //
57 // Instruction Encodings
58 //
59 //===----------------------------------------------------------------------===//
60
61 class ADDIUPC_ENC : PCREL19_FM<OPCODE2_ADDIUPC>;
62 class ALIGN_ENC  : SPECIAL3_ALIGN_FM<OPCODE6_ALIGN>;
63 class ALUIPC_ENC : PCREL16_FM<OPCODE5_ALUIPC>;
64 class AUI_ENC    : AUI_FM;
65 class AUIPC_ENC  : PCREL16_FM<OPCODE5_AUIPC>;
66 class BITSWAP_ENC : SPECIAL3_2R_FM<OPCODE6_BITSWAP>;
67 class DIV_ENC    : SPECIAL_3R_FM<0b00010, 0b011010>;
68 class DIVU_ENC   : SPECIAL_3R_FM<0b00010, 0b011011>;
69 class MOD_ENC    : SPECIAL_3R_FM<0b00011, 0b011010>;
70 class MODU_ENC   : SPECIAL_3R_FM<0b00011, 0b011011>;
71 class MUH_ENC    : SPECIAL_3R_FM<0b00011, 0b011000>;
72 class MUHU_ENC   : SPECIAL_3R_FM<0b00011, 0b011001>;
73 class MUL_R6_ENC : SPECIAL_3R_FM<0b00010, 0b011000>;
74 class MULU_ENC   : SPECIAL_3R_FM<0b00010, 0b011001>;
75 class SEL_D_ENC  : COP1_3R_FM<0b010000, FIELD_FMT_D>;
76 class SEL_S_ENC  : COP1_3R_FM<0b010000, FIELD_FMT_S>;
77
78 //===----------------------------------------------------------------------===//
79 //
80 // Instruction Descriptions
81 //
82 //===----------------------------------------------------------------------===//
83
84 class ADDIUPC_DESC_BASE<string instr_asm, RegisterOperand GPROpnd> {
85   dag OutOperandList = (outs GPROpnd:$rs);
86   dag InOperandList = (ins simm19_lsl2:$imm);
87   string AsmString = !strconcat(instr_asm, "\t$rs, $imm");
88   list<dag> Pattern = [];
89 }
90
91 class ADDIUPC_DESC : ADDIUPC_DESC_BASE<"addiupc", GPR32Opnd>;
92
93 class ALIGN_DESC_BASE<string instr_asm, RegisterOperand GPROpnd,
94                       Operand ImmOpnd> {
95   dag OutOperandList = (outs GPROpnd:$rd);
96   dag InOperandList = (ins GPROpnd:$rs, GPROpnd:$rt, ImmOpnd:$bp);
97   string AsmString = !strconcat(instr_asm, "\t$rd, $rs, $rt, $bp");
98   list<dag> Pattern = [];
99 }
100
101 class ALIGN_DESC : ALIGN_DESC_BASE<"align", GPR32Opnd, uimm2>;
102
103 class ALUIPC_DESC_BASE<string instr_asm, RegisterOperand GPROpnd> {
104   dag OutOperandList = (outs GPROpnd:$rs);
105   dag InOperandList = (ins simm16:$imm);
106   string AsmString = !strconcat(instr_asm, "\t$rs, $imm");
107   list<dag> Pattern = [];
108 }
109
110 class ALUIPC_DESC : ALUIPC_DESC_BASE<"aluipc", GPR32Opnd>;
111 class AUIPC_DESC : ALUIPC_DESC_BASE<"auipc", GPR32Opnd>;
112
113 class AUI_DESC_BASE<string instr_asm, RegisterOperand GPROpnd> {
114   dag OutOperandList = (outs GPROpnd:$rs);
115   dag InOperandList = (ins GPROpnd:$rt, simm16:$imm);
116   string AsmString = !strconcat(instr_asm, "\t$rs, $rt, $imm");
117   list<dag> Pattern = [];
118 }
119
120 class AUI_DESC : AUI_DESC_BASE<"aui", GPR32Opnd>;
121
122 class BITSWAP_DESC_BASE<string instr_asm, RegisterOperand GPROpnd> {
123   dag OutOperandList = (outs GPROpnd:$rd);
124   dag InOperandList = (ins GPROpnd:$rt);
125   string AsmString = !strconcat(instr_asm, "\t$rd, $rt");
126   list<dag> Pattern = [];
127 }
128
129 class BITSWAP_DESC : BITSWAP_DESC_BASE<"bitswap", GPR32Opnd>;
130
131 class DIVMOD_DESC_BASE<string instr_asm, RegisterOperand GPROpnd> {
132   dag OutOperandList = (outs GPROpnd:$rd);
133   dag InOperandList = (ins GPROpnd:$rs, GPROpnd:$rt);
134   string AsmString = !strconcat(instr_asm, "\t$rd, $rs, $rt");
135   list<dag> Pattern = [];
136 }
137
138 class DIV_DESC  : DIVMOD_DESC_BASE<"div", GPR32Opnd>;
139 class DIVU_DESC : DIVMOD_DESC_BASE<"divu", GPR32Opnd>;
140 class MOD_DESC  : DIVMOD_DESC_BASE<"mod", GPR32Opnd>;
141 class MODU_DESC : DIVMOD_DESC_BASE<"modu", GPR32Opnd>;
142
143 class MUL_R6_DESC_BASE<string instr_asm, RegisterOperand GPROpnd> {
144   dag OutOperandList = (outs GPROpnd:$rd);
145   dag InOperandList = (ins GPROpnd:$rs, GPROpnd:$rt);
146   string AsmString = !strconcat(instr_asm, "\t$rd, $rs, $rt");
147   list<dag> Pattern = [];
148 }
149
150 class MUH_DESC    : MUL_R6_DESC_BASE<"muh", GPR32Opnd>;
151 class MUHU_DESC   : MUL_R6_DESC_BASE<"muhu", GPR32Opnd>;
152 class MUL_R6_DESC : MUL_R6_DESC_BASE<"mul", GPR32Opnd>;
153 class MULU_DESC   : MUL_R6_DESC_BASE<"mulu", GPR32Opnd>;
154
155 class SEL_DESC_BASE<string instr_asm, RegisterOperand FGROpnd> {
156   dag OutOperandList = (outs FGROpnd:$fd);
157   dag InOperandList = (ins FGROpnd:$fd_in, FGROpnd:$fs, FGROpnd:$ft);
158   string AsmString = !strconcat(instr_asm, "\t$fd, $fs, $ft");
159   list<dag> Pattern = [];
160   string Constraints = "$fd_in = $fd";
161 }
162
163 class SEL_D_DESC : SEL_DESC_BASE<"sel.d", FGR64Opnd>;
164 class SEL_S_DESC : SEL_DESC_BASE<"sel.s", FGR32Opnd>;
165
166 //===----------------------------------------------------------------------===//
167 //
168 // Instruction Definitions
169 //
170 //===----------------------------------------------------------------------===//
171
172 def ADDIUPC : ADDIUPC_ENC, ADDIUPC_DESC, ISA_MIPS32R6;
173 def ALIGN : ALIGN_ENC, ALIGN_DESC, ISA_MIPS32R6;
174 def ALUIPC : ALUIPC_ENC, ALUIPC_DESC, ISA_MIPS32R6;
175 def AUI : AUI_ENC, AUI_DESC, ISA_MIPS32R6;
176 def AUIPC : AUIPC_ENC, AUIPC_DESC, ISA_MIPS32R6;
177 def BALC;
178 def BC1EQZ;
179 def BC1NEZ;
180 def BC2EQZ;
181 def BC2NEZ;
182 def BC;
183 def BEQC;
184 def BEQZALC;
185 def BEQZC;
186 def BGEC;  // Also aliased to blec with operands swapped
187 def BGEUC; // Also aliased to bleuc with operands swapped
188 def BGEZALC;
189 def BGEZC;
190 def BGTZALC;
191 def BGTZC;
192 def BITSWAP : BITSWAP_ENC, BITSWAP_DESC, ISA_MIPS32R6;
193 def BLEZALC;
194 def BLEZC;
195 def BLTC; // Also aliased to bgtc with operands swapped
196 def BLTUC; // Also aliased to bgtuc with operands swapped
197 def BLTZALC;
198 def BLTZC;
199 def BNEC;
200 def BNEZALC;
201 def BNEZC;
202 def BNVC;
203 def BOVC;
204 def CLASS_D;
205 def CLASS_S;
206 def CMP_CC_D;
207 def CMP_CC_S;
208 def DIV : DIV_ENC, DIV_DESC, ISA_MIPS32R6;
209 def DIVU : DIVU_ENC, DIVU_DESC, ISA_MIPS32R6;
210 def JIALC;
211 def JIC;
212 // def LSA; // See MSA
213 def LWPC;
214 def LWUPC;
215 def MADDF;
216 def MAXA_D;
217 def MAXA_S;
218 def MAX_D;
219 def MAX_S;
220 def MINA_D;
221 def MINA_S;
222 def MIN_D;
223 def MOD : MOD_ENC, MOD_DESC, ISA_MIPS32R6;
224 def MODU : MODU_ENC, MODU_DESC, ISA_MIPS32R6;
225 def MSUBF;
226 def MUH    : MUH_ENC, MUH_DESC, ISA_MIPS32R6;
227 def MUHU   : MUHU_ENC, MUHU_DESC, ISA_MIPS32R6;
228 def MUL_R6 : MUL_R6_ENC, MUL_R6_DESC, ISA_MIPS32R6;
229 def MULU   : MULU_ENC, MULU_DESC, ISA_MIPS32R6;
230 def NAL; // BAL with rd=0
231 def RINT_D;
232 def RINT_S;
233 def SELEQZ;
234 def SELEQZ_D;
235 def SELEQZ_S;
236 def SELNEZ;
237 def SELNEZ_D;
238 def SELNEZ_S;
239 def SEL_D : SEL_D_ENC, SEL_D_DESC, ISA_MIPS32R6;
240 def SEL_S : SEL_S_ENC, SEL_S_DESC, ISA_MIPS32R6;