Commit | Line | Data |
---|---|---|
87e6d782 NC |
1 | /* Instruction opcode table for openrisc. |
2 | ||
3 | THIS FILE IS MACHINE GENERATED WITH CGEN. | |
4 | ||
5 | Copyright 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. | |
6 | ||
7 | This file is part of the GNU Binutils and/or GDB, the GNU debugger. | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation; either version 2, or (at your option) | |
12 | any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License along | |
20 | with this program; if not, write to the Free Software Foundation, Inc., | |
21 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
22 | ||
23 | */ | |
24 | ||
25 | #include "sysdep.h" | |
26 | #include "ansidecl.h" | |
27 | #include "bfd.h" | |
28 | #include "symcat.h" | |
29 | #include "openrisc-desc.h" | |
30 | #include "openrisc-opc.h" | |
31 | #include "libiberty.h" | |
32 | ||
33 | /* -- opc.c */ | |
34 | /* -- */ | |
35 | /* The hash functions are recorded here to help keep assembler code out of | |
36 | the disassembler and vice versa. */ | |
37 | ||
fc05c67f NC |
38 | static int asm_hash_insn_p PARAMS ((const CGEN_INSN *)); |
39 | static unsigned int asm_hash_insn PARAMS ((const char *)); | |
40 | static int dis_hash_insn_p PARAMS ((const CGEN_INSN *)); | |
41 | static unsigned int dis_hash_insn PARAMS ((const char *, CGEN_INSN_INT)); | |
42 | static void set_fields_bitsize PARAMS ((CGEN_FIELDS *, int)); | |
87e6d782 NC |
43 | |
44 | /* Instruction formats. */ | |
45 | ||
46 | #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) | |
47 | #define F(f) & openrisc_cgen_ifld_table[OPENRISC_##f] | |
48 | #else | |
49 | #define F(f) & openrisc_cgen_ifld_table[OPENRISC_/**/f] | |
50 | #endif | |
51 | static const CGEN_IFMT ifmt_empty = { | |
52 | 0, 0, 0x0, { { 0 } } | |
53 | }; | |
54 | ||
55 | static const CGEN_IFMT ifmt_l_j = { | |
56 | 32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_ABS26) }, { 0 } } | |
57 | }; | |
58 | ||
59 | static const CGEN_IFMT ifmt_l_jr = { | |
60 | 32, 32, 0xffe00000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP3) }, { F (F_OP4) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } } | |
61 | }; | |
62 | ||
63 | static const CGEN_IFMT ifmt_l_bal = { | |
64 | 32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_DISP26) }, { 0 } } | |
65 | }; | |
66 | ||
67 | static const CGEN_IFMT ifmt_l_movhi = { | |
68 | 32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } } | |
69 | }; | |
70 | ||
71 | static const CGEN_IFMT ifmt_l_mfsr = { | |
72 | 32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } } | |
73 | }; | |
74 | ||
75 | static const CGEN_IFMT ifmt_l_mtsr = { | |
76 | 32, 32, 0xfc0007ff, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_R3) }, { F (F_I16_1) }, { 0 } } | |
77 | }; | |
78 | ||
79 | static const CGEN_IFMT ifmt_l_lw = { | |
80 | 32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } } | |
81 | }; | |
82 | ||
83 | static const CGEN_IFMT ifmt_l_sw = { | |
84 | 32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R3) }, { F (F_I16NC) }, { 0 } } | |
85 | }; | |
86 | ||
87 | static const CGEN_IFMT ifmt_l_sll = { | |
88 | 32, 32, 0xfc0007ff, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_R3) }, { F (F_F_10_3) }, { F (F_OP6) }, { F (F_F_4_1) }, { F (F_OP7) }, { 0 } } | |
89 | }; | |
90 | ||
91 | static const CGEN_IFMT ifmt_l_slli = { | |
92 | 32, 32, 0xfc00ffe0, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_F_15_8) }, { F (F_OP6) }, { F (F_UIMM5) }, { 0 } } | |
93 | }; | |
94 | ||
95 | static const CGEN_IFMT ifmt_l_add = { | |
96 | 32, 32, 0xfc0007ff, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_R3) }, { F (F_F_10_7) }, { F (F_OP7) }, { 0 } } | |
97 | }; | |
98 | ||
99 | static const CGEN_IFMT ifmt_l_addi = { | |
100 | 32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_LO16) }, { 0 } } | |
101 | }; | |
102 | ||
103 | static const CGEN_IFMT ifmt_l_sfgts = { | |
104 | 32, 32, 0xffe007ff, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP5) }, { F (F_R2) }, { F (F_R3) }, { F (F_F_10_11) }, { 0 } } | |
105 | }; | |
106 | ||
107 | static const CGEN_IFMT ifmt_l_sfgtsi = { | |
108 | 32, 32, 0xffe00000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP5) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } } | |
109 | }; | |
110 | ||
111 | static const CGEN_IFMT ifmt_l_sfgtui = { | |
112 | 32, 32, 0xffe00000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP5) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } } | |
113 | }; | |
114 | ||
115 | #undef F | |
116 | ||
117 | #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) | |
118 | #define A(a) (1 << CGEN_INSN_##a) | |
119 | #else | |
120 | #define A(a) (1 << CGEN_INSN_/**/a) | |
121 | #endif | |
122 | #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) | |
123 | #define OPERAND(op) OPENRISC_OPERAND_##op | |
124 | #else | |
125 | #define OPERAND(op) OPENRISC_OPERAND_/**/op | |
126 | #endif | |
127 | #define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */ | |
128 | #define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field)) | |
129 | ||
130 | /* The instruction table. */ | |
131 | ||
132 | static const CGEN_OPCODE openrisc_cgen_insn_opcode_table[MAX_INSNS] = | |
133 | { | |
134 | /* Special null first entry. | |
135 | A `num' value of zero is thus invalid. | |
136 | Also, the special `invalid' insn resides here. */ | |
137 | { { 0, 0, 0, 0 }, {{0}}, 0, {0}}, | |
138 | /* l.j ${abs-26} */ | |
139 | { | |
140 | { 0, 0, 0, 0 }, | |
141 | { { MNEM, ' ', OP (ABS_26), 0 } }, | |
142 | & ifmt_l_j, { 0x0 } | |
143 | }, | |
144 | /* l.jal ${abs-26} */ | |
145 | { | |
146 | { 0, 0, 0, 0 }, | |
147 | { { MNEM, ' ', OP (ABS_26), 0 } }, | |
148 | & ifmt_l_j, { 0x4000000 } | |
149 | }, | |
150 | /* l.jr $rA */ | |
151 | { | |
152 | { 0, 0, 0, 0 }, | |
153 | { { MNEM, ' ', OP (RA), 0 } }, | |
154 | & ifmt_l_jr, { 0x14000000 } | |
155 | }, | |
156 | /* l.jalr $rA */ | |
157 | { | |
158 | { 0, 0, 0, 0 }, | |
159 | { { MNEM, ' ', OP (RA), 0 } }, | |
160 | & ifmt_l_jr, { 0x14200000 } | |
161 | }, | |
162 | /* l.bal ${disp-26} */ | |
163 | { | |
164 | { 0, 0, 0, 0 }, | |
165 | { { MNEM, ' ', OP (DISP_26), 0 } }, | |
166 | & ifmt_l_bal, { 0x8000000 } | |
167 | }, | |
168 | /* l.bnf ${disp-26} */ | |
169 | { | |
170 | { 0, 0, 0, 0 }, | |
171 | { { MNEM, ' ', OP (DISP_26), 0 } }, | |
172 | & ifmt_l_bal, { 0xc000000 } | |
173 | }, | |
174 | /* l.bf ${disp-26} */ | |
175 | { | |
176 | { 0, 0, 0, 0 }, | |
177 | { { MNEM, ' ', OP (DISP_26), 0 } }, | |
178 | & ifmt_l_bal, { 0x10000000 } | |
179 | }, | |
180 | /* l.brk ${uimm-16} */ | |
181 | { | |
182 | { 0, 0, 0, 0 }, | |
183 | { { MNEM, ' ', OP (UIMM_16), 0 } }, | |
184 | & ifmt_l_jr, { 0x17000000 } | |
185 | }, | |
186 | /* l.rfe $rA */ | |
187 | { | |
188 | { 0, 0, 0, 0 }, | |
189 | { { MNEM, ' ', OP (RA), 0 } }, | |
190 | & ifmt_l_jr, { 0x14400000 } | |
191 | }, | |
192 | /* l.sys ${uimm-16} */ | |
193 | { | |
194 | { 0, 0, 0, 0 }, | |
195 | { { MNEM, ' ', OP (UIMM_16), 0 } }, | |
196 | & ifmt_l_jr, { 0x16000000 } | |
197 | }, | |
198 | /* l.nop */ | |
199 | { | |
200 | { 0, 0, 0, 0 }, | |
201 | { { MNEM, 0 } }, | |
202 | & ifmt_l_jr, { 0x15000000 } | |
203 | }, | |
204 | /* l.movhi $rD,$hi16 */ | |
205 | { | |
206 | { 0, 0, 0, 0 }, | |
207 | { { MNEM, ' ', OP (RD), ',', OP (HI16), 0 } }, | |
208 | & ifmt_l_movhi, { 0x18000000 } | |
209 | }, | |
210 | /* l.mfsr $rD,$rA */ | |
211 | { | |
212 | { 0, 0, 0, 0 }, | |
213 | { { MNEM, ' ', OP (RD), ',', OP (RA), 0 } }, | |
214 | & ifmt_l_mfsr, { 0x1c000000 } | |
215 | }, | |
216 | /* l.mtsr $rA,$rB */ | |
217 | { | |
218 | { 0, 0, 0, 0 }, | |
219 | { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, | |
220 | & ifmt_l_mtsr, { 0x40000000 } | |
221 | }, | |
222 | /* l.lw $rD,${simm-16}($rA) */ | |
223 | { | |
224 | { 0, 0, 0, 0 }, | |
225 | { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } }, | |
226 | & ifmt_l_lw, { 0x80000000 } | |
227 | }, | |
228 | /* l.lbz $rD,${simm-16}($rA) */ | |
229 | { | |
230 | { 0, 0, 0, 0 }, | |
231 | { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } }, | |
232 | & ifmt_l_lw, { 0x84000000 } | |
233 | }, | |
234 | /* l.lbs $rD,${simm-16}($rA) */ | |
235 | { | |
236 | { 0, 0, 0, 0 }, | |
237 | { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } }, | |
238 | & ifmt_l_lw, { 0x88000000 } | |
239 | }, | |
240 | /* l.lhz $rD,${simm-16}($rA) */ | |
241 | { | |
242 | { 0, 0, 0, 0 }, | |
243 | { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } }, | |
244 | & ifmt_l_lw, { 0x8c000000 } | |
245 | }, | |
246 | /* l.lhs $rD,${simm-16}($rA) */ | |
247 | { | |
248 | { 0, 0, 0, 0 }, | |
249 | { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } }, | |
250 | & ifmt_l_lw, { 0x90000000 } | |
251 | }, | |
252 | /* l.sw ${ui16nc}($rA),$rB */ | |
253 | { | |
254 | { 0, 0, 0, 0 }, | |
255 | { { MNEM, ' ', OP (UI16NC), '(', OP (RA), ')', ',', OP (RB), 0 } }, | |
256 | & ifmt_l_sw, { 0xd4000000 } | |
257 | }, | |
258 | /* l.sb ${ui16nc}($rA),$rB */ | |
259 | { | |
260 | { 0, 0, 0, 0 }, | |
261 | { { MNEM, ' ', OP (UI16NC), '(', OP (RA), ')', ',', OP (RB), 0 } }, | |
262 | & ifmt_l_sw, { 0xd8000000 } | |
263 | }, | |
264 | /* l.sh ${ui16nc}($rA),$rB */ | |
265 | { | |
266 | { 0, 0, 0, 0 }, | |
267 | { { MNEM, ' ', OP (UI16NC), '(', OP (RA), ')', ',', OP (RB), 0 } }, | |
268 | & ifmt_l_sw, { 0xdc000000 } | |
269 | }, | |
270 | /* l.sll $rD,$rA,$rB */ | |
271 | { | |
272 | { 0, 0, 0, 0 }, | |
273 | { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, | |
274 | & ifmt_l_sll, { 0xe0000008 } | |
275 | }, | |
276 | /* l.slli $rD,$rA,${uimm-5} */ | |
277 | { | |
278 | { 0, 0, 0, 0 }, | |
279 | { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM_5), 0 } }, | |
280 | & ifmt_l_slli, { 0xb4000000 } | |
281 | }, | |
282 | /* l.srl $rD,$rA,$rB */ | |
283 | { | |
284 | { 0, 0, 0, 0 }, | |
285 | { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, | |
286 | & ifmt_l_sll, { 0xe0000028 } | |
287 | }, | |
288 | /* l.srli $rD,$rA,${uimm-5} */ | |
289 | { | |
290 | { 0, 0, 0, 0 }, | |
291 | { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM_5), 0 } }, | |
292 | & ifmt_l_slli, { 0xb4000020 } | |
293 | }, | |
294 | /* l.sra $rD,$rA,$rB */ | |
295 | { | |
296 | { 0, 0, 0, 0 }, | |
297 | { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, | |
298 | & ifmt_l_sll, { 0xe0000048 } | |
299 | }, | |
300 | /* l.srai $rD,$rA,${uimm-5} */ | |
301 | { | |
302 | { 0, 0, 0, 0 }, | |
303 | { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM_5), 0 } }, | |
304 | & ifmt_l_slli, { 0xb4000040 } | |
305 | }, | |
306 | /* l.ror $rD,$rA,$rB */ | |
307 | { | |
308 | { 0, 0, 0, 0 }, | |
309 | { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, | |
310 | & ifmt_l_sll, { 0xe0000088 } | |
311 | }, | |
312 | /* l.rori $rD,$rA,${uimm-5} */ | |
313 | { | |
314 | { 0, 0, 0, 0 }, | |
315 | { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM_5), 0 } }, | |
316 | & ifmt_l_slli, { 0xb4000080 } | |
317 | }, | |
318 | /* l.add $rD,$rA,$rB */ | |
319 | { | |
320 | { 0, 0, 0, 0 }, | |
321 | { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, | |
322 | & ifmt_l_add, { 0xe0000000 } | |
323 | }, | |
324 | /* l.addi $rD,$rA,$lo16 */ | |
325 | { | |
326 | { 0, 0, 0, 0 }, | |
327 | { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } }, | |
328 | & ifmt_l_addi, { 0x94000000 } | |
329 | }, | |
330 | /* l.sub $rD,$rA,$rB */ | |
331 | { | |
332 | { 0, 0, 0, 0 }, | |
333 | { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, | |
334 | & ifmt_l_add, { 0xe0000002 } | |
335 | }, | |
336 | /* l.subi $rD,$rA,$lo16 */ | |
337 | { | |
338 | { 0, 0, 0, 0 }, | |
339 | { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } }, | |
340 | & ifmt_l_addi, { 0x9c000000 } | |
341 | }, | |
342 | /* l.and $rD,$rA,$rB */ | |
343 | { | |
344 | { 0, 0, 0, 0 }, | |
345 | { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, | |
346 | & ifmt_l_add, { 0xe0000003 } | |
347 | }, | |
348 | /* l.andi $rD,$rA,$lo16 */ | |
349 | { | |
350 | { 0, 0, 0, 0 }, | |
351 | { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } }, | |
352 | & ifmt_l_addi, { 0xa0000000 } | |
353 | }, | |
354 | /* l.or $rD,$rA,$rB */ | |
355 | { | |
356 | { 0, 0, 0, 0 }, | |
357 | { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, | |
358 | & ifmt_l_add, { 0xe0000004 } | |
359 | }, | |
360 | /* l.ori $rD,$rA,$lo16 */ | |
361 | { | |
362 | { 0, 0, 0, 0 }, | |
363 | { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } }, | |
364 | & ifmt_l_addi, { 0xa4000000 } | |
365 | }, | |
366 | /* l.xor $rD,$rA,$rB */ | |
367 | { | |
368 | { 0, 0, 0, 0 }, | |
369 | { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, | |
370 | & ifmt_l_add, { 0xe0000005 } | |
371 | }, | |
372 | /* l.xori $rD,$rA,$lo16 */ | |
373 | { | |
374 | { 0, 0, 0, 0 }, | |
375 | { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } }, | |
376 | & ifmt_l_addi, { 0xa8000000 } | |
377 | }, | |
378 | /* l.mul $rD,$rA,$rB */ | |
379 | { | |
380 | { 0, 0, 0, 0 }, | |
381 | { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, | |
382 | & ifmt_l_add, { 0xe0000006 } | |
383 | }, | |
384 | /* l.muli $rD,$rA,$lo16 */ | |
385 | { | |
386 | { 0, 0, 0, 0 }, | |
387 | { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } }, | |
388 | & ifmt_l_addi, { 0xac000000 } | |
389 | }, | |
390 | /* l.div $rD,$rA,$rB */ | |
391 | { | |
392 | { 0, 0, 0, 0 }, | |
393 | { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, | |
394 | & ifmt_l_add, { 0xe0000009 } | |
395 | }, | |
396 | /* l.divu $rD,$rA,$rB */ | |
397 | { | |
398 | { 0, 0, 0, 0 }, | |
399 | { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, | |
400 | & ifmt_l_add, { 0xe000000a } | |
401 | }, | |
402 | /* l.sfgts $rA,$rB */ | |
403 | { | |
404 | { 0, 0, 0, 0 }, | |
405 | { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, | |
406 | & ifmt_l_sfgts, { 0xe4c00000 } | |
407 | }, | |
408 | /* l.sfgtu $rA,$rB */ | |
409 | { | |
410 | { 0, 0, 0, 0 }, | |
411 | { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, | |
412 | & ifmt_l_sfgts, { 0xe4400000 } | |
413 | }, | |
414 | /* l.sfges $rA,$rB */ | |
415 | { | |
416 | { 0, 0, 0, 0 }, | |
417 | { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, | |
418 | & ifmt_l_sfgts, { 0xe4e00000 } | |
419 | }, | |
420 | /* l.sfgeu $rA,$rB */ | |
421 | { | |
422 | { 0, 0, 0, 0 }, | |
423 | { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, | |
424 | & ifmt_l_sfgts, { 0xe4600000 } | |
425 | }, | |
426 | /* l.sflts $rA,$rB */ | |
427 | { | |
428 | { 0, 0, 0, 0 }, | |
429 | { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, | |
430 | & ifmt_l_sfgts, { 0xe5000000 } | |
431 | }, | |
432 | /* l.sfltu $rA,$rB */ | |
433 | { | |
434 | { 0, 0, 0, 0 }, | |
435 | { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, | |
436 | & ifmt_l_sfgts, { 0xe4800000 } | |
437 | }, | |
438 | /* l.sfles $rA,$rB */ | |
439 | { | |
440 | { 0, 0, 0, 0 }, | |
441 | { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, | |
442 | & ifmt_l_sfgts, { 0xe5200000 } | |
443 | }, | |
444 | /* l.sfleu $rA,$rB */ | |
445 | { | |
446 | { 0, 0, 0, 0 }, | |
447 | { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, | |
448 | & ifmt_l_sfgts, { 0xe4a00000 } | |
449 | }, | |
450 | /* l.sfgtsi $rA,${simm-16} */ | |
451 | { | |
452 | { 0, 0, 0, 0 }, | |
453 | { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } }, | |
454 | & ifmt_l_sfgtsi, { 0xb8c00000 } | |
455 | }, | |
456 | /* l.sfgtui $rA,${uimm-16} */ | |
457 | { | |
458 | { 0, 0, 0, 0 }, | |
459 | { { MNEM, ' ', OP (RA), ',', OP (UIMM_16), 0 } }, | |
460 | & ifmt_l_sfgtui, { 0xb8400000 } | |
461 | }, | |
462 | /* l.sfgesi $rA,${simm-16} */ | |
463 | { | |
464 | { 0, 0, 0, 0 }, | |
465 | { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } }, | |
466 | & ifmt_l_sfgtsi, { 0xb8e00000 } | |
467 | }, | |
468 | /* l.sfgeui $rA,${uimm-16} */ | |
469 | { | |
470 | { 0, 0, 0, 0 }, | |
471 | { { MNEM, ' ', OP (RA), ',', OP (UIMM_16), 0 } }, | |
472 | & ifmt_l_sfgtui, { 0xb8600000 } | |
473 | }, | |
474 | /* l.sfltsi $rA,${simm-16} */ | |
475 | { | |
476 | { 0, 0, 0, 0 }, | |
477 | { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } }, | |
478 | & ifmt_l_sfgtsi, { 0xb9000000 } | |
479 | }, | |
480 | /* l.sfltui $rA,${uimm-16} */ | |
481 | { | |
482 | { 0, 0, 0, 0 }, | |
483 | { { MNEM, ' ', OP (RA), ',', OP (UIMM_16), 0 } }, | |
484 | & ifmt_l_sfgtui, { 0xb8800000 } | |
485 | }, | |
486 | /* l.sflesi $rA,${simm-16} */ | |
487 | { | |
488 | { 0, 0, 0, 0 }, | |
489 | { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } }, | |
490 | & ifmt_l_sfgtsi, { 0xb9200000 } | |
491 | }, | |
492 | /* l.sfleui $rA,${uimm-16} */ | |
493 | { | |
494 | { 0, 0, 0, 0 }, | |
495 | { { MNEM, ' ', OP (RA), ',', OP (UIMM_16), 0 } }, | |
496 | & ifmt_l_sfgtui, { 0xb8a00000 } | |
497 | }, | |
498 | /* l.sfeq $rA,$rB */ | |
499 | { | |
500 | { 0, 0, 0, 0 }, | |
501 | { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, | |
502 | & ifmt_l_sfgts, { 0xe4000000 } | |
503 | }, | |
504 | /* l.sfeqi $rA,${simm-16} */ | |
505 | { | |
506 | { 0, 0, 0, 0 }, | |
507 | { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } }, | |
508 | & ifmt_l_sfgtsi, { 0xb8000000 } | |
509 | }, | |
510 | /* l.sfne $rA,$rB */ | |
511 | { | |
512 | { 0, 0, 0, 0 }, | |
513 | { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, | |
514 | & ifmt_l_sfgts, { 0xe4200000 } | |
515 | }, | |
516 | /* l.sfnei $rA,${simm-16} */ | |
517 | { | |
518 | { 0, 0, 0, 0 }, | |
519 | { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } }, | |
520 | & ifmt_l_sfgtsi, { 0xb8200000 } | |
521 | }, | |
522 | }; | |
523 | ||
524 | #undef A | |
525 | #undef OPERAND | |
526 | #undef MNEM | |
527 | #undef OP | |
528 | ||
529 | /* Formats for ALIAS macro-insns. */ | |
530 | ||
531 | #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) | |
532 | #define F(f) & openrisc_cgen_ifld_table[OPENRISC_##f] | |
533 | #else | |
534 | #define F(f) & openrisc_cgen_ifld_table[OPENRISC_/**/f] | |
535 | #endif | |
536 | static const CGEN_IFMT ifmt_l_ret = { | |
537 | 32, 32, 0xffffffff, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP3) }, { F (F_OP4) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } } | |
538 | }; | |
539 | ||
540 | #undef F | |
541 | ||
542 | /* Each non-simple macro entry points to an array of expansion possibilities. */ | |
543 | ||
544 | #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) | |
545 | #define A(a) (1 << CGEN_INSN_##a) | |
546 | #else | |
547 | #define A(a) (1 << CGEN_INSN_/**/a) | |
548 | #endif | |
549 | #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) | |
550 | #define OPERAND(op) OPENRISC_OPERAND_##op | |
551 | #else | |
552 | #define OPERAND(op) OPENRISC_OPERAND_/**/op | |
553 | #endif | |
554 | #define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */ | |
555 | #define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field)) | |
556 | ||
557 | /* The macro instruction table. */ | |
558 | ||
559 | static const CGEN_IBASE openrisc_cgen_macro_insn_table[] = | |
560 | { | |
561 | /* l.ret */ | |
562 | { | |
563 | -1, "l-ret", "l.ret", 32, | |
564 | { 0|A(ALIAS), { (1<<MACH_BASE) } } | |
565 | }, | |
566 | }; | |
567 | ||
568 | /* The macro instruction opcode table. */ | |
569 | ||
570 | static const CGEN_OPCODE openrisc_cgen_macro_insn_opcode_table[] = | |
571 | { | |
572 | /* l.ret */ | |
573 | { | |
574 | { 0, 0, 0, 0 }, | |
575 | { { MNEM, 0 } }, | |
576 | & ifmt_l_ret, { 0x140b0000 } | |
577 | }, | |
578 | }; | |
579 | ||
580 | #undef A | |
581 | #undef OPERAND | |
582 | #undef MNEM | |
583 | #undef OP | |
584 | ||
585 | #ifndef CGEN_ASM_HASH_P | |
586 | #define CGEN_ASM_HASH_P(insn) 1 | |
587 | #endif | |
588 | ||
589 | #ifndef CGEN_DIS_HASH_P | |
590 | #define CGEN_DIS_HASH_P(insn) 1 | |
591 | #endif | |
592 | ||
593 | /* Return non-zero if INSN is to be added to the hash table. | |
594 | Targets are free to override CGEN_{ASM,DIS}_HASH_P in the .opc file. */ | |
595 | ||
596 | static int | |
597 | asm_hash_insn_p (insn) | |
fc05c67f | 598 | const CGEN_INSN *insn ATTRIBUTE_UNUSED; |
87e6d782 NC |
599 | { |
600 | return CGEN_ASM_HASH_P (insn); | |
601 | } | |
602 | ||
603 | static int | |
604 | dis_hash_insn_p (insn) | |
605 | const CGEN_INSN *insn; | |
606 | { | |
607 | /* If building the hash table and the NO-DIS attribute is present, | |
608 | ignore. */ | |
609 | if (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_NO_DIS)) | |
610 | return 0; | |
611 | return CGEN_DIS_HASH_P (insn); | |
612 | } | |
613 | ||
614 | #ifndef CGEN_ASM_HASH | |
615 | #define CGEN_ASM_HASH_SIZE 127 | |
616 | #ifdef CGEN_MNEMONIC_OPERANDS | |
617 | #define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE) | |
618 | #else | |
619 | #define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE) /*FIXME*/ | |
620 | #endif | |
621 | #endif | |
622 | ||
623 | /* It doesn't make much sense to provide a default here, | |
624 | but while this is under development we do. | |
625 | BUFFER is a pointer to the bytes of the insn, target order. | |
626 | VALUE is the first base_insn_bitsize bits as an int in host order. */ | |
627 | ||
628 | #ifndef CGEN_DIS_HASH | |
629 | #define CGEN_DIS_HASH_SIZE 256 | |
630 | #define CGEN_DIS_HASH(buf, value) (*(unsigned char *) (buf)) | |
631 | #endif | |
632 | ||
633 | /* The result is the hash value of the insn. | |
634 | Targets are free to override CGEN_{ASM,DIS}_HASH in the .opc file. */ | |
635 | ||
636 | static unsigned int | |
637 | asm_hash_insn (mnem) | |
638 | const char * mnem; | |
639 | { | |
640 | return CGEN_ASM_HASH (mnem); | |
641 | } | |
642 | ||
643 | /* BUF is a pointer to the bytes of the insn, target order. | |
644 | VALUE is the first base_insn_bitsize bits as an int in host order. */ | |
645 | ||
646 | static unsigned int | |
647 | dis_hash_insn (buf, value) | |
648 | const char * buf; | |
fc05c67f | 649 | CGEN_INSN_INT value ATTRIBUTE_UNUSED; |
87e6d782 NC |
650 | { |
651 | return CGEN_DIS_HASH (buf, value); | |
652 | } | |
653 | ||
654 | /* Set the recorded length of the insn in the CGEN_FIELDS struct. */ | |
655 | ||
656 | static void | |
657 | set_fields_bitsize (fields, size) | |
658 | CGEN_FIELDS *fields; | |
659 | int size; | |
660 | { | |
661 | CGEN_FIELDS_BITSIZE (fields) = size; | |
662 | } | |
663 | ||
664 | /* Function to call before using the operand instance table. | |
665 | This plugs the opcode entries and macro instructions into the cpu table. */ | |
666 | ||
667 | void | |
668 | openrisc_cgen_init_opcode_table (cd) | |
669 | CGEN_CPU_DESC cd; | |
670 | { | |
671 | int i; | |
672 | int num_macros = (sizeof (openrisc_cgen_macro_insn_table) / | |
673 | sizeof (openrisc_cgen_macro_insn_table[0])); | |
674 | const CGEN_IBASE *ib = & openrisc_cgen_macro_insn_table[0]; | |
675 | const CGEN_OPCODE *oc = & openrisc_cgen_macro_insn_opcode_table[0]; | |
676 | CGEN_INSN *insns = (CGEN_INSN *) xmalloc (num_macros * sizeof (CGEN_INSN)); | |
677 | memset (insns, 0, num_macros * sizeof (CGEN_INSN)); | |
678 | for (i = 0; i < num_macros; ++i) | |
679 | { | |
680 | insns[i].base = &ib[i]; | |
681 | insns[i].opcode = &oc[i]; | |
fc7bc883 | 682 | openrisc_cgen_build_insn_regex (& insns[i]); |
87e6d782 NC |
683 | } |
684 | cd->macro_insn_table.init_entries = insns; | |
685 | cd->macro_insn_table.entry_size = sizeof (CGEN_IBASE); | |
686 | cd->macro_insn_table.num_init_entries = num_macros; | |
687 | ||
688 | oc = & openrisc_cgen_insn_opcode_table[0]; | |
689 | insns = (CGEN_INSN *) cd->insn_table.init_entries; | |
690 | for (i = 0; i < MAX_INSNS; ++i) | |
fc7bc883 RH |
691 | { |
692 | insns[i].opcode = &oc[i]; | |
693 | openrisc_cgen_build_insn_regex (& insns[i]); | |
694 | } | |
87e6d782 NC |
695 | |
696 | cd->sizeof_fields = sizeof (CGEN_FIELDS); | |
697 | cd->set_fields_bitsize = set_fields_bitsize; | |
698 | ||
699 | cd->asm_hash_p = asm_hash_insn_p; | |
700 | cd->asm_hash = asm_hash_insn; | |
701 | cd->asm_hash_size = CGEN_ASM_HASH_SIZE; | |
702 | ||
703 | cd->dis_hash_p = dis_hash_insn_p; | |
704 | cd->dis_hash = dis_hash_insn; | |
705 | cd->dis_hash_size = CGEN_DIS_HASH_SIZE; | |
706 | } |