diff options
author | Alan Modra <amodra@gmail.com> | 2003-07-07 01:34:04 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2003-07-07 01:34:04 +0000 |
commit | 8427c424251eeb9dfd53b39b54e77d6e8e7d4ba6 (patch) | |
tree | 3d9a10bbbc7c90e1ce85b6a03b3028df42364f7d /opcodes/ppc-opc.c | |
parent | 503e66900fddfec60fd5d8099413b4e04d65a7e7 (diff) | |
download | gdb-8427c424251eeb9dfd53b39b54e77d6e8e7d4ba6.zip gdb-8427c424251eeb9dfd53b39b54e77d6e8e7d4ba6.tar.gz gdb-8427c424251eeb9dfd53b39b54e77d6e8e7d4ba6.tar.bz2 |
* ppc-opc.c: Remove NULL pointer checks. Formatting. Remove
extraneous ATTRIBUTE_UNUSED.
* ppc-dis.c (print_insn_powerpc): Always pass a valid address to
operand->extract.
Diffstat (limited to 'opcodes/ppc-opc.c')
-rw-r--r-- | opcodes/ppc-opc.c | 160 |
1 files changed, 69 insertions, 91 deletions
diff --git a/opcodes/ppc-opc.c b/opcodes/ppc-opc.c index ced449a..02d9872 100644 --- a/opcodes/ppc-opc.c +++ b/opcodes/ppc-opc.c @@ -563,8 +563,7 @@ extract_bat (unsigned long insn, int dialect ATTRIBUTE_UNUSED, int *invalid) { - if (invalid != NULL - && ((insn >> 21) & 0x1f) != ((insn >> 16) & 0x1f)) + if (((insn >> 21) & 0x1f) != ((insn >> 16) & 0x1f)) *invalid = 1; return 0; } @@ -590,8 +589,7 @@ extract_bba (unsigned long insn, int dialect ATTRIBUTE_UNUSED, int *invalid) { - if (invalid != NULL - && ((insn >> 16) & 0x1f) != ((insn >> 11) & 0x1f)) + if (((insn >> 16) & 0x1f) != ((insn >> 11) & 0x1f)) *invalid = 1; return 0; } @@ -658,20 +656,18 @@ extract_bdm (unsigned long insn, int dialect, int *invalid) { - if (invalid != NULL) + if ((dialect & PPC_OPCODE_POWER4) == 0) { - if ((dialect & PPC_OPCODE_POWER4) == 0) - { - if (((insn & (1 << 21)) == 0) != ((insn & (1 << 15)) == 0)) - *invalid = 1; - } - else - { - if ((insn & (0x17 << 21)) != (0x06 << 21) - && (insn & (0x1d << 21)) != (0x18 << 21)) - *invalid = 1; - } + if (((insn & (1 << 21)) == 0) != ((insn & (1 << 15)) == 0)) + *invalid = 1; } + else + { + if ((insn & (0x17 << 21)) != (0x06 << 21) + && (insn & (0x1d << 21)) != (0x18 << 21)) + *invalid = 1; + } + return ((insn & 0xfffc) ^ 0x8000) - 0x8000; } @@ -706,20 +702,18 @@ extract_bdp (unsigned long insn, int dialect, int *invalid) { - if (invalid != NULL) + if ((dialect & PPC_OPCODE_POWER4) == 0) { - if ((dialect & PPC_OPCODE_POWER4) == 0) - { - if (((insn & (1 << 21)) == 0) == ((insn & (1 << 15)) == 0)) - *invalid = 1; - } - else - { - if ((insn & (0x17 << 21)) != (0x07 << 21) - && (insn & (0x1d << 21)) != (0x19 << 21)) - *invalid = 1; - } + if (((insn & (1 << 21)) == 0) == ((insn & (1 << 15)) == 0)) + *invalid = 1; + } + else + { + if ((insn & (0x17 << 21)) != (0x07 << 21) + && (insn & (0x1d << 21)) != (0x19 << 21)) + *invalid = 1; } + return ((insn & 0xfffc) ^ 0x8000) - 0x8000; } @@ -783,8 +777,7 @@ insert_bo (unsigned long insn, int dialect, const char **errmsg) { - if (errmsg != NULL - && ! valid_bo (value, dialect)) + if (!valid_bo (value, dialect)) *errmsg = _("invalid conditional option"); return insn | ((value & 0x1f) << 21); } @@ -797,8 +790,7 @@ extract_bo (unsigned long insn, long value; value = (insn >> 21) & 0x1f; - if (invalid != NULL - && ! valid_bo (value, dialect)) + if (!valid_bo (value, dialect)) *invalid = 1; return value; } @@ -813,13 +805,11 @@ insert_boe (unsigned long insn, int dialect, const char **errmsg) { - if (errmsg != NULL) - { - if (! valid_bo (value, dialect)) - *errmsg = _("invalid conditional option"); - else if ((value & 1) != 0) - *errmsg = _("attempt to set y bit when using + or - modifier"); - } + if (!valid_bo (value, dialect)) + *errmsg = _("invalid conditional option"); + else if ((value & 1) != 0) + *errmsg = _("attempt to set y bit when using + or - modifier"); + return insn | ((value & 0x1f) << 21); } @@ -831,23 +821,22 @@ extract_boe (unsigned long insn, long value; value = (insn >> 21) & 0x1f; - if (invalid != NULL - && ! valid_bo (value, dialect)) + if (!valid_bo (value, dialect)) *invalid = 1; return value & 0x1e; } - /* The DQ field in a DQ form instruction. This is like D, but the - lower four bits are forced to zero. */ +/* The DQ field in a DQ form instruction. This is like D, but the + lower four bits are forced to zero. */ /*ARGSUSED*/ static unsigned long insert_dq (unsigned long insn, long value, int dialect ATTRIBUTE_UNUSED, - const char ** errmsg ATTRIBUTE_UNUSED) + const char **errmsg) { - if ((value & 0xf) != 0 && errmsg != NULL) + if ((value & 0xf) != 0) *errmsg = _("offset not a multiple of 16"); return insn | (value & 0xfff0); } @@ -865,11 +854,11 @@ static unsigned long insert_ev2 (unsigned long insn, long value, int dialect ATTRIBUTE_UNUSED, - const char ** errmsg ATTRIBUTE_UNUSED) + const char **errmsg) { - if ((value & 1) != 0 && errmsg != NULL) + if ((value & 1) != 0) *errmsg = _("offset not a multiple of 2"); - if ((value > 62) != 0 && errmsg != NULL) + if ((value > 62) != 0) *errmsg = _("offset greater than 62"); return insn | ((value & 0x3e) << 10); } @@ -886,11 +875,11 @@ static unsigned long insert_ev4 (unsigned long insn, long value, int dialect ATTRIBUTE_UNUSED, - const char **errmsg ATTRIBUTE_UNUSED) + const char **errmsg) { - if ((value & 3) != 0 && errmsg != NULL) + if ((value & 3) != 0) *errmsg = _("offset not a multiple of 4"); - if ((value > 124) != 0 && errmsg != NULL) + if ((value > 124) != 0) *errmsg = _("offset greater than 124"); return insn | ((value & 0x7c) << 9); } @@ -907,11 +896,11 @@ static unsigned long insert_ev8 (unsigned long insn, long value, int dialect ATTRIBUTE_UNUSED, - const char **errmsg ATTRIBUTE_UNUSED) + const char **errmsg) { - if ((value & 7) != 0 && errmsg != NULL) + if ((value & 7) != 0) *errmsg = _("offset not a multiple of 8"); - if ((value > 248) != 0 && errmsg != NULL) + if ((value > 248) != 0) *errmsg = _("offset greater than 248"); return insn | ((value & 0xf8) << 8); } @@ -919,7 +908,7 @@ insert_ev8 (unsigned long insn, static long extract_ev8 (unsigned long insn, int dialect ATTRIBUTE_UNUSED, - int * invalid ATTRIBUTE_UNUSED) + int *invalid ATTRIBUTE_UNUSED) { return (insn >> 8) & 0xf8; } @@ -934,7 +923,7 @@ insert_ds (unsigned long insn, int dialect ATTRIBUTE_UNUSED, const char **errmsg) { - if ((value & 3) != 0 && errmsg != NULL) + if ((value & 3) != 0) *errmsg = _("offset not a multiple of 4"); return insn | (value & 0xfffc); } @@ -957,7 +946,7 @@ insert_de (unsigned long insn, int dialect ATTRIBUTE_UNUSED, const char **errmsg) { - if ((value > 2047 || value < -2048) && errmsg != NULL) + if (value > 2047 || value < -2048) *errmsg = _("offset not between -2048 and 2047"); return insn | ((value << 4) & 0xfff0); } @@ -980,9 +969,9 @@ insert_des (unsigned long insn, int dialect ATTRIBUTE_UNUSED, const char **errmsg) { - if ((value > 8191 || value < -8192) && errmsg != NULL) + if (value > 8191 || value < -8192) *errmsg = _("offset not between -8192 and 8191"); - else if ((value & 3) != 0 && errmsg != NULL) + else if ((value & 3) != 0) *errmsg = _("offset not a multiple of 4"); return insn | ((value << 2) & 0xfff0); } @@ -1019,8 +1008,7 @@ insert_fxm (unsigned long insn, /* Any other value on mfcr is an error. */ else if ((insn & (0x3ff << 1)) == 19 << 1) { - if (errmsg != NULL) - *errmsg = _("ignoring invalid mfcr mask"); + *errmsg = _("ignoring invalid mfcr mask"); value = 0; } @@ -1038,14 +1026,11 @@ extract_fxm (unsigned long insn, if ((insn & (1 << 20)) != 0) { if ((dialect & PPC_OPCODE_POWER4) == 0) - { - if (invalid != NULL) - *invalid = 1; - } + *invalid = 1; else { /* Exactly one bit of MASK should be set. */ - if ((mask == 0 || (mask & -mask) != mask) && invalid != NULL) + if (mask == 0 || (mask & -mask) != mask) *invalid = 1; } } @@ -1053,7 +1038,7 @@ extract_fxm (unsigned long insn, /* Check that non-power4 form of mfcr has a zero MASK. */ else if ((insn & (0x3ff << 1)) == 19 << 1) { - if (mask != 0 && invalid != NULL) + if (mask != 0) *invalid = 1; } @@ -1070,7 +1055,7 @@ insert_li (unsigned long insn, int dialect ATTRIBUTE_UNUSED, const char **errmsg) { - if ((value & 3) != 0 && errmsg != NULL) + if ((value & 3) != 0) *errmsg = _("ignoring least significant bits in branch offset"); return insn | (value & 0x3fffffc); } @@ -1102,8 +1087,7 @@ insert_mbe (unsigned long insn, if (uval == 0) { - if (errmsg != NULL) - *errmsg = _("illegal bitmask"); + *errmsg = _("illegal bitmask"); return insn; } @@ -1138,10 +1122,7 @@ insert_mbe (unsigned long insn, me = 32; if (count != 2 && (count != 0 || ! last)) - { - if (errmsg != NULL) - *errmsg = _("illegal bitmask"); - } + *errmsg = _("illegal bitmask"); return insn | (mb << 6) | ((me - 1) << 1); } @@ -1155,8 +1136,7 @@ extract_mbe (unsigned long insn, int mb, me; int i; - if (invalid != NULL) - *invalid = 1; + *invalid = 1; mb = (insn >> 6) & 0x1f; me = (insn >> 1) & 0x1f; @@ -1167,12 +1147,12 @@ extract_mbe (unsigned long insn, ret |= 1 << (31 - i); } else if (mb == me + 1) - ret = -1; + ret = ~0; else /* (mb > me + 1) */ { ret = ~0; for (i = me + 1; i < mb; i++) - ret &= ~ (1 << (31 - i)); + ret &= ~(1 << (31 - i)); } return ret; } @@ -1249,8 +1229,7 @@ extract_nsi (unsigned long insn, int dialect ATTRIBUTE_UNUSED, int *invalid) { - if (invalid != NULL) - *invalid = 1; + *invalid = 1; return -(((insn & 0xffff) ^ 0x8000) - 0x8000); } @@ -1284,8 +1263,8 @@ insert_ram (unsigned long insn, return insn | ((value & 0x1f) << 16); } - /* The RA field in the DQ form lq instruction, which has special - value restrictions. */ +/* The RA field in the DQ form lq instruction, which has special + value restrictions. */ /*ARGSUSED*/ static unsigned long @@ -1296,7 +1275,7 @@ insert_raq (unsigned long insn, { long rtvalue = (insn & RT_MASK) >> 21; - if (value == rtvalue && errmsg != NULL) + if (value == rtvalue) *errmsg = _("source and target register operands must be different"); return insn | ((value & 0x1f) << 16); } @@ -1337,14 +1316,13 @@ extract_rbs (unsigned long insn, int dialect ATTRIBUTE_UNUSED, int *invalid) { - if (invalid != NULL - && ((insn >> 21) & 0x1f) != ((insn >> 11) & 0x1f)) + if (((insn >> 21) & 0x1f) != ((insn >> 11) & 0x1f)) *invalid = 1; return 0; } - /* The RT field of the DQ form lq instruction, which has special - value restrictions. */ +/* The RT field of the DQ form lq instruction, which has special + value restrictions. */ /*ARGSUSED*/ static unsigned long @@ -1353,13 +1331,13 @@ insert_rtq (unsigned long insn, int dialect ATTRIBUTE_UNUSED, const char **errmsg) { - if ((value & 1) != 0 && errmsg != NULL) + if ((value & 1) != 0) *errmsg = _("target register operand must be even"); return insn | ((value & 0x1f) << 21); } - /* The RS field of the DS form stq instruction, which has special - value restrictions. */ +/* The RS field of the DS form stq instruction, which has special + value restrictions. */ /*ARGSUSED*/ static unsigned long @@ -1368,7 +1346,7 @@ insert_rsq (unsigned long insn, int dialect ATTRIBUTE_UNUSED, const char **errmsg) { - if ((value & 1) != 0 && errmsg != NULL) + if ((value & 1) != 0) *errmsg = _("source register operand must be even"); return insn | ((value & 0x1f) << 21); } |