aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriele Svelto <gsvelto@gcc.gnu.org>2009-07-14 22:15:45 +0000
committerGabriele Svelto <gsvelto@gcc.gnu.org>2009-07-14 22:15:45 +0000
commit8e5ab52a0c9b28252b3fe3b657af2c1862131390 (patch)
tree3374a6fa5c9ff04d08719e982aa9eaf04161d29f
parentebe70b1c0c01a4cffc4fddc2220df34baf8aafe4 (diff)
merge from gcc trunk rev 132492:145122 2/2
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/st/cli-be@149646 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cfgexpand.c9
-rw-r--r--gcc/config/cil32/bb-layout.c10
-rw-r--r--gcc/config/cil32/cil-dump.c11
-rw-r--r--gcc/config/cil32/cil-lower.c10
-rw-r--r--gcc/config/cil32/cil-refs.c4
-rw-r--r--gcc/config/cil32/cil-stmt-inline.h4
-rw-r--r--gcc/config/cil32/cil-stmt.c6
-rw-r--r--gcc/config/cil32/cil-types.h2
-rw-r--r--gcc/config/cil32/cil32.h24
-rw-r--r--gcc/config/cil32/emit-cil.c40
-rw-r--r--gcc/config/cil32/emit-cil.h10
-rw-r--r--gcc/config/cil32/emit-hints.c41
-rw-r--r--gcc/config/cil32/emit-hints.h2
-rw-r--r--gcc/config/cil32/gimple-to-cil.c204
-rw-r--r--gcc/config/cil32/missing-protos.c10
-rw-r--r--gcc/config/cil32/peephole.c10
-rw-r--r--gcc/config/cil32/remove-convs.c10
-rw-r--r--gcc/config/cil32/remove-temps.c10
-rw-r--r--gcc/config/cil32/simp-cond.c14
-rw-r--r--gcc/config/cil32/t-cil324
-rw-r--r--gcc/config/cil32/tree-simp-cil-early.c416
-rw-r--r--gcc/profile.c39
22 files changed, 428 insertions, 462 deletions
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 4bfdc5fed74..9624dd8a4aa 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -96,13 +96,18 @@ set_expr_location_r (tree *tp, int *ws ATTRIBUTE_UNUSED, void *data)
}
+/* This prototypes are needed as we made gimple_to_tree() and
+ release_stmt_tree() non-static. */
+extern tree gimple_to_tree (gimple);
+extern void release_stmt_tree (gimple, tree);
+
/* RTL expansion has traditionally been done on trees, so the
transition to doing it on GIMPLE tuples is very invasive to the RTL
expander. To facilitate the transition, this function takes a
GIMPLE tuple STMT and returns the same statement in the form of a
tree. */
-static tree
+tree
gimple_to_tree (gimple stmt)
{
tree t;
@@ -341,7 +346,7 @@ gimple_to_tree (gimple stmt)
/* Release back to GC memory allocated by gimple_to_tree. */
-static void
+void
release_stmt_tree (gimple stmt, tree stmt_tree)
{
tree_ann_common_t ann;
diff --git a/gcc/config/cil32/bb-layout.c b/gcc/config/cil32/bb-layout.c
index 76f94418fdd..384ad125754 100644
--- a/gcc/config/cil32/bb-layout.c
+++ b/gcc/config/cil32/bb-layout.c
@@ -186,8 +186,10 @@ bblayout_gate (void)
/* Define the parameters of the bb layout pass. */
-struct tree_opt_pass pass_bb_layout =
+struct gimple_opt_pass pass_bb_layout =
{
+ {
+ GIMPLE_PASS, /* type */
"bblayout", /* name */
bblayout_gate, /* gate */
bblayout, /* execute */
@@ -199,9 +201,9 @@ struct tree_opt_pass pass_bb_layout =
0, /* properties_provided */
/* ??? If TER is enabled, we also kill gimple. */
0, /* properties_destroyed */
- 0,
- TODO_dump_func, /* todo_flags_finish */
- 0 /* letter */
+ 0, /* todo_flags_start */
+ TODO_dump_func /* todo_flags_finish */
+ }
};
/*
diff --git a/gcc/config/cil32/cil-dump.c b/gcc/config/cil32/cil-dump.c
index 966573b0d5c..0873fb108f8 100644
--- a/gcc/config/cil32/cil-dump.c
+++ b/gcc/config/cil32/cil-dump.c
@@ -35,7 +35,6 @@ Erven Rohou <erven.rohou@inria.fr>
#include "tm.h"
#include "real.h"
#include "tree.h"
-#include "tree-pass.h"
#include "langhooks.h"
#include "pointer-set.h"
@@ -72,7 +71,7 @@ static const char* const cil_type_names[] = {
static void
dump_label_name (const_tree label)
{
- printf ("?L" HOST_WIDE_INT_PRINT_DEC, LABEL_DECL_UID (label));
+ printf ("?L" HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT) LABEL_DECL_UID (label));
}
/* Dump the name of a _DECL node pointed by NODE. */
@@ -364,6 +363,7 @@ dump_cil_stmt (const_cil_stmt stmt, cil_stack stack)
gcc_unreachable ();
}
break;
+
case CIL_STRING:
gcc_assert (opcode == CIL_ASM);
printf ("\n\t// BEGIN ASM"
@@ -371,8 +371,10 @@ dump_cil_stmt (const_cil_stmt stmt, cil_stack stack)
"\n\t// END ASM",
TREE_STRING_POINTER (cil_string (stmt)));
break;
+
case CIL_NONE:
break;
+
default:
gcc_unreachable ();
}
@@ -386,12 +388,11 @@ static void
dump_cil_bb (basic_block bb, cil_stack stack)
{
cil_stmt_iterator csi;
- block_stmt_iterator bsi = bsi_start (bb);
- tree label;
cil_stmt stmt = NULL;
+ tree label;
/* Dump this block label */
- label = LABEL_EXPR_LABEL (bsi_stmt (bsi));
+ label = gimple_block_label (bb);
printf ("\n");
dump_label_name (label);
printf (":\n");
diff --git a/gcc/config/cil32/cil-lower.c b/gcc/config/cil32/cil-lower.c
index 6e2c327bf66..754ba6b964a 100644
--- a/gcc/config/cil32/cil-lower.c
+++ b/gcc/config/cil32/cil-lower.c
@@ -581,8 +581,10 @@ lower_cil_gate (void)
/* Define the parameters of the CIL lowering pass. */
-struct tree_opt_pass pass_lower_cil =
+struct gimple_opt_pass pass_lower_cil =
{
+ {
+ GIMPLE_PASS, /* type */
"lowercil", /* name */
lower_cil_gate, /* gate */
lower_cil, /* execute */
@@ -593,9 +595,9 @@ struct tree_opt_pass pass_lower_cil =
PROP_cfg, /* properties_required */
0, /* properties_provided */
0, /* properties_destroyed */
- 0,
- 0, /* todo_flags_finish */
- 0 /* letter */
+ 0, /* todo_flags_start */
+ 0 /* todo_flags_finish */
+ }
};
/*
diff --git a/gcc/config/cil32/cil-refs.c b/gcc/config/cil32/cil-refs.c
index d02e6852808..2ab8c52bf37 100644
--- a/gcc/config/cil32/cil-refs.c
+++ b/gcc/config/cil32/cil-refs.c
@@ -1053,9 +1053,9 @@ get_addr_taken_label_id (tree label)
static int
fill_label_addrs (void **slot, void *data)
{
- tree addrs = data;
+ tree addrs = (tree) data;
tree case_label;
- label_addr addr = *slot;
+ label_addr addr = (label_addr) *slot;
if (DECL_CONTEXT (addr->label) == current_function_decl)
{
diff --git a/gcc/config/cil32/cil-stmt-inline.h b/gcc/config/cil32/cil-stmt-inline.h
index f52225467e5..ad319eeea7c 100644
--- a/gcc/config/cil32/cil-stmt-inline.h
+++ b/gcc/config/cil32/cil-stmt-inline.h
@@ -63,7 +63,7 @@ cil_set_bb (cil_stmt stmt, basic_block bb)
/* Return locus information for statement STMT. */
-static inline source_locus
+static inline source_location
cil_locus (const_cil_stmt stmt)
{
return stmt->locus;
@@ -72,7 +72,7 @@ cil_locus (const_cil_stmt stmt)
/* Set locus information for statement STMT. */
static inline void
-cil_set_locus (cil_stmt stmt, source_locus locus)
+cil_set_locus (cil_stmt stmt, source_location locus)
{
stmt->locus = locus;
}
diff --git a/gcc/config/cil32/cil-stmt.c b/gcc/config/cil32/cil-stmt.c
index 2f10e49989d..7a2f1886d1e 100644
--- a/gcc/config/cil32/cil-stmt.c
+++ b/gcc/config/cil32/cil-stmt.c
@@ -375,6 +375,7 @@ int
cil_prefix_unaligned (const_cil_stmt stmt)
{
int result = 0;
+
if (((stmt->opcode == CIL_CPBLK) || (stmt->opcode == CIL_INITBLK)
|| (stmt->opcode == CIL_LDOBJ) || (stmt->opcode == CIL_STOBJ)
|| (stmt->opcode == CIL_LDVEC) || (stmt->opcode == CIL_STVEC)
@@ -382,7 +383,9 @@ cil_prefix_unaligned (const_cil_stmt stmt)
|| ((stmt->opcode >= CIL_STIND_I1) && (stmt->opcode <= CIL_STIND_I))
|| (stmt->opcode == CIL_LDFLD) || (stmt->opcode == CIL_STFLD))
&& stmt->prefix_unaligned)
- result = stmt->alignment;
+ {
+ result = stmt->alignment;
+ }
return result;
}
@@ -436,6 +439,7 @@ cil_prefix_volatile (const_cil_stmt stmt)
|| (stmt->opcode == CIL_LDSFLD) || (stmt->opcode == CIL_STSFLD))
&& stmt->prefix_volatile);
}
+
/* Returns TRUE if the CIL stsatement STMT represents a conversion, FALSE
otherwise. */
diff --git a/gcc/config/cil32/cil-types.h b/gcc/config/cil32/cil-types.h
index 6db6eeefb49..6d57acb63fe 100644
--- a/gcc/config/cil32/cil-types.h
+++ b/gcc/config/cil32/cil-types.h
@@ -97,7 +97,7 @@ extern enum cil_arg_type opcode_arg_types[];
static inline enum cil_arg_type opcode_arg_type (enum cil_opcode cil_opcode)
{
- return opcode_arg_types[cil_opcode];
+ return opcode_arg_types[cil_opcode];
}
/* Represents the information provided by a CALL_EXPR when converted to a CIL
diff --git a/gcc/config/cil32/cil32.h b/gcc/config/cil32/cil32.h
index 2e97e71f56d..6dc83314fe6 100644
--- a/gcc/config/cil32/cil32.h
+++ b/gcc/config/cil32/cil32.h
@@ -93,7 +93,7 @@ extern int target_flags;
#define WORDS_BIG_ENDIAN 0
#define UNITS_PER_WORD 4
-#define UNITS_PER_SIMD_WORD 16
+#define UNITS_PER_SIMD_WORD(mode) 16
/* Unused by cil32 machine */
#define PARM_BOUNDARY 32
@@ -537,17 +537,17 @@ struct cum_args {int regs;};
#define NO_IMPLICIT_EXTERN_C
-extern struct tree_opt_pass pass_simp_cil_early;
-extern struct tree_opt_pass pass_bb_layout;
-extern struct tree_opt_pass pass_gimple_to_cil;
-extern struct tree_opt_pass pass_missing_protos;
-extern struct tree_opt_pass pass_cil_peephole;
-extern struct tree_opt_pass pass_remove_convs;
-extern struct tree_opt_pass pass_remove_temps;
-extern struct tree_opt_pass pass_simp_cond;
-extern struct tree_opt_pass pass_emit_cil_vcg;
-extern struct tree_opt_pass pass_emit_cil;
-extern struct tree_opt_pass pass_lower_cil;
+extern struct gimple_opt_pass pass_simp_cil_early;
+extern struct gimple_opt_pass pass_bb_layout;
+extern struct gimple_opt_pass pass_gimple_to_cil;
+extern struct gimple_opt_pass pass_missing_protos;
+extern struct gimple_opt_pass pass_cil_peephole;
+extern struct gimple_opt_pass pass_remove_convs;
+extern struct gimple_opt_pass pass_remove_temps;
+extern struct gimple_opt_pass pass_simp_cond;
+extern struct gimple_opt_pass pass_lower_cil;
+extern struct gimple_opt_pass pass_emit_cil_vcg;
+extern struct gimple_opt_pass pass_emit_cil;
/*
* Local variables:
diff --git a/gcc/config/cil32/emit-cil.c b/gcc/config/cil32/emit-cil.c
index 0bfeb3f051d..18b4ccfba9c 100644
--- a/gcc/config/cil32/emit-cil.c
+++ b/gcc/config/cil32/emit-cil.c
@@ -359,7 +359,8 @@ static void
dump_label_name (FILE *file, tree node)
{
/* Always print the label id. */
- fprintf (file, "?L" HOST_WIDE_INT_PRINT_DEC, LABEL_DECL_UID (node));
+ fprintf (file, "?L" HOST_WIDE_INT_PRINT_DEC,
+ (HOST_WIDE_INT) LABEL_DECL_UID (node));
/* For convenience, also print the identifier when available. Note that the
identifier alone is incorrect: in case of inlining, several labels can
@@ -1169,7 +1170,7 @@ emit_incomplete_type (const void *elem, void *data)
{
const_tree type = (const_tree) elem;
tree type_name = TYPE_NAME (type);
- struct pointer_set_t *emitted_types = data;
+ struct pointer_set_t *emitted_types = (struct pointer_set_t *) data;
gcc_assert (DECL_P (type_name)
|| TREE_CODE (type_name) == IDENTIFIER_NODE);
@@ -1846,7 +1847,7 @@ rename_var (tree var, const char *suffix, unsigned long index)
static void
emit_static_vars (FILE *file, struct function *fun)
{
- tree cell = fun->unexpanded_var_list;
+ tree cell = fun->local_decls;
while (cell != NULL_TREE)
{
@@ -1872,8 +1873,8 @@ emit_static_vars (FILE *file, struct function *fun)
static int
var_uses_compare (const void *t1, const void *t2)
{
- const var_uses_s *vu1 = t1;
- const var_uses_s *vu2 = t2;
+ const var_uses_s *vu1 = (const var_uses_s *) t1;
+ const var_uses_s *vu2 = (const var_uses_s *) t2;
if (vu1->uses == vu2->uses)
return DECL_UID (vu1->var) - DECL_UID (vu2->var);
@@ -1975,6 +1976,7 @@ emit_local_vars (FILE *file, struct function *fun)
/* Emit the local variables starting from the most used ones. */
+ /* FIXME: We shouldn't always set init */
if (fun->machine->locals_init || 1)
fprintf (file, "\n\t.locals init (");
else
@@ -2127,12 +2129,12 @@ static void
emit_cil_bb (FILE *file, basic_block bb)
{
cil_stmt_iterator csi;
- block_stmt_iterator bsi = bsi_start (bb);
+ gimple_stmt_iterator gsi = gsi_start_bb (bb);
tree label;
cil_stmt stmt = NULL;
/* Dump this block label */
- label = LABEL_EXPR_LABEL (bsi_stmt (bsi));
+ label = gimple_label_label (gsi_stmt (gsi));
fprintf (file, "\n");
dump_label_name (file, label);
fprintf (file, ":");
@@ -2152,7 +2154,7 @@ emit_cil_1 (FILE *file, struct function *fun)
/* Make sure that every bb has a label */
FOR_EACH_BB_FN (bb, fun)
{
- tree_block_label (bb);
+ gimple_block_label (bb);
}
emit_referenced_assemblies (file);
@@ -2171,7 +2173,7 @@ emit_cil_1 (FILE *file, struct function *fun)
fprintf (file,
"\n\t.maxstack %u\n"
- "\n} // %s\n",
+ "} // %s\n",
compute_max_stack (fun),
lang_hooks.decl_printable_name (fun->decl, 1));
TREE_ASM_WRITTEN (fun->decl) = 1;
@@ -2197,8 +2199,10 @@ emit_cil (void)
/* Define the parameters of the CIL assembly emission pass. */
-struct tree_opt_pass pass_emit_cil =
+struct gimple_opt_pass pass_emit_cil =
{
+ {
+ GIMPLE_PASS, /* type */
"emitcil", /* name */
emit_cil_gate, /* gate */
emit_cil, /* execute */
@@ -2209,9 +2213,9 @@ struct tree_opt_pass pass_emit_cil =
PROP_cfg, /* properties_required */
0, /* properties_provided */
0, /* properties_destroyed */
- 0,
- 0, /* todo_flags_finish */
- 0 /* letter */
+ 0, /* todo_flags_start */
+ 0 /* todo_flags_finish */
+ }
};
/* This function is mostly a copy of the last part of 'gen_cil'. */
@@ -2303,8 +2307,10 @@ emit_cil_vcg (void)
/* Define the parameters of the CIL_VCG pass. */
-struct tree_opt_pass pass_emit_cil_vcg =
+struct gimple_opt_pass pass_emit_cil_vcg =
{
+ {
+ GIMPLE_PASS, /* type */
"emit_cil_vcg", /* name */
emit_cil_vcg_gate, /* gate */
emit_cil_vcg, /* execute */
@@ -2315,9 +2321,9 @@ struct tree_opt_pass pass_emit_cil_vcg =
PROP_cfg, /* properties_required */
0, /* properties_provided */
0, /* properties_destroyed */
- 0,
- 0, /* todo_flags_finish */
- 0 /* letter */
+ 0, /* todo_flags_start */
+ 0 /* todo_flags_finish */
+ }
};
diff --git a/gcc/config/cil32/emit-cil.h b/gcc/config/cil32/emit-cil.h
index bb3999d8760..dd3dc209f33 100644
--- a/gcc/config/cil32/emit-cil.h
+++ b/gcc/config/cil32/emit-cil.h
@@ -40,11 +40,11 @@ Erven Rohou <erven.rohou@inria.fr>
* Function prototypes *
******************************************************************************/
-void emit_cil_init (void);
-void emit_cil_fini (void);
-void emit_cil_decl (FILE *, tree);
+extern void emit_cil_init (void);
+extern void emit_cil_fini (void);
+extern void emit_cil_decl (FILE *, tree);
-void emit_vcg_init (void);
-void emit_vcg_fini (void);
+extern void emit_vcg_init (void);
+extern void emit_vcg_fini (void);
#endif /* EMIT_CIL_H */
diff --git a/gcc/config/cil32/emit-hints.c b/gcc/config/cil32/emit-hints.c
index 4d6dc9b20cf..388e6623c2f 100644
--- a/gcc/config/cil32/emit-hints.c
+++ b/gcc/config/cil32/emit-hints.c
@@ -113,30 +113,21 @@ static struct branch_prob_list_node *branch_prob_list_head = NULL;
static struct branch_prob_list_node *branch_prob_list_tail = NULL;
-/* Given COND_EXPR statement NODE, register the probability that is taken.
+/* Given COND_EXPR statement NODE, and its true edge TRUE_EDGE and register the
+ probability that is taken.
Also dump a comment with such a probability to FILE. */
void
-branch_probability_add (FILE *file ATTRIBUTE_UNUSED, tree node)
+branch_probability_add (FILE *file ATTRIBUTE_UNUSED, tree node, edge true_edge)
{
- edge e;
struct branch_prob_list_node *n;
gcc_assert (TREE_CODE (node) == COND_EXPR);
- {
- edge true_edge;
- edge false_edge;
- basic_block src_bb = get_stmt_ann (node)->bb;
- extract_true_false_edges_from_block (src_bb, &true_edge, &false_edge);
- e = true_edge;
- gcc_assert (e);
- }
-
/* Initialize new branch probability node */
n = XNEW (struct branch_prob_list_node);
n->next = NULL;
- n->branch_prob = e->probability;
+ n->branch_prob = true_edge->probability;
/* Update branch probability list */
if (branch_prob_list_head)
@@ -254,15 +245,15 @@ basic_block_frequency_emit (FILE *file, struct function *fun)
FOR_EACH_BB_FN (bb, fun)
{
- block_stmt_iterator last_bsi = bsi_last (bb);
+ gimple_stmt_iterator last_gsi = gsi_last_bb (bb);
- if (bsi_end_p (last_bsi))
+ if (gsi_end_p (last_gsi))
--emitted_bbs;
else
{
- tree last = bsi_stmt (last_bsi);
+ gimple last = gsi_stmt (last_gsi);
- if (TREE_CODE (last) == COND_EXPR)
+ if (gimple_code (last) == GIMPLE_COND)
{
edge true_edge;
edge false_edge;
@@ -293,11 +284,11 @@ basic_block_frequency_emit (FILE *file, struct function *fun)
Beware that some GIMPLE blocks are emitted as two blocks! */
FOR_EACH_BB_FN (bb, fun)
{
- block_stmt_iterator last_bsi = bsi_last (bb);
+ gimple_stmt_iterator last_gsi = gsi_last_bb (bb);
int freq_class;
/* Frequency is not emitted for an empty basic block */
- if (bsi_end_p (last_bsi))
+ if (gsi_end_p (last_gsi))
continue;
fprintf (file, "%02x ", bb->frequency * 100 / BB_FREQ_MAX);
@@ -308,8 +299,7 @@ basic_block_frequency_emit (FILE *file, struct function *fun)
coding[freq_class].num_bits,
coding[freq_class].code);
- if (TREE_CODE (bsi_stmt (last_bsi)) == COND_EXPR)
- {
+ if (gimple_code (gsi_stmt (last_gsi)) == GIMPLE_COND) {
edge true_edge;
edge false_edge;
basic_block dest_bb;
@@ -323,8 +313,8 @@ basic_block_frequency_emit (FILE *file, struct function *fun)
int new_bb_frequency;
gcc_assert (split_edge);
- new_bb_frequency =
- (bb->frequency * split_edge->probability) / REG_BR_PROB_BASE;
+ new_bb_frequency = (bb->frequency * split_edge->probability)
+ / REG_BR_PROB_BASE;
fprintf (file, "%02x ",
new_bb_frequency * 100 / BB_FREQ_MAX);
@@ -370,9 +360,8 @@ basic_block_frequency_emit (FILE *file, struct function *fun)
for (n = branch_prob_list_head; n; n = n->next)
{
- int prob_class =
- ((n->branch_prob * 256 - REG_BR_PROB_BASE * 256 / 16)
- * 7 / REG_BR_PROB_BASE) / 256;
+ int prob_class = ((n->branch_prob * 256 - REG_BR_PROB_BASE * 256 / 16)
+ * 7 / REG_BR_PROB_BASE) / 256;
gcc_assert (prob_class >= -1 && prob_class <= 7);
diff --git a/gcc/config/cil32/emit-hints.h b/gcc/config/cil32/emit-hints.h
index 3b172360212..74713246c22 100644
--- a/gcc/config/cil32/emit-hints.h
+++ b/gcc/config/cil32/emit-hints.h
@@ -35,7 +35,7 @@ Erven Rohou <erven.rohou@inria.fr>
#include "coretypes.h"
-void branch_probability_add (FILE *, tree);
+void branch_probability_add (FILE *, tree, edge);
void branch_probability_emit_and_reset (FILE *);
void basic_block_frequency_emit (FILE *, struct function *);
diff --git a/gcc/config/cil32/gimple-to-cil.c b/gcc/config/cil32/gimple-to-cil.c
index 6881893b99a..be0f5e86752 100644
--- a/gcc/config/cil32/gimple-to-cil.c
+++ b/gcc/config/cil32/gimple-to-cil.c
@@ -59,6 +59,10 @@ Erven Rohou <erven.rohou@inria.fr>
even though they are declared to return a non-VOID value. */
static tree res_var;
+/* Defined in cfgexpand.c, made non-local so that we can use it here */
+extern tree gimple_to_tree (gimple);
+extern void release_stmt_tree (gimple, tree);
+
/******************************************************************************
* Local functions prototypes *
******************************************************************************/
@@ -264,7 +268,7 @@ gen_addr_expr (cil_stmt_iterator *csi, tree node)
case INDIRECT_REF:
case MISALIGNED_INDIRECT_REF:
- gimple_to_cil_node (csi, GENERIC_TREE_OPERAND (node, 0));
+ gimple_to_cil_node (csi, TREE_OPERAND (node, 0));
break;
case ARRAY_REF:
@@ -273,8 +277,8 @@ gen_addr_expr (cil_stmt_iterator *csi, tree node)
case COMPONENT_REF:
{
- tree obj = GENERIC_TREE_OPERAND (node, 0);
- tree fld = GENERIC_TREE_OPERAND (node, 1);
+ tree obj = TREE_OPERAND (node, 0);
+ tree fld = TREE_OPERAND (node, 1);
tree obj_type = TYPE_MAIN_VARIANT (TREE_TYPE (obj));
gcc_assert (!DECL_BIT_FIELD (fld));
@@ -288,14 +292,14 @@ gen_addr_expr (cil_stmt_iterator *csi, tree node)
break;
case VIEW_CONVERT_EXPR:
- gen_addr_expr (csi, GENERIC_TREE_OPERAND (node, 0));
+ gen_addr_expr (csi, TREE_OPERAND (node, 0));
csi_insert_after (csi, cil_build_stmt (CIL_CONV_I), CSI_CONTINUE_LINKING);
break;
case REALPART_EXPR:
case IMAGPART_EXPR:
{
- tree obj = GENERIC_TREE_OPERAND (node, 0);
+ tree obj = TREE_OPERAND (node, 0);
tree type = TREE_TYPE (obj);
gen_addr_expr (csi, obj);
@@ -1269,7 +1273,7 @@ gen_bit_field_modify_expr (cil_stmt_iterator *csi, tree lhs, tree rhs)
/* Strip redundant conversions. */
while (TREE_CODE (tmp) == NOP_EXPR && INTEGRAL_TYPE_P (TREE_TYPE (tmp)))
- tmp = GENERIC_TREE_OPERAND (tmp, 0);
+ tmp = TREE_OPERAND (tmp, 0);
gimple_to_cil_node (csi, tmp);
@@ -1375,10 +1379,9 @@ gen_vector_bitfield_ref_modify_expr (cil_stmt_iterator *csi, tree lhs, tree rhs)
cil_stmt stmt;
tree cst;
- gen_addr_expr (csi, GENERIC_TREE_OPERAND (lhs, 0));
+ gen_addr_expr (csi, TREE_OPERAND (lhs, 0));
csi_insert_after (csi, cil_build_stmt (CIL_CONV_I), CSI_CONTINUE_LINKING);
- cst = size_binop (TRUNC_DIV_EXPR, GENERIC_TREE_OPERAND (lhs, 2),
- bitsize_unit_node);
+ cst = size_binop (TRUNC_DIV_EXPR, TREE_OPERAND (lhs, 2), bitsize_unit_node);
if (!integer_zerop (cst))
{
@@ -1459,8 +1462,8 @@ gen_modify_expr (cil_stmt_iterator *csi, tree lhs, tree rhs)
case COMPONENT_REF:
{
- tree obj = GENERIC_TREE_OPERAND (lhs, 0);
- tree fld = GENERIC_TREE_OPERAND (lhs, 1);
+ tree obj = TREE_OPERAND (lhs, 0);
+ tree fld = TREE_OPERAND (lhs, 1);
mark_referenced_type (TYPE_MAIN_VARIANT (TREE_TYPE (obj)));
@@ -1494,7 +1497,7 @@ gen_modify_expr (cil_stmt_iterator *csi, tree lhs, tree rhs)
break;
case BIT_FIELD_REF:
- if (TREE_CODE (TREE_TYPE (GENERIC_TREE_OPERAND (lhs, 0))) == VECTOR_TYPE)
+ if (TREE_CODE (TREE_TYPE (TREE_OPERAND (lhs, 0))) == VECTOR_TYPE)
gen_vector_bitfield_ref_modify_expr (csi, lhs, rhs);
else
gen_bitfield_ref_modify_expr (csi, lhs, rhs);
@@ -1514,7 +1517,7 @@ gen_goto_expr (cil_stmt_iterator *csi, tree node)
tree label_decl = GOTO_DESTINATION (node);
cil_stmt stmt;
- if (computed_goto_p (node))
+ if (TREE_CODE (label_decl) != LABEL_DECL)
{
/* This is a goto to the address of a label. Labels have
been numbered, and we emit a switch based on that ID. */
@@ -1547,8 +1550,8 @@ gen_cond_expr (cil_stmt_iterator *csi, tree node)
bool uns;
extract_true_false_edges_from_block (csi_bb (*csi), &true_edge, &false_edge);
- label_then = tree_block_label (true_edge->dest);
- label_else = tree_block_label (false_edge->dest);
+ label_then = gimple_block_label (true_edge->dest);
+ label_else = gimple_block_label (false_edge->dest);
cond = COND_EXPR_COND (node);
@@ -1562,8 +1565,8 @@ gen_cond_expr (cil_stmt_iterator *csi, tree node)
}
else
{
- lhs = GENERIC_TREE_OPERAND (cond, 0);
- rhs = GENERIC_TREE_OPERAND (cond, 1);
+ lhs = TREE_OPERAND (cond, 0);
+ rhs = TREE_OPERAND (cond, 1);
type = TREE_TYPE (lhs);
switch (TREE_CODE (cond))
@@ -2297,8 +2300,8 @@ gen_bit_and_expr (cil_stmt_iterator *csi, tree node)
{
enum cil_opcode opcode;
cil_stmt stmt;
- tree op0 = GENERIC_TREE_OPERAND (node, 0);
- tree op1 = GENERIC_TREE_OPERAND (node, 1);
+ tree op0 = TREE_OPERAND (node, 0);
+ tree op1 = TREE_OPERAND (node, 1);
if (TREE_CODE (op0) == INTEGER_CST
&& (TREE_INT_CST_LOW (op0) == 255U
@@ -2371,8 +2374,8 @@ static void
gen_compare_expr (cil_stmt_iterator *csi, tree node)
{
enum tree_code code = TREE_CODE (node);
- tree op0 = GENERIC_TREE_OPERAND (node, 0);
- tree op1 = GENERIC_TREE_OPERAND (node, 1);
+ tree op0 = TREE_OPERAND (node, 0);
+ tree op1 = TREE_OPERAND (node, 1);
cil_stmt stmt;
enum cil_opcode opcode;
@@ -2564,7 +2567,7 @@ gen_minmax_expr (cil_stmt_iterator *csi, tree node)
bool unsignedp;
enum cil32_builtin builtin = 0;
- gimple_to_cil_node (csi, GENERIC_TREE_OPERAND (node, 0));
+ gimple_to_cil_node (csi, TREE_OPERAND (node, 0));
if (POINTER_TYPE_P (type))
{
@@ -2572,7 +2575,7 @@ gen_minmax_expr (cil_stmt_iterator *csi, tree node)
csi_insert_after (csi, stmt, CSI_CONTINUE_LINKING);
}
- gimple_to_cil_node (csi, GENERIC_TREE_OPERAND (node, 1));
+ gimple_to_cil_node (csi, TREE_OPERAND (node, 1));
if (POINTER_TYPE_P (type))
{
@@ -2633,7 +2636,7 @@ gen_abs_expr (cil_stmt_iterator *csi, tree node)
gcc_assert (!TARGET_EXPAND_ABS);
- gimple_to_cil_node (csi, GENERIC_TREE_OPERAND (node, 0));
+ gimple_to_cil_node (csi, TREE_OPERAND (node, 0));
if (INTEGRAL_TYPE_P (type))
{
@@ -2805,8 +2808,8 @@ gen_bit_field_comp_ref (cil_stmt_iterator *csi, tree node)
static void
gen_comp_ref (cil_stmt_iterator *csi, tree node)
{
- tree obj = GENERIC_TREE_OPERAND (node, 0);
- tree fld = GENERIC_TREE_OPERAND (node, 1);
+ tree obj = TREE_OPERAND (node, 0);
+ tree fld = TREE_OPERAND (node, 1);
cil_stmt stmt;
gcc_assert (TREE_CODE (fld) == FIELD_DECL);
@@ -2838,10 +2841,9 @@ gen_vector_bitfield_ref (cil_stmt_iterator *csi, tree node)
cil_stmt stmt;
tree cst;
- gen_addr_expr (csi, GENERIC_TREE_OPERAND (node, 0));
+ gen_addr_expr (csi, TREE_OPERAND (node, 0));
csi_insert_after (csi, cil_build_stmt (CIL_CONV_I), CSI_CONTINUE_LINKING);
- cst = size_binop (TRUNC_DIV_EXPR, GENERIC_TREE_OPERAND (node, 2),
- bitsize_unit_node);
+ cst = size_binop (TRUNC_DIV_EXPR, TREE_OPERAND (node, 2), bitsize_unit_node);
if (!integer_zerop (cst))
{
@@ -2869,10 +2871,11 @@ gen_bit_field_ref (cil_stmt_iterator *csi, tree node)
enum cil_opcode opcode;
tree cont_type;
tree cst;
- tree offset = GENERIC_TREE_OPERAND (node, 2);
+ tree offset = TREE_OPERAND (node, 2);
+ bool unsignedp = TYPE_UNSIGNED (TREE_TYPE (node));
/* TODO: Add support for big-endian targets. */
- gen_addr_expr (csi, GENERIC_TREE_OPERAND (node, 0));
+ gen_addr_expr (csi, TREE_OPERAND (node, 0));
csi_insert_after (csi, cil_build_stmt (CIL_CONV_I), CSI_CONTINUE_LINKING);
cst = size_binop (TRUNC_DIV_EXPR, offset, bitsize_unit_node);
@@ -2892,7 +2895,7 @@ gen_bit_field_ref (cil_stmt_iterator *csi, tree node)
while ((bit_pos % cont_size + bit_size) > cont_size)
cont_size *= 2;
- cont_type = get_integer_type (cont_size, BIT_FIELD_REF_UNSIGNED (node));
+ cont_type = get_integer_type (cont_size, unsignedp);
cont_off = bit_pos % cont_size;
/* Load the container. */
@@ -2922,7 +2925,7 @@ gen_bit_field_ref (cil_stmt_iterator *csi, tree node)
gen_integer_cst (csi,
build_int_cst (intSI_type_node,
cont_size - bit_size));
- opcode = BIT_FIELD_REF_UNSIGNED (node) ? CIL_SHR_UN : CIL_SHR;
+ opcode = unsignedp ? CIL_SHR_UN : CIL_SHR;
stmt = cil_build_stmt (opcode);
csi_insert_after (csi, stmt, CSI_CONTINUE_LINKING);
}
@@ -2936,8 +2939,8 @@ gen_bit_field_ref (cil_stmt_iterator *csi, tree node)
static void
gen_truth_expr (cil_stmt_iterator *csi, tree node)
{
- tree op0 = GENERIC_TREE_OPERAND (node, 0);
- tree op1 = GENERIC_TREE_OPERAND (node, 1);
+ tree op0 = TREE_OPERAND (node, 0);
+ tree op1 = TREE_OPERAND (node, 1);
cil_stmt stmt;
gimple_to_cil_node (csi, op0);
@@ -3136,16 +3139,16 @@ static void
gen_complex_part_expr (cil_stmt_iterator *csi, tree node)
{
cil_stmt stmt;
- tree op0 = GENERIC_TREE_OPERAND (node, 0);
+ tree op0 = TREE_OPERAND (node, 0);
tree type = TREE_TYPE (op0);
if (TREE_CODE (op0) == COMPLEX_EXPR)
{
/* Get the relevant part immediately */
if (TREE_CODE (node) == REALPART_EXPR)
- gimple_to_cil_node (csi, GENERIC_TREE_OPERAND (op0, 0));
+ gimple_to_cil_node (csi, TREE_OPERAND (op0, 0));
else
- gimple_to_cil_node (csi, GENERIC_TREE_OPERAND (op0, 1));
+ gimple_to_cil_node (csi, TREE_OPERAND (op0, 1));
}
else
{
@@ -3403,12 +3406,12 @@ gen_rotate (cil_stmt_iterator *csi, tree node)
/* Rotation is replaced by shifts on unsigned values:
generate the unsigned version of first operand type. */
- op0 = GENERIC_TREE_OPERAND (node, 0);
+ op0 = TREE_OPERAND (node, 0);
uns_type = unsigned_type_for (TREE_TYPE (op0));
op0 = fold_convert (uns_type, op0);
/* Convert the second operand to 32-bit. */
- op1 = fold_convert (intSI_type_node, GENERIC_TREE_OPERAND (node, 1));
+ op1 = fold_convert (intSI_type_node, TREE_OPERAND (node, 1));
/* Build first shift. */
t1 = fold_build2 (left ? LSHIFT_EXPR : RSHIFT_EXPR, uns_type, op0, op1);
@@ -3489,9 +3492,8 @@ gimple_to_cil_node (cil_stmt_iterator *csi, tree node)
case INIT_EXPR:
case MODIFY_EXPR:
- case GIMPLE_MODIFY_STMT:
- op0 = GENERIC_TREE_OPERAND (node, 0);
- op1 = GENERIC_TREE_OPERAND (node, 1);
+ op0 = TREE_OPERAND (node, 0);
+ op1 = TREE_OPERAND (node, 1);
if ((TREE_CODE (op1) == CONSTRUCTOR &&
(TREE_CODE (TREE_TYPE (op1)) != VECTOR_TYPE)) ||
@@ -3560,8 +3562,8 @@ gimple_to_cil_node (cil_stmt_iterator *csi, tree node)
case MINUS_EXPR:
case RDIV_EXPR:
case LSHIFT_EXPR:
- op0 = GENERIC_TREE_OPERAND (node, 0);
- op1 = GENERIC_TREE_OPERAND (node, 1);
+ op0 = TREE_OPERAND (node, 0);
+ op1 = TREE_OPERAND (node, 1);
gimple_to_cil_node (csi, op0);
@@ -3593,8 +3595,8 @@ gimple_to_cil_node (cil_stmt_iterator *csi, tree node)
case BIT_IOR_EXPR:
case BIT_XOR_EXPR:
- op0 = GENERIC_TREE_OPERAND (node, 0);
- op1 = GENERIC_TREE_OPERAND (node, 1);
+ op0 = TREE_OPERAND (node, 0);
+ op1 = TREE_OPERAND (node, 1);
gimple_to_cil_node (csi, op0);
gimple_to_cil_node (csi, op1);
@@ -3641,8 +3643,8 @@ gimple_to_cil_node (cil_stmt_iterator *csi, tree node)
case TRUNC_DIV_EXPR:
case TRUNC_MOD_EXPR:
case RSHIFT_EXPR:
- op0 = GENERIC_TREE_OPERAND (node, 0);
- op1 = GENERIC_TREE_OPERAND (node, 1);
+ op0 = TREE_OPERAND (node, 0);
+ op1 = TREE_OPERAND (node, 1);
uns = TYPE_UNSIGNED (TREE_TYPE (node));
gimple_to_cil_node (csi, op0);
@@ -3680,8 +3682,8 @@ gimple_to_cil_node (cil_stmt_iterator *csi, tree node)
{
bool is_signed0, is_signed1;
- op0 = GENERIC_TREE_OPERAND (node, 0);
- op1 = GENERIC_TREE_OPERAND (node, 1);
+ op0 = TREE_OPERAND (node, 0);
+ op1 = TREE_OPERAND (node, 1);
gimple_to_cil_node (csi, op0);
gimple_to_cil_node (csi, op1);
@@ -3707,7 +3709,7 @@ gimple_to_cil_node (cil_stmt_iterator *csi, tree node)
case NEGATE_EXPR:
case BIT_NOT_EXPR:
- gimple_to_cil_node (csi, GENERIC_TREE_OPERAND (node, 0));
+ gimple_to_cil_node (csi, TREE_OPERAND (node, 0));
if (POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (node, 0))))
{
@@ -3751,7 +3753,7 @@ gimple_to_cil_node (cil_stmt_iterator *csi, tree node)
{
tree type;
- op0 = GENERIC_TREE_OPERAND (node, 0);
+ op0 = TREE_OPERAND (node, 0);
gimple_to_cil_node (csi, op0);
/* Temporaries with weird types are handled correctly without need
@@ -3771,13 +3773,12 @@ gimple_to_cil_node (cil_stmt_iterator *csi, tree node)
break;
case RETURN_EXPR:
- op0 = GENERIC_TREE_OPERAND (node, 0);
+ op0 = TREE_OPERAND (node, 0);
if (op0 != NULL_TREE)
{
- if (TREE_CODE (op0) == MODIFY_EXPR
- || TREE_CODE (op0) == GIMPLE_MODIFY_STMT)
- op0 = GENERIC_TREE_OPERAND (op0, 1);
+ if (TREE_CODE (op0) == MODIFY_EXPR)
+ op0 = TREE_OPERAND (op0, 1);
gimple_to_cil_node (csi, op0);
}
@@ -3859,7 +3860,7 @@ gimple_to_cil_node (cil_stmt_iterator *csi, tree node)
break;
case ADDR_EXPR:
- gen_addr_expr (csi, GENERIC_TREE_OPERAND (node, 0));
+ gen_addr_expr (csi, TREE_OPERAND (node, 0));
break;
case COMPONENT_REF:
@@ -3867,7 +3868,7 @@ gimple_to_cil_node (cil_stmt_iterator *csi, tree node)
break;
case TRUTH_NOT_EXPR:
- gimple_to_cil_node (csi, GENERIC_TREE_OPERAND (node, 0));
+ gimple_to_cil_node (csi, TREE_OPERAND (node, 0));
gen_integer_cst (csi, integer_zero_node);
stmt = cil_build_stmt (CIL_CEQ);
csi_insert_after (csi, stmt, CSI_CONTINUE_LINKING);
@@ -3884,12 +3885,12 @@ gimple_to_cil_node (cil_stmt_iterator *csi, tree node)
/* VIEW_CONVERT_EXPRs may be redundant, check the type of the innermost
object and emit code only if it differs from the topmost conversion.
*/
- tree op0 = GENERIC_TREE_OPERAND (node, 0);
+ tree op0 = TREE_OPERAND (node, 0);
tree dest_type = TREE_TYPE (node);
tree src_type;
while (TREE_CODE (op0) == VIEW_CONVERT_EXPR)
- op0 = GENERIC_TREE_OPERAND (op0, 0);
+ op0 = TREE_OPERAND (op0, 0);
src_type = TREE_TYPE (op0);
@@ -3915,12 +3916,12 @@ gimple_to_cil_node (cil_stmt_iterator *csi, tree node)
case COMPLEX_EXPR:
gen_complex (csi, TREE_TYPE (node),
- GENERIC_TREE_OPERAND (node, 0),
- GENERIC_TREE_OPERAND (node, 1));
+ TREE_OPERAND (node, 0),
+ TREE_OPERAND (node, 1));
break;
case BIT_FIELD_REF:
- if (TREE_CODE (TREE_TYPE (GENERIC_TREE_OPERAND (node, 0))) == VECTOR_TYPE)
+ if (TREE_CODE (TREE_TYPE (TREE_OPERAND (node, 0))) == VECTOR_TYPE)
gen_vector_bitfield_ref (csi, node);
else
gen_bit_field_ref (csi, node);
@@ -3959,31 +3960,31 @@ static void
process_labels (void)
{
basic_block bb;
- block_stmt_iterator bsi;
- tree stmt;
+ gimple_stmt_iterator gsi;
+ gimple stmt;
/* Record all the labels whose address has been taken */
FOR_EACH_BB (bb)
{
- for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
- {
- stmt = bsi_stmt (bsi);
-
- /* Record the address taken labels. */
- if (TREE_CODE (stmt) == LABEL_EXPR)
- {
- tree label = LABEL_EXPR_LABEL (stmt);
- /* Check if the label has its address taken. */
- if (FORCED_LABEL (label))
+ for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+ {
+ stmt = gsi_stmt (gsi);
+
+ /* Record the address taken labels. */
+ if (gimple_code (stmt) == GIMPLE_LABEL)
+ {
+ tree label = gimple_label_label (stmt);
+ /* Check if the label has its address taken. */
+ if (FORCED_LABEL (label))
record_addr_taken_label (label);
- }
- }
+ }
+ }
}
/* Make sure that every bb has a label */
FOR_EACH_BB (bb)
{
- tree_block_label (bb);
+ gimple_block_label (bb);
}
}
@@ -4000,7 +4001,7 @@ process_initializers (void)
cil_stmt_iterator bb_csi = csi_start_bb (single_succ (ENTRY_BLOCK_PTR));
tree cell;
- for (cell = cfun->unexpanded_var_list; cell; cell = TREE_CHAIN (cell))
+ for (cell = cfun->local_decls; cell; cell = TREE_CHAIN (cell))
{
tree var = TREE_VALUE (cell);
tree init = DECL_INITIAL (var);
@@ -4022,11 +4023,12 @@ static unsigned int
gimple_to_cil (void)
{
basic_block bb;
- block_stmt_iterator bsi;
+ gimple_stmt_iterator gsi;
cil_stmt stmt;
cil_seq seq;
cil_stmt_iterator csi, prev_csi;
tree node = NULL_TREE;
+ gimple gimple_node = NULL;
/* Initialization */
refs_init ();
@@ -4041,10 +4043,11 @@ gimple_to_cil (void)
cil_set_bb_seq (bb, seq);
csi = csi_start_bb (bb);
- for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
+ for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
{
- node = bsi_stmt (bsi);
prev_csi = csi;
+ gimple_node = gsi_stmt (gsi);
+ node = gimple_to_tree (gimple_node);
switch (TREE_CODE (node))
{
@@ -4064,17 +4067,17 @@ gimple_to_cil (void)
break;
case GOTO_EXPR:
- gcc_assert (bsi_stmt (bsi_last (bb)) == node);
+ gcc_assert (gsi_stmt (gsi_last_bb (bb)) == gimple_node);
gen_goto_expr (&csi, node);
break;
case COND_EXPR:
- gcc_assert (bsi_stmt (bsi_last (bb)) == node);
+ gcc_assert (gsi_stmt (gsi_last_bb (bb)) == gimple_node);
gen_cond_expr (&csi, node);
break;
case SWITCH_EXPR:
- gcc_assert (bsi_stmt (bsi_last (bb)) == node);
+ gcc_assert (gsi_stmt (gsi_last_bb (bb)) == gimple_node);
gen_switch_expr (&csi, node);
break;
@@ -4086,11 +4089,16 @@ gimple_to_cil (void)
}
}
+ release_stmt_tree (gimple_node, node);
+
for (; !csi_end_p (prev_csi); csi_next (&prev_csi))
- cil_set_locus (csi_stmt (prev_csi), EXPR_LOCATION (node));
+ cil_set_locus (csi_stmt (prev_csi), gimple_location (gimple_node));
}
- if ((!node || (TREE_CODE (node) != COND_EXPR)) && single_succ_p (bb))
+ gimple_node = gsi_stmt (gsi_last_bb (bb));
+
+ if ((!gimple_node || (gimple_code (gimple_node) != GIMPLE_COND))
+ && single_succ_p (bb))
{
basic_block succ = single_succ (bb);
@@ -4100,20 +4108,18 @@ gimple_to_cil (void)
blocks. */
if ((succ->index != EXIT_BLOCK) && (succ != bb->next_bb))
{
- tree label = tree_block_label (succ);
+ tree label = gimple_block_label (succ);
stmt = cil_build_stmt_arg (CIL_BR, label);
cil_set_locus (stmt,
- node ? EXPR_LOCATION (node) : UNKNOWN_LOCATION);
+ gimple_node ? gimple_location (gimple_node)
+ : UNKNOWN_LOCATION);
csi_insert_after (&csi, stmt, CSI_CONTINUE_LINKING);
}
}
else if (EDGE_COUNT (bb->succs) == 0)
{
- bsi = bsi_last (bb);
- node = bsi_stmt (bsi);
-
- if (TREE_CODE (node) != RETURN_EXPR)
+ if (gimple_code (gimple_node) != GIMPLE_RETURN)
{
tree ret_type = TREE_TYPE (TREE_TYPE (current_function_decl));
@@ -4155,8 +4161,10 @@ gimple_to_cil_gate (void)
/* Define the parameters of the tree-final-simp-CIL pass. */
-struct tree_opt_pass pass_gimple_to_cil =
+struct gimple_opt_pass pass_gimple_to_cil =
{
+ {
+ GIMPLE_PASS, /* type */
"gimple2cil", /* name */
gimple_to_cil_gate, /* gate */
gimple_to_cil, /* execute */
@@ -4167,9 +4175,9 @@ struct tree_opt_pass pass_gimple_to_cil =
PROP_cfg, /* properties_required */
0, /* properties_provided */
0, /* properties_destroyed */
- 0,
- TODO_ggc_collect, /* todo_flags_finish */
- 0 /* letter */
+ 0, /* todo_flags_start */
+ TODO_ggc_collect /* todo_flags_finish */
+ }
};
/*
diff --git a/gcc/config/cil32/missing-protos.c b/gcc/config/cil32/missing-protos.c
index be635f7f74a..2fe9d60d272 100644
--- a/gcc/config/cil32/missing-protos.c
+++ b/gcc/config/cil32/missing-protos.c
@@ -201,8 +201,10 @@ missing_protos_gate (void)
/* Define the parameters of the missing-protos pass. */
-struct tree_opt_pass pass_missing_protos =
+struct gimple_opt_pass pass_missing_protos =
{
+ {
+ GIMPLE_PASS, /* type */
"missing_protos", /* name */
missing_protos_gate, /* gate */
missing_protos, /* execute */
@@ -213,9 +215,9 @@ struct tree_opt_pass pass_missing_protos =
PROP_cfg, /* properties_required */
0, /* properties_provided */
0, /* properties_destroyed */
- 0,
- TODO_ggc_collect, /* todo_flags_finish */
- 0 /* letter */
+ 0, /* todo_flags_start */
+ TODO_ggc_collect /* todo_flags_finish */
+ }
};
/*
diff --git a/gcc/config/cil32/peephole.c b/gcc/config/cil32/peephole.c
index be24cf55368..046e13ac9e4 100644
--- a/gcc/config/cil32/peephole.c
+++ b/gcc/config/cil32/peephole.c
@@ -126,8 +126,10 @@ cil_peephole_gate (void)
/* Define the parameters of the peephole-optimizations pass. */
-struct tree_opt_pass pass_cil_peephole =
+struct gimple_opt_pass pass_cil_peephole =
{
+ {
+ GIMPLE_PASS, /* type */
"cil_peephole", /* name */
cil_peephole_gate, /* gate */
cil_peephole, /* execute */
@@ -138,9 +140,9 @@ struct tree_opt_pass pass_cil_peephole =
PROP_cfg, /* properties_required */
0, /* properties_provided */
0, /* properties_destroyed */
- 0,
- TODO_ggc_collect, /* todo_flags_finish */
- 0 /* letter */
+ 0, /* todo_flags_start */
+ TODO_ggc_collect /* todo_flags_finish */
+ }
};
/*
diff --git a/gcc/config/cil32/remove-convs.c b/gcc/config/cil32/remove-convs.c
index 50b97ea4dbd..067e8246465 100644
--- a/gcc/config/cil32/remove-convs.c
+++ b/gcc/config/cil32/remove-convs.c
@@ -309,8 +309,10 @@ remove_convs_gate (void)
/* Define the parameters of the remove-temps pass. */
-struct tree_opt_pass pass_remove_convs =
+struct gimple_opt_pass pass_remove_convs =
{
+ {
+ GIMPLE_PASS, /* type */
"remove_convs", /* name */
remove_convs_gate, /* gate */
remove_convs, /* execute */
@@ -321,9 +323,9 @@ struct tree_opt_pass pass_remove_convs =
PROP_cfg, /* properties_required */
0, /* properties_provided */
0, /* properties_destroyed */
- 0,
- TODO_ggc_collect, /* todo_flags_finish */
- 0 /* letter */
+ 0, /* todo_flags_start */
+ TODO_ggc_collect /* todo_flags_finish */
+ }
};
/*
diff --git a/gcc/config/cil32/remove-temps.c b/gcc/config/cil32/remove-temps.c
index 47a32c6d52a..e9d2ba849e7 100644
--- a/gcc/config/cil32/remove-temps.c
+++ b/gcc/config/cil32/remove-temps.c
@@ -809,8 +809,10 @@ remove_temps_gate (void)
/* Define the parameters of the remove-temps pass. */
-struct tree_opt_pass pass_remove_temps =
+struct gimple_opt_pass pass_remove_temps =
{
+ {
+ GIMPLE_PASS, /* type */
"remove_temps", /* name */
remove_temps_gate, /* gate */
remove_temps, /* execute */
@@ -821,9 +823,9 @@ struct tree_opt_pass pass_remove_temps =
PROP_cfg, /* properties_required */
0, /* properties_provided */
0, /* properties_destroyed */
- 0,
- TODO_ggc_collect, /* todo_flags_finish */
- 0 /* letter */
+ 0, /* todo_flags_start */
+ TODO_ggc_collect /* todo_flags_finish */
+ }
};
/*
diff --git a/gcc/config/cil32/simp-cond.c b/gcc/config/cil32/simp-cond.c
index 5aa3a50b35e..dff1a6087d4 100644
--- a/gcc/config/cil32/simp-cond.c
+++ b/gcc/config/cil32/simp-cond.c
@@ -69,8 +69,8 @@ simplify_cond_branch (cil_stmt_iterator *csi, cil_stack stack)
/* Extract the condition's edges. */
extract_true_false_edges_from_block (csi_bb (*csi), &true_edge, &false_edge);
- label_then = tree_block_label (true_edge->dest);
- label_else = tree_block_label (false_edge->dest);
+ label_then = gimple_block_label (true_edge->dest);
+ label_else = gimple_block_label (false_edge->dest);
then_bb = label_to_block (label_then);
@@ -174,8 +174,10 @@ simp_cond_gate (void)
/* Define the parameters of the cond-simp pass. */
-struct tree_opt_pass pass_simp_cond =
+struct gimple_opt_pass pass_simp_cond =
{
+ {
+ GIMPLE_PASS, /* type */
"cond_simp", /* name */
simp_cond_gate, /* gate */
simp_cond, /* execute */
@@ -186,9 +188,9 @@ struct tree_opt_pass pass_simp_cond =
PROP_cfg, /* properties_required */
0, /* properties_provided */
0, /* properties_destroyed */
- 0,
- TODO_ggc_collect, /* todo_flags_finish */
- 0 /* letter */
+ 0, /* todo_flags_start */
+ TODO_ggc_collect /* todo_flags_finish */
+ }
};
/*
diff --git a/gcc/config/cil32/t-cil32 b/gcc/config/cil32/t-cil32
index 2f11ff81d68..1d16bf59a69 100644
--- a/gcc/config/cil32/t-cil32
+++ b/gcc/config/cil32/t-cil32
@@ -173,7 +173,3 @@ bb-layout.o: $(srcdir)/config/cil32/bb-layout.c \
$(CONFIG_H) $(SYSTEM_H) $(TIMEVAR_H) $(TM_H) $(TREE_H) $(TREE_FLOW_H) \
coretypes.h tree-pass.h
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $< $(OUTPUT_OPTION)
-
-gt-cil-refs.h : s-gtype ; @true
-gt-cil-stmt.h : s-gtype ; @true
-gt-cil-builtins.h : s-gtype ; @true
diff --git a/gcc/config/cil32/tree-simp-cil-early.c b/gcc/config/cil32/tree-simp-cil-early.c
index 6f64f14a918..414ee92b336 100644
--- a/gcc/config/cil32/tree-simp-cil-early.c
+++ b/gcc/config/cil32/tree-simp-cil-early.c
@@ -36,9 +36,8 @@ Erven Rohou <erven.rohou@inria.fr>
#include "coretypes.h"
#include "tm.h"
#include "timevar.h"
+#include "gimple.h"
#include "tree.h"
-#include "tree-gimple.h"
-#include "tree-iterator.h"
#include "tree-pass.h"
#include "pointer-set.h"
@@ -59,21 +58,19 @@ struct eqv_label_entry_t
/* Label manipulation functions */
static bool is_eqv_label (tree, tree);
-static void group_labels (tree);
+static void group_labels (void);
static bool eqv_label_dispose (const void *, void **, void *data);
/* Switch-conversion functions */
-static void merge_cases_into_ranges (tree);
-static void case_to_cond_expr (tree, tree, tree *);
-static void case_range_to_cond_expr (tree, tree, tree *);
-static void cases_to_switch (tree, unsigned int, unsigned int, tree *);
-static tree simp_cil_switch (tree);
-
-/* Misc functionality */
-static void set_statement_list_location (tree, location_t);
+static void merge_cases_into_ranges (gimple);
+static void case_to_cond_expr (gimple, tree, tree, gimple_stmt_iterator *);
+static void case_range_to_cond_expr (gimple, tree, tree,
+ gimple_stmt_iterator *);
+static void cases_to_switch (gimple, unsigned int, unsigned int,
+ tree, gimple_stmt_iterator *);
+static gimple_seq simp_cil_switch (gimple);
/* Top-level functionality */
-static tree simp_cil_stmt (tree);
static unsigned int simp_cil_early (void);
static bool simp_cil_early_gate (void);
@@ -89,25 +86,6 @@ static bool simp_cil_early_gate (void);
static struct pointer_map_t *eqv_labels = NULL;
/******************************************************************************
- * Misc functions *
- ******************************************************************************/
-
-/* Set the location of the statements in the statement list pointed by LIST to
- the location passed in LOCUS */
-
-static void
-set_statement_list_location (tree list, location_t locus)
-{
- tree_stmt_iterator tsi = tsi_start (list);
-
- while (!tsi_end_p (tsi))
- {
- SET_EXPR_LOCATION (tsi_stmt (tsi), locus);
- tsi_next (&tsi);
- }
-}
-
-/******************************************************************************
* Label manipulation functions *
******************************************************************************/
@@ -118,8 +96,8 @@ is_eqv_label (tree label1, tree label2)
{
struct eqv_label_entry_t *t1, *t2;
- t1 = *pointer_map_contains (eqv_labels, label1);
- t2 = *pointer_map_contains (eqv_labels, label2);
+ t1 = (struct eqv_label_entry_t *) *pointer_map_contains (eqv_labels, label1);
+ t2 = (struct eqv_label_entry_t *) *pointer_map_contains (eqv_labels, label2);
if (t1 == NULL || t2 == NULL)
return false;
@@ -135,28 +113,28 @@ is_eqv_label (tree label1, tree label2)
not group equivalent labels which are non-adjacent. */
static void
-group_labels (tree func)
+group_labels (void)
{
- tree_stmt_iterator tsi;
- tree t = NULL_TREE;
+ gimple_stmt_iterator gsi;
+ gimple stmt = NULL;
unsigned int value = 0;
bool prev_label = false;
struct eqv_label_entry_t *entry;
- tsi = tsi_start (func);
+ gsi = gsi_start (gimple_body (current_function_decl));
- while (!tsi_end_p (tsi))
+ while (!gsi_end_p (gsi))
{
- t = tsi_stmt (tsi);
- tsi_next (&tsi);
+ stmt = gsi_stmt (gsi);
+ gsi_next (&gsi);
- if (TREE_CODE (t) == LABEL_EXPR)
+ if (gimple_code (stmt) == GIMPLE_LABEL)
{
/* Insert the label in the hash-table */
entry = XCNEW (struct eqv_label_entry_t);
- entry->label = LABEL_EXPR_LABEL (t);
+ entry->label = gimple_label_label (stmt);
entry->val = value;
- *pointer_map_insert (eqv_labels, LABEL_EXPR_LABEL (t)) = entry;
+ *pointer_map_insert (eqv_labels, gimple_label_label (stmt)) = entry;
prev_label = true;
}
else if (prev_label)
@@ -186,49 +164,41 @@ eqv_label_dispose (const void *key ATTRIBUTE_UNUSED, void **value,
case 1: case 2: case 3: -> case 1 ... 3: */
static void
-merge_cases_into_ranges (tree switch_stmt)
+merge_cases_into_ranges (gimple switch_stmt)
{
- tree labels = SWITCH_LABELS (switch_stmt);
- unsigned int old_size = TREE_VEC_LENGTH (labels);
+ unsigned int old_size = gimple_switch_num_labels (switch_stmt);
unsigned int i, j, new_size = old_size;
- tree default_case = TREE_VEC_ELT (labels, old_size - 1);
- tree default_label;
-
- /* The default label is always the last case in a switch
- statement after gimplification. */
- default_label = CASE_LABEL (default_case);
-
- /* Look for possible opportunities to merge cases.
- Ignore the last element of the label vector because it
- must be the default case. */
- i = 0;
- while (i < old_size - 1)
+ tree default_case = gimple_switch_default_label (switch_stmt);
+ tree default_label = CASE_LABEL (default_case);
+
+ /* Look for possible opportunities to merge cases. Ignore the first label
+ of the switch because it is the default case. */
+ i = 1;
+
+ while (i < old_size)
{
tree base_case, base_label, base_high;
- base_case = TREE_VEC_ELT (labels, i);
-
- gcc_assert (base_case);
+ base_case = gimple_switch_label (switch_stmt, i);
base_label = CASE_LABEL (base_case);
- /* Discard cases that have the same destination as the
- default case. */
+ /* Discard cases that have the same destination as the default case. */
if (is_eqv_label (base_label, default_label))
{
- TREE_VEC_ELT (labels, i) = NULL_TREE;
+ gimple_switch_set_label (switch_stmt, i, NULL_TREE);
i++;
new_size--;
continue;
}
- base_high = CASE_HIGH (base_case) ?
- CASE_HIGH (base_case) : CASE_LOW (base_case);
+ base_high = CASE_HIGH (base_case) ? CASE_HIGH (base_case)
+ : CASE_LOW (base_case);
i++;
/* Try to merge case labels. Break out when we reach the end
of the label vector or when we cannot merge the next case
label with the current one. */
- while (i < old_size - 1)
+ while (i < old_size)
{
- tree merge_case = TREE_VEC_ELT (labels, i);
+ tree merge_case = gimple_switch_label (switch_stmt, i);
tree merge_label = CASE_LABEL (merge_case);
tree t = int_const_binop (PLUS_EXPR, base_high,
integer_one_node, 1);
@@ -238,10 +208,10 @@ merge_cases_into_ranges (tree switch_stmt)
if (is_eqv_label (merge_label, base_label)
&& tree_int_cst_equal (CASE_LOW (merge_case), t))
{
- base_high = CASE_HIGH (merge_case) ?
- CASE_HIGH (merge_case) : CASE_LOW (merge_case);
+ base_high = CASE_HIGH (merge_case) ? CASE_HIGH (merge_case)
+ : CASE_LOW (merge_case);
CASE_HIGH (base_case) = base_high;
- TREE_VEC_ELT (labels, i) = NULL_TREE;
+ gimple_switch_set_label (switch_stmt, i, NULL_TREE);
new_size--;
i++;
}
@@ -254,114 +224,87 @@ merge_cases_into_ranges (tree switch_stmt)
length of the vector. */
for (i = 0, j = 0; i < new_size; i++)
{
- while (!TREE_VEC_ELT (labels, j))
- j++;
+ while ((j < gimple_switch_num_labels (switch_stmt))
+ && (gimple_switch_label (switch_stmt, j) == NULL_TREE))
+ {
+ j++;
+ }
- TREE_VEC_ELT (labels, i) = TREE_VEC_ELT (labels, j++);
+ gimple_switch_set_label (switch_stmt, i,
+ gimple_switch_label (switch_stmt, j++));
}
- TREE_VEC_LENGTH (labels) = new_size;
+ gimple_switch_set_num_labels (switch_stmt, new_size);
}
/* Turn a single isolated case into a COND_EXPR */
static void
-case_to_cond_expr (tree switch_stmt, tree single_case, tree *list)
+case_to_cond_expr (gimple switch_stmt, tree single_case, tree deft,
+ gimple_stmt_iterator *gsi)
{
- tree cmp_stmt, label;
- tree label_decl = create_artificial_label ();
+ gimple cmp_stmt;
- /* Build the COND_EXPR */
- cmp_stmt = build3 (COND_EXPR, void_type_node,
- build2 (EQ_EXPR, boolean_type_node,
- SWITCH_COND (switch_stmt),
- CASE_LOW (single_case)),
- build1 (GOTO_EXPR, void_type_node,
- CASE_LABEL (single_case)),
- build1 (GOTO_EXPR, void_type_node, label_decl));
-
- /* Append the COND_EXPR to the list */
- append_to_statement_list (cmp_stmt, list);
-
- /* Create the label to the next statement and append it to the list */
- label = build1 (LABEL_EXPR, void_type_node, label_decl);
- append_to_statement_list (label, list);
+ /* Build the GIMPLE_COND statement and append it */
+ cmp_stmt = gimple_build_cond (EQ_EXPR, gimple_switch_index (switch_stmt),
+ CASE_LOW (single_case),
+ CASE_LABEL (single_case), deft);
+ gsi_insert_after (gsi, cmp_stmt, GSI_CONTINUE_LINKING);
}
/* Turn a case range into a couple of COND_EXPRs */
static void
-case_range_to_cond_expr (tree switch_stmt, tree case_range, tree *list)
+case_range_to_cond_expr (gimple switch_stmt, tree case_range, tree deft,
+ gimple_stmt_iterator *gsi)
{
- tree label_decl1 = create_artificial_label ();
- tree label_decl2 = create_artificial_label ();
- tree cmp1_stmt, cmp2_stmt, label;
+ tree label_decl = create_artificial_label ();
+ gimple cmp1_stmt, cmp2_stmt, label_stmt;
gcc_assert (CASE_HIGH (case_range) != NULL_TREE
&& CASE_LOW (case_range) != NULL_TREE);
- /* Build the 1st COND_EXPR */
- cmp1_stmt = build3 (COND_EXPR, void_type_node,
- build2 (GE_EXPR, boolean_type_node,
- SWITCH_COND (switch_stmt),
- CASE_LOW (case_range)),
- build1 (GOTO_EXPR, void_type_node,
- label_decl1),
- build1 (GOTO_EXPR, void_type_node,
- label_decl2));
-
- /* Append the 1st COND_EXPR to the list */
- append_to_statement_list (cmp1_stmt, list);
-
- /* Create a new label and append it to the list */
- label = build1 (LABEL_EXPR, void_type_node, label_decl1);
- append_to_statement_list (label, list);
-
- /* Build the 2nd COND_EXPR */
- cmp2_stmt = build3 (COND_EXPR, void_type_node,
- build2 (LE_EXPR, boolean_type_node,
- SWITCH_COND (switch_stmt),
- CASE_HIGH (case_range)),
- build1 (GOTO_EXPR, void_type_node,
- CASE_LABEL (case_range)),
- build1 (GOTO_EXPR, void_type_node,
- label_decl2));
-
- /* Append the 2nd COND_EXPR to the list */
- append_to_statement_list (cmp2_stmt, list);
-
- /* Create the label to the next statement and append it */
- label = build1 (LABEL_EXPR, void_type_node, label_decl2);
- append_to_statement_list (label, list);
+ /* Build and append the 1st GIMPLE_COND */
+ cmp1_stmt = gimple_build_cond (GE_EXPR, gimple_switch_index (switch_stmt),
+ CASE_LOW (case_range), label_decl, deft);
+ gsi_insert_after (gsi, cmp1_stmt, GSI_CONTINUE_LINKING);
+
+ /* Create a new label and append it */
+ label_stmt = gimple_build_label (label_decl);
+ gsi_insert_after (gsi, label_stmt, GSI_CONTINUE_LINKING);
+
+ /* Build and append the 2nd GIMPLE_COND */
+ cmp2_stmt = gimple_build_cond (LE_EXPR, gimple_switch_index (switch_stmt),
+ CASE_HIGH (case_range),
+ CASE_LABEL (case_range), deft);
+ gsi_insert_after (gsi, cmp2_stmt, GSI_CONTINUE_LINKING);
}
-/* Turn the cases between <start> and <end> (included) into a new switch
+/* Turn the cases between START and END (included) into a new switch
statement */
static void
-cases_to_switch (tree switch_stmt, unsigned int start, unsigned int end,
- tree *list)
+cases_to_switch (gimple switch_stmt, unsigned int start, unsigned int end,
+ tree deft, gimple_stmt_iterator *gsi)
{
- tree label_decl;
- tree labels = SWITCH_LABELS (switch_stmt);
- tree stmt, label, vec, deft, elt;
+ gimple stmt;
+ VEC (tree, heap) *vec;
+ tree type, elt;
unsigned int i, len;
tree low, high, range, limit;
- tree type;
- type = TREE_TYPE (CASE_LOW (TREE_VEC_ELT (labels, start)));
+ type = TREE_TYPE (CASE_LOW (gimple_switch_label (switch_stmt, start)));
limit = build_int_cst (type, 8192);
while (start <= end)
{
- label_decl = create_artificial_label ();
- elt = TREE_VEC_ELT (labels, start);
+ elt = gimple_switch_label (switch_stmt, start);
low = CASE_LOW (elt);
len = 1;
while (start + len <= end)
{
- elt = TREE_VEC_ELT (labels, start + len);
+ elt = gimple_switch_label (switch_stmt, start + len);
high = CASE_HIGH (elt) ? CASE_HIGH (elt) : CASE_LOW (elt);
range = size_binop (MINUS_EXPR, high, low);
@@ -372,93 +315,91 @@ cases_to_switch (tree switch_stmt, unsigned int start, unsigned int end,
}
/* Build the switch cases */
- vec = make_tree_vec (len + 1);
+ vec = VEC_alloc (tree, heap, len);
for (i = 0; i < len; i++)
- TREE_VEC_ELT (vec, i) = TREE_VEC_ELT (labels, start + i);
-
- /* Create the new default label */
- deft = build3 (CASE_LABEL_EXPR, void_type_node, NULL_TREE, NULL_TREE,
- label_decl);
- TREE_VEC_ELT (vec, len) = deft;
-
- /* Build the switch statement */
- stmt = build3 (SWITCH_EXPR, TREE_TYPE (switch_stmt),
- SWITCH_COND (switch_stmt), NULL, vec);
-
- /* Append the SWITCH to the list */
- append_to_statement_list (stmt, list);
+ {
+ VEC_quick_push (tree, vec,
+ gimple_switch_label (switch_stmt, start + i));
+ }
- /* Create a new label and append it to the list */
- label = build1 (LABEL_EXPR, void_type_node, label_decl);
- append_to_statement_list (label, list);
+ /* Build and append the new switch statement */
+ stmt = gimple_build_switch_vec (gimple_switch_index (switch_stmt),
+ build3 (CASE_LABEL_EXPR, void_type_node,
+ NULL_TREE, NULL_TREE, deft),
+ vec);
+ gsi_insert_after (gsi, stmt, GSI_CONTINUE_LINKING);
+ VEC_free (tree, heap, vec);
- /* Move ahead in the labels vector */
+ /* Move ahead in the labels */
start += len;
}
}
-/* Break a switch statement pointed by SWITCH_STMT into multiple expressions in
- order to produce better/smaller code in the CIL back-end. Large case ranges
- or isolated cases are turned into COND_EXPRs, large 'holes' inside the switch
- are removed replacing a single switch with two or more distinct switches. The
- list holding the replacement is returned. If no replacement is needed
- NULL_TREE is returned instead */
+/* Break a switch statement pointed by GIMPLE_SWITCH into multiple expressions
+ in order to produce better/smaller code in the CIL back-end. Large case
+ ranges or isolated cases are turned into GIMPLE_CONDs, large 'holes' inside
+ the switch are removed replacing a single switch with two or more distinct
+ switches. The sequence holding the replacement is returned. If no
+ replacement is needed NULL is returned instead */
-static tree
-simp_cil_switch (tree switch_stmt)
+static gimple_seq
+simp_cil_switch (gimple switch_stmt)
{
tree curr, next;
- tree labels = SWITCH_LABELS (switch_stmt);
- tree list = NULL_TREE;
+ gimple stmt;
+ gimple_seq seq = gimple_seq_alloc ();
+ gimple_stmt_iterator gsi = gsi_start (seq);
tree range_size, hole_size, curr_high, next_low;
- tree type;
- unsigned int i = 0;
- unsigned int base_idx = 0;
+ tree type, label_decl;
+ unsigned int i = 1;
+ unsigned int base_idx = 1;
merge_cases_into_ranges (switch_stmt);
- if (TREE_VEC_LENGTH (labels) == 1)
+ if (gimple_switch_num_labels (switch_stmt) == 1)
{
/* Only the default statement, nothing to do as this will be optimized
out later by the subsequent passes */
- return NULL_TREE;
+ gimple_seq_free (seq);
+ return NULL;
}
- type = TREE_TYPE (CASE_LOW (TREE_VEC_ELT (labels, 0)));
+ type = TREE_TYPE (CASE_LOW (gimple_switch_label (switch_stmt, 1)));
range_size = build_int_cst (type, SIMP_SWITCH_RANGE_SIZE);
hole_size = build_int_cst (type, SIMP_SWITCH_HOLE_SIZE);
while (true)
{
- curr = TREE_VEC_ELT (labels, i);
- next = TREE_VEC_ELT (labels, i + 1);
+ curr = gimple_switch_label (switch_stmt, i);
- if (CASE_LOW (next) == NULL_TREE)
+ if (i == gimple_switch_num_labels (switch_stmt) - 1)
{
- /* This is the last case, the next one is the default label, emit the
- previous cases if needed. If base_idx != i and base_idx is 0 then
- the original switch has been left untouched and it is not
- replaced */
+ /* This is the last case, emit the previous cases if needed.
+ If base_idx != i and base_idx is 0 then the original switch has
+ been left untouched and it is not replaced */
+ label_decl = CASE_LABEL (gimple_switch_default_label (switch_stmt));
+
if (base_idx != i)
{
- if (base_idx == 0)
- return NULL_TREE;
+ if (base_idx == 1)
+ {
+ gimple_seq_free (seq);
+ return NULL;
+ }
else
- cases_to_switch (switch_stmt, base_idx, i, &list);
+ cases_to_switch (switch_stmt, base_idx, i, label_decl, &gsi);
}
else if (CASE_HIGH (curr) != NULL_TREE)
- case_range_to_cond_expr (switch_stmt, curr, &list);
+ case_range_to_cond_expr (switch_stmt, curr, label_decl, &gsi);
else
- case_to_cond_expr (switch_stmt, curr, &list);
+ case_to_cond_expr (switch_stmt, curr, label_decl, &gsi);
- /* Add a label which jumps to the default label. */
- append_to_statement_list (build1 (GOTO_EXPR, void_type_node,
- CASE_LABEL (next)),
- &list);
break;
}
+ next = gimple_switch_label (switch_stmt, i + 1);
+
if (CASE_HIGH (curr) != NULL_TREE)
{
/* This case is a range, if it's large enough we blow it up into two
@@ -471,8 +412,14 @@ simp_cil_switch (tree switch_stmt)
/* if (low + SIMP_SWITCH_RANGE_SIZE > high) */
if (tree_int_cst_compare (low, high) == 1)
{
+ label_decl = create_artificial_label ();
+
gcc_assert (i == base_idx);
- case_range_to_cond_expr (switch_stmt, curr, &list);
+ case_range_to_cond_expr (switch_stmt, curr, label_decl, &gsi);
+
+ /* Create the label to the next statement and append it */
+ stmt = gimple_build_label (label_decl);
+ gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
i++;
base_idx = i;
@@ -490,12 +437,18 @@ simp_cil_switch (tree switch_stmt)
/* if (low + SIMP_SWITCH_RANGE_SIZE > high) */
if (tree_int_cst_compare (low, high) == 1)
{
+ label_decl = create_artificial_label ();
+
if (base_idx != i)
- cases_to_switch (switch_stmt, base_idx, i, &list);
+ cases_to_switch (switch_stmt, base_idx, i, label_decl, &gsi);
else if (CASE_HIGH (curr) != NULL_TREE)
- case_range_to_cond_expr (switch_stmt, curr, &list);
+ case_range_to_cond_expr (switch_stmt, curr, label_decl, &gsi);
else
- case_to_cond_expr (switch_stmt, curr, &list);
+ case_to_cond_expr (switch_stmt, curr, label_decl, &gsi);
+
+ /* Create the label to the next statement and append it */
+ stmt = gimple_build_label (label_decl);
+ gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
i++;
base_idx = i;
@@ -516,12 +469,18 @@ simp_cil_switch (tree switch_stmt)
/* if (curr_high + SIMP_SWITCH_HOLE_SIZE < next_low) */
if (tree_int_cst_lt (curr_high, next_low))
{
+ label_decl = create_artificial_label ();
+
if (base_idx != i)
- cases_to_switch (switch_stmt, base_idx, i, &list);
+ cases_to_switch (switch_stmt, base_idx, i, label_decl, &gsi);
else if (CASE_HIGH (curr) != NULL_TREE)
- case_range_to_cond_expr (switch_stmt, curr, &list);
+ case_range_to_cond_expr (switch_stmt, curr, label_decl, &gsi);
else
- case_to_cond_expr (switch_stmt, curr, &list);
+ case_to_cond_expr (switch_stmt, curr, label_decl, &gsi);
+
+ /* Create the label to the next statement and append it */
+ stmt = gimple_build_label (label_decl);
+ gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
i++;
base_idx = i;
@@ -531,61 +490,48 @@ simp_cil_switch (tree switch_stmt)
i++;
}
- return list;
+ return seq;
}
/******************************************************************************
* Top-level functionality *
******************************************************************************/
-/* Simplify a GIMPLE statement. */
-
-static tree
-simp_cil_stmt (tree stmt)
-{
- tree list = NULL_TREE; /* Replacement list for the current statement */
-
- switch (TREE_CODE (stmt))
- {
- case SWITCH_EXPR:
- list = simp_cil_switch (stmt);
- break;
-
- default:
- break;
- }
-
- return list;
-}
-
-/* Main function of this pass. */
+/* Main function of this pass. */
static unsigned int
simp_cil_early (void)
{
- tree_stmt_iterator tsi;
+ gimple_stmt_iterator gsi;
+ gimple_seq seq;
+ gimple stmt;
/* Create the structures used by the pass */
eqv_labels = pointer_map_create ();
- group_labels (DECL_SAVED_TREE (current_function_decl));
+ group_labels ();
- tsi = tsi_start (DECL_SAVED_TREE (current_function_decl));
+ gsi = gsi_start (gimple_body (current_function_decl));
- while (!tsi_end_p (tsi))
+ while (!gsi_end_p (gsi))
{
- tree list = simp_cil_stmt (tsi_stmt (tsi));
+ stmt = gsi_stmt (gsi);
- if (list != NULL_TREE)
+ if (gimple_code (stmt) == GIMPLE_SWITCH)
{
- location_t locus = EXPR_LOCATION (tsi_stmt (tsi));
+ seq = simp_cil_switch (stmt);
- set_statement_list_location (list, locus);
- tsi_link_before (&tsi, list, TSI_SAME_STMT);
- tsi_delink (&tsi);
+ if (seq != NULL)
+ {
+ annotate_all_with_location (seq, gimple_location (stmt));
+ gsi_insert_seq_before (&gsi, seq, GSI_SAME_STMT);
+ gsi_remove (&gsi, true);
+ }
+ else
+ gsi_next (&gsi);
}
else
- tsi_next (&tsi);
+ gsi_next (&gsi);
}
/* Dispose of the structures created by the pass */
@@ -603,7 +549,9 @@ simp_cil_early_gate (void)
return true;
}
-struct tree_opt_pass pass_simp_cil_early = {
+struct gimple_opt_pass pass_simp_cil_early = {
+ {
+ GIMPLE_PASS, /* type */
"simpcilearly", /* name */
simp_cil_early_gate, /* gate */
simp_cil_early, /* execute */
@@ -616,6 +564,6 @@ struct tree_opt_pass pass_simp_cil_early = {
0, /* properties_destroyed */
0, /* todo_flags_start */
TODO_dump_func
- | TODO_ggc_collect, /* todo_flags_finish */
- 0 /* letter */
+ | TODO_ggc_collect /* todo_flags_finish */
+ }
};
diff --git a/gcc/profile.c b/gcc/profile.c
index 5e1e15abd15..9c1b304a155 100644
--- a/gcc/profile.c
+++ b/gcc/profile.c
@@ -64,9 +64,9 @@ along with GCC; see the file COPYING3. If not see
#include "value-prof.h"
#include "tree.h"
#include "cfghooks.h"
-#include "tree-flow.h"
#include "timevar.h"
#include "cfgloop.h"
+#include "gimple.h"
#include "tree-pass.h"
#include "splay-tree.h"
@@ -417,7 +417,7 @@ location_profile_info_add_bb_exec_count (const char *file, int bb_line, int coun
static int
location_profile_info_dump_edge (splay_tree_node n, void *d)
{
- FILE *f = d;
+ FILE *f = (FILE *) d;
int v = (int) n->value;
fprintf (f, "-> %x: %d\n", (int) n->key, v);
return 0;
@@ -426,7 +426,7 @@ location_profile_info_dump_edge (splay_tree_node n, void *d)
static int
location_profile_info_dump_location (splay_tree_node n, void *d)
{
- FILE *f = d;
+ FILE *f = (FILE *) d;
struct location_profile_info *v = (struct location_profile_info *) n->value;
fprintf (f, "%x\n", (int) n->key);
splay_tree_foreach (v->edges, location_profile_info_dump_edge, f);
@@ -436,7 +436,7 @@ location_profile_info_dump_location (splay_tree_node n, void *d)
static int
location_profile_info_dump_file (splay_tree_node n, void *d)
{
- FILE *f = d;
+ FILE *f = (FILE *) d;
struct location_profile_info_file *v = (struct location_profile_info_file *) n->value;
fprintf (f, "File: '%s'\n", (const char *) n->key);
splay_tree_foreach (v->locations, location_profile_info_dump_location, f);
@@ -454,27 +454,22 @@ basic_block_get_location (basic_block bb)
{
while (bb)
{
- if (bb_stmt_list (bb))
- {
- tree_stmt_iterator i = tsi_start (bb_stmt_list (bb));
- while (!tsi_end_p (i))
- {
- if (EXPR_HAS_LOCATION (tsi_stmt (i)))
- {
- return EXPR_LOCATION (tsi_stmt (i));
- }
- tsi_next (&i);
- }
- }
+ gimple_stmt_iterator gsi = gsi_start_bb (bb);
+
+ while (!gsi_end_p (gsi))
+ {
+ if (gimple_has_location (gsi_stmt (gsi)))
+ return gimple_location (gsi_stmt (gsi));
+
+ gsi_next (&gsi);
+ }
+
if (single_succ_p (bb))
- {
- bb = single_succ_edge (bb)->dest;
- }
+ bb = single_succ_edge (bb)->dest;
else
- {
- break;
- }
+ return UNKNOWN_LOCATION;
}
+
return UNKNOWN_LOCATION;
}