Commit c395453c by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (struct language_function): Remove temp_name_counter.

	* cp-tree.h (struct language_function): Remove temp_name_counter.
	(temp_name_counter): Remove.
	(get_temp_name): Change prototype.
	(get_guard): New function.
	(get_guard_cond): Likewise.
	(set_guard): Likewise.
	* cvt.c (build_up_reference): Adjust call to get_temp_name.
	* decl.c (expand_static_init): Use get_guard and friends to
	implement guard variables.
	* decl2.c (get_temp_name): Assume that the variables created are
	always static.
	(get_sentry): Rename to ...
	(get_guard): ... this.  Implement new ABI guard	variables.
	(get_guard_bits): New function.
	(get_guard_cond): Likewise.
	(set_guard): Likewise.
	(start_static_initialization_or_destruction): Use them.
	(do_static_initialization): Replace sentry with guard throughout.
	(do_static_destruction): Likewise.
	* init.c (create_temporary_var): Add comment.

From-SVN: r34803
parent c1c8f8cc
2000-06-30 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (struct language_function): Remove temp_name_counter.
(temp_name_counter): Remove.
(get_temp_name): Change prototype.
(get_guard): New function.
(get_guard_cond): Likewise.
(set_guard): Likewise.
* cvt.c (build_up_reference): Adjust call to get_temp_name.
* decl.c (expand_static_init): Use get_guard and friends to
implement guard variables.
* decl2.c (get_temp_name): Assume that the variables created are
always static.
(get_sentry): Rename to ...
(get_guard): ... this. Implement new ABI guard variables.
(get_guard_bits): New function.
(get_guard_cond): Likewise.
(set_guard): Likewise.
(start_static_initialization_or_destruction): Use them.
(do_static_initialization): Replace sentry with guard throughout.
(do_static_destruction): Likewise.
* init.c (create_temporary_var): Add comment.
2000-06-29 Mark Mitchell <mark@codesourcery.com> 2000-06-29 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (flag_const_strings): Remove. * cp-tree.h (flag_const_strings): Remove.
......
...@@ -900,7 +900,6 @@ struct language_function ...@@ -900,7 +900,6 @@ struct language_function
int returns_value; int returns_value;
int returns_null; int returns_null;
int parms_stored; int parms_stored;
int temp_name_counter;
int in_function_try_handler; int in_function_try_handler;
int x_expanding_p; int x_expanding_p;
int name_declared; int name_declared;
...@@ -1004,11 +1003,6 @@ struct language_function ...@@ -1004,11 +1003,6 @@ struct language_function
#define vtbls_set_up_p cp_function_chain->vtbls_set_up_p #define vtbls_set_up_p cp_function_chain->vtbls_set_up_p
/* Used to help generate temporary names which are unique within
a function. Reset to 0 by start_function. */
#define temp_name_counter cp_function_chain->temp_name_counter
/* Non-zero if we should generate RTL for functions that we process. /* Non-zero if we should generate RTL for functions that we process.
When this is zero, we just accumulate tree structure, without When this is zero, we just accumulate tree structure, without
interacting with the back end. */ interacting with the back end. */
...@@ -4075,7 +4069,7 @@ extern tree constructor_name_full PARAMS ((tree)); ...@@ -4075,7 +4069,7 @@ extern tree constructor_name_full PARAMS ((tree));
extern tree constructor_name PARAMS ((tree)); extern tree constructor_name PARAMS ((tree));
extern void setup_vtbl_ptr PARAMS ((tree, tree)); extern void setup_vtbl_ptr PARAMS ((tree, tree));
extern void defer_fn PARAMS ((tree)); extern void defer_fn PARAMS ((tree));
extern tree get_temp_name PARAMS ((tree, int)); extern tree get_temp_name PARAMS ((tree));
extern void finish_anon_union PARAMS ((tree)); extern void finish_anon_union PARAMS ((tree));
extern tree finish_table PARAMS ((tree, tree, tree, int)); extern tree finish_table PARAMS ((tree, tree, tree, int));
extern void finish_builtin_type PARAMS ((tree, const char *, extern void finish_builtin_type PARAMS ((tree, const char *,
...@@ -4110,6 +4104,9 @@ extern tree handle_class_head PARAMS ((tree, tree, tree)); ...@@ -4110,6 +4104,9 @@ extern tree handle_class_head PARAMS ((tree, tree, tree));
extern tree lookup_arg_dependent PARAMS ((tree, tree, tree)); extern tree lookup_arg_dependent PARAMS ((tree, tree, tree));
extern void finish_static_data_member_decl PARAMS ((tree, tree, tree, int)); extern void finish_static_data_member_decl PARAMS ((tree, tree, tree, int));
extern tree build_artificial_parm PARAMS ((tree, tree)); extern tree build_artificial_parm PARAMS ((tree, tree));
extern tree get_guard PARAMS ((tree));
extern tree get_guard_cond PARAMS ((tree));
extern tree set_guard PARAMS ((tree));
/* in parse.y */ /* in parse.y */
extern void cp_parse_init PARAMS ((void)); extern void cp_parse_init PARAMS ((void));
......
...@@ -356,7 +356,7 @@ build_up_reference (type, arg, flags) ...@@ -356,7 +356,7 @@ build_up_reference (type, arg, flags)
/* Create a new temporary variable. */ /* Create a new temporary variable. */
tree targ = arg; tree targ = arg;
if (toplevel_bindings_p ()) if (toplevel_bindings_p ())
arg = get_temp_name (argtype, 1); arg = get_temp_name (argtype);
else else
{ {
arg = pushdecl (build_decl (VAR_DECL, NULL_TREE, argtype)); arg = pushdecl (build_decl (VAR_DECL, NULL_TREE, argtype));
......
...@@ -8572,19 +8572,19 @@ expand_static_init (decl, init) ...@@ -8572,19 +8572,19 @@ expand_static_init (decl, init)
else if (! toplevel_bindings_p ()) else if (! toplevel_bindings_p ())
{ {
/* Emit code to perform this initialization but once. */ /* Emit code to perform this initialization but once. */
tree temp;
tree if_stmt; tree if_stmt;
tree then_clause; tree then_clause;
tree assignment; tree assignment;
tree temp_init; tree guard;
tree guard_init;
/* Emit code to perform this initialization but once. This code /* Emit code to perform this initialization but once. This code
looks like: looks like:
static int temp = 0; static int guard = 0;
if (!temp) { if (!guard) {
// Do initialization. // Do initialization.
temp = 1; guard = 1;
// Register variable for destruction at end of program. // Register variable for destruction at end of program.
} }
...@@ -8602,14 +8602,13 @@ expand_static_init (decl, init) ...@@ -8602,14 +8602,13 @@ expand_static_init (decl, init)
In theory, this process should be thread-safe, too; multiple In theory, this process should be thread-safe, too; multiple
threads should not be able to initialize the variable more threads should not be able to initialize the variable more
than once. We don't yet attempt to ensure thread-safety. */ than once. We don't yet attempt to ensure thread-safety. */
temp = get_temp_name (integer_type_node, 1);
rest_of_decl_compilation (temp, NULL_PTR, 0, 0); /* Create the guard variable. */
guard = get_guard (decl);
/* Begin the conditional initialization. */ /* Begin the conditional initialization. */
if_stmt = begin_if_stmt (); if_stmt = begin_if_stmt ();
finish_if_stmt_cond (cp_build_binary_op (EQ_EXPR, temp, finish_if_stmt_cond (get_guard_cond (guard), if_stmt);
integer_zero_node),
if_stmt);
then_clause = begin_compound_stmt (/*has_no_scope=*/0); then_clause = begin_compound_stmt (/*has_no_scope=*/0);
/* Do the initialization itself. */ /* Do the initialization itself. */
...@@ -8631,16 +8630,16 @@ expand_static_init (decl, init) ...@@ -8631,16 +8630,16 @@ expand_static_init (decl, init)
the assignment to TEMP into a single expression, ensuring the assignment to TEMP into a single expression, ensuring
that when we call finish_expr_stmt the cleanups will not be that when we call finish_expr_stmt the cleanups will not be
run until after TEMP is set to 1. */ run until after TEMP is set to 1. */
temp_init = build_modify_expr (temp, NOP_EXPR, integer_one_node); guard_init = set_guard (guard);
if (assignment) if (assignment)
{ {
assignment = tree_cons (NULL_TREE, assignment, assignment = tree_cons (NULL_TREE, assignment,
build_tree_list (NULL_TREE, build_tree_list (NULL_TREE,
temp_init)); guard_init));
assignment = build_compound_expr (assignment); assignment = build_compound_expr (assignment);
} }
else else
assignment = temp_init; assignment = guard_init;
finish_expr_stmt (assignment); finish_expr_stmt (assignment);
/* Use atexit to register a function for destroying this static /* Use atexit to register a function for destroying this static
......
...@@ -2729,6 +2729,8 @@ build_vec_delete_1 (base, maxindex, type, auto_delete_vec, use_global_delete) ...@@ -2729,6 +2729,8 @@ build_vec_delete_1 (base, maxindex, type, auto_delete_vec, use_global_delete)
return cp_convert (void_type_node, body); return cp_convert (void_type_node, body);
} }
/* Create an unnamed variable of the indicated TYPE. */
tree tree
create_temporary_var (type) create_temporary_var (type)
tree type; tree type;
......
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