diff mbox series

[Stage1] Refactor tree-ssa-operands.c

Message ID 20200422183958.tbdu77enaazwpqxx@smtp.gmail.com
State New
Headers show
Series [Stage1] Refactor tree-ssa-operands.c | expand

Commit Message

Giuliano Belinassi April 22, 2020, 6:39 p.m. UTC
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  <giuliano.belinassi@usp.br>

	* 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.

Comments

Richard Biener April 23, 2020, 9:17 a.m. UTC | #1
On Wed, Apr 22, 2020 at 8:40 PM Giuliano Belinassi
<giuliano.belinassi@usp.br> wrote:
>
> 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.

First of all thanks for doing this.  I have a few editorial suggestions
about the class setup - first the name build_virtual_operands is
badly chosen, I prefer operand_scanner.  Second I suggest to
have the CTOR take the invariants as arguments which is the
stmt we operate on and its containing function.  Thus,

  operand_scanner (function *, gimple *);

which makes passing those down functions unnecessary.

Since build_vuses is now a member and allocated for each stmt
which would be a regression I'd suggest to use an auto_vec
with some pre-allocated storage, thus change it to

  auto_vec<tree *, 16> build_uses;

that also makes the destructor trivial (please simply remove
cleanup_build_arrays).  I guess there's further possibilities
for streamlining the initialization/teardown process but that's
better done as followup.

Otherwise the change looks OK to me.

Thanks,
Richard.

> gcc/ChangeLog:
> 2020-04-22  Giuliano Belinassi  <giuliano.belinassi@usp.br>
>
>         * 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.
Giuliano Belinassi April 23, 2020, 11:29 p.m. UTC | #2
Hi, Thank you for your quick review :)

This patch refactors tree-ssa-operands.c by wrapping the global
variables into a class, and also removes unused code.

In this version, we now move struct function and gimple stmt
arguments previously in the methods to the object constructor,
so that we avoid passing down these values to every function.

Bootstrapped and ran the testsuite in Linux x86_64.

gcc/ChangeLog:
2020-04-23  Giuliano Belinassi  <giuliano.belinassi@usp.br>

	* tree-ssa-operands.c (operands_scanner): New class.
	(operands_bitmap_obstack): Remove.
	(n_initialized): Remove.
	(build_uses): Move to operands_scanner 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 operands_scanner.
Martin Sebor April 27, 2020, 4:23 p.m. UTC | #3
On 4/22/20 12:39 PM, Giuliano Belinassi via Gcc-patches wrote:
> This patch refactors tree-ssa-operands.c by wrapping the global
> variables into a class, and also removes unused code.

Just a few comments on this nice cleanup:

It looks to me like class build_virtual_operands isn't safe to copy
or assign due its vec member.  If that's correct, can you please
either disable copying and assignments for such classes or make sure
they can be?  (The macro DISABLE_COPY_AND_ASSIGN will do the former.)

I would also suggest to avoid declaring member functions inline.
It serves no purpose if the function is also defined inline later
on and  causes problems when it isn't (e.g., when the definition
is moved to a .cc file).

Finally, as a purely cosmetic improvement, although it's benign
the void parameter in a parameter list can be omitted in C++.

Martin

> 
> 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  <giuliano.belinassi@usp.br>
> 
> 	* 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.
>
Giuliano Belinassi May 4, 2020, 10 p.m. UTC | #4
Hi,

This patch Refactors tree-ssa-operands.c by wrapping the global
variables into a class, and also removes unused code.

The difference between this version and v2 is:
  * Disable the copy of operands_scanner
  * remove void from empty arguments functions.


gcc/ChangeLog:
2020-05-04  Giuliano Belinassi  <giuliano.belinassi@usp.br>

	* tree-ssa-operands.c (operands_scanner): New class.
	(operands_bitmap_obstack): Remove.
	(n_initialized): Remove.
	(build_uses): Move to operands_scanner 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 operands_scanner.
