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
This commit is contained in:
parent
f12bc141e1
commit
f45c9d956f
7 changed files with 92 additions and 74 deletions
|
@ -1,5 +1,21 @@
|
|||
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
|
||||
out check for wchar_t.
|
||||
* acconfig.h: Add template for ssize_t. Remove @TOP@.
|
||||
|
|
|
@ -981,7 +981,7 @@ expand_builtin_apply (function, arguments, argsize)
|
|||
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),
|
||||
const0_rtx, NULL_RTX, const0_rtx));
|
||||
|
||||
|
|
23
gcc/calls.c
23
gcc/calls.c
|
@ -435,12 +435,13 @@ emit_call_1 (funexp, fndecl, funtype, stack_size, rounded_stack_size,
|
|||
int ecf_flags;
|
||||
{
|
||||
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;
|
||||
int already_popped = 0;
|
||||
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,
|
||||
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,
|
|||
if possible, for the sake of frame pointer elimination. */
|
||||
|
||||
if (valreg)
|
||||
pat = gen_sibcall_value_pop (valreg,
|
||||
pat = GEN_SIBCALL_VALUE_POP (valreg,
|
||||
gen_rtx_MEM (FUNCTION_MODE, funexp),
|
||||
rounded_stack_size_rtx, next_arg_reg,
|
||||
n_pop);
|
||||
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);
|
||||
|
||||
emit_call_insn (pat);
|
||||
|
@ -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 (valreg)
|
||||
pat = gen_call_value_pop (valreg,
|
||||
pat = GEN_CALL_VALUE_POP (valreg,
|
||||
gen_rtx_MEM (FUNCTION_MODE, funexp),
|
||||
rounded_stack_size_rtx, next_arg_reg, n_pop);
|
||||
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);
|
||||
|
||||
emit_call_insn (pat);
|
||||
|
@ -512,12 +513,12 @@ emit_call_1 (funexp, fndecl, funtype, stack_size, rounded_stack_size,
|
|||
&& HAVE_sibcall && HAVE_sibcall_value)
|
||||
{
|
||||
if (valreg)
|
||||
emit_call_insn (gen_sibcall_value (valreg,
|
||||
emit_call_insn (GEN_SIBCALL_VALUE (valreg,
|
||||
gen_rtx_MEM (FUNCTION_MODE, funexp),
|
||||
rounded_stack_size_rtx,
|
||||
next_arg_reg, NULL_RTX));
|
||||
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,
|
||||
struct_value_size_rtx));
|
||||
}
|
||||
|
@ -528,12 +529,12 @@ emit_call_1 (funexp, fndecl, funtype, stack_size, rounded_stack_size,
|
|||
if (HAVE_call && HAVE_call_value)
|
||||
{
|
||||
if (valreg)
|
||||
emit_call_insn (gen_call_value (valreg,
|
||||
emit_call_insn (GEN_CALL_VALUE (valreg,
|
||||
gen_rtx_MEM (FUNCTION_MODE, funexp),
|
||||
rounded_stack_size_rtx, next_arg_reg,
|
||||
NULL_RTX));
|
||||
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,
|
||||
struct_value_size_rtx));
|
||||
}
|
||||
|
|
2
gcc/configure
vendored
2
gcc/configure
vendored
|
@ -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.
|
||||
# That's useful for people building cross-compilers, or just running a
|
||||
# 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"
|
||||
if test "x$GCC" = "xyes"; 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
|
|||
# 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
|
||||
# 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"
|
||||
if test "x$GCC" = "xyes"; 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
|
|||
determined automatically whether your compiler supports
|
||||
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
|
||||
@item PATH_SEPARATOR
|
||||
Define this macro to be a C character constant representing the
|
||||
|
|
112
gcc/genflags.c
112
gcc/genflags.c
|
@ -33,8 +33,8 @@ Boston, MA 02111-1307, USA. */
|
|||
#define obstack_chunk_alloc xmalloc
|
||||
#define obstack_chunk_free free
|
||||
|
||||
/* Obstacks to remember normal, and call insns. */
|
||||
static struct obstack call_obstack, normal_obstack;
|
||||
/* Obstack to remember insns with. */
|
||||
static struct obstack obstack;
|
||||
|
||||
/* Max size of names encountered. */
|
||||
static int max_id_len;
|
||||
|
@ -45,7 +45,7 @@ static int max_opno;
|
|||
static void max_operand_1 PARAMS ((rtx));
|
||||
static int num_operands 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));
|
||||
|
||||
/* Count the number of match_operand's found. */
|
||||
|
@ -98,6 +98,36 @@ num_operands (insn)
|
|||
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. */
|
||||
|
||||
static void
|
||||
|
@ -105,7 +135,28 @@ gen_proto (insn)
|
|||
rtx 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)
|
||||
printf ("void");
|
||||
|
@ -118,15 +169,7 @@ gen_proto (insn)
|
|||
}
|
||||
|
||||
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
|
||||
|
@ -135,7 +178,6 @@ gen_insn (insn)
|
|||
{
|
||||
const char *name = XSTR (insn, 0);
|
||||
const char *p;
|
||||
struct obstack *obstack_ptr;
|
||||
int len;
|
||||
|
||||
/* Don't mention instructions whose names are the null string
|
||||
|
@ -167,24 +209,7 @@ gen_insn (insn)
|
|||
printf (")\n");
|
||||
}
|
||||
|
||||
/* Save the current insn, so that we can later put out appropriate
|
||||
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));
|
||||
obstack_grow (&obstack, &insn, sizeof (rtx));
|
||||
}
|
||||
|
||||
extern int main PARAMS ((int, char **));
|
||||
|
@ -196,13 +221,11 @@ main (argc, argv)
|
|||
{
|
||||
rtx desc;
|
||||
rtx dummy;
|
||||
rtx *call_insns;
|
||||
rtx *normal_insns;
|
||||
rtx *insns;
|
||||
rtx *insn_ptr;
|
||||
|
||||
progname = "genflags";
|
||||
obstack_init (&call_obstack);
|
||||
obstack_init (&normal_obstack);
|
||||
obstack_init (&obstack);
|
||||
|
||||
if (argc <= 1)
|
||||
fatal ("No input file name.");
|
||||
|
@ -228,25 +251,12 @@ from the machine description file `md'. */\n\n");
|
|||
|
||||
/* Print out the prototypes now. */
|
||||
dummy = (rtx) 0;
|
||||
obstack_grow (&call_obstack, &dummy, sizeof (rtx));
|
||||
call_insns = (rtx *) obstack_finish (&call_obstack);
|
||||
obstack_grow (&obstack, &dummy, sizeof (rtx));
|
||||
insns = (rtx *) obstack_finish (&obstack);
|
||||
|
||||
obstack_grow (&normal_obstack, &dummy, sizeof (rtx));
|
||||
normal_insns = (rtx *) obstack_finish (&normal_obstack);
|
||||
|
||||
for (insn_ptr = normal_insns; *insn_ptr; insn_ptr++)
|
||||
for (insn_ptr = insns; *insn_ptr; 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);
|
||||
return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue