===================================================================
@@ -390,10 +390,10 @@
{
prev_visited_bb.push_back (bb);
- for (edge_iterator ei = ei_start (bb->preds); !ei_end_p (ei);
- ei_next (&ei))
+ for (basic_block::edge_iterator ei = bb->pred_edges ().begin ();
+ ei != bb->pred_edges ().end (); ++ei)
{
- basic_block pred_bb = ei_edge (ei)->src;
+ basic_block pred_bb = (*ei)->src;
pred_bb_count += 1;
find_last_ccreg_values (BB_END (pred_bb), pred_bb, values_out,
prev_visited_bb);
===================================================================
@@ -25,6 +25,7 @@
#include "tree.h"
#include "gimple-pretty-print.h"
#include "context.h"
+#include "basic-block2.h"
/* If non-NULL, return one past-the-end of the matching SUBPART of
the WHOLE string. */
===================================================================
@@ -102,7 +102,7 @@
/* A transaction is a single entry multiple exit region. It must be
duplicated in its entirety or not at all. */
- g = last_stmt (CONST_CAST_BB (bb));
+ g = last_stmt (basic_block (bb));
if (g && gimple_code (g) == GIMPLE_TRANSACTION)
return true;
===================================================================
@@ -503,6 +503,8 @@
TBB v, w, k, par;
basic_block en_block;
edge_iterator ei, einext;
+ TBB k1;
+ basic_block b;
if (reverse)
en_block = EXIT_BLOCK_PTR_FOR_FN (cfun);
@@ -538,9 +540,6 @@
semidominator. */
while (!ei_end_p (ei))
{
- TBB k1;
- basic_block b;
-
e = ei_edge (ei);
b = (reverse) ? e->dest : e->src;
einext = ei;
===================================================================
@@ -482,6 +482,15 @@
void quick_grow (unsigned len);
void quick_grow_cleared (unsigned len);
+ /* STL like iterator interface. */
+ typedef T* iterator;
+ typedef const T* const_iterator;
+
+ iterator begin (void) { return &m_vecdata[0]; }
+ iterator end (void) { return &m_vecdata[m_vecpfx.m_num]; }
+ const_iterator begin (void) const { return &m_vecdata[0]; }
+ const_iterator end (void) const { &m_vecdata[m_vecpfx.m_num]; }
+
/* vec class can access our internal data and functions. */
template <typename, typename, typename> friend struct vec;
===================================================================
@@ -65,7 +65,7 @@
#define IFCVT_MULTIPLE_DUMPS 1
-#define NULL_BLOCK ((basic_block) NULL)
+#define NULL_BLOCK (basic_block ((basic_block_def*) NULL))
/* True if after combine pass. */
static bool ifcvt_after_combine;
===================================================================
@@ -152,8 +152,8 @@
typedef struct edge_def *edge;
typedef const struct edge_def *const_edge;
struct basic_block_def;
-typedef struct basic_block_def *basic_block;
-typedef const struct basic_block_def *const_basic_block;
+class basic_block;
+class const_basic_block;
#define obstack_chunk_alloc ((void *(*) (long)) xmalloc)
#define obstack_chunk_free ((void (*) (void *)) free)
===================================================================
@@ -4446,7 +4446,7 @@
emit_note_after (enum insn_note subtype, rtx after)
{
rtx note = make_note_raw (subtype);
- basic_block bb = BARRIER_P (after) ? NULL : BLOCK_FOR_INSN (after);
+ basic_block bb = BARRIER_P (after) ? (basic_block_def*)NULL : (basic_block_def*)BLOCK_FOR_INSN (after);
bool on_bb_boundary_p = (bb != NULL && BB_END (bb) == after);
if (note_outside_basic_block_p (subtype, on_bb_boundary_p))
@@ -4462,7 +4462,7 @@
emit_note_before (enum insn_note subtype, rtx before)
{
rtx note = make_note_raw (subtype);
- basic_block bb = BARRIER_P (before) ? NULL : BLOCK_FOR_INSN (before);
+ basic_block bb = BARRIER_P (before) ? (basic_block_def*)NULL : (basic_block_def*)BLOCK_FOR_INSN (before);
bool on_bb_boundary_p = (bb != NULL && BB_HEAD (bb) == before);
if (note_outside_basic_block_p (subtype, on_bb_boundary_p))
===================================================================
@@ -117,7 +117,7 @@
struct pointer_set_t *statements_to_fold;
/* Entry basic block to currently copied body. */
- basic_block entry_bb;
+ basic_block_def* entry_bb;
/* For partial function versioning, bitmap of bbs to be copied,
otherwise NULL. */
===================================================================
@@ -392,7 +392,7 @@
/* Artificial refs do not have an insn, so to get the basic block,
it must be explicitly here. */
- basic_block bb;
+ basic_block_in_union bb;
};
===================================================================
@@ -0,0 +1,81 @@
+#ifndef GCC_BASIC_BLOCK2_H
+#define GCC_BASIC_BLOCK2_H
+
+struct basic_block_def;
+
+class basic_block_in_union
+{
+public:
+ typedef vec<edge, va_gc>::iterator edge_iterator;
+ typedef vec<edge, va_gc>::const_iterator const_edge_iterator;
+
+ basic_block_in_union& operator = (basic_block_def* bb) { m_bb = bb; return *this; }
+
+ basic_block_def* operator -> (void) const { return m_bb; }
+
+ bool operator == (const basic_block_in_union& rhs) const { return m_bb == rhs.m_bb; }
+ bool operator != (const basic_block_in_union& rhs) const { return m_bb != rhs.m_bb; }
+
+ operator basic_block_def* (void) const { return m_bb; }
+
+ basic_block_def* get (void) const { return m_bb; }
+
+protected:
+ basic_block_def* m_bb;
+};
+
+class const_basic_block_in_union
+{
+public:
+ typedef vec<edge, va_gc>::const_iterator const_edge_iterator;
+
+ const_basic_block_in_union& operator = (const basic_block_def* bb) { m_bb = bb; return *this; }
+ const_basic_block_in_union& operator = (basic_block_def* bb) { m_bb = bb; return *this; }
+
+ const basic_block_def* operator -> (void) const { return m_bb; }
+
+ bool operator == (const basic_block_in_union& rhs) const { return m_bb == rhs.get (); }
+ bool operator != (const basic_block_in_union& rhs) const { return m_bb != rhs.get (); }
+
+ operator const basic_block_def* (void) const { return m_bb; }
+
+ const basic_block_def* get (void) const { return m_bb; }
+
+protected:
+ const basic_block_def* m_bb;
+};
+
+class const_basic_block;
+
+class basic_block : public basic_block_in_union
+{
+public:
+ basic_block (void) { }
+ basic_block (const basic_block& rhs) { m_bb = rhs.get (); }
+ basic_block (const basic_block_in_union& rhs) { m_bb = rhs.get (); }
+ basic_block (basic_block_def* bb) { m_bb = bb; }
+
+ explicit basic_block (void* p) { m_bb = (basic_block_def*)p; }
+ explicit basic_block (const const_basic_block& rhs);
+};
+
+class const_basic_block : public const_basic_block_in_union
+{
+public:
+ const_basic_block (void) { }
+ const_basic_block (const const_basic_block& rhs) { m_bb = rhs.get (); }
+ const_basic_block (const basic_block& rhs) { m_bb = rhs.get (); }
+ const_basic_block (const basic_block_in_union& rhs) { m_bb = rhs.get (); }
+ const_basic_block (const const_basic_block_in_union& rhs) { m_bb = rhs.get (); }
+ const_basic_block (basic_block_def* bb) { m_bb = bb; }
+ const_basic_block (const basic_block_def* bb) { m_bb = bb; }
+
+ explicit const_basic_block (const void* p) { m_bb = (const basic_block_def*)p; }
+};
+
+inline basic_block::basic_block (const const_basic_block& rhs) { m_bb = const_cast<basic_block_def*> (rhs.get ()); }
+
+
+
+
+#endif // GCC_BASIC_BLOCK2_H
===================================================================
@@ -23,6 +23,7 @@
#include "predict.h"
#include "vec.h"
#include "function.h"
+#include "basic-block2.h"
/* Use gcov_type to hold basic block counters. Should be at least
64bit. Although a counter cannot be negative, we use a signed
@@ -169,6 +170,12 @@
vec<edge, va_gc> *preds;
vec<edge, va_gc> *succs;
+ vec<edge, va_gc>& pred_edges (void) { return *preds; }
+ const vec<edge, va_gc>& pred_edges (void) const { return *preds; }
+
+ vec<edge, va_gc>& succ_edges (void) { return *succs; }
+ const vec<edge, va_gc>& succ_edges (void) const { return *succs; }
+
/* Auxiliary info specific to a pass. */
PTR GTY ((skip (""))) aux;
===================================================================
@@ -24,6 +24,7 @@
#include "bitmap.h"
#include "sbitmap.h"
#include "function.h"
+#include "basic-block2.h"
/* Structure to hold decision about unrolling/peeling. */
enum lpt_dec
===================================================================
@@ -7356,7 +7356,7 @@
static bool
gimple_block_ends_with_condjump_p (const_basic_block bb)
{
- gimple stmt = last_stmt (CONST_CAST_BB (bb));
+ gimple stmt = last_stmt (basic_block (bb));
return (stmt && gimple_code (stmt) == GIMPLE_COND);
}
===================================================================
@@ -2033,7 +2033,7 @@
bb->aux = stridx_to_strinfo;
if (vec_safe_length (stridx_to_strinfo) && !strinfo_shared ())
- (*stridx_to_strinfo)[0] = (strinfo) bb;
+ (*stridx_to_strinfo)[0] = (strinfo) bb.get ();
}
/* Callback for walk_dominator_tree. Free strinfo vector if it is
@@ -2046,7 +2046,7 @@
{
stridx_to_strinfo = ((vec<strinfo, va_heap, vl_embed> *) bb->aux);
if (vec_safe_length (stridx_to_strinfo)
- && (*stridx_to_strinfo)[0] == (strinfo) bb)
+ && (*stridx_to_strinfo)[0] == (strinfo) bb.get ())
{
unsigned int i;
strinfo si;
===================================================================
@@ -29,6 +29,7 @@
#include "alias.h"
#include "hashtab.h"
#include "flags.h"
+#include "basic-block2.h"
/* Value used by some passes to "recognize" noop moves as valid
instructions. */
@@ -193,7 +194,7 @@
addr_diff_vec_flags rt_addr_diff_vec_flags;
struct cselib_val *rt_cselib;
tree rt_tree;
- basic_block rt_bb;
+ basic_block_in_union rt_bb;
mem_attrs *rt_mem;
reg_attrs *rt_reg;
struct constant_descriptor_rtx *rt_constant;