This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Make ir_type differentiate between cfgrtl and cfglayout mode


Hello,

With this patch, we can tell more easily whether we're in cfglayout
mode or in cfgrtl mode.  This becomes necessary when some functions
that previously would see every insn when walking the insns list.
In cfglayout mode the non-insns between basic blocks are not in that
list.  This causes e.g. rebuild_jump_labels to miss all the labels
in jump tables, so I need a way to tell such functions to look in
the bb header and footer as well.  This seems the cleanest solution
to me.

Bootstrapped&tested on x86_64-suse-linux-gnu.  I didn't test ARM but
the change to arm.c pretty trivial anyway.

OK for trunk?

Gr.
Steven

2006-11-01  Steven Bosscher  <steven@gcc.gnu.org>

	* tree-dump.c (dump_enable_all): Rename local variable
	ir_type to avoid name conflicts.
	* cfgloopmanip.c (lv_adjust_loop_entry_edge): Check for IR_GIMPLE
	instead of using ir_type().
	* profile.c (tree_register_profile_hooks): Likewise.
	* value-prof.c (tree_register_value_prof_hooks): Likewise.
	* basic-block.h (struct edge_def): Likewise.
	* config/arm/arm.c (legitimize_pic_address): Likewise.
	* coretypes.h (ir_type): New enum of all intermediate languages
	used in GCC.
	* cfghooks.c (ir_type): Rename to...
	(current_ir_type): ...this.  Distinguish between cfgrtl and
	cfglayout mode when the current IR is RTL.  Return enum ir_type.
	* cfghooks.h (ir_type): Replace with current_ir_type prototype.


