This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch to remove TARGET_MEM_FUNCTIONS
- From: "Joseph S. Myers" <jsm at polyomino dot org dot uk>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 5 Jul 2004 18:59:28 +0000 (UTC)
- Subject: Patch to remove TARGET_MEM_FUNCTIONS
This patch gets rid of TARGET_MEM_FUNCTIONS, putting the mem*
functions (cut down from the libiberty versions) in libgcc for the
pdp11 and vax targets that need them. (Andrew Pinski confirmed
<http://gcc.gnu.org/ml/gcc/2004-07/msg00177.html> that x86-darwin
doesn't need it, and m68k-aout and m68k-coff may not correspond to a
particular libc but I don't think FSF GCC now needs to be concerned
with their use with very old BSD libc. In fact, the pdp11 and vax
targets may not need all the functions - for example, 2.11BSD only
needs memmove to be provided, and has the others - but I don't have
access to them all the check. If users of those systems don't like
the trivial C versions of the functions, they can of course contribute
optimized assembler ones.) __gcc_bcmp remains in libgcc for
compatibility with old GCC-compiled object files on the few systems
that didn't define TARGET_MEM_FUNCTIONS.
Bootstrapped with no regressions on i686-pc-linux-gnu. OK to commit?
2004-07-05 Joseph S. Myers <jsm@polyomino.org.uk>
* c-decl.c, config/m32r/m32r.c, expr.c, optabs.c: Don't check
TARGET_MEM_FUNCTIONS.
* system.h: Poison TARGET_MEM_FUNCTIONS.
* libfuncs.h (LTI_bcopy, LTI_bcmp, LTI_bzero, bcopy_libfunc,
bcmp_libfunc, bzero_libfunc): Remove.
* optabs.c (init_obtabs): Don't set bcopy_libfunc, bcmp_libfunc or
bzero_libfunc.
* doc/tm.texi (TARGET_MEM_FUNCTIONS): Remove.
* doc/standards.texi: Don't mention calling BSD string functions.
* doc/invoke.texi: Likewise. Mention that memmove may be called.
* config/vax/t-memfuncs: New.
* config/memcmp.c, config/memcpy.c, config/memmove.c,
config/memset.c: New.
* config/pdp11/t-pdp11 (LIB2FUNCS_EXTRA): Use these files.
* config.gcc (vax-*-bsd*, vax-*-sysv*, vax-*-ultrix*): Use
vax/t-memfuncs.
* config/alpha/alpha.h, config/arc/arc.h, config/arm/arm.h,
config/avr/avr.h, config/c4x/c4x.h, config/cris/aout.h,
config/elfos.h, config/gnu.h, config/h8300/h8300.h,
config/i386/gas.h, config/ia64/ia64.h, config/interix.h,
config/ip2k/ip2k.h, config/lynx-ng.h, config/m32r/m32r.h,
config/mcore/mcore.h, config/mips/mips.h, config/mmix/mmix.h,
config/netbsd.h, config/openbsd.h, config/pa/pa.h,
config/rs6000/rs6000.h, config/rtems.h, config/s390/s390.h,
config/sh/sh.h, config/sparc/sparc.h, config/stormy16/stormy16.h,
config/svr3.h: Don't define TARGET_MEM_FUNCTIONS.
--
Joseph S. Myers http://www.srcf.ucam.org/~jsm28/gcc/
jsm@polyomino.org.uk (personal mail)
jsm28@gcc.gnu.org (Bugzilla assignments and CCs)
diff -rupN GCC.orig/gcc/c-decl.c GCC/gcc/c-decl.c
--- GCC.orig/gcc/c-decl.c 2004-07-03 11:45:11.000000000 +0000
+++ GCC/gcc/c-decl.c 2004-07-04 22:59:12.000000000 +0000
@@ -2944,17 +2944,10 @@ finish_decl (tree decl, tree init, tree
tree builtin = built_in_decls [DECL_FUNCTION_CODE (decl)];
SET_DECL_RTL (builtin, NULL_RTX);
change_decl_assembler_name (builtin, get_identifier (starred));
-#ifdef TARGET_MEM_FUNCTIONS
if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMCPY)
init_block_move_fn (starred);
else if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMSET)
init_block_clear_fn (starred);
-#else
- if (DECL_FUNCTION_CODE (decl) == BUILT_IN_BCOPY)
- init_block_move_fn (starred);
- else if (DECL_FUNCTION_CODE (decl) == BUILT_IN_BZERO)
- init_block_clear_fn (starred);
-#endif
}
SET_DECL_RTL (decl, NULL_RTX);
change_decl_assembler_name (decl, get_identifier (starred));
diff -rupN GCC.orig/gcc/config/alpha/alpha.h GCC/gcc/config/alpha/alpha.h
--- GCC.orig/gcc/config/alpha/alpha.h 2004-06-12 08:54:40.000000000 +0000
+++ GCC/gcc/config/alpha/alpha.h 2004-07-04 23:12:08.000000000 +0000
@@ -1835,6 +1835,3 @@ do { \
/* The system headers under Alpha systems are generally C++-aware. */
#define NO_IMPLICIT_EXTERN_C
-
-/* Generate calls to memcpy, etc., not bcopy, etc. */
-#define TARGET_MEM_FUNCTIONS 1
diff -rupN GCC.orig/gcc/config/arc/arc.h GCC/gcc/config/arc/arc.h
--- GCC.orig/gcc/config/arc/arc.h 2004-05-21 22:19:33.000000000 +0000
+++ GCC/gcc/config/arc/arc.h 2004-07-04 23:12:18.000000000 +0000
@@ -802,11 +802,6 @@ do { \
emit_insn (gen_flush_icache (validize_mem (gen_rtx_MEM (SImode, TRAMP)))); \
} while (0)
-/* Library calls. */
-
-/* Generate calls to memcpy, memcmp and memset. */
-#define TARGET_MEM_FUNCTIONS
-
/* Addressing modes, and classification of registers for them. */
/* Maximum number of registers that can appear in a valid memory address. */
diff -rupN GCC.orig/gcc/config/arm/arm.h GCC/gcc/config/arm/arm.h
--- GCC.orig/gcc/config/arm/arm.h 2004-06-27 18:47:51.000000000 +0000
+++ GCC/gcc/config/arm/arm.h 2004-07-04 23:12:52.000000000 +0000
@@ -536,9 +536,6 @@ extern int arm_is_6_or_7;
that is controlled by the APCS-FRAME option. */
#define CAN_DEBUG_WITHOUT_FP
-#undef TARGET_MEM_FUNCTIONS
-#define TARGET_MEM_FUNCTIONS 1
-
#define OVERRIDE_OPTIONS arm_override_options ()
/* Nonzero if PIC code requires explicit qualifiers to generate
diff -rupN GCC.orig/gcc/config/avr/avr.h GCC/gcc/config/avr/avr.h
--- GCC.orig/gcc/config/avr/avr.h 2004-05-25 10:47:15.000000000 +0000
+++ GCC/gcc/config/avr/avr.h 2004-07-04 23:13:01.000000000 +0000
@@ -803,8 +803,6 @@ extern int avr_case_values_threshold;
#define ADJUST_INSN_LENGTH(INSN, LENGTH) (LENGTH =\
adjust_insn_length (INSN, LENGTH))
-#define TARGET_MEM_FUNCTIONS
-
#define CPP_SPEC "%{posix:-D_POSIX_SOURCE}"
#define CC1_SPEC "%{profile:-p}"
diff -rupN GCC.orig/gcc/config/c4x/c4x.h GCC/gcc/config/c4x/c4x.h
--- GCC.orig/gcc/config/c4x/c4x.h 2004-05-21 22:19:33.000000000 +0000
+++ GCC/gcc/config/c4x/c4x.h 2004-07-04 23:13:15.000000000 +0000
@@ -1193,10 +1193,6 @@ CUMULATIVE_ARGS;
fprintf (FILE, "\tpop\tar2\n"); \
}
-/* Implicit Calls to Library Routines. */
-
-#define TARGET_MEM_FUNCTIONS
-
/* CC_NOOVmode should be used when the first operand is a PLUS, MINUS, NEG
or MULT.
CCmode should be used when no special processing is needed. */
diff -rupN GCC.orig/gcc/config/cris/aout.h GCC/gcc/config/cris/aout.h
--- GCC.orig/gcc/config/cris/aout.h 2003-10-04 07:32:00.000000000 +0000
+++ GCC/gcc/config/cris/aout.h 2004-07-04 23:13:27.000000000 +0000
@@ -139,11 +139,6 @@ Boston, MA 02111-1307, USA. */
#define MAX_OFILE_ALIGNMENT 16
-/* Node: Library Calls */
-
-#define TARGET_MEM_FUNCTIONS
-
-
/* Node: Data Output */
#define ESCAPES \
diff -rupN GCC.orig/gcc/config/elfos.h GCC/gcc/config/elfos.h
--- GCC.orig/gcc/config/elfos.h 2003-12-24 20:09:58.000000000 +0000
+++ GCC/gcc/config/elfos.h 2004-07-04 23:10:48.000000000 +0000
@@ -58,10 +58,6 @@ Boston, MA 02111-1307, USA. */
#define PCC_BITFIELD_TYPE_MATTERS 1
#endif
-/* Implicit library calls should use memcpy, not bcopy, etc. */
-
-#define TARGET_MEM_FUNCTIONS
-
/* Handle #pragma weak and #pragma pack. */
#define HANDLE_SYSV_PRAGMA 1
diff -rupN GCC.orig/gcc/config/gnu.h GCC/gcc/config/gnu.h
--- GCC.orig/gcc/config/gnu.h 2003-11-29 11:23:03.000000000 +0000
+++ GCC/gcc/config/gnu.h 2004-07-04 23:10:54.000000000 +0000
@@ -12,10 +12,6 @@
#undef STANDARD_INCLUDE_DIR
#define STANDARD_INCLUDE_DIR "/include"
-/* Implicit library calls should use memcpy, not bcopy, etc. */
-#undef TARGET_MEM_FUNCTIONS
-#define TARGET_MEM_FUNCTIONS
-
/* The system headers under GNU are C++-aware. */
#define NO_IMPLICIT_EXTERN_C
diff -rupN GCC.orig/gcc/config/h8300/h8300.h GCC/gcc/config/h8300/h8300.h
--- GCC.orig/gcc/config/h8300/h8300.h 2004-06-28 21:48:06.000000000 +0000
+++ GCC/gcc/config/h8300/h8300.h 2004-07-04 23:13:37.000000000 +0000
@@ -1138,12 +1138,6 @@ struct cum_arg
#define FINAL_PRESCAN_INSN(insn, operand, nop) \
final_prescan_insn (insn, operand, nop)
-/* Define this macro if GCC should generate calls to the System V
- (and ANSI C) library functions `memcpy' and `memset' rather than
- the BSD functions `bcopy' and `bzero'. */
-
-#define TARGET_MEM_FUNCTIONS
-
#define MOVE_RATIO 3
/* Define the codes that are matched by predicates in h8300.c. */
diff -rupN GCC.orig/gcc/config/i386/gas.h GCC/gcc/config/i386/gas.h
--- GCC.orig/gcc/config/i386/gas.h 2003-10-04 07:32:06.000000000 +0000
+++ GCC/gcc/config/i386/gas.h 2004-07-04 23:13:46.000000000 +0000
@@ -49,10 +49,6 @@ Boston, MA 02111-1307, USA. */
#define ASM_OUTPUT_IDENT(FILE, NAME) fprintf (FILE, "\t.ident \"%s\"\n", NAME);
-/* Implicit library calls should use memcpy, not bcopy, etc. */
-
-#define TARGET_MEM_FUNCTIONS
-
/* In the past there was confusion as to what the argument to .align was
in GAS. For the last several years the rule has been this: for a.out
file formats that argument is LOG, and for all other file formats the
diff -rupN GCC.orig/gcc/config/ia64/ia64.h GCC/gcc/config/ia64/ia64.h
--- GCC.orig/gcc/config/ia64/ia64.h 2004-06-12 08:54:40.000000000 +0000
+++ GCC/gcc/config/ia64/ia64.h 2004-07-04 23:13:56.000000000 +0000
@@ -1556,15 +1556,6 @@ do { \
#define INITIALIZE_TRAMPOLINE(ADDR, FNADDR, STATIC_CHAIN) \
ia64_initialize_trampoline((ADDR), (FNADDR), (STATIC_CHAIN))
-/* Implicit Calls to Library Routines */
-
-/* Define this macro if GCC should generate calls to the System V (and ANSI
- C) library functions `memcpy' and `memset' rather than the BSD functions
- `bcopy' and `bzero'. */
-
-#define TARGET_MEM_FUNCTIONS
-
-
/* Addressing Modes */
/* Define this macro if the machine supports post-increment addressing. */
diff -rupN GCC.orig/gcc/config/interix.h GCC/gcc/config/interix.h
--- GCC.orig/gcc/config/interix.h 2003-10-04 07:31:43.000000000 +0000
+++ GCC/gcc/config/interix.h 2004-07-04 23:11:02.000000000 +0000
@@ -22,10 +22,6 @@ along with GCC; see the file COPYING. I
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#ifndef TARGET_MEM_FUNCTIONS
-#define TARGET_MEM_FUNCTIONS
-#endif
-
/* POSIX/Uni-thread only for now. Look at the winnt version
for windows/multi thread */
diff -rupN GCC.orig/gcc/config/ip2k/ip2k.h GCC/gcc/config/ip2k/ip2k.h
--- GCC.orig/gcc/config/ip2k/ip2k.h 2004-05-21 22:19:34.000000000 +0000
+++ GCC/gcc/config/ip2k/ip2k.h 2004-07-04 23:14:03.000000000 +0000
@@ -808,8 +808,6 @@ extern int ip2k_reorg_merge_qimode;
#define FUNCTION_PROFILER(FILE, LABELNO) \
fprintf ((FILE), "/* profiler %d */", (LABELNO))
-#define TARGET_MEM_FUNCTIONS
-
#undef ENDFILE_SPEC
#undef LINK_SPEC
#undef STARTFILE_SPEC
diff -rupN GCC.orig/gcc/config/lynx-ng.h GCC/gcc/config/lynx-ng.h
--- GCC.orig/gcc/config/lynx-ng.h 2003-10-04 07:31:43.000000000 +0000
+++ GCC/gcc/config/lynx-ng.h 2004-07-04 23:11:15.000000000 +0000
@@ -64,10 +64,6 @@ Boston, MA 02111-1307, USA. */
#define SDB_DEBUGGING_INFO 1
-/* Generate calls to memcpy, memcmp and memset. */
-
-#define TARGET_MEM_FUNCTIONS
-
/* Handle #pragma pack and sometimes #pragma weak. */
#define HANDLE_SYSV_PRAGMA 1
diff -rupN GCC.orig/gcc/config/m32r/m32r.c GCC/gcc/config/m32r/m32r.c
--- GCC.orig/gcc/config/m32r/m32r.c 2004-06-29 07:44:19.000000000 +0000
+++ GCC/gcc/config/m32r/m32r.c 2004-07-04 23:12:30.000000000 +0000
@@ -2601,19 +2601,11 @@ block_move_call (rtx dest_reg, rtx src_r
&& GET_MODE (bytes_rtx) != Pmode)
bytes_rtx = convert_to_mode (Pmode, bytes_rtx, 1);
-#ifdef TARGET_MEM_FUNCTIONS
emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "memcpy"), 0,
VOIDmode, 3, dest_reg, Pmode, src_reg, Pmode,
convert_to_mode (TYPE_MODE (sizetype), bytes_rtx,
TYPE_UNSIGNED (sizetype)),
TYPE_MODE (sizetype));
-#else
- emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "bcopy"), 0,
- VOIDmode, 3, src_reg, Pmode, dest_reg, Pmode,
- convert_to_mode (TYPE_MODE (integer_type_node), bytes_rtx,
- TYPE_UNSIGNED (integer_type_node)),
- TYPE_MODE (integer_type_node));
-#endif
}
/* The maximum number of bytes to copy using pairs of load/store instructions.
diff -rupN GCC.orig/gcc/config/m32r/m32r.h GCC/gcc/config/m32r/m32r.h
--- GCC.orig/gcc/config/m32r/m32r.h 2004-06-16 08:10:44.000000000 +0000
+++ GCC/gcc/config/m32r/m32r.h 2004-07-04 23:12:41.000000000 +0000
@@ -1260,11 +1260,6 @@ L2: .word STATIC
} \
while (0)
-/* Library calls. */
-
-/* Generate calls to memcpy, memcmp and memset. */
-#define TARGET_MEM_FUNCTIONS
-
#define RETURN_ADDR_RTX(COUNT, FRAME) m32r_return_addr (COUNT)
#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, RETURN_ADDR_REGNUM)
diff -rupN GCC.orig/gcc/config/mcore/mcore.h GCC/gcc/config/mcore/mcore.h
--- GCC.orig/gcc/config/mcore/mcore.h 2004-05-21 22:19:34.000000000 +0000
+++ GCC/gcc/config/mcore/mcore.h 2004-07-04 23:14:12.000000000 +0000
@@ -953,9 +953,6 @@ extern const enum reg_class reg_class_fr
#define WORD_REGISTER_OPERATIONS
-/* Implicit library calls should use memcpy, not bcopy, etc. */
-#define TARGET_MEM_FUNCTIONS
-
/* Assembler output control. */
#define ASM_COMMENT_START "\t//"
diff -rupN GCC.orig/gcc/config/memcmp.c GCC/gcc/config/memcmp.c
--- GCC.orig/gcc/config/memcmp.c 1970-01-01 00:00:00.000000000 +0000
+++ GCC/gcc/config/memcmp.c 2004-07-04 23:19:59.000000000 +0000
@@ -0,0 +1,16 @@
+/* Public domain. */
+#include <stddef.h>
+
+int
+memcmp (const void *str1, const void *str2, size_t count)
+{
+ const unsigned char *s1 = str1;
+ const unsigned char *s2 = str2;
+
+ while (count-- > 0)
+ {
+ if (*s1++ != *s2++)
+ return s1[-1] < s2[-1] ? -1 : 1;
+ }
+ return 0;
+}
diff -rupN GCC.orig/gcc/config/memcpy.c GCC/gcc/config/memcpy.c
--- GCC.orig/gcc/config/memcpy.c 1970-01-01 00:00:00.000000000 +0000
+++ GCC/gcc/config/memcpy.c 2004-07-04 23:27:29.000000000 +0000
@@ -0,0 +1,12 @@
+/* Public domain. */
+#include <stddef.h>
+
+void *
+memcpy (void *dest, const void *src, size_t len)
+{
+ char *d = dest;
+ const char *s = src;
+ while (len--)
+ *d++ = *s++;
+ return dest;
+}
diff -rupN GCC.orig/gcc/config/memmove.c GCC/gcc/config/memmove.c
--- GCC.orig/gcc/config/memmove.c 1970-01-01 00:00:00.000000000 +0000
+++ GCC/gcc/config/memmove.c 2004-07-04 23:28:57.000000000 +0000
@@ -0,0 +1,20 @@
+/* Public domain. */
+#include <stddef.h>
+
+void *
+memmove (void *dest, const void *src, size_t len)
+{
+ char *d = dest;
+ const char *s = src;
+ if (d < s)
+ while (len--)
+ *d++ = *s++;
+ else
+ {
+ char *lasts = s + (len-1);
+ char *lastd = d + (len-1);
+ while (len--)
+ *lastd-- = *lasts--;
+ }
+ return dest;
+}
diff -rupN GCC.orig/gcc/config/memset.c GCC/gcc/config/memset.c
--- GCC.orig/gcc/config/memset.c 1970-01-01 00:00:00.000000000 +0000
+++ GCC/gcc/config/memset.c 2004-07-04 23:21:21.000000000 +0000
@@ -0,0 +1,11 @@
+/* Public domain. */
+#include <stddef.h>
+
+void *
+memset (void *dest, int val, size_t len)
+{
+ unsigned char *ptr = dest;
+ while (len-- > 0)
+ *ptr++ = val;
+ return dest;
+}
diff -rupN GCC.orig/gcc/config/mips/mips.h GCC/gcc/config/mips/mips.h
--- GCC.orig/gcc/config/mips/mips.h 2004-05-21 22:19:34.000000000 +0000
+++ GCC/gcc/config/mips/mips.h 2004-07-04 23:14:23.000000000 +0000
@@ -3367,9 +3367,6 @@ while (0)
#define DONT_ACCESS_GBLS_AFTER_EPILOGUE (TARGET_ABICALLS && !TARGET_OLDABI)
-/* Generate calls to memcpy, etc., not bcopy, etc. */
-#define TARGET_MEM_FUNCTIONS
-
#ifndef __mips16
/* Since the bits of the _init and _fini function is spread across
many object files, each potentially with its own GP, we must assume
diff -rupN GCC.orig/gcc/config/mmix/mmix.h GCC/gcc/config/mmix/mmix.h
--- GCC.orig/gcc/config/mmix/mmix.h 2004-04-10 09:28:43.000000000 +0000
+++ GCC/gcc/config/mmix/mmix.h 2004-07-04 23:14:35.000000000 +0000
@@ -806,11 +806,6 @@ typedef struct { int regs; int lib; } CU
mmix_initialize_trampoline (ADDR, FNADDR, STATIC_CHAIN)
-/* Node: Library Calls */
-
-#define TARGET_MEM_FUNCTIONS
-
-
/* Node: Addressing Modes */
#define CONSTANT_ADDRESS_P(X) \
diff -rupN GCC.orig/gcc/config/netbsd.h GCC/gcc/config/netbsd.h
--- GCC.orig/gcc/config/netbsd.h 2003-10-04 07:31:43.000000000 +0000
+++ GCC/gcc/config/netbsd.h 2004-07-04 23:11:21.000000000 +0000
@@ -157,11 +157,6 @@ Boston, MA 02111-1307, USA. */
#undef TARGET_HAS_F_SETLKW
#define TARGET_HAS_F_SETLKW
-/* Implicit library calls should use memcpy, not bcopy, etc. */
-
-#undef TARGET_MEM_FUNCTIONS
-#define TARGET_MEM_FUNCTIONS 1
-
/* Handle #pragma weak and #pragma pack. */
#define HANDLE_SYSV_PRAGMA 1
diff -rupN GCC.orig/gcc/config/openbsd.h GCC/gcc/config/openbsd.h
--- GCC.orig/gcc/config/openbsd.h 2003-10-04 07:31:43.000000000 +0000
+++ GCC/gcc/config/openbsd.h 2004-07-04 23:11:29.000000000 +0000
@@ -130,13 +130,6 @@ Boston, MA 02111-1307, USA. */
/* Runtime target specification. */
-/* Implicit calls to library routines. */
-
-/* Use memcpy and memset instead of bcopy and bzero. */
-#ifndef TARGET_MEM_FUNCTIONS
-#define TARGET_MEM_FUNCTIONS
-#endif
-
/* Miscellaneous parameters. */
/* Controlling debugging info: dbx options. */
diff -rupN GCC.orig/gcc/config/pa/pa.h GCC/gcc/config/pa/pa.h
--- GCC.orig/gcc/config/pa/pa.h 2004-07-01 08:22:13.000000000 +0000
+++ GCC/gcc/config/pa/pa.h 2004-07-04 23:14:44.000000000 +0000
@@ -500,9 +500,6 @@ do { \
when given unaligned data. */
#define STRICT_ALIGNMENT 1
-/* Generate calls to memcpy, memcmp and memset. */
-#define TARGET_MEM_FUNCTIONS
-
/* Value is 1 if it is a good idea to tie two pseudo registers
when one has mode MODE1 and one has mode MODE2.
If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
diff -rupN GCC.orig/gcc/config/pdp11/t-pdp11 GCC/gcc/config/pdp11/t-pdp11
--- GCC.orig/gcc/config/pdp11/t-pdp11 2002-11-06 22:48:58.000000000 +0000
+++ GCC/gcc/config/pdp11/t-pdp11 2004-07-04 23:29:51.000000000 +0000
@@ -1,5 +1,7 @@
TARGET_LIBGCC2_CFLAGS = -O2 -mfloat32
-LIB2FUNCS_EXTRA = $(srcdir)/config/udivmod.c $(srcdir)/config/udivmodsi4.c
+LIB2FUNCS_EXTRA = $(srcdir)/config/udivmod.c $(srcdir)/config/udivmodsi4.c \
+ $(srcdir)/config/memcmp.c $(srcdir)/config/memcpy.c \
+ $(srcdir)/config/memmove.c $(srcdir)/config/memset.c
# floating point emulation libraries
FPBIT = fp-bit.c
diff -rupN GCC.orig/gcc/config/rs6000/rs6000.h GCC/gcc/config/rs6000/rs6000.h
--- GCC.orig/gcc/config/rs6000/rs6000.h 2004-06-14 22:20:33.000000000 +0000
+++ GCC/gcc/config/rs6000/rs6000.h 2004-07-04 23:14:52.000000000 +0000
@@ -2217,10 +2217,6 @@ extern int rs6000_compare_fp_p;
the end of the line. */
#define ASM_COMMENT_START " #"
-/* Implicit library calls should use memcpy, not bcopy, etc. */
-
-#define TARGET_MEM_FUNCTIONS
-
/* Flag to say the TOC is initialized */
extern int toc_initialized;
diff -rupN GCC.orig/gcc/config/rtems.h GCC/gcc/config/rtems.h
--- GCC.orig/gcc/config/rtems.h 2004-03-18 11:06:36.000000000 +0000
+++ GCC/gcc/config/rtems.h 2004-07-04 23:11:36.000000000 +0000
@@ -21,11 +21,6 @@ Boston, MA 02111-1307, USA. */
/* The system headers under RTEMS are C++-aware. */
#define NO_IMPLICIT_EXTERN_C
-/* Generate calls to memcpy, memcmp and memset. */
-#ifndef TARGET_MEM_FUNCTIONS
-#define TARGET_MEM_FUNCTIONS
-#endif
-
/*
* Dummy start/end specification to let linker work as
* needed by autoconf scripts using this compiler.
diff -rupN GCC.orig/gcc/config/s390/s390.h GCC/gcc/config/s390/s390.h
--- GCC.orig/gcc/config/s390/s390.h 2004-06-24 08:28:39.000000000 +0000
+++ GCC/gcc/config/s390/s390.h 2004-07-04 23:15:01.000000000 +0000
@@ -722,12 +722,6 @@ CUMULATIVE_ARGS;
s390_trampoline_template (FILE)
-/* Library calls. */
-
-/* We should use memcpy, not bcopy. */
-#define TARGET_MEM_FUNCTIONS
-
-
/* Addressing modes, and classification of registers for them. */
/* Recognize any constant value that is a valid address. */
diff -rupN GCC.orig/gcc/config/sh/sh.h GCC/gcc/config/sh/sh.h
--- GCC.orig/gcc/config/sh/sh.h 2004-06-30 09:34:45.000000000 +0000
+++ GCC/gcc/config/sh/sh.h 2004-07-04 23:15:09.000000000 +0000
@@ -3232,10 +3232,6 @@ enum mdep_reorg_phase_e
extern enum mdep_reorg_phase_e mdep_reorg_phase;
-/* Generate calls to memcpy, memcmp and memset. */
-
-#define TARGET_MEM_FUNCTIONS
-
/* Handle Renesas compiler's pragmas. */
#define REGISTER_TARGET_PRAGMAS() do { \
c_register_pragma (0, "interrupt", sh_pr_interrupt); \
diff -rupN GCC.orig/gcc/config/sparc/sparc.h GCC/gcc/config/sparc/sparc.h
--- GCC.orig/gcc/config/sparc/sparc.h 2004-06-30 22:18:35.000000000 +0000
+++ GCC/gcc/config/sparc/sparc.h 2004-07-04 23:15:16.000000000 +0000
@@ -2207,9 +2207,6 @@ do {
/* Specify the machine mode used for addresses. */
#define Pmode (TARGET_ARCH64 ? DImode : SImode)
-/* Generate calls to memcpy, memcmp and memset. */
-#define TARGET_MEM_FUNCTIONS
-
/* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
return the mode to be used for the comparison. For floating-point,
CCFP[E]mode is used. CC_NOOVmode should be used when the first operand
diff -rupN GCC.orig/gcc/config/stormy16/stormy16.h GCC/gcc/config/stormy16/stormy16.h
--- GCC.orig/gcc/config/stormy16/stormy16.h 2004-05-21 22:19:35.000000000 +0000
+++ GCC/gcc/config/stormy16/stormy16.h 2004-07-04 23:15:28.000000000 +0000
@@ -497,10 +497,6 @@ enum reg_class
xstormy16_initialize_trampoline (ADDR, FNADDR, STATIC_CHAIN)
-/* Implicit Calls to Library Routines */
-
-#define TARGET_MEM_FUNCTIONS
-
/* Define this macro to override the type used by the library routines to pick
up arguments of type `float'. (By default, they use a union of `float' and
`int'.)
diff -rupN GCC.orig/gcc/config/svr3.h GCC/gcc/config/svr3.h
--- GCC.orig/gcc/config/svr3.h 2003-10-04 07:31:43.000000000 +0000
+++ GCC/gcc/config/svr3.h 2004-07-04 23:11:44.000000000 +0000
@@ -70,10 +70,6 @@ Boston, MA 02111-1307, USA. */
#define NO_DOLLAR_IN_LABEL
-/* Implicit library calls should use memcpy, not bcopy, etc. */
-
-#define TARGET_MEM_FUNCTIONS
-
/* System V Release 3 uses COFF debugging info. */
#define SDB_DEBUGGING_INFO 1
diff -rupN GCC.orig/gcc/config/vax/t-memfuncs GCC/gcc/config/vax/t-memfuncs
--- GCC.orig/gcc/config/vax/t-memfuncs 1970-01-01 00:00:00.000000000 +0000
+++ GCC/gcc/config/vax/t-memfuncs 2004-07-04 23:31:17.000000000 +0000
@@ -0,0 +1,3 @@
+LIB2FUNCS_EXTRA = \
+ $(srcdir)/config/memcmp.c $(srcdir)/config/memcpy.c \
+ $(srcdir)/config/memmove.c $(srcdir)/config/memset.c
diff -rupN GCC.orig/gcc/config.gcc GCC/gcc/config.gcc
--- GCC.orig/gcc/config.gcc 2004-06-29 07:44:16.000000000 +0000
+++ GCC/gcc/config.gcc 2004-07-04 23:32:39.000000000 +0000
@@ -2012,11 +2012,13 @@ v850-*-*)
;;
vax-*-bsd*) # VAXen running BSD
tm_file="${tm_file} vax/bsd.h"
+ tmake_file=vax/t-memfuncs
use_collect2=yes
use_fixproto=yes
;;
vax-*-sysv*) # VAXen running system V
tm_file="${tm_file} vax/vaxv.h"
+ tmake_file=vax/t-memfuncs
use_fixproto=yes
;;
vax-*-netbsdelf*)
@@ -2034,6 +2036,7 @@ vax-*-openbsd*)
;;
vax-*-ultrix*) # VAXen running ultrix
tm_file="${tm_file} vax/ultrix.h"
+ tmake_file=vax/t-memfuncs
use_fixproto=yes
;;
xscale-*-elf)
diff -rupN GCC.orig/gcc/doc/invoke.texi GCC/gcc/doc/invoke.texi
--- GCC.orig/gcc/doc/invoke.texi 2004-07-02 23:47:25.000000000 +0000
+++ GCC/gcc/doc/invoke.texi 2004-07-04 23:09:05.000000000 +0000
@@ -5440,9 +5440,9 @@ or @option{-nodefaultlibs} is used.
Do not use the standard system libraries when linking.
Only the libraries you specify will be passed to the linker.
The standard startup files are used normally, unless @option{-nostartfiles}
-is used. The compiler may generate calls to memcmp, memset, and memcpy
-for System V (and ISO C) environments or to bcopy and bzero for
-BSD environments. These entries are usually resolved by entries in
+is used. The compiler may generate calls to @code{memcmp},
+@code{memset}, @code{memcpy} and @code{memmove}.
+These entries are usually resolved by entries in
libc. These entry points should be supplied through some other
mechanism when this option is specified.
@@ -5450,9 +5450,9 @@ mechanism when this option is specified.
@opindex nostdlib
Do not use the standard system startup files or libraries when linking.
No startup files and only the libraries you specify will be passed to
-the linker. The compiler may generate calls to memcmp, memset, and memcpy
-for System V (and ISO C) environments or to bcopy and bzero for
-BSD environments. These entries are usually resolved by entries in
+the linker. The compiler may generate calls to @code{memcmp}, @code{memset},
+@code{memcpy} and @code{memmove}.
+These entries are usually resolved by entries in
libc. These entry points should be supplied through some other
mechanism when this option is specified.
diff -rupN GCC.orig/gcc/doc/standards.texi GCC/gcc/doc/standards.texi
--- GCC.orig/gcc/doc/standards.texi 2004-05-18 10:12:45.000000000 +0000
+++ GCC/gcc/doc/standards.texi 2004-07-04 23:07:16.000000000 +0000
@@ -145,9 +145,7 @@ GNU C library). @xref{Standard Librarie
Most of the compiler support routines used by GCC are present in
@file{libgcc}, but there are a few exceptions. GCC requires the
freestanding environment provide @code{memcpy}, @code{memmove},
-@code{memset} and @code{memcmp}. Some older ports of GCC are
-configured to use the BSD @code{bcopy}, @code{bzero} and @code{bcmp}
-functions instead, but this is deprecated for new ports.
+@code{memset} and @code{memcmp}.
Finally, if @code{__builtin_trap} is used, and the target does
not implement the @code{trap} pattern, then GCC will emit a call
to @code{abort}.
diff -rupN GCC.orig/gcc/doc/tm.texi GCC/gcc/doc/tm.texi
--- GCC.orig/gcc/doc/tm.texi 2004-07-02 07:56:27.000000000 +0000
+++ GCC/gcc/doc/tm.texi 2004-07-04 23:06:55.000000000 +0000
@@ -4811,17 +4811,6 @@ refers to the global ``variable'' @code{
macro, a reasonable default is used.
@end defmac
-@cindex @code{bcopy}, implicit usage
-@cindex @code{memcpy}, implicit usage
-@cindex @code{memmove}, implicit usage
-@cindex @code{bzero}, implicit usage
-@cindex @code{memset}, implicit usage
-@defmac TARGET_MEM_FUNCTIONS
-Define this macro if GCC should generate calls to the ISO C
-(and System V) library functions @code{memcpy}, @code{memmove} and
-@code{memset} rather than the BSD functions @code{bcopy} and @code{bzero}.
-@end defmac
-
@cindex C99 math functions, implicit usage
@defmac TARGET_C99_FUNCTIONS
When this macro is nonzero, GCC will implicitly optimize @code{sin} calls into
diff -rupN GCC.orig/gcc/expr.c GCC/gcc/expr.c
--- GCC.orig/gcc/expr.c 2004-07-03 11:45:12.000000000 +0000
+++ GCC/gcc/expr.c 2004-07-04 23:02:12.000000000 +0000
@@ -77,14 +77,6 @@ Software Foundation, 59 Temple Place - S
#endif
#endif
-/* Convert defined/undefined to boolean. */
-#ifdef TARGET_MEM_FUNCTIONS
-#undef TARGET_MEM_FUNCTIONS
-#define TARGET_MEM_FUNCTIONS 1
-#else
-#define TARGET_MEM_FUNCTIONS 0
-#endif
-
/* If this is nonzero, we do not bother generating VOLATILE
around volatile memory references, and we are willing to
@@ -1511,7 +1503,7 @@ emit_block_move_via_movstr (rtx x, rtx y
return false;
}
-/* A subroutine of emit_block_move. Expand a call to memcpy or bcopy.
+/* A subroutine of emit_block_move. Expand a call to memcpy.
Return the return value from memcpy, 0 otherwise. */
static rtx
@@ -1550,10 +1542,7 @@ emit_block_move_via_libcall (rtx dst, rt
dst_tree = make_tree (ptr_type_node, dst_addr);
src_tree = make_tree (ptr_type_node, src_addr);
- if (TARGET_MEM_FUNCTIONS)
- size_mode = TYPE_MODE (sizetype);
- else
- size_mode = TYPE_MODE (unsigned_type_node);
+ size_mode = TYPE_MODE (sizetype);
size = convert_to_mode (size_mode, size, 1);
size = copy_to_mode_reg (size_mode, size);
@@ -1562,27 +1551,14 @@ emit_block_move_via_libcall (rtx dst, rt
memcpy in this context. This could be a user call to memcpy and
the user may wish to examine the return value from memcpy. For
targets where libcalls and normal calls have different conventions
- for returning pointers, we could end up generating incorrect code.
+ for returning pointers, we could end up generating incorrect code. */
- For convenience, we generate the call to bcopy this way as well. */
-
- if (TARGET_MEM_FUNCTIONS)
- size_tree = make_tree (sizetype, size);
- else
- size_tree = make_tree (unsigned_type_node, size);
+ size_tree = make_tree (sizetype, size);
fn = emit_block_move_libcall_fn (true);
arg_list = tree_cons (NULL_TREE, size_tree, NULL_TREE);
- if (TARGET_MEM_FUNCTIONS)
- {
- arg_list = tree_cons (NULL_TREE, src_tree, arg_list);
- arg_list = tree_cons (NULL_TREE, dst_tree, arg_list);
- }
- else
- {
- arg_list = tree_cons (NULL_TREE, dst_tree, arg_list);
- arg_list = tree_cons (NULL_TREE, src_tree, arg_list);
- }
+ arg_list = tree_cons (NULL_TREE, src_tree, arg_list);
+ arg_list = tree_cons (NULL_TREE, dst_tree, arg_list);
/* Now we have to build up the CALL_EXPR itself. */
call_expr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (fn)), fn);
@@ -1601,7 +1577,7 @@ emit_block_move_via_libcall (rtx dst, rt
gen_rtx_CLOBBER (VOIDmode, dst),
NULL_RTX));
- return TARGET_MEM_FUNCTIONS ? retval : NULL_RTX;
+ return retval;
}
/* A subroutine of emit_block_move_via_libcall. Create the tree node
@@ -1617,20 +1593,10 @@ init_block_move_fn (const char *asmspec)
{
tree args, fn;
- if (TARGET_MEM_FUNCTIONS)
- {
- fn = get_identifier ("memcpy");
- args = build_function_type_list (ptr_type_node, ptr_type_node,
- const_ptr_type_node, sizetype,
- NULL_TREE);
- }
- else
- {
- fn = get_identifier ("bcopy");
- args = build_function_type_list (void_type_node, const_ptr_type_node,
- ptr_type_node, unsigned_type_node,
- NULL_TREE);
- }
+ fn = get_identifier ("memcpy");
+ args = build_function_type_list (ptr_type_node, ptr_type_node,
+ const_ptr_type_node, sizetype,
+ NULL_TREE);
fn = build_decl (FUNCTION_DECL, fn, args);
DECL_EXTERNAL (fn) = 1;
@@ -2642,7 +2608,7 @@ clear_storage_via_clrstr (rtx object, rt
return false;
}
-/* A subroutine of clear_storage. Expand a call to memset or bzero.
+/* A subroutine of clear_storage. Expand a call to memset.
Return the return value of memset, 0 otherwise. */
static rtx
@@ -2673,10 +2639,7 @@ clear_storage_via_libcall (rtx object, r
object = copy_to_mode_reg (Pmode, XEXP (object, 0));
- if (TARGET_MEM_FUNCTIONS)
- size_mode = TYPE_MODE (sizetype);
- else
- size_mode = TYPE_MODE (unsigned_type_node);
+ size_mode = TYPE_MODE (sizetype);
size = convert_to_mode (size_mode, size, 1);
size = copy_to_mode_reg (size_mode, size);
@@ -2684,20 +2647,14 @@ clear_storage_via_libcall (rtx object, r
memset in this context. This could be a user call to memset and
the user may wish to examine the return value from memset. For
targets where libcalls and normal calls have different conventions
- for returning pointers, we could end up generating incorrect code.
-
- For convenience, we generate the call to bzero this way as well. */
+ for returning pointers, we could end up generating incorrect code. */
object_tree = make_tree (ptr_type_node, object);
- if (TARGET_MEM_FUNCTIONS)
- size_tree = make_tree (sizetype, size);
- else
- size_tree = make_tree (unsigned_type_node, size);
+ size_tree = make_tree (sizetype, size);
fn = clear_storage_libcall_fn (true);
arg_list = tree_cons (NULL_TREE, size_tree, NULL_TREE);
- if (TARGET_MEM_FUNCTIONS)
- arg_list = tree_cons (NULL_TREE, integer_zero_node, arg_list);
+ arg_list = tree_cons (NULL_TREE, integer_zero_node, arg_list);
arg_list = tree_cons (NULL_TREE, object_tree, arg_list);
/* Now we have to build up the CALL_EXPR itself. */
@@ -2713,7 +2670,7 @@ clear_storage_via_libcall (rtx object, r
if (RTX_UNCHANGING_P (object))
emit_insn (gen_rtx_CLOBBER (VOIDmode, object));
- return (TARGET_MEM_FUNCTIONS ? retval : NULL_RTX);
+ return retval;
}
/* A subroutine of clear_storage_via_libcall. Create the tree node
@@ -2729,19 +2686,10 @@ init_block_clear_fn (const char *asmspec
{
tree fn, args;
- if (TARGET_MEM_FUNCTIONS)
- {
- fn = get_identifier ("memset");
- args = build_function_type_list (ptr_type_node, ptr_type_node,
- integer_type_node, sizetype,
- NULL_TREE);
- }
- else
- {
- fn = get_identifier ("bzero");
- args = build_function_type_list (void_type_node, ptr_type_node,
- unsigned_type_node, NULL_TREE);
- }
+ fn = get_identifier ("memset");
+ args = build_function_type_list (ptr_type_node, ptr_type_node,
+ integer_type_node, sizetype,
+ NULL_TREE);
fn = build_decl (FUNCTION_DECL, fn, args);
DECL_EXTERNAL (fn) = 1;
@@ -4029,21 +3977,12 @@ expand_assignment (tree to, tree from, i
size = expr_size (from);
from_rtx = expand_expr (from, NULL_RTX, VOIDmode, 0);
- if (TARGET_MEM_FUNCTIONS)
- emit_library_call (memmove_libfunc, LCT_NORMAL,
- VOIDmode, 3, XEXP (to_rtx, 0), Pmode,
- XEXP (from_rtx, 0), Pmode,
- convert_to_mode (TYPE_MODE (sizetype),
- size, TYPE_UNSIGNED (sizetype)),
- TYPE_MODE (sizetype));
- else
- emit_library_call (bcopy_libfunc, LCT_NORMAL,
- VOIDmode, 3, XEXP (from_rtx, 0), Pmode,
- XEXP (to_rtx, 0), Pmode,
- convert_to_mode (TYPE_MODE (integer_type_node),
- size,
- TYPE_UNSIGNED (integer_type_node)),
- TYPE_MODE (integer_type_node));
+ emit_library_call (memmove_libfunc, LCT_NORMAL,
+ VOIDmode, 3, XEXP (to_rtx, 0), Pmode,
+ XEXP (from_rtx, 0), Pmode,
+ convert_to_mode (TYPE_MODE (sizetype),
+ size, TYPE_UNSIGNED (sizetype)),
+ TYPE_MODE (sizetype));
preserve_temp_slots (to_rtx);
free_temp_slots ();
@@ -5207,10 +5146,10 @@ store_constructor (tree exp, rtx target,
and then "or" in whatever non-constant ranges we need in addition.
If a large set is all zero or all ones, it is
- probably better to set it using memset (if available) or bzero.
+ probably better to set it using memset.
Also, if a large set has just a single range, it may also be
better to first clear all the first clear the set (using
- bzero/memset), and set the bits we want. */
+ memset), and set the bits we want. */
/* Check for all zeros. */
if (elt == NULL_TREE && size > 0)
@@ -5342,8 +5281,7 @@ store_constructor (tree exp, rtx target,
/* Optimization: If startbit and endbit are constants divisible
by BITS_PER_UNIT, call memset instead. */
- if (TARGET_MEM_FUNCTIONS
- && TREE_CODE (startbit) == INTEGER_CST
+ if (TREE_CODE (startbit) == INTEGER_CST
&& TREE_CODE (endbit) == INTEGER_CST
&& (startb = TREE_INT_CST_LOW (startbit)) % BITS_PER_UNIT == 0
&& (endb = TREE_INT_CST_LOW (endbit) + 1) % BITS_PER_UNIT == 0)
diff -rupN GCC.orig/gcc/libfuncs.h GCC/gcc/libfuncs.h
--- GCC.orig/gcc/libfuncs.h 2004-07-01 08:22:08.000000000 +0000
+++ GCC/gcc/libfuncs.h 2004-07-04 23:02:55.000000000 +0000
@@ -27,11 +27,8 @@ enum libfunc_index
LTI_abort,
LTI_memcpy,
LTI_memmove,
- LTI_bcopy,
LTI_memcmp,
- LTI_bcmp,
LTI_memset,
- LTI_bzero,
LTI_setbits,
LTI_unwind_resume,
@@ -58,11 +55,8 @@ extern GTY(()) rtx libfunc_table[LTI_MAX
#define abort_libfunc (libfunc_table[LTI_abort])
#define memcpy_libfunc (libfunc_table[LTI_memcpy])
#define memmove_libfunc (libfunc_table[LTI_memmove])
-#define bcopy_libfunc (libfunc_table[LTI_bcopy])
#define memcmp_libfunc (libfunc_table[LTI_memcmp])
-#define bcmp_libfunc (libfunc_table[LTI_bcmp])
#define memset_libfunc (libfunc_table[LTI_memset])
-#define bzero_libfunc (libfunc_table[LTI_bzero])
#define setbits_libfunc (libfunc_table[LTI_setbits])
#define unwind_resume_libfunc (libfunc_table[LTI_unwind_resume])
diff -rupN GCC.orig/gcc/optabs.c GCC/gcc/optabs.c
--- GCC.orig/gcc/optabs.c 2004-07-01 21:44:57.000000000 +0000
+++ GCC/gcc/optabs.c 2004-07-04 23:03:40.000000000 +0000
@@ -3744,15 +3744,9 @@ prepare_cmp_insn (rtx *px, rtx *py, enum
return;
}
- /* Otherwise call a library function, memcmp if we've got it,
- bcmp otherwise. */
-#ifdef TARGET_MEM_FUNCTIONS
+ /* Otherwise call a library function, memcmp. */
libfunc = memcmp_libfunc;
length_type = sizetype;
-#else
- libfunc = bcmp_libfunc;
- length_type = integer_type_node;
-#endif
result_mode = TYPE_MODE (integer_type_node);
cmp_mode = TYPE_MODE (length_type);
size = convert_to_mode (TYPE_MODE (length_type), size,
@@ -5522,11 +5516,8 @@ init_optabs (void)
abort_libfunc = init_one_libfunc ("abort");
memcpy_libfunc = init_one_libfunc ("memcpy");
memmove_libfunc = init_one_libfunc ("memmove");
- bcopy_libfunc = init_one_libfunc ("bcopy");
memcmp_libfunc = init_one_libfunc ("memcmp");
- bcmp_libfunc = init_one_libfunc ("__gcc_bcmp");
memset_libfunc = init_one_libfunc ("memset");
- bzero_libfunc = init_one_libfunc ("bzero");
setbits_libfunc = init_one_libfunc ("__setbits");
unwind_resume_libfunc = init_one_libfunc (USING_SJLJ_EXCEPTIONS
diff -rupN GCC.orig/gcc/system.h GCC/gcc/system.h
--- GCC.orig/gcc/system.h 2004-06-25 08:53:43.000000000 +0000
+++ GCC/gcc/system.h 2004-07-04 23:03:57.000000000 +0000
@@ -618,7 +618,7 @@ extern int snprintf (char *, size_t, con
DBX_OUTPUT_STANDARD_TYPES BUILTIN_SETJMP_FRAME_VALUE \
SUNOS4_SHARED_LIBRARIES PROMOTE_FOR_CALL_ONLY \
SPACE_AFTER_L_OPTION NO_RECURSIVE_FUNCTION_CSE \
- DEFAULT_MAIN_RETURN
+ DEFAULT_MAIN_RETURN TARGET_MEM_FUNCTIONS
/* Hooks that are no longer used. */
#pragma GCC poison LANG_HOOKS_FUNCTION_MARK LANG_HOOKS_FUNCTION_FREE \