This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
ppc 64-bit clean-up
- To: binutils at sources dot redhat dot com
- Subject: ppc 64-bit clean-up
- From: Alexandre Oliva <aoliva at redhat dot com>
- Date: 30 Mar 2001 04:35:51 -0300
- Organization: GCC Team, Red Hat
A cross-assembler to ppc on a host with 64-bit longs fails to
assemble:
rlwinm 22,22,28,0xf0000000
because the signed int (1 << 31) is sign-extended to long, resulting
in an incorrect bit pattern. Even worse: if `int's were 16-bits wide,
this would invoke undefined behavior.
This patch fixes it, casting the 1 to long, as done in other nearby
constructs. I'm checking this in as obviously correct.
Index: opcodes/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* ppc-opc.c (insert_mbe): Shift mask initializer as long.
Index: opcodes/ppc-opc.c
===================================================================
RCS file: /cvs/src/src/opcodes/ppc-opc.c,v
retrieving revision 1.10
diff -u -p -r1.10 ppc-opc.c
--- opcodes/ppc-opc.c 2001/03/13 22:58:37 1.10
+++ opcodes/ppc-opc.c 2001/03/30 07:15:56
@@ -756,7 +756,7 @@ insert_mbe (insn, value, errmsg)
/* me: location of last 1->0 transition */
/* count: # transitions */
- for (mx = 0, mask = 1 << 31; mx < 32; ++mx, mask >>= 1)
+ for (mx = 0, mask = (long) 1 << 31; mx < 32; ++mx, mask >>= 1)
{
if ((uval & mask) && !last)
{
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me