PATCH for global register error message
Andrew Haley
aph@pasanda.cygnus.co.uk
Fri Oct 22 06:34:00 GMT 1999
This patch moves the error checking for global register variables from
varasm to regclass. The reason for this is that the C++ front end may
define some functions before parsing any source, thus making it
impossible to declare any global register variables; better to defer
the checking until registers are allocated.
Andrew.
Fri Oct 22 14:30:30 1999 Andrew Haley <aph@cygnus.com>
* varasm.c (function_defined): Remove.
(make_function_rtl): Don't set function_defined.
(make_decl_rtl): Remove global register warning.
* regclass.c (no_global_reg_vars): New variable.
(globalize_reg): Warn if function has already been defined.
(regclass_init): Set no_global_reg_vars.
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/varasm.c,v
retrieving revision 1.84
diff -p -r1.84 varasm.c
*** varasm.c 1999/10/03 16:47:52 1.84
--- varasm.c 1999/10/22 13:23:58
*************** int size_directive_output;
*** 149,158 ****
tree last_assemble_variable_decl;
- /* Nonzero if at least one function definition has been seen. */
-
- static int function_defined;
-
static const char *strip_reg_name PROTO((const char *));
static int contains_pointers_p PROTO((tree));
static void decode_addr_const PROTO((tree, struct addr_const *));
--- 149,154 ----
*************** make_function_rtl (decl)
*** 579,587 ****
ENCODE_SECTION_INFO (decl);
#endif
}
-
- /* Record at least one function has been defined. */
- function_defined = 1;
}
/* Given NAME, a putative register name, discard any customary prefixes. */
--- 575,580 ----
*************** make_decl_rtl (decl, asmspec, top_level)
*** 729,737 ****
DECL_INITIAL (decl) = 0;
error ("global register variable has initial value");
}
- if (fixed_regs[reg_number] == 0
- && function_defined && top_level)
- error ("global register variable follows a function definition");
if (TREE_THIS_VOLATILE (decl))
warning ("volatile register variables don't work as you might wish");
--- 722,727 ----
Index: regclass.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/regclass.c,v
retrieving revision 1.63
diff -p -r1.63 regclass.c
*** regclass.c 1999/10/01 10:00:25 1.63
--- regclass.c 1999/10/22 13:23:59
*************** struct reg_info_data {
*** 213,219 ****
--- 213,224 ----
static struct reg_info_data *reg_info_head;
+ /* No more global register vairiables may be declared; true once
+ regclass has been initialized. */
+ static int no_global_reg_vars = 0;
+
+
/* Function called only once to initialize the above data on reg usage.
Once this is done, various switches may override. */
*************** void
*** 615,620 ****
--- 620,628 ----
globalize_reg (i)
int i;
{
+ if (no_global_reg_vars)
+ error ("global register variable follows a function definition");
+
if (global_regs[i])
{
warning ("register used for two global register variables");
*************** regclass_init ()
*** 743,748 ****
--- 751,759 ----
/* This prevents dump_flow_info from losing if called
before regclass is run. */
prefclass = 0;
+
+ /* No more global register vairiables may be declared. */
+ no_global_reg_vars = 1;
}
/* Subroutine of regclass, processes one insn INSN. Scan it and record each
More information about the Gcc-patches
mailing list