Patchwork split gfc_code.backend_decl into separate fields

login
register
mail settings
Submitter Nathan Froyd
Date June 27, 2010, 7:34 p.m.
Message ID <20100627193443.GV22606@codesourcery.com>
Download mbox | patch
Permalink /patch/57098/
State New
Headers show

Comments

Nathan Froyd - June 27, 2010, 7:34 p.m.
gfc_code.backend_decl is an unusual animal: a field which is only ever
assigned a single, un-TREE_CHAIN'd TREE_LIST.  In the interest of
getting rid of TREE_LIST uses throughout the compiler, the patch below
splits backend_decl into the appropriate two fields.

Tested on x86_64-unknown-linux-gnu.  OK to commit?

-Nathan

	* gfortran.h (gfc_code): Split backend_decl field into cycle_label
	and exit_label fields.
	* trans-openmp.c (gfc_trans_omp_do): Assign to new fields
	individually.
	* trans-stmt.c (gfc_trans_simple_do): Likewise.
	(gfc_trans_do): Likewise.
	(gfc_trans_do_while): Likewise.
	(gfc_trans_cycle): Use cycle_label directly.
	(gfc_trans_exit): Use exit_label directly.
Steven Bosscher - June 27, 2010, 7:39 p.m.
On Sun, Jun 27, 2010 at 9:34 PM, Nathan Froyd <froydnj@codesourcery.com> wrote:
> gfc_code.backend_decl is an unusual animal: a field which is only ever
> assigned a single, un-TREE_CHAIN'd TREE_LIST.  In the interest of
> getting rid of TREE_LIST uses throughout the compiler, the patch below
> splits backend_decl into the appropriate two fields.
>
> Tested on x86_64-unknown-linux-gnu.  OK to commit?

This is fine. Please don't forget to send a commit confirmation.

Ciao!
Steven
Tobias Burnus - June 27, 2010, 7:41 p.m.
Nathan Froyd wrote:
> gfc_code.backend_decl is an unusual animal: a field which is only ever
> assigned a single, un-TREE_CHAIN'd TREE_LIST.  In the interest of
> getting rid of TREE_LIST uses throughout the compiler, the patch below
> splits backend_decl into the appropriate two fields.
>
> Tested on x86_64-unknown-linux-gnu.  OK to commit?
>   

OK. Thanks for the patch! I recently had a look at that code and found
it awkward - thus also in terms of readability I like the patch.

Tobias
Nathan Froyd - June 27, 2010, 8:01 p.m.
On Sun, Jun 27, 2010 at 09:41:53PM +0200, Tobias Burnus wrote:
> Nathan Froyd wrote:
> > gfc_code.backend_decl is an unusual animal: a field which is only ever
> > assigned a single, un-TREE_CHAIN'd TREE_LIST.  In the interest of
> > getting rid of TREE_LIST uses throughout the compiler, the patch below
> > splits backend_decl into the appropriate two fields.
> 
> OK. Thanks for the patch! I recently had a look at that code and found
> it awkward - thus also in terms of readability I like the patch.

Yes, my head hurts trying to keep TREE_PURPOSE and TREE_VALUE straight
when translating away from TREE_LIST. :)

Thanks for the review.  Committed as r161473.

-Nathan

Patch

diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 4a9b5f0..0c96bf4 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -2077,9 +2077,9 @@  typedef struct gfc_code
   }
   ext;		/* Points to additional structures required by statement */
 
-  /* Backend_decl is used for cycle and break labels in do loops, and
-     probably for other constructs as well, once we translate them.  */
-  tree backend_decl;
+  /* Cycle and break labels in do loops.  */
+  tree cycle_label;
+  tree exit_label;
 }
 gfc_code;
 
diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c
index 1be4b81..a5d5ba1 100644
--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -1357,12 +1357,10 @@  gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock,
      present for this loop.  */
   cycle_label = gfc_build_label_decl (NULL_TREE);
 
-  /* Put these labels where they can be found later. We put the
-     labels in a TREE_LIST node (because TREE_CHAIN is already
-     used). cycle_label goes in TREE_PURPOSE (backend_decl), exit
-     label in TREE_VALUE (backend_decl).  */
+  /* Put these labels where they can be found later.  */
 
-  code->block->backend_decl = tree_cons (cycle_label, NULL, NULL);
+  code->block->cycle_label = cycle_label;
+  code->block->exit_label = NULL_TREE;
 
   /* Main loop body.  */
   tmp = gfc_trans_omp_code (code->block->next, true);
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
index ad05426..6fa84b9 100644
--- a/gcc/fortran/trans-stmt.c
+++ b/gcc/fortran/trans-stmt.c
@@ -928,7 +928,8 @@  gfc_trans_simple_do (gfc_code * code, stmtblock_t *pblock, tree dovar,
   exit_label = gfc_build_label_decl (NULL_TREE);
 
   /* Put the labels where they can be found later. See gfc_trans_do().  */
-  code->block->backend_decl = tree_cons (cycle_label, exit_label, NULL);
+  code->block->cycle_label = cycle_label;
+  code->block->exit_label = exit_label;
 
   /* Loop body.  */
   gfc_start_block (&body);
@@ -1196,12 +1197,10 @@  gfc_trans_do (gfc_code * code, tree exit_cond)
   /* Loop body.  */
   gfc_start_block (&body);
 
-  /* Put these labels where they can be found later. We put the
-     labels in a TREE_LIST node (because TREE_CHAIN is already
-     used). cycle_label goes in TREE_PURPOSE (backend_decl), exit
-     label in TREE_VALUE (backend_decl).  */
+  /* Put these labels where they can be found later.  */
 
-  code->block->backend_decl = tree_cons (cycle_label, exit_label, NULL);
+  code->block->cycle_label = cycle_label;
+  code->block->exit_label = exit_label;
 
   /* Main loop body.  */
   tmp = gfc_trans_code_cond (code->block->next, exit_cond);
@@ -1305,7 +1304,8 @@  gfc_trans_do_while (gfc_code * code)
   exit_label = gfc_build_label_decl (NULL_TREE);
 
   /* Put the labels where they can be found later. See gfc_trans_do().  */
-  code->block->backend_decl = tree_cons (cycle_label, exit_label, NULL);
+  code->block->cycle_label = cycle_label;
+  code->block->exit_label = exit_label;
 
   /* Create a GIMPLE version of the exit condition.  */
   gfc_init_se (&cond, NULL);
@@ -4080,7 +4080,7 @@  gfc_trans_cycle (gfc_code * code)
 {
   tree cycle_label;
 
-  cycle_label = TREE_PURPOSE (code->ext.whichloop->backend_decl);
+  cycle_label = code->ext.whichloop->cycle_label;
   TREE_USED (cycle_label) = 1;
   return build1_v (GOTO_EXPR, cycle_label);
 }
@@ -4095,7 +4095,7 @@  gfc_trans_exit (gfc_code * code)
 {
   tree exit_label;
 
-  exit_label = TREE_VALUE (code->ext.whichloop->backend_decl);
+  exit_label = code->ext.whichloop->exit_label;
   TREE_USED (exit_label) = 1;
   return build1_v (GOTO_EXPR, exit_label);
 }