/src/binutils-gdb/opcodes/epiphany-ibld.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* DO NOT EDIT! -*- buffer-read-only: t -*- vi:set ro: */ |
2 | | /* Instruction building/extraction support for epiphany. -*- C -*- |
3 | | |
4 | | THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator. |
5 | | - the resultant file is machine generated, cgen-ibld.in isn't |
6 | | |
7 | | Copyright (C) 1996-2025 Free Software Foundation, Inc. |
8 | | |
9 | | This file is part of libopcodes. |
10 | | |
11 | | This library is free software; you can redistribute it and/or modify |
12 | | it under the terms of the GNU General Public License as published by |
13 | | the Free Software Foundation; either version 3, or (at your option) |
14 | | any later version. |
15 | | |
16 | | It is distributed in the hope that it will be useful, but WITHOUT |
17 | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
18 | | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public |
19 | | License for more details. |
20 | | |
21 | | You should have received a copy of the GNU General Public License |
22 | | along with this program; if not, write to the Free Software Foundation, Inc., |
23 | | 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ |
24 | | |
25 | | /* ??? Eventually more and more of this stuff can go to cpu-independent files. |
26 | | Keep that in mind. */ |
27 | | |
28 | | #include "sysdep.h" |
29 | | #include <stdio.h> |
30 | | #include "ansidecl.h" |
31 | | #include "dis-asm.h" |
32 | | #include "bfd.h" |
33 | | #include "symcat.h" |
34 | | #include "epiphany-desc.h" |
35 | | #include "epiphany-opc.h" |
36 | | #include "cgen/basic-modes.h" |
37 | | #include "opintl.h" |
38 | | #include "safe-ctype.h" |
39 | | |
40 | | #undef min |
41 | | #define min(a,b) ((a) < (b) ? (a) : (b)) |
42 | | #undef max |
43 | | #define max(a,b) ((a) > (b) ? (a) : (b)) |
44 | | |
45 | | /* Used by the ifield rtx function. */ |
46 | 24.7k | #define FLD(f) (fields->f) |
47 | | |
48 | | static const char * insert_normal |
49 | | (CGEN_CPU_DESC, long, unsigned int, unsigned int, unsigned int, |
50 | | unsigned int, unsigned int, unsigned int, CGEN_INSN_BYTES_PTR); |
51 | | static const char * insert_insn_normal |
52 | | (CGEN_CPU_DESC, const CGEN_INSN *, |
53 | | CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma); |
54 | | static int extract_normal |
55 | | (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, |
56 | | unsigned int, unsigned int, unsigned int, unsigned int, |
57 | | unsigned int, unsigned int, bfd_vma, long *); |
58 | | static int extract_insn_normal |
59 | | (CGEN_CPU_DESC, const CGEN_INSN *, CGEN_EXTRACT_INFO *, |
60 | | CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma); |
61 | | #if CGEN_INT_INSN_P |
62 | | static void put_insn_int_value |
63 | | (CGEN_CPU_DESC, CGEN_INSN_BYTES_PTR, int, int, CGEN_INSN_INT); |
64 | | #endif |
65 | | #if ! CGEN_INT_INSN_P |
66 | | static CGEN_INLINE void insert_1 |
67 | | (CGEN_CPU_DESC, unsigned long, int, int, int, unsigned char *); |
68 | | static CGEN_INLINE int fill_cache |
69 | | (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, bfd_vma); |
70 | | static CGEN_INLINE long extract_1 |
71 | | (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, int, unsigned char *, bfd_vma); |
72 | | #endif |
73 | | |
74 | | /* Operand insertion. */ |
75 | | |
76 | | #if ! CGEN_INT_INSN_P |
77 | | |
78 | | /* Subroutine of insert_normal. */ |
79 | | |
80 | | static CGEN_INLINE void |
81 | | insert_1 (CGEN_CPU_DESC cd, |
82 | | unsigned long value, |
83 | | int start, |
84 | | int length, |
85 | | int word_length, |
86 | | unsigned char *bufp) |
87 | | { |
88 | | unsigned long x, mask; |
89 | | int shift; |
90 | | |
91 | | x = cgen_get_insn_value (cd, bufp, word_length, cd->endian); |
92 | | |
93 | | /* Written this way to avoid undefined behaviour. */ |
94 | | mask = (1UL << (length - 1) << 1) - 1; |
95 | | if (CGEN_INSN_LSB0_P) |
96 | | shift = (start + 1) - length; |
97 | | else |
98 | | shift = (word_length - (start + length)); |
99 | | x = (x & ~(mask << shift)) | ((value & mask) << shift); |
100 | | |
101 | | cgen_put_insn_value (cd, bufp, word_length, (bfd_vma) x, cd->endian); |
102 | | } |
103 | | |
104 | | #endif /* ! CGEN_INT_INSN_P */ |
105 | | |
106 | | /* Default insertion routine. |
107 | | |
108 | | ATTRS is a mask of the boolean attributes. |
109 | | WORD_OFFSET is the offset in bits from the start of the insn of the value. |
110 | | WORD_LENGTH is the length of the word in bits in which the value resides. |
111 | | START is the starting bit number in the word, architecture origin. |
112 | | LENGTH is the length of VALUE in bits. |
113 | | TOTAL_LENGTH is the total length of the insn in bits. |
114 | | |
115 | | The result is an error message or NULL if success. */ |
116 | | |
117 | | /* ??? This duplicates functionality with bfd's howto table and |
118 | | bfd_install_relocation. */ |
119 | | /* ??? This doesn't handle bfd_vma's. Create another function when |
120 | | necessary. */ |
121 | | |
122 | | static const char * |
123 | | insert_normal (CGEN_CPU_DESC cd, |
124 | | long value, |
125 | | unsigned int attrs, |
126 | | unsigned int word_offset, |
127 | | unsigned int start, |
128 | | unsigned int length, |
129 | | unsigned int word_length, |
130 | | unsigned int total_length, |
131 | | CGEN_INSN_BYTES_PTR buffer) |
132 | 0 | { |
133 | 0 | static char errbuf[100]; |
134 | 0 | unsigned long mask; |
135 | | |
136 | | /* If LENGTH is zero, this operand doesn't contribute to the value. */ |
137 | 0 | if (length == 0) |
138 | 0 | return NULL; |
139 | | |
140 | | /* Written this way to avoid undefined behaviour. */ |
141 | 0 | mask = (1UL << (length - 1) << 1) - 1; |
142 | |
|
143 | 0 | if (word_length > 8 * sizeof (CGEN_INSN_INT)) |
144 | 0 | abort (); |
145 | | |
146 | | /* For architectures with insns smaller than the base-insn-bitsize, |
147 | | word_length may be too big. */ |
148 | 0 | if (cd->min_insn_bitsize < cd->base_insn_bitsize) |
149 | 0 | { |
150 | 0 | if (word_offset == 0 |
151 | 0 | && word_length > total_length) |
152 | 0 | word_length = total_length; |
153 | 0 | } |
154 | | |
155 | | /* Ensure VALUE will fit. */ |
156 | 0 | if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGN_OPT)) |
157 | 0 | { |
158 | 0 | long minval = - (1UL << (length - 1)); |
159 | 0 | unsigned long maxval = mask; |
160 | |
|
161 | 0 | if ((value > 0 && (unsigned long) value > maxval) |
162 | 0 | || value < minval) |
163 | 0 | { |
164 | | /* xgettext:c-format */ |
165 | 0 | sprintf (errbuf, |
166 | 0 | _("operand out of range (%ld not between %ld and %lu)"), |
167 | 0 | value, minval, maxval); |
168 | 0 | return errbuf; |
169 | 0 | } |
170 | 0 | } |
171 | 0 | else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)) |
172 | 0 | { |
173 | 0 | unsigned long maxval = mask; |
174 | 0 | unsigned long val = (unsigned long) value; |
175 | | |
176 | | /* For hosts with a word size > 32 check to see if value has been sign |
177 | | extended beyond 32 bits. If so then ignore these higher sign bits |
178 | | as the user is attempting to store a 32-bit signed value into an |
179 | | unsigned 32-bit field which is allowed. */ |
180 | 0 | if (sizeof (unsigned long) > 4 && ((value >> 32) == -1)) |
181 | 0 | val &= 0xFFFFFFFF; |
182 | |
|
183 | 0 | if (val > maxval) |
184 | 0 | { |
185 | | /* xgettext:c-format */ |
186 | 0 | sprintf (errbuf, |
187 | 0 | _("operand out of range (0x%lx not between 0 and 0x%lx)"), |
188 | 0 | val, maxval); |
189 | 0 | return errbuf; |
190 | 0 | } |
191 | 0 | } |
192 | 0 | else |
193 | 0 | { |
194 | 0 | if (! cgen_signed_overflow_ok_p (cd)) |
195 | 0 | { |
196 | 0 | long minval = - (1UL << (length - 1)); |
197 | 0 | long maxval = (1UL << (length - 1)) - 1; |
198 | |
|
199 | 0 | if (value < minval || value > maxval) |
200 | 0 | { |
201 | 0 | sprintf |
202 | | /* xgettext:c-format */ |
203 | 0 | (errbuf, _("operand out of range (%ld not between %ld and %ld)"), |
204 | 0 | value, minval, maxval); |
205 | 0 | return errbuf; |
206 | 0 | } |
207 | 0 | } |
208 | 0 | } |
209 | | |
210 | 0 | #if CGEN_INT_INSN_P |
211 | | |
212 | 0 | { |
213 | 0 | int shift_within_word, shift_to_word, shift; |
214 | | |
215 | | /* How to shift the value to BIT0 of the word. */ |
216 | 0 | shift_to_word = total_length - (word_offset + word_length); |
217 | | |
218 | | /* How to shift the value to the field within the word. */ |
219 | 0 | if (CGEN_INSN_LSB0_P) |
220 | 0 | shift_within_word = start + 1 - length; |
221 | 0 | else |
222 | 0 | shift_within_word = word_length - start - length; |
223 | | |
224 | | /* The total SHIFT, then mask in the value. */ |
225 | 0 | shift = shift_to_word + shift_within_word; |
226 | 0 | *buffer = (*buffer & ~(mask << shift)) | ((value & mask) << shift); |
227 | 0 | } |
228 | |
|
229 | | #else /* ! CGEN_INT_INSN_P */ |
230 | | |
231 | | { |
232 | | unsigned char *bufp = (unsigned char *) buffer + word_offset / 8; |
233 | | |
234 | | insert_1 (cd, value, start, length, word_length, bufp); |
235 | | } |
236 | | |
237 | | #endif /* ! CGEN_INT_INSN_P */ |
238 | |
|
239 | 0 | return NULL; |
240 | 0 | } |
241 | | |
242 | | /* Default insn builder (insert handler). |
243 | | The instruction is recorded in CGEN_INT_INSN_P byte order (meaning |
244 | | that if CGEN_INSN_BYTES_PTR is an int * and thus, the value is |
245 | | recorded in host byte order, otherwise BUFFER is an array of bytes |
246 | | and the value is recorded in target byte order). |
247 | | The result is an error message or NULL if success. */ |
248 | | |
249 | | static const char * |
250 | | insert_insn_normal (CGEN_CPU_DESC cd, |
251 | | const CGEN_INSN * insn, |
252 | | CGEN_FIELDS * fields, |
253 | | CGEN_INSN_BYTES_PTR buffer, |
254 | | bfd_vma pc) |
255 | 0 | { |
256 | 0 | const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); |
257 | 0 | unsigned long value; |
258 | 0 | const CGEN_SYNTAX_CHAR_TYPE * syn; |
259 | |
|
260 | 0 | CGEN_INIT_INSERT (cd); |
261 | 0 | value = CGEN_INSN_BASE_VALUE (insn); |
262 | | |
263 | | /* If we're recording insns as numbers (rather than a string of bytes), |
264 | | target byte order handling is deferred until later. */ |
265 | |
|
266 | 0 | #if CGEN_INT_INSN_P |
267 | |
|
268 | 0 | put_insn_int_value (cd, buffer, cd->base_insn_bitsize, |
269 | 0 | CGEN_FIELDS_BITSIZE (fields), value); |
270 | |
|
271 | | #else |
272 | | |
273 | | cgen_put_insn_value (cd, buffer, min ((unsigned) cd->base_insn_bitsize, |
274 | | (unsigned) CGEN_FIELDS_BITSIZE (fields)), |
275 | | value, cd->insn_endian); |
276 | | |
277 | | #endif /* ! CGEN_INT_INSN_P */ |
278 | | |
279 | | /* ??? It would be better to scan the format's fields. |
280 | | Still need to be able to insert a value based on the operand though; |
281 | | e.g. storing a branch displacement that got resolved later. |
282 | | Needs more thought first. */ |
283 | |
|
284 | 0 | for (syn = CGEN_SYNTAX_STRING (syntax); * syn; ++ syn) |
285 | 0 | { |
286 | 0 | const char *errmsg; |
287 | |
|
288 | 0 | if (CGEN_SYNTAX_CHAR_P (* syn)) |
289 | 0 | continue; |
290 | | |
291 | 0 | errmsg = (* cd->insert_operand) (cd, CGEN_SYNTAX_FIELD (*syn), |
292 | 0 | fields, buffer, pc); |
293 | 0 | if (errmsg) |
294 | 0 | return errmsg; |
295 | 0 | } |
296 | | |
297 | 0 | return NULL; |
298 | 0 | } |
299 | | |
300 | | #if CGEN_INT_INSN_P |
301 | | /* Cover function to store an insn value into an integral insn. Must go here |
302 | | because it needs <prefix>-desc.h for CGEN_INT_INSN_P. */ |
303 | | |
304 | | static void |
305 | | put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, |
306 | | CGEN_INSN_BYTES_PTR buf, |
307 | | int length, |
308 | | int insn_length, |
309 | | CGEN_INSN_INT value) |
310 | 0 | { |
311 | | /* For architectures with insns smaller than the base-insn-bitsize, |
312 | | length may be too big. */ |
313 | 0 | if (length > insn_length) |
314 | 0 | *buf = value; |
315 | 0 | else |
316 | 0 | { |
317 | 0 | int shift = insn_length - length; |
318 | | /* Written this way to avoid undefined behaviour. */ |
319 | 0 | CGEN_INSN_INT mask = length == 0 ? 0 : (1UL << (length - 1) << 1) - 1; |
320 | |
|
321 | 0 | *buf = (*buf & ~(mask << shift)) | ((value & mask) << shift); |
322 | 0 | } |
323 | 0 | } |
324 | | #endif |
325 | | |
326 | | /* Operand extraction. */ |
327 | | |
328 | | #if ! CGEN_INT_INSN_P |
329 | | |
330 | | /* Subroutine of extract_normal. |
331 | | Ensure sufficient bytes are cached in EX_INFO. |
332 | | OFFSET is the offset in bytes from the start of the insn of the value. |
333 | | BYTES is the length of the needed value. |
334 | | Returns 1 for success, 0 for failure. */ |
335 | | |
336 | | static CGEN_INLINE int |
337 | | fill_cache (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, |
338 | | CGEN_EXTRACT_INFO *ex_info, |
339 | | int offset, |
340 | | int bytes, |
341 | | bfd_vma pc) |
342 | | { |
343 | | /* It's doubtful that the middle part has already been fetched so |
344 | | we don't optimize that case. kiss. */ |
345 | | unsigned int mask; |
346 | | disassemble_info *info = (disassemble_info *) ex_info->dis_info; |
347 | | |
348 | | /* First do a quick check. */ |
349 | | mask = (1 << bytes) - 1; |
350 | | if (((ex_info->valid >> offset) & mask) == mask) |
351 | | return 1; |
352 | | |
353 | | /* Search for the first byte we need to read. */ |
354 | | for (mask = 1 << offset; bytes > 0; --bytes, ++offset, mask <<= 1) |
355 | | if (! (mask & ex_info->valid)) |
356 | | break; |
357 | | |
358 | | if (bytes) |
359 | | { |
360 | | int status; |
361 | | |
362 | | pc += offset; |
363 | | status = (*info->read_memory_func) |
364 | | (pc, ex_info->insn_bytes + offset, bytes, info); |
365 | | |
366 | | if (status != 0) |
367 | | { |
368 | | (*info->memory_error_func) (status, pc, info); |
369 | | return 0; |
370 | | } |
371 | | |
372 | | ex_info->valid |= ((1 << bytes) - 1) << offset; |
373 | | } |
374 | | |
375 | | return 1; |
376 | | } |
377 | | |
378 | | /* Subroutine of extract_normal. */ |
379 | | |
380 | | static CGEN_INLINE long |
381 | | extract_1 (CGEN_CPU_DESC cd, |
382 | | CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED, |
383 | | int start, |
384 | | int length, |
385 | | int word_length, |
386 | | unsigned char *bufp, |
387 | | bfd_vma pc ATTRIBUTE_UNUSED) |
388 | | { |
389 | | unsigned long x; |
390 | | int shift; |
391 | | |
392 | | x = cgen_get_insn_value (cd, bufp, word_length, cd->endian); |
393 | | |
394 | | if (CGEN_INSN_LSB0_P) |
395 | | shift = (start + 1) - length; |
396 | | else |
397 | | shift = (word_length - (start + length)); |
398 | | return x >> shift; |
399 | | } |
400 | | |
401 | | #endif /* ! CGEN_INT_INSN_P */ |
402 | | |
403 | | /* Default extraction routine. |
404 | | |
405 | | INSN_VALUE is the first base_insn_bitsize bits of the insn in host order, |
406 | | or sometimes less for cases like the m32r where the base insn size is 32 |
407 | | but some insns are 16 bits. |
408 | | ATTRS is a mask of the boolean attributes. We only need `SIGNED', |
409 | | but for generality we take a bitmask of all of them. |
410 | | WORD_OFFSET is the offset in bits from the start of the insn of the value. |
411 | | WORD_LENGTH is the length of the word in bits in which the value resides. |
412 | | START is the starting bit number in the word, architecture origin. |
413 | | LENGTH is the length of VALUE in bits. |
414 | | TOTAL_LENGTH is the total length of the insn in bits. |
415 | | |
416 | | Returns 1 for success, 0 for failure. */ |
417 | | |
418 | | /* ??? The return code isn't properly used. wip. */ |
419 | | |
420 | | /* ??? This doesn't handle bfd_vma's. Create another function when |
421 | | necessary. */ |
422 | | |
423 | | static int |
424 | | extract_normal (CGEN_CPU_DESC cd, |
425 | | #if ! CGEN_INT_INSN_P |
426 | | CGEN_EXTRACT_INFO *ex_info, |
427 | | #else |
428 | | CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED, |
429 | | #endif |
430 | | CGEN_INSN_INT insn_value, |
431 | | unsigned int attrs, |
432 | | unsigned int word_offset, |
433 | | unsigned int start, |
434 | | unsigned int length, |
435 | | unsigned int word_length, |
436 | | unsigned int total_length, |
437 | | #if ! CGEN_INT_INSN_P |
438 | | bfd_vma pc, |
439 | | #else |
440 | | bfd_vma pc ATTRIBUTE_UNUSED, |
441 | | #endif |
442 | | long *valuep) |
443 | 83.9k | { |
444 | 83.9k | long value, mask; |
445 | | |
446 | | /* If LENGTH is zero, this operand doesn't contribute to the value |
447 | | so give it a standard value of zero. */ |
448 | 83.9k | if (length == 0) |
449 | 0 | { |
450 | 0 | *valuep = 0; |
451 | 0 | return 1; |
452 | 0 | } |
453 | | |
454 | 83.9k | if (word_length > 8 * sizeof (CGEN_INSN_INT)) |
455 | 0 | abort (); |
456 | | |
457 | | /* For architectures with insns smaller than the insn-base-bitsize, |
458 | | word_length may be too big. */ |
459 | 83.9k | if (cd->min_insn_bitsize < cd->base_insn_bitsize) |
460 | 83.9k | { |
461 | 83.9k | if (word_offset + word_length > total_length) |
462 | 63.9k | word_length = total_length - word_offset; |
463 | 83.9k | } |
464 | | |
465 | | /* Does the value reside in INSN_VALUE, and at the right alignment? */ |
466 | | |
467 | 83.9k | if (CGEN_INT_INSN_P || (word_offset == 0 && word_length == total_length)) |
468 | 83.9k | { |
469 | 83.9k | if (CGEN_INSN_LSB0_P) |
470 | 83.9k | value = insn_value >> ((word_offset + start + 1) - length); |
471 | 0 | else |
472 | 0 | value = insn_value >> (total_length - ( word_offset + start + length)); |
473 | 83.9k | } |
474 | | |
475 | | #if ! CGEN_INT_INSN_P |
476 | | |
477 | | else |
478 | | { |
479 | | unsigned char *bufp = ex_info->insn_bytes + word_offset / 8; |
480 | | |
481 | | if (word_length > 8 * sizeof (CGEN_INSN_INT)) |
482 | | abort (); |
483 | | |
484 | | if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0) |
485 | | { |
486 | | *valuep = 0; |
487 | | return 0; |
488 | | } |
489 | | |
490 | | value = extract_1 (cd, ex_info, start, length, word_length, bufp, pc); |
491 | | } |
492 | | |
493 | | #endif /* ! CGEN_INT_INSN_P */ |
494 | | |
495 | | /* Written this way to avoid undefined behaviour. */ |
496 | 83.9k | mask = (1UL << (length - 1) << 1) - 1; |
497 | | |
498 | 83.9k | value &= mask; |
499 | | /* sign extend? */ |
500 | 83.9k | if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED) |
501 | 83.9k | && (value & (1UL << (length - 1)))) |
502 | 4.25k | value |= ~mask; |
503 | | |
504 | 83.9k | *valuep = value; |
505 | | |
506 | 83.9k | return 1; |
507 | 83.9k | } |
508 | | |
509 | | /* Default insn extractor. |
510 | | |
511 | | INSN_VALUE is the first base_insn_bitsize bits, translated to host order. |
512 | | The extracted fields are stored in FIELDS. |
513 | | EX_INFO is used to handle reading variable length insns. |
514 | | Return the length of the insn in bits, or 0 if no match, |
515 | | or -1 if an error occurs fetching data (memory_error_func will have |
516 | | been called). */ |
517 | | |
518 | | static int |
519 | | extract_insn_normal (CGEN_CPU_DESC cd, |
520 | | const CGEN_INSN *insn, |
521 | | CGEN_EXTRACT_INFO *ex_info, |
522 | | CGEN_INSN_INT insn_value, |
523 | | CGEN_FIELDS *fields, |
524 | | bfd_vma pc) |
525 | 37.2k | { |
526 | 37.2k | const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); |
527 | 37.2k | const CGEN_SYNTAX_CHAR_TYPE *syn; |
528 | | |
529 | 37.2k | CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn); |
530 | | |
531 | 37.2k | CGEN_INIT_EXTRACT (cd); |
532 | | |
533 | 245k | for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn) |
534 | 207k | { |
535 | 207k | int length; |
536 | | |
537 | 207k | if (CGEN_SYNTAX_CHAR_P (*syn)) |
538 | 132k | continue; |
539 | | |
540 | 75.7k | length = (* cd->extract_operand) (cd, CGEN_SYNTAX_FIELD (*syn), |
541 | 75.7k | ex_info, insn_value, fields, pc); |
542 | 75.7k | if (length <= 0) |
543 | 0 | return length; |
544 | 75.7k | } |
545 | | |
546 | | /* We recognized and successfully extracted this insn. */ |
547 | 37.2k | return CGEN_INSN_BITSIZE (insn); |
548 | 37.2k | } |
549 | | |
550 | | /* Machine generated code added here. */ |
551 | | |
552 | | const char * epiphany_cgen_insert_operand |
553 | | (CGEN_CPU_DESC, int, CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma); |
554 | | |
555 | | /* Main entry point for operand insertion. |
556 | | |
557 | | This function is basically just a big switch statement. Earlier versions |
558 | | used tables to look up the function to use, but |
559 | | - if the table contains both assembler and disassembler functions then |
560 | | the disassembler contains much of the assembler and vice-versa, |
561 | | - there's a lot of inlining possibilities as things grow, |
562 | | - using a switch statement avoids the function call overhead. |
563 | | |
564 | | This function could be moved into `parse_insn_normal', but keeping it |
565 | | separate makes clear the interface between `parse_insn_normal' and each of |
566 | | the handlers. It's also needed by GAS to insert operands that couldn't be |
567 | | resolved during parsing. */ |
568 | | |
569 | | const char * |
570 | | epiphany_cgen_insert_operand (CGEN_CPU_DESC cd, |
571 | | int opindex, |
572 | | CGEN_FIELDS * fields, |
573 | | CGEN_INSN_BYTES_PTR buffer, |
574 | | bfd_vma pc ATTRIBUTE_UNUSED) |
575 | 0 | { |
576 | 0 | const char * errmsg = NULL; |
577 | 0 | unsigned int total_length = CGEN_FIELDS_BITSIZE (fields); |
578 | |
|
579 | 0 | switch (opindex) |
580 | 0 | { |
581 | 0 | case EPIPHANY_OPERAND_DIRECTION : |
582 | 0 | errmsg = insert_normal (cd, fields->f_addsubx, 0, 0, 20, 1, 32, total_length, buffer); |
583 | 0 | break; |
584 | 0 | case EPIPHANY_OPERAND_DISP11 : |
585 | 0 | { |
586 | 0 | { |
587 | 0 | FLD (f_disp8) = ((((UINT) (FLD (f_disp11)) >> (3))) & (255)); |
588 | 0 | FLD (f_disp3) = ((FLD (f_disp11)) & (7)); |
589 | 0 | } |
590 | 0 | errmsg = insert_normal (cd, fields->f_disp3, 0, 0, 9, 3, 32, total_length, buffer); |
591 | 0 | if (errmsg) |
592 | 0 | break; |
593 | 0 | errmsg = insert_normal (cd, fields->f_disp8, 0, 0, 23, 8, 32, total_length, buffer); |
594 | 0 | if (errmsg) |
595 | 0 | break; |
596 | 0 | } |
597 | 0 | break; |
598 | 0 | case EPIPHANY_OPERAND_DISP3 : |
599 | 0 | errmsg = insert_normal (cd, fields->f_disp3, 0, 0, 9, 3, 32, total_length, buffer); |
600 | 0 | break; |
601 | 0 | case EPIPHANY_OPERAND_DPMI : |
602 | 0 | errmsg = insert_normal (cd, fields->f_subd, 0, 0, 24, 1, 32, total_length, buffer); |
603 | 0 | break; |
604 | 0 | case EPIPHANY_OPERAND_FRD : |
605 | 0 | errmsg = insert_normal (cd, fields->f_rd, 0, 0, 15, 3, 32, total_length, buffer); |
606 | 0 | break; |
607 | 0 | case EPIPHANY_OPERAND_FRD6 : |
608 | 0 | { |
609 | 0 | { |
610 | 0 | FLD (f_rd) = ((FLD (f_rd6)) & (7)); |
611 | 0 | FLD (f_rd_x) = ((UINT) (FLD (f_rd6)) >> (3)); |
612 | 0 | } |
613 | 0 | errmsg = insert_normal (cd, fields->f_rd_x, 0, 0, 31, 3, 32, total_length, buffer); |
614 | 0 | if (errmsg) |
615 | 0 | break; |
616 | 0 | errmsg = insert_normal (cd, fields->f_rd, 0, 0, 15, 3, 32, total_length, buffer); |
617 | 0 | if (errmsg) |
618 | 0 | break; |
619 | 0 | } |
620 | 0 | break; |
621 | 0 | case EPIPHANY_OPERAND_FRM : |
622 | 0 | errmsg = insert_normal (cd, fields->f_rm, 0, 0, 9, 3, 32, total_length, buffer); |
623 | 0 | break; |
624 | 0 | case EPIPHANY_OPERAND_FRM6 : |
625 | 0 | { |
626 | 0 | { |
627 | 0 | FLD (f_rm) = ((FLD (f_rm6)) & (7)); |
628 | 0 | FLD (f_rm_x) = ((UINT) (FLD (f_rm6)) >> (3)); |
629 | 0 | } |
630 | 0 | errmsg = insert_normal (cd, fields->f_rm_x, 0, 0, 25, 3, 32, total_length, buffer); |
631 | 0 | if (errmsg) |
632 | 0 | break; |
633 | 0 | errmsg = insert_normal (cd, fields->f_rm, 0, 0, 9, 3, 32, total_length, buffer); |
634 | 0 | if (errmsg) |
635 | 0 | break; |
636 | 0 | } |
637 | 0 | break; |
638 | 0 | case EPIPHANY_OPERAND_FRN : |
639 | 0 | errmsg = insert_normal (cd, fields->f_rn, 0, 0, 12, 3, 32, total_length, buffer); |
640 | 0 | break; |
641 | 0 | case EPIPHANY_OPERAND_FRN6 : |
642 | 0 | { |
643 | 0 | { |
644 | 0 | FLD (f_rn) = ((FLD (f_rn6)) & (7)); |
645 | 0 | FLD (f_rn_x) = ((UINT) (FLD (f_rn6)) >> (3)); |
646 | 0 | } |
647 | 0 | errmsg = insert_normal (cd, fields->f_rn_x, 0, 0, 28, 3, 32, total_length, buffer); |
648 | 0 | if (errmsg) |
649 | 0 | break; |
650 | 0 | errmsg = insert_normal (cd, fields->f_rn, 0, 0, 12, 3, 32, total_length, buffer); |
651 | 0 | if (errmsg) |
652 | 0 | break; |
653 | 0 | } |
654 | 0 | break; |
655 | 0 | case EPIPHANY_OPERAND_IMM16 : |
656 | 0 | { |
657 | 0 | { |
658 | 0 | FLD (f_imm8) = ((FLD (f_imm16)) & (255)); |
659 | 0 | FLD (f_imm_27_8) = ((UINT) (FLD (f_imm16)) >> (8)); |
660 | 0 | } |
661 | 0 | errmsg = insert_normal (cd, fields->f_imm8, 0, 0, 12, 8, 32, total_length, buffer); |
662 | 0 | if (errmsg) |
663 | 0 | break; |
664 | 0 | errmsg = insert_normal (cd, fields->f_imm_27_8, 0, 0, 27, 8, 32, total_length, buffer); |
665 | 0 | if (errmsg) |
666 | 0 | break; |
667 | 0 | } |
668 | 0 | break; |
669 | 0 | case EPIPHANY_OPERAND_IMM8 : |
670 | 0 | errmsg = insert_normal (cd, fields->f_imm8, 0, 0, 12, 8, 32, total_length, buffer); |
671 | 0 | break; |
672 | 0 | case EPIPHANY_OPERAND_RD : |
673 | 0 | errmsg = insert_normal (cd, fields->f_rd, 0, 0, 15, 3, 32, total_length, buffer); |
674 | 0 | break; |
675 | 0 | case EPIPHANY_OPERAND_RD6 : |
676 | 0 | { |
677 | 0 | { |
678 | 0 | FLD (f_rd) = ((FLD (f_rd6)) & (7)); |
679 | 0 | FLD (f_rd_x) = ((UINT) (FLD (f_rd6)) >> (3)); |
680 | 0 | } |
681 | 0 | errmsg = insert_normal (cd, fields->f_rd_x, 0, 0, 31, 3, 32, total_length, buffer); |
682 | 0 | if (errmsg) |
683 | 0 | break; |
684 | 0 | errmsg = insert_normal (cd, fields->f_rd, 0, 0, 15, 3, 32, total_length, buffer); |
685 | 0 | if (errmsg) |
686 | 0 | break; |
687 | 0 | } |
688 | 0 | break; |
689 | 0 | case EPIPHANY_OPERAND_RM : |
690 | 0 | errmsg = insert_normal (cd, fields->f_rm, 0, 0, 9, 3, 32, total_length, buffer); |
691 | 0 | break; |
692 | 0 | case EPIPHANY_OPERAND_RM6 : |
693 | 0 | { |
694 | 0 | { |
695 | 0 | FLD (f_rm) = ((FLD (f_rm6)) & (7)); |
696 | 0 | FLD (f_rm_x) = ((UINT) (FLD (f_rm6)) >> (3)); |
697 | 0 | } |
698 | 0 | errmsg = insert_normal (cd, fields->f_rm_x, 0, 0, 25, 3, 32, total_length, buffer); |
699 | 0 | if (errmsg) |
700 | 0 | break; |
701 | 0 | errmsg = insert_normal (cd, fields->f_rm, 0, 0, 9, 3, 32, total_length, buffer); |
702 | 0 | if (errmsg) |
703 | 0 | break; |
704 | 0 | } |
705 | 0 | break; |
706 | 0 | case EPIPHANY_OPERAND_RN : |
707 | 0 | errmsg = insert_normal (cd, fields->f_rn, 0, 0, 12, 3, 32, total_length, buffer); |
708 | 0 | break; |
709 | 0 | case EPIPHANY_OPERAND_RN6 : |
710 | 0 | { |
711 | 0 | { |
712 | 0 | FLD (f_rn) = ((FLD (f_rn6)) & (7)); |
713 | 0 | FLD (f_rn_x) = ((UINT) (FLD (f_rn6)) >> (3)); |
714 | 0 | } |
715 | 0 | errmsg = insert_normal (cd, fields->f_rn_x, 0, 0, 28, 3, 32, total_length, buffer); |
716 | 0 | if (errmsg) |
717 | 0 | break; |
718 | 0 | errmsg = insert_normal (cd, fields->f_rn, 0, 0, 12, 3, 32, total_length, buffer); |
719 | 0 | if (errmsg) |
720 | 0 | break; |
721 | 0 | } |
722 | 0 | break; |
723 | 0 | case EPIPHANY_OPERAND_SD : |
724 | 0 | errmsg = insert_normal (cd, fields->f_sd, 0, 0, 15, 3, 32, total_length, buffer); |
725 | 0 | break; |
726 | 0 | case EPIPHANY_OPERAND_SD6 : |
727 | 0 | { |
728 | 0 | { |
729 | 0 | FLD (f_sd) = ((FLD (f_sd6)) & (7)); |
730 | 0 | FLD (f_sd_x) = ((UINT) (FLD (f_sd6)) >> (3)); |
731 | 0 | } |
732 | 0 | errmsg = insert_normal (cd, fields->f_sd_x, 0, 0, 31, 3, 32, total_length, buffer); |
733 | 0 | if (errmsg) |
734 | 0 | break; |
735 | 0 | errmsg = insert_normal (cd, fields->f_sd, 0, 0, 15, 3, 32, total_length, buffer); |
736 | 0 | if (errmsg) |
737 | 0 | break; |
738 | 0 | } |
739 | 0 | break; |
740 | 0 | case EPIPHANY_OPERAND_SDDMA : |
741 | 0 | { |
742 | 0 | { |
743 | 0 | FLD (f_sd) = ((FLD (f_sd6)) & (7)); |
744 | 0 | FLD (f_sd_x) = ((UINT) (FLD (f_sd6)) >> (3)); |
745 | 0 | } |
746 | 0 | errmsg = insert_normal (cd, fields->f_sd_x, 0, 0, 31, 3, 32, total_length, buffer); |
747 | 0 | if (errmsg) |
748 | 0 | break; |
749 | 0 | errmsg = insert_normal (cd, fields->f_sd, 0, 0, 15, 3, 32, total_length, buffer); |
750 | 0 | if (errmsg) |
751 | 0 | break; |
752 | 0 | } |
753 | 0 | break; |
754 | 0 | case EPIPHANY_OPERAND_SDMEM : |
755 | 0 | { |
756 | 0 | { |
757 | 0 | FLD (f_sd) = ((FLD (f_sd6)) & (7)); |
758 | 0 | FLD (f_sd_x) = ((UINT) (FLD (f_sd6)) >> (3)); |
759 | 0 | } |
760 | 0 | errmsg = insert_normal (cd, fields->f_sd_x, 0, 0, 31, 3, 32, total_length, buffer); |
761 | 0 | if (errmsg) |
762 | 0 | break; |
763 | 0 | errmsg = insert_normal (cd, fields->f_sd, 0, 0, 15, 3, 32, total_length, buffer); |
764 | 0 | if (errmsg) |
765 | 0 | break; |
766 | 0 | } |
767 | 0 | break; |
768 | 0 | case EPIPHANY_OPERAND_SDMESH : |
769 | 0 | { |
770 | 0 | { |
771 | 0 | FLD (f_sd) = ((FLD (f_sd6)) & (7)); |
772 | 0 | FLD (f_sd_x) = ((UINT) (FLD (f_sd6)) >> (3)); |
773 | 0 | } |
774 | 0 | errmsg = insert_normal (cd, fields->f_sd_x, 0, 0, 31, 3, 32, total_length, buffer); |
775 | 0 | if (errmsg) |
776 | 0 | break; |
777 | 0 | errmsg = insert_normal (cd, fields->f_sd, 0, 0, 15, 3, 32, total_length, buffer); |
778 | 0 | if (errmsg) |
779 | 0 | break; |
780 | 0 | } |
781 | 0 | break; |
782 | 0 | case EPIPHANY_OPERAND_SHIFT : |
783 | 0 | errmsg = insert_normal (cd, fields->f_shift, 0, 0, 9, 5, 32, total_length, buffer); |
784 | 0 | break; |
785 | 0 | case EPIPHANY_OPERAND_SIMM11 : |
786 | 0 | { |
787 | 0 | { |
788 | 0 | FLD (f_disp8) = ((255) & (((USI) (FLD (f_sdisp11)) >> (3)))); |
789 | 0 | FLD (f_disp3) = ((FLD (f_sdisp11)) & (7)); |
790 | 0 | } |
791 | 0 | errmsg = insert_normal (cd, fields->f_disp3, 0, 0, 9, 3, 32, total_length, buffer); |
792 | 0 | if (errmsg) |
793 | 0 | break; |
794 | 0 | errmsg = insert_normal (cd, fields->f_disp8, 0, 0, 23, 8, 32, total_length, buffer); |
795 | 0 | if (errmsg) |
796 | 0 | break; |
797 | 0 | } |
798 | 0 | break; |
799 | 0 | case EPIPHANY_OPERAND_SIMM24 : |
800 | 0 | { |
801 | 0 | long value = fields->f_simm24; |
802 | 0 | value = ((SI) (((value) - (pc))) >> (1)); |
803 | 0 | errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 31, 24, 32, total_length, buffer); |
804 | 0 | } |
805 | 0 | break; |
806 | 0 | case EPIPHANY_OPERAND_SIMM3 : |
807 | 0 | errmsg = insert_normal (cd, fields->f_sdisp3, 0|(1<<CGEN_IFLD_SIGNED), 0, 9, 3, 32, total_length, buffer); |
808 | 0 | break; |
809 | 0 | case EPIPHANY_OPERAND_SIMM8 : |
810 | 0 | { |
811 | 0 | long value = fields->f_simm8; |
812 | 0 | value = ((SI) (((value) - (pc))) >> (1)); |
813 | 0 | errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 15, 8, 32, total_length, buffer); |
814 | 0 | } |
815 | 0 | break; |
816 | 0 | case EPIPHANY_OPERAND_SN : |
817 | 0 | errmsg = insert_normal (cd, fields->f_sn, 0, 0, 12, 3, 32, total_length, buffer); |
818 | 0 | break; |
819 | 0 | case EPIPHANY_OPERAND_SN6 : |
820 | 0 | { |
821 | 0 | { |
822 | 0 | FLD (f_sn) = ((FLD (f_sn6)) & (7)); |
823 | 0 | FLD (f_sn_x) = ((UINT) (FLD (f_sn6)) >> (3)); |
824 | 0 | } |
825 | 0 | errmsg = insert_normal (cd, fields->f_sn_x, 0, 0, 28, 3, 32, total_length, buffer); |
826 | 0 | if (errmsg) |
827 | 0 | break; |
828 | 0 | errmsg = insert_normal (cd, fields->f_sn, 0, 0, 12, 3, 32, total_length, buffer); |
829 | 0 | if (errmsg) |
830 | 0 | break; |
831 | 0 | } |
832 | 0 | break; |
833 | 0 | case EPIPHANY_OPERAND_SNDMA : |
834 | 0 | { |
835 | 0 | { |
836 | 0 | FLD (f_sn) = ((FLD (f_sn6)) & (7)); |
837 | 0 | FLD (f_sn_x) = ((UINT) (FLD (f_sn6)) >> (3)); |
838 | 0 | } |
839 | 0 | errmsg = insert_normal (cd, fields->f_sn_x, 0, 0, 28, 3, 32, total_length, buffer); |
840 | 0 | if (errmsg) |
841 | 0 | break; |
842 | 0 | errmsg = insert_normal (cd, fields->f_sn, 0, 0, 12, 3, 32, total_length, buffer); |
843 | 0 | if (errmsg) |
844 | 0 | break; |
845 | 0 | } |
846 | 0 | break; |
847 | 0 | case EPIPHANY_OPERAND_SNMEM : |
848 | 0 | { |
849 | 0 | { |
850 | 0 | FLD (f_sn) = ((FLD (f_sn6)) & (7)); |
851 | 0 | FLD (f_sn_x) = ((UINT) (FLD (f_sn6)) >> (3)); |
852 | 0 | } |
853 | 0 | errmsg = insert_normal (cd, fields->f_sn_x, 0, 0, 28, 3, 32, total_length, buffer); |
854 | 0 | if (errmsg) |
855 | 0 | break; |
856 | 0 | errmsg = insert_normal (cd, fields->f_sn, 0, 0, 12, 3, 32, total_length, buffer); |
857 | 0 | if (errmsg) |
858 | 0 | break; |
859 | 0 | } |
860 | 0 | break; |
861 | 0 | case EPIPHANY_OPERAND_SNMESH : |
862 | 0 | { |
863 | 0 | { |
864 | 0 | FLD (f_sn) = ((FLD (f_sn6)) & (7)); |
865 | 0 | FLD (f_sn_x) = ((UINT) (FLD (f_sn6)) >> (3)); |
866 | 0 | } |
867 | 0 | errmsg = insert_normal (cd, fields->f_sn_x, 0, 0, 28, 3, 32, total_length, buffer); |
868 | 0 | if (errmsg) |
869 | 0 | break; |
870 | 0 | errmsg = insert_normal (cd, fields->f_sn, 0, 0, 12, 3, 32, total_length, buffer); |
871 | 0 | if (errmsg) |
872 | 0 | break; |
873 | 0 | } |
874 | 0 | break; |
875 | 0 | case EPIPHANY_OPERAND_SWI_NUM : |
876 | 0 | errmsg = insert_normal (cd, fields->f_trap_num, 0, 0, 15, 6, 32, total_length, buffer); |
877 | 0 | break; |
878 | 0 | case EPIPHANY_OPERAND_TRAPNUM6 : |
879 | 0 | errmsg = insert_normal (cd, fields->f_trap_num, 0, 0, 15, 6, 32, total_length, buffer); |
880 | 0 | break; |
881 | | |
882 | 0 | default : |
883 | | /* xgettext:c-format */ |
884 | 0 | opcodes_error_handler |
885 | 0 | (_("internal error: unrecognized field %d while building insn"), |
886 | 0 | opindex); |
887 | 0 | abort (); |
888 | 0 | } |
889 | | |
890 | 0 | return errmsg; |
891 | 0 | } |
892 | | |
893 | | int epiphany_cgen_extract_operand |
894 | | (CGEN_CPU_DESC, int, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma); |
895 | | |
896 | | /* Main entry point for operand extraction. |
897 | | The result is <= 0 for error, >0 for success. |
898 | | ??? Actual values aren't well defined right now. |
899 | | |
900 | | This function is basically just a big switch statement. Earlier versions |
901 | | used tables to look up the function to use, but |
902 | | - if the table contains both assembler and disassembler functions then |
903 | | the disassembler contains much of the assembler and vice-versa, |
904 | | - there's a lot of inlining possibilities as things grow, |
905 | | - using a switch statement avoids the function call overhead. |
906 | | |
907 | | This function could be moved into `print_insn_normal', but keeping it |
908 | | separate makes clear the interface between `print_insn_normal' and each of |
909 | | the handlers. */ |
910 | | |
911 | | int |
912 | | epiphany_cgen_extract_operand (CGEN_CPU_DESC cd, |
913 | | int opindex, |
914 | | CGEN_EXTRACT_INFO *ex_info, |
915 | | CGEN_INSN_INT insn_value, |
916 | | CGEN_FIELDS * fields, |
917 | | bfd_vma pc) |
918 | 75.7k | { |
919 | | /* Assume success (for those operands that are nops). */ |
920 | 75.7k | int length = 1; |
921 | 75.7k | unsigned int total_length = CGEN_FIELDS_BITSIZE (fields); |
922 | | |
923 | 75.7k | switch (opindex) |
924 | 75.7k | { |
925 | 635 | case EPIPHANY_OPERAND_DIRECTION : |
926 | 635 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 1, 32, total_length, pc, & fields->f_addsubx); |
927 | 635 | break; |
928 | 1.32k | case EPIPHANY_OPERAND_DISP11 : |
929 | 1.32k | { |
930 | 1.32k | length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_disp3); |
931 | 1.32k | if (length <= 0) break; |
932 | 1.32k | length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 8, 32, total_length, pc, & fields->f_disp8); |
933 | 1.32k | if (length <= 0) break; |
934 | 1.32k | { |
935 | 1.32k | FLD (f_disp11) = ((((FLD (f_disp8)) << (3))) | (FLD (f_disp3))); |
936 | 1.32k | } |
937 | 1.32k | } |
938 | 0 | break; |
939 | 1.79k | case EPIPHANY_OPERAND_DISP3 : |
940 | 1.79k | length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_disp3); |
941 | 1.79k | break; |
942 | 1.32k | case EPIPHANY_OPERAND_DPMI : |
943 | 1.32k | length = extract_normal (cd, ex_info, insn_value, 0, 0, 24, 1, 32, total_length, pc, & fields->f_subd); |
944 | 1.32k | break; |
945 | 0 | case EPIPHANY_OPERAND_FRD : |
946 | 0 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_rd); |
947 | 0 | break; |
948 | 20 | case EPIPHANY_OPERAND_FRD6 : |
949 | 20 | { |
950 | 20 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 3, 32, total_length, pc, & fields->f_rd_x); |
951 | 20 | if (length <= 0) break; |
952 | 20 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_rd); |
953 | 20 | if (length <= 0) break; |
954 | 20 | { |
955 | 20 | FLD (f_rd6) = ((((FLD (f_rd_x)) << (3))) | (FLD (f_rd))); |
956 | 20 | } |
957 | 20 | } |
958 | 0 | break; |
959 | 0 | case EPIPHANY_OPERAND_FRM : |
960 | 0 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_rm); |
961 | 0 | break; |
962 | 0 | case EPIPHANY_OPERAND_FRM6 : |
963 | 0 | { |
964 | 0 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 3, 32, total_length, pc, & fields->f_rm_x); |
965 | 0 | if (length <= 0) break; |
966 | 0 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_rm); |
967 | 0 | if (length <= 0) break; |
968 | 0 | { |
969 | 0 | FLD (f_rm6) = ((((FLD (f_rm_x)) << (3))) | (FLD (f_rm))); |
970 | 0 | } |
971 | 0 | } |
972 | 0 | break; |
973 | 0 | case EPIPHANY_OPERAND_FRN : |
974 | 0 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_rn); |
975 | 0 | break; |
976 | 20 | case EPIPHANY_OPERAND_FRN6 : |
977 | 20 | { |
978 | 20 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 3, 32, total_length, pc, & fields->f_rn_x); |
979 | 20 | if (length <= 0) break; |
980 | 20 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_rn); |
981 | 20 | if (length <= 0) break; |
982 | 20 | { |
983 | 20 | FLD (f_rn6) = ((((FLD (f_rn_x)) << (3))) | (FLD (f_rn))); |
984 | 20 | } |
985 | 20 | } |
986 | 0 | break; |
987 | 85 | case EPIPHANY_OPERAND_IMM16 : |
988 | 85 | { |
989 | 85 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 8, 32, total_length, pc, & fields->f_imm8); |
990 | 85 | if (length <= 0) break; |
991 | 85 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 27, 8, 32, total_length, pc, & fields->f_imm_27_8); |
992 | 85 | if (length <= 0) break; |
993 | 85 | { |
994 | 85 | FLD (f_imm16) = ((((FLD (f_imm_27_8)) << (8))) | (FLD (f_imm8))); |
995 | 85 | } |
996 | 85 | } |
997 | 0 | break; |
998 | 1.40k | case EPIPHANY_OPERAND_IMM8 : |
999 | 1.40k | length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 8, 32, total_length, pc, & fields->f_imm8); |
1000 | 1.40k | break; |
1001 | 17.4k | case EPIPHANY_OPERAND_RD : |
1002 | 17.4k | length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_rd); |
1003 | 17.4k | break; |
1004 | 2.93k | case EPIPHANY_OPERAND_RD6 : |
1005 | 2.93k | { |
1006 | 2.93k | length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 3, 32, total_length, pc, & fields->f_rd_x); |
1007 | 2.93k | if (length <= 0) break; |
1008 | 2.93k | length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_rd); |
1009 | 2.93k | if (length <= 0) break; |
1010 | 2.93k | { |
1011 | 2.93k | FLD (f_rd6) = ((((FLD (f_rd_x)) << (3))) | (FLD (f_rd))); |
1012 | 2.93k | } |
1013 | 2.93k | } |
1014 | 0 | break; |
1015 | 7.96k | case EPIPHANY_OPERAND_RM : |
1016 | 7.96k | length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_rm); |
1017 | 7.96k | break; |
1018 | 664 | case EPIPHANY_OPERAND_RM6 : |
1019 | 664 | { |
1020 | 664 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 3, 32, total_length, pc, & fields->f_rm_x); |
1021 | 664 | if (length <= 0) break; |
1022 | 664 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_rm); |
1023 | 664 | if (length <= 0) break; |
1024 | 664 | { |
1025 | 664 | FLD (f_rm6) = ((((FLD (f_rm_x)) << (3))) | (FLD (f_rm))); |
1026 | 664 | } |
1027 | 664 | } |
1028 | 0 | break; |
1029 | 15.8k | case EPIPHANY_OPERAND_RN : |
1030 | 15.8k | length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_rn); |
1031 | 15.8k | break; |
1032 | 2.39k | case EPIPHANY_OPERAND_RN6 : |
1033 | 2.39k | { |
1034 | 2.39k | length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 3, 32, total_length, pc, & fields->f_rn_x); |
1035 | 2.39k | if (length <= 0) break; |
1036 | 2.39k | length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_rn); |
1037 | 2.39k | if (length <= 0) break; |
1038 | 2.39k | { |
1039 | 2.39k | FLD (f_rn6) = ((((FLD (f_rn_x)) << (3))) | (FLD (f_rn))); |
1040 | 2.39k | } |
1041 | 2.39k | } |
1042 | 0 | break; |
1043 | 0 | case EPIPHANY_OPERAND_SD : |
1044 | 0 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_sd); |
1045 | 0 | break; |
1046 | 0 | case EPIPHANY_OPERAND_SD6 : |
1047 | 0 | { |
1048 | 0 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 3, 32, total_length, pc, & fields->f_sd_x); |
1049 | 0 | if (length <= 0) break; |
1050 | 0 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_sd); |
1051 | 0 | if (length <= 0) break; |
1052 | 0 | { |
1053 | 0 | FLD (f_sd6) = ((((FLD (f_sd_x)) << (3))) | (FLD (f_sd))); |
1054 | 0 | } |
1055 | 0 | } |
1056 | 0 | break; |
1057 | 0 | case EPIPHANY_OPERAND_SDDMA : |
1058 | 0 | { |
1059 | 0 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 3, 32, total_length, pc, & fields->f_sd_x); |
1060 | 0 | if (length <= 0) break; |
1061 | 0 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_sd); |
1062 | 0 | if (length <= 0) break; |
1063 | 0 | { |
1064 | 0 | FLD (f_sd6) = ((((FLD (f_sd_x)) << (3))) | (FLD (f_sd))); |
1065 | 0 | } |
1066 | 0 | } |
1067 | 0 | break; |
1068 | 0 | case EPIPHANY_OPERAND_SDMEM : |
1069 | 0 | { |
1070 | 0 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 3, 32, total_length, pc, & fields->f_sd_x); |
1071 | 0 | if (length <= 0) break; |
1072 | 0 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_sd); |
1073 | 0 | if (length <= 0) break; |
1074 | 0 | { |
1075 | 0 | FLD (f_sd6) = ((((FLD (f_sd_x)) << (3))) | (FLD (f_sd))); |
1076 | 0 | } |
1077 | 0 | } |
1078 | 0 | break; |
1079 | 0 | case EPIPHANY_OPERAND_SDMESH : |
1080 | 0 | { |
1081 | 0 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 3, 32, total_length, pc, & fields->f_sd_x); |
1082 | 0 | if (length <= 0) break; |
1083 | 0 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 3, 32, total_length, pc, & fields->f_sd); |
1084 | 0 | if (length <= 0) break; |
1085 | 0 | { |
1086 | 0 | FLD (f_sd6) = ((((FLD (f_sd_x)) << (3))) | (FLD (f_sd))); |
1087 | 0 | } |
1088 | 0 | } |
1089 | 0 | break; |
1090 | 3.39k | case EPIPHANY_OPERAND_SHIFT : |
1091 | 3.39k | length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 5, 32, total_length, pc, & fields->f_shift); |
1092 | 3.39k | break; |
1093 | 354 | case EPIPHANY_OPERAND_SIMM11 : |
1094 | 354 | { |
1095 | 354 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 3, 32, total_length, pc, & fields->f_disp3); |
1096 | 354 | if (length <= 0) break; |
1097 | 354 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 8, 32, total_length, pc, & fields->f_disp8); |
1098 | 354 | if (length <= 0) break; |
1099 | 354 | { |
1100 | 354 | FLD (f_sdisp11) = ((((((((((FLD (f_disp8)) << (3))) | (FLD (f_disp3)))) & (2047))) ^ (1024))) - (1024)); |
1101 | 354 | } |
1102 | 354 | } |
1103 | 0 | break; |
1104 | 1.50k | case EPIPHANY_OPERAND_SIMM24 : |
1105 | 1.50k | { |
1106 | 1.50k | long value; |
1107 | 1.50k | length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 31, 24, 32, total_length, pc, & value); |
1108 | 1.50k | value = ((((value) * (2))) + (pc)); |
1109 | 1.50k | fields->f_simm24 = value; |
1110 | 1.50k | } |
1111 | 1.50k | break; |
1112 | 907 | case EPIPHANY_OPERAND_SIMM3 : |
1113 | 907 | length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 9, 3, 32, total_length, pc, & fields->f_sdisp3); |
1114 | 907 | break; |
1115 | 14.6k | case EPIPHANY_OPERAND_SIMM8 : |
1116 | 14.6k | { |
1117 | 14.6k | long value; |
1118 | 14.6k | length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 15, 8, 32, total_length, pc, & value); |
1119 | 14.6k | value = ((((value) * (2))) + (pc)); |
1120 | 14.6k | fields->f_simm8 = value; |
1121 | 14.6k | } |
1122 | 14.6k | break; |
1123 | 241 | case EPIPHANY_OPERAND_SN : |
1124 | 241 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_sn); |
1125 | 241 | break; |
1126 | 223 | case EPIPHANY_OPERAND_SN6 : |
1127 | 223 | { |
1128 | 223 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 3, 32, total_length, pc, & fields->f_sn_x); |
1129 | 223 | if (length <= 0) break; |
1130 | 223 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_sn); |
1131 | 223 | if (length <= 0) break; |
1132 | 223 | { |
1133 | 223 | FLD (f_sn6) = ((((FLD (f_sn_x)) << (3))) | (FLD (f_sn))); |
1134 | 223 | } |
1135 | 223 | } |
1136 | 0 | break; |
1137 | 53 | case EPIPHANY_OPERAND_SNDMA : |
1138 | 53 | { |
1139 | 53 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 3, 32, total_length, pc, & fields->f_sn_x); |
1140 | 53 | if (length <= 0) break; |
1141 | 53 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_sn); |
1142 | 53 | if (length <= 0) break; |
1143 | 53 | { |
1144 | 53 | FLD (f_sn6) = ((((FLD (f_sn_x)) << (3))) | (FLD (f_sn))); |
1145 | 53 | } |
1146 | 53 | } |
1147 | 0 | break; |
1148 | 113 | case EPIPHANY_OPERAND_SNMEM : |
1149 | 113 | { |
1150 | 113 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 3, 32, total_length, pc, & fields->f_sn_x); |
1151 | 113 | if (length <= 0) break; |
1152 | 113 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_sn); |
1153 | 113 | if (length <= 0) break; |
1154 | 113 | { |
1155 | 113 | FLD (f_sn6) = ((((FLD (f_sn_x)) << (3))) | (FLD (f_sn))); |
1156 | 113 | } |
1157 | 113 | } |
1158 | 0 | break; |
1159 | 68 | case EPIPHANY_OPERAND_SNMESH : |
1160 | 68 | { |
1161 | 68 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 3, 32, total_length, pc, & fields->f_sn_x); |
1162 | 68 | if (length <= 0) break; |
1163 | 68 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 3, 32, total_length, pc, & fields->f_sn); |
1164 | 68 | if (length <= 0) break; |
1165 | 68 | { |
1166 | 68 | FLD (f_sn6) = ((((FLD (f_sn_x)) << (3))) | (FLD (f_sn))); |
1167 | 68 | } |
1168 | 68 | } |
1169 | 0 | break; |
1170 | 194 | case EPIPHANY_OPERAND_SWI_NUM : |
1171 | 194 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 6, 32, total_length, pc, & fields->f_trap_num); |
1172 | 194 | break; |
1173 | 113 | case EPIPHANY_OPERAND_TRAPNUM6 : |
1174 | 113 | length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 6, 32, total_length, pc, & fields->f_trap_num); |
1175 | 113 | break; |
1176 | | |
1177 | 0 | default : |
1178 | | /* xgettext:c-format */ |
1179 | 0 | opcodes_error_handler |
1180 | 0 | (_("internal error: unrecognized field %d while decoding insn"), |
1181 | 0 | opindex); |
1182 | 0 | abort (); |
1183 | 75.7k | } |
1184 | | |
1185 | 75.7k | return length; |
1186 | 75.7k | } |
1187 | | |
1188 | | cgen_insert_fn * const epiphany_cgen_insert_handlers[] = |
1189 | | { |
1190 | | insert_insn_normal, |
1191 | | }; |
1192 | | |
1193 | | cgen_extract_fn * const epiphany_cgen_extract_handlers[] = |
1194 | | { |
1195 | | extract_insn_normal, |
1196 | | }; |
1197 | | |
1198 | | int epiphany_cgen_get_int_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *); |
1199 | | bfd_vma epiphany_cgen_get_vma_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *); |
1200 | | |
1201 | | /* Getting values from cgen_fields is handled by a collection of functions. |
1202 | | They are distinguished by the type of the VALUE argument they return. |
1203 | | TODO: floating point, inlining support, remove cases where result type |
1204 | | not appropriate. */ |
1205 | | |
1206 | | int |
1207 | | epiphany_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, |
1208 | | int opindex, |
1209 | | const CGEN_FIELDS * fields) |
1210 | 0 | { |
1211 | 0 | int value; |
1212 | |
|
1213 | 0 | switch (opindex) |
1214 | 0 | { |
1215 | 0 | case EPIPHANY_OPERAND_DIRECTION : |
1216 | 0 | value = fields->f_addsubx; |
1217 | 0 | break; |
1218 | 0 | case EPIPHANY_OPERAND_DISP11 : |
1219 | 0 | value = fields->f_disp11; |
1220 | 0 | break; |
1221 | 0 | case EPIPHANY_OPERAND_DISP3 : |
1222 | 0 | value = fields->f_disp3; |
1223 | 0 | break; |
1224 | 0 | case EPIPHANY_OPERAND_DPMI : |
1225 | 0 | value = fields->f_subd; |
1226 | 0 | break; |
1227 | 0 | case EPIPHANY_OPERAND_FRD : |
1228 | 0 | value = fields->f_rd; |
1229 | 0 | break; |
1230 | 0 | case EPIPHANY_OPERAND_FRD6 : |
1231 | 0 | value = fields->f_rd6; |
1232 | 0 | break; |
1233 | 0 | case EPIPHANY_OPERAND_FRM : |
1234 | 0 | value = fields->f_rm; |
1235 | 0 | break; |
1236 | 0 | case EPIPHANY_OPERAND_FRM6 : |
1237 | 0 | value = fields->f_rm6; |
1238 | 0 | break; |
1239 | 0 | case EPIPHANY_OPERAND_FRN : |
1240 | 0 | value = fields->f_rn; |
1241 | 0 | break; |
1242 | 0 | case EPIPHANY_OPERAND_FRN6 : |
1243 | 0 | value = fields->f_rn6; |
1244 | 0 | break; |
1245 | 0 | case EPIPHANY_OPERAND_IMM16 : |
1246 | 0 | value = fields->f_imm16; |
1247 | 0 | break; |
1248 | 0 | case EPIPHANY_OPERAND_IMM8 : |
1249 | 0 | value = fields->f_imm8; |
1250 | 0 | break; |
1251 | 0 | case EPIPHANY_OPERAND_RD : |
1252 | 0 | value = fields->f_rd; |
1253 | 0 | break; |
1254 | 0 | case EPIPHANY_OPERAND_RD6 : |
1255 | 0 | value = fields->f_rd6; |
1256 | 0 | break; |
1257 | 0 | case EPIPHANY_OPERAND_RM : |
1258 | 0 | value = fields->f_rm; |
1259 | 0 | break; |
1260 | 0 | case EPIPHANY_OPERAND_RM6 : |
1261 | 0 | value = fields->f_rm6; |
1262 | 0 | break; |
1263 | 0 | case EPIPHANY_OPERAND_RN : |
1264 | 0 | value = fields->f_rn; |
1265 | 0 | break; |
1266 | 0 | case EPIPHANY_OPERAND_RN6 : |
1267 | 0 | value = fields->f_rn6; |
1268 | 0 | break; |
1269 | 0 | case EPIPHANY_OPERAND_SD : |
1270 | 0 | value = fields->f_sd; |
1271 | 0 | break; |
1272 | 0 | case EPIPHANY_OPERAND_SD6 : |
1273 | 0 | value = fields->f_sd6; |
1274 | 0 | break; |
1275 | 0 | case EPIPHANY_OPERAND_SDDMA : |
1276 | 0 | value = fields->f_sd6; |
1277 | 0 | break; |
1278 | 0 | case EPIPHANY_OPERAND_SDMEM : |
1279 | 0 | value = fields->f_sd6; |
1280 | 0 | break; |
1281 | 0 | case EPIPHANY_OPERAND_SDMESH : |
1282 | 0 | value = fields->f_sd6; |
1283 | 0 | break; |
1284 | 0 | case EPIPHANY_OPERAND_SHIFT : |
1285 | 0 | value = fields->f_shift; |
1286 | 0 | break; |
1287 | 0 | case EPIPHANY_OPERAND_SIMM11 : |
1288 | 0 | value = fields->f_sdisp11; |
1289 | 0 | break; |
1290 | 0 | case EPIPHANY_OPERAND_SIMM24 : |
1291 | 0 | value = fields->f_simm24; |
1292 | 0 | break; |
1293 | 0 | case EPIPHANY_OPERAND_SIMM3 : |
1294 | 0 | value = fields->f_sdisp3; |
1295 | 0 | break; |
1296 | 0 | case EPIPHANY_OPERAND_SIMM8 : |
1297 | 0 | value = fields->f_simm8; |
1298 | 0 | break; |
1299 | 0 | case EPIPHANY_OPERAND_SN : |
1300 | 0 | value = fields->f_sn; |
1301 | 0 | break; |
1302 | 0 | case EPIPHANY_OPERAND_SN6 : |
1303 | 0 | value = fields->f_sn6; |
1304 | 0 | break; |
1305 | 0 | case EPIPHANY_OPERAND_SNDMA : |
1306 | 0 | value = fields->f_sn6; |
1307 | 0 | break; |
1308 | 0 | case EPIPHANY_OPERAND_SNMEM : |
1309 | 0 | value = fields->f_sn6; |
1310 | 0 | break; |
1311 | 0 | case EPIPHANY_OPERAND_SNMESH : |
1312 | 0 | value = fields->f_sn6; |
1313 | 0 | break; |
1314 | 0 | case EPIPHANY_OPERAND_SWI_NUM : |
1315 | 0 | value = fields->f_trap_num; |
1316 | 0 | break; |
1317 | 0 | case EPIPHANY_OPERAND_TRAPNUM6 : |
1318 | 0 | value = fields->f_trap_num; |
1319 | 0 | break; |
1320 | | |
1321 | 0 | default : |
1322 | | /* xgettext:c-format */ |
1323 | 0 | opcodes_error_handler |
1324 | 0 | (_("internal error: unrecognized field %d while getting int operand"), |
1325 | 0 | opindex); |
1326 | 0 | abort (); |
1327 | 0 | } |
1328 | | |
1329 | 0 | return value; |
1330 | 0 | } |
1331 | | |
1332 | | bfd_vma |
1333 | | epiphany_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, |
1334 | | int opindex, |
1335 | | const CGEN_FIELDS * fields) |
1336 | 0 | { |
1337 | 0 | bfd_vma value; |
1338 | |
|
1339 | 0 | switch (opindex) |
1340 | 0 | { |
1341 | 0 | case EPIPHANY_OPERAND_DIRECTION : |
1342 | 0 | value = fields->f_addsubx; |
1343 | 0 | break; |
1344 | 0 | case EPIPHANY_OPERAND_DISP11 : |
1345 | 0 | value = fields->f_disp11; |
1346 | 0 | break; |
1347 | 0 | case EPIPHANY_OPERAND_DISP3 : |
1348 | 0 | value = fields->f_disp3; |
1349 | 0 | break; |
1350 | 0 | case EPIPHANY_OPERAND_DPMI : |
1351 | 0 | value = fields->f_subd; |
1352 | 0 | break; |
1353 | 0 | case EPIPHANY_OPERAND_FRD : |
1354 | 0 | value = fields->f_rd; |
1355 | 0 | break; |
1356 | 0 | case EPIPHANY_OPERAND_FRD6 : |
1357 | 0 | value = fields->f_rd6; |
1358 | 0 | break; |
1359 | 0 | case EPIPHANY_OPERAND_FRM : |
1360 | 0 | value = fields->f_rm; |
1361 | 0 | break; |
1362 | 0 | case EPIPHANY_OPERAND_FRM6 : |
1363 | 0 | value = fields->f_rm6; |
1364 | 0 | break; |
1365 | 0 | case EPIPHANY_OPERAND_FRN : |
1366 | 0 | value = fields->f_rn; |
1367 | 0 | break; |
1368 | 0 | case EPIPHANY_OPERAND_FRN6 : |
1369 | 0 | value = fields->f_rn6; |
1370 | 0 | break; |
1371 | 0 | case EPIPHANY_OPERAND_IMM16 : |
1372 | 0 | value = fields->f_imm16; |
1373 | 0 | break; |
1374 | 0 | case EPIPHANY_OPERAND_IMM8 : |
1375 | 0 | value = fields->f_imm8; |
1376 | 0 | break; |
1377 | 0 | case EPIPHANY_OPERAND_RD : |
1378 | 0 | value = fields->f_rd; |
1379 | 0 | break; |
1380 | 0 | case EPIPHANY_OPERAND_RD6 : |
1381 | 0 | value = fields->f_rd6; |
1382 | 0 | break; |
1383 | 0 | case EPIPHANY_OPERAND_RM : |
1384 | 0 | value = fields->f_rm; |
1385 | 0 | break; |
1386 | 0 | case EPIPHANY_OPERAND_RM6 : |
1387 | 0 | value = fields->f_rm6; |
1388 | 0 | break; |
1389 | 0 | case EPIPHANY_OPERAND_RN : |
1390 | 0 | value = fields->f_rn; |
1391 | 0 | break; |
1392 | 0 | case EPIPHANY_OPERAND_RN6 : |
1393 | 0 | value = fields->f_rn6; |
1394 | 0 | break; |
1395 | 0 | case EPIPHANY_OPERAND_SD : |
1396 | 0 | value = fields->f_sd; |
1397 | 0 | break; |
1398 | 0 | case EPIPHANY_OPERAND_SD6 : |
1399 | 0 | value = fields->f_sd6; |
1400 | 0 | break; |
1401 | 0 | case EPIPHANY_OPERAND_SDDMA : |
1402 | 0 | value = fields->f_sd6; |
1403 | 0 | break; |
1404 | 0 | case EPIPHANY_OPERAND_SDMEM : |
1405 | 0 | value = fields->f_sd6; |
1406 | 0 | break; |
1407 | 0 | case EPIPHANY_OPERAND_SDMESH : |
1408 | 0 | value = fields->f_sd6; |
1409 | 0 | break; |
1410 | 0 | case EPIPHANY_OPERAND_SHIFT : |
1411 | 0 | value = fields->f_shift; |
1412 | 0 | break; |
1413 | 0 | case EPIPHANY_OPERAND_SIMM11 : |
1414 | 0 | value = fields->f_sdisp11; |
1415 | 0 | break; |
1416 | 0 | case EPIPHANY_OPERAND_SIMM24 : |
1417 | 0 | value = fields->f_simm24; |
1418 | 0 | break; |
1419 | 0 | case EPIPHANY_OPERAND_SIMM3 : |
1420 | 0 | value = fields->f_sdisp3; |
1421 | 0 | break; |
1422 | 0 | case EPIPHANY_OPERAND_SIMM8 : |
1423 | 0 | value = fields->f_simm8; |
1424 | 0 | break; |
1425 | 0 | case EPIPHANY_OPERAND_SN : |
1426 | 0 | value = fields->f_sn; |
1427 | 0 | break; |
1428 | 0 | case EPIPHANY_OPERAND_SN6 : |
1429 | 0 | value = fields->f_sn6; |
1430 | 0 | break; |
1431 | 0 | case EPIPHANY_OPERAND_SNDMA : |
1432 | 0 | value = fields->f_sn6; |
1433 | 0 | break; |
1434 | 0 | case EPIPHANY_OPERAND_SNMEM : |
1435 | 0 | value = fields->f_sn6; |
1436 | 0 | break; |
1437 | 0 | case EPIPHANY_OPERAND_SNMESH : |
1438 | 0 | value = fields->f_sn6; |
1439 | 0 | break; |
1440 | 0 | case EPIPHANY_OPERAND_SWI_NUM : |
1441 | 0 | value = fields->f_trap_num; |
1442 | 0 | break; |
1443 | 0 | case EPIPHANY_OPERAND_TRAPNUM6 : |
1444 | 0 | value = fields->f_trap_num; |
1445 | 0 | break; |
1446 | | |
1447 | 0 | default : |
1448 | | /* xgettext:c-format */ |
1449 | 0 | opcodes_error_handler |
1450 | 0 | (_("internal error: unrecognized field %d while getting vma operand"), |
1451 | 0 | opindex); |
1452 | 0 | abort (); |
1453 | 0 | } |
1454 | | |
1455 | 0 | return value; |
1456 | 0 | } |
1457 | | |
1458 | | void epiphany_cgen_set_int_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, int); |
1459 | | void epiphany_cgen_set_vma_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, bfd_vma); |
1460 | | |
1461 | | /* Stuffing values in cgen_fields is handled by a collection of functions. |
1462 | | They are distinguished by the type of the VALUE argument they accept. |
1463 | | TODO: floating point, inlining support, remove cases where argument type |
1464 | | not appropriate. */ |
1465 | | |
1466 | | void |
1467 | | epiphany_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, |
1468 | | int opindex, |
1469 | | CGEN_FIELDS * fields, |
1470 | | int value) |
1471 | 0 | { |
1472 | 0 | switch (opindex) |
1473 | 0 | { |
1474 | 0 | case EPIPHANY_OPERAND_DIRECTION : |
1475 | 0 | fields->f_addsubx = value; |
1476 | 0 | break; |
1477 | 0 | case EPIPHANY_OPERAND_DISP11 : |
1478 | 0 | fields->f_disp11 = value; |
1479 | 0 | break; |
1480 | 0 | case EPIPHANY_OPERAND_DISP3 : |
1481 | 0 | fields->f_disp3 = value; |
1482 | 0 | break; |
1483 | 0 | case EPIPHANY_OPERAND_DPMI : |
1484 | 0 | fields->f_subd = value; |
1485 | 0 | break; |
1486 | 0 | case EPIPHANY_OPERAND_FRD : |
1487 | 0 | fields->f_rd = value; |
1488 | 0 | break; |
1489 | 0 | case EPIPHANY_OPERAND_FRD6 : |
1490 | 0 | fields->f_rd6 = value; |
1491 | 0 | break; |
1492 | 0 | case EPIPHANY_OPERAND_FRM : |
1493 | 0 | fields->f_rm = value; |
1494 | 0 | break; |
1495 | 0 | case EPIPHANY_OPERAND_FRM6 : |
1496 | 0 | fields->f_rm6 = value; |
1497 | 0 | break; |
1498 | 0 | case EPIPHANY_OPERAND_FRN : |
1499 | 0 | fields->f_rn = value; |
1500 | 0 | break; |
1501 | 0 | case EPIPHANY_OPERAND_FRN6 : |
1502 | 0 | fields->f_rn6 = value; |
1503 | 0 | break; |
1504 | 0 | case EPIPHANY_OPERAND_IMM16 : |
1505 | 0 | fields->f_imm16 = value; |
1506 | 0 | break; |
1507 | 0 | case EPIPHANY_OPERAND_IMM8 : |
1508 | 0 | fields->f_imm8 = value; |
1509 | 0 | break; |
1510 | 0 | case EPIPHANY_OPERAND_RD : |
1511 | 0 | fields->f_rd = value; |
1512 | 0 | break; |
1513 | 0 | case EPIPHANY_OPERAND_RD6 : |
1514 | 0 | fields->f_rd6 = value; |
1515 | 0 | break; |
1516 | 0 | case EPIPHANY_OPERAND_RM : |
1517 | 0 | fields->f_rm = value; |
1518 | 0 | break; |
1519 | 0 | case EPIPHANY_OPERAND_RM6 : |
1520 | 0 | fields->f_rm6 = value; |
1521 | 0 | break; |
1522 | 0 | case EPIPHANY_OPERAND_RN : |
1523 | 0 | fields->f_rn = value; |
1524 | 0 | break; |
1525 | 0 | case EPIPHANY_OPERAND_RN6 : |
1526 | 0 | fields->f_rn6 = value; |
1527 | 0 | break; |
1528 | 0 | case EPIPHANY_OPERAND_SD : |
1529 | 0 | fields->f_sd = value; |
1530 | 0 | break; |
1531 | 0 | case EPIPHANY_OPERAND_SD6 : |
1532 | 0 | fields->f_sd6 = value; |
1533 | 0 | break; |
1534 | 0 | case EPIPHANY_OPERAND_SDDMA : |
1535 | 0 | fields->f_sd6 = value; |
1536 | 0 | break; |
1537 | 0 | case EPIPHANY_OPERAND_SDMEM : |
1538 | 0 | fields->f_sd6 = value; |
1539 | 0 | break; |
1540 | 0 | case EPIPHANY_OPERAND_SDMESH : |
1541 | 0 | fields->f_sd6 = value; |
1542 | 0 | break; |
1543 | 0 | case EPIPHANY_OPERAND_SHIFT : |
1544 | 0 | fields->f_shift = value; |
1545 | 0 | break; |
1546 | 0 | case EPIPHANY_OPERAND_SIMM11 : |
1547 | 0 | fields->f_sdisp11 = value; |
1548 | 0 | break; |
1549 | 0 | case EPIPHANY_OPERAND_SIMM24 : |
1550 | 0 | fields->f_simm24 = value; |
1551 | 0 | break; |
1552 | 0 | case EPIPHANY_OPERAND_SIMM3 : |
1553 | 0 | fields->f_sdisp3 = value; |
1554 | 0 | break; |
1555 | 0 | case EPIPHANY_OPERAND_SIMM8 : |
1556 | 0 | fields->f_simm8 = value; |
1557 | 0 | break; |
1558 | 0 | case EPIPHANY_OPERAND_SN : |
1559 | 0 | fields->f_sn = value; |
1560 | 0 | break; |
1561 | 0 | case EPIPHANY_OPERAND_SN6 : |
1562 | 0 | fields->f_sn6 = value; |
1563 | 0 | break; |
1564 | 0 | case EPIPHANY_OPERAND_SNDMA : |
1565 | 0 | fields->f_sn6 = value; |
1566 | 0 | break; |
1567 | 0 | case EPIPHANY_OPERAND_SNMEM : |
1568 | 0 | fields->f_sn6 = value; |
1569 | 0 | break; |
1570 | 0 | case EPIPHANY_OPERAND_SNMESH : |
1571 | 0 | fields->f_sn6 = value; |
1572 | 0 | break; |
1573 | 0 | case EPIPHANY_OPERAND_SWI_NUM : |
1574 | 0 | fields->f_trap_num = value; |
1575 | 0 | break; |
1576 | 0 | case EPIPHANY_OPERAND_TRAPNUM6 : |
1577 | 0 | fields->f_trap_num = value; |
1578 | 0 | break; |
1579 | | |
1580 | 0 | default : |
1581 | | /* xgettext:c-format */ |
1582 | 0 | opcodes_error_handler |
1583 | 0 | (_("internal error: unrecognized field %d while setting int operand"), |
1584 | 0 | opindex); |
1585 | 0 | abort (); |
1586 | 0 | } |
1587 | 0 | } |
1588 | | |
1589 | | void |
1590 | | epiphany_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, |
1591 | | int opindex, |
1592 | | CGEN_FIELDS * fields, |
1593 | | bfd_vma value) |
1594 | 0 | { |
1595 | 0 | switch (opindex) |
1596 | 0 | { |
1597 | 0 | case EPIPHANY_OPERAND_DIRECTION : |
1598 | 0 | fields->f_addsubx = value; |
1599 | 0 | break; |
1600 | 0 | case EPIPHANY_OPERAND_DISP11 : |
1601 | 0 | fields->f_disp11 = value; |
1602 | 0 | break; |
1603 | 0 | case EPIPHANY_OPERAND_DISP3 : |
1604 | 0 | fields->f_disp3 = value; |
1605 | 0 | break; |
1606 | 0 | case EPIPHANY_OPERAND_DPMI : |
1607 | 0 | fields->f_subd = value; |
1608 | 0 | break; |
1609 | 0 | case EPIPHANY_OPERAND_FRD : |
1610 | 0 | fields->f_rd = value; |
1611 | 0 | break; |
1612 | 0 | case EPIPHANY_OPERAND_FRD6 : |
1613 | 0 | fields->f_rd6 = value; |
1614 | 0 | break; |
1615 | 0 | case EPIPHANY_OPERAND_FRM : |
1616 | 0 | fields->f_rm = value; |
1617 | 0 | break; |
1618 | 0 | case EPIPHANY_OPERAND_FRM6 : |
1619 | 0 | fields->f_rm6 = value; |
1620 | 0 | break; |
1621 | 0 | case EPIPHANY_OPERAND_FRN : |
1622 | 0 | fields->f_rn = value; |
1623 | 0 | break; |
1624 | 0 | case EPIPHANY_OPERAND_FRN6 : |
1625 | 0 | fields->f_rn6 = value; |
1626 | 0 | break; |
1627 | 0 | case EPIPHANY_OPERAND_IMM16 : |
1628 | 0 | fields->f_imm16 = value; |
1629 | 0 | break; |
1630 | 0 | case EPIPHANY_OPERAND_IMM8 : |
1631 | 0 | fields->f_imm8 = value; |
1632 | 0 | break; |
1633 | 0 | case EPIPHANY_OPERAND_RD : |
1634 | 0 | fields->f_rd = value; |
1635 | 0 | break; |
1636 | 0 | case EPIPHANY_OPERAND_RD6 : |
1637 | 0 | fields->f_rd6 = value; |
1638 | 0 | break; |
1639 | 0 | case EPIPHANY_OPERAND_RM : |
1640 | 0 | fields->f_rm = value; |
1641 | 0 | break; |
1642 | 0 | case EPIPHANY_OPERAND_RM6 : |
1643 | 0 | fields->f_rm6 = value; |
1644 | 0 | break; |
1645 | 0 | case EPIPHANY_OPERAND_RN : |
1646 | 0 | fields->f_rn = value; |
1647 | 0 | break; |
1648 | 0 | case EPIPHANY_OPERAND_RN6 : |
1649 | 0 | fields->f_rn6 = value; |
1650 | 0 | break; |
1651 | 0 | case EPIPHANY_OPERAND_SD : |
1652 | 0 | fields->f_sd = value; |
1653 | 0 | break; |
1654 | 0 | case EPIPHANY_OPERAND_SD6 : |
1655 | 0 | fields->f_sd6 = value; |
1656 | 0 | break; |
1657 | 0 | case EPIPHANY_OPERAND_SDDMA : |
1658 | 0 | fields->f_sd6 = value; |
1659 | 0 | break; |
1660 | 0 | case EPIPHANY_OPERAND_SDMEM : |
1661 | 0 | fields->f_sd6 = value; |
1662 | 0 | break; |
1663 | 0 | case EPIPHANY_OPERAND_SDMESH : |
1664 | 0 | fields->f_sd6 = value; |
1665 | 0 | break; |
1666 | 0 | case EPIPHANY_OPERAND_SHIFT : |
1667 | 0 | fields->f_shift = value; |
1668 | 0 | break; |
1669 | 0 | case EPIPHANY_OPERAND_SIMM11 : |
1670 | 0 | fields->f_sdisp11 = value; |
1671 | 0 | break; |
1672 | 0 | case EPIPHANY_OPERAND_SIMM24 : |
1673 | 0 | fields->f_simm24 = value; |
1674 | 0 | break; |
1675 | 0 | case EPIPHANY_OPERAND_SIMM3 : |
1676 | 0 | fields->f_sdisp3 = value; |
1677 | 0 | break; |
1678 | 0 | case EPIPHANY_OPERAND_SIMM8 : |
1679 | 0 | fields->f_simm8 = value; |
1680 | 0 | break; |
1681 | 0 | case EPIPHANY_OPERAND_SN : |
1682 | 0 | fields->f_sn = value; |
1683 | 0 | break; |
1684 | 0 | case EPIPHANY_OPERAND_SN6 : |
1685 | 0 | fields->f_sn6 = value; |
1686 | 0 | break; |
1687 | 0 | case EPIPHANY_OPERAND_SNDMA : |
1688 | 0 | fields->f_sn6 = value; |
1689 | 0 | break; |
1690 | 0 | case EPIPHANY_OPERAND_SNMEM : |
1691 | 0 | fields->f_sn6 = value; |
1692 | 0 | break; |
1693 | 0 | case EPIPHANY_OPERAND_SNMESH : |
1694 | 0 | fields->f_sn6 = value; |
1695 | 0 | break; |
1696 | 0 | case EPIPHANY_OPERAND_SWI_NUM : |
1697 | 0 | fields->f_trap_num = value; |
1698 | 0 | break; |
1699 | 0 | case EPIPHANY_OPERAND_TRAPNUM6 : |
1700 | 0 | fields->f_trap_num = value; |
1701 | 0 | break; |
1702 | | |
1703 | 0 | default : |
1704 | | /* xgettext:c-format */ |
1705 | 0 | opcodes_error_handler |
1706 | 0 | (_("internal error: unrecognized field %d while setting vma operand"), |
1707 | 0 | opindex); |
1708 | 0 | abort (); |
1709 | 0 | } |
1710 | 0 | } |
1711 | | |
1712 | | /* Function to call before using the instruction builder tables. */ |
1713 | | |
1714 | | void |
1715 | | epiphany_cgen_init_ibld_table (CGEN_CPU_DESC cd) |
1716 | 3 | { |
1717 | 3 | cd->insert_handlers = & epiphany_cgen_insert_handlers[0]; |
1718 | 3 | cd->extract_handlers = & epiphany_cgen_extract_handlers[0]; |
1719 | | |
1720 | 3 | cd->insert_operand = epiphany_cgen_insert_operand; |
1721 | 3 | cd->extract_operand = epiphany_cgen_extract_operand; |
1722 | | |
1723 | 3 | cd->get_int_operand = epiphany_cgen_get_int_operand; |
1724 | 3 | cd->set_int_operand = epiphany_cgen_set_int_operand; |
1725 | 3 | cd->get_vma_operand = epiphany_cgen_get_vma_operand; |
1726 | 3 | cd->set_vma_operand = epiphany_cgen_set_vma_operand; |
1727 | 3 | } |