1 /* Instruction building/extraction support for openrisc. -*- C -*-
3 THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator.
4 - the resultant file is machine generated, cgen-ibld.in isn't
6 Copyright 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
8 This file is part of the GNU Binutils and GDB, the GNU debugger.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software Foundation, Inc.,
22 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
24 /* ??? Eventually more and more of this stuff can go to cpu-independent files.
34 #include "openrisc-desc.h"
35 #include "openrisc-opc.h"
39 #define min(a,b) ((a) < (b) ? (a) : (b))
41 #define max(a,b) ((a) > (b) ? (a) : (b))
43 /* Used by the ifield rtx function. */
44 #define FLD(f) (fields->f)
46 static const char * insert_normal
47 PARAMS ((CGEN_CPU_DESC
, long, unsigned int, unsigned int, unsigned int,
48 unsigned int, unsigned int, unsigned int, CGEN_INSN_BYTES_PTR
));
49 static const char * insert_insn_normal
50 PARAMS ((CGEN_CPU_DESC
, const CGEN_INSN
*,
51 CGEN_FIELDS
*, CGEN_INSN_BYTES_PTR
, bfd_vma
));
53 static int extract_normal
54 PARAMS ((CGEN_CPU_DESC
, CGEN_EXTRACT_INFO
*, CGEN_INSN_INT
,
55 unsigned int, unsigned int, unsigned int, unsigned int,
56 unsigned int, unsigned int, bfd_vma
, long *));
57 static int extract_insn_normal
58 PARAMS ((CGEN_CPU_DESC
, const CGEN_INSN
*, CGEN_EXTRACT_INFO
*,
59 CGEN_INSN_INT
, CGEN_FIELDS
*, bfd_vma
));
60 static void put_insn_int_value
61 PARAMS ((CGEN_CPU_DESC
, CGEN_INSN_BYTES_PTR
, int, int, CGEN_INSN_INT
));
64 /* Operand insertion. */
68 /* Subroutine of insert_normal. */
70 static CGEN_INLINE
void
71 insert_1 (cd
, value
, start
, length
, word_length
, bufp
)
74 int start
,length
,word_length
;
79 int big_p
= CGEN_CPU_INSN_ENDIAN (cd
) == CGEN_ENDIAN_BIG
;
81 x
= bfd_get_bits (bufp
, word_length
, big_p
);
83 /* Written this way to avoid undefined behaviour. */
84 mask
= (((1L << (length
- 1)) - 1) << 1) | 1;
86 shift
= (start
+ 1) - length
;
88 shift
= (word_length
- (start
+ length
));
89 x
= (x
& ~(mask
<< shift
)) | ((value
& mask
) << shift
);
91 bfd_put_bits ((bfd_vma
) x
, bufp
, word_length
, big_p
);
94 #endif /* ! CGEN_INT_INSN_P */
96 /* Default insertion routine.
98 ATTRS is a mask of the boolean attributes.
99 WORD_OFFSET is the offset in bits from the start of the insn of the value.
100 WORD_LENGTH is the length of the word in bits in which the value resides.
101 START is the starting bit number in the word, architecture origin.
102 LENGTH is the length of VALUE in bits.
103 TOTAL_LENGTH is the total length of the insn in bits.
105 The result is an error message or NULL if success. */
107 /* ??? This duplicates functionality with bfd's howto table and
108 bfd_install_relocation. */
109 /* ??? This doesn't handle bfd_vma's. Create another function when
113 insert_normal (cd
, value
, attrs
, word_offset
, start
, length
, word_length
,
114 total_length
, buffer
)
118 unsigned int word_offset
, start
, length
, word_length
, total_length
;
119 CGEN_INSN_BYTES_PTR buffer
;
121 static char errbuf
[100];
122 /* Written this way to avoid undefined behaviour. */
123 unsigned long mask
= (((1L << (length
- 1)) - 1) << 1) | 1;
125 /* If LENGTH is zero, this operand doesn't contribute to the value. */
135 if (word_length
> 32)
138 /* For architectures with insns smaller than the base-insn-bitsize,
139 word_length may be too big. */
140 if (cd
->min_insn_bitsize
< cd
->base_insn_bitsize
)
143 && word_length
> total_length
)
144 word_length
= total_length
;
147 /* Ensure VALUE will fit. */
148 if (CGEN_BOOL_ATTR (attrs
, CGEN_IFLD_SIGN_OPT
))
150 long minval
= - (1L << (length
- 1));
151 unsigned long maxval
= mask
;
153 if ((value
> 0 && (unsigned long) value
> maxval
)
156 /* xgettext:c-format */
158 _("operand out of range (%ld not between %ld and %lu)"),
159 value
, minval
, maxval
);
163 else if (! CGEN_BOOL_ATTR (attrs
, CGEN_IFLD_SIGNED
))
165 unsigned long maxval
= mask
;
167 if ((unsigned long) value
> maxval
)
169 /* xgettext:c-format */
171 _("operand out of range (%lu not between 0 and %lu)"),
178 if (! cgen_signed_overflow_ok_p (cd
))
180 long minval
= - (1L << (length
- 1));
181 long maxval
= (1L << (length
- 1)) - 1;
183 if (value
< minval
|| value
> maxval
)
186 /* xgettext:c-format */
187 (errbuf
, _("operand out of range (%ld not between %ld and %ld)"),
188 value
, minval
, maxval
);
199 if (CGEN_INSN_LSB0_P
)
200 shift
= (word_offset
+ start
+ 1) - length
;
202 shift
= total_length
- (word_offset
+ start
+ length
);
203 *buffer
= (*buffer
& ~(mask
<< shift
)) | ((value
& mask
) << shift
);
206 #else /* ! CGEN_INT_INSN_P */
209 unsigned char *bufp
= (unsigned char *) buffer
+ word_offset
/ 8;
211 insert_1 (cd
, value
, start
, length
, word_length
, bufp
);
214 #endif /* ! CGEN_INT_INSN_P */
219 /* Default insn builder (insert handler).
220 The instruction is recorded in CGEN_INT_INSN_P byte order (meaning
221 that if CGEN_INSN_BYTES_PTR is an int * and thus, the value is
222 recorded in host byte order, otherwise BUFFER is an array of bytes
223 and the value is recorded in target byte order).
224 The result is an error message or NULL if success. */
227 insert_insn_normal (cd
, insn
, fields
, buffer
, pc
)
229 const CGEN_INSN
* insn
;
230 CGEN_FIELDS
* fields
;
231 CGEN_INSN_BYTES_PTR buffer
;
234 const CGEN_SYNTAX
*syntax
= CGEN_INSN_SYNTAX (insn
);
236 const CGEN_SYNTAX_CHAR_TYPE
* syn
;
238 CGEN_INIT_INSERT (cd
);
239 value
= CGEN_INSN_BASE_VALUE (insn
);
241 /* If we're recording insns as numbers (rather than a string of bytes),
242 target byte order handling is deferred until later. */
246 put_insn_int_value (cd
, buffer
, cd
->base_insn_bitsize
,
247 CGEN_FIELDS_BITSIZE (fields
), value
);
251 cgen_put_insn_value (cd
, buffer
, min (cd
->base_insn_bitsize
,
252 CGEN_FIELDS_BITSIZE (fields
)),
255 #endif /* ! CGEN_INT_INSN_P */
257 /* ??? It would be better to scan the format's fields.
258 Still need to be able to insert a value based on the operand though;
259 e.g. storing a branch displacement that got resolved later.
260 Needs more thought first. */
262 for (syn
= CGEN_SYNTAX_STRING (syntax
); * syn
; ++ syn
)
266 if (CGEN_SYNTAX_CHAR_P (* syn
))
269 errmsg
= (* cd
->insert_operand
) (cd
, CGEN_SYNTAX_FIELD (*syn
),
278 /* Cover function to store an insn value into an integral insn. Must go here
279 because it needs <prefix>-desc.h for CGEN_INT_INSN_P. */
282 put_insn_int_value (cd
, buf
, length
, insn_length
, value
)
283 CGEN_CPU_DESC cd ATTRIBUTE_UNUSED
;
284 CGEN_INSN_BYTES_PTR buf
;
289 /* For architectures with insns smaller than the base-insn-bitsize,
290 length may be too big. */
291 if (length
> insn_length
)
295 int shift
= insn_length
- length
;
296 /* Written this way to avoid undefined behaviour. */
297 CGEN_INSN_INT mask
= (((1L << (length
- 1)) - 1) << 1) | 1;
298 *buf
= (*buf
& ~(mask
<< shift
)) | ((value
& mask
) << shift
);
302 /* Operand extraction. */
304 #if ! CGEN_INT_INSN_P
306 /* Subroutine of extract_normal.
307 Ensure sufficient bytes are cached in EX_INFO.
308 OFFSET is the offset in bytes from the start of the insn of the value.
309 BYTES is the length of the needed value.
310 Returns 1 for success, 0 for failure. */
312 static CGEN_INLINE
int
313 fill_cache (cd
, ex_info
, offset
, bytes
, pc
)
315 CGEN_EXTRACT_INFO
*ex_info
;
319 /* It's doubtful that the middle part has already been fetched so
320 we don't optimize that case. kiss. */
322 disassemble_info
*info
= (disassemble_info
*) ex_info
->dis_info
;
324 /* First do a quick check. */
325 mask
= (1 << bytes
) - 1;
326 if (((ex_info
->valid
>> offset
) & mask
) == mask
)
329 /* Search for the first byte we need to read. */
330 for (mask
= 1 << offset
; bytes
> 0; --bytes
, ++offset
, mask
<<= 1)
331 if (! (mask
& ex_info
->valid
))
339 status
= (*info
->read_memory_func
)
340 (pc
, ex_info
->insn_bytes
+ offset
, bytes
, info
);
344 (*info
->memory_error_func
) (status
, pc
, info
);
348 ex_info
->valid
|= ((1 << bytes
) - 1) << offset
;
354 /* Subroutine of extract_normal. */
356 static CGEN_INLINE
long
357 extract_1 (cd
, ex_info
, start
, length
, word_length
, bufp
, pc
)
359 CGEN_EXTRACT_INFO
*ex_info
;
360 int start
,length
,word_length
;
366 int big_p
= CGEN_CPU_INSN_ENDIAN (cd
) == CGEN_ENDIAN_BIG
;
368 x
= bfd_get_bits (bufp
, word_length
, big_p
);
370 if (CGEN_INSN_LSB0_P
)
371 shift
= (start
+ 1) - length
;
373 shift
= (word_length
- (start
+ length
));
377 #endif /* ! CGEN_INT_INSN_P */
379 /* Default extraction routine.
381 INSN_VALUE is the first base_insn_bitsize bits of the insn in host order,
382 or sometimes less for cases like the m32r where the base insn size is 32
383 but some insns are 16 bits.
384 ATTRS is a mask of the boolean attributes. We only need `SIGNED',
385 but for generality we take a bitmask of all of them.
386 WORD_OFFSET is the offset in bits from the start of the insn of the value.
387 WORD_LENGTH is the length of the word in bits in which the value resides.
388 START is the starting bit number in the word, architecture origin.
389 LENGTH is the length of VALUE in bits.
390 TOTAL_LENGTH is the total length of the insn in bits.
392 Returns 1 for success, 0 for failure. */
394 /* ??? The return code isn't properly used. wip. */
396 /* ??? This doesn't handle bfd_vma's. Create another function when
400 extract_normal (cd
, ex_info
, insn_value
, attrs
, word_offset
, start
, length
,
401 word_length
, total_length
, pc
, valuep
)
403 #if ! CGEN_INT_INSN_P
404 CGEN_EXTRACT_INFO
*ex_info
;
406 CGEN_EXTRACT_INFO
*ex_info ATTRIBUTE_UNUSED
;
408 CGEN_INSN_INT insn_value
;
410 unsigned int word_offset
, start
, length
, word_length
, total_length
;
411 #if ! CGEN_INT_INSN_P
414 bfd_vma pc ATTRIBUTE_UNUSED
;
420 /* If LENGTH is zero, this operand doesn't contribute to the value
421 so give it a standard value of zero. */
434 if (word_length
> 32)
437 /* For architectures with insns smaller than the insn-base-bitsize,
438 word_length may be too big. */
439 if (cd
->min_insn_bitsize
< cd
->base_insn_bitsize
)
442 && word_length
> total_length
)
443 word_length
= total_length
;
446 /* Does the value reside in INSN_VALUE, and at the right alignment? */
448 if (CGEN_INT_INSN_P
|| (word_offset
== 0 && word_length
== total_length
))
450 if (CGEN_INSN_LSB0_P
)
451 value
= insn_value
>> ((word_offset
+ start
+ 1) - length
);
453 value
= insn_value
>> (total_length
- ( word_offset
+ start
+ length
));
456 #if ! CGEN_INT_INSN_P
460 unsigned char *bufp
= ex_info
->insn_bytes
+ word_offset
/ 8;
462 if (word_length
> 32)
465 if (fill_cache (cd
, ex_info
, word_offset
/ 8, word_length
/ 8, pc
) == 0)
468 value
= extract_1 (cd
, ex_info
, start
, length
, word_length
, bufp
, pc
);
471 #endif /* ! CGEN_INT_INSN_P */
473 /* Written this way to avoid undefined behaviour. */
474 mask
= (((1L << (length
- 1)) - 1) << 1) | 1;
478 if (CGEN_BOOL_ATTR (attrs
, CGEN_IFLD_SIGNED
)
479 && (value
& (1L << (length
- 1))))
487 /* Default insn extractor.
489 INSN_VALUE is the first base_insn_bitsize bits, translated to host order.
490 The extracted fields are stored in FIELDS.
491 EX_INFO is used to handle reading variable length insns.
492 Return the length of the insn in bits, or 0 if no match,
493 or -1 if an error occurs fetching data (memory_error_func will have
497 extract_insn_normal (cd
, insn
, ex_info
, insn_value
, fields
, pc
)
499 const CGEN_INSN
*insn
;
500 CGEN_EXTRACT_INFO
*ex_info
;
501 CGEN_INSN_INT insn_value
;
505 const CGEN_SYNTAX
*syntax
= CGEN_INSN_SYNTAX (insn
);
506 const CGEN_SYNTAX_CHAR_TYPE
*syn
;
508 CGEN_FIELDS_BITSIZE (fields
) = CGEN_INSN_BITSIZE (insn
);
510 CGEN_INIT_EXTRACT (cd
);
512 for (syn
= CGEN_SYNTAX_STRING (syntax
); *syn
; ++syn
)
516 if (CGEN_SYNTAX_CHAR_P (*syn
))
519 length
= (* cd
->extract_operand
) (cd
, CGEN_SYNTAX_FIELD (*syn
),
520 ex_info
, insn_value
, fields
, pc
);
525 /* We recognized and successfully extracted this insn. */
526 return CGEN_INSN_BITSIZE (insn
);
529 /* machine generated code added here */
531 /* Main entry point for operand insertion.
533 This function is basically just a big switch statement. Earlier versions
534 used tables to look up the function to use, but
535 - if the table contains both assembler and disassembler functions then
536 the disassembler contains much of the assembler and vice-versa,
537 - there's a lot of inlining possibilities as things grow,
538 - using a switch statement avoids the function call overhead.
540 This function could be moved into `parse_insn_normal', but keeping it
541 separate makes clear the interface between `parse_insn_normal' and each of
542 the handlers. It's also needed by GAS to insert operands that couldn't be
543 resolved during parsing.
547 openrisc_cgen_insert_operand (cd
, opindex
, fields
, buffer
, pc
)
550 CGEN_FIELDS
* fields
;
551 CGEN_INSN_BYTES_PTR buffer
;
554 const char * errmsg
= NULL
;
555 unsigned int total_length
= CGEN_FIELDS_BITSIZE (fields
);
559 case OPENRISC_OPERAND_ABS_26
:
561 long value
= fields
->f_abs26
;
562 value
= ((unsigned int) (pc
) >> (2));
563 errmsg
= insert_normal (cd
, value
, 0|(1<<CGEN_IFLD_SIGNED
)|(1<<CGEN_IFLD_ABS_ADDR
), 0, 25, 26, 32, total_length
, buffer
);
566 case OPENRISC_OPERAND_DISP_26
:
568 long value
= fields
->f_disp26
;
569 value
= ((int) (((value
) - (pc
))) >> (2));
570 errmsg
= insert_normal (cd
, value
, 0|(1<<CGEN_IFLD_SIGNED
)|(1<<CGEN_IFLD_PCREL_ADDR
), 0, 25, 26, 32, total_length
, buffer
);
573 case OPENRISC_OPERAND_HI16
:
574 errmsg
= insert_normal (cd
, fields
->f_simm16
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 15, 16, 32, total_length
, buffer
);
576 case OPENRISC_OPERAND_LO16
:
577 errmsg
= insert_normal (cd
, fields
->f_lo16
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 15, 16, 32, total_length
, buffer
);
579 case OPENRISC_OPERAND_OP_F_23
:
580 errmsg
= insert_normal (cd
, fields
->f_op4
, 0, 0, 23, 3, 32, total_length
, buffer
);
582 case OPENRISC_OPERAND_OP_F_3
:
583 errmsg
= insert_normal (cd
, fields
->f_op5
, 0, 0, 25, 5, 32, total_length
, buffer
);
585 case OPENRISC_OPERAND_RA
:
586 errmsg
= insert_normal (cd
, fields
->f_r2
, 0, 0, 20, 5, 32, total_length
, buffer
);
588 case OPENRISC_OPERAND_RB
:
589 errmsg
= insert_normal (cd
, fields
->f_r3
, 0, 0, 15, 5, 32, total_length
, buffer
);
591 case OPENRISC_OPERAND_RD
:
592 errmsg
= insert_normal (cd
, fields
->f_r1
, 0, 0, 25, 5, 32, total_length
, buffer
);
594 case OPENRISC_OPERAND_SIMM_16
:
595 errmsg
= insert_normal (cd
, fields
->f_simm16
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 15, 16, 32, total_length
, buffer
);
597 case OPENRISC_OPERAND_UI16NC
:
600 FLD (f_i16_2
) = ((((unsigned int) (FLD (f_i16nc
)) >> (11))) & (31));
601 FLD (f_i16_1
) = ((FLD (f_i16nc
)) & (2047));
603 errmsg
= insert_normal (cd
, fields
->f_i16_1
, 0, 0, 10, 11, 32, total_length
, buffer
);
606 errmsg
= insert_normal (cd
, fields
->f_i16_2
, 0, 0, 25, 5, 32, total_length
, buffer
);
611 case OPENRISC_OPERAND_UIMM_16
:
612 errmsg
= insert_normal (cd
, fields
->f_uimm16
, 0, 0, 15, 16, 32, total_length
, buffer
);
614 case OPENRISC_OPERAND_UIMM_5
:
615 errmsg
= insert_normal (cd
, fields
->f_uimm5
, 0, 0, 4, 5, 32, total_length
, buffer
);
619 /* xgettext:c-format */
620 fprintf (stderr
, _("Unrecognized field %d while building insn.\n"),
628 /* Main entry point for operand extraction.
629 The result is <= 0 for error, >0 for success.
630 ??? Actual values aren't well defined right now.
632 This function is basically just a big switch statement. Earlier versions
633 used tables to look up the function to use, but
634 - if the table contains both assembler and disassembler functions then
635 the disassembler contains much of the assembler and vice-versa,
636 - there's a lot of inlining possibilities as things grow,
637 - using a switch statement avoids the function call overhead.
639 This function could be moved into `print_insn_normal', but keeping it
640 separate makes clear the interface between `print_insn_normal' and each of
645 openrisc_cgen_extract_operand (cd
, opindex
, ex_info
, insn_value
, fields
, pc
)
648 CGEN_EXTRACT_INFO
*ex_info
;
649 CGEN_INSN_INT insn_value
;
650 CGEN_FIELDS
* fields
;
653 /* Assume success (for those operands that are nops). */
655 unsigned int total_length
= CGEN_FIELDS_BITSIZE (fields
);
659 case OPENRISC_OPERAND_ABS_26
:
662 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
)|(1<<CGEN_IFLD_ABS_ADDR
), 0, 25, 26, 32, total_length
, pc
, & value
);
663 value
= ((value
) << (2));
664 fields
->f_abs26
= value
;
667 case OPENRISC_OPERAND_DISP_26
:
670 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
)|(1<<CGEN_IFLD_PCREL_ADDR
), 0, 25, 26, 32, total_length
, pc
, & value
);
671 value
= ((((value
) << (2))) + (pc
));
672 fields
->f_disp26
= value
;
675 case OPENRISC_OPERAND_HI16
:
676 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 15, 16, 32, total_length
, pc
, & fields
->f_simm16
);
678 case OPENRISC_OPERAND_LO16
:
679 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 15, 16, 32, total_length
, pc
, & fields
->f_lo16
);
681 case OPENRISC_OPERAND_OP_F_23
:
682 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 23, 3, 32, total_length
, pc
, & fields
->f_op4
);
684 case OPENRISC_OPERAND_OP_F_3
:
685 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 5, 32, total_length
, pc
, & fields
->f_op5
);
687 case OPENRISC_OPERAND_RA
:
688 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 20, 5, 32, total_length
, pc
, & fields
->f_r2
);
690 case OPENRISC_OPERAND_RB
:
691 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 5, 32, total_length
, pc
, & fields
->f_r3
);
693 case OPENRISC_OPERAND_RD
:
694 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 5, 32, total_length
, pc
, & fields
->f_r1
);
696 case OPENRISC_OPERAND_SIMM_16
:
697 length
= extract_normal (cd
, ex_info
, insn_value
, 0|(1<<CGEN_IFLD_SIGNED
), 0, 15, 16, 32, total_length
, pc
, & fields
->f_simm16
);
699 case OPENRISC_OPERAND_UI16NC
:
701 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 10, 11, 32, total_length
, pc
, & fields
->f_i16_1
);
702 if (length
<= 0) break;
703 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 25, 5, 32, total_length
, pc
, & fields
->f_i16_2
);
704 if (length
<= 0) break;
706 FLD (f_i16nc
) = openrisc_sign_extend_16bit (((((FLD (f_i16_2
)) << (11))) | (FLD (f_i16_1
))));
710 case OPENRISC_OPERAND_UIMM_16
:
711 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 15, 16, 32, total_length
, pc
, & fields
->f_uimm16
);
713 case OPENRISC_OPERAND_UIMM_5
:
714 length
= extract_normal (cd
, ex_info
, insn_value
, 0, 0, 4, 5, 32, total_length
, pc
, & fields
->f_uimm5
);
718 /* xgettext:c-format */
719 fprintf (stderr
, _("Unrecognized field %d while decoding insn.\n"),
727 cgen_insert_fn
* const openrisc_cgen_insert_handlers
[] =
732 cgen_extract_fn
* const openrisc_cgen_extract_handlers
[] =
737 /* Getting values from cgen_fields is handled by a collection of functions.
738 They are distinguished by the type of the VALUE argument they return.
739 TODO: floating point, inlining support, remove cases where result type
743 openrisc_cgen_get_int_operand (cd
, opindex
, fields
)
746 const CGEN_FIELDS
* fields
;
752 case OPENRISC_OPERAND_ABS_26
:
753 value
= fields
->f_abs26
;
755 case OPENRISC_OPERAND_DISP_26
:
756 value
= fields
->f_disp26
;
758 case OPENRISC_OPERAND_HI16
:
759 value
= fields
->f_simm16
;
761 case OPENRISC_OPERAND_LO16
:
762 value
= fields
->f_lo16
;
764 case OPENRISC_OPERAND_OP_F_23
:
765 value
= fields
->f_op4
;
767 case OPENRISC_OPERAND_OP_F_3
:
768 value
= fields
->f_op5
;
770 case OPENRISC_OPERAND_RA
:
771 value
= fields
->f_r2
;
773 case OPENRISC_OPERAND_RB
:
774 value
= fields
->f_r3
;
776 case OPENRISC_OPERAND_RD
:
777 value
= fields
->f_r1
;
779 case OPENRISC_OPERAND_SIMM_16
:
780 value
= fields
->f_simm16
;
782 case OPENRISC_OPERAND_UI16NC
:
783 value
= fields
->f_i16nc
;
785 case OPENRISC_OPERAND_UIMM_16
:
786 value
= fields
->f_uimm16
;
788 case OPENRISC_OPERAND_UIMM_5
:
789 value
= fields
->f_uimm5
;
793 /* xgettext:c-format */
794 fprintf (stderr
, _("Unrecognized field %d while getting int operand.\n"),
803 openrisc_cgen_get_vma_operand (cd
, opindex
, fields
)
806 const CGEN_FIELDS
* fields
;
812 case OPENRISC_OPERAND_ABS_26
:
813 value
= fields
->f_abs26
;
815 case OPENRISC_OPERAND_DISP_26
:
816 value
= fields
->f_disp26
;
818 case OPENRISC_OPERAND_HI16
:
819 value
= fields
->f_simm16
;
821 case OPENRISC_OPERAND_LO16
:
822 value
= fields
->f_lo16
;
824 case OPENRISC_OPERAND_OP_F_23
:
825 value
= fields
->f_op4
;
827 case OPENRISC_OPERAND_OP_F_3
:
828 value
= fields
->f_op5
;
830 case OPENRISC_OPERAND_RA
:
831 value
= fields
->f_r2
;
833 case OPENRISC_OPERAND_RB
:
834 value
= fields
->f_r3
;
836 case OPENRISC_OPERAND_RD
:
837 value
= fields
->f_r1
;
839 case OPENRISC_OPERAND_SIMM_16
:
840 value
= fields
->f_simm16
;
842 case OPENRISC_OPERAND_UI16NC
:
843 value
= fields
->f_i16nc
;
845 case OPENRISC_OPERAND_UIMM_16
:
846 value
= fields
->f_uimm16
;
848 case OPENRISC_OPERAND_UIMM_5
:
849 value
= fields
->f_uimm5
;
853 /* xgettext:c-format */
854 fprintf (stderr
, _("Unrecognized field %d while getting vma operand.\n"),
862 /* Stuffing values in cgen_fields is handled by a collection of functions.
863 They are distinguished by the type of the VALUE argument they accept.
864 TODO: floating point, inlining support, remove cases where argument type
868 openrisc_cgen_set_int_operand (cd
, opindex
, fields
, value
)
871 CGEN_FIELDS
* fields
;
876 case OPENRISC_OPERAND_ABS_26
:
877 fields
->f_abs26
= value
;
879 case OPENRISC_OPERAND_DISP_26
:
880 fields
->f_disp26
= value
;
882 case OPENRISC_OPERAND_HI16
:
883 fields
->f_simm16
= value
;
885 case OPENRISC_OPERAND_LO16
:
886 fields
->f_lo16
= value
;
888 case OPENRISC_OPERAND_OP_F_23
:
889 fields
->f_op4
= value
;
891 case OPENRISC_OPERAND_OP_F_3
:
892 fields
->f_op5
= value
;
894 case OPENRISC_OPERAND_RA
:
895 fields
->f_r2
= value
;
897 case OPENRISC_OPERAND_RB
:
898 fields
->f_r3
= value
;
900 case OPENRISC_OPERAND_RD
:
901 fields
->f_r1
= value
;
903 case OPENRISC_OPERAND_SIMM_16
:
904 fields
->f_simm16
= value
;
906 case OPENRISC_OPERAND_UI16NC
:
907 fields
->f_i16nc
= value
;
909 case OPENRISC_OPERAND_UIMM_16
:
910 fields
->f_uimm16
= value
;
912 case OPENRISC_OPERAND_UIMM_5
:
913 fields
->f_uimm5
= value
;
917 /* xgettext:c-format */
918 fprintf (stderr
, _("Unrecognized field %d while setting int operand.\n"),
925 openrisc_cgen_set_vma_operand (cd
, opindex
, fields
, value
)
928 CGEN_FIELDS
* fields
;
933 case OPENRISC_OPERAND_ABS_26
:
934 fields
->f_abs26
= value
;
936 case OPENRISC_OPERAND_DISP_26
:
937 fields
->f_disp26
= value
;
939 case OPENRISC_OPERAND_HI16
:
940 fields
->f_simm16
= value
;
942 case OPENRISC_OPERAND_LO16
:
943 fields
->f_lo16
= value
;
945 case OPENRISC_OPERAND_OP_F_23
:
946 fields
->f_op4
= value
;
948 case OPENRISC_OPERAND_OP_F_3
:
949 fields
->f_op5
= value
;
951 case OPENRISC_OPERAND_RA
:
952 fields
->f_r2
= value
;
954 case OPENRISC_OPERAND_RB
:
955 fields
->f_r3
= value
;
957 case OPENRISC_OPERAND_RD
:
958 fields
->f_r1
= value
;
960 case OPENRISC_OPERAND_SIMM_16
:
961 fields
->f_simm16
= value
;
963 case OPENRISC_OPERAND_UI16NC
:
964 fields
->f_i16nc
= value
;
966 case OPENRISC_OPERAND_UIMM_16
:
967 fields
->f_uimm16
= value
;
969 case OPENRISC_OPERAND_UIMM_5
:
970 fields
->f_uimm5
= value
;
974 /* xgettext:c-format */
975 fprintf (stderr
, _("Unrecognized field %d while setting vma operand.\n"),
981 /* Function to call before using the instruction builder tables. */
984 openrisc_cgen_init_ibld_table (cd
)
987 cd
->insert_handlers
= & openrisc_cgen_insert_handlers
[0];
988 cd
->extract_handlers
= & openrisc_cgen_extract_handlers
[0];
990 cd
->insert_operand
= openrisc_cgen_insert_operand
;
991 cd
->extract_operand
= openrisc_cgen_extract_operand
;
993 cd
->get_int_operand
= openrisc_cgen_get_int_operand
;
994 cd
->set_int_operand
= openrisc_cgen_set_int_operand
;
995 cd
->get_vma_operand
= openrisc_cgen_get_vma_operand
;
996 cd
->set_vma_operand
= openrisc_cgen_set_vma_operand
;