Index: tree-dump.c
===================================================================
--- tree-dump.c	(revision 118333)
+++ tree-dump.c	(working copy)
@@ -956,12 +956,12 @@ dump_end (enum tree_dump_index phase ATT
 static int
 dump_enable_all (int flags, int letter)
 {
-  int ir_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
+  int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
   int n = 0;
   size_t i;
 
   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
-    if ((dump_files[i].flags & ir_type)
+    if ((dump_files[i].flags & ir_dump_type)
 	&& (letter == 0 || letter == dump_files[i].letter))
       {
         dump_files[i].state = -1;
@@ -970,7 +970,7 @@ dump_enable_all (int flags, int letter)
       }
 
   for (i = 0; i < extra_dump_files_in_use; i++)
-    if ((extra_dump_files[i].flags & ir_type)
+    if ((extra_dump_files[i].flags & ir_dump_type)
 	&& (letter == 0 || letter == extra_dump_files[i].letter))
       {
         extra_dump_files[i].state = -1;
Index: cfgloopmanip.c
===================================================================
--- cfgloopmanip.c	(revision 118333)
+++ cfgloopmanip.c	(working copy)
@@ -1268,7 +1268,8 @@ lv_adjust_loop_entry_edge (basic_block f
 			  cond_expr);
 
   /* Don't set EDGE_TRUE_VALUE in RTL mode, as it's invalid there.  */
-  e1 = make_edge (new_head, first_head, ir_type () ? EDGE_TRUE_VALUE : 0);
+  e1 = make_edge (new_head, first_head,
+		  current_ir_type () == IR_GIMPLE ? EDGE_TRUE_VALUE : 0);
   set_immediate_dominator (CDI_DOMINATORS, first_head, new_head);
   set_immediate_dominator (CDI_DOMINATORS, second_head, new_head);
 
Index: value-prof.c
===================================================================
--- value-prof.c	(revision 118333)
+++ value-prof.c	(working copy)
@@ -854,8 +854,8 @@ static struct value_prof_hooks tree_valu
 void
 tree_register_value_prof_hooks (void)
 {
+  gcc_assert (current_ir_type () == IR_GIMPLE);
   value_prof_hooks = &tree_value_prof_hooks;
-  gcc_assert (ir_type ());
 }
 
 /* IR-independent entry points.  */
Index: cfghooks.c
===================================================================
--- cfghooks.c	(revision 118333)
+++ cfghooks.c	(working copy)
@@ -55,12 +55,19 @@ tree_register_cfg_hooks (void)
   cfg_hooks = &tree_cfg_hooks;
 }
 
-/* Returns current ir type (rtl = 0, trees = 1).  */
+/* Returns current ir type.  */
 
-int
-ir_type (void)
+enum ir_type
+current_ir_type (void)
 {
-  return cfg_hooks == &tree_cfg_hooks ? 1 : 0;
+  if (cfg_hooks == &tree_cfg_hooks)
+    return IR_GIMPLE;
+  else if (cfg_hooks == &rtl_cfg_hooks)
+    return IR_RTL_CFGRTL;
+  else if (cfg_hooks == &cfg_layout_rtl_cfg_hooks)
+    return IR_RTL_CFGLAYOUT;
+  else
+    gcc_unreachable ();
 }
 
 /* Verify the CFG consistency.
Index: cfghooks.h
===================================================================
--- cfghooks.h	(revision 118333)
+++ cfghooks.h	(working copy)
@@ -184,7 +184,7 @@ extern struct cfg_hooks rtl_cfg_hooks;
 extern struct cfg_hooks cfg_layout_rtl_cfg_hooks;
 
 /* Declarations.  */
-extern int ir_type (void);
+extern enum ir_type current_ir_type (void);
 extern void rtl_register_cfg_hooks (void);
 extern void cfg_layout_rtl_register_cfg_hooks (void);
 extern void tree_register_cfg_hooks (void);
Index: profile.c
===================================================================
--- profile.c	(revision 118333)
+++ profile.c	(working copy)
@@ -1228,7 +1228,7 @@ end_branch_prob (void)
 void
 tree_register_profile_hooks (void)
 {
-  gcc_assert (ir_type ());
+  gcc_assert (current_ir_type () == IR_GIMPLE);
   profile_hooks = &tree_profile_hooks;
 }
 
Index: coretypes.h
===================================================================
--- coretypes.h	(revision 118333)
+++ coretypes.h	(working copy)
@@ -48,6 +48,13 @@ typedef union tree_node *tree;
 union section;
 typedef union section section;
 
+/* The major intermediate representations of GCC.  */
+enum ir_type {
+  IR_GIMPLE,
+  IR_RTL_CFGRTL,
+  IR_RTL_CFGLAYOUT
+};
+
 /* Provide forward struct declaration so that we don't have to include
    all of cpplib.h whenever a random prototype includes a pointer.
    Note that the cpp_reader typedef remains part of cpplib.h.  */
Index: basic-block.h
===================================================================
--- basic-block.h	(revision 118333)
+++ basic-block.h	(working copy)
@@ -123,9 +123,9 @@ struct edge_def GTY(())
 
   /* Instructions queued on the edge.  */
   union edge_def_insns {
-    rtx GTY ((tag ("0"))) r;
-    tree GTY ((tag ("1"))) t;
-  } GTY ((desc ("ir_type ()"))) insns;
+    tree GTY ((tag ("true"))) t;
+    rtx GTY ((tag ("false"))) r;
+  } GTY ((desc ("current_ir_type () == IR_GIMPLE"))) insns;
 
   /* Auxiliary info specific to a pass.  */
   PTR GTY ((skip (""))) aux;
Index: config/arm/arm.c
===================================================================
--- config/arm/arm.c	(revision 118333)
+++ config/arm/arm.c	(working copy)
@@ -3222,7 +3222,7 @@ legitimize_pic_address (rtx orig, enum m
 	      /* Play games to avoid marking the function as needing pic
 		 if we are being called as part of the cost-estimation
 		 process.  */
-	      if (!ir_type())
+	      if (current_ir_type () != IR_GIMPLE)
 		current_function_uses_pic_offset_table = 1;
 	    }
 	  else
@@ -3234,7 +3234,7 @@ legitimize_pic_address (rtx orig, enum m
 	      /* Play games to avoid marking the function as needing pic
 		 if we are being called as part of the cost-estimation
 		 process.  */
-	      if (!ir_type())
+	      if (current_ir_type () != IR_GIMPLE)
 		{
 		  current_function_uses_pic_offset_table = 1;
 		  start_sequence ();


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]