This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: ns32k fixes
Richard Henderson writes:
> On Tue, Jul 30, 2002 at 01:00:58PM +0930, Ian Dall wrote:
> > Presumably in the language of the standard, this invokes undefined
> > behaviour. But bear in mind that this is libgcc2 code which only ever
> > gets compiled by gcc and is only ever executed on this target, so it
> > seems OK to rely on features of both.
>
> The feature of gcc though, is that you'll lose here. Use
OK. For my education, what feature is that? Presumably some
optimization which wants to assume that an incompatible pointer cast
will never be dereferenced? I am having trouble seeing how the
compiler could use this (given the flow analysis should already keep track
of whether it is used or not).
> union u { float f; unsigned int i; } *t = (union u *)&x;
This works and produces code just as good as the original!
Here is the whole patch revised:
2002-07-29 Ian Dall <ian@sibyl.beware.dropbear.id.au>
* config/ns32k/ns32k.h (TARGET_IEEE_COMPARE): Correct earlier
patch.
(RETURN_ADDR_RTX): Cannot determine return address for FRAME > 0
when there is no frame pointer.
(INITIAL_FRAME_POINTER_OFFSET): Count stack space for saved fp
registers properly.
* config.gcc (ns32k-*-netbsd*): Add reference to new file,
ns32k/t-netbsd to define LIB2FUNCS_EXTRA
* config/ns32k/t-netbsd: New file
* config/ns32k/__unorddf2.c: New file
* config/ns32k/__unordsf2.c: New file
Index: config.gcc
===================================================================
RCS file: /usr/local/cvs-rep/gcc/gcc/config.gcc,v
retrieving revision 1.1.1.7
diff -c -3 -p -r1.1.1.7 config.gcc
*** config.gcc 31 Jul 2002 01:34:25 -0000 1.1.1.7
--- config.gcc 31 Jul 2002 01:50:39 -0000
*************** ns32k-*-netbsdelf*)
*** 1958,1964 ****
ns32k-*-netbsd*)
tm_file="${tm_file} netbsd.h netbsd-aout.h ns32k/netbsd.h"
# On NetBSD, the headers are already okay, except for math.h.
! tmake_file=t-netbsd
use_collect2=yes
;;
pdp11-*-bsd)
--- 1958,1964 ----
ns32k-*-netbsd*)
tm_file="${tm_file} netbsd.h netbsd-aout.h ns32k/netbsd.h"
# On NetBSD, the headers are already okay, except for math.h.
! tmake_file="t-netbsd ns32k/t-netbsd"
use_collect2=yes
;;
pdp11-*-bsd)
Index: longlong.h
===================================================================
RCS file: /usr/local/cvs-rep/gcc/gcc/longlong.h,v
retrieving revision 1.1.1.3
retrieving revision 1.3
diff -c -3 -p -r1.1.1.3 -r1.3
Index: config/ns32k/ns32k.h
===================================================================
RCS file: /usr/local/cvs-rep/gcc/gcc/config/ns32k/ns32k.h,v
retrieving revision 1.1.1.5
diff -c -3 -p -r1.1.1.5 ns32k.h
*** config/ns32k/ns32k.h 31 Jul 2002 01:36:49 -0000 1.1.1.5
--- config/ns32k/ns32k.h 31 Jul 2002 02:07:01 -0000
*************** extern int target_flags;
*** 129,135 ****
/* Compile using bitfield insns. */
#define TARGET_BITFIELD ((target_flags & MASK_NO_BITFIELD) == 0)
! #define TARGET_IEEE_FP (target_flags & MASK_IEEE_COMPARE)
/* Macro to define tables used to set the flags.
This is a list in braces of pairs in braces,
--- 129,135 ----
/* Compile using bitfield insns. */
#define TARGET_BITFIELD ((target_flags & MASK_NO_BITFIELD) == 0)
! #define TARGET_IEEE_COMPARE (target_flags & MASK_IEEE_COMPARE)
/* Macro to define tables used to set the flags.
This is a list in braces of pairs in braces,
*************** enum reg_class
*** 578,584 ****
After the prologue, RA is at 4(fp) in the current frame. */
#define RETURN_ADDR_RTX(COUNT, FRAME) \
! (gen_rtx (MEM, Pmode, gen_rtx (PLUS, Pmode, (FRAME), GEN_INT(4))))
/* A C expression whose value is an integer giving the offset, in
bytes, from the value of the stack pointer register to the top of
--- 578,585 ----
After the prologue, RA is at 4(fp) in the current frame. */
#define RETURN_ADDR_RTX(COUNT, FRAME) \
! ((COUNT> 0 && flag_omit_frame_pointer)? NULL_RTX \
! : gen_rtx (MEM, Pmode, gen_rtx (PLUS, Pmode, (FRAME), GEN_INT(4))))
/* A C expression whose value is an integer giving the offset, in
bytes, from the value of the stack pointer register to the top of
*************** enum reg_class
*** 743,754 ****
{ \
int regno; \
int offset = -4; \
! for (regno = 0; regno < L1_REGNUM; regno++) \
if (regs_ever_live[regno] && ! call_used_regs[regno]) \
offset += 4; \
- for (; regno < FRAME_POINTER_REGNUM; regno++) \
- if (regs_ever_live[regno] && ! call_used_regs[regno]) \
- offset += 8; \
if (flag_pic && current_function_uses_pic_offset_table) \
offset += 4; \
(DEPTH) = (offset + get_frame_size () \
--- 744,752 ----
{ \
int regno; \
int offset = -4; \
! for (regno = 0; regno < FRAME_POINTER_REGNUM; regno++) \
if (regs_ever_live[regno] && ! call_used_regs[regno]) \
offset += 4; \
if (flag_pic && current_function_uses_pic_offset_table) \
offset += 4; \
(DEPTH) = (offset + get_frame_size () \
*** /dev/null Fri Aug 31 06:00:55 2001
--- config/ns32k/__unorddf2.c Wed Jul 31 08:23:26 2002
***************
*** 0 ****
--- 1,34 ----
+ /* Lightweight function to test for ieee unordered comparison
+ Copyright (C) 2002
+ Free Software Foundation, Inc.
+ Contributed by Ian Dall <ian@beware.dropbear.id.au>
+
+ This file is part of GNU CC.
+
+ GNU CC is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU CC is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU CC; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+ # define ISNAN(x) ( \
+ { \
+ union u { double d; unsigned int i[2]; } *t = (union u *)&(x); \
+ ((t->i[1] & 0x7ff00000) == 0x7ff00000) && \
+ (t->i[0] != 0 || (t->i[1] & 0xfffff) != 0); \
+ })
+
+ int __unorddf2 (double, double);
+ int __unorddf2 (double a, double b)
+ {
+ return ISNAN(a) || ISNAN(b);
+ }
*** /dev/null Fri Aug 31 06:00:55 2001
--- config/ns32k/__unordsf2.c Wed Jul 31 08:20:40 2002
***************
*** 0 ****
--- 1,34 ----
+ /* Lightweight function to test for ieee unordered comparison
+ Copyright (C) 2002
+ Free Software Foundation, Inc.
+ Contributed by Ian Dall <ian@beware.dropbear.id.au>
+
+ This file is part of GNU CC.
+
+ GNU CC is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU CC is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU CC; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+ # define ISNAN(x) ( \
+ { \
+ union u { float f; unsigned int i; } *t = (union u *)&(x); \
+ ((t->i & 0x7f800000) == 0x7f800000) && \
+ ((t->i & 0x7fffff) != 0); \
+ })
+
+ int __unordsf2 ( float, float);
+ int __unordsf2 ( float a, float b)
+ {
+ return ISNAN(a) || ISNAN(b);
+ }
*** /dev/null Fri Aug 31 06:00:55 2001
--- config/ns32k/t-netbsd Fri Jul 19 00:03:05 2002
***************
*** 0 ****
--- 1,4 ----
+ # We want fine grained libraries, so use the new code to build the
+ # floating point emulation libraries.
+ LIB2FUNCS_EXTRA = $(srcdir)/config/ns32k/__unorddf2.c \
+ $(srcdir)/config/ns32k/__unordsf2.c