m32c-asm.c revision 1.1.1.3 1 1.1 christos /* Assembler interface for targets using CGEN. -*- C -*-
2 1.1 christos CGEN: Cpu tools GENerator
3 1.1 christos
4 1.1 christos THIS FILE IS MACHINE GENERATED WITH CGEN.
5 1.1 christos - the resultant file is machine generated, cgen-asm.in isn't
6 1.1 christos
7 1.1.1.3 christos Copyright (C) 1996-2016 Free Software Foundation, Inc.
8 1.1 christos
9 1.1 christos This file is part of libopcodes.
10 1.1 christos
11 1.1 christos This library is free software; you can redistribute it and/or modify
12 1.1 christos it under the terms of the GNU General Public License as published by
13 1.1 christos the Free Software Foundation; either version 3, or (at your option)
14 1.1 christos any later version.
15 1.1 christos
16 1.1 christos It is distributed in the hope that it will be useful, but WITHOUT
17 1.1 christos ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 1.1 christos or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
19 1.1 christos License for more details.
20 1.1 christos
21 1.1 christos You should have received a copy of the GNU General Public License
22 1.1 christos along with this program; if not, write to the Free Software Foundation, Inc.,
23 1.1 christos 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
24 1.1 christos
25 1.1 christos
26 1.1 christos /* ??? Eventually more and more of this stuff can go to cpu-independent files.
27 1.1 christos Keep that in mind. */
28 1.1 christos
29 1.1 christos #include "sysdep.h"
30 1.1 christos #include <stdio.h>
31 1.1 christos #include "ansidecl.h"
32 1.1 christos #include "bfd.h"
33 1.1 christos #include "symcat.h"
34 1.1 christos #include "m32c-desc.h"
35 1.1 christos #include "m32c-opc.h"
36 1.1 christos #include "opintl.h"
37 1.1 christos #include "xregex.h"
38 1.1 christos #include "libiberty.h"
39 1.1 christos #include "safe-ctype.h"
40 1.1 christos
41 1.1 christos #undef min
42 1.1 christos #define min(a,b) ((a) < (b) ? (a) : (b))
43 1.1 christos #undef max
44 1.1 christos #define max(a,b) ((a) > (b) ? (a) : (b))
45 1.1 christos
46 1.1 christos static const char * parse_insn_normal
47 1.1 christos (CGEN_CPU_DESC, const CGEN_INSN *, const char **, CGEN_FIELDS *);
48 1.1 christos
49 1.1 christos /* -- assembler routines inserted here. */
51 1.1 christos
52 1.1 christos /* -- asm.c */
53 1.1 christos #include "safe-ctype.h"
54 1.1 christos
55 1.1 christos #define MACH_M32C 5 /* Must match md_begin. */
56 1.1 christos
57 1.1 christos static int
58 1.1 christos m32c_cgen_isa_register (const char **strp)
59 1.1 christos {
60 1.1 christos int u;
61 1.1.1.3 christos const char *s = *strp;
62 1.1 christos static char * m32c_register_names [] =
63 1.1 christos {
64 1.1 christos "r0", "r1", "r2", "r3", "r0l", "r0h", "r1l", "r1h",
65 1.1 christos "a0", "a1", "r2r0", "r3r1", "sp", "fb", "dct0", "dct1", "flg", "svf",
66 1.1 christos "drc0", "drc1", "dmd0", "dmd1", "intb", "svp", "vct", "isp", "dma0",
67 1.1 christos "dma1", "dra0", "dra1", "dsa0", "dsa1", 0
68 1.1.1.3 christos };
69 1.1 christos
70 1.1 christos for (u = 0; m32c_register_names[u]; u++)
71 1.1 christos {
72 1.1 christos int len = strlen (m32c_register_names[u]);
73 1.1 christos
74 1.1 christos if (memcmp (m32c_register_names[u], s, len) == 0
75 1.1 christos && (s[len] == 0 || ! ISALNUM (s[len])))
76 1.1 christos return 1;
77 1.1 christos }
78 1.1 christos return 0;
79 1.1 christos }
80 1.1 christos
81 1.1 christos #define PARSE_UNSIGNED \
82 1.1 christos do \
83 1.1 christos { \
84 1.1 christos /* Don't successfully parse literals beginning with '['. */ \
85 1.1 christos if (**strp == '[') \
86 1.1 christos return "Invalid literal"; /* Anything -- will not be seen. */ \
87 1.1 christos \
88 1.1 christos errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, & value);\
89 1.1 christos if (errmsg) \
90 1.1 christos return errmsg; \
91 1.1 christos } \
92 1.1 christos while (0)
93 1.1 christos
94 1.1 christos #define PARSE_SIGNED \
95 1.1 christos do \
96 1.1 christos { \
97 1.1 christos /* Don't successfully parse literals beginning with '['. */ \
98 1.1 christos if (**strp == '[') \
99 1.1 christos return "Invalid literal"; /* Anything -- will not be seen. */ \
100 1.1 christos \
101 1.1 christos errmsg = cgen_parse_signed_integer (cd, strp, opindex, & value); \
102 1.1 christos if (errmsg) \
103 1.1 christos return errmsg; \
104 1.1 christos } \
105 1.1 christos while (0)
106 1.1 christos
107 1.1 christos static const char *
108 1.1 christos parse_unsigned6 (CGEN_CPU_DESC cd, const char **strp,
109 1.1 christos int opindex, unsigned long *valuep)
110 1.1 christos {
111 1.1 christos const char *errmsg = 0;
112 1.1 christos unsigned long value;
113 1.1 christos
114 1.1 christos PARSE_UNSIGNED;
115 1.1 christos
116 1.1 christos if (value > 0x3f)
117 1.1 christos return _("imm:6 immediate is out of range");
118 1.1 christos
119 1.1 christos *valuep = value;
120 1.1 christos return 0;
121 1.1 christos }
122 1.1 christos
123 1.1 christos static const char *
124 1.1 christos parse_unsigned8 (CGEN_CPU_DESC cd, const char **strp,
125 1.1 christos int opindex, unsigned long *valuep)
126 1.1 christos {
127 1.1 christos const char *errmsg = 0;
128 1.1 christos unsigned long value = 0;
129 1.1 christos long have_zero = 0;
130 1.1 christos
131 1.1 christos if (strncasecmp (*strp, "%dsp8(", 6) == 0)
132 1.1 christos {
133 1.1 christos enum cgen_parse_operand_result result_type;
134 1.1 christos bfd_vma val;
135 1.1 christos
136 1.1 christos *strp += 6;
137 1.1 christos errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_8,
138 1.1 christos & result_type, & val);
139 1.1 christos if (**strp != ')')
140 1.1 christos return _("missing `)'");
141 1.1 christos (*strp) ++;
142 1.1 christos
143 1.1 christos if (errmsg == NULL
144 1.1 christos && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
145 1.1 christos return _("%dsp8() takes a symbolic address, not a number");
146 1.1 christos
147 1.1 christos value = val;
148 1.1 christos *valuep = value;
149 1.1 christos return errmsg;
150 1.1 christos }
151 1.1.1.3 christos
152 1.1 christos if (strncmp (*strp, "0x0", 3) == 0
153 1.1 christos || (**strp == '0' && *(*strp + 1) != 'x'))
154 1.1 christos have_zero = 1;
155 1.1 christos
156 1.1 christos PARSE_UNSIGNED;
157 1.1 christos
158 1.1 christos if (value > 0xff)
159 1.1 christos return _("dsp:8 immediate is out of range");
160 1.1 christos
161 1.1 christos /* If this field may require a relocation then use larger dsp16. */
162 1.1 christos if (! have_zero && value == 0)
163 1.1 christos return _("dsp:8 immediate is out of range");
164 1.1 christos
165 1.1 christos *valuep = value;
166 1.1 christos return 0;
167 1.1 christos }
168 1.1 christos
169 1.1 christos static const char *
170 1.1 christos parse_signed4 (CGEN_CPU_DESC cd, const char **strp,
171 1.1 christos int opindex, signed long *valuep)
172 1.1 christos {
173 1.1 christos const char *errmsg = 0;
174 1.1 christos signed long value;
175 1.1 christos long have_zero = 0;
176 1.1.1.3 christos
177 1.1 christos if (strncmp (*strp, "0x0", 3) == 0
178 1.1 christos || (**strp == '0' && *(*strp + 1) != 'x'))
179 1.1 christos have_zero = 1;
180 1.1 christos
181 1.1 christos PARSE_SIGNED;
182 1.1 christos
183 1.1 christos if (value < -8 || value > 7)
184 1.1 christos return _("Immediate is out of range -8 to 7");
185 1.1 christos
186 1.1 christos /* If this field may require a relocation then use larger dsp16. */
187 1.1 christos if (! have_zero && value == 0)
188 1.1 christos return _("Immediate is out of range -8 to 7");
189 1.1 christos
190 1.1 christos *valuep = value;
191 1.1 christos return 0;
192 1.1 christos }
193 1.1 christos
194 1.1 christos static const char *
195 1.1 christos parse_signed4n (CGEN_CPU_DESC cd, const char **strp,
196 1.1 christos int opindex, signed long *valuep)
197 1.1 christos {
198 1.1 christos const char *errmsg = 0;
199 1.1 christos signed long value;
200 1.1 christos long have_zero = 0;
201 1.1.1.3 christos
202 1.1 christos if (strncmp (*strp, "0x0", 3) == 0
203 1.1 christos || (**strp == '0' && *(*strp + 1) != 'x'))
204 1.1 christos have_zero = 1;
205 1.1 christos
206 1.1 christos PARSE_SIGNED;
207 1.1 christos
208 1.1 christos if (value < -7 || value > 8)
209 1.1 christos return _("Immediate is out of range -7 to 8");
210 1.1 christos
211 1.1 christos /* If this field may require a relocation then use larger dsp16. */
212 1.1 christos if (! have_zero && value == 0)
213 1.1 christos return _("Immediate is out of range -7 to 8");
214 1.1 christos
215 1.1 christos *valuep = -value;
216 1.1 christos return 0;
217 1.1 christos }
218 1.1 christos
219 1.1 christos static const char *
220 1.1 christos parse_signed8 (CGEN_CPU_DESC cd, const char **strp,
221 1.1 christos int opindex, signed long *valuep)
222 1.1 christos {
223 1.1 christos const char *errmsg = 0;
224 1.1 christos signed long value = 0;
225 1.1 christos
226 1.1 christos if (strncasecmp (*strp, "%hi8(", 5) == 0)
227 1.1 christos {
228 1.1 christos enum cgen_parse_operand_result result_type;
229 1.1 christos bfd_vma val;
230 1.1 christos
231 1.1 christos *strp += 5;
232 1.1 christos errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_M32C_HI8,
233 1.1 christos & result_type, & val);
234 1.1 christos if (**strp != ')')
235 1.1 christos return _("missing `)'");
236 1.1 christos (*strp) ++;
237 1.1 christos
238 1.1 christos if (errmsg == NULL
239 1.1 christos && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
240 1.1 christos val >>= 16;
241 1.1 christos
242 1.1 christos value = val;
243 1.1 christos *valuep = value;
244 1.1 christos return errmsg;
245 1.1 christos }
246 1.1 christos
247 1.1 christos PARSE_SIGNED;
248 1.1 christos
249 1.1 christos if (value <= 255 && value > 127)
250 1.1 christos value -= 0x100;
251 1.1 christos
252 1.1 christos if (value < -128 || value > 127)
253 1.1 christos return _("dsp:8 immediate is out of range");
254 1.1 christos
255 1.1 christos *valuep = value;
256 1.1 christos return 0;
257 1.1 christos }
258 1.1 christos
259 1.1 christos static const char *
260 1.1 christos parse_unsigned16 (CGEN_CPU_DESC cd, const char **strp,
261 1.1 christos int opindex, unsigned long *valuep)
262 1.1 christos {
263 1.1 christos const char *errmsg = 0;
264 1.1 christos unsigned long value = 0;
265 1.1 christos long have_zero = 0;
266 1.1 christos
267 1.1 christos if (strncasecmp (*strp, "%dsp16(", 7) == 0)
268 1.1 christos {
269 1.1 christos enum cgen_parse_operand_result result_type;
270 1.1 christos bfd_vma val;
271 1.1 christos
272 1.1 christos *strp += 7;
273 1.1 christos errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_16,
274 1.1 christos & result_type, & val);
275 1.1 christos if (**strp != ')')
276 1.1 christos return _("missing `)'");
277 1.1 christos (*strp) ++;
278 1.1 christos
279 1.1 christos if (errmsg == NULL
280 1.1 christos && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
281 1.1 christos return _("%dsp16() takes a symbolic address, not a number");
282 1.1 christos
283 1.1 christos value = val;
284 1.1 christos *valuep = value;
285 1.1 christos return errmsg;
286 1.1 christos }
287 1.1 christos
288 1.1 christos /* Don't successfully parse literals beginning with '['. */
289 1.1 christos if (**strp == '[')
290 1.1 christos return "Invalid literal"; /* Anything -- will not be seen. */
291 1.1 christos
292 1.1 christos /* Don't successfully parse register names. */
293 1.1 christos if (m32c_cgen_isa_register (strp))
294 1.1 christos return "Invalid literal"; /* Anything -- will not be seen. */
295 1.1.1.3 christos
296 1.1 christos if (strncmp (*strp, "0x0", 3) == 0
297 1.1 christos || (**strp == '0' && *(*strp + 1) != 'x'))
298 1.1.1.3 christos have_zero = 1;
299 1.1 christos
300 1.1 christos errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, & value);
301 1.1 christos if (errmsg)
302 1.1 christos return errmsg;
303 1.1 christos
304 1.1 christos if (value > 0xffff)
305 1.1 christos return _("dsp:16 immediate is out of range");
306 1.1 christos
307 1.1 christos /* If this field may require a relocation then use larger dsp24. */
308 1.1 christos if (cd->machs == MACH_M32C && ! have_zero && value == 0
309 1.1 christos && (strncmp (*strp, "[a", 2) == 0
310 1.1 christos || **strp == ','
311 1.1 christos || **strp == 0))
312 1.1 christos return _("dsp:16 immediate is out of range");
313 1.1 christos
314 1.1 christos *valuep = value;
315 1.1 christos return 0;
316 1.1 christos }
317 1.1 christos
318 1.1 christos static const char *
319 1.1 christos parse_signed16 (CGEN_CPU_DESC cd, const char **strp,
320 1.1 christos int opindex, signed long *valuep)
321 1.1 christos {
322 1.1 christos const char *errmsg = 0;
323 1.1 christos signed long value = 0;
324 1.1 christos
325 1.1 christos if (strncasecmp (*strp, "%lo16(", 6) == 0)
326 1.1 christos {
327 1.1 christos enum cgen_parse_operand_result result_type;
328 1.1 christos bfd_vma val;
329 1.1 christos
330 1.1 christos *strp += 6;
331 1.1 christos errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_LO16,
332 1.1 christos & result_type, & val);
333 1.1 christos if (**strp != ')')
334 1.1 christos return _("missing `)'");
335 1.1 christos (*strp) ++;
336 1.1 christos
337 1.1 christos if (errmsg == NULL
338 1.1 christos && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
339 1.1 christos val &= 0xffff;
340 1.1 christos
341 1.1 christos value = val;
342 1.1 christos *valuep = value;
343 1.1 christos return errmsg;
344 1.1 christos }
345 1.1 christos
346 1.1 christos if (strncasecmp (*strp, "%hi16(", 6) == 0)
347 1.1 christos {
348 1.1 christos enum cgen_parse_operand_result result_type;
349 1.1 christos bfd_vma val;
350 1.1 christos
351 1.1 christos *strp += 6;
352 1.1 christos errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_HI16,
353 1.1 christos & result_type, & val);
354 1.1 christos if (**strp != ')')
355 1.1 christos return _("missing `)'");
356 1.1 christos (*strp) ++;
357 1.1 christos
358 1.1 christos if (errmsg == NULL
359 1.1 christos && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
360 1.1 christos val >>= 16;
361 1.1 christos
362 1.1 christos value = val;
363 1.1 christos *valuep = value;
364 1.1 christos return errmsg;
365 1.1 christos }
366 1.1 christos
367 1.1 christos PARSE_SIGNED;
368 1.1 christos
369 1.1 christos if (value <= 65535 && value > 32767)
370 1.1 christos value -= 0x10000;
371 1.1 christos
372 1.1 christos if (value < -32768 || value > 32767)
373 1.1 christos return _("dsp:16 immediate is out of range");
374 1.1 christos
375 1.1 christos *valuep = value;
376 1.1 christos return 0;
377 1.1 christos }
378 1.1 christos
379 1.1 christos static const char *
380 1.1 christos parse_unsigned20 (CGEN_CPU_DESC cd, const char **strp,
381 1.1 christos int opindex, unsigned long *valuep)
382 1.1 christos {
383 1.1 christos const char *errmsg = 0;
384 1.1.1.3 christos unsigned long value;
385 1.1 christos
386 1.1 christos /* Don't successfully parse literals beginning with '['. */
387 1.1 christos if (**strp == '[')
388 1.1 christos return "Invalid literal"; /* Anything -- will not be seen. */
389 1.1 christos
390 1.1 christos /* Don't successfully parse register names. */
391 1.1 christos if (m32c_cgen_isa_register (strp))
392 1.1 christos return "Invalid literal"; /* Anything -- will not be seen. */
393 1.1 christos
394 1.1 christos errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, & value);
395 1.1 christos if (errmsg)
396 1.1 christos return errmsg;
397 1.1 christos
398 1.1 christos if (value > 0xfffff)
399 1.1 christos return _("dsp:20 immediate is out of range");
400 1.1 christos
401 1.1 christos *valuep = value;
402 1.1 christos return 0;
403 1.1 christos }
404 1.1 christos
405 1.1 christos static const char *
406 1.1 christos parse_unsigned24 (CGEN_CPU_DESC cd, const char **strp,
407 1.1 christos int opindex, unsigned long *valuep)
408 1.1 christos {
409 1.1 christos const char *errmsg = 0;
410 1.1.1.3 christos unsigned long value;
411 1.1 christos
412 1.1 christos /* Don't successfully parse literals beginning with '['. */
413 1.1 christos if (**strp == '[')
414 1.1 christos return "Invalid literal"; /* Anything -- will not be seen. */
415 1.1 christos
416 1.1 christos /* Don't successfully parse register names. */
417 1.1 christos if (m32c_cgen_isa_register (strp))
418 1.1 christos return "Invalid literal"; /* Anything -- will not be seen. */
419 1.1 christos
420 1.1 christos errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, & value);
421 1.1 christos if (errmsg)
422 1.1 christos return errmsg;
423 1.1 christos
424 1.1 christos if (value > 0xffffff)
425 1.1 christos return _("dsp:24 immediate is out of range");
426 1.1 christos
427 1.1 christos *valuep = value;
428 1.1 christos return 0;
429 1.1 christos }
430 1.1 christos
431 1.1 christos /* This should only be used for #imm->reg. */
432 1.1 christos static const char *
433 1.1 christos parse_signed24 (CGEN_CPU_DESC cd, const char **strp,
434 1.1 christos int opindex, signed long *valuep)
435 1.1 christos {
436 1.1 christos const char *errmsg = 0;
437 1.1 christos signed long value;
438 1.1 christos
439 1.1 christos PARSE_SIGNED;
440 1.1 christos
441 1.1 christos if (value <= 0xffffff && value > 0x7fffff)
442 1.1 christos value -= 0x1000000;
443 1.1 christos
444 1.1 christos if (value > 0xffffff)
445 1.1 christos return _("dsp:24 immediate is out of range");
446 1.1 christos
447 1.1 christos *valuep = value;
448 1.1 christos return 0;
449 1.1 christos }
450 1.1 christos
451 1.1 christos static const char *
452 1.1 christos parse_signed32 (CGEN_CPU_DESC cd, const char **strp,
453 1.1 christos int opindex, signed long *valuep)
454 1.1 christos {
455 1.1 christos const char *errmsg = 0;
456 1.1.1.3 christos signed long value;
457 1.1 christos
458 1.1 christos errmsg = cgen_parse_signed_integer (cd, strp, opindex, & value);
459 1.1 christos if (errmsg)
460 1.1 christos return errmsg;
461 1.1 christos
462 1.1 christos *valuep = value;
463 1.1 christos return 0;
464 1.1 christos }
465 1.1 christos
466 1.1 christos static const char *
467 1.1 christos parse_imm1_S (CGEN_CPU_DESC cd, const char **strp,
468 1.1 christos int opindex, signed long *valuep)
469 1.1 christos {
470 1.1 christos const char *errmsg = 0;
471 1.1 christos signed long value;
472 1.1 christos
473 1.1 christos errmsg = cgen_parse_signed_integer (cd, strp, opindex, & value);
474 1.1 christos if (errmsg)
475 1.1 christos return errmsg;
476 1.1 christos
477 1.1 christos if (value < 1 || value > 2)
478 1.1 christos return _("immediate is out of range 1-2");
479 1.1 christos
480 1.1 christos *valuep = value;
481 1.1 christos return 0;
482 1.1 christos }
483 1.1 christos
484 1.1 christos static const char *
485 1.1 christos parse_imm3_S (CGEN_CPU_DESC cd, const char **strp,
486 1.1 christos int opindex, signed long *valuep)
487 1.1 christos {
488 1.1 christos const char *errmsg = 0;
489 1.1.1.3 christos signed long value;
490 1.1 christos
491 1.1 christos errmsg = cgen_parse_signed_integer (cd, strp, opindex, & value);
492 1.1 christos if (errmsg)
493 1.1 christos return errmsg;
494 1.1 christos
495 1.1 christos if (value < 1 || value > 8)
496 1.1 christos return _("immediate is out of range 1-8");
497 1.1 christos
498 1.1 christos *valuep = value;
499 1.1 christos return 0;
500 1.1 christos }
501 1.1 christos
502 1.1 christos static const char *
503 1.1 christos parse_bit3_S (CGEN_CPU_DESC cd, const char **strp,
504 1.1 christos int opindex, signed long *valuep)
505 1.1 christos {
506 1.1 christos const char *errmsg = 0;
507 1.1.1.3 christos signed long value;
508 1.1 christos
509 1.1 christos errmsg = cgen_parse_signed_integer (cd, strp, opindex, & value);
510 1.1 christos if (errmsg)
511 1.1 christos return errmsg;
512 1.1 christos
513 1.1 christos if (value < 0 || value > 7)
514 1.1 christos return _("immediate is out of range 0-7");
515 1.1 christos
516 1.1 christos *valuep = value;
517 1.1 christos return 0;
518 1.1 christos }
519 1.1 christos
520 1.1 christos static const char *
521 1.1 christos parse_lab_5_3 (CGEN_CPU_DESC cd,
522 1.1 christos const char **strp,
523 1.1 christos int opindex ATTRIBUTE_UNUSED,
524 1.1 christos int opinfo,
525 1.1 christos enum cgen_parse_operand_result *type_addr,
526 1.1 christos bfd_vma *valuep)
527 1.1 christos {
528 1.1 christos const char *errmsg = 0;
529 1.1 christos bfd_vma value;
530 1.1 christos enum cgen_parse_operand_result op_res;
531 1.1 christos
532 1.1 christos errmsg = cgen_parse_address (cd, strp, M32C_OPERAND_LAB_5_3,
533 1.1 christos opinfo, & op_res, & value);
534 1.1 christos
535 1.1 christos if (type_addr)
536 1.1 christos *type_addr = op_res;
537 1.1 christos
538 1.1 christos if (op_res == CGEN_PARSE_OPERAND_RESULT_QUEUED)
539 1.1 christos {
540 1.1 christos /* This is a hack; the field cannot handle near-zero signed
541 1.1 christos offsets that CGEN wants to put in to indicate an "empty"
542 1.1 christos operand at first. */
543 1.1 christos *valuep = 2;
544 1.1 christos return 0;
545 1.1 christos }
546 1.1 christos if (errmsg)
547 1.1 christos return errmsg;
548 1.1 christos
549 1.1 christos if (value < 2 || value > 9)
550 1.1 christos return _("immediate is out of range 2-9");
551 1.1 christos
552 1.1 christos *valuep = value;
553 1.1 christos return 0;
554 1.1 christos }
555 1.1 christos
556 1.1 christos static const char *
557 1.1 christos parse_Bitno16R (CGEN_CPU_DESC cd, const char **strp,
558 1.1 christos int opindex, unsigned long *valuep)
559 1.1 christos {
560 1.1 christos const char *errmsg = 0;
561 1.1 christos unsigned long value;
562 1.1 christos
563 1.1 christos errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, & value);
564 1.1 christos if (errmsg)
565 1.1 christos return errmsg;
566 1.1 christos
567 1.1 christos if (value > 15)
568 1.1 christos return _("Bit number for indexing general register is out of range 0-15");
569 1.1 christos
570 1.1 christos *valuep = value;
571 1.1 christos return 0;
572 1.1 christos }
573 1.1 christos
574 1.1 christos static const char *
575 1.1 christos parse_unsigned_bitbase (CGEN_CPU_DESC cd, const char **strp,
576 1.1 christos int opindex, unsigned long *valuep,
577 1.1 christos unsigned bits, int allow_syms)
578 1.1 christos {
579 1.1 christos const char *errmsg = 0;
580 1.1 christos unsigned long bit;
581 1.1 christos unsigned long base;
582 1.1 christos const char *newp = *strp;
583 1.1 christos unsigned long long bitbase;
584 1.1 christos long have_zero = 0;
585 1.1 christos
586 1.1 christos errmsg = cgen_parse_unsigned_integer (cd, & newp, opindex, & bit);
587 1.1 christos if (errmsg)
588 1.1 christos return errmsg;
589 1.1 christos
590 1.1 christos if (*newp != ',')
591 1.1 christos return "Missing base for bit,base:8";
592 1.1 christos
593 1.1 christos ++newp;
594 1.1.1.3 christos
595 1.1 christos if (strncmp (newp, "0x0", 3) == 0
596 1.1 christos || (newp[0] == '0' && newp[1] != 'x'))
597 1.1 christos have_zero = 1;
598 1.1 christos
599 1.1 christos errmsg = cgen_parse_unsigned_integer (cd, & newp, opindex, & base);
600 1.1 christos if (errmsg)
601 1.1 christos return errmsg;
602 1.1 christos
603 1.1 christos bitbase = (unsigned long long) bit + ((unsigned long long) base * 8);
604 1.1 christos
605 1.1 christos if (bitbase >= (1ull << bits))
606 1.1 christos return _("bit,base is out of range");
607 1.1 christos
608 1.1 christos /* If this field may require a relocation then use larger displacement. */
609 1.1 christos if (! have_zero && base == 0)
610 1.1 christos {
611 1.1 christos switch (allow_syms) {
612 1.1 christos case 0:
613 1.1 christos return _("bit,base out of range for symbol");
614 1.1 christos case 1:
615 1.1 christos break;
616 1.1 christos case 2:
617 1.1 christos if (strncmp (newp, "[sb]", 4) != 0)
618 1.1 christos return _("bit,base out of range for symbol");
619 1.1 christos break;
620 1.1 christos }
621 1.1 christos }
622 1.1 christos
623 1.1 christos *valuep = bitbase;
624 1.1 christos *strp = newp;
625 1.1 christos return 0;
626 1.1 christos }
627 1.1 christos
628 1.1 christos static const char *
629 1.1 christos parse_signed_bitbase (CGEN_CPU_DESC cd, const char **strp,
630 1.1 christos int opindex, signed long *valuep,
631 1.1 christos unsigned bits, int allow_syms)
632 1.1 christos {
633 1.1 christos const char *errmsg = 0;
634 1.1 christos unsigned long bit;
635 1.1 christos signed long base;
636 1.1 christos const char *newp = *strp;
637 1.1 christos long long bitbase;
638 1.1 christos long long limit;
639 1.1 christos long have_zero = 0;
640 1.1 christos
641 1.1 christos errmsg = cgen_parse_unsigned_integer (cd, & newp, opindex, & bit);
642 1.1 christos if (errmsg)
643 1.1 christos return errmsg;
644 1.1 christos
645 1.1 christos if (*newp != ',')
646 1.1 christos return "Missing base for bit,base:8";
647 1.1 christos
648 1.1 christos ++newp;
649 1.1.1.3 christos
650 1.1 christos if (strncmp (newp, "0x0", 3) == 0
651 1.1 christos || (newp[0] == '0' && newp[1] != 'x'))
652 1.1 christos have_zero = 1;
653 1.1 christos
654 1.1 christos errmsg = cgen_parse_signed_integer (cd, & newp, opindex, & base);
655 1.1 christos if (errmsg)
656 1.1 christos return errmsg;
657 1.1 christos
658 1.1 christos bitbase = (long long)bit + ((long long)base * 8);
659 1.1 christos
660 1.1 christos limit = 1ll << (bits - 1);
661 1.1 christos if (bitbase < -limit || bitbase >= limit)
662 1.1 christos return _("bit,base is out of range");
663 1.1 christos
664 1.1 christos /* If this field may require a relocation then use larger displacement. */
665 1.1 christos if (! have_zero && base == 0 && ! allow_syms)
666 1.1 christos return _("bit,base out of range for symbol");
667 1.1 christos
668 1.1 christos *valuep = bitbase;
669 1.1 christos *strp = newp;
670 1.1 christos return 0;
671 1.1 christos }
672 1.1 christos
673 1.1 christos static const char *
674 1.1 christos parse_unsigned_bitbase8 (CGEN_CPU_DESC cd, const char **strp,
675 1.1 christos int opindex, unsigned long *valuep)
676 1.1 christos {
677 1.1 christos return parse_unsigned_bitbase (cd, strp, opindex, valuep, 8, 0);
678 1.1 christos }
679 1.1 christos
680 1.1 christos static const char *
681 1.1 christos parse_unsigned_bitbase11 (CGEN_CPU_DESC cd, const char **strp,
682 1.1 christos int opindex, unsigned long *valuep)
683 1.1 christos {
684 1.1 christos return parse_unsigned_bitbase (cd, strp, opindex, valuep, 11, 0);
685 1.1 christos }
686 1.1 christos
687 1.1 christos static const char *
688 1.1 christos parse_unsigned_bitbase16 (CGEN_CPU_DESC cd, const char **strp,
689 1.1 christos int opindex, unsigned long *valuep)
690 1.1 christos {
691 1.1 christos return parse_unsigned_bitbase (cd, strp, opindex, valuep, 16, 1);
692 1.1 christos }
693 1.1 christos
694 1.1 christos static const char *
695 1.1 christos parse_unsigned_bitbase19 (CGEN_CPU_DESC cd, const char **strp,
696 1.1 christos int opindex, unsigned long *valuep)
697 1.1 christos {
698 1.1 christos return parse_unsigned_bitbase (cd, strp, opindex, valuep, 19, 2);
699 1.1 christos }
700 1.1 christos
701 1.1 christos static const char *
702 1.1 christos parse_unsigned_bitbase27 (CGEN_CPU_DESC cd, const char **strp,
703 1.1 christos int opindex, unsigned long *valuep)
704 1.1 christos {
705 1.1 christos return parse_unsigned_bitbase (cd, strp, opindex, valuep, 27, 1);
706 1.1 christos }
707 1.1 christos
708 1.1 christos static const char *
709 1.1 christos parse_signed_bitbase8 (CGEN_CPU_DESC cd, const char **strp,
710 1.1 christos int opindex, signed long *valuep)
711 1.1 christos {
712 1.1 christos return parse_signed_bitbase (cd, strp, opindex, valuep, 8, 1);
713 1.1 christos }
714 1.1 christos
715 1.1 christos static const char *
716 1.1 christos parse_signed_bitbase11 (CGEN_CPU_DESC cd, const char **strp,
717 1.1 christos int opindex, signed long *valuep)
718 1.1 christos {
719 1.1 christos return parse_signed_bitbase (cd, strp, opindex, valuep, 11, 0);
720 1.1 christos }
721 1.1 christos
722 1.1 christos static const char *
723 1.1 christos parse_signed_bitbase19 (CGEN_CPU_DESC cd, const char **strp,
724 1.1 christos int opindex, signed long *valuep)
725 1.1 christos {
726 1.1 christos return parse_signed_bitbase (cd, strp, opindex, valuep, 19, 1);
727 1.1 christos }
728 1.1 christos
729 1.1 christos /* Parse the suffix as :<char> or as nothing followed by a whitespace. */
730 1.1 christos
731 1.1 christos static const char *
732 1.1 christos parse_suffix (const char **strp, char suffix)
733 1.1 christos {
734 1.1.1.3 christos const char *newp = *strp;
735 1.1 christos
736 1.1 christos if (**strp == ':' && TOLOWER (*(*strp + 1)) == suffix)
737 1.1 christos newp = *strp + 2;
738 1.1 christos
739 1.1 christos if (ISSPACE (*newp))
740 1.1 christos {
741 1.1 christos *strp = newp;
742 1.1 christos return 0;
743 1.1.1.3 christos }
744 1.1 christos
745 1.1 christos return "Invalid suffix"; /* Anything -- will not be seen. */
746 1.1 christos }
747 1.1 christos
748 1.1 christos static const char *
749 1.1 christos parse_S (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, const char **strp,
750 1.1 christos int opindex ATTRIBUTE_UNUSED, signed long *valuep ATTRIBUTE_UNUSED)
751 1.1 christos {
752 1.1 christos return parse_suffix (strp, 's');
753 1.1 christos }
754 1.1 christos
755 1.1 christos static const char *
756 1.1 christos parse_G (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, const char **strp,
757 1.1 christos int opindex ATTRIBUTE_UNUSED, signed long *valuep ATTRIBUTE_UNUSED)
758 1.1 christos {
759 1.1 christos return parse_suffix (strp, 'g');
760 1.1 christos }
761 1.1 christos
762 1.1 christos static const char *
763 1.1 christos parse_Q (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, const char **strp,
764 1.1 christos int opindex ATTRIBUTE_UNUSED, signed long *valuep ATTRIBUTE_UNUSED)
765 1.1 christos {
766 1.1 christos return parse_suffix (strp, 'q');
767 1.1 christos }
768 1.1 christos
769 1.1 christos static const char *
770 1.1 christos parse_Z (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, const char **strp,
771 1.1 christos int opindex ATTRIBUTE_UNUSED, signed long *valuep ATTRIBUTE_UNUSED)
772 1.1 christos {
773 1.1 christos return parse_suffix (strp, 'z');
774 1.1 christos }
775 1.1 christos
776 1.1 christos /* Parse an empty suffix. Fail if the next char is ':'. */
777 1.1 christos
778 1.1 christos static const char *
779 1.1 christos parse_X (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, const char **strp,
780 1.1 christos int opindex ATTRIBUTE_UNUSED, signed long *valuep ATTRIBUTE_UNUSED)
781 1.1 christos {
782 1.1 christos if (**strp == ':')
783 1.1 christos return "Unexpected suffix";
784 1.1 christos return 0;
785 1.1 christos }
786 1.1 christos
787 1.1 christos static const char *
788 1.1 christos parse_r0l_r0h (CGEN_CPU_DESC cd, const char **strp,
789 1.1 christos int opindex ATTRIBUTE_UNUSED, signed long *valuep)
790 1.1 christos {
791 1.1 christos const char *errmsg;
792 1.1 christos signed long value;
793 1.1 christos signed long junk;
794 1.1 christos const char *newp = *strp;
795 1.1 christos
796 1.1 christos /* Parse r0[hl]. */
797 1.1 christos errmsg = cgen_parse_keyword (cd, & newp, & m32c_cgen_opval_h_r0l_r0h, & value);
798 1.1 christos if (errmsg)
799 1.1 christos return errmsg;
800 1.1 christos
801 1.1 christos if (*newp != ',')
802 1.1 christos return _("not a valid r0l/r0h pair");
803 1.1 christos ++newp;
804 1.1 christos
805 1.1 christos /* Parse the second register in the pair. */
806 1.1 christos if (value == 0) /* r0l */
807 1.1 christos errmsg = cgen_parse_keyword (cd, & newp, & m32c_cgen_opval_h_r0h, & junk);
808 1.1 christos else
809 1.1 christos errmsg = cgen_parse_keyword (cd, & newp, & m32c_cgen_opval_h_r0l, & junk);
810 1.1 christos if (errmsg)
811 1.1 christos return errmsg;
812 1.1 christos
813 1.1 christos *strp = newp;
814 1.1 christos *valuep = ! value;
815 1.1 christos return 0;
816 1.1 christos }
817 1.1 christos
818 1.1 christos /* Accept .b or .w in any case. */
819 1.1 christos
820 1.1 christos static const char *
821 1.1 christos parse_size (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, const char **strp,
822 1.1 christos int opindex ATTRIBUTE_UNUSED, signed long *valuep ATTRIBUTE_UNUSED)
823 1.1 christos {
824 1.1 christos if (**strp == '.'
825 1.1 christos && (*(*strp + 1) == 'b' || *(*strp + 1) == 'B'
826 1.1 christos || *(*strp + 1) == 'w' || *(*strp + 1) == 'W'))
827 1.1 christos {
828 1.1 christos *strp += 2;
829 1.1 christos return NULL;
830 1.1 christos }
831 1.1 christos
832 1.1 christos return _("Invalid size specifier");
833 1.1 christos }
834 1.1 christos
835 1.1 christos /* Special check to ensure that instruction exists for given machine. */
836 1.1 christos
837 1.1 christos int
838 1.1 christos m32c_cgen_insn_supported (CGEN_CPU_DESC cd,
839 1.1 christos const CGEN_INSN *insn)
840 1.1 christos {
841 1.1 christos int machs = CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_MACH);
842 1.1 christos CGEN_BITSET isas = CGEN_INSN_BITSET_ATTR_VALUE (insn, CGEN_INSN_ISA);
843 1.1 christos
844 1.1 christos /* If attributes are absent, assume no restriction. */
845 1.1 christos if (machs == 0)
846 1.1 christos machs = ~0;
847 1.1 christos
848 1.1 christos return ((machs & cd->machs)
849 1.1 christos && cgen_bitset_intersect_p (& isas, cd->isas));
850 1.1 christos }
851 1.1 christos
852 1.1 christos /* Parse a set of registers, R0,R1,A0,A1,SB,FB. */
853 1.1 christos
854 1.1 christos static const char *
855 1.1 christos parse_regset (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
856 1.1 christos const char **strp,
857 1.1 christos int opindex ATTRIBUTE_UNUSED,
858 1.1 christos unsigned long *valuep,
859 1.1 christos int push)
860 1.1 christos {
861 1.1 christos const char *errmsg = 0;
862 1.1.1.3 christos int regno = 0;
863 1.1 christos
864 1.1 christos *valuep = 0;
865 1.1 christos while (**strp && **strp != ')')
866 1.1 christos {
867 1.1 christos if (**strp == 'r' || **strp == 'R')
868 1.1 christos {
869 1.1 christos ++*strp;
870 1.1 christos regno = **strp - '0';
871 1.1 christos if (regno > 4)
872 1.1 christos errmsg = _("Register number is not valid");
873 1.1 christos }
874 1.1 christos else if (**strp == 'a' || **strp == 'A')
875 1.1 christos {
876 1.1 christos ++*strp;
877 1.1 christos regno = **strp - '0';
878 1.1 christos if (regno > 2)
879 1.1 christos errmsg = _("Register number is not valid");
880 1.1 christos regno = **strp - '0' + 4;
881 1.1.1.3 christos }
882 1.1 christos
883 1.1 christos else if (strncasecmp (*strp, "sb", 2) == 0 || strncasecmp (*strp, "SB", 2) == 0)
884 1.1 christos {
885 1.1 christos regno = 6;
886 1.1 christos ++*strp;
887 1.1.1.3 christos }
888 1.1 christos
889 1.1 christos else if (strncasecmp (*strp, "fb", 2) == 0 || strncasecmp (*strp, "FB", 2) == 0)
890 1.1 christos {
891 1.1 christos regno = 7;
892 1.1 christos ++*strp;
893 1.1.1.3 christos }
894 1.1 christos
895 1.1 christos if (push) /* Mask is reversed for push. */
896 1.1 christos *valuep |= 0x80 >> regno;
897 1.1 christos else
898 1.1 christos *valuep |= 1 << regno;
899 1.1 christos
900 1.1 christos ++*strp;
901 1.1 christos if (**strp == ',')
902 1.1 christos {
903 1.1 christos if (*(*strp + 1) == ')')
904 1.1 christos break;
905 1.1 christos ++*strp;
906 1.1 christos }
907 1.1 christos }
908 1.1 christos
909 1.1 christos if (!*strp)
910 1.1 christos errmsg = _("Register list is not valid");
911 1.1 christos
912 1.1 christos return errmsg;
913 1.1 christos }
914 1.1 christos
915 1.1 christos #define POP 0
916 1.1 christos #define PUSH 1
917 1.1 christos
918 1.1 christos static const char *
919 1.1 christos parse_pop_regset (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
920 1.1 christos const char **strp,
921 1.1 christos int opindex ATTRIBUTE_UNUSED,
922 1.1 christos unsigned long *valuep)
923 1.1 christos {
924 1.1 christos return parse_regset (cd, strp, opindex, valuep, POP);
925 1.1 christos }
926 1.1 christos
927 1.1 christos static const char *
928 1.1 christos parse_push_regset (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
929 1.1 christos const char **strp,
930 1.1 christos int opindex ATTRIBUTE_UNUSED,
931 1.1 christos unsigned long *valuep)
932 1.1 christos {
933 1.1 christos return parse_regset (cd, strp, opindex, valuep, PUSH);
934 1.1 christos }
935 1.1 christos
936 1.1 christos /* -- dis.c */
937 1.1 christos
938 1.1 christos const char * m32c_cgen_parse_operand
939 1.1 christos (CGEN_CPU_DESC, int, const char **, CGEN_FIELDS *);
940 1.1 christos
941 1.1 christos /* Main entry point for operand parsing.
942 1.1 christos
943 1.1 christos This function is basically just a big switch statement. Earlier versions
944 1.1 christos used tables to look up the function to use, but
945 1.1 christos - if the table contains both assembler and disassembler functions then
946 1.1 christos the disassembler contains much of the assembler and vice-versa,
947 1.1 christos - there's a lot of inlining possibilities as things grow,
948 1.1 christos - using a switch statement avoids the function call overhead.
949 1.1 christos
950 1.1 christos This function could be moved into `parse_insn_normal', but keeping it
951 1.1 christos separate makes clear the interface between `parse_insn_normal' and each of
952 1.1 christos the handlers. */
953 1.1 christos
954 1.1 christos const char *
955 1.1 christos m32c_cgen_parse_operand (CGEN_CPU_DESC cd,
956 1.1 christos int opindex,
957 1.1 christos const char ** strp,
958 1.1 christos CGEN_FIELDS * fields)
959 1.1 christos {
960 1.1 christos const char * errmsg = NULL;
961 1.1 christos /* Used by scalar operands that still need to be parsed. */
962 1.1 christos long junk ATTRIBUTE_UNUSED;
963 1.1 christos
964 1.1 christos switch (opindex)
965 1.1 christos {
966 1.1 christos case M32C_OPERAND_A0 :
967 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_a0, & junk);
968 1.1 christos break;
969 1.1 christos case M32C_OPERAND_A1 :
970 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_a1, & junk);
971 1.1 christos break;
972 1.1 christos case M32C_OPERAND_AN16_PUSH_S :
973 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar_HI, & fields->f_4_1);
974 1.1 christos break;
975 1.1 christos case M32C_OPERAND_BIT16AN :
976 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar, & fields->f_dst16_an);
977 1.1 christos break;
978 1.1 christos case M32C_OPERAND_BIT16RN :
979 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_HI, & fields->f_dst16_rn);
980 1.1 christos break;
981 1.1 christos case M32C_OPERAND_BIT3_S :
982 1.1 christos errmsg = parse_bit3_S (cd, strp, M32C_OPERAND_BIT3_S, (long *) (& fields->f_imm3_S));
983 1.1 christos break;
984 1.1 christos case M32C_OPERAND_BIT32ANPREFIXED :
985 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar, & fields->f_dst32_an_prefixed);
986 1.1 christos break;
987 1.1 christos case M32C_OPERAND_BIT32ANUNPREFIXED :
988 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar, & fields->f_dst32_an_unprefixed);
989 1.1 christos break;
990 1.1 christos case M32C_OPERAND_BIT32RNPREFIXED :
991 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_QI, & fields->f_dst32_rn_prefixed_QI);
992 1.1 christos break;
993 1.1 christos case M32C_OPERAND_BIT32RNUNPREFIXED :
994 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_QI, & fields->f_dst32_rn_unprefixed_QI);
995 1.1 christos break;
996 1.1 christos case M32C_OPERAND_BITBASE16_16_S8 :
997 1.1 christos errmsg = parse_signed_bitbase8 (cd, strp, M32C_OPERAND_BITBASE16_16_S8, (long *) (& fields->f_dsp_16_s8));
998 1.1 christos break;
999 1.1 christos case M32C_OPERAND_BITBASE16_16_U16 :
1000 1.1 christos errmsg = parse_unsigned_bitbase16 (cd, strp, M32C_OPERAND_BITBASE16_16_U16, (unsigned long *) (& fields->f_dsp_16_u16));
1001 1.1 christos break;
1002 1.1 christos case M32C_OPERAND_BITBASE16_16_U8 :
1003 1.1 christos errmsg = parse_unsigned_bitbase8 (cd, strp, M32C_OPERAND_BITBASE16_16_U8, (unsigned long *) (& fields->f_dsp_16_u8));
1004 1.1 christos break;
1005 1.1 christos case M32C_OPERAND_BITBASE16_8_U11_S :
1006 1.1 christos errmsg = parse_unsigned_bitbase11 (cd, strp, M32C_OPERAND_BITBASE16_8_U11_S, (unsigned long *) (& fields->f_bitbase16_u11_S));
1007 1.1 christos break;
1008 1.1 christos case M32C_OPERAND_BITBASE32_16_S11_UNPREFIXED :
1009 1.1 christos errmsg = parse_signed_bitbase11 (cd, strp, M32C_OPERAND_BITBASE32_16_S11_UNPREFIXED, (long *) (& fields->f_bitbase32_16_s11_unprefixed));
1010 1.1 christos break;
1011 1.1 christos case M32C_OPERAND_BITBASE32_16_S19_UNPREFIXED :
1012 1.1 christos errmsg = parse_signed_bitbase19 (cd, strp, M32C_OPERAND_BITBASE32_16_S19_UNPREFIXED, (long *) (& fields->f_bitbase32_16_s19_unprefixed));
1013 1.1 christos break;
1014 1.1 christos case M32C_OPERAND_BITBASE32_16_U11_UNPREFIXED :
1015 1.1 christos errmsg = parse_unsigned_bitbase11 (cd, strp, M32C_OPERAND_BITBASE32_16_U11_UNPREFIXED, (unsigned long *) (& fields->f_bitbase32_16_u11_unprefixed));
1016 1.1 christos break;
1017 1.1 christos case M32C_OPERAND_BITBASE32_16_U19_UNPREFIXED :
1018 1.1 christos errmsg = parse_unsigned_bitbase19 (cd, strp, M32C_OPERAND_BITBASE32_16_U19_UNPREFIXED, (unsigned long *) (& fields->f_bitbase32_16_u19_unprefixed));
1019 1.1 christos break;
1020 1.1 christos case M32C_OPERAND_BITBASE32_16_U27_UNPREFIXED :
1021 1.1 christos errmsg = parse_unsigned_bitbase27 (cd, strp, M32C_OPERAND_BITBASE32_16_U27_UNPREFIXED, (unsigned long *) (& fields->f_bitbase32_16_u27_unprefixed));
1022 1.1 christos break;
1023 1.1 christos case M32C_OPERAND_BITBASE32_24_S11_PREFIXED :
1024 1.1 christos errmsg = parse_signed_bitbase11 (cd, strp, M32C_OPERAND_BITBASE32_24_S11_PREFIXED, (long *) (& fields->f_bitbase32_24_s11_prefixed));
1025 1.1 christos break;
1026 1.1 christos case M32C_OPERAND_BITBASE32_24_S19_PREFIXED :
1027 1.1 christos errmsg = parse_signed_bitbase19 (cd, strp, M32C_OPERAND_BITBASE32_24_S19_PREFIXED, (long *) (& fields->f_bitbase32_24_s19_prefixed));
1028 1.1 christos break;
1029 1.1 christos case M32C_OPERAND_BITBASE32_24_U11_PREFIXED :
1030 1.1 christos errmsg = parse_unsigned_bitbase11 (cd, strp, M32C_OPERAND_BITBASE32_24_U11_PREFIXED, (unsigned long *) (& fields->f_bitbase32_24_u11_prefixed));
1031 1.1 christos break;
1032 1.1 christos case M32C_OPERAND_BITBASE32_24_U19_PREFIXED :
1033 1.1 christos errmsg = parse_unsigned_bitbase19 (cd, strp, M32C_OPERAND_BITBASE32_24_U19_PREFIXED, (unsigned long *) (& fields->f_bitbase32_24_u19_prefixed));
1034 1.1 christos break;
1035 1.1 christos case M32C_OPERAND_BITBASE32_24_U27_PREFIXED :
1036 1.1 christos errmsg = parse_unsigned_bitbase27 (cd, strp, M32C_OPERAND_BITBASE32_24_U27_PREFIXED, (unsigned long *) (& fields->f_bitbase32_24_u27_prefixed));
1037 1.1 christos break;
1038 1.1 christos case M32C_OPERAND_BITNO16R :
1039 1.1 christos errmsg = parse_Bitno16R (cd, strp, M32C_OPERAND_BITNO16R, (unsigned long *) (& fields->f_dsp_16_u8));
1040 1.1 christos break;
1041 1.1 christos case M32C_OPERAND_BITNO32PREFIXED :
1042 1.1 christos errmsg = cgen_parse_unsigned_integer (cd, strp, M32C_OPERAND_BITNO32PREFIXED, (unsigned long *) (& fields->f_bitno32_prefixed));
1043 1.1 christos break;
1044 1.1 christos case M32C_OPERAND_BITNO32UNPREFIXED :
1045 1.1 christos errmsg = cgen_parse_unsigned_integer (cd, strp, M32C_OPERAND_BITNO32UNPREFIXED, (unsigned long *) (& fields->f_bitno32_unprefixed));
1046 1.1 christos break;
1047 1.1 christos case M32C_OPERAND_DSP_10_U6 :
1048 1.1 christos errmsg = parse_unsigned6 (cd, strp, M32C_OPERAND_DSP_10_U6, (unsigned long *) (& fields->f_dsp_10_u6));
1049 1.1 christos break;
1050 1.1 christos case M32C_OPERAND_DSP_16_S16 :
1051 1.1 christos errmsg = parse_signed16 (cd, strp, M32C_OPERAND_DSP_16_S16, (long *) (& fields->f_dsp_16_s16));
1052 1.1 christos break;
1053 1.1 christos case M32C_OPERAND_DSP_16_S8 :
1054 1.1 christos errmsg = parse_signed8 (cd, strp, M32C_OPERAND_DSP_16_S8, (long *) (& fields->f_dsp_16_s8));
1055 1.1 christos break;
1056 1.1 christos case M32C_OPERAND_DSP_16_U16 :
1057 1.1 christos errmsg = parse_unsigned16 (cd, strp, M32C_OPERAND_DSP_16_U16, (unsigned long *) (& fields->f_dsp_16_u16));
1058 1.1 christos break;
1059 1.1 christos case M32C_OPERAND_DSP_16_U20 :
1060 1.1 christos errmsg = parse_unsigned20 (cd, strp, M32C_OPERAND_DSP_16_U20, (unsigned long *) (& fields->f_dsp_16_u24));
1061 1.1 christos break;
1062 1.1 christos case M32C_OPERAND_DSP_16_U24 :
1063 1.1 christos errmsg = parse_unsigned24 (cd, strp, M32C_OPERAND_DSP_16_U24, (unsigned long *) (& fields->f_dsp_16_u24));
1064 1.1 christos break;
1065 1.1 christos case M32C_OPERAND_DSP_16_U8 :
1066 1.1 christos errmsg = parse_unsigned8 (cd, strp, M32C_OPERAND_DSP_16_U8, (unsigned long *) (& fields->f_dsp_16_u8));
1067 1.1 christos break;
1068 1.1 christos case M32C_OPERAND_DSP_24_S16 :
1069 1.1 christos errmsg = parse_signed16 (cd, strp, M32C_OPERAND_DSP_24_S16, (long *) (& fields->f_dsp_24_s16));
1070 1.1 christos break;
1071 1.1 christos case M32C_OPERAND_DSP_24_S8 :
1072 1.1 christos errmsg = parse_signed8 (cd, strp, M32C_OPERAND_DSP_24_S8, (long *) (& fields->f_dsp_24_s8));
1073 1.1 christos break;
1074 1.1 christos case M32C_OPERAND_DSP_24_U16 :
1075 1.1 christos errmsg = parse_unsigned16 (cd, strp, M32C_OPERAND_DSP_24_U16, (unsigned long *) (& fields->f_dsp_24_u16));
1076 1.1 christos break;
1077 1.1 christos case M32C_OPERAND_DSP_24_U20 :
1078 1.1 christos errmsg = parse_unsigned20 (cd, strp, M32C_OPERAND_DSP_24_U20, (unsigned long *) (& fields->f_dsp_24_u24));
1079 1.1 christos break;
1080 1.1 christos case M32C_OPERAND_DSP_24_U24 :
1081 1.1 christos errmsg = parse_unsigned24 (cd, strp, M32C_OPERAND_DSP_24_U24, (unsigned long *) (& fields->f_dsp_24_u24));
1082 1.1 christos break;
1083 1.1 christos case M32C_OPERAND_DSP_24_U8 :
1084 1.1 christos errmsg = parse_unsigned8 (cd, strp, M32C_OPERAND_DSP_24_U8, (unsigned long *) (& fields->f_dsp_24_u8));
1085 1.1 christos break;
1086 1.1 christos case M32C_OPERAND_DSP_32_S16 :
1087 1.1 christos errmsg = parse_signed16 (cd, strp, M32C_OPERAND_DSP_32_S16, (long *) (& fields->f_dsp_32_s16));
1088 1.1 christos break;
1089 1.1 christos case M32C_OPERAND_DSP_32_S8 :
1090 1.1 christos errmsg = parse_signed8 (cd, strp, M32C_OPERAND_DSP_32_S8, (long *) (& fields->f_dsp_32_s8));
1091 1.1 christos break;
1092 1.1 christos case M32C_OPERAND_DSP_32_U16 :
1093 1.1 christos errmsg = parse_unsigned16 (cd, strp, M32C_OPERAND_DSP_32_U16, (unsigned long *) (& fields->f_dsp_32_u16));
1094 1.1 christos break;
1095 1.1 christos case M32C_OPERAND_DSP_32_U20 :
1096 1.1 christos errmsg = parse_unsigned20 (cd, strp, M32C_OPERAND_DSP_32_U20, (unsigned long *) (& fields->f_dsp_32_u24));
1097 1.1 christos break;
1098 1.1 christos case M32C_OPERAND_DSP_32_U24 :
1099 1.1 christos errmsg = parse_unsigned24 (cd, strp, M32C_OPERAND_DSP_32_U24, (unsigned long *) (& fields->f_dsp_32_u24));
1100 1.1 christos break;
1101 1.1 christos case M32C_OPERAND_DSP_32_U8 :
1102 1.1 christos errmsg = parse_unsigned8 (cd, strp, M32C_OPERAND_DSP_32_U8, (unsigned long *) (& fields->f_dsp_32_u8));
1103 1.1 christos break;
1104 1.1 christos case M32C_OPERAND_DSP_40_S16 :
1105 1.1 christos errmsg = parse_signed16 (cd, strp, M32C_OPERAND_DSP_40_S16, (long *) (& fields->f_dsp_40_s16));
1106 1.1 christos break;
1107 1.1 christos case M32C_OPERAND_DSP_40_S8 :
1108 1.1 christos errmsg = parse_signed8 (cd, strp, M32C_OPERAND_DSP_40_S8, (long *) (& fields->f_dsp_40_s8));
1109 1.1 christos break;
1110 1.1 christos case M32C_OPERAND_DSP_40_U16 :
1111 1.1 christos errmsg = parse_unsigned16 (cd, strp, M32C_OPERAND_DSP_40_U16, (unsigned long *) (& fields->f_dsp_40_u16));
1112 1.1 christos break;
1113 1.1 christos case M32C_OPERAND_DSP_40_U20 :
1114 1.1 christos errmsg = parse_unsigned20 (cd, strp, M32C_OPERAND_DSP_40_U20, (unsigned long *) (& fields->f_dsp_40_u20));
1115 1.1 christos break;
1116 1.1 christos case M32C_OPERAND_DSP_40_U24 :
1117 1.1 christos errmsg = parse_unsigned24 (cd, strp, M32C_OPERAND_DSP_40_U24, (unsigned long *) (& fields->f_dsp_40_u24));
1118 1.1 christos break;
1119 1.1 christos case M32C_OPERAND_DSP_40_U8 :
1120 1.1 christos errmsg = parse_unsigned8 (cd, strp, M32C_OPERAND_DSP_40_U8, (unsigned long *) (& fields->f_dsp_40_u8));
1121 1.1 christos break;
1122 1.1 christos case M32C_OPERAND_DSP_48_S16 :
1123 1.1 christos errmsg = parse_signed16 (cd, strp, M32C_OPERAND_DSP_48_S16, (long *) (& fields->f_dsp_48_s16));
1124 1.1 christos break;
1125 1.1 christos case M32C_OPERAND_DSP_48_S8 :
1126 1.1 christos errmsg = parse_signed8 (cd, strp, M32C_OPERAND_DSP_48_S8, (long *) (& fields->f_dsp_48_s8));
1127 1.1 christos break;
1128 1.1 christos case M32C_OPERAND_DSP_48_U16 :
1129 1.1 christos errmsg = parse_unsigned16 (cd, strp, M32C_OPERAND_DSP_48_U16, (unsigned long *) (& fields->f_dsp_48_u16));
1130 1.1 christos break;
1131 1.1 christos case M32C_OPERAND_DSP_48_U20 :
1132 1.1 christos errmsg = parse_unsigned24 (cd, strp, M32C_OPERAND_DSP_48_U20, (unsigned long *) (& fields->f_dsp_48_u20));
1133 1.1 christos break;
1134 1.1 christos case M32C_OPERAND_DSP_48_U24 :
1135 1.1 christos errmsg = parse_unsigned24 (cd, strp, M32C_OPERAND_DSP_48_U24, (unsigned long *) (& fields->f_dsp_48_u24));
1136 1.1 christos break;
1137 1.1 christos case M32C_OPERAND_DSP_48_U8 :
1138 1.1 christos errmsg = parse_unsigned8 (cd, strp, M32C_OPERAND_DSP_48_U8, (unsigned long *) (& fields->f_dsp_48_u8));
1139 1.1 christos break;
1140 1.1 christos case M32C_OPERAND_DSP_8_S24 :
1141 1.1 christos errmsg = parse_signed24 (cd, strp, M32C_OPERAND_DSP_8_S24, (long *) (& fields->f_dsp_8_s24));
1142 1.1 christos break;
1143 1.1 christos case M32C_OPERAND_DSP_8_S8 :
1144 1.1 christos errmsg = parse_signed8 (cd, strp, M32C_OPERAND_DSP_8_S8, (long *) (& fields->f_dsp_8_s8));
1145 1.1 christos break;
1146 1.1 christos case M32C_OPERAND_DSP_8_U16 :
1147 1.1 christos errmsg = parse_unsigned16 (cd, strp, M32C_OPERAND_DSP_8_U16, (unsigned long *) (& fields->f_dsp_8_u16));
1148 1.1 christos break;
1149 1.1 christos case M32C_OPERAND_DSP_8_U24 :
1150 1.1 christos errmsg = parse_unsigned24 (cd, strp, M32C_OPERAND_DSP_8_U24, (unsigned long *) (& fields->f_dsp_8_u24));
1151 1.1 christos break;
1152 1.1 christos case M32C_OPERAND_DSP_8_U6 :
1153 1.1 christos errmsg = parse_unsigned6 (cd, strp, M32C_OPERAND_DSP_8_U6, (unsigned long *) (& fields->f_dsp_8_u6));
1154 1.1 christos break;
1155 1.1 christos case M32C_OPERAND_DSP_8_U8 :
1156 1.1 christos errmsg = parse_unsigned8 (cd, strp, M32C_OPERAND_DSP_8_U8, (unsigned long *) (& fields->f_dsp_8_u8));
1157 1.1 christos break;
1158 1.1 christos case M32C_OPERAND_DST16AN :
1159 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar, & fields->f_dst16_an);
1160 1.1 christos break;
1161 1.1 christos case M32C_OPERAND_DST16AN_S :
1162 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar_HI, & fields->f_dst16_an_s);
1163 1.1 christos break;
1164 1.1 christos case M32C_OPERAND_DST16ANHI :
1165 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar_HI, & fields->f_dst16_an);
1166 1.1 christos break;
1167 1.1 christos case M32C_OPERAND_DST16ANQI :
1168 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar_QI, & fields->f_dst16_an);
1169 1.1 christos break;
1170 1.1 christos case M32C_OPERAND_DST16ANQI_S :
1171 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar_QI, & fields->f_dst16_rn_QI_s);
1172 1.1 christos break;
1173 1.1 christos case M32C_OPERAND_DST16ANSI :
1174 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar_SI, & fields->f_dst16_an);
1175 1.1 christos break;
1176 1.1 christos case M32C_OPERAND_DST16RNEXTQI :
1177 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_ext_QI, & fields->f_dst16_rn_ext);
1178 1.1 christos break;
1179 1.1 christos case M32C_OPERAND_DST16RNHI :
1180 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_HI, & fields->f_dst16_rn);
1181 1.1 christos break;
1182 1.1 christos case M32C_OPERAND_DST16RNQI :
1183 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_QI, & fields->f_dst16_rn);
1184 1.1 christos break;
1185 1.1 christos case M32C_OPERAND_DST16RNQI_S :
1186 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_r0l_r0h, & fields->f_dst16_rn_QI_s);
1187 1.1 christos break;
1188 1.1 christos case M32C_OPERAND_DST16RNSI :
1189 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_SI, & fields->f_dst16_rn);
1190 1.1 christos break;
1191 1.1 christos case M32C_OPERAND_DST32ANEXTUNPREFIXED :
1192 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar, & fields->f_dst32_an_unprefixed);
1193 1.1 christos break;
1194 1.1 christos case M32C_OPERAND_DST32ANPREFIXED :
1195 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar, & fields->f_dst32_an_prefixed);
1196 1.1 christos break;
1197 1.1 christos case M32C_OPERAND_DST32ANPREFIXEDHI :
1198 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar_HI, & fields->f_dst32_an_prefixed);
1199 1.1 christos break;
1200 1.1 christos case M32C_OPERAND_DST32ANPREFIXEDQI :
1201 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar_QI, & fields->f_dst32_an_prefixed);
1202 1.1 christos break;
1203 1.1 christos case M32C_OPERAND_DST32ANPREFIXEDSI :
1204 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar, & fields->f_dst32_an_prefixed);
1205 1.1 christos break;
1206 1.1 christos case M32C_OPERAND_DST32ANUNPREFIXED :
1207 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar, & fields->f_dst32_an_unprefixed);
1208 1.1 christos break;
1209 1.1 christos case M32C_OPERAND_DST32ANUNPREFIXEDHI :
1210 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar_HI, & fields->f_dst32_an_unprefixed);
1211 1.1 christos break;
1212 1.1 christos case M32C_OPERAND_DST32ANUNPREFIXEDQI :
1213 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar_QI, & fields->f_dst32_an_unprefixed);
1214 1.1 christos break;
1215 1.1 christos case M32C_OPERAND_DST32ANUNPREFIXEDSI :
1216 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar, & fields->f_dst32_an_unprefixed);
1217 1.1 christos break;
1218 1.1 christos case M32C_OPERAND_DST32R0HI_S :
1219 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_r0, & junk);
1220 1.1 christos break;
1221 1.1 christos case M32C_OPERAND_DST32R0QI_S :
1222 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_r0l, & junk);
1223 1.1 christos break;
1224 1.1 christos case M32C_OPERAND_DST32RNEXTUNPREFIXEDHI :
1225 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_ext_HI, & fields->f_dst32_rn_ext_unprefixed);
1226 1.1 christos break;
1227 1.1 christos case M32C_OPERAND_DST32RNEXTUNPREFIXEDQI :
1228 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_ext_QI, & fields->f_dst32_rn_ext_unprefixed);
1229 1.1 christos break;
1230 1.1 christos case M32C_OPERAND_DST32RNPREFIXEDHI :
1231 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_HI, & fields->f_dst32_rn_prefixed_HI);
1232 1.1 christos break;
1233 1.1 christos case M32C_OPERAND_DST32RNPREFIXEDQI :
1234 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_QI, & fields->f_dst32_rn_prefixed_QI);
1235 1.1 christos break;
1236 1.1 christos case M32C_OPERAND_DST32RNPREFIXEDSI :
1237 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_SI, & fields->f_dst32_rn_prefixed_SI);
1238 1.1 christos break;
1239 1.1 christos case M32C_OPERAND_DST32RNUNPREFIXEDHI :
1240 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_HI, & fields->f_dst32_rn_unprefixed_HI);
1241 1.1 christos break;
1242 1.1 christos case M32C_OPERAND_DST32RNUNPREFIXEDQI :
1243 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_QI, & fields->f_dst32_rn_unprefixed_QI);
1244 1.1 christos break;
1245 1.1 christos case M32C_OPERAND_DST32RNUNPREFIXEDSI :
1246 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_SI, & fields->f_dst32_rn_unprefixed_SI);
1247 1.1 christos break;
1248 1.1 christos case M32C_OPERAND_G :
1249 1.1 christos errmsg = parse_G (cd, strp, M32C_OPERAND_G, (long *) (& junk));
1250 1.1 christos break;
1251 1.1 christos case M32C_OPERAND_IMM_12_S4 :
1252 1.1 christos errmsg = parse_signed4 (cd, strp, M32C_OPERAND_IMM_12_S4, (long *) (& fields->f_imm_12_s4));
1253 1.1 christos break;
1254 1.1 christos case M32C_OPERAND_IMM_12_S4N :
1255 1.1 christos errmsg = parse_signed4n (cd, strp, M32C_OPERAND_IMM_12_S4N, (long *) (& fields->f_imm_12_s4));
1256 1.1 christos break;
1257 1.1 christos case M32C_OPERAND_IMM_13_U3 :
1258 1.1 christos errmsg = parse_signed4 (cd, strp, M32C_OPERAND_IMM_13_U3, (long *) (& fields->f_imm_13_u3));
1259 1.1 christos break;
1260 1.1 christos case M32C_OPERAND_IMM_16_HI :
1261 1.1 christos errmsg = parse_signed16 (cd, strp, M32C_OPERAND_IMM_16_HI, (long *) (& fields->f_dsp_16_s16));
1262 1.1 christos break;
1263 1.1 christos case M32C_OPERAND_IMM_16_QI :
1264 1.1 christos errmsg = parse_signed8 (cd, strp, M32C_OPERAND_IMM_16_QI, (long *) (& fields->f_dsp_16_s8));
1265 1.1 christos break;
1266 1.1 christos case M32C_OPERAND_IMM_16_SI :
1267 1.1 christos errmsg = parse_signed32 (cd, strp, M32C_OPERAND_IMM_16_SI, (long *) (& fields->f_dsp_16_s32));
1268 1.1 christos break;
1269 1.1 christos case M32C_OPERAND_IMM_20_S4 :
1270 1.1 christos errmsg = parse_signed4 (cd, strp, M32C_OPERAND_IMM_20_S4, (long *) (& fields->f_imm_20_s4));
1271 1.1 christos break;
1272 1.1 christos case M32C_OPERAND_IMM_24_HI :
1273 1.1 christos errmsg = parse_signed16 (cd, strp, M32C_OPERAND_IMM_24_HI, (long *) (& fields->f_dsp_24_s16));
1274 1.1 christos break;
1275 1.1 christos case M32C_OPERAND_IMM_24_QI :
1276 1.1 christos errmsg = parse_signed8 (cd, strp, M32C_OPERAND_IMM_24_QI, (long *) (& fields->f_dsp_24_s8));
1277 1.1 christos break;
1278 1.1 christos case M32C_OPERAND_IMM_24_SI :
1279 1.1 christos errmsg = parse_signed32 (cd, strp, M32C_OPERAND_IMM_24_SI, (long *) (& fields->f_dsp_24_s32));
1280 1.1 christos break;
1281 1.1 christos case M32C_OPERAND_IMM_32_HI :
1282 1.1 christos errmsg = parse_signed16 (cd, strp, M32C_OPERAND_IMM_32_HI, (long *) (& fields->f_dsp_32_s16));
1283 1.1 christos break;
1284 1.1 christos case M32C_OPERAND_IMM_32_QI :
1285 1.1 christos errmsg = parse_signed8 (cd, strp, M32C_OPERAND_IMM_32_QI, (long *) (& fields->f_dsp_32_s8));
1286 1.1 christos break;
1287 1.1 christos case M32C_OPERAND_IMM_32_SI :
1288 1.1 christos errmsg = parse_signed32 (cd, strp, M32C_OPERAND_IMM_32_SI, (long *) (& fields->f_dsp_32_s32));
1289 1.1 christos break;
1290 1.1 christos case M32C_OPERAND_IMM_40_HI :
1291 1.1 christos errmsg = parse_signed16 (cd, strp, M32C_OPERAND_IMM_40_HI, (long *) (& fields->f_dsp_40_s16));
1292 1.1 christos break;
1293 1.1 christos case M32C_OPERAND_IMM_40_QI :
1294 1.1 christos errmsg = parse_signed8 (cd, strp, M32C_OPERAND_IMM_40_QI, (long *) (& fields->f_dsp_40_s8));
1295 1.1 christos break;
1296 1.1 christos case M32C_OPERAND_IMM_40_SI :
1297 1.1 christos errmsg = parse_signed32 (cd, strp, M32C_OPERAND_IMM_40_SI, (long *) (& fields->f_dsp_40_s32));
1298 1.1 christos break;
1299 1.1 christos case M32C_OPERAND_IMM_48_HI :
1300 1.1 christos errmsg = parse_signed16 (cd, strp, M32C_OPERAND_IMM_48_HI, (long *) (& fields->f_dsp_48_s16));
1301 1.1 christos break;
1302 1.1 christos case M32C_OPERAND_IMM_48_QI :
1303 1.1 christos errmsg = parse_signed8 (cd, strp, M32C_OPERAND_IMM_48_QI, (long *) (& fields->f_dsp_48_s8));
1304 1.1 christos break;
1305 1.1 christos case M32C_OPERAND_IMM_48_SI :
1306 1.1 christos errmsg = parse_signed32 (cd, strp, M32C_OPERAND_IMM_48_SI, (long *) (& fields->f_dsp_48_s32));
1307 1.1 christos break;
1308 1.1 christos case M32C_OPERAND_IMM_56_HI :
1309 1.1 christos errmsg = parse_signed16 (cd, strp, M32C_OPERAND_IMM_56_HI, (long *) (& fields->f_dsp_56_s16));
1310 1.1 christos break;
1311 1.1 christos case M32C_OPERAND_IMM_56_QI :
1312 1.1 christos errmsg = parse_signed8 (cd, strp, M32C_OPERAND_IMM_56_QI, (long *) (& fields->f_dsp_56_s8));
1313 1.1 christos break;
1314 1.1 christos case M32C_OPERAND_IMM_64_HI :
1315 1.1 christos errmsg = parse_signed16 (cd, strp, M32C_OPERAND_IMM_64_HI, (long *) (& fields->f_dsp_64_s16));
1316 1.1 christos break;
1317 1.1 christos case M32C_OPERAND_IMM_8_HI :
1318 1.1 christos errmsg = parse_signed16 (cd, strp, M32C_OPERAND_IMM_8_HI, (long *) (& fields->f_dsp_8_s16));
1319 1.1 christos break;
1320 1.1 christos case M32C_OPERAND_IMM_8_QI :
1321 1.1 christos errmsg = parse_signed8 (cd, strp, M32C_OPERAND_IMM_8_QI, (long *) (& fields->f_dsp_8_s8));
1322 1.1 christos break;
1323 1.1 christos case M32C_OPERAND_IMM_8_S4 :
1324 1.1 christos errmsg = parse_signed4 (cd, strp, M32C_OPERAND_IMM_8_S4, (long *) (& fields->f_imm_8_s4));
1325 1.1 christos break;
1326 1.1 christos case M32C_OPERAND_IMM_8_S4N :
1327 1.1 christos errmsg = parse_signed4n (cd, strp, M32C_OPERAND_IMM_8_S4N, (long *) (& fields->f_imm_8_s4));
1328 1.1 christos break;
1329 1.1 christos case M32C_OPERAND_IMM_SH_12_S4 :
1330 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_shimm, & fields->f_imm_12_s4);
1331 1.1 christos break;
1332 1.1 christos case M32C_OPERAND_IMM_SH_20_S4 :
1333 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_shimm, & fields->f_imm_20_s4);
1334 1.1 christos break;
1335 1.1 christos case M32C_OPERAND_IMM_SH_8_S4 :
1336 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_shimm, & fields->f_imm_8_s4);
1337 1.1 christos break;
1338 1.1 christos case M32C_OPERAND_IMM1_S :
1339 1.1 christos errmsg = parse_imm1_S (cd, strp, M32C_OPERAND_IMM1_S, (long *) (& fields->f_imm1_S));
1340 1.1 christos break;
1341 1.1 christos case M32C_OPERAND_IMM3_S :
1342 1.1 christos errmsg = parse_imm3_S (cd, strp, M32C_OPERAND_IMM3_S, (long *) (& fields->f_imm3_S));
1343 1.1 christos break;
1344 1.1 christos case M32C_OPERAND_LAB_16_8 :
1345 1.1 christos {
1346 1.1 christos bfd_vma value = 0;
1347 1.1 christos errmsg = cgen_parse_address (cd, strp, M32C_OPERAND_LAB_16_8, 0, NULL, & value);
1348 1.1 christos fields->f_lab_16_8 = value;
1349 1.1 christos }
1350 1.1 christos break;
1351 1.1 christos case M32C_OPERAND_LAB_24_8 :
1352 1.1 christos {
1353 1.1 christos bfd_vma value = 0;
1354 1.1 christos errmsg = cgen_parse_address (cd, strp, M32C_OPERAND_LAB_24_8, 0, NULL, & value);
1355 1.1 christos fields->f_lab_24_8 = value;
1356 1.1 christos }
1357 1.1 christos break;
1358 1.1 christos case M32C_OPERAND_LAB_32_8 :
1359 1.1 christos {
1360 1.1 christos bfd_vma value = 0;
1361 1.1 christos errmsg = cgen_parse_address (cd, strp, M32C_OPERAND_LAB_32_8, 0, NULL, & value);
1362 1.1 christos fields->f_lab_32_8 = value;
1363 1.1 christos }
1364 1.1 christos break;
1365 1.1 christos case M32C_OPERAND_LAB_40_8 :
1366 1.1 christos {
1367 1.1 christos bfd_vma value = 0;
1368 1.1 christos errmsg = cgen_parse_address (cd, strp, M32C_OPERAND_LAB_40_8, 0, NULL, & value);
1369 1.1 christos fields->f_lab_40_8 = value;
1370 1.1 christos }
1371 1.1 christos break;
1372 1.1 christos case M32C_OPERAND_LAB_5_3 :
1373 1.1 christos {
1374 1.1 christos bfd_vma value = 0;
1375 1.1 christos errmsg = parse_lab_5_3 (cd, strp, M32C_OPERAND_LAB_5_3, 0, NULL, & value);
1376 1.1 christos fields->f_lab_5_3 = value;
1377 1.1 christos }
1378 1.1 christos break;
1379 1.1 christos case M32C_OPERAND_LAB_8_16 :
1380 1.1 christos {
1381 1.1 christos bfd_vma value = 0;
1382 1.1 christos errmsg = cgen_parse_address (cd, strp, M32C_OPERAND_LAB_8_16, 0, NULL, & value);
1383 1.1 christos fields->f_lab_8_16 = value;
1384 1.1 christos }
1385 1.1 christos break;
1386 1.1 christos case M32C_OPERAND_LAB_8_24 :
1387 1.1 christos {
1388 1.1 christos bfd_vma value = 0;
1389 1.1 christos errmsg = cgen_parse_address (cd, strp, M32C_OPERAND_LAB_8_24, 0, NULL, & value);
1390 1.1 christos fields->f_lab_8_24 = value;
1391 1.1 christos }
1392 1.1 christos break;
1393 1.1 christos case M32C_OPERAND_LAB_8_8 :
1394 1.1 christos {
1395 1.1 christos bfd_vma value = 0;
1396 1.1 christos errmsg = cgen_parse_address (cd, strp, M32C_OPERAND_LAB_8_8, 0, NULL, & value);
1397 1.1 christos fields->f_lab_8_8 = value;
1398 1.1 christos }
1399 1.1 christos break;
1400 1.1 christos case M32C_OPERAND_LAB32_JMP_S :
1401 1.1 christos {
1402 1.1 christos bfd_vma value = 0;
1403 1.1 christos errmsg = parse_lab_5_3 (cd, strp, M32C_OPERAND_LAB32_JMP_S, 0, NULL, & value);
1404 1.1 christos fields->f_lab32_jmp_s = value;
1405 1.1 christos }
1406 1.1 christos break;
1407 1.1 christos case M32C_OPERAND_Q :
1408 1.1 christos errmsg = parse_Q (cd, strp, M32C_OPERAND_Q, (long *) (& junk));
1409 1.1 christos break;
1410 1.1 christos case M32C_OPERAND_R0 :
1411 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_r0, & junk);
1412 1.1 christos break;
1413 1.1 christos case M32C_OPERAND_R0H :
1414 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_r0h, & junk);
1415 1.1 christos break;
1416 1.1 christos case M32C_OPERAND_R0L :
1417 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_r0l, & junk);
1418 1.1 christos break;
1419 1.1 christos case M32C_OPERAND_R1 :
1420 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_r1, & junk);
1421 1.1 christos break;
1422 1.1 christos case M32C_OPERAND_R1R2R0 :
1423 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_r1r2r0, & junk);
1424 1.1 christos break;
1425 1.1 christos case M32C_OPERAND_R2 :
1426 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_r2, & junk);
1427 1.1 christos break;
1428 1.1 christos case M32C_OPERAND_R2R0 :
1429 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_r2r0, & junk);
1430 1.1 christos break;
1431 1.1 christos case M32C_OPERAND_R3 :
1432 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_r3, & junk);
1433 1.1 christos break;
1434 1.1 christos case M32C_OPERAND_R3R1 :
1435 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_r3r1, & junk);
1436 1.1 christos break;
1437 1.1 christos case M32C_OPERAND_REGSETPOP :
1438 1.1 christos errmsg = parse_pop_regset (cd, strp, M32C_OPERAND_REGSETPOP, (unsigned long *) (& fields->f_8_8));
1439 1.1 christos break;
1440 1.1 christos case M32C_OPERAND_REGSETPUSH :
1441 1.1 christos errmsg = parse_push_regset (cd, strp, M32C_OPERAND_REGSETPUSH, (unsigned long *) (& fields->f_8_8));
1442 1.1 christos break;
1443 1.1 christos case M32C_OPERAND_RN16_PUSH_S :
1444 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_QI, & fields->f_4_1);
1445 1.1 christos break;
1446 1.1 christos case M32C_OPERAND_S :
1447 1.1 christos errmsg = parse_S (cd, strp, M32C_OPERAND_S, (long *) (& junk));
1448 1.1 christos break;
1449 1.1 christos case M32C_OPERAND_SRC16AN :
1450 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar, & fields->f_src16_an);
1451 1.1 christos break;
1452 1.1 christos case M32C_OPERAND_SRC16ANHI :
1453 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar_HI, & fields->f_src16_an);
1454 1.1 christos break;
1455 1.1 christos case M32C_OPERAND_SRC16ANQI :
1456 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar_QI, & fields->f_src16_an);
1457 1.1 christos break;
1458 1.1 christos case M32C_OPERAND_SRC16RNHI :
1459 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_HI, & fields->f_src16_rn);
1460 1.1 christos break;
1461 1.1 christos case M32C_OPERAND_SRC16RNQI :
1462 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_QI, & fields->f_src16_rn);
1463 1.1 christos break;
1464 1.1 christos case M32C_OPERAND_SRC32ANPREFIXED :
1465 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar, & fields->f_src32_an_prefixed);
1466 1.1 christos break;
1467 1.1 christos case M32C_OPERAND_SRC32ANPREFIXEDHI :
1468 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar_HI, & fields->f_src32_an_prefixed);
1469 1.1 christos break;
1470 1.1 christos case M32C_OPERAND_SRC32ANPREFIXEDQI :
1471 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar_QI, & fields->f_src32_an_prefixed);
1472 1.1 christos break;
1473 1.1 christos case M32C_OPERAND_SRC32ANPREFIXEDSI :
1474 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar, & fields->f_src32_an_prefixed);
1475 1.1 christos break;
1476 1.1 christos case M32C_OPERAND_SRC32ANUNPREFIXED :
1477 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar, & fields->f_src32_an_unprefixed);
1478 1.1 christos break;
1479 1.1 christos case M32C_OPERAND_SRC32ANUNPREFIXEDHI :
1480 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar_HI, & fields->f_src32_an_unprefixed);
1481 1.1 christos break;
1482 1.1 christos case M32C_OPERAND_SRC32ANUNPREFIXEDQI :
1483 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar_QI, & fields->f_src32_an_unprefixed);
1484 1.1 christos break;
1485 1.1 christos case M32C_OPERAND_SRC32ANUNPREFIXEDSI :
1486 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar, & fields->f_src32_an_unprefixed);
1487 1.1 christos break;
1488 1.1 christos case M32C_OPERAND_SRC32RNPREFIXEDHI :
1489 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_HI, & fields->f_src32_rn_prefixed_HI);
1490 1.1 christos break;
1491 1.1 christos case M32C_OPERAND_SRC32RNPREFIXEDQI :
1492 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_QI, & fields->f_src32_rn_prefixed_QI);
1493 1.1 christos break;
1494 1.1 christos case M32C_OPERAND_SRC32RNPREFIXEDSI :
1495 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_SI, & fields->f_src32_rn_prefixed_SI);
1496 1.1 christos break;
1497 1.1 christos case M32C_OPERAND_SRC32RNUNPREFIXEDHI :
1498 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_HI, & fields->f_src32_rn_unprefixed_HI);
1499 1.1 christos break;
1500 1.1 christos case M32C_OPERAND_SRC32RNUNPREFIXEDQI :
1501 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_QI, & fields->f_src32_rn_unprefixed_QI);
1502 1.1 christos break;
1503 1.1 christos case M32C_OPERAND_SRC32RNUNPREFIXEDSI :
1504 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_SI, & fields->f_src32_rn_unprefixed_SI);
1505 1.1 christos break;
1506 1.1 christos case M32C_OPERAND_SRCDST16_R0L_R0H_S_NORMAL :
1507 1.1 christos errmsg = parse_r0l_r0h (cd, strp, M32C_OPERAND_SRCDST16_R0L_R0H_S_NORMAL, (long *) (& fields->f_5_1));
1508 1.1 christos break;
1509 1.1 christos case M32C_OPERAND_X :
1510 1.1 christos errmsg = parse_X (cd, strp, M32C_OPERAND_X, (long *) (& junk));
1511 1.1 christos break;
1512 1.1 christos case M32C_OPERAND_Z :
1513 1.1 christos errmsg = parse_Z (cd, strp, M32C_OPERAND_Z, (long *) (& junk));
1514 1.1 christos break;
1515 1.1 christos case M32C_OPERAND_COND16_16 :
1516 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_cond16, & fields->f_dsp_16_u8);
1517 1.1 christos break;
1518 1.1 christos case M32C_OPERAND_COND16_24 :
1519 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_cond16, & fields->f_dsp_24_u8);
1520 1.1 christos break;
1521 1.1 christos case M32C_OPERAND_COND16_32 :
1522 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_cond16, & fields->f_dsp_32_u8);
1523 1.1 christos break;
1524 1.1 christos case M32C_OPERAND_COND16C :
1525 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_cond16c, & fields->f_cond16);
1526 1.1 christos break;
1527 1.1 christos case M32C_OPERAND_COND16J :
1528 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_cond16j, & fields->f_cond16);
1529 1.1 christos break;
1530 1.1 christos case M32C_OPERAND_COND16J5 :
1531 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_cond16j_5, & fields->f_cond16j_5);
1532 1.1 christos break;
1533 1.1 christos case M32C_OPERAND_COND32 :
1534 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_cond32, & fields->f_cond32);
1535 1.1 christos break;
1536 1.1 christos case M32C_OPERAND_COND32_16 :
1537 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_cond32, & fields->f_dsp_16_u8);
1538 1.1 christos break;
1539 1.1 christos case M32C_OPERAND_COND32_24 :
1540 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_cond32, & fields->f_dsp_24_u8);
1541 1.1 christos break;
1542 1.1 christos case M32C_OPERAND_COND32_32 :
1543 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_cond32, & fields->f_dsp_32_u8);
1544 1.1 christos break;
1545 1.1 christos case M32C_OPERAND_COND32_40 :
1546 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_cond32, & fields->f_dsp_40_u8);
1547 1.1 christos break;
1548 1.1 christos case M32C_OPERAND_COND32J :
1549 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_cond32, & fields->f_cond32j);
1550 1.1 christos break;
1551 1.1 christos case M32C_OPERAND_CR1_PREFIXED_32 :
1552 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_cr1_32, & fields->f_21_3);
1553 1.1 christos break;
1554 1.1 christos case M32C_OPERAND_CR1_UNPREFIXED_32 :
1555 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_cr1_32, & fields->f_13_3);
1556 1.1 christos break;
1557 1.1 christos case M32C_OPERAND_CR16 :
1558 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_cr_16, & fields->f_9_3);
1559 1.1 christos break;
1560 1.1 christos case M32C_OPERAND_CR2_32 :
1561 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_cr2_32, & fields->f_13_3);
1562 1.1 christos break;
1563 1.1 christos case M32C_OPERAND_CR3_PREFIXED_32 :
1564 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_cr3_32, & fields->f_21_3);
1565 1.1 christos break;
1566 1.1 christos case M32C_OPERAND_CR3_UNPREFIXED_32 :
1567 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_cr3_32, & fields->f_13_3);
1568 1.1 christos break;
1569 1.1 christos case M32C_OPERAND_FLAGS16 :
1570 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_flags, & fields->f_9_3);
1571 1.1 christos break;
1572 1.1 christos case M32C_OPERAND_FLAGS32 :
1573 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_flags, & fields->f_13_3);
1574 1.1 christos break;
1575 1.1 christos case M32C_OPERAND_SCCOND32 :
1576 1.1 christos errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_cond32, & fields->f_cond16);
1577 1.1 christos break;
1578 1.1 christos case M32C_OPERAND_SIZE :
1579 1.1 christos errmsg = parse_size (cd, strp, M32C_OPERAND_SIZE, (long *) (& junk));
1580 1.1 christos break;
1581 1.1 christos
1582 1.1 christos default :
1583 1.1 christos /* xgettext:c-format */
1584 1.1 christos fprintf (stderr, _("Unrecognized field %d while parsing.\n"), opindex);
1585 1.1 christos abort ();
1586 1.1 christos }
1587 1.1 christos
1588 1.1 christos return errmsg;
1589 1.1 christos }
1590 1.1.1.3 christos
1591 1.1 christos cgen_parse_fn * const m32c_cgen_parse_handlers[] =
1592 1.1 christos {
1593 1.1 christos parse_insn_normal,
1594 1.1 christos };
1595 1.1 christos
1596 1.1 christos void
1597 1.1 christos m32c_cgen_init_asm (CGEN_CPU_DESC cd)
1598 1.1 christos {
1599 1.1 christos m32c_cgen_init_opcode_table (cd);
1600 1.1 christos m32c_cgen_init_ibld_table (cd);
1601 1.1 christos cd->parse_handlers = & m32c_cgen_parse_handlers[0];
1602 1.1 christos cd->parse_operand = m32c_cgen_parse_operand;
1603 1.1 christos #ifdef CGEN_ASM_INIT_HOOK
1604 1.1 christos CGEN_ASM_INIT_HOOK
1605 1.1 christos #endif
1606 1.1 christos }
1607 1.1 christos
1608 1.1 christos
1609 1.1 christos
1611 1.1 christos /* Regex construction routine.
1612 1.1 christos
1613 1.1 christos This translates an opcode syntax string into a regex string,
1614 1.1 christos by replacing any non-character syntax element (such as an
1615 1.1 christos opcode) with the pattern '.*'
1616 1.1 christos
1617 1.1 christos It then compiles the regex and stores it in the opcode, for
1618 1.1 christos later use by m32c_cgen_assemble_insn
1619 1.1 christos
1620 1.1.1.3 christos Returns NULL for success, an error message for failure. */
1621 1.1 christos
1622 1.1.1.3 christos char *
1623 1.1 christos m32c_cgen_build_insn_regex (CGEN_INSN *insn)
1624 1.1 christos {
1625 1.1 christos CGEN_OPCODE *opc = (CGEN_OPCODE *) CGEN_INSN_OPCODE (insn);
1626 1.1 christos const char *mnem = CGEN_INSN_MNEMONIC (insn);
1627 1.1 christos char rxbuf[CGEN_MAX_RX_ELEMENTS];
1628 1.1 christos char *rx = rxbuf;
1629 1.1 christos const CGEN_SYNTAX_CHAR_TYPE *syn;
1630 1.1 christos int reg_err;
1631 1.1 christos
1632 1.1 christos syn = CGEN_SYNTAX_STRING (CGEN_OPCODE_SYNTAX (opc));
1633 1.1 christos
1634 1.1 christos /* Mnemonics come first in the syntax string. */
1635 1.1 christos if (! CGEN_SYNTAX_MNEMONIC_P (* syn))
1636 1.1 christos return _("missing mnemonic in syntax string");
1637 1.1 christos ++syn;
1638 1.1 christos
1639 1.1 christos /* Generate a case sensitive regular expression that emulates case
1640 1.1 christos insensitive matching in the "C" locale. We cannot generate a case
1641 1.1 christos insensitive regular expression because in Turkish locales, 'i' and 'I'
1642 1.1 christos are not equal modulo case conversion. */
1643 1.1 christos
1644 1.1 christos /* Copy the literal mnemonic out of the insn. */
1645 1.1 christos for (; *mnem; mnem++)
1646 1.1 christos {
1647 1.1 christos char c = *mnem;
1648 1.1 christos
1649 1.1 christos if (ISALPHA (c))
1650 1.1 christos {
1651 1.1 christos *rx++ = '[';
1652 1.1 christos *rx++ = TOLOWER (c);
1653 1.1 christos *rx++ = TOUPPER (c);
1654 1.1 christos *rx++ = ']';
1655 1.1 christos }
1656 1.1 christos else
1657 1.1 christos *rx++ = c;
1658 1.1 christos }
1659 1.1 christos
1660 1.1 christos /* Copy any remaining literals from the syntax string into the rx. */
1661 1.1.1.3 christos for(; * syn != 0 && rx <= rxbuf + (CGEN_MAX_RX_ELEMENTS - 7 - 4); ++syn)
1662 1.1 christos {
1663 1.1 christos if (CGEN_SYNTAX_CHAR_P (* syn))
1664 1.1 christos {
1665 1.1.1.3 christos char c = CGEN_SYNTAX_CHAR (* syn);
1666 1.1 christos
1667 1.1 christos switch (c)
1668 1.1.1.3 christos {
1669 1.1.1.3 christos /* Escape any regex metacharacters in the syntax. */
1670 1.1 christos case '.': case '[': case '\\':
1671 1.1 christos case '*': case '^': case '$':
1672 1.1.1.3 christos
1673 1.1 christos #ifdef CGEN_ESCAPE_EXTENDED_REGEX
1674 1.1 christos case '?': case '{': case '}':
1675 1.1 christos case '(': case ')': case '*':
1676 1.1 christos case '|': case '+': case ']':
1677 1.1 christos #endif
1678 1.1 christos *rx++ = '\\';
1679 1.1 christos *rx++ = c;
1680 1.1 christos break;
1681 1.1 christos
1682 1.1 christos default:
1683 1.1 christos if (ISALPHA (c))
1684 1.1 christos {
1685 1.1 christos *rx++ = '[';
1686 1.1 christos *rx++ = TOLOWER (c);
1687 1.1 christos *rx++ = TOUPPER (c);
1688 1.1 christos *rx++ = ']';
1689 1.1 christos }
1690 1.1 christos else
1691 1.1 christos *rx++ = c;
1692 1.1 christos break;
1693 1.1 christos }
1694 1.1 christos }
1695 1.1 christos else
1696 1.1 christos {
1697 1.1 christos /* Replace non-syntax fields with globs. */
1698 1.1 christos *rx++ = '.';
1699 1.1 christos *rx++ = '*';
1700 1.1 christos }
1701 1.1 christos }
1702 1.1.1.3 christos
1703 1.1.1.3 christos /* Trailing whitespace ok. */
1704 1.1.1.3 christos * rx++ = '[';
1705 1.1.1.3 christos * rx++ = ' ';
1706 1.1.1.3 christos * rx++ = '\t';
1707 1.1 christos * rx++ = ']';
1708 1.1 christos * rx++ = '*';
1709 1.1.1.3 christos
1710 1.1 christos /* But anchor it after that. */
1711 1.1 christos * rx++ = '$';
1712 1.1 christos * rx = '\0';
1713 1.1 christos
1714 1.1 christos CGEN_INSN_RX (insn) = xmalloc (sizeof (regex_t));
1715 1.1.1.3 christos reg_err = regcomp ((regex_t *) CGEN_INSN_RX (insn), rxbuf, REG_NOSUB);
1716 1.1 christos
1717 1.1 christos if (reg_err == 0)
1718 1.1 christos return NULL;
1719 1.1 christos else
1720 1.1 christos {
1721 1.1 christos static char msg[80];
1722 1.1 christos
1723 1.1 christos regerror (reg_err, (regex_t *) CGEN_INSN_RX (insn), msg, 80);
1724 1.1 christos regfree ((regex_t *) CGEN_INSN_RX (insn));
1725 1.1 christos free (CGEN_INSN_RX (insn));
1726 1.1 christos (CGEN_INSN_RX (insn)) = NULL;
1727 1.1 christos return msg;
1728 1.1 christos }
1729 1.1 christos }
1730 1.1 christos
1731 1.1 christos
1732 1.1 christos /* Default insn parser.
1734 1.1 christos
1735 1.1 christos The syntax string is scanned and operands are parsed and stored in FIELDS.
1736 1.1 christos Relocs are queued as we go via other callbacks.
1737 1.1 christos
1738 1.1 christos ??? Note that this is currently an all-or-nothing parser. If we fail to
1739 1.1 christos parse the instruction, we return 0 and the caller will start over from
1740 1.1 christos the beginning. Backtracking will be necessary in parsing subexpressions,
1741 1.1 christos but that can be handled there. Not handling backtracking here may get
1742 1.1 christos expensive in the case of the m68k. Deal with later.
1743 1.1 christos
1744 1.1 christos Returns NULL for success, an error message for failure. */
1745 1.1 christos
1746 1.1 christos static const char *
1747 1.1 christos parse_insn_normal (CGEN_CPU_DESC cd,
1748 1.1 christos const CGEN_INSN *insn,
1749 1.1 christos const char **strp,
1750 1.1 christos CGEN_FIELDS *fields)
1751 1.1 christos {
1752 1.1 christos /* ??? Runtime added insns not handled yet. */
1753 1.1 christos const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
1754 1.1 christos const char *str = *strp;
1755 1.1 christos const char *errmsg;
1756 1.1 christos const char *p;
1757 1.1 christos const CGEN_SYNTAX_CHAR_TYPE * syn;
1758 1.1 christos #ifdef CGEN_MNEMONIC_OPERANDS
1759 1.1 christos /* FIXME: wip */
1760 1.1 christos int past_opcode_p;
1761 1.1 christos #endif
1762 1.1 christos
1763 1.1 christos /* For now we assume the mnemonic is first (there are no leading operands).
1764 1.1 christos We can parse it without needing to set up operand parsing.
1765 1.1 christos GAS's input scrubber will ensure mnemonics are lowercase, but we may
1766 1.1 christos not be called from GAS. */
1767 1.1 christos p = CGEN_INSN_MNEMONIC (insn);
1768 1.1 christos while (*p && TOLOWER (*p) == TOLOWER (*str))
1769 1.1 christos ++p, ++str;
1770 1.1 christos
1771 1.1 christos if (* p)
1772 1.1 christos return _("unrecognized instruction");
1773 1.1 christos
1774 1.1 christos #ifndef CGEN_MNEMONIC_OPERANDS
1775 1.1 christos if (* str && ! ISSPACE (* str))
1776 1.1 christos return _("unrecognized instruction");
1777 1.1 christos #endif
1778 1.1 christos
1779 1.1 christos CGEN_INIT_PARSE (cd);
1780 1.1 christos cgen_init_parse_operand (cd);
1781 1.1 christos #ifdef CGEN_MNEMONIC_OPERANDS
1782 1.1 christos past_opcode_p = 0;
1783 1.1 christos #endif
1784 1.1 christos
1785 1.1 christos /* We don't check for (*str != '\0') here because we want to parse
1786 1.1 christos any trailing fake arguments in the syntax string. */
1787 1.1 christos syn = CGEN_SYNTAX_STRING (syntax);
1788 1.1 christos
1789 1.1 christos /* Mnemonics come first for now, ensure valid string. */
1790 1.1 christos if (! CGEN_SYNTAX_MNEMONIC_P (* syn))
1791 1.1 christos abort ();
1792 1.1 christos
1793 1.1 christos ++syn;
1794 1.1 christos
1795 1.1 christos while (* syn != 0)
1796 1.1 christos {
1797 1.1 christos /* Non operand chars must match exactly. */
1798 1.1 christos if (CGEN_SYNTAX_CHAR_P (* syn))
1799 1.1 christos {
1800 1.1 christos /* FIXME: While we allow for non-GAS callers above, we assume the
1801 1.1 christos first char after the mnemonic part is a space. */
1802 1.1 christos /* FIXME: We also take inappropriate advantage of the fact that
1803 1.1 christos GAS's input scrubber will remove extraneous blanks. */
1804 1.1 christos if (TOLOWER (*str) == TOLOWER (CGEN_SYNTAX_CHAR (* syn)))
1805 1.1 christos {
1806 1.1 christos #ifdef CGEN_MNEMONIC_OPERANDS
1807 1.1 christos if (CGEN_SYNTAX_CHAR(* syn) == ' ')
1808 1.1 christos past_opcode_p = 1;
1809 1.1 christos #endif
1810 1.1 christos ++ syn;
1811 1.1 christos ++ str;
1812 1.1 christos }
1813 1.1 christos else if (*str)
1814 1.1 christos {
1815 1.1 christos /* Syntax char didn't match. Can't be this insn. */
1816 1.1 christos static char msg [80];
1817 1.1 christos
1818 1.1 christos /* xgettext:c-format */
1819 1.1 christos sprintf (msg, _("syntax error (expected char `%c', found `%c')"),
1820 1.1 christos CGEN_SYNTAX_CHAR(*syn), *str);
1821 1.1 christos return msg;
1822 1.1 christos }
1823 1.1 christos else
1824 1.1 christos {
1825 1.1 christos /* Ran out of input. */
1826 1.1 christos static char msg [80];
1827 1.1 christos
1828 1.1 christos /* xgettext:c-format */
1829 1.1 christos sprintf (msg, _("syntax error (expected char `%c', found end of instruction)"),
1830 1.1 christos CGEN_SYNTAX_CHAR(*syn));
1831 1.1 christos return msg;
1832 1.1 christos }
1833 1.1 christos continue;
1834 1.1 christos }
1835 1.1 christos
1836 1.1 christos #ifdef CGEN_MNEMONIC_OPERANDS
1837 1.1 christos (void) past_opcode_p;
1838 1.1 christos #endif
1839 1.1 christos /* We have an operand of some sort. */
1840 1.1 christos errmsg = cd->parse_operand (cd, CGEN_SYNTAX_FIELD (*syn), &str, fields);
1841 1.1 christos if (errmsg)
1842 1.1 christos return errmsg;
1843 1.1 christos
1844 1.1 christos /* Done with this operand, continue with next one. */
1845 1.1 christos ++ syn;
1846 1.1 christos }
1847 1.1 christos
1848 1.1 christos /* If we're at the end of the syntax string, we're done. */
1849 1.1 christos if (* syn == 0)
1850 1.1 christos {
1851 1.1 christos /* FIXME: For the moment we assume a valid `str' can only contain
1852 1.1 christos blanks now. IE: We needn't try again with a longer version of
1853 1.1 christos the insn and it is assumed that longer versions of insns appear
1854 1.1 christos before shorter ones (eg: lsr r2,r3,1 vs lsr r2,r3). */
1855 1.1 christos while (ISSPACE (* str))
1856 1.1 christos ++ str;
1857 1.1 christos
1858 1.1 christos if (* str != '\0')
1859 1.1 christos return _("junk at end of line"); /* FIXME: would like to include `str' */
1860 1.1 christos
1861 1.1 christos return NULL;
1862 1.1 christos }
1863 1.1 christos
1864 1.1 christos /* We couldn't parse it. */
1865 1.1 christos return _("unrecognized instruction");
1866 1.1 christos }
1867 1.1 christos
1868 1.1 christos /* Main entry point.
1870 1.1 christos This routine is called for each instruction to be assembled.
1871 1.1 christos STR points to the insn to be assembled.
1872 1.1 christos We assume all necessary tables have been initialized.
1873 1.1 christos The assembled instruction, less any fixups, is stored in BUF.
1874 1.1 christos Remember that if CGEN_INT_INSN_P then BUF is an int and thus the value
1875 1.1 christos still needs to be converted to target byte order, otherwise BUF is an array
1876 1.1 christos of bytes in target byte order.
1877 1.1 christos The result is a pointer to the insn's entry in the opcode table,
1878 1.1 christos or NULL if an error occured (an error message will have already been
1879 1.1 christos printed).
1880 1.1 christos
1881 1.1 christos Note that when processing (non-alias) macro-insns,
1882 1.1 christos this function recurses.
1883 1.1 christos
1884 1.1 christos ??? It's possible to make this cpu-independent.
1885 1.1 christos One would have to deal with a few minor things.
1886 1.1 christos At this point in time doing so would be more of a curiosity than useful
1887 1.1 christos [for example this file isn't _that_ big], but keeping the possibility in
1888 1.1 christos mind helps keep the design clean. */
1889 1.1 christos
1890 1.1 christos const CGEN_INSN *
1891 1.1 christos m32c_cgen_assemble_insn (CGEN_CPU_DESC cd,
1892 1.1 christos const char *str,
1893 1.1 christos CGEN_FIELDS *fields,
1894 1.1 christos CGEN_INSN_BYTES_PTR buf,
1895 1.1 christos char **errmsg)
1896 1.1 christos {
1897 1.1 christos const char *start;
1898 1.1 christos CGEN_INSN_LIST *ilist;
1899 1.1 christos const char *parse_errmsg = NULL;
1900 1.1 christos const char *insert_errmsg = NULL;
1901 1.1 christos int recognized_mnemonic = 0;
1902 1.1 christos
1903 1.1 christos /* Skip leading white space. */
1904 1.1 christos while (ISSPACE (* str))
1905 1.1 christos ++ str;
1906 1.1 christos
1907 1.1 christos /* The instructions are stored in hashed lists.
1908 1.1 christos Get the first in the list. */
1909 1.1 christos ilist = CGEN_ASM_LOOKUP_INSN (cd, str);
1910 1.1 christos
1911 1.1 christos /* Keep looking until we find a match. */
1912 1.1 christos start = str;
1913 1.1 christos for ( ; ilist != NULL ; ilist = CGEN_ASM_NEXT_INSN (ilist))
1914 1.1.1.3 christos {
1915 1.1 christos const CGEN_INSN *insn = ilist->insn;
1916 1.1 christos recognized_mnemonic = 1;
1917 1.1 christos
1918 1.1 christos #ifdef CGEN_VALIDATE_INSN_SUPPORTED
1919 1.1 christos /* Not usually needed as unsupported opcodes
1920 1.1 christos shouldn't be in the hash lists. */
1921 1.1 christos /* Is this insn supported by the selected cpu? */
1922 1.1 christos if (! m32c_cgen_insn_supported (cd, insn))
1923 1.1 christos continue;
1924 1.1 christos #endif
1925 1.1 christos /* If the RELAXED attribute is set, this is an insn that shouldn't be
1926 1.1 christos chosen immediately. Instead, it is used during assembler/linker
1927 1.1 christos relaxation if possible. */
1928 1.1 christos if (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_RELAXED) != 0)
1929 1.1 christos continue;
1930 1.1 christos
1931 1.1 christos str = start;
1932 1.1 christos
1933 1.1 christos /* Skip this insn if str doesn't look right lexically. */
1934 1.1 christos if (CGEN_INSN_RX (insn) != NULL &&
1935 1.1 christos regexec ((regex_t *) CGEN_INSN_RX (insn), str, 0, NULL, 0) == REG_NOMATCH)
1936 1.1 christos continue;
1937 1.1 christos
1938 1.1 christos /* Allow parse/insert handlers to obtain length of insn. */
1939 1.1 christos CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn);
1940 1.1 christos
1941 1.1 christos parse_errmsg = CGEN_PARSE_FN (cd, insn) (cd, insn, & str, fields);
1942 1.1 christos if (parse_errmsg != NULL)
1943 1.1 christos continue;
1944 1.1 christos
1945 1.1 christos /* ??? 0 is passed for `pc'. */
1946 1.1 christos insert_errmsg = CGEN_INSERT_FN (cd, insn) (cd, insn, fields, buf,
1947 1.1 christos (bfd_vma) 0);
1948 1.1 christos if (insert_errmsg != NULL)
1949 1.1 christos continue;
1950 1.1 christos
1951 1.1 christos /* It is up to the caller to actually output the insn and any
1952 1.1 christos queued relocs. */
1953 1.1 christos return insn;
1954 1.1 christos }
1955 1.1 christos
1956 1.1 christos {
1957 1.1 christos static char errbuf[150];
1958 1.1 christos const char *tmp_errmsg;
1959 1.1 christos #ifdef CGEN_VERBOSE_ASSEMBLER_ERRORS
1960 1.1 christos #define be_verbose 1
1961 1.1 christos #else
1962 1.1 christos #define be_verbose 0
1963 1.1 christos #endif
1964 1.1 christos
1965 1.1 christos if (be_verbose)
1966 1.1 christos {
1967 1.1 christos /* If requesting verbose error messages, use insert_errmsg.
1968 1.1 christos Failing that, use parse_errmsg. */
1969 1.1 christos tmp_errmsg = (insert_errmsg ? insert_errmsg :
1970 1.1 christos parse_errmsg ? parse_errmsg :
1971 1.1 christos recognized_mnemonic ?
1972 1.1 christos _("unrecognized form of instruction") :
1973 1.1 christos _("unrecognized instruction"));
1974 1.1.1.3 christos
1975 1.1 christos if (strlen (start) > 50)
1976 1.1 christos /* xgettext:c-format */
1977 1.1 christos sprintf (errbuf, "%s `%.50s...'", tmp_errmsg, start);
1978 1.1 christos else
1979 1.1 christos /* xgettext:c-format */
1980 1.1 christos sprintf (errbuf, "%s `%.50s'", tmp_errmsg, start);
1981 1.1 christos }
1982 1.1 christos else
1983 1.1.1.3 christos {
1984 1.1 christos if (strlen (start) > 50)
1985 1.1 christos /* xgettext:c-format */
1986 1.1 christos sprintf (errbuf, _("bad instruction `%.50s...'"), start);
1987 1.1.1.3 christos else
1988 1.1 christos /* xgettext:c-format */
1989 1.1 christos sprintf (errbuf, _("bad instruction `%.50s'"), start);
1990 1.1 christos }
1991 1.1 christos
1992 *errmsg = errbuf;
1993 return NULL;
1994 }
1995 }
1996