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