This patch refactors tree-ssa-operands.c by wrapping the global
variables into a class, and also removes unused code.
Just sending this for when Stage1 is back again.
I ran the testsuite and bootstraped in a x86_64 linux machine and
found no issues.
gcc/ChangeLog:
2020-04-22 Giuliano Belinassi
* tree-ssa-operands.c (build_virtual_operands): New class.
(operands_bitmap_obstack): Remove.
(n_initialized): Remove.
(build_uses): Move to build_virtual_operands class.
(build_vuse): Same as above.
(build_vdef): Same as above.
(verify_ssa_operands): Same as above.
(finalize_ssa_uses): Same as above.
(cleanup_build_arrays): Same as above.
(finalize_ssa_stmt_operands): Same as above.
(start_ssa_stmt_operands): Same as above.
(append_use): Same as above.
(append_vdef): Same as above.
(add_virtual_operand): Same as above.
(add_stmt_operand): Same as above.
(get_mem_ref_operands): Same as above.
(get_tmr_operands): Same as above.
(maybe_add_call_vops): Same as above.
(get_asm_stmt_operands): Same as above.
(get_expr_operands): Same as above.
(parse_ssa_operands): Same as above.
(finalize_ssa_defs): Same as above.
(build_ssa_operands): Same as above, plus create a C-like wrapper.
(update_stmt_operands): Create an instance of build_virtual_operands.
>From b860b39045e1b90319caa7c75ad189514e4a5641 Mon Sep 17 00:00:00 2001
From: Giuliano Belinassi
Date: Tue, 21 Apr 2020 19:38:37 -0300
Subject: [PATCH] [Stage1] Refactor tree-ssa-operands.c
Refactor tree-ssa-operands.c by wrapping the global
variables into a class, and also removes unused code.
gcc/ChangeLog:
2020-04-22 Giuliano Belinassi
* tree-ssa-operands.c (build_virtual_operands): New class.
(operands_bitmap_obstack): Remove.
(n_initialized): Remove.
(build_uses): Move to build_virtual_operands class.
(build_vuse): Same as above.
(build_vdef): Same as above.
(verify_ssa_operands): Same as above.
(finalize_ssa_uses): Same as above.
(cleanup_build_arrays): Same as above.
(finalize_ssa_stmt_operands): Same as above.
(start_ssa_stmt_operands): Same as above.
(append_use): Same as above.
(append_vdef): Same as above.
(add_virtual_operand): Same as above.
(add_stmt_operand): Same as above.
(get_mem_ref_operands): Same as above.
(get_tmr_operands): Same as above.
(maybe_add_call_vops): Same as above.
(get_asm_stmt_operands): Same as above.
(get_expr_operands): Same as above.
(parse_ssa_operands): Same as above.
(finalize_ssa_defs): Same as above.
(build_ssa_operands): Same as above, plus create a C-like wrapper.
(update_stmt_operands): Create an instance of build_virtual_operands.
---
gcc/tree-ssa-operands.c | 218 +++-
1 file changed, 150 insertions(+), 68 deletions(-)
diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c
index b525ee318a4..ae8734d17e2 100644
--- a/gcc/tree-ssa-operands.c
+++ b/gcc/tree-ssa-operands.c
@@ -99,23 +99,111 @@ along with GCC; see the file COPYING3. If not see
/* Operand is having its address taken. */
#define opf_address_taken (1 << 5)
-/* Array for building all the use operands. */
-static vec build_uses;
+/* Class containing temporary per-stmt state. */
-/* The built VDEF operand. */
-static tree build_vdef;
+class build_virtual_operands
+{
+ public:
+build_virtual_operands ()
+ {
+ build_uses.create (10);
+ build_vuse = NULL_TREE;
+ build_vdef = NULL_TREE;
+ }
+
+~build_virtual_operands ()
+ {
+ cleanup_build_arrays ();
+ build_uses.release ();
+ }
+
+/* Create an operands cache for STMT. */
+void build_ssa_operands (struct function *fn, gimple *stmt);
+
+/* Verifies SSA statement operands. */
+DEBUG_FUNCTION bool verify_ssa_operands (struct function *fn, gimple *stmt);
+
+ private:
+/* Array for building all the use operands. */
+vec build_uses;
+
+/* The built VDEF operand. */
+tree build_vdef;
+
+/* The built VUSE operand. */
+tree build_vuse;
+
+/* Takes elements from build_uses and turns them into use operands of STMT. */
+inline void finalize_ssa_uses (struct function *fn, gimple *stmt);
+
+/* Clear the in_list bits and empty the build array for VDEFs and
+ VUSEs. */
+inline void cleanup_build_arrays (void);
+
+/* Finalize all the build vectors, fill the new ones into INFO. */
+inline void finalize_ssa_stmt_operands (struct function *fn, gimple *stmt);
+
+/* Start the process of building up operands vectors in INFO. */
+inline void start_ssa_stmt_operands (void);
+
+/* Add USE_P to the list of pointers to operands. */
+inline void append_use (tree *use_p);
-/* The built VUSE operand. */
-static tree build_vuse;
+/* Add VAR to the set of variables that require a VDEF operator. */
+inline void append_vdef