This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] compiling gcc with a C++ compiler 3/n
- From: Thomas Neumann <tneumann at users dot sourceforge dot net>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 14 May 2007 20:13:35 +0200
- Subject: [PATCH] compiling gcc with a C++ compiler 3/n
:ADDPATCH control flow graph:
The attached patch fixed compiling the cfg* code with a C++ compiler.
Most changes are very minor, the only complicated (or rather confusion)
issue was "edge": There were two edge structures in use, on in the
struct namespace and another one in the global namespace. The C++
compiler does not like this, and it is confusing for humans, too,
therefore I renamed one to cfg_edge.
Bootstrapped and tested in i686.
Thomas
* cfgloopmanip.c (unloop): Cast as needed.
* cfghooks.c: Cast as needed, avoid C++ keywords.
* cfgloopanal.c: Rename struct edge into cfg_edge to avoid conflicts.
* cfgloopanal.c: Use typesafe memory macros.
* cfg.c: Use typesafe memory macros. Cast as needed.
* cfgexpand.c: Cast as needed.
* cfglayout.c: Likewise.
* cfgloop.c: Likewise
* cfgloop.h: Move enum loop_estimation out of the struct namespace.
* cfgrtl.c: Cast as needed. Use typesafe memory macros.
Index: gcc/cfgloopmanip.c
===================================================================
--- gcc/cfgloopmanip.c (revision 124708)
+++ gcc/cfgloopmanip.c (working copy)
@@ -50,7 +50,7 @@ static void unloop (struct loop *, bool
static bool
rpe_enum_p (basic_block bb, void *data)
{
- return dominated_by_p (CDI_DOMINATORS, bb, data);
+ return dominated_by_p (CDI_DOMINATORS, bb, (basic_block) data);
}
/* Remove basic blocks BBS. NBBS is the number of the basic blocks. */
Index: gcc/cfghooks.c
===================================================================
--- gcc/cfghooks.c (revision 124708)
+++ gcc/cfghooks.c (working copy)
@@ -259,7 +259,7 @@ dump_bb (basic_block bb, FILE *outf, int
edge_iterator ei;
char *s_indent;
- s_indent = alloca ((size_t) indent + 1);
+ s_indent = (char *) alloca ((size_t) indent + 1);
memset (s_indent, ' ', (size_t) indent);
s_indent[indent] = '\0';
@@ -1038,10 +1038,10 @@ extract_cond_bb_edges (basic_block b, ed
new condition basic block that guards the versioned loop. */
void
lv_adjust_loop_header_phi (basic_block first, basic_block second,
- basic_block new, edge e)
+ basic_block new_block, edge e)
{
if (cfg_hooks->lv_adjust_loop_header_phi)
- cfg_hooks->lv_adjust_loop_header_phi (first, second, new, e);
+ cfg_hooks->lv_adjust_loop_header_phi (first, second, new_block, e);
}
/* Conditions in trees and RTL are different so we need
@@ -1049,8 +1049,8 @@ lv_adjust_loop_header_phi (basic_block f
versioning code. */
void
lv_add_condition_to_bb (basic_block first, basic_block second,
- basic_block new, void *cond)
+ basic_block new_block, void *cond)
{
gcc_assert (cfg_hooks->lv_add_condition_to_bb);
- cfg_hooks->lv_add_condition_to_bb (first, second, new, cond);
+ cfg_hooks->lv_add_condition_to_bb (first, second, new_block, cond);
}
Index: gcc/cfgloopanal.c
===================================================================
--- gcc/cfgloopanal.c (revision 124708)
+++ gcc/cfgloopanal.c (working copy)
@@ -52,10 +52,10 @@ just_once_each_iteration_p (const struct
/* Structure representing edge of a graph. */
-struct edge
+struct cfg_edge
{
int src, dest; /* Source and destination. */
- struct edge *pred_next, *succ_next;
+ struct cfg_edge *pred_next, *succ_next;
/* Next edge in predecessor and successor lists. */
void *data; /* Data attached to the edge. */
};
@@ -64,7 +64,7 @@ struct edge
struct vertex
{
- struct edge *pred, *succ;
+ struct cfg_edge *pred, *succ;
/* Lists of predecessors and successors. */
int component; /* Number of dfs restarts before reaching the
vertex. */
@@ -88,7 +88,7 @@ void
dump_graph (FILE *f, struct graph *g)
{
int i;
- struct edge *e;
+ struct cfg_edge *e;
for (i = 0; i < g->n_vertices; i++)
{
@@ -126,7 +126,7 @@ new_graph (int n_vertices)
static void
add_edge (struct graph *g, int f, int t, void *data)
{
- struct edge *e = xmalloc (sizeof (struct edge));
+ struct cfg_edge *e = XNEW (struct cfg_edge);
e->src = f;
e->dest = t;
@@ -147,8 +147,8 @@ static void
dfs (struct graph *g, int *qs, int nq, int *qt, bool forward)
{
int i, tick = 0, v, comp = 0, top;
- struct edge *e;
- struct edge **stack = xmalloc (sizeof (struct edge *) * g->n_vertices);
+ struct cfg_edge *e;
+ struct cfg_edge **stack = XNEWVEC (struct cfg_edge *, g->n_vertices);
for (i = 0; i < g->n_vertices; i++)
{
@@ -205,9 +205,9 @@ dfs (struct graph *g, int *qs, int nq, i
same scc. */
static void
-check_irred (struct graph *g, struct edge *e)
+check_irred (struct graph *g, struct cfg_edge *e)
{
- edge real = e->data;
+ edge real = (edge) e->data;
/* All edges should lead from a component with higher number to the
one with lower one. */
@@ -225,9 +225,9 @@ check_irred (struct graph *g, struct edg
static void
for_each_edge (struct graph *g,
- void (callback) (struct graph *, struct edge *))
+ void (callback) (struct graph *, struct cfg_edge *))
{
- struct edge *e;
+ struct cfg_edge *e;
int i;
for (i = 0; i < g->n_vertices; i++)
@@ -240,7 +240,7 @@ for_each_edge (struct graph *g,
static void
free_graph (struct graph *g)
{
- struct edge *e, *n;
+ struct cfg_edge *e, *n;
int i;
for (i = 0; i < g->n_vertices; i++)
Index: gcc/cfg.c
===================================================================
--- gcc/cfg.c (revision 124708)
+++ gcc/cfg.c (working copy)
@@ -82,11 +82,11 @@ void
init_flow (void)
{
if (!cfun->cfg)
- cfun->cfg = ggc_alloc_cleared (sizeof (struct control_flow_graph));
+ cfun->cfg = GGC_CNEW (struct control_flow_graph);
n_edges = 0;
- ENTRY_BLOCK_PTR = ggc_alloc_cleared (sizeof (struct basic_block_def));
+ ENTRY_BLOCK_PTR = GGC_CNEW (struct basic_block_def);
ENTRY_BLOCK_PTR->index = ENTRY_BLOCK;
- EXIT_BLOCK_PTR = ggc_alloc_cleared (sizeof (struct basic_block_def));
+ EXIT_BLOCK_PTR = GGC_CNEW (struct basic_block_def);
EXIT_BLOCK_PTR->index = EXIT_BLOCK;
ENTRY_BLOCK_PTR->next_bb = EXIT_BLOCK_PTR;
EXIT_BLOCK_PTR->prev_bb = ENTRY_BLOCK_PTR;
@@ -133,7 +133,7 @@ basic_block
alloc_block (void)
{
basic_block bb;
- bb = ggc_alloc_cleared (sizeof (*bb));
+ bb = GGC_CNEW (struct basic_block_def);
return bb;
}
@@ -263,7 +263,7 @@ edge
unchecked_make_edge (basic_block src, basic_block dst, int flags)
{
edge e;
- e = ggc_alloc_cleared (sizeof (*e));
+ e = GGC_CNEW (struct edge_def);
n_edges++;
e->src = src;
@@ -541,7 +541,7 @@ dump_flow_info (FILE *file, int flags)
for (i = FIRST_PSEUDO_REGISTER; i < max; i++)
if (REG_N_REFS (i))
{
- enum reg_class class, altclass;
+ enum reg_class prefclass, altclass;
fprintf (file, "\nRegister %d used %d times across %d insns",
i, REG_N_REFS (i), REG_LIVE_LENGTH (i));
@@ -562,17 +562,17 @@ dump_flow_info (FILE *file, int flags)
&& PSEUDO_REGNO_BYTES (i) != UNITS_PER_WORD)
fprintf (file, "; %d bytes", PSEUDO_REGNO_BYTES (i));
- class = reg_preferred_class (i);
+ prefclass = reg_preferred_class (i);
altclass = reg_alternate_class (i);
- if (class != GENERAL_REGS || altclass != ALL_REGS)
+ if (prefclass != GENERAL_REGS || altclass != ALL_REGS)
{
- if (altclass == ALL_REGS || class == ALL_REGS)
- fprintf (file, "; pref %s", reg_class_names[(int) class]);
+ if (altclass == ALL_REGS || prefclass == ALL_REGS)
+ fprintf (file, "; pref %s", reg_class_names[(int) prefclass]);
else if (altclass == NO_REGS)
- fprintf (file, "; %s or none", reg_class_names[(int) class]);
+ fprintf (file, "; %s or none", reg_class_names[(int) prefclass]);
else
fprintf (file, "; pref %s, else %s",
- reg_class_names[(int) class],
+ reg_class_names[(int) prefclass],
reg_class_names[(int) altclass]);
}
@@ -1102,7 +1102,8 @@ set_bb_original (basic_block bb, basic_b
(*slot)->index2 = original->index;
else
{
- *slot = pool_alloc (original_copy_bb_pool);
+ *slot = (struct htab_bb_copy_original_entry *)
+ pool_alloc (original_copy_bb_pool);
(*slot)->index1 = bb->index;
(*slot)->index2 = original->index;
}
@@ -1144,7 +1145,8 @@ set_bb_copy (basic_block bb, basic_block
(*slot)->index2 = copy->index;
else
{
- *slot = pool_alloc (original_copy_bb_pool);
+ *slot = (struct htab_bb_copy_original_entry *)
+ pool_alloc (original_copy_bb_pool);
(*slot)->index1 = bb->index;
(*slot)->index2 = copy->index;
}
Index: gcc/cfgexpand.c
===================================================================
--- gcc/cfgexpand.c (revision 124708)
+++ gcc/cfgexpand.c (working copy)
@@ -1262,7 +1262,7 @@ label_rtx_for_bb (basic_block bb)
elt = pointer_map_contains (lab_rtx_for_bb, bb);
if (elt)
- return *elt;
+ return (rtx) *elt;
/* Find the tree label if it is present. */
@@ -1281,7 +1281,7 @@ label_rtx_for_bb (basic_block bb)
elt = pointer_map_insert (lab_rtx_for_bb, bb);
*elt = gen_label_rtx ();
- return *elt;
+ return (rtx) *elt;
}
/* A subroutine of expand_gimple_basic_block. Expand one COND_EXPR.
@@ -1538,7 +1538,7 @@ expand_gimple_basic_block (basic_block b
}
if (elt)
- emit_label (*elt);
+ emit_label ((rtx) *elt);
/* Java emits line number notes in the top of labels.
??? Make this go away once line number notes are obsoleted. */
Index: gcc/cfglayout.c
===================================================================
--- gcc/cfglayout.c (revision 124708)
+++ gcc/cfglayout.c (working copy)
@@ -629,7 +629,7 @@ relink_block_chain (bool stay_in_cfglayo
fprintf (dump_file, "Reordered sequence:\n");
for (bb = ENTRY_BLOCK_PTR->next_bb, index = NUM_FIXED_BLOCKS;
bb;
- bb = bb->aux, index++)
+ bb = (basic_block) bb->aux, index++)
{
fprintf (dump_file, " %i ", index);
if (get_bb_original (bb))
@@ -647,7 +647,7 @@ relink_block_chain (bool stay_in_cfglayo
/* Now reorder the blocks. */
prev_bb = ENTRY_BLOCK_PTR;
bb = ENTRY_BLOCK_PTR->next_bb;
- for (; bb; prev_bb = bb, bb = bb->aux)
+ for (; bb; prev_bb = bb, bb = (basic_block) bb->aux)
{
bb->prev_bb = prev_bb;
prev_bb->next_bb = bb;
@@ -695,7 +695,7 @@ fixup_reorder_chain (void)
/* First do the bulk reordering -- rechain the blocks without regard to
the needed changes to jumps and labels. */
- for (bb = ENTRY_BLOCK_PTR->next_bb; bb; bb = bb->aux)
+ for (bb = ENTRY_BLOCK_PTR->next_bb; bb; bb = (basic_block) bb->aux)
{
if (bb->il.rtl->header)
{
@@ -738,7 +738,7 @@ fixup_reorder_chain (void)
/* Now add jumps and labels as needed to match the blocks new
outgoing edges. */
- for (bb = ENTRY_BLOCK_PTR->next_bb; bb ; bb = bb->aux)
+ for (bb = ENTRY_BLOCK_PTR->next_bb; bb ; bb = (basic_block) bb->aux)
{
edge e_fall, e_taken, e;
rtx bb_end_insn;
@@ -953,11 +953,11 @@ fixup_fallthru_exit_predecessor (void)
}
while (c->aux != bb)
- c = c->aux;
+ c = (basic_block) c->aux;
c->aux = bb->aux;
while (c->aux)
- c = c->aux;
+ c = (basic_block) c->aux;
c->aux = bb;
bb->aux = NULL;
Index: gcc/cfgloop.c
===================================================================
--- gcc/cfgloop.c (revision 124708)
+++ gcc/cfgloop.c (working copy)
@@ -772,7 +772,7 @@ flow_bb_inside_loop_p (const struct loop
static bool
glb_enum_p (basic_block bb, void *glb_loop)
{
- struct loop *loop = glb_loop;
+ struct loop *loop = (struct loop *) glb_loop;
return (bb != loop->header
&& dominated_by_p (CDI_DOMINATORS, bb, loop->header));
}
@@ -970,8 +970,8 @@ loop_exit_free (void *ex)
static struct loop_exit *
get_exit_descriptions (edge e)
{
- return htab_find_with_hash (current_loops->exits, e,
- htab_hash_pointer (e));
+ return (struct loop_exit *) htab_find_with_hash (current_loops->exits, e,
+ htab_hash_pointer (e));
}
/* Updates the lists of loop exits in that E appears.
@@ -1070,14 +1070,14 @@ record_loop_exits (void)
static int
dump_recorded_exit (void **slot, void *file)
{
- struct loop_exit *exit = *slot;
+ struct loop_exit *exit = (struct loop_exit *) *slot;
unsigned n = 0;
edge e = exit->e;
for (; exit != NULL; exit = exit->next_e)
n++;
- fprintf (file, "Edge %d->%d exits %u loops\n",
+ fprintf ((FILE*) file, "Edge %d->%d exits %u loops\n",
e->src->index, e->dest->index, n);
return 1;
Index: gcc/cfgloop.h
===================================================================
--- gcc/cfgloop.h (revision 124708)
+++ gcc/cfgloop.h (working copy)
@@ -89,6 +89,16 @@ typedef struct loop *loop_p;
DEF_VEC_P (loop_p);
DEF_VEC_ALLOC_P (loop_p, heap);
+/* An integer estimation of the number of iterations. Estimate_state
+ describes what is the state of the estimation. */
+enum loop_estimation
+{
+ /* Estimate was not computed yet. */
+ EST_NOT_COMPUTED,
+ /* Estimate is ready. */
+ EST_AVAILABLE
+};
+
/* Structure to hold information for each natural loop. */
struct loop
{
@@ -137,13 +147,7 @@ struct loop
/* An integer estimation of the number of iterations. Estimate_state
describes what is the state of the estimation. */
- enum
- {
- /* Estimate was not computed yet. */
- EST_NOT_COMPUTED,
- /* Estimate is ready. */
- EST_AVAILABLE
- } estimate_state;
+ enum loop_estimation estimate_state;
/* An integer guaranteed to bound the number of iterations of the loop
from above. */
Index: gcc/cfgrtl.c
===================================================================
--- gcc/cfgrtl.c (revision 124708)
+++ gcc/cfgrtl.c (working copy)
@@ -321,7 +321,7 @@ create_basic_block_structure (rtx head,
static basic_block
rtl_create_basic_block (void *headp, void *endp, basic_block after)
{
- rtx head = headp, end = endp;
+ rtx head = (rtx) headp, end = (rtx) endp;
basic_block bb;
/* Grow the basic block array if needed. */
@@ -474,7 +474,7 @@ static basic_block
rtl_split_block (basic_block bb, void *insnp)
{
basic_block new_bb;
- rtx insn = insnp;
+ rtx insn = (rtx) insnp;
edge e;
edge_iterator ei;
@@ -1520,7 +1520,7 @@ rtl_dump_bb (basic_block bb, FILE *outf,
rtx last;
char *s_indent;
- s_indent = alloca ((size_t) indent + 1);
+ s_indent = (char *) alloca ((size_t) indent + 1);
memset (s_indent, ' ', (size_t) indent);
s_indent[indent] = '\0';
@@ -2302,7 +2302,7 @@ purge_all_dead_edges (void)
static basic_block
cfg_layout_split_block (basic_block bb, void *insnp)
{
- rtx insn = insnp;
+ rtx insn = (rtx) insnp;
basic_block new_bb = rtl_split_block (bb, insn);
new_bb->il.rtl->footer = bb->il.rtl->footer;
@@ -2881,7 +2881,7 @@ void
init_rtl_bb_info (basic_block bb)
{
gcc_assert (!bb->il.rtl);
- bb->il.rtl = ggc_alloc_cleared (sizeof (struct rtl_bb_info));
+ bb->il.rtl = GGC_CNEW (struct rtl_bb_info);
}