From: Alan Modra Date: Thu, 4 Dec 2003 08:33:25 +0000 (+0000) Subject: * cpu/openrisc.opc (openrisc_sign_extend_16bit): Don't rely on X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=caa4cda5058d7127f6c49d1be6dceba4b83aa6c9;p=cgen.git * cpu/openrisc.opc (openrisc_sign_extend_16bit): Don't rely on "short" being 16 bit. (parse_hi16): Likewise. Fix type-punned pointer warnings too, and internationalize error message. (parse_lo16): Likewise. Remove useless code. --- diff --git a/ChangeLog b/ChangeLog index c4e5036..74c0371 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2003-12-04 Alan Modra + + * cpu/openrisc.opc (openrisc_sign_extend_16bit): Don't rely on + "short" being 16 bit. + (parse_hi16): Likewise. Fix type-punned pointer warnings too, and + internationalize error message. + (parse_lo16): Likewise. Remove useless code. + 2003-12-03 Kazuhiro Inaoka * cpu/m32r.cpu : Add new model m32r2. diff --git a/cpu/openrisc.opc b/cpu/openrisc.opc index 4b6b0d7..7e18bba 100644 --- a/cpu/openrisc.opc +++ b/cpu/openrisc.opc @@ -1,5 +1,5 @@ /* OpenRISC opcode support. -*- C -*- - Copyright (C) 2000, 2001 Free Software Foundation + Copyright (C) 2000, 2001, 2003 Free Software Foundation Based upon work by Red Hat, Inc. This file is part of CGEN. */ @@ -44,7 +44,7 @@ long openrisc_sign_extend_16bit (value) long value; { - return (long) (short) value; + return ((value & 0xffff) ^ 0x8000) - 0x8000; } /* Handle hi(). */ @@ -58,15 +58,16 @@ parse_hi16 (cd, strp, opindex, valuep) { const char *errmsg; enum cgen_parse_operand_result result_type; - bfd_vma value; + unsigned long ret; if (**strp == '#') ++*strp; if (strncasecmp (*strp, "hi(", 3) == 0) { - *strp += 3; + bfd_vma value; + *strp += 3; #if 0 errmsg = cgen_parse_signed_integer (cd, strp, opindex, valuep); if (errmsg != NULL) @@ -76,23 +77,31 @@ parse_hi16 (cd, strp, opindex, valuep) errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_HI16, &result_type, &value); if (**strp != ')') - return "missing `)'"; + return _("missing `)'"); + ++*strp; if (errmsg == NULL && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) value >>= 16; - *valuep = (long) (short) value; - - return errmsg; + ret = value; } else { if (**strp == '-') - errmsg = cgen_parse_signed_integer (cd, strp, opindex, (long *) &value); + { + long value; + errmsg = cgen_parse_signed_integer (cd, strp, opindex, &value); + ret = value; + } else - errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, (unsigned long *) &value); + { + unsigned long value; + errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, &value); + ret = value; + } } - *valuep = (long) (short) (value & 0xffff); + + *valuep = ((ret & 0xffff) ^ 0x8000) - 0x8000; return errmsg; } @@ -107,15 +116,16 @@ parse_lo16 (cd, strp, opindex, valuep) { const char *errmsg; enum cgen_parse_operand_result result_type; - bfd_vma value; + unsigned long ret; if (**strp == '#') ++*strp; if (strncasecmp (*strp, "lo(", 3) == 0) { - *strp += 3; + bfd_vma value; + *strp += 3; #if 0 errmsg = cgen_parse_signed_integer (cd, strp, opindex, valuep); if (errmsg != NULL) @@ -126,21 +136,28 @@ parse_lo16 (cd, strp, opindex, valuep) errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_LO16, &result_type, &value); if (**strp != ')') - return "missing `)'"; - ++*strp; - if (errmsg == NULL - && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) - value &= 0xffff; - *valuep = (long) (short) value; + return _("missing `)'"); - return errmsg; + ++*strp; + ret = value; } - - if (**strp == '-') - errmsg = cgen_parse_signed_integer (cd, strp, opindex, (long *) &value); else - errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, (unsigned long *) &value); - *valuep = (long) (short) (value & 0xffff); + { + if (**strp == '-') + { + long value; + errmsg = cgen_parse_signed_integer (cd, strp, opindex, &value); + ret = value; + } + else + { + unsigned long value; + errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, &value); + ret = value; + } + } + + *valuep = ((ret & 0xffff) ^ 0x8000) - 0x8000; return errmsg; }