Richard Biener May 5, 2020, 12:57 p.m. UTC | #5
On Tue, May 5, 2020 at 12:00 AM Giuliano Belinassi
<giuliano.belinassi@usp.br> wrote:
>
> Hi,
>
> This patch Refactors tree-ssa-operands.c by wrapping the global
> variables into a class, and also removes unused code.
>
> The difference between this version and v2 is:
>   * Disable the copy of operands_scanner
>   * remove void from empty arguments functions.

This variant is OK for master if it passed bootstrap and regtest.

Thanks!
Richard.

>
> gcc/ChangeLog:
> 2020-05-04  Giuliano Belinassi  <giuliano.belinassi@usp.br>
>
>         * tree-ssa-operands.c (operands_scanner): New class.
>         (operands_bitmap_obstack): Remove.
>         (n_initialized): Remove.
>         (build_uses): Move to operands_scanner 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 operands_scanner.
Li, Pan2 via Gcc-patches May 7, 2020, 5:46 p.m. UTC | #6
On Mon, 2020-05-04 at 19:00 -0300, Giuliano Belinassi via Gcc-patches wrote:
> Hi,
> 
> This patch Refactors tree-ssa-operands.c by wrapping the global
> variables into a class, and also removes unused code.
> 
> The difference between this version and v2 is:
>   * Disable the copy of operands_scanner
>   * remove void from empty arguments functions.
> 
> 
> gcc/ChangeLog:
> 2020-05-04  Giuliano Belinassi  <giuliano.belinassi@usp.br>
> 
> 	* tree-ssa-operands.c (operands_scanner): New class.
> 	(operands_bitmap_obstack): Remove.
> 	(n_initialized): Remove.
> 	(build_uses): Move to operands_scanner 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 operands_scanner.
Like Richi, I want to say thanks for taking care of this and feel free to repeat
elsewhere :-)  There's a ton of this kind of cleanup we ought to be doing.

I've committed the patch and pushed  to the trunk.

Jeff
diff mbox series

Patch

From b860b39045e1b90319caa7c75ad189514e4a5641 Mon Sep 17 00:00:00 2001
From: Giuliano Belinassi <giuliano.belinassi@usp.br>
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  <giuliano.belinassi@usp.br>

	* 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<tree *> 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<tree *> 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 (tree var);
 
-/* Bitmap obstack for our datastructures that needs to survive across
-   compilations of multiple functions.  */
-static bitmap_obstack operands_bitmap_obstack;
+    /* Add VAR to the set of variables that require a VUSE operator.  */
+    inline void append_vuse (tree var);
 
-static void get_expr_operands (struct function *, gimple *, tree *, int);
+    /* Add virtual operands for STMT.  FLAGS is as in get_expr_operands.  */
+    void add_virtual_operand (struct function *fn, gimple *stmt ATTRIBUTE_UNUSED,
+			      int flags);
 
