From patchwork Sun Jun 27 19:34:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: split gfc_code.backend_decl into separate fields Date: Sun, 27 Jun 2010 09:34:43 -0000 From: Nathan Froyd X-Patchwork-Id: 57098 Message-Id: <20100627193443.GV22606@codesourcery.com> To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org 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. 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); }