diff options
-rw-r--r-- | gcc/ChangeLog | 46 | ||||
-rw-r--r-- | gcc/Makefile.in | 2 | ||||
-rw-r--r-- | gcc/builtins.c | 25 | ||||
-rw-r--r-- | gcc/c-common.c | 2 | ||||
-rw-r--r-- | gcc/config/arm/arm.c | 6 | ||||
-rw-r--r-- | gcc/config/arm/arm.h | 10 | ||||
-rw-r--r-- | gcc/config/c4x/c4x-protos.h | 6 | ||||
-rw-r--r-- | gcc/config/c4x/c4x.c | 15 | ||||
-rw-r--r-- | gcc/config/c4x/c4x.h | 7 | ||||
-rw-r--r-- | gcc/config/i386/i386-protos.h | 1 | ||||
-rw-r--r-- | gcc/config/i386/i386.c | 18 | ||||
-rw-r--r-- | gcc/config/i386/i386.h | 15 | ||||
-rw-r--r-- | gcc/config/ia64/ia64.c | 6 | ||||
-rw-r--r-- | gcc/config/ia64/ia64.h | 7 | ||||
-rw-r--r-- | gcc/defaults.h | 8 | ||||
-rw-r--r-- | gcc/doc/tm.texi | 25 | ||||
-rw-r--r-- | gcc/expr.h | 3 | ||||
-rw-r--r-- | gcc/target-def.h | 8 | ||||
-rw-r--r-- | gcc/target.h | 13 |
19 files changed, 148 insertions, 75 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index abf5bd4..bd62dc4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,49 @@ +2001-07-09 Stan Shebs <shebs@apple.com> + + * target.h (struct gcc_target): New fields init_builtins and + expand_builtin. + * target-def.h (TARGET_INIT_BUILTINS): New macro. + (TARGET_EXPAND_BUILTIN): New macro. + (TARGET_INITIALIZER): Add them. + * builtins.c: Include target.h. + (expand_builtin): Use targetm.expand_builtin. + (default_init_builtins): New function. + (default_expand_builtin): New function. + * expr.h (default_init_builtins): Declare. + (default_expand_builtin): Declare. + * c-common.c (c_common_nodes_and_builtins): Use + targetm.init_builtins. + * defaults.h (MD_INIT_BUILTINS): Remove. + * Makefile.in (builtins.o): Depend on target.h. + + * config/arm/arm.c (TARGET_INIT_BUILTINS): Define. + (TARGET_EXPAND_BUILTIN): Define. + * config/arm/arm.h (MD_INIT_BUILTINS): Remove. + (MD_EXPAND_BUILTIN): Remove. + + * config/c4x/c4x.c (TARGET_INIT_BUILTINS): Define. + (TARGET_EXPAND_BUILTIN): Define. + (c4x_init_builtins): Make endlink arg a local. + (c4x_print_operand): Fix typos in adjust_address usages. + * config/c4x/c4x-protos.h (c4x_init_builtins): Update decl. + * config/c4x/c4x.h (MD_INIT_BUILTINS): Remove. + (MD_EXPAND_BUILTIN): Remove. + + * config/i386/i386.c (TARGET_INIT_BUILTINS): Define. + (TARGET_EXPAND_BUILTIN): Define. + (ix86_init_mmx_sse_builtins): New function, was ix86_init_builtins. + (ix86_init_builtins): Call new function only if TARGET_MMX. + * config/i386/i386-protos.h (ix86_init_mmx_sse_builtins): Declare. + * config/i386/i386.h (MD_INIT_BUILTINS): Remove. + (MD_EXPAND_BUILTIN): Remove. + + * config/ia64/ia64.c (TARGET_INIT_BUILTINS): Define. + (TARGET_EXPAND_BUILTIN): Define. + * config/ia64/ia64.h (MD_INIT_BUILTINS): Remove. + (MD_EXPAND_BUILTIN): Remove. + + * doc/tm.texi: Document these changes. + 2001-07-09 Diego Novillo <dnovillo@redhat.com> * basic-block.h (tree_node): Forward declare if needed. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index a2ef4e7..8d2fb1c 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1377,7 +1377,7 @@ expr.o : expr.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(TREE_H) flags.h function.h \ output.h typeclass.h hard-reg-set.h toplev.h hard-reg-set.h except.h \ reload.h $(GGC_H) intl.h $(TM_P_H) builtins.o : builtins.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(TREE_H) flags.h \ - function.h $(REGS_H) $(EXPR_H) insn-config.h \ + $(TARGET_H) function.h $(REGS_H) $(EXPR_H) insn-config.h \ $(RECOG_H) output.h typeclass.h hard-reg-set.h toplev.h hard-reg-set.h \ except.h $(TM_P_H) $(PREDICT_H) calls.o : calls.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(TREE_H) flags.h $(EXPR_H) \ diff --git a/gcc/builtins.c b/gcc/builtins.c index f6f76ba..0c84715 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -38,6 +38,7 @@ Boston, MA 02111-1307, USA. */ #include "toplev.h" #include "predict.h" #include "tm_p.h" +#include "target.h" #define CALLED_AS_BUILT_IN(NODE) \ (!strncmp (IDENTIFIER_POINTER (DECL_NAME (NODE)), "__builtin_", 10)) @@ -3401,10 +3402,8 @@ expand_builtin (exp, target, subtarget, mode, ignore) tree arglist = TREE_OPERAND (exp, 1); enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); -#ifdef MD_EXPAND_BUILTIN if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD) - return MD_EXPAND_BUILTIN (exp, target, subtarget, mode, ignore); -#endif + return (*targetm.expand_builtin) (exp, target, subtarget, mode, ignore); /* When not optimizing, generate calls to library functions for a certain set of builtins. */ @@ -3897,3 +3896,23 @@ validate_arglist VPARAMS ((tree arglist, ...)) arglist = TREE_CHAIN (arglist); } while (1); } + +/* Default version of target-specific builtin setup that does nothing. */ + +void +default_init_builtins () +{ +} + +/* Default target-specific builtin expander that does nothing. */ + +rtx +default_expand_builtin (exp, target, subtarget, mode, ignore) + tree exp ATTRIBUTE_UNUSED; + rtx target ATTRIBUTE_UNUSED; + rtx subtarget ATTRIBUTE_UNUSED; + enum machine_mode mode ATTRIBUTE_UNUSED; + int ignore ATTRIBUTE_UNUSED; +{ + return NULL_RTX; +} diff --git a/gcc/c-common.c b/gcc/c-common.c index f1ee8b1..0213843 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -3009,7 +3009,7 @@ c_common_nodes_and_builtins () c_language != clk_cplusplus) ? const_string_type_node : const_ptr_type_node); - MD_INIT_BUILTINS; + (*targetm.init_builtins) (); /* This is special for C++ so functions can be overloaded. */ wchar_type_node = get_identifier (flag_short_wchar diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 48f0c5f..35c520c 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -148,6 +148,12 @@ static void arm_set_default_type_attributes PARAMS ((tree)); #undef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES arm_set_default_type_attributes +#undef TARGET_INIT_BUILTINS +#define TARGET_INIT_BUILTINS arm_init_builtins + +#undef TARGET_EXPAND_BUILTIN +#define TARGET_EXPAND_BUILTIN arm_expand_builtin + struct gcc_target targetm = TARGET_INITIALIZER; /* Obstack for minipool constant handling. */ diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index 59884cd..143e1d4 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -2954,14 +2954,4 @@ enum arm_builtins ARM_BUILTIN_PREFETCH, ARM_BUILTIN_MAX }; - -#define MD_INIT_BUILTINS \ - do \ - { \ - arm_init_builtins (); \ - } \ - while (0) - -#define MD_EXPAND_BUILTIN(EXP, TARGET, SUBTARGET, MODE, IGNORE) \ - arm_expand_builtin ((EXP), (TARGET), (SUBTARGET), (MODE), (IGNORE)) #endif /* ! GCC_ARM_H */ diff --git a/gcc/config/c4x/c4x-protos.h b/gcc/config/c4x/c4x-protos.h index 44f47b6..99ce1cc 100644 --- a/gcc/config/c4x/c4x-protos.h +++ b/gcc/config/c4x/c4x-protos.h @@ -69,10 +69,10 @@ extern void c4x_va_start PARAMS ((int, tree, rtx)); extern struct rtx_def *c4x_va_arg PARAMS ((tree, tree)); -extern rtx c4x_expand_builtin PARAMS((tree, rtx, rtx, - enum machine_mode, int)); +extern rtx c4x_expand_builtin PARAMS ((tree, rtx, rtx, + enum machine_mode, int)); -extern void c4x_init_builtins PARAMS((tree)); +extern void c4x_init_builtins PARAMS ((void)); #endif /* TREE_CODE and RTX_CODE*/ diff --git a/gcc/config/c4x/c4x.c b/gcc/config/c4x/c4x.c index c0500be..02a3dcd 100644 --- a/gcc/config/c4x/c4x.c +++ b/gcc/config/c4x/c4x.c @@ -199,6 +199,12 @@ static void c4x_insert_attributes PARAMS ((tree, tree *)); #undef TARGET_INSERT_ATTRIBUTES #define TARGET_INSERT_ATTRIBUTES c4x_insert_attributes +#undef TARGET_INIT_BUILTINS +#define TARGET_INIT_BUILTINS c4x_init_builtins + +#undef TARGET_EXPAND_BUILTIN +#define TARGET_EXPAND_BUILTIN c4x_expand_builtin + struct gcc_target targetm = TARGET_INITIALIZER; /* Called to register all of our global variables with the garbage @@ -1925,7 +1931,7 @@ c4x_print_operand (file, op, letter) if (GET_CODE(op1) == CONST_INT || GET_CODE(op1) == SYMBOL_REF) { asm_fprintf (file, "\t%s\t@", TARGET_C3X ? "ldp" : "ldpk"); - output_address (XEXP (adjust_address (op, VOIDmodem, 1), 0)); + output_address (XEXP (adjust_address (op, VOIDmode, 1), 0)); asm_fprintf (file, "\n"); } } @@ -1947,7 +1953,7 @@ c4x_print_operand (file, op, letter) if (code == MEM && c4x_autoinc_operand (op, Pmode)) break; else if (code == MEM) - output_address (XEXP (adjust_address (op, 1), VOIDmode, 0)); + output_address (XEXP (adjust_address (op, VOIDmode, 1), 0)); else if (code == REG) fprintf (file, "%s", reg_names[REGNO (op) + 1]); else @@ -5037,9 +5043,10 @@ c4x_adjust_cost (insn, link, dep_insn, cost) } void -c4x_init_builtins (endlink) - tree endlink; +c4x_init_builtins () { + tree endlink = void_list_node; + builtin_function ("fast_ftoi", build_function_type (integer_type_node, diff --git a/gcc/config/c4x/c4x.h b/gcc/config/c4x/c4x.h index c515337..102346f 100644 --- a/gcc/config/c4x/c4x.h +++ b/gcc/config/c4x/c4x.h @@ -2744,10 +2744,3 @@ enum c4x_builtins C4X_BUILTIN_FRIEEE, /* frieee (only C4x) */ C4X_BUILTIN_RCPF /* fast_invf (only C4x) */ }; - -#define MD_INIT_BUILTINS do { \ - c4x_init_builtins (void_list_node); \ - } while (0) - -#define MD_EXPAND_BUILTIN(EXP, TARGET, SUBTARGET, MODE, IGNORE) \ - c4x_expand_builtin ((EXP), (TARGET), (SUBTARGET), (MODE), (IGNORE)) diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h index 78fcf3b..f98b95b 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -163,6 +163,7 @@ extern rtx function_arg PARAMS ((CUMULATIVE_ARGS *, enum machine_mode, tree, int extern void function_arg_advance PARAMS ((CUMULATIVE_ARGS *, enum machine_mode, tree, int)); extern void ix86_init_builtins PARAMS ((void)); +extern void ix86_init_mmx_sse_builtins PARAMS ((void)); extern rtx ix86_expand_builtin PARAMS ((tree, rtx, rtx, enum machine_mode, int)); #endif diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 4572849..9b32180 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -624,6 +624,12 @@ static int ix86_comp_type_attributes PARAMS ((tree, tree)); #undef TARGET_COMP_TYPE_ATTRIBUTES #define TARGET_COMP_TYPE_ATTRIBUTES ix86_comp_type_attributes +#undef TARGET_INIT_BUILTINS +#define TARGET_INIT_BUILTINS ix86_init_builtins + +#undef TARGET_EXPAND_BUILTIN +#define TARGET_EXPAND_BUILTIN ix86_expand_builtin + #if defined (OSF_OS) || defined (TARGET_OSF1ELF) static void ix86_osf_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT)); @@ -9340,11 +9346,19 @@ static struct builtin_description bdesc_1arg[] = }; -/* Expand all the target specific builtins. This is not called if TARGET_MMX +/* Set up all the target-specific builtins. */ +void +ix86_init_builtins () +{ + if (TARGET_MMX) + ix86_init_mmx_sse_builtins (); +} + +/* Set up all the MMX/SSE builtins. This is not called if TARGET_MMX is zero. Otherwise, if TARGET_SSE is not set, only expand the MMX builtins. */ void -ix86_init_builtins () +ix86_init_mmx_sse_builtins () { struct builtin_description * d; size_t i; diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index ee5b615..5869602 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -2176,21 +2176,6 @@ enum ix86_builtins IX86_BUILTIN_MAX }; - -/* Initialize the target-specific builtin functions. Only do something - if TARGET_MMX is nonzero; we take care in ix86_init_builtins not to - enable any SSE builtins if TARGET_SSE is zero. */ -#define MD_INIT_BUILTINS \ - do \ - { \ - if (TARGET_MMX) \ - ix86_init_builtins (); \ - } \ - while (0) - -/* Expand a target-specific builtin function. */ -#define MD_EXPAND_BUILTIN(EXP, TARGET, SUBTARGET, MODE, IGNORE) \ - ix86_expand_builtin (EXP, TARGET, SUBTARGET, MODE, IGNORE) /* Define this macro if references to a symbol must be treated differently depending on something about the variable or diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index a09a7b7..394c910 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -145,6 +145,12 @@ static void ia64_output_function_end_prologue PARAMS ((FILE *)); #undef TARGET_VALID_TYPE_ATTRIBUTE #define TARGET_VALID_TYPE_ATTRIBUTE ia64_valid_type_attribute +#undef TARGET_INIT_BUILTINS +#define TARGET_INIT_BUILTINS ia64_init_builtins + +#undef TARGET_EXPAND_BUILTIN +#define TARGET_EXPAND_BUILTIN ia64_expand_builtin + #undef TARGET_ASM_FUNCTION_PROLOGUE #define TARGET_ASM_FUNCTION_PROLOGUE ia64_output_function_prologue #undef TARGET_ASM_FUNCTION_END_PROLOGUE diff --git a/gcc/config/ia64/ia64.h b/gcc/config/ia64/ia64.h index e22aff3..218b9a0 100644 --- a/gcc/config/ia64/ia64.h +++ b/gcc/config/ia64/ia64.h @@ -2859,11 +2859,4 @@ enum fetchop_code { IA64_ADD_OP, IA64_SUB_OP, IA64_OR_OP, IA64_AND_OP, IA64_XOR_OP, IA64_NAND_OP }; -#define MD_INIT_BUILTINS do { \ - ia64_init_builtins (); \ - } while (0) - -#define MD_EXPAND_BUILTIN(EXP, TARGET, SUBTARGET, MODE, IGNORE) \ - ia64_expand_builtin ((EXP), (TARGET), (SUBTARGET), (MODE), (IGNORE)) - /* End of ia64.h */ diff --git a/gcc/defaults.h b/gcc/defaults.h index c22f9cd..a1001b9 100644 --- a/gcc/defaults.h +++ b/gcc/defaults.h @@ -364,12 +364,4 @@ do { \ #define TARGET_ALLOWS_PROFILING_WITHOUT_FRAME_POINTER true #endif -/* Define this macro if you have any machine-specific builtin - functions that need to be defined. It should be a C expression - that performs the necessary setup. */ - -#ifndef MD_INIT_BUILTINS -#define MD_INIT_BUILTINS -#endif - #endif /* ! GCC_DEFAULTS_H */ diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 665ce35..a06e47c 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -8663,10 +8663,9 @@ A C expression to cancel any machine dependent modifications in converting code to conditional execution in the basic blocks @code{TEST_BB}, @code{THEN_BB}, @code{ELSE_BB}, and @code{JOIN_BB}. -@findex MD_INIT_BUILTINS -@item MD_INIT_BUILTINS -Define this macro if you have any machine-specific built-in functions that -need to be defined. It should be a C expression that performs the +@deftypefn {Target Hook} void TARGET_INIT_BUILTINS () +Define this hook if you have any machine-specific built-in functions +that need to be defined. It should be a function that performs the necessary setup. Machine specific built-in functions can be useful to expand special machine @@ -8678,17 +8677,17 @@ To create a built-in function, call the function @code{builtin_function} which is defined by the language front end. You can use any type nodes set up by @code{build_common_tree_nodes} and @code{build_common_tree_nodes_2}; only language front ends that use these two functions will use -@samp{MD_INIT_BUILTINS}. +@samp{TARGET_INIT_BUILTINS}. -@findex MD_EXPAND_BUILTIN -@item MD_EXPAND_BUILTIN(@var{exp}, @var{target}, @var{subtarget}, @var{mode}, @var{ignore}) +@deftypefn {Target Hook} rtx TARGET_EXPAND_BUILTIN (tree @var{exp}, rtx @var{target}, rtx @var{subtarget}, enum machine_mode @var{mode}, int @var{ignore}) Expand a call to a machine specific built-in function that was set up by -@samp{MD_INIT_BUILTINS}. @var{exp} is the expression for the function call; -the result should go to @var{target} if that is convenient, and have mode -@var{mode} if that is convenient. @var{subtarget} may be used as the target -for computing one of @var{exp}'s operands. @var{ignore} is nonzero if the value -is to be ignored. -This macro should return the result of the call to the built-in function. +@samp{TARGET_INIT_BUILTINS}. @var{exp} is the expression for the +function call; the result should go to @var{target} if that is +convenient, and have mode @var{mode} if that is convenient. +@var{subtarget} may be used as the target for computing one of +@var{exp}'s operands. @var{ignore} is nonzero if the value is to be +ignored. This function should return the result of the call to the +built-in function. @end table @@ -907,6 +907,9 @@ extern rtx expand_builtin PARAMS ((tree, rtx, rtx, enum machine_mode, int)); extern void std_expand_builtin_va_start PARAMS ((int, tree, rtx)); extern rtx std_expand_builtin_va_arg PARAMS ((tree, tree)); extern rtx expand_builtin_va_arg PARAMS ((tree, tree)); +extern void default_init_builtins PARAMS ((void)); +extern rtx default_expand_builtin PARAMS ((tree, rtx, rtx, + enum machine_mode, int)); #endif extern void expand_builtin_setjmp_setup PARAMS ((rtx, rtx)); diff --git a/gcc/target-def.h b/gcc/target-def.h index ca24c5f..264d22b 100644 --- a/gcc/target-def.h +++ b/gcc/target-def.h @@ -49,6 +49,10 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES default_set_default_type_attributes #define TARGET_INSERT_ATTRIBUTES default_insert_attributes +/* In builtins.c. */ +#define TARGET_INIT_BUILTINS default_init_builtins +#define TARGET_EXPAND_BUILTIN default_expand_builtin + /* The whole shebang. */ #define TARGET_INITIALIZER \ { \ @@ -59,5 +63,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. TARGET_VALID_TYPE_ATTRIBUTE, \ TARGET_COMP_TYPE_ATTRIBUTES, \ TARGET_SET_DEFAULT_TYPE_ATTRIBUTES, \ - TARGET_INSERT_ATTRIBUTES \ + TARGET_INSERT_ATTRIBUTES, \ + TARGET_INIT_BUILTINS, \ + TARGET_EXPAND_BUILTIN \ } diff --git a/gcc/target.h b/gcc/target.h index 126147d..fdd0bb1 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -44,6 +44,9 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. to gradually reduce the amount of conditional compilation that is scattered throughout GCC. */ +/* Forward declaration for the benefit of prototypes. */ +struct rtx_def; + struct gcc_target { /* Functions that output assembler for the target. */ @@ -93,6 +96,16 @@ struct gcc_target /* Insert attributes on the newly created DECL. */ void (* insert_attributes) PARAMS ((tree decl, tree *attributes)); + + /* Set up target-specific built-in functions. */ + void (* init_builtins) PARAMS ((void)); + + /* Expand a target-specific builtin. */ + struct rtx_def * (* expand_builtin) PARAMS ((tree exp, + struct rtx_def *target, + struct rtx_def *subtarget, + enum machine_mode mode, + int ignore)); }; extern struct gcc_target targetm; |