Tree structure marking

Message ID 81bd415c-1819-5b7c-f8ba-b1e6c0a52d84@acm.org
State New
Headers show
Series
  • Tree structure marking
Related show

Commit Message

Nathan Sidwell Oct. 13, 2017, 11:20 a.m.
In figuring out a problem with CODE_CONTAINS_STRUCT I noticed that:

1) the tree_contains_struct array is unsigned char.  bool seems a better 
choice now we're in C++-land.

2) the MARK_TS_FOO macros used the 'do ... while (0)' idiom.  But 
there's no need for such verbosity.  These are 'ary[index] = true' 
setters -- other setters don't use  do while:
#define SET_DECL_ASSEMBLER_NAME(NODE, NAME) \
   (DECL_ASSEMBLER_NAME_RAW (NODE) = (NAME))

We can combine them with the comma operator, not make separate statements.

Fixed thusly, ok?

nathan

Comments

Richard Biener Oct. 13, 2017, 11:25 a.m. | #1
On Fri, 13 Oct 2017, Nathan Sidwell wrote:

> In figuring out a problem with CODE_CONTAINS_STRUCT I noticed that:
> 
> 1) the tree_contains_struct array is unsigned char.  bool seems a better
> choice now we're in C++-land.
> 
> 2) the MARK_TS_FOO macros used the 'do ... while (0)' idiom.  But there's no
> need for such verbosity.  These are 'ary[index] = true' setters -- other
> setters don't use  do while:
> #define SET_DECL_ASSEMBLER_NAME(NODE, NAME) \
>   (DECL_ASSEMBLER_NAME_RAW (NODE) = (NAME))
> 
> We can combine them with the comma operator, not make separate statements.
> 
> Fixed thusly, ok?

OK.

Richard.

> nathan
>

Patch

2017-10-13  Nathan Sidwell  <nathan@acm.org>

	* tree-core.h (tree_contains_struct): Make bool.
	* tree.c (tree_contains_struct): Likewise.
	* tree.h (MARK_TS_BASE): Remove do ... while (0) idiom.
	(MARK_TS_TYPED, MARK_TS_COMMON, MARK_TS_TYPE_COMMON,
	MARK_TS_TYPE_WITH_LANG_SPECIFIC, MARK_TS_DECL_MINIMAL,
	MARK_TS_DECL_COMMON, MARK_TS_DECL_WRTL, MARK_TS_DECL_WITH_VIS,
	MARK_TS_DECL_NON_COMMON): Likewise, use comma operator.

Index: tree-core.h
===================================================================
--- tree-core.h	(revision 253695)
+++ tree-core.h	(working copy)
@@ -2058,7 +2058,7 @@  struct floatn_type_info {
                                 Global variables
 ---------------------------------------------------------------------------*/
 /* Matrix describing the structures contained in a given tree code.  */
-extern unsigned char tree_contains_struct[MAX_TREE_CODES][64];
+extern bool tree_contains_struct[MAX_TREE_CODES][64];
 
 /* Class of tree given its code.  */
 extern const enum tree_code_class tree_code_type[];
Index: tree.c
===================================================================
--- tree.c	(revision 253695)
+++ tree.c	(working copy)
@@ -259,7 +259,7 @@  tree integer_types[itk_none];
 bool int_n_enabled_p[NUM_INT_N_ENTS];
 struct int_n_trees_t int_n_trees [NUM_INT_N_ENTS];
 
-unsigned char tree_contains_struct[MAX_TREE_CODES][64];
+bool tree_contains_struct[MAX_TREE_CODES][64];
 
 /* Number of operands for each OpenMP clause.  */
 unsigned const char omp_clause_num_ops[] =
Index: tree.h
===================================================================
--- tree.h	(revision 253695)
+++ tree.h	(working copy)
@@ -76,64 +76,43 @@  as_internal_fn (combined_fn code)
 
 /* Macros for initializing `tree_contains_struct'.  */
 #define MARK_TS_BASE(C)					\
-  do {							\
-    tree_contains_struct[C][TS_BASE] = 1;		\
-  } while (0)
+  (tree_contains_struct[C][TS_BASE] = true)
 
 #define MARK_TS_TYPED(C)				\
-  do {							\
-    MARK_TS_BASE (C);					\
-    tree_contains_struct[C][TS_TYPED] = 1;		\
-  } while (0)
+  (MARK_TS_BASE (C),					\
+   tree_contains_struct[C][TS_TYPED] = true)
 
 #define MARK_TS_COMMON(C)				\
-  do {							\
-    MARK_TS_TYPED (C);					\
-    tree_contains_struct[C][TS_COMMON] = 1;		\
-  } while (0)
+  (MARK_TS_TYPED (C),					\
+   tree_contains_struct[C][TS_COMMON] = true)
 
 #define MARK_TS_TYPE_COMMON(C)				\
-  do {							\
-    MARK_TS_COMMON (C);					\
-    tree_contains_struct[C][TS_TYPE_COMMON] = 1;	\
-  } while (0)
+  (MARK_TS_COMMON (C),					\
+   tree_contains_struct[C][TS_TYPE_COMMON] = true)
 
 #define MARK_TS_TYPE_WITH_LANG_SPECIFIC(C)		\
-  do {							\
-    MARK_TS_TYPE_COMMON (C);				\
-    tree_contains_struct[C][TS_TYPE_WITH_LANG_SPECIFIC] = 1;	\
-  } while (0)
+  (MARK_TS_TYPE_COMMON (C),				\
+   tree_contains_struct[C][TS_TYPE_WITH_LANG_SPECIFIC] = true)
 
 #define MARK_TS_DECL_MINIMAL(C)				\
-  do {							\
-    MARK_TS_COMMON (C);					\
-    tree_contains_struct[C][TS_DECL_MINIMAL] = 1;	\
-  } while (0)
+  (MARK_TS_COMMON (C),					\
+   tree_contains_struct[C][TS_DECL_MINIMAL] = true)
 
 #define MARK_TS_DECL_COMMON(C)				\
-  do {							\
-    MARK_TS_DECL_MINIMAL (C);				\
-    tree_contains_struct[C][TS_DECL_COMMON] = 1;	\
-  } while (0)
+  (MARK_TS_DECL_MINIMAL (C),				\
+   tree_contains_struct[C][TS_DECL_COMMON] = true)
 
 #define MARK_TS_DECL_WRTL(C)				\
-  do {							\
-    MARK_TS_DECL_COMMON (C);				\
-    tree_contains_struct[C][TS_DECL_WRTL] = 1;		\
-  } while (0)
+  (MARK_TS_DECL_COMMON (C),				\
+   tree_contains_struct[C][TS_DECL_WRTL] = true)
 
 #define MARK_TS_DECL_WITH_VIS(C)			\
-  do {							\
-    MARK_TS_DECL_WRTL (C);				\
-    tree_contains_struct[C][TS_DECL_WITH_VIS] = 1;	\
-  } while (0)
+  (MARK_TS_DECL_WRTL (C),				\
+   tree_contains_struct[C][TS_DECL_WITH_VIS] = true)
 
 #define MARK_TS_DECL_NON_COMMON(C)			\
-  do {							\
-    MARK_TS_DECL_WITH_VIS (C);				\
-    tree_contains_struct[C][TS_DECL_NON_COMMON] = 1;	\
-  } while (0)
-
+  (MARK_TS_DECL_WITH_VIS (C),				\
+   tree_contains_struct[C][TS_DECL_NON_COMMON] = true)
 
 /* Returns the string representing CLASS.  */