From: Jan-Benedict G. <jb...@us...> - 2005-09-26 22:37:56
|
Update of /cvsroot/linux-vax/toolchain/patches In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16265 Added Files: gcc-000006-urem-udiv.patch Log Message: - Add __udivsi3 and umodsi3. For now, use slow (but working) C versions, but there's also a start for assembler versions. --- NEW FILE: gcc-000006-urem-udiv.patch --- diff -Nurp src-gcc-fresh/gcc/config/vax/lib1funcs.S src-gcc-hacked/gcc/config/vax/lib1funcs.S --- src-gcc-fresh/gcc/config/vax/lib1funcs.S 1970-01-01 01:00:00.000000000 +0100 +++ src-gcc-hacked/gcc/config/vax/lib1funcs.S 2005-09-26 23:44:43.000000000 +0200 @@ -0,0 +1,86 @@ +/* + * Assembly functions for the VAX version of libgcc1. + * Copyright (C) 2005 Free Software Foundation, Inc. + * Contributed by Jan-Benedict Glaw <jb...@lu...>. + * + * This file is part of GCC. + * + * GCC 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. + * + * In addition to the permissions in the GNU General Public License, the + * Free Software Foundation gives you unlimited permission to link the + * compiled version of this file into combinations with other programs, + * and to distribute those combinations without any restriction coming + * from the use of this file. (The General Public License restrictions + * do apply in other respects; for example, they cover modification of + * the file, and distribution when not linked into a combine + * executable.) + * + * GCC 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 GCC; see the file COPYING. If not, write to the Free + * Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#ifdef L_udivsi3 +#define DIVISOR 8(%ap) +#define DIVIDENT 4(%ap) + .align 4 + .global __udivsi3 + .type __udivsi3, @function +__udivsi3: + .word 0x0004 + movl DIVISOR, %r2 + jlss JustCompare + movl DIVIDENT, %r0 + jlss RealHardDivide + +SimpleDivide: + divl2 %r2, %r0 + j Return + +RealHardDivide: + clrl %r1 + ediv %r2, %r0, %r0, %r1 + j Return + +JustCompare: + cmpl DIVIDEND, %r2 + jgequ ItIsOne + +ItIsntOne: + clrl %r0 + j Return + +ItIsOne: + movl $1, %r0 + j Return + +Return: + ret + .size __udivsi3, . - __udivsi3 +#undef DIVISOR +#undef DIVIDENT +#endif /* L_udivsi3 */ + + +#ifdef L_umodsi3 +#define DIVISOR 8(%ap) +#define DIVIDENT 4(%ap) + .align 4 + .global __umodsi3 + .type __umodsi3, @function +__umodsi3: + .word 0x0004 + + .size __umodsi3, . - __umodsi3 +#endif /* L_umodsi3 */ + diff -Nurp src-gcc-fresh/gcc/config/vax/linux.h src-gcc-hacked/gcc/config/vax/linux.h --- src-gcc-fresh/gcc/config/vax/linux.h 2005-09-25 14:04:59.000000000 +0200 +++ src-gcc-hacked/gcc/config/vax/linux.h 2005-09-25 14:21:35.000000000 +0200 @@ -28,4 +28,8 @@ * the ELF binary format. */ +#ifdef HAVE___UDIV___UREM_IN_LIBC +#undef HAVE___UDIV___UREM_IN_LIBC +#endif + #endif /* _CONFIG_VAX_LINUX_H */ diff -Nurp src-gcc-fresh/gcc/config/vax/netbsd.h src-gcc-hacked/gcc/config/vax/netbsd.h --- src-gcc-fresh/gcc/config/vax/netbsd.h 2005-06-26 15:39:59.000000000 +0200 +++ src-gcc-hacked/gcc/config/vax/netbsd.h 2005-09-25 14:22:26.000000000 +0200 @@ -46,3 +46,7 @@ Boston, MA 02110-1301, USA. */ /* We use gas, not the UNIX assembler. */ #undef TARGET_DEFAULT #define TARGET_DEFAULT 0 + +/* BSDs do have __udev and __urem in libc. */ +#define HAVE___UDIV___UREM_IN_LIBC + diff -Nurp src-gcc-fresh/gcc/config/vax/openbsd1.h src-gcc-hacked/gcc/config/vax/openbsd1.h --- src-gcc-fresh/gcc/config/vax/openbsd1.h 2005-06-26 15:39:59.000000000 +0200 +++ src-gcc-hacked/gcc/config/vax/openbsd1.h 2005-09-26 22:10:57.000000000 +0200 @@ -19,5 +19,9 @@ the Free Software Foundation, 51 Frankli Boston, MA 02110-1301, USA. */ /* Set up definitions before picking up the common openbsd.h file. */ -#define OBSD_OLD_GAS +#define OBSD_OLD_GAS #define OBSD_NO_DYNAMIC_LIBRARIES + +/* BSDs do have __udiv and __urem in libc. */ +#define HAVE___UDIV___UREM_IN_LIBC + diff -Nurp src-gcc-fresh/gcc/config/vax/openbsd.h src-gcc-hacked/gcc/config/vax/openbsd.h --- src-gcc-fresh/gcc/config/vax/openbsd.h 2005-06-26 15:39:59.000000000 +0200 +++ src-gcc-hacked/gcc/config/vax/openbsd.h 2005-09-25 14:22:52.000000000 +0200 @@ -44,3 +44,7 @@ Boston, MA 02110-1301, USA. */ #undef WCHAR_TYPE_SIZE #define WCHAR_TYPE_SIZE 32 + +/* BSDs do have __udiv and __urem in libc. */ +#define HAVE___UDIV___UREM_IN_LIBC + diff -Nurp src-gcc-fresh/gcc/config/vax/t-vax src-gcc-hacked/gcc/config/vax/t-vax --- src-gcc-fresh/gcc/config/vax/t-vax 1970-01-01 01:00:00.000000000 +0100 +++ src-gcc-hacked/gcc/config/vax/t-vax 2005-09-26 23:54:16.000000000 +0200 @@ -0,0 +1,4 @@ +# LIB1ASMSRC = vax/lib1funcs.S +# LIB1ASMFUNCS = _udivsi3 _uremsi3 +# LIB1ASMSRC = $(srcdir)/config/udivmod.c $(srcdir)/config/udivmodsi4.c +LIB2FUNCS_EXTRA = $(srcdir)/config/udivmod.c $(srcdir)/config/udivmodsi4.c diff -Nurp src-gcc-fresh/gcc/config/vax/vax.c src-gcc-hacked/gcc/config/vax/vax.c --- src-gcc-fresh/gcc/config/vax/vax.c 2005-09-25 14:07:22.000000000 +0200 +++ src-gcc-hacked/gcc/config/vax/vax.c 2005-09-26 20:27:06.000000000 +0200 @@ -46,13 +46,15 @@ Boston, MA 02110-1301, USA. */ static void vax_output_function_prologue (FILE *, HOST_WIDE_INT); static void vax_file_start (void); -static void vax_init_libfuncs (void); static void vax_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT, tree); static int vax_address_cost_1 (rtx); static int vax_address_cost (rtx); static bool vax_rtx_costs (rtx, int, int, int *); static rtx vax_struct_value_rtx (tree, int); +#ifdef HAVE___UDIV___UREM_IN_LIBC +static void vax_init_libfuncs (void); +#endif /* Initialize the GCC target structure. */ #undef TARGET_ASM_ALIGNED_HI_OP @@ -66,8 +68,10 @@ static rtx vax_struct_value_rtx (tree, i #undef TARGET_ASM_FILE_START_APP_OFF #define TARGET_ASM_FILE_START_APP_OFF true +#ifdef HAVE___UDIV___UREM_IN_LIBC #undef TARGET_INIT_LIBFUNCS #define TARGET_INIT_LIBFUNCS vax_init_libfuncs +#endif #undef TARGET_ASM_OUTPUT_MI_THUNK #define TARGET_ASM_OUTPUT_MI_THUNK vax_output_mi_thunk @@ -162,6 +166,7 @@ vax_file_start (void) fprintf (asm_out_file, "___vax_%c_doubles:\n", ASM_DOUBLE_CHAR); } +#ifdef HAVE___UDIV___UREM_IN_LIBC /* We can use the BSD C library routines for the libgcc calls that are still generated, since that's what they boil down to anyways. When ELF, avoid the user's namespace. */ @@ -172,6 +177,7 @@ vax_init_libfuncs (void) set_optab_libfunc (udiv_optab, SImode, TARGET_ELF ? "*__udiv" : "*udiv"); set_optab_libfunc (umod_optab, SImode, TARGET_ELF ? "*__urem" : "*urem"); } +#endif /* HAVE___UDIV___UREM_IN_LIBC */ /* This is like nonimmediate_operand with a restriction on the type of MEM. */ diff -Nurp src-gcc-fresh/gcc/config.gcc src-gcc-hacked/gcc/config.gcc --- src-gcc-fresh/gcc/config.gcc 2005-09-25 14:04:59.000000000 +0200 +++ src-gcc-hacked/gcc/config.gcc 2005-09-25 14:27:09.000000000 +0200 @@ -2239,9 +2239,11 @@ vax-*-sysv*) # VAXen running system V ;; vax-*-linux-uclibc*) # VAXen running Linux ELF with uClibc tm_file="${tm_file} elfos.h linux.h vax/elf.h vax/uclinux.h" + tmake_file="vax/t-vax" ;; vax-*-linux*) # VAXen running Linux ELF with GNU libc tm_file="${tm_file} elfos.h linux.h vax/elf.h vax/linux.h" + tmake_file="vax/t-vax" ;; vax-*-netbsdelf*) tm_file="${tm_file} elfos.h netbsd.h netbsd-elf.h vax/elf.h vax/netbsd-elf.h" |