-/* Number of functions with initialized ssa_operands.  */
-static int n_initialized = 0;
+
+    /* Add *VAR_P to the appropriate operand array for statement STMT.
+       FLAGS is as in get_expr_operands.  If *VAR_P is a GIMPLE register,
+       it will be added to the statement's real operands, otherwise it is
+       added to virtual operands.  */
+    void add_stmt_operand (struct function *fn, tree *var_p, gimple *stmt,
+			   int flags);
+
+    /* A subroutine of get_expr_operands to handle MEM_REF.
+
+       STMT is the statement being processed, EXPR is the MEM_REF
+	  that got us here.
+
+       FLAGS is as in get_expr_operands.  */
+    void get_mem_ref_operands (struct function *fn, gimple *stmt, tree expr,
+			       int flags);
+
+    /* A subroutine of get_expr_operands to handle TARGET_MEM_REF.  */
+    void get_tmr_operands (struct function *fn, gimple *stmt, tree expr,
+			   int flags);
+
+
+    /* If STMT is a call that may clobber globals and other symbols that
+       escape, add them to the VDEF/VUSE lists for it.  */
+    void maybe_add_call_vops (struct function *fn, gcall *stmt);
+
+    /* Scan operands in the ASM_EXPR stmt referred to in INFO.  */
+    void get_asm_stmt_operands (struct function *fn, gasm *stmt);
+
+
+    /* Recursively scan the expression pointed to by EXPR_P in statement
+       STMT.  FLAGS is one of the OPF_* constants modifying how to
+       interpret the operands found.  */
+    void get_expr_operands (struct function *fn, gimple *stmt, tree *expr_p,
+			    int flags);
+
+    /* Parse STMT looking for operands.  When finished, the various
+       build_* operand vectors will have potential operands in them.  */
+    void parse_ssa_operands (struct function *fn, gimple *stmt);
+
+
+    /* Takes elements from build_defs and turns them into def operands of STMT.
+       TODO -- Make build_defs vec of tree *.  */
+    inline void finalize_ssa_defs (struct function *fn, gimple *stmt);
+};
 
 /* Accessor to tree-ssa-operands.c caches.  */
 static inline struct ssa_operands *
