Commit f45c9d95 by Zack Weinberg Committed by Zack Weinberg

configure.in (stage1_warn_cflags): Add -Wstrict-prototypes -Wmissing-prototypes.

	* configure.in (stage1_warn_cflags): Add -Wstrict-prototypes
	-Wmissing-prototypes.
	* configure: Regenerate.
	* gcc.texi: Remove explanation of MD_CALL_PROTOTYPES.

	* builtins.c, calls.c: Change all instances of gen_call_* or
	gen_sibcall_* to GEN_CALL_* and GEN_SIBCALL_*.
	* calls.c (struct_value_size_rtx): Separate definition from
	initialization to avoid unused variable warning.

	* genflags.c (gen_macro): New function.
	(gen_proto): Call it for gen_call_* and gen_sibcall_*.
	(gen_nonproto): Delete.
	(gen_insn): Put all insns on the same obstack.
	(main): Generate prototypes for everything unconditionally.

From-SVN: r34213
parent f12bc141
2000-05-27 Zack Weinberg <zack@wolery.cumb.org> 2000-05-27 Zack Weinberg <zack@wolery.cumb.org>
* configure.in (stage1_warn_cflags): Add -Wstrict-prototypes
-Wmissing-prototypes.
* configure: Regenerate.
* gcc.texi: Remove explanation of MD_CALL_PROTOTYPES.
* builtins.c, calls.c: Change all instances of gen_call_* or
gen_sibcall_* to GEN_CALL_* and GEN_SIBCALL_*.
* calls.c (struct_value_size_rtx): Separate definition from
initialization to avoid unused variable warning.
* genflags.c (gen_macro): New function.
(gen_proto): Call it for gen_call_* and gen_sibcall_*.
(gen_nonproto): Delete.
(gen_insn): Put all insns on the same obstack.
(main): Generate prototypes for everything unconditionally.
* configure.in: Add AC_CHECK_TYPE(ssize_t). Remove commented * configure.in: Add AC_CHECK_TYPE(ssize_t). Remove commented
out check for wchar_t. out check for wchar_t.
* acconfig.h: Add template for ssize_t. Remove @TOP@. * acconfig.h: Add template for ssize_t. Remove @TOP@.
...@@ -981,7 +981,7 @@ expand_builtin_apply (function, arguments, argsize) ...@@ -981,7 +981,7 @@ expand_builtin_apply (function, arguments, argsize)
valreg = gen_rtx_REG (mode, regno); valreg = gen_rtx_REG (mode, regno);
} }
emit_call_insn (gen_call_value (valreg, emit_call_insn (GEN_CALL_VALUE (valreg,
gen_rtx_MEM (FUNCTION_MODE, function), gen_rtx_MEM (FUNCTION_MODE, function),
const0_rtx, NULL_RTX, const0_rtx)); const0_rtx, NULL_RTX, const0_rtx));
......
...@@ -435,12 +435,13 @@ emit_call_1 (funexp, fndecl, funtype, stack_size, rounded_stack_size, ...@@ -435,12 +435,13 @@ emit_call_1 (funexp, fndecl, funtype, stack_size, rounded_stack_size,
int ecf_flags; int ecf_flags;
{ {
rtx rounded_stack_size_rtx = GEN_INT (rounded_stack_size); rtx rounded_stack_size_rtx = GEN_INT (rounded_stack_size);
#if defined (HAVE_call) && defined (HAVE_call_value)
rtx struct_value_size_rtx = GEN_INT (struct_value_size);
#endif
rtx call_insn; rtx call_insn;
int already_popped = 0; int already_popped = 0;
HOST_WIDE_INT n_popped = RETURN_POPS_ARGS (fndecl, funtype, stack_size); HOST_WIDE_INT n_popped = RETURN_POPS_ARGS (fndecl, funtype, stack_size);
#if defined (HAVE_call) && defined (HAVE_call_value)
rtx struct_value_size_rtx;
struct_value_size_rtx = GEN_INT (struct_value_size);
#endif
/* Ensure address is valid. SYMBOL_REF is already valid, so no need, /* Ensure address is valid. SYMBOL_REF is already valid, so no need,
and we don't want to load it into a register as an optimization, and we don't want to load it into a register as an optimization,
...@@ -461,12 +462,12 @@ emit_call_1 (funexp, fndecl, funtype, stack_size, rounded_stack_size, ...@@ -461,12 +462,12 @@ emit_call_1 (funexp, fndecl, funtype, stack_size, rounded_stack_size,
if possible, for the sake of frame pointer elimination. */ if possible, for the sake of frame pointer elimination. */
if (valreg) if (valreg)
pat = gen_sibcall_value_pop (valreg, pat = GEN_SIBCALL_VALUE_POP (valreg,
gen_rtx_MEM (FUNCTION_MODE, funexp), gen_rtx_MEM (FUNCTION_MODE, funexp),
rounded_stack_size_rtx, next_arg_reg, rounded_stack_size_rtx, next_arg_reg,
n_pop); n_pop);
else else
pat = gen_sibcall_pop (gen_rtx_MEM (FUNCTION_MODE, funexp), pat = GEN_SIBCALL_POP (gen_rtx_MEM (FUNCTION_MODE, funexp),
rounded_stack_size_rtx, next_arg_reg, n_pop); rounded_stack_size_rtx, next_arg_reg, n_pop);
emit_call_insn (pat); emit_call_insn (pat);
...@@ -494,11 +495,11 @@ emit_call_1 (funexp, fndecl, funtype, stack_size, rounded_stack_size, ...@@ -494,11 +495,11 @@ emit_call_1 (funexp, fndecl, funtype, stack_size, rounded_stack_size,
if possible, for the sake of frame pointer elimination. */ if possible, for the sake of frame pointer elimination. */
if (valreg) if (valreg)
pat = gen_call_value_pop (valreg, pat = GEN_CALL_VALUE_POP (valreg,
gen_rtx_MEM (FUNCTION_MODE, funexp), gen_rtx_MEM (FUNCTION_MODE, funexp),
rounded_stack_size_rtx, next_arg_reg, n_pop); rounded_stack_size_rtx, next_arg_reg, n_pop);
else else
pat = gen_call_pop (gen_rtx_MEM (FUNCTION_MODE, funexp), pat = GEN_CALL_POP (gen_rtx_MEM (FUNCTION_MODE, funexp),
rounded_stack_size_rtx, next_arg_reg, n_pop); rounded_stack_size_rtx, next_arg_reg, n_pop);
emit_call_insn (pat); emit_call_insn (pat);
...@@ -512,12 +513,12 @@ emit_call_1 (funexp, fndecl, funtype, stack_size, rounded_stack_size, ...@@ -512,12 +513,12 @@ emit_call_1 (funexp, fndecl, funtype, stack_size, rounded_stack_size,
&& HAVE_sibcall && HAVE_sibcall_value) && HAVE_sibcall && HAVE_sibcall_value)
{ {
if (valreg) if (valreg)
emit_call_insn (gen_sibcall_value (valreg, emit_call_insn (GEN_SIBCALL_VALUE (valreg,
gen_rtx_MEM (FUNCTION_MODE, funexp), gen_rtx_MEM (FUNCTION_MODE, funexp),
rounded_stack_size_rtx, rounded_stack_size_rtx,
next_arg_reg, NULL_RTX)); next_arg_reg, NULL_RTX));
else else
emit_call_insn (gen_sibcall (gen_rtx_MEM (FUNCTION_MODE, funexp), emit_call_insn (GEN_SIBCALL (gen_rtx_MEM (FUNCTION_MODE, funexp),
rounded_stack_size_rtx, next_arg_reg, rounded_stack_size_rtx, next_arg_reg,
struct_value_size_rtx)); struct_value_size_rtx));
} }
...@@ -528,12 +529,12 @@ emit_call_1 (funexp, fndecl, funtype, stack_size, rounded_stack_size, ...@@ -528,12 +529,12 @@ emit_call_1 (funexp, fndecl, funtype, stack_size, rounded_stack_size,
if (HAVE_call && HAVE_call_value) if (HAVE_call && HAVE_call_value)
{ {
if (valreg) if (valreg)
emit_call_insn (gen_call_value (valreg, emit_call_insn (GEN_CALL_VALUE (valreg,
gen_rtx_MEM (FUNCTION_MODE, funexp), gen_rtx_MEM (FUNCTION_MODE, funexp),
rounded_stack_size_rtx, next_arg_reg, rounded_stack_size_rtx, next_arg_reg,
NULL_RTX)); NULL_RTX));
else else
emit_call_insn (gen_call (gen_rtx_MEM (FUNCTION_MODE, funexp), emit_call_insn (GEN_CALL (gen_rtx_MEM (FUNCTION_MODE, funexp),
rounded_stack_size_rtx, next_arg_reg, rounded_stack_size_rtx, next_arg_reg,
struct_value_size_rtx)); struct_value_size_rtx));
} }
......
...@@ -1362,7 +1362,7 @@ echo "$ac_t"$ac_cv_prog_cc_no_long_long 1>&6 ...@@ -1362,7 +1362,7 @@ echo "$ac_t"$ac_cv_prog_cc_no_long_long 1>&6
# If the native compiler is GCC, we can enable warnings even in stage1. # If the native compiler is GCC, we can enable warnings even in stage1.
# That's useful for people building cross-compilers, or just running a # That's useful for people building cross-compilers, or just running a
# quick `make'. # quick `make'.
stage1_warn_cflags=" -W -Wall -Wtraditional -Wwrite-strings" stage1_warn_cflags=" -W -Wall -Wtraditional -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes"
stage2_warn_cflags="$stage1_warn_cflags -pedantic -Wno-long-long" stage2_warn_cflags="$stage1_warn_cflags -pedantic -Wno-long-long"
if test "x$GCC" = "xyes"; then if test "x$GCC" = "xyes"; then
if test $ac_cv_prog_cc_no_long_long = yes; then if test $ac_cv_prog_cc_no_long_long = yes; then
......
...@@ -342,7 +342,7 @@ echo "$ac_t"$ac_cv_prog_cc_no_long_long 1>&6 ...@@ -342,7 +342,7 @@ echo "$ac_t"$ac_cv_prog_cc_no_long_long 1>&6
# If the native compiler is GCC, we can enable warnings even in stage1. # If the native compiler is GCC, we can enable warnings even in stage1.
# That's useful for people building cross-compilers, or just running a # That's useful for people building cross-compilers, or just running a
# quick `make'. # quick `make'.
stage1_warn_cflags=" -W -Wall -Wtraditional -Wwrite-strings" stage1_warn_cflags=" -W -Wall -Wtraditional -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes"
stage2_warn_cflags="$stage1_warn_cflags -pedantic -Wno-long-long" stage2_warn_cflags="$stage1_warn_cflags -pedantic -Wno-long-long"
if test "x$GCC" = "xyes"; then if test "x$GCC" = "xyes"; then
if test $ac_cv_prog_cc_no_long_long = yes; then if test $ac_cv_prog_cc_no_long_long = yes; then
......
...@@ -3911,15 +3911,6 @@ GCC. If @samp{USE_PROTOTYPES} is not defined, it will be ...@@ -3911,15 +3911,6 @@ GCC. If @samp{USE_PROTOTYPES} is not defined, it will be
determined automatically whether your compiler supports determined automatically whether your compiler supports
prototypes by checking if @samp{__STDC__} is defined. prototypes by checking if @samp{__STDC__} is defined.
@findex MD_CALL_PROTOTYPES
@item MD_CALL_PROTOTYPES
Define this if you wish to generate prototypes for the @code{gen_call}
or @code{gen_call_value} functions generated from the machine
description file. If @samp{USE_PROTOTYPES} is defined to be 0, or the
host compiler does not support prototypes, this macro has no effect. As
soon as all of the machine descriptions are modified to have the
appropriate number of arguments, this macro will be removed.
@findex PATH_SEPARATOR @findex PATH_SEPARATOR
@item PATH_SEPARATOR @item PATH_SEPARATOR
Define this macro to be a C character constant representing the Define this macro to be a C character constant representing the
......
...@@ -33,8 +33,8 @@ Boston, MA 02111-1307, USA. */ ...@@ -33,8 +33,8 @@ Boston, MA 02111-1307, USA. */
#define obstack_chunk_alloc xmalloc #define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free #define obstack_chunk_free free
/* Obstacks to remember normal, and call insns. */ /* Obstack to remember insns with. */
static struct obstack call_obstack, normal_obstack; static struct obstack obstack;
/* Max size of names encountered. */ /* Max size of names encountered. */
static int max_id_len; static int max_id_len;
...@@ -45,7 +45,7 @@ static int max_opno; ...@@ -45,7 +45,7 @@ static int max_opno;
static void max_operand_1 PARAMS ((rtx)); static void max_operand_1 PARAMS ((rtx));
static int num_operands PARAMS ((rtx)); static int num_operands PARAMS ((rtx));
static void gen_proto PARAMS ((rtx)); static void gen_proto PARAMS ((rtx));
static void gen_nonproto PARAMS ((rtx)); static void gen_macro PARAMS ((const char *, int, int));
static void gen_insn PARAMS ((rtx)); static void gen_insn PARAMS ((rtx));
/* Count the number of match_operand's found. */ /* Count the number of match_operand's found. */
...@@ -98,6 +98,36 @@ num_operands (insn) ...@@ -98,6 +98,36 @@ num_operands (insn)
return max_opno + 1; return max_opno + 1;
} }
/* Print out a wrapper macro for a function which corrects the number
of arguments it takes. Any missing arguments are assumed to be at
the end. */
static void
gen_macro (name, real, expect)
const char *name;
int real, expect;
{
int i;
if (real > expect)
abort ();
if (real == 0)
abort ();
/* #define GEN_CALL(A, B, C, D) gen_call((A), (B)) */
fputs ("#define GEN_", stdout);
for (i = 0; name[i]; i++)
putchar (TOUPPER (name[i]));
putchar('(');
for (i = 0; i < expect - 1; i++)
printf ("%c, ", i + 'A');
printf ("%c) gen_%s (", i + 'A', name);
for (i = 0; i < real - 1; i++)
printf ("(%c), ", i + 'A');
printf ("(%c))\n", i + 'A');
}
/* Print out prototype information for a function. */ /* Print out prototype information for a function. */
static void static void
...@@ -105,7 +135,28 @@ gen_proto (insn) ...@@ -105,7 +135,28 @@ gen_proto (insn)
rtx insn; rtx insn;
{ {
int num = num_operands (insn); int num = num_operands (insn);
printf ("extern rtx gen_%-*s PARAMS ((", max_id_len, XSTR (insn, 0)); const char *name = XSTR (insn, 0);
/* Many md files don't refer to the last two operands passed to the
call patterns. This means their generator functions will be two
arguments too short. Instead of changing every md file to touch
those operands, we wrap the prototypes in macros that take the
correct number of arguments. */
if (name[0] == 'c' || name[0] == 's')
{
if (!strcmp (name, "call")
|| !strcmp (name, "call_pop")
|| !strcmp (name, "sibcall")
|| !strcmp (name, "sibcall_pop"))
gen_macro (name, num, 4);
else if (!strcmp (name, "call_value")
|| !strcmp (name, "call_value_pop")
|| !strcmp (name, "sibcall_value")
|| !strcmp (name, "sibcall_value_pop"))
gen_macro (name, num, 5);
}
printf ("extern rtx gen_%-*s PARAMS ((", max_id_len, name);
if (num == 0) if (num == 0)
printf ("void"); printf ("void");
...@@ -118,15 +169,7 @@ gen_proto (insn) ...@@ -118,15 +169,7 @@ gen_proto (insn)
} }
printf ("));\n"); printf ("));\n");
}
/* Print out a function declaration without a prototype. */
static void
gen_nonproto (insn)
rtx insn;
{
printf ("extern rtx gen_%s ();\n", XSTR (insn, 0));
} }
static void static void
...@@ -135,7 +178,6 @@ gen_insn (insn) ...@@ -135,7 +178,6 @@ gen_insn (insn)
{ {
const char *name = XSTR (insn, 0); const char *name = XSTR (insn, 0);
const char *p; const char *p;
struct obstack *obstack_ptr;
int len; int len;
/* Don't mention instructions whose names are the null string /* Don't mention instructions whose names are the null string
...@@ -167,24 +209,7 @@ gen_insn (insn) ...@@ -167,24 +209,7 @@ gen_insn (insn)
printf (")\n"); printf (")\n");
} }
/* Save the current insn, so that we can later put out appropriate obstack_grow (&obstack, &insn, sizeof (rtx));
prototypes. At present, most md files have the wrong number of
arguments for the call insns (call, call_value, call_pop,
call_value_pop) ignoring the extra arguments that are passed for
some machines, so by default, turn off the prototype. */
obstack_ptr = ((name[0] == 'c' || name[0] == 's')
&& (!strcmp (name, "call")
|| !strcmp (name, "call_value")
|| !strcmp (name, "call_pop")
|| !strcmp (name, "call_value_pop")
|| !strcmp (name, "sibcall")
|| !strcmp (name, "sibcall_value")
|| !strcmp (name, "sibcall_pop")
|| !strcmp (name, "sibcall_value_pop")))
? &call_obstack : &normal_obstack;
obstack_grow (obstack_ptr, &insn, sizeof (rtx));
} }
extern int main PARAMS ((int, char **)); extern int main PARAMS ((int, char **));
...@@ -196,13 +221,11 @@ main (argc, argv) ...@@ -196,13 +221,11 @@ main (argc, argv)
{ {
rtx desc; rtx desc;
rtx dummy; rtx dummy;
rtx *call_insns; rtx *insns;
rtx *normal_insns;
rtx *insn_ptr; rtx *insn_ptr;
progname = "genflags"; progname = "genflags";
obstack_init (&call_obstack); obstack_init (&obstack);
obstack_init (&normal_obstack);
if (argc <= 1) if (argc <= 1)
fatal ("No input file name."); fatal ("No input file name.");
...@@ -228,25 +251,12 @@ from the machine description file `md'. */\n\n"); ...@@ -228,25 +251,12 @@ from the machine description file `md'. */\n\n");
/* Print out the prototypes now. */ /* Print out the prototypes now. */
dummy = (rtx) 0; dummy = (rtx) 0;
obstack_grow (&call_obstack, &dummy, sizeof (rtx)); obstack_grow (&obstack, &dummy, sizeof (rtx));
call_insns = (rtx *) obstack_finish (&call_obstack); insns = (rtx *) obstack_finish (&obstack);
obstack_grow (&normal_obstack, &dummy, sizeof (rtx)); for (insn_ptr = insns; *insn_ptr; insn_ptr++)
normal_insns = (rtx *) obstack_finish (&normal_obstack);
for (insn_ptr = normal_insns; *insn_ptr; insn_ptr++)
gen_proto (*insn_ptr); gen_proto (*insn_ptr);
printf ("\n#ifdef MD_CALL_PROTOTYPES\n");
for (insn_ptr = call_insns; *insn_ptr; insn_ptr++)
gen_proto (*insn_ptr);
printf ("\n#else /* !MD_CALL_PROTOTYPES */\n");
for (insn_ptr = call_insns; *insn_ptr; insn_ptr++)
gen_nonproto (*insn_ptr);
printf ("#endif /* !MD_CALL_PROTOTYPES */\n");
fflush (stdout); fflush (stdout);
return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE); return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment