X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=opcodes%2Ffr30-ibld.c;h=f2d9eb8c649142e4621978f80a9b99fae979e562;hb=8f467114435286e4f78b16fc1f5864acf6488fc0;hp=d41332582d64ec93ec2056e93cc6b68c1bc72f9f;hpb=4b95cf5c0c75d6efc1b2f96af72317aecca079f1;p=binutils-gdb.git diff --git a/opcodes/fr30-ibld.c b/opcodes/fr30-ibld.c index d41332582d6..f2d9eb8c649 100644 --- a/opcodes/fr30-ibld.c +++ b/opcodes/fr30-ibld.c @@ -1,9 +1,10 @@ +/* DO NOT EDIT! -*- buffer-read-only: t -*- vi:set ro: */ /* Instruction building/extraction support for fr30. -*- C -*- THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator. - the resultant file is machine generated, cgen-ibld.in isn't - Copyright (C) 1996-2014 Free Software Foundation, Inc. + Copyright (C) 1996-2021 Free Software Foundation, Inc. This file is part of libopcodes. @@ -84,20 +85,20 @@ insert_1 (CGEN_CPU_DESC cd, int word_length, unsigned char *bufp) { - unsigned long x,mask; + unsigned long x, mask; int shift; - x = cgen_get_insn_value (cd, bufp, word_length); + x = cgen_get_insn_value (cd, bufp, word_length, cd->endian); /* Written this way to avoid undefined behaviour. */ - mask = (((1L << (length - 1)) - 1) << 1) | 1; + mask = (1UL << (length - 1) << 1) - 1; if (CGEN_INSN_LSB0_P) shift = (start + 1) - length; else shift = (word_length - (start + length)); x = (x & ~(mask << shift)) | ((value & mask) << shift); - cgen_put_insn_value (cd, bufp, word_length, (bfd_vma) x); + cgen_put_insn_value (cd, bufp, word_length, (bfd_vma) x, cd->endian); } #endif /* ! CGEN_INT_INSN_P */ @@ -130,13 +131,15 @@ insert_normal (CGEN_CPU_DESC cd, CGEN_INSN_BYTES_PTR buffer) { static char errbuf[100]; - /* Written this way to avoid undefined behaviour. */ - unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1; + unsigned long mask; /* If LENGTH is zero, this operand doesn't contribute to the value. */ if (length == 0) return NULL; + /* Written this way to avoid undefined behaviour. */ + mask = (1UL << (length - 1) << 1) - 1; + if (word_length > 8 * sizeof (CGEN_INSN_INT)) abort (); @@ -152,9 +155,9 @@ insert_normal (CGEN_CPU_DESC cd, /* Ensure VALUE will fit. */ if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGN_OPT)) { - long minval = - (1L << (length - 1)); + long minval = - (1UL << (length - 1)); unsigned long maxval = mask; - + if ((value > 0 && (unsigned long) value > maxval) || value < minval) { @@ -190,9 +193,9 @@ insert_normal (CGEN_CPU_DESC cd, { if (! cgen_signed_overflow_ok_p (cd)) { - long minval = - (1L << (length - 1)); - long maxval = (1L << (length - 1)) - 1; - + long minval = - (1UL << (length - 1)); + long maxval = (1UL << (length - 1)) - 1; + if (value < minval || value > maxval) { sprintf @@ -207,12 +210,19 @@ insert_normal (CGEN_CPU_DESC cd, #if CGEN_INT_INSN_P { - int shift; + int shift_within_word, shift_to_word, shift; + + /* How to shift the value to BIT0 of the word. */ + shift_to_word = total_length - (word_offset + word_length); + /* How to shift the value to the field within the word. */ if (CGEN_INSN_LSB0_P) - shift = (word_offset + start + 1) - length; + shift_within_word = start + 1 - length; else - shift = total_length - (word_offset + start + length); + shift_within_word = word_length - start - length; + + /* The total SHIFT, then mask in the value. */ + shift = shift_to_word + shift_within_word; *buffer = (*buffer & ~(mask << shift)) | ((value & mask) << shift); } @@ -261,8 +271,8 @@ insert_insn_normal (CGEN_CPU_DESC cd, #else cgen_put_insn_value (cd, buffer, min ((unsigned) cd->base_insn_bitsize, - (unsigned) CGEN_FIELDS_BITSIZE (fields)), - value); + (unsigned) CGEN_FIELDS_BITSIZE (fields)), + value, cd->insn_endian); #endif /* ! CGEN_INT_INSN_P */ @@ -306,7 +316,7 @@ put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, { int shift = insn_length - length; /* Written this way to avoid undefined behaviour. */ - CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1; + CGEN_INSN_INT mask = length == 0 ? 0 : (1UL << (length - 1) << 1) - 1; *buf = (*buf & ~(mask << shift)) | ((value & mask) << shift); } @@ -379,7 +389,7 @@ extract_1 (CGEN_CPU_DESC cd, unsigned long x; int shift; - x = cgen_get_insn_value (cd, bufp, word_length); + x = cgen_get_insn_value (cd, bufp, word_length, cd->endian); if (CGEN_INSN_LSB0_P) shift = (start + 1) - length; @@ -472,7 +482,10 @@ extract_normal (CGEN_CPU_DESC cd, abort (); if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0) - return 0; + { + *valuep = 0; + return 0; + } value = extract_1 (cd, ex_info, start, length, word_length, bufp, pc); } @@ -480,12 +493,12 @@ extract_normal (CGEN_CPU_DESC cd, #endif /* ! CGEN_INT_INSN_P */ /* Written this way to avoid undefined behaviour. */ - mask = (((1L << (length - 1)) - 1) << 1) | 1; + mask = (1UL << (length - 1) << 1) - 1; value &= mask; /* sign extend? */ if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED) - && (value & (1L << (length - 1)))) + && (value & (1UL << (length - 1)))) value |= ~mask; *valuep = value; @@ -723,8 +736,9 @@ fr30_cgen_insert_operand (CGEN_CPU_DESC cd, default : /* xgettext:c-format */ - fprintf (stderr, _("Unrecognized field %d while building insn.\n"), - opindex); + opcodes_error_handler + (_("internal error: unrecognized field %d while building insn"), + opindex); abort (); } @@ -822,7 +836,7 @@ fr30_cgen_extract_operand (CGEN_CPU_DESC cd, { long value; length = extract_normal (cd, ex_info, insn_value, 0|(1<f_disp10 = value; } break; @@ -833,7 +847,7 @@ fr30_cgen_extract_operand (CGEN_CPU_DESC cd, { long value; length = extract_normal (cd, ex_info, insn_value, 0|(1<f_disp9 = value; } break; @@ -858,7 +872,7 @@ fr30_cgen_extract_operand (CGEN_CPU_DESC cd, { long value; length = extract_normal (cd, ex_info, insn_value, 0|(1<f_rel12 = value; } break; @@ -866,7 +880,7 @@ fr30_cgen_extract_operand (CGEN_CPU_DESC cd, { long value; length = extract_normal (cd, ex_info, insn_value, 0|(1<f_rel9 = value; } break; @@ -874,7 +888,7 @@ fr30_cgen_extract_operand (CGEN_CPU_DESC cd, { long value; length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 4, 16, total_length, pc, & value); - value = ((value) | (((-1) << (4)))); + value = ((value) | (-16)); fields->f_m4 = value; } break; @@ -896,7 +910,7 @@ fr30_cgen_extract_operand (CGEN_CPU_DESC cd, { long value; length = extract_normal (cd, ex_info, insn_value, 0|(1<f_s10 = value; } break; @@ -928,20 +942,21 @@ fr30_cgen_extract_operand (CGEN_CPU_DESC cd, default : /* xgettext:c-format */ - fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"), - opindex); + opcodes_error_handler + (_("internal error: unrecognized field %d while decoding insn"), + opindex); abort (); } return length; } -cgen_insert_fn * const fr30_cgen_insert_handlers[] = +cgen_insert_fn * const fr30_cgen_insert_handlers[] = { insert_insn_normal, }; -cgen_extract_fn * const fr30_cgen_extract_handlers[] = +cgen_extract_fn * const fr30_cgen_extract_handlers[] = { extract_insn_normal, }; @@ -1074,8 +1089,9 @@ fr30_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, default : /* xgettext:c-format */ - fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"), - opindex); + opcodes_error_handler + (_("internal error: unrecognized field %d while getting int operand"), + opindex); abort (); } @@ -1202,8 +1218,9 @@ fr30_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, default : /* xgettext:c-format */ - fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"), - opindex); + opcodes_error_handler + (_("internal error: unrecognized field %d while getting vma operand"), + opindex); abort (); } @@ -1333,8 +1350,9 @@ fr30_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, default : /* xgettext:c-format */ - fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"), - opindex); + opcodes_error_handler + (_("internal error: unrecognized field %d while setting int operand"), + opindex); abort (); } } @@ -1454,8 +1472,9 @@ fr30_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, default : /* xgettext:c-format */ - fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"), - opindex); + opcodes_error_handler + (_("internal error: unrecognized field %d while setting vma operand"), + opindex); abort (); } }