public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [tuples] Fix GIMPLE_CHECK* macros
@ 2007-08-08 16:58 Diego Novillo
  2007-08-08 17:05 ` Paolo Bonzini
  0 siblings, 1 reply; 3+ messages in thread
From: Diego Novillo @ 2007-08-08 16:58 UTC (permalink / raw)
  To: gcc-patches, Aldy Hernandez

[-- Attachment #1: Type: text/plain, Size: 252 bytes --]


These macros do not really need to return a value.  They are never used
in another macro.  This also has the tiny added advantage that they can
be used when the stage 0 compiler is anything other than GCC.

Tested on libgcc and check-gcc.  Committed.

[-- Attachment #2: 20070808-fix-GIMPLE_CHECK.diff --]
[-- Type: text/x-patch, Size: 5543 bytes --]

2007-08-08  Diego Novillo  <dnovillo@google.com>

	* gimple.h (GIMPLE_CHECK, GIMPLE_CHECK2, GIMPLE_RANGE_CHECK):
	Do not return the checked statement.  Update all users.
	Enable on compilers other than GCC.

Index: gimple-pretty-print.c
===================================================================
--- gimple-pretty-print.c	(revision 127278)
+++ gimple-pretty-print.c	(working copy)
@@ -244,6 +244,7 @@ static void
 dump_gimple_switch (pretty_printer *buffer, gimple gs, int spc, int flags)
 {
   unsigned int i;
+
   GIMPLE_CHECK (gs, GIMPLE_SWITCH);
   pp_string (buffer, "switch (");
   dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
Index: gimplify.c
===================================================================
--- gimplify.c	(revision 127278)
+++ gimplify.c	(working copy)
@@ -4514,9 +4514,7 @@ gimplify_target_expr (tree *expr_p, gimp
 bool
 gimplify_stmt (tree *stmt_p, gimple_seq seq_p)
 {
-  gimple last;
-
-  last = gimple_seq_last (seq_p);
+  gimple last = gimple_seq_last (seq_p);
   gimplify_expr (stmt_p, seq_p, NULL, is_gimple_stmt, fb_none);
   return last != gimple_seq_last (seq_p);
 }
Index: gimple.h
===================================================================
--- gimple.h	(revision 127278)
+++ gimple.h	(working copy)
@@ -432,7 +432,7 @@ extern const char *const gimple_code_nam
 
 
 /* Error out if a gimple tuple is addressed incorrectly.  */
-#if defined ENABLE_GIMPLE_CHECKING && (GCC_VERSION >= 2007)
+#if defined ENABLE_GIMPLE_CHECKING
 extern void gimple_check_failed (const gimple, const char *, int,          \
                                  const char *, unsigned int, unsigned int) \
                                  ATTRIBUTE_NORETURN;                       \
@@ -440,30 +440,34 @@ extern void gimple_range_check_failed (c
                                        const char *, unsigned int,         \
 				       unsigned int) ATTRIBUTE_NORETURN;
 
-#define GIMPLE_CHECK(GS, CODE) __extension__				\
-  ({  const gimple __gs = (GS);						\
-      if (gimple_code (__gs) != (CODE))					\
-        gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__,	\
-	  		 (CODE), 0);					\
-      __gs; })
+#define GIMPLE_CHECK(GS, CODE)						\
+  {									\
+    const gimple __gs = (GS);						\
+    if (gimple_code (__gs) != (CODE))					\
+      gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__,	\
+	  		   (CODE), 0);					\
+  }
 
-#define GIMPLE_CHECK2(GS, CODE1, CODE2) __extension__			\
-  ({  const gimple __gs = (GS);						\
-      if (gimple_code (__gs) != (CODE1)					\
-	  || gimple_flags (__gs) != (CODE2))				\
-        gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__,	\
-	  		 (CODE1), (CODE2));				\
-      __gs; })
-#define GIMPLE_RANGE_CHECK(GS, CODE1, CODE2) __extension__		\
-  ({ const gimple __gs = (GS);						\
-     if (gimple_code (__gs) < (CODE1) || gimple_code (__gs) > (CODE2))	\
-       gimple_range_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__,	\
-		        (CODE1), (CODE2));				\
-     __gs; })
-#else  /* not ENABLE_GIMPLE_CHECKING, or not gcc */
-#define GIMPLE_CHECK(GS, CODE)			(GS)
-#define GIMPLE_CHECK2(GS, C1, C2)		(GS)
-#define GIMPLE_RANGE_CHECK(GS, CODE1, CODE2)	(GS)
+#define GIMPLE_CHECK2(GS, CODE1, CODE2)					\
+  {									\
+    const gimple __gs = (GS);						\
+    if (gimple_code (__gs) != (CODE1)					\
+	|| gimple_flags (__gs) != (CODE2))				\
+      gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__,	\
+	  		   (CODE1), (CODE2));				\
+  }
+
+#define GIMPLE_RANGE_CHECK(GS, CODE1, CODE2)				\
+  {									\
+    const gimple __gs = (GS);						\
+    if (gimple_code (__gs) < (CODE1) || gimple_code (__gs) > (CODE2))	\
+      gimple_range_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__,\
+		                 (CODE1), (CODE2));			\
+  }
+#else  /* not ENABLE_GIMPLE_CHECKING  */
+#define GIMPLE_CHECK(GS, CODE)			;
+#define GIMPLE_CHECK2(GS, C1, C2)		;
+#define GIMPLE_RANGE_CHECK(GS, CODE1, CODE2)	;
 #endif
 
 
@@ -474,24 +478,24 @@ extern void gimple_range_check_failed (c
 static inline size_t
 gimple_num_ops (gimple gs)
 {
-  gimple g = GIMPLE_RANGE_CHECK (gs, GIMPLE_ASSIGN, GIMPLE_RETURN);
-  return g->with_ops.num_ops;
+  GIMPLE_RANGE_CHECK (gs, GIMPLE_ASSIGN, GIMPLE_RETURN);
+  return gs->with_ops.num_ops;
 }
 
 static inline tree
 gimple_op (gimple gs, size_t i)
 {
-  gimple g = GIMPLE_RANGE_CHECK (gs, GIMPLE_ASSIGN, GIMPLE_RETURN);
-  gcc_assert (i < g->with_ops.num_ops);
-  return g->with_ops.op[i];
+  GIMPLE_RANGE_CHECK (gs, GIMPLE_ASSIGN, GIMPLE_RETURN);
+  gcc_assert (i < gs->with_ops.num_ops);
+  return gs->with_ops.op[i];
 }
 
 static inline void
 gimple_set_op (gimple gs, size_t i, tree op)
 {
-  gimple g = GIMPLE_RANGE_CHECK (gs, GIMPLE_ASSIGN, GIMPLE_RETURN);
-  gcc_assert (i < g->with_ops.num_ops);
-  g->with_ops.op[i] = op;
+  GIMPLE_RANGE_CHECK (gs, GIMPLE_ASSIGN, GIMPLE_RETURN);
+  gcc_assert (i < gs->with_ops.num_ops);
+  gs->with_ops.op[i] = op;
 }
 
 
@@ -851,8 +855,8 @@ gimple_asm_string (gimple gs)
 static inline tree
 gimple_catch_types (gimple gs)
 {
- GIMPLE_CHECK (gs, GIMPLE_CATCH);
- return gs->gimple_catch.types;
+  GIMPLE_CHECK (gs, GIMPLE_CATCH);
+  return gs->gimple_catch.types;
 }
 
 static inline gimple_seq
@@ -944,8 +948,8 @@ gimple_try_set_cleanup (gimple gs, gimpl
 static inline unsigned int
 gimple_phi_capacity (gimple gs)
 {
-    GIMPLE_CHECK (gs, GIMPLE_PHI);
-    return gs->gimple_phi.capacity;
+  GIMPLE_CHECK (gs, GIMPLE_PHI);
+  return gs->gimple_phi.capacity;
 }
 
 static inline void

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [tuples] Fix GIMPLE_CHECK* macros
  2007-08-08 16:58 [tuples] Fix GIMPLE_CHECK* macros Diego Novillo
@ 2007-08-08 17:05 ` Paolo Bonzini
  2007-08-08 17:07   ` Diego Novillo
  0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2007-08-08 17:05 UTC (permalink / raw)
  To: Diego Novillo; +Cc: gcc-patches, Aldy Hernandez

> +#define GIMPLE_CHECK(GS, CODE)						\
> +  {									\
> +    const gimple __gs = (GS);						\
> +    if (gimple_code (__gs) != (CODE))					\
> +      gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__,	\
> +	  		   (CODE), 0);					\
> +  }

do .. while (0) maybe?

Paolo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [tuples] Fix GIMPLE_CHECK* macros
  2007-08-08 17:05 ` Paolo Bonzini
@ 2007-08-08 17:07   ` Diego Novillo
  0 siblings, 0 replies; 3+ messages in thread
From: Diego Novillo @ 2007-08-08 17:07 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: gcc-patches, Aldy Hernandez

On 8/8/07 1:05 PM, Paolo Bonzini wrote:

> do .. while (0) maybe?

Ah, yes.  Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-08-08 17:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-08 16:58 [tuples] Fix GIMPLE_CHECK* macros Diego Novillo
2007-08-08 17:05 ` Paolo Bonzini
2007-08-08 17:07   ` Diego Novillo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).