* 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.
This commit is contained in:
Alan Modra 2003-07-07 01:34:04 +00:00
parent 503e66900f
commit 8427c42425
3 changed files with 79 additions and 93 deletions

View file

@ -1,3 +1,10 @@
2003-07-07 Alan Modra <amodra@bigpond.net.au>
* 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.
2003-07-04 Alan Modra <amodra@bigpond.net.au> 2003-07-04 Alan Modra <amodra@bigpond.net.au>
* ppc-opc.c: Convert to C90, removing unnecessary prototypes and * ppc-opc.c: Convert to C90, removing unnecessary prototypes and

View file

@ -1,5 +1,6 @@
/* ppc-dis.c -- Disassemble PowerPC instructions /* ppc-dis.c -- Disassemble PowerPC instructions
Copyright 1994, 1995, 2000, 2001, 2002 Free Software Foundation, Inc. Copyright 1994, 1995, 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support Written by Ian Lance Taylor, Cygnus Support
This file is part of GDB, GAS, and the GNU binutils. This file is part of GDB, GAS, and the GNU binutils.
@ -214,7 +215,7 @@ print_insn_powerpc (memaddr, info, bigendian, dialect)
/* Extract the value from the instruction. */ /* Extract the value from the instruction. */
if (operand->extract) if (operand->extract)
value = (*operand->extract) (insn, dialect, (int *) NULL); value = (*operand->extract) (insn, dialect, &invalid);
else else
{ {
value = (insn >> operand->shift) & ((1 << operand->bits) - 1); value = (insn >> operand->shift) & ((1 << operand->bits) - 1);

View file

@ -563,8 +563,7 @@ extract_bat (unsigned long insn,
int dialect ATTRIBUTE_UNUSED, int dialect ATTRIBUTE_UNUSED,
int *invalid) int *invalid)
{ {
if (invalid != NULL if (((insn >> 21) & 0x1f) != ((insn >> 16) & 0x1f))
&& ((insn >> 21) & 0x1f) != ((insn >> 16) & 0x1f))
*invalid = 1; *invalid = 1;
return 0; return 0;
} }
@ -590,8 +589,7 @@ extract_bba (unsigned long insn,
int dialect ATTRIBUTE_UNUSED, int dialect ATTRIBUTE_UNUSED,
int *invalid) int *invalid)
{ {
if (invalid != NULL if (((insn >> 16) & 0x1f) != ((insn >> 11) & 0x1f))
&& ((insn >> 16) & 0x1f) != ((insn >> 11) & 0x1f))
*invalid = 1; *invalid = 1;
return 0; return 0;
} }
@ -657,8 +655,6 @@ static long
extract_bdm (unsigned long insn, extract_bdm (unsigned long insn,
int dialect, int dialect,
int *invalid) int *invalid)
{
if (invalid != NULL)
{ {
if ((dialect & PPC_OPCODE_POWER4) == 0) if ((dialect & PPC_OPCODE_POWER4) == 0)
{ {
@ -671,7 +667,7 @@ extract_bdm (unsigned long insn,
&& (insn & (0x1d << 21)) != (0x18 << 21)) && (insn & (0x1d << 21)) != (0x18 << 21))
*invalid = 1; *invalid = 1;
} }
}
return ((insn & 0xfffc) ^ 0x8000) - 0x8000; return ((insn & 0xfffc) ^ 0x8000) - 0x8000;
} }
@ -705,8 +701,6 @@ static long
extract_bdp (unsigned long insn, extract_bdp (unsigned long insn,
int dialect, int dialect,
int *invalid) int *invalid)
{
if (invalid != NULL)
{ {
if ((dialect & PPC_OPCODE_POWER4) == 0) if ((dialect & PPC_OPCODE_POWER4) == 0)
{ {
@ -719,7 +713,7 @@ extract_bdp (unsigned long insn,
&& (insn & (0x1d << 21)) != (0x19 << 21)) && (insn & (0x1d << 21)) != (0x19 << 21))
*invalid = 1; *invalid = 1;
} }
}
return ((insn & 0xfffc) ^ 0x8000) - 0x8000; return ((insn & 0xfffc) ^ 0x8000) - 0x8000;
} }
@ -783,8 +777,7 @@ insert_bo (unsigned long insn,
int dialect, int dialect,
const char **errmsg) const char **errmsg)
{ {
if (errmsg != NULL if (!valid_bo (value, dialect))
&& ! valid_bo (value, dialect))
*errmsg = _("invalid conditional option"); *errmsg = _("invalid conditional option");
return insn | ((value & 0x1f) << 21); return insn | ((value & 0x1f) << 21);
} }
@ -797,8 +790,7 @@ extract_bo (unsigned long insn,
long value; long value;
value = (insn >> 21) & 0x1f; value = (insn >> 21) & 0x1f;
if (invalid != NULL if (!valid_bo (value, dialect))
&& ! valid_bo (value, dialect))
*invalid = 1; *invalid = 1;
return value; return value;
} }
@ -812,14 +804,12 @@ insert_boe (unsigned long insn,
long value, long value,
int dialect, int dialect,
const char **errmsg) const char **errmsg)
{
if (errmsg != NULL)
{ {
if (!valid_bo (value, dialect)) if (!valid_bo (value, dialect))
*errmsg = _("invalid conditional option"); *errmsg = _("invalid conditional option");
else if ((value & 1) != 0) else if ((value & 1) != 0)
*errmsg = _("attempt to set y bit when using + or - modifier"); *errmsg = _("attempt to set y bit when using + or - modifier");
}
return insn | ((value & 0x1f) << 21); return insn | ((value & 0x1f) << 21);
} }
@ -831,8 +821,7 @@ extract_boe (unsigned long insn,
long value; long value;
value = (insn >> 21) & 0x1f; value = (insn >> 21) & 0x1f;
if (invalid != NULL if (!valid_bo (value, dialect))
&& ! valid_bo (value, dialect))
*invalid = 1; *invalid = 1;
return value & 0x1e; return value & 0x1e;
} }
@ -845,9 +834,9 @@ static unsigned long
insert_dq (unsigned long insn, insert_dq (unsigned long insn,
long value, long value,
int dialect ATTRIBUTE_UNUSED, 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"); *errmsg = _("offset not a multiple of 16");
return insn | (value & 0xfff0); return insn | (value & 0xfff0);
} }
@ -865,11 +854,11 @@ static unsigned long
insert_ev2 (unsigned long insn, insert_ev2 (unsigned long insn,
long value, long value,
int dialect ATTRIBUTE_UNUSED, 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"); *errmsg = _("offset not a multiple of 2");
if ((value > 62) != 0 && errmsg != NULL) if ((value > 62) != 0)
*errmsg = _("offset greater than 62"); *errmsg = _("offset greater than 62");
return insn | ((value & 0x3e) << 10); return insn | ((value & 0x3e) << 10);
} }
@ -886,11 +875,11 @@ static unsigned long
insert_ev4 (unsigned long insn, insert_ev4 (unsigned long insn,
long value, long value,
int dialect ATTRIBUTE_UNUSED, 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"); *errmsg = _("offset not a multiple of 4");
if ((value > 124) != 0 && errmsg != NULL) if ((value > 124) != 0)
*errmsg = _("offset greater than 124"); *errmsg = _("offset greater than 124");
return insn | ((value & 0x7c) << 9); return insn | ((value & 0x7c) << 9);
} }
@ -907,11 +896,11 @@ static unsigned long
insert_ev8 (unsigned long insn, insert_ev8 (unsigned long insn,
long value, long value,
int dialect ATTRIBUTE_UNUSED, 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"); *errmsg = _("offset not a multiple of 8");
if ((value > 248) != 0 && errmsg != NULL) if ((value > 248) != 0)
*errmsg = _("offset greater than 248"); *errmsg = _("offset greater than 248");
return insn | ((value & 0xf8) << 8); return insn | ((value & 0xf8) << 8);
} }
@ -934,7 +923,7 @@ insert_ds (unsigned long insn,
int dialect ATTRIBUTE_UNUSED, int dialect ATTRIBUTE_UNUSED,
const char **errmsg) const char **errmsg)
{ {
if ((value & 3) != 0 && errmsg != NULL) if ((value & 3) != 0)
*errmsg = _("offset not a multiple of 4"); *errmsg = _("offset not a multiple of 4");
return insn | (value & 0xfffc); return insn | (value & 0xfffc);
} }
@ -957,7 +946,7 @@ insert_de (unsigned long insn,
int dialect ATTRIBUTE_UNUSED, int dialect ATTRIBUTE_UNUSED,
const char **errmsg) const char **errmsg)
{ {
if ((value > 2047 || value < -2048) && errmsg != NULL) if (value > 2047 || value < -2048)
*errmsg = _("offset not between -2048 and 2047"); *errmsg = _("offset not between -2048 and 2047");
return insn | ((value << 4) & 0xfff0); return insn | ((value << 4) & 0xfff0);
} }
@ -980,9 +969,9 @@ insert_des (unsigned long insn,
int dialect ATTRIBUTE_UNUSED, int dialect ATTRIBUTE_UNUSED,
const char **errmsg) const char **errmsg)
{ {
if ((value > 8191 || value < -8192) && errmsg != NULL) if (value > 8191 || value < -8192)
*errmsg = _("offset not between -8192 and 8191"); *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"); *errmsg = _("offset not a multiple of 4");
return insn | ((value << 2) & 0xfff0); return insn | ((value << 2) & 0xfff0);
} }
@ -1019,7 +1008,6 @@ insert_fxm (unsigned long insn,
/* Any other value on mfcr is an error. */ /* Any other value on mfcr is an error. */
else if ((insn & (0x3ff << 1)) == 19 << 1) else if ((insn & (0x3ff << 1)) == 19 << 1)
{ {
if (errmsg != NULL)
*errmsg = _("ignoring invalid mfcr mask"); *errmsg = _("ignoring invalid mfcr mask");
value = 0; value = 0;
} }
@ -1038,14 +1026,11 @@ extract_fxm (unsigned long insn,
if ((insn & (1 << 20)) != 0) if ((insn & (1 << 20)) != 0)
{ {
if ((dialect & PPC_OPCODE_POWER4) == 0) if ((dialect & PPC_OPCODE_POWER4) == 0)
{
if (invalid != NULL)
*invalid = 1; *invalid = 1;
}
else else
{ {
/* Exactly one bit of MASK should be set. */ /* Exactly one bit of MASK should be set. */
if ((mask == 0 || (mask & -mask) != mask) && invalid != NULL) if (mask == 0 || (mask & -mask) != mask)
*invalid = 1; *invalid = 1;
} }
} }
@ -1053,7 +1038,7 @@ extract_fxm (unsigned long insn,
/* Check that non-power4 form of mfcr has a zero MASK. */ /* Check that non-power4 form of mfcr has a zero MASK. */
else if ((insn & (0x3ff << 1)) == 19 << 1) else if ((insn & (0x3ff << 1)) == 19 << 1)
{ {
if (mask != 0 && invalid != NULL) if (mask != 0)
*invalid = 1; *invalid = 1;
} }
@ -1070,7 +1055,7 @@ insert_li (unsigned long insn,
int dialect ATTRIBUTE_UNUSED, int dialect ATTRIBUTE_UNUSED,
const char **errmsg) const char **errmsg)
{ {
if ((value & 3) != 0 && errmsg != NULL) if ((value & 3) != 0)
*errmsg = _("ignoring least significant bits in branch offset"); *errmsg = _("ignoring least significant bits in branch offset");
return insn | (value & 0x3fffffc); return insn | (value & 0x3fffffc);
} }
@ -1102,7 +1087,6 @@ insert_mbe (unsigned long insn,
if (uval == 0) if (uval == 0)
{ {
if (errmsg != NULL)
*errmsg = _("illegal bitmask"); *errmsg = _("illegal bitmask");
return insn; return insn;
} }
@ -1138,10 +1122,7 @@ insert_mbe (unsigned long insn,
me = 32; me = 32;
if (count != 2 && (count != 0 || ! last)) if (count != 2 && (count != 0 || ! last))
{
if (errmsg != NULL)
*errmsg = _("illegal bitmask"); *errmsg = _("illegal bitmask");
}
return insn | (mb << 6) | ((me - 1) << 1); return insn | (mb << 6) | ((me - 1) << 1);
} }
@ -1155,7 +1136,6 @@ extract_mbe (unsigned long insn,
int mb, me; int mb, me;
int i; int i;
if (invalid != NULL)
*invalid = 1; *invalid = 1;
mb = (insn >> 6) & 0x1f; mb = (insn >> 6) & 0x1f;
@ -1167,7 +1147,7 @@ extract_mbe (unsigned long insn,
ret |= 1 << (31 - i); ret |= 1 << (31 - i);
} }
else if (mb == me + 1) else if (mb == me + 1)
ret = -1; ret = ~0;
else /* (mb > me + 1) */ else /* (mb > me + 1) */
{ {
ret = ~0; ret = ~0;
@ -1249,7 +1229,6 @@ extract_nsi (unsigned long insn,
int dialect ATTRIBUTE_UNUSED, int dialect ATTRIBUTE_UNUSED,
int *invalid) int *invalid)
{ {
if (invalid != NULL)
*invalid = 1; *invalid = 1;
return -(((insn & 0xffff) ^ 0x8000) - 0x8000); return -(((insn & 0xffff) ^ 0x8000) - 0x8000);
} }
@ -1296,7 +1275,7 @@ insert_raq (unsigned long insn,
{ {
long rtvalue = (insn & RT_MASK) >> 21; long rtvalue = (insn & RT_MASK) >> 21;
if (value == rtvalue && errmsg != NULL) if (value == rtvalue)
*errmsg = _("source and target register operands must be different"); *errmsg = _("source and target register operands must be different");
return insn | ((value & 0x1f) << 16); return insn | ((value & 0x1f) << 16);
} }
@ -1337,8 +1316,7 @@ extract_rbs (unsigned long insn,
int dialect ATTRIBUTE_UNUSED, int dialect ATTRIBUTE_UNUSED,
int *invalid) int *invalid)
{ {
if (invalid != NULL if (((insn >> 21) & 0x1f) != ((insn >> 11) & 0x1f))
&& ((insn >> 21) & 0x1f) != ((insn >> 11) & 0x1f))
*invalid = 1; *invalid = 1;
return 0; return 0;
} }
@ -1353,7 +1331,7 @@ insert_rtq (unsigned long insn,
int dialect ATTRIBUTE_UNUSED, int dialect ATTRIBUTE_UNUSED,
const char **errmsg) const char **errmsg)
{ {
if ((value & 1) != 0 && errmsg != NULL) if ((value & 1) != 0)
*errmsg = _("target register operand must be even"); *errmsg = _("target register operand must be even");
return insn | ((value & 0x1f) << 21); return insn | ((value & 0x1f) << 21);
} }
@ -1368,7 +1346,7 @@ insert_rsq (unsigned long insn,
int dialect ATTRIBUTE_UNUSED, int dialect ATTRIBUTE_UNUSED,
const char **errmsg) const char **errmsg)
{ {
if ((value & 1) != 0 && errmsg != NULL) if ((value & 1) != 0)
*errmsg = _("source register operand must be even"); *errmsg = _("source register operand must be even");
return insn | ((value & 0x1f) << 21); return insn | ((value & 0x1f) << 21);
} }