Patchwork [4/6] Implement is_a_helper <>::test specializations for various gimple types

login
register
mail settings
Submitter David Malcolm
Date Oct. 31, 2013, 4:26 p.m.
Message ID <1383236801-13234-5-git-send-email-dmalcolm@redhat.com>
Download mbox | patch
Permalink /patch/287555/
State New
Headers show

Comments

David Malcolm - Oct. 31, 2013, 4:26 p.m.
* gimple.h (is_a_helper <const gimple_statement_with_ops>::test): New.
	(is_a_helper <gimple_statement_with_ops>::test): New.
	(is_a_helper <const gimple_statement_with_memory_ops>::test): New.
	(is_a_helper <gimple_statement_with_memory_ops>::test): New.
---
 gcc/gimple.h | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
Jeff Law - Nov. 14, 2013, 7:37 a.m.
On 10/31/13 10:26, David Malcolm wrote:
> 	* gimple.h (is_a_helper <const gimple_statement_with_ops>::test): New.
> 	(is_a_helper <gimple_statement_with_ops>::test): New.
> 	(is_a_helper <const gimple_statement_with_memory_ops>::test): New.
> 	(is_a_helper <gimple_statement_with_memory_ops>::test): New.
OK with the usual conditions.  Check with Andrew as to the location of 
these helpers since he's in the middle of ripping apart gimple.h.
jeff
David Malcolm - Nov. 18, 2013, 6:54 p.m.
On Thu, 2013-11-14 at 00:37 -0700, Jeff Law wrote:
> On 10/31/13 10:26, David Malcolm wrote:
> > 	* gimple.h (is_a_helper <const gimple_statement_with_ops>::test): New.
> > 	(is_a_helper <gimple_statement_with_ops>::test): New.
> > 	(is_a_helper <const gimple_statement_with_memory_ops>::test): New.
> > 	(is_a_helper <gimple_statement_with_memory_ops>::test): New.
> OK with the usual conditions.  Check with Andrew as to the location of 
> these helpers since he's in the middle of ripping apart gimple.h.

The helpers become used in accessors such as gimple_use_ops,
gimple_vuse, gimple_vdef etc as of the automated patch (patch 3 in the
series [1]), so presumably the helpers need to be in the same file as
those accessors.  The accessors are currently in gimple.h, and hence I
also put the helpers within gimple.h (earlier within the header).

Andrew, do you plan to move the accessor functions out of gimple.h?  If
so, where should the is_a_helper fns land?

Dave

[1] hence these patches need to be committed at the same time, whether
than means a single "revision" or not; I split them up conceptually for
ease of review.
Andrew MacLeod - Nov. 18, 2013, 7:08 p.m.
On 11/18/2013 01:54 PM, David Malcolm wrote:
> On Thu, 2013-11-14 at 00:37 -0700, Jeff Law wrote:
>> On 10/31/13 10:26, David Malcolm wrote:
>>> 	* gimple.h (is_a_helper <const gimple_statement_with_ops>::test): New.
>>> 	(is_a_helper <gimple_statement_with_ops>::test): New.
>>> 	(is_a_helper <const gimple_statement_with_memory_ops>::test): New.
>>> 	(is_a_helper <gimple_statement_with_memory_ops>::test): New.
>> OK with the usual conditions.  Check with Andrew as to the location of
>> these helpers since he's in the middle of ripping apart gimple.h.
> The helpers become used in accessors such as gimple_use_ops,
> gimple_vuse, gimple_vdef etc as of the automated patch (patch 3 in the
> series [1]), so presumably the helpers need to be in the same file as
> those accessors.  The accessors are currently in gimple.h, and hence I
> also put the helpers within gimple.h (earlier within the header).
>
> Andrew, do you plan to move the accessor functions out of gimple.h?  If
> so, where should the is_a_helper fns land?
>
Not currently. They are a component of the gimple statement, and 
gimple.[ch] is now just the statement and related accessors.  Since your 
changes are just for gimple-stmt, in theory everything should go there.

Andrew
Jeff Law - Nov. 18, 2013, 7:12 p.m.
On 11/18/13 11:54, David Malcolm wrote:
> On Thu, 2013-11-14 at 00:37 -0700, Jeff Law wrote:
>> On 10/31/13 10:26, David Malcolm wrote:
>>> 	* gimple.h (is_a_helper <const gimple_statement_with_ops>::test): New.
>>> 	(is_a_helper <gimple_statement_with_ops>::test): New.
>>> 	(is_a_helper <const gimple_statement_with_memory_ops>::test): New.
>>> 	(is_a_helper <gimple_statement_with_memory_ops>::test): New.
>> OK with the usual conditions.  Check with Andrew as to the location of
>> these helpers since he's in the middle of ripping apart gimple.h.
>
> The helpers become used in accessors such as gimple_use_ops,
> gimple_vuse, gimple_vdef etc as of the automated patch (patch 3 in the
> series [1]), so presumably the helpers need to be in the same file as
> those accessors.  The accessors are currently in gimple.h, and hence I
> also put the helpers within gimple.h (earlier within the header).
>
> Andrew, do you plan to move the accessor functions out of gimple.h?  If
> so, where should the is_a_helper fns land?
>
> Dave
>
> [1] hence these patches need to be committed at the same time, whether
> than means a single "revision" or not; I split them up conceptually for
> ease of review.
I'd say single commit since they are dependent upon each other.

jeff

Patch

diff --git a/gcc/gimple.h b/gcc/gimple.h
index f258992..710ce04 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -1756,6 +1756,21 @@  gimple_has_ops (const_gimple g)
   return gimple_code (g) >= GIMPLE_COND && gimple_code (g) <= GIMPLE_RETURN;
 }
 
+template <>
+template <>
+inline bool
+is_a_helper <const gimple_statement_with_ops>::test (const_gimple gs)
+{
+  return gimple_has_ops (gs);
+}
+
+template <>
+template <>
+inline bool
+is_a_helper <gimple_statement_with_ops>::test (gimple gs)
+{
+  return gimple_has_ops (gs);
+}
 
 /* Return true if GIMPLE statement G has memory operands.  */
 
@@ -1765,6 +1780,21 @@  gimple_has_mem_ops (const_gimple g)
   return gimple_code (g) >= GIMPLE_ASSIGN && gimple_code (g) <= GIMPLE_RETURN;
 }
 
+template <>
+template <>
+inline bool
+is_a_helper <const gimple_statement_with_memory_ops>::test (const_gimple gs)
+{
+  return gimple_has_mem_ops (gs);
+}
+
+template <>
+template <>
+inline bool
+is_a_helper <gimple_statement_with_memory_ops>::test (gimple gs)
+{
+  return gimple_has_mem_ops (gs);
+}
 
 /* Return the set of USE operands for statement G.  */