From 8f99553ff6cdc54e5af910042f93fbfbdaac0424 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Mon, 5 Jul 2004 20:49:20 +0100 Subject: [PATCH] c-decl.c, [...]: Don't check TARGET_MEM_FUNCTIONS. * 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. From-SVN: r84130 --- gcc/ChangeLog | 29 ++++++++ gcc/c-decl.c | 7 -- gcc/config.gcc | 3 + gcc/config/alpha/alpha.h | 3 - gcc/config/arc/arc.h | 5 -- gcc/config/arm/arm.h | 3 - gcc/config/avr/avr.h | 2 - gcc/config/c4x/c4x.h | 4 -- gcc/config/cris/aout.h | 5 -- gcc/config/elfos.h | 4 -- gcc/config/gnu.h | 4 -- gcc/config/h8300/h8300.h | 6 -- gcc/config/i386/gas.h | 4 -- gcc/config/ia64/ia64.h | 9 --- gcc/config/interix.h | 4 -- gcc/config/ip2k/ip2k.h | 2 - gcc/config/lynx-ng.h | 4 -- gcc/config/m32r/m32r.c | 8 --- gcc/config/m32r/m32r.h | 5 -- gcc/config/mcore/mcore.h | 3 - gcc/config/memcmp.c | 16 +++++ gcc/config/memcpy.c | 12 ++++ gcc/config/memmove.c | 20 ++++++ gcc/config/memset.c | 11 +++ gcc/config/mips/mips.h | 3 - gcc/config/mmix/mmix.h | 5 -- gcc/config/netbsd.h | 5 -- gcc/config/openbsd.h | 7 -- gcc/config/pa/pa.h | 3 - gcc/config/pdp11/t-pdp11 | 4 +- gcc/config/rs6000/rs6000.h | 4 -- gcc/config/rtems.h | 5 -- gcc/config/s390/s390.h | 6 -- gcc/config/sh/sh.h | 4 -- gcc/config/sparc/sparc.h | 3 - gcc/config/stormy16/stormy16.h | 4 -- gcc/config/svr3.h | 4 -- gcc/config/vax/t-memfuncs | 3 + gcc/doc/invoke.texi | 12 ++-- gcc/doc/standards.texi | 4 +- gcc/doc/tm.texi | 11 --- gcc/expr.c | 122 ++++++++------------------------- gcc/libfuncs.h | 6 -- gcc/optabs.c | 11 +-- gcc/system.h | 2 +- 45 files changed, 136 insertions(+), 265 deletions(-) create mode 100644 gcc/config/memcmp.c create mode 100644 gcc/config/memcpy.c create mode 100644 gcc/config/memmove.c create mode 100644 gcc/config/memset.c create mode 100644 gcc/config/vax/t-memfuncs diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cce5964af42..66f6821dfc1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,32 @@ +2004-07-05 Joseph S. Myers + + * 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. + 2004-07-05 Richard Henderson * function.c (assign_parm_setup_reg): Properly rename variables in diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 56351512ff4..5e34bb59e82 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -2944,17 +2944,10 @@ finish_decl (tree decl, tree init, tree asmspec_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 --git a/gcc/config.gcc b/gcc/config.gcc index 35b55d5487a..2d70d44708c 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -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 --git a/gcc/config/alpha/alpha.h b/gcc/config/alpha/alpha.h index 8cc22caf1b4..8e03fd75310 100644 --- a/gcc/config/alpha/alpha.h +++ b/gcc/config/alpha/alpha.h @@ -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 --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h index f25e5d369d3..1ee15192711 100644 --- a/gcc/config/arc/arc.h +++ b/gcc/config/arc/arc.h @@ -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 --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index 4b4ddedf483..3067153131f 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -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 --git a/gcc/config/avr/avr.h b/gcc/config/avr/avr.h index c9beb30410f..da06c207604 100644 --- a/gcc/config/avr/avr.h +++ b/gcc/config/avr/avr.h @@ -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 --git a/gcc/config/c4x/c4x.h b/gcc/config/c4x/c4x.h index 3079c0a66c6..cff2548df77 100644 --- a/gcc/config/c4x/c4x.h +++ b/gcc/config/c4x/c4x.h @@ -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 --git a/gcc/config/cris/aout.h b/gcc/config/cris/aout.h index e77c73ce432..9a409cf8a42 100644 --- a/gcc/config/cris/aout.h +++ b/gcc/config/cris/aout.h @@ -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 --git a/gcc/config/elfos.h b/gcc/config/elfos.h index 6a138f9f76f..743ae71ab6d 100644 --- a/gcc/config/elfos.h +++ b/gcc/config/elfos.h @@ -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 --git a/gcc/config/gnu.h b/gcc/config/gnu.h index 23a8a730ec9..79c64c77ba9 100644 --- a/gcc/config/gnu.h +++ b/gcc/config/gnu.h @@ -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 --git a/gcc/config/h8300/h8300.h b/gcc/config/h8300/h8300.h index eeafd84a24e..fcb082372a1 100644 --- a/gcc/config/h8300/h8300.h +++ b/gcc/config/h8300/h8300.h @@ -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 --git a/gcc/config/i386/gas.h b/gcc/config/i386/gas.h index 78195b97a85..9f002431018 100644 --- a/gcc/config/i386/gas.h +++ b/gcc/config/i386/gas.h @@ -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 --git a/gcc/config/ia64/ia64.h b/gcc/config/ia64/ia64.h index a26a1da4b87..930266c6f85 100644 --- a/gcc/config/ia64/ia64.h +++ b/gcc/config/ia64/ia64.h @@ -1555,15 +1555,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 */ diff --git a/gcc/config/interix.h b/gcc/config/interix.h index 9d05f1bcc0a..9db2d84af98 100644 --- a/gcc/config/interix.h +++ b/gcc/config/interix.h @@ -22,10 +22,6 @@ along with GCC; see the file COPYING. If not, write to 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 --git a/gcc/config/ip2k/ip2k.h b/gcc/config/ip2k/ip2k.h index d78ae7779b1..c24c49370f5 100644 --- a/gcc/config/ip2k/ip2k.h +++ b/gcc/config/ip2k/ip2k.h @@ -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 --git a/gcc/config/lynx-ng.h b/gcc/config/lynx-ng.h index c23ad39a77f..a1fe786b463 100644 --- a/gcc/config/lynx-ng.h +++ b/gcc/config/lynx-ng.h @@ -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 --git a/gcc/config/m32r/m32r.c b/gcc/config/m32r/m32r.c index 5adc498c52f..9de4eb34d28 100644 --- a/gcc/config/m32r/m32r.c +++ b/gcc/config/m32r/m32r.c @@ -2601,19 +2601,11 @@ block_move_call (rtx dest_reg, rtx src_reg, rtx bytes_rtx) && 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 --git a/gcc/config/m32r/m32r.h b/gcc/config/m32r/m32r.h index c20b0424bb0..14f266c0949 100644 --- a/gcc/config/m32r/m32r.h +++ b/gcc/config/m32r/m32r.h @@ -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 --git a/gcc/config/mcore/mcore.h b/gcc/config/mcore/mcore.h index ccae6d945dd..b6e5d87a42a 100644 --- a/gcc/config/mcore/mcore.h +++ b/gcc/config/mcore/mcore.h @@ -953,9 +953,6 @@ extern const enum reg_class reg_class_from_letter[]; #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 --git a/gcc/config/memcmp.c b/gcc/config/memcmp.c new file mode 100644 index 00000000000..2348afe1d27 --- /dev/null +++ b/gcc/config/memcmp.c @@ -0,0 +1,16 @@ +/* Public domain. */ +#include + +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 --git a/gcc/config/memcpy.c b/gcc/config/memcpy.c new file mode 100644 index 00000000000..58b1e405627 --- /dev/null +++ b/gcc/config/memcpy.c @@ -0,0 +1,12 @@ +/* Public domain. */ +#include + +void * +memcpy (void *dest, const void *src, size_t len) +{ + char *d = dest; + const char *s = src; + while (len--) + *d++ = *s++; + return dest; +} diff --git a/gcc/config/memmove.c b/gcc/config/memmove.c new file mode 100644 index 00000000000..13b340af6a0 --- /dev/null +++ b/gcc/config/memmove.c @@ -0,0 +1,20 @@ +/* Public domain. */ +#include + +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 --git a/gcc/config/memset.c b/gcc/config/memset.c new file mode 100644 index 00000000000..3e7025ee394 --- /dev/null +++ b/gcc/config/memset.c @@ -0,0 +1,11 @@ +/* Public domain. */ +#include + +void * +memset (void *dest, int val, size_t len) +{ + unsigned char *ptr = dest; + while (len-- > 0) + *ptr++ = val; + return dest; +} diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h index 1722041c542..77ea0e0e32e 100644 --- a/gcc/config/mips/mips.h +++ b/gcc/config/mips/mips.h @@ -3363,9 +3363,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 --git a/gcc/config/mmix/mmix.h b/gcc/config/mmix/mmix.h index 01090b7771a..8e5432bb211 100644 --- a/gcc/config/mmix/mmix.h +++ b/gcc/config/mmix/mmix.h @@ -806,11 +806,6 @@ typedef struct { int regs; int lib; } CUMULATIVE_ARGS; mmix_initialize_trampoline (ADDR, FNADDR, STATIC_CHAIN) -/* Node: Library Calls */ - -#define TARGET_MEM_FUNCTIONS - - /* Node: Addressing Modes */ #define CONSTANT_ADDRESS_P(X) \ diff --git a/gcc/config/netbsd.h b/gcc/config/netbsd.h index e3eb0d1ffa8..40adf1a381d 100644 --- a/gcc/config/netbsd.h +++ b/gcc/config/netbsd.h @@ -159,11 +159,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 --git a/gcc/config/openbsd.h b/gcc/config/openbsd.h index 670a0a08aa1..b472182718f 100644 --- a/gcc/config/openbsd.h +++ b/gcc/config/openbsd.h @@ -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 --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h index 1b6a2c8f2f0..fec6f2cf0ca 100644 --- a/gcc/config/pa/pa.h +++ b/gcc/config/pa/pa.h @@ -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 --git a/gcc/config/pdp11/t-pdp11 b/gcc/config/pdp11/t-pdp11 index 0231a7b38d6..c0a23c2ec45 100644 --- a/gcc/config/pdp11/t-pdp11 +++ b/gcc/config/pdp11/t-pdp11 @@ -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 --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index 00aad36832d..17df6c082eb 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -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 --git a/gcc/config/rtems.h b/gcc/config/rtems.h index 2656ff78b3a..301154325fb 100644 --- a/gcc/config/rtems.h +++ b/gcc/config/rtems.h @@ -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 --git a/gcc/config/s390/s390.h b/gcc/config/s390/s390.h index 30202e4b5b3..85168b4d99a 100644 --- a/gcc/config/s390/s390.h +++ b/gcc/config/s390/s390.h @@ -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 --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h index 0d6d1c6570c..c9f411ae72f 100644 --- a/gcc/config/sh/sh.h +++ b/gcc/config/sh/sh.h @@ -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 --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h index 595a0f5fa88..030d3ab7863 100644 --- a/gcc/config/sparc/sparc.h +++ b/gcc/config/sparc/sparc.h @@ -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 --git a/gcc/config/stormy16/stormy16.h b/gcc/config/stormy16/stormy16.h index 051914b31d2..b2472bc841f 100644 --- a/gcc/config/stormy16/stormy16.h +++ b/gcc/config/stormy16/stormy16.h @@ -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 --git a/gcc/config/svr3.h b/gcc/config/svr3.h index 21595eac273..b544abba91a 100644 --- a/gcc/config/svr3.h +++ b/gcc/config/svr3.h @@ -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 --git a/gcc/config/vax/t-memfuncs b/gcc/config/vax/t-memfuncs new file mode 100644 index 00000000000..6a8da6146b5 --- /dev/null +++ b/gcc/config/vax/t-memfuncs @@ -0,0 +1,3 @@ +LIB2FUNCS_EXTRA = \ + $(srcdir)/config/memcmp.c $(srcdir)/config/memcpy.c \ + $(srcdir)/config/memmove.c $(srcdir)/config/memset.c diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 625a6789672..c764ee800f7 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -5437,9 +5437,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. @@ -5447,9 +5447,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 --git a/gcc/doc/standards.texi b/gcc/doc/standards.texi index faa08e4a9f6..dcedc754f59 100644 --- a/gcc/doc/standards.texi +++ b/gcc/doc/standards.texi @@ -145,9 +145,7 @@ GNU C library). @xref{Standard Libraries,,Standard Libraries}. 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 --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 1b5de1b71cb..5cbff1c53d1 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -4811,17 +4811,6 @@ refers to the global ``variable'' @code{errno}. (On certain systems, 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 --git a/gcc/expr.c b/gcc/expr.c index efca348f547..3c15a7bde7a 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -77,14 +77,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #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, rtx size, unsigned int align) 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, rtx src, rtx size) 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, rtx src, rtx size) 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, rtx src, rtx size) 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, rtx size, unsigned int align) 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, rtx size) 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, rtx size) 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, rtx size) 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, int want_value) 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, int cleared, HOST_WIDE_INT size) 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, int cleared, HOST_WIDE_INT size) /* 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 --git a/gcc/libfuncs.h b/gcc/libfuncs.h index 1a9fe47490f..32cde82c185 100644 --- a/gcc/libfuncs.h +++ b/gcc/libfuncs.h @@ -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 --git a/gcc/optabs.c b/gcc/optabs.c index 1ef656d0eb1..021033113e5 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -3744,15 +3744,9 @@ prepare_cmp_insn (rtx *px, rtx *py, enum rtx_code *pcomparison, rtx size, 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 --git a/gcc/system.h b/gcc/system.h index 1c2bbbe78f7..90d906b3b3a 100644 --- a/gcc/system.h +++ b/gcc/system.h @@ -618,7 +618,7 @@ extern int snprintf (char *, size_t, const char *, ...); 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 \ -- 2.30.2