@@ -181,14 +269,6 @@  create_vop_var (struct function *fn)
 void
 init_ssa_operands (struct function *fn)
 {
-  if (!n_initialized++)
-    {
-      build_uses.create (10);
-      build_vuse = NULL_TREE;
-      build_vdef = NULL_TREE;
-      bitmap_obstack_initialize (&operands_bitmap_obstack);
-    }
-
   gcc_assert (gimple_ssa_operands (fn)->operand_memory == NULL);
   gimple_ssa_operands (fn)->operand_memory_index
      = gimple_ssa_operands (fn)->ssa_operand_mem_size;
@@ -205,13 +285,6 @@  fini_ssa_operands (struct function *fn)
 {
   struct ssa_operand_memory_d *ptr;
 
-  if (!--n_initialized)
-    {
-      build_uses.release ();
-      build_vdef = NULL_TREE;
-      build_vuse = NULL_TREE;
-    }
-
   gimple_ssa_operands (fn)->free_uses = NULL;
 
   while ((ptr = gimple_ssa_operands (fn)->operand_memory) != NULL)
@@ -223,9 +296,6 @@  fini_ssa_operands (struct function *fn)
 
   gimple_ssa_operands (fn)->ops_active = false;
 
-  if (!n_initialized)
-    bitmap_obstack_release (&operands_bitmap_obstack);
-
   fn->gimple_df->vop = NULL_TREE;
 }
 
@@ -315,8 +385,8 @@  add_use_op (struct function *fn, gimple *stmt, tree *op, use_optype_p last)
 /* Takes elements from build_defs and turns them into def operands of STMT.
    TODO -- Make build_defs vec of tree *.  */
 
-static inline void
-finalize_ssa_defs (struct function *fn, gimple *stmt)
+inline void
+build_virtual_operands::finalize_ssa_defs (struct function *fn, gimple *stmt)
 {
   /* Pre-pend the vdef we may have built.  */
   if (build_vdef != NULL_TREE)
@@ -353,8 +423,8 @@  finalize_ssa_defs (struct function *fn, gimple *stmt)
 
 /* Takes elements from build_uses and turns them into use operands of STMT.  */
 
-static inline void
-finalize_ssa_uses (struct function *fn, gimple *stmt)
+inline void
+build_virtual_operands::finalize_ssa_uses (struct function *fn, gimple *stmt)
 {
   unsigned new_i;
   struct use_optype_d new_list;
@@ -418,8 +488,8 @@  finalize_ssa_uses (struct function *fn, gimple *stmt)
 /* Clear the in_list bits and empty the build array for VDEFs and
    VUSEs.  */
 
-static inline void
-cleanup_build_arrays (void)
+inline void
+build_virtual_operands::cleanup_build_arrays (void)
 {
   build_vdef = NULL_TREE;
   build_vuse = NULL_TREE;
@@ -429,8 +499,8 @@  cleanup_build_arrays (void)
 
 /* Finalize all the build vectors, fill the new ones into INFO.  */
 
-static inline void
-finalize_ssa_stmt_operands (struct function *fn, gimple *stmt)
+inline void
+build_virtual_operands::finalize_ssa_stmt_operands (struct function *fn, gimple *stmt)
 {
   finalize_ssa_defs (fn, stmt);
   finalize_ssa_uses (fn, stmt);
@@ -440,8 +510,8 @@  finalize_ssa_stmt_operands (struct function *fn, gimple *stmt)
 
 /* Start the process of building up operands vectors in INFO.  */
 
-static inline void
-start_ssa_stmt_operands (void)
+inline void
+build_virtual_operands::start_ssa_stmt_operands (void)
 {
   gcc_assert (build_uses.length () == 0);
   gcc_assert (build_vuse == NULL_TREE);
@@ -451,8 +521,8 @@  start_ssa_stmt_operands (void)
 
 /* Add USE_P to the list of pointers to operands.  */
 
-static inline void
-append_use (tree *use_p)
+inline void
+build_virtual_operands::append_use (tree *use_p)
 {
   build_uses.safe_push (use_p);
 }
@@ -460,8 +530,8 @@  append_use (tree *use_p)
 
 /* Add VAR to the set of variables that require a VDEF operator.  */
 
-static inline void
-append_vdef (tree var)
+inline void
+build_virtual_operands::append_vdef (tree var)
 {
   gcc_assert ((build_vdef == NULL_TREE
 	       || build_vdef == var)
@@ -475,8 +545,8 @@  append_vdef (tree var)
 
 /* Add VAR to the set of variables that require a VUSE operator.  */
 
-static inline void
-append_vuse (tree var)
+inline void
+build_virtual_operands::append_vuse (tree var)
 {
   gcc_assert (build_vuse == NULL_TREE
 	      || build_vuse == var);
@@ -486,9 +556,10 @@  append_vuse (tree var)
 
 /* Add virtual operands for STMT.  FLAGS is as in get_expr_operands.  */
 
-static void
-add_virtual_operand (struct function *fn,
-		     gimple *stmt ATTRIBUTE_UNUSED, int flags)
+void
+build_virtual_operands::add_virtual_operand (struct function *fn,
+					gimple *stmt ATTRIBUTE_UNUSED,
+					int flags)
 {
   /* Add virtual operands to the stmt, unless the caller has specifically
      requested not to do that (used when adding operands inside an
@@ -510,8 +581,9 @@  add_virtual_operand (struct function *fn,
    it will be added to the statement's real operands, otherwise it is
    added to virtual operands.  */
 
-static void
-add_stmt_operand (struct function *fn, tree *var_p, gimple *stmt, int flags)
+void
+build_virtual_operands::add_stmt_operand (struct function *fn, tree *var_p,
+				     gimple *stmt, int flags)
 {
   tree var = *var_p;
 
@@ -576,9 +648,9 @@  mark_address_taken (tree ref)
 
    FLAGS is as in get_expr_operands.  */
 
-static void
-get_mem_ref_operands (struct function *fn,
-		      gimple *stmt, tree expr, int flags)
+void
+build_virtual_operands::get_mem_ref_operands (struct function *fn,
+					 gimple *stmt, tree expr, int flags)
 {
   tree *pptr = &TREE_OPERAND (expr, 0);
 
@@ -598,8 +670,9 @@  get_mem_ref_operands (struct function *fn,
 
 /* A subroutine of get_expr_operands to handle TARGET_MEM_REF.  */
 
-static void
-get_tmr_operands (struct function *fn, gimple *stmt, tree expr, int flags)
+void
+build_virtual_operands::get_tmr_operands (struct function *fn, gimple *stmt,
+				     tree expr, int flags)
 {
   if (!(flags & opf_no_vops)
       && TREE_THIS_VOLATILE (expr))
@@ -620,8 +693,8 @@  get_tmr_operands (struct function *fn, gimple *stmt, tree expr, int flags)
 /* If STMT is a call that may clobber globals and other symbols that
    escape, add them to the VDEF/VUSE lists for it.  */
 
-static void
-maybe_add_call_vops (struct function *fn, gcall *stmt)
+void
+build_virtual_operands::maybe_add_call_vops (struct function *fn, gcall *stmt)
 {
   int call_flags = gimple_call_flags (stmt);
 
@@ -641,8 +714,8 @@  maybe_add_call_vops (struct function *fn, gcall *stmt)
 
 /* Scan operands in the ASM_EXPR stmt referred to in INFO.  */
 
-static void
-get_asm_stmt_operands (struct function *fn, gasm *stmt)
+void
+build_virtual_operands::get_asm_stmt_operands (struct function *fn, gasm *stmt)
 {
   size_t i, noutputs;
   const char **oconstraints;
@@ -699,8 +772,9 @@  get_asm_stmt_operands (struct function *fn, gasm *stmt)
    STMT.  FLAGS is one of the OPF_* constants modifying how to
    interpret the operands found.  */
 
-static void
-get_expr_operands (struct function *fn, gimple *stmt, tree *expr_p, int flags)
+void
+build_virtual_operands::get_expr_operands (struct function *fn, gimple *stmt,
+				      tree *expr_p, int flags)
 {
   enum tree_code code;
   enum tree_code_class codeclass;
@@ -889,8 +963,8 @@  get_expr_operands (struct function *fn, gimple *stmt, tree *expr_p, int flags)
 /* Parse STMT looking for operands.  When finished, the various
    build_* operand vectors will have potential operands in them.  */
 
-static void
-parse_ssa_operands (struct function *fn, gimple *stmt)
+void
+build_virtual_operands::parse_ssa_operands (struct function *fn, gimple *stmt)
 {
   enum gimple_code code = gimple_code (stmt);
   size_t i, n, start = 0;
@@ -939,8 +1013,8 @@  parse_ssa_operands (struct function *fn, gimple *stmt)
 
 /* Create an operands cache for STMT.  */
 
-static void
-build_ssa_operands (struct function *fn, gimple *stmt)
+void
+build_virtual_operands::build_ssa_operands (struct function *fn, gimple *stmt)
 {
   /* Initially assume that the statement has no volatile operands.  */
   gimple_set_has_volatile_ops (stmt, false);
@@ -953,7 +1027,7 @@  build_ssa_operands (struct function *fn, gimple *stmt)
 /* Verifies SSA statement operands.  */
 
 DEBUG_FUNCTION bool
-verify_ssa_operands (struct function *fn, gimple *stmt)
+build_virtual_operands::verify_ssa_operands (struct function *fn, gimple *stmt)
 {
   use_operand_p use_p;
   def_operand_p def_p;
@@ -1040,6 +1114,14 @@  verify_ssa_operands (struct function *fn, gimple *stmt)
   return false;
 }
 
+/* Interface for external use.  */
+
+DEBUG_FUNCTION bool
+verify_ssa_operands (struct function *fn, gimple *stmt)
+{
+  return build_virtual_operands ().verify_ssa_operands (fn, stmt);
+}
+
 
 /* Releases the operands of STMT back to their freelists, and clears
    the stmt operand lists.  */
@@ -1080,7 +1162,7 @@  update_stmt_operands (struct function *fn, gimple *stmt)
   timevar_push (TV_TREE_OPS);
 
   gcc_assert (gimple_modified_p (stmt));
-  build_ssa_operands (fn, stmt);
+  build_virtual_operands ().build_ssa_operands (fn, stmt);
   gimple_set_modified (stmt, false);
 
   timevar_pop (TV_TREE_OPS);
-- 
2.26.2