+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.
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) \
#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))
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. */
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;
+}
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
#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;
\f
/* Obstack for minipool constant handling. */
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 */
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*/
#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;
\f
/* Called to register all of our global variables with the garbage
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");
}
}
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
}
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,
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))
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
#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));
};
-/* 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;
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)
\f
/* Define this macro if references to a symbol must be treated
differently depending on something about the variable or
#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
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 */
#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 */
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
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
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));
#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 \
{ \
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 \
}
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. */
/* 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;