This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: gas/config/tc-alpha.c


On Tue, May 16, 2000 at 10:30:13AM +1000, Alan Modra wrote:
> On Mon, 15 May 2000, Michael Meissner wrote:
> 
> > On Sun, May 14, 2000 at 09:42:15PM +1000, Alan Modra wrote:
> > > Is there any real reason to prefer the dangerous first form of these
> > > macros?
> > > 
> > > extract from tc-alpha.c:
> > > 
> > > /* Macros for sign extending from 16- and 32-bits.  */
> > > /* XXX: The cast macros will work on all the systems that I care about,
> > >    but really a predicate should be found to use the non-cast forms.  */
> > > 
> > > #if 1
> > > #define sign_extend_16(x)	((short)(x))
> > > #define sign_extend_32(x)	((int)(x))
> > > #else
> > > #define sign_extend_16(x)	((offsetT)(((x) & 0xFFFF) ^ 0x8000) - 0x8000)
> > > #define sign_extend_32(x)	((offsetT)(((x) & 0xFFFFFFFF) \
> > > 					   ^ 0x80000000) - 0x80000000)
> > > #endif
> > 
> > If you are worried about micro-optimizations, the first form is faster than the
> > second on some platforms (in particular, if your machine does not support
> > and/xor/sub of the constants in place, GCC will not re-optimize the expression
> > into an appropriate sign extension).
> 
> Sure.  That's why I said "any real reason" rather than "any reason".  :-)
> 
> I guess it doesn't matter a great deal as binutils is riddled with this
> sort of assumption about sizes of integral types.  I did have some idea of
> attacking the problem, but it seems a whole lot of work for little
> immediate benefit.

Or include limits.h (presumably also checking if limits.h exists via autoconf),
and base the #if on whether you have 8 bit bytes and 16 bit longs, which would
be the portable way of doing it.

-- 
Michael Meissner, Cygnus Solutions, a Red Hat company.
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work:	  meissner@redhat.com		phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org	fax:   +1 978-692-4482

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]