Patchwork [2/6] Hand-written port of various accessors within gimple.h

login
register
mail settings
Submitter David Malcolm
Date Aug. 29, 2013, 4:20 p.m.
Message ID <1377793216-22549-3-git-send-email-dmalcolm@redhat.com>
Download mbox | patch
Permalink /patch/270877/
State New
Headers show

Comments

David Malcolm - Aug. 29, 2013, 4:20 p.m.
* gimple.h (gimple_use_ops): Port from union to usage of
	dyn_cast.
	(gimple_set_use_ops): Port from union to usage of as_a.
	(gimple_set_vuse): Likewise.
	(gimple_set_vdef): Likewise.
	(gimple_call_internal_fn): Port from union to a static_cast,
	given that the type has already been asserted.
	(gimple_omp_body_ptr): Port from unchecked union usage to
	a static_cast.
	(gimple_omp_set_body): Likewise.
---
 gcc/gimple.h | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

Patch

diff --git a/gcc/gimple.h b/gcc/gimple.h
index d7ea2e4..1ee6238 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -1433,9 +1433,11 @@  gimple_has_mem_ops (const_gimple g)
 static inline struct use_optype_d *
 gimple_use_ops (const_gimple g)
 {
-  if (!gimple_has_ops (g))
+  const gimple_statement_with_ops *ops_stmt =
+    dyn_cast <const gimple_statement_with_ops> (g);
+  if (!ops_stmt)
     return NULL;
-  return g->gsops.opbase.use_ops;
+  return ops_stmt->use_ops;
 }
 
 
@@ -1444,8 +1446,9 @@  gimple_use_ops (const_gimple g)
 static inline void
 gimple_set_use_ops (gimple g, struct use_optype_d *use)
 {
-  gcc_gimple_checking_assert (gimple_has_ops (g));
-  g->gsops.opbase.use_ops = use;
+  gimple_statement_with_ops *ops_stmt =
+    as_a <gimple_statement_with_ops> (g);
+  ops_stmt->use_ops = use;
 }
 
 
@@ -1522,8 +1525,9 @@  gimple_vdef_ptr (gimple g)
 static inline void
 gimple_set_vuse (gimple g, tree vuse)
 {
-  gcc_gimple_checking_assert (gimple_has_mem_ops (g));
-  g->gsmembase.vuse = vuse;
+  gimple_statement_with_memory_ops *mem_ops_stmt =
+    as_a <gimple_statement_with_memory_ops> (g);
+  mem_ops_stmt->vuse = vuse;
 }
 
 /* Set the single VDEF operand of the statement G.  */
@@ -1531,8 +1535,9 @@  gimple_set_vuse (gimple g, tree vuse)
 static inline void
 gimple_set_vdef (gimple g, tree vdef)
 {
-  gcc_gimple_checking_assert (gimple_has_mem_ops (g));
-  g->gsmembase.vdef = vdef;
+  gimple_statement_with_memory_ops *mem_ops_stmt =
+    as_a <gimple_statement_with_memory_ops> (g);
+  mem_ops_stmt->vdef = vdef;
 }
 
 
@@ -2188,7 +2193,7 @@  static inline enum internal_fn
 gimple_call_internal_fn (const_gimple gs)
 {
   gcc_gimple_checking_assert (gimple_call_internal_p (gs));
-  return gs->gimple_call.u.internal_fn;
+  return static_cast <const gimple_statement_call *> (gs)->u.internal_fn;
 }
 
 
@@ -3860,7 +3865,7 @@  gimple_debug_source_bind_set_value (gimple dbg, tree value)
 static inline gimple_seq *
 gimple_omp_body_ptr (gimple gs)
 {
-  return &gs->omp.body;
+  return &static_cast <gimple_statement_omp *> (gs)->body;
 }
 
 /* Return the body for the OMP statement GS.  */
@@ -3876,7 +3881,7 @@  gimple_omp_body (gimple gs)
 static inline void
 gimple_omp_set_body (gimple gs, gimple_seq body)
 {
-  gs->omp.body = body;
+  static_cast <gimple_statement_omp *> (gs)->body = body;
 }