[mips][mips64r6] Add bitswap, and dbitswap
[oota-llvm.git] / lib / Target / Mips / Mips32r6InstrFormats.td
1 //=- Mips32r6InstrFormats.td - Mips32r6 Instruction Formats -*- 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 instruction formats.
11 //
12 //===----------------------------------------------------------------------===//
13
14 class MipsR6Inst : MipsInst<(outs), (ins), "", [], NoItinerary, FrmOther>,
15                    PredicateControl {
16   let DecoderNamespace = "Mips32r6_64r6";
17   let EncodingPredicates = [HasStdEnc];
18 }
19
20 //===----------------------------------------------------------------------===//
21 //
22 // Field Values
23 //
24 //===----------------------------------------------------------------------===//
25
26 def OPGROUP_COP1    { bits<6> Value = 0b010001; }
27 def OPGROUP_AUI     { bits<6> Value = 0b001111; }
28 def OPGROUP_DAUI    { bits<6> Value = 0b011101; }
29 def OPGROUP_PCREL   { bits<6> Value = 0b111011; }
30 def OPGROUP_REGIMM  { bits<6> Value = 0b000001; }
31 def OPGROUP_SPECIAL { bits<6> Value = 0b000000; }
32 def OPGROUP_SPECIAL3 { bits<6> Value = 0b011111; }
33
34 class OPCODE2<bits<2> Val> {
35   bits<2> Value = Val;
36 }
37 def OPCODE2_ADDIUPC : OPCODE2<0b00>;
38
39 class OPCODE5<bits<5> Val> {
40   bits<5> Value = Val;
41 }
42 def OPCODE5_ALUIPC : OPCODE5<0b11111>;
43 def OPCODE5_AUIPC  : OPCODE5<0b11110>;
44 def OPCODE5_DAHI : OPCODE5<0b00110>;
45 def OPCODE5_DATI : OPCODE5<0b11110>;
46
47 class OPCODE6<bits<6> Val> {
48   bits<6> Value = Val;
49 }
50 def OPCODE6_ALIGN    : OPCODE6<0b100000>;
51 def OPCODE6_DALIGN   : OPCODE6<0b100100>;
52 def OPCODE6_BITSWAP  : OPCODE6<0b100000>;
53 def OPCODE6_DBITSWAP : OPCODE6<0b100100>;
54
55 class FIELD_FMT<bits<5> Val> {
56   bits<5> Value = Val;
57 }
58 def FIELD_FMT_S : FIELD_FMT<0b10000>;
59 def FIELD_FMT_D : FIELD_FMT<0b10001>;
60
61 //===----------------------------------------------------------------------===//
62 //
63 // Encoding Formats
64 //
65 //===----------------------------------------------------------------------===//
66
67 class AUI_FM : MipsR6Inst {
68   bits<5> rs;
69   bits<5> rt;
70   bits<16> imm;
71
72   bits<32> Inst;
73
74   let Inst{31-26} = OPGROUP_AUI.Value;
75   let Inst{25-21} = rs;
76   let Inst{20-16} = rt;
77   let Inst{15-0} = imm;
78 }
79
80 class DAUI_FM : AUI_FM {
81   let Inst{31-26} = OPGROUP_DAUI.Value;
82 }
83
84 class COP1_3R_FM<bits<6> funct, FIELD_FMT Format> : MipsR6Inst {
85   bits<5> ft;
86   bits<5> fs;
87   bits<5> fd;
88
89   bits<32> Inst;
90
91   let Inst{31-26} = OPGROUP_COP1.Value;
92   let Inst{25-21} = Format.Value;
93   let Inst{20-16} = ft;
94   let Inst{15-11} = fs;
95   let Inst{10-6} = fd;
96   let Inst{5-0} = funct;
97 }
98
99 class PCREL16_FM<OPCODE5 Operation> : MipsR6Inst {
100   bits<5> rs;
101   bits<16> imm;
102
103   bits<32> Inst;
104
105   let Inst{31-26} = OPGROUP_PCREL.Value;
106   let Inst{25-21} = rs;
107   let Inst{20-16} = Operation.Value;
108   let Inst{15-0} = imm;
109 }
110
111 class PCREL19_FM<OPCODE2 Operation> : MipsR6Inst {
112   bits<5> rs;
113   bits<19> imm;
114
115   bits<32> Inst;
116
117   let Inst{31-26} = OPGROUP_PCREL.Value;
118   let Inst{25-21} = rs;
119   let Inst{20-19} = Operation.Value;
120   let Inst{18-0} = imm;
121 }
122
123 class SPECIAL3_2R_FM<OPCODE6 Operation> : MipsR6Inst {
124   bits<5> rd;
125   bits<5> rt;
126
127   bits<32> Inst;
128
129   let Inst{31-26} = OPGROUP_SPECIAL3.Value;
130   let Inst{25-21} = 0b00000;
131   let Inst{20-16} = rt;
132   let Inst{15-11} = rd;
133   let Inst{10-6}  = 0b00000;
134   let Inst{5-0}   = Operation.Value;
135 }
136
137 class SPECIAL_3R_FM<bits<5> mulop, bits<6> funct> : MipsR6Inst {
138   bits<5> rd;
139   bits<5> rs;
140   bits<5> rt;
141
142   bits<32> Inst;
143
144   let Inst{31-26} = OPGROUP_SPECIAL.Value;
145   let Inst{25-21} = rs;
146   let Inst{20-16} = rt;
147   let Inst{15-11} = rd;
148   let Inst{10-6}  = mulop;
149   let Inst{5-0}   = funct;
150 }
151
152 class SPECIAL3_ALIGN_FM<OPCODE6 Operation> : MipsR6Inst {
153   bits<5> rd;
154   bits<5> rs;
155   bits<5> rt;
156   bits<2> bp;
157
158   bits<32> Inst;
159
160   let Inst{31-26} = OPGROUP_SPECIAL3.Value;
161   let Inst{25-21} = rs;
162   let Inst{20-16} = rt;
163   let Inst{15-11} = rd;
164   let Inst{10-8}  = 0b010;
165   let Inst{7-6}   = bp;
166   let Inst{5-0}   = Operation.Value;
167 }
168
169 class SPECIAL3_DALIGN_FM<OPCODE6 Operation> : MipsR6Inst {
170   bits<5> rd;
171   bits<5> rs;
172   bits<5> rt;
173   bits<3> bp;
174
175   bits<32> Inst;
176
177   let Inst{31-26} = OPGROUP_SPECIAL3.Value;
178   let Inst{25-21} = rs;
179   let Inst{20-16} = rt;
180   let Inst{15-11} = rd;
181   let Inst{10-9}  = 0b01;
182   let Inst{8-6}   = bp;
183   let Inst{5-0}   = Operation.Value;
184 }
185
186 class REGIMM_FM<OPCODE5 Operation> : MipsR6Inst {
187   bits<5> rs;
188   bits<16> imm;
189
190   bits<32> Inst;
191
192   let Inst{31-26} = OPGROUP_REGIMM.Value;
193   let Inst{25-21} = rs;
194   let Inst{20-16} = Operation.Value;
195   let Inst{15-0} = imm;
196 }