[svn:parrot] r46430 - trunk/compilers/imcc
plobsing at svn.parrot.org
plobsing at svn.parrot.org
Sun May 9 05:42:44 UTC 2010
Author: plobsing
Date: Sun May 9 05:42:43 2010
New Revision: 46430
URL: https://trac.parrot.org/parrot/changeset/46430
Log:
remove some life analysis code dead after graph colouring allocator removal
Modified:
trunk/compilers/imcc/cfg.c
trunk/compilers/imcc/cfg.h
trunk/compilers/imcc/debug.c
trunk/compilers/imcc/imc.h
trunk/compilers/imcc/main.c
trunk/compilers/imcc/reg_alloc.c
trunk/compilers/imcc/symreg.c
trunk/compilers/imcc/symreg.h
Modified: trunk/compilers/imcc/cfg.c
==============================================================================
--- trunk/compilers/imcc/cfg.c Sun May 9 05:21:35 2010 (r46429)
+++ trunk/compilers/imcc/cfg.c Sun May 9 05:42:43 2010 (r46430)
@@ -35,22 +35,6 @@
/* HEADERIZER BEGIN: static */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
-static void analyse_life_block(PARROT_INTERP,
- ARGIN(const Basic_block* bb),
- ARGMOD(SymReg *r))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- FUNC_MODIFIES(*r);
-
-static void analyse_life_symbol(PARROT_INTERP,
- ARGIN(const IMC_Unit *unit),
- ARGMOD(SymReg* r))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- FUNC_MODIFIES(* r);
-
static void bb_add_edge(PARROT_INTERP,
ARGMOD(IMC_Unit *unit),
ARGIN(Basic_block *from),
@@ -137,14 +121,6 @@
__attribute__nonnull__(3)
FUNC_MODIFIES(*unit);
-static void propagate_need(
- ARGMOD(Basic_block *bb),
- ARGIN(const SymReg *r),
- int i)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*bb);
-
static void sort_loops(PARROT_INTERP, ARGIN(IMC_Unit *unit))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
@@ -153,10 +129,6 @@
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(bb) \
, PARROT_ASSERT_ARG(r))
-#define ASSERT_ARGS_analyse_life_symbol __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp) \
- , PARROT_ASSERT_ARG(unit) \
- , PARROT_ASSERT_ARG(r))
#define ASSERT_ARGS_bb_add_edge __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(unit) \
@@ -198,9 +170,6 @@
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(unit) \
, PARROT_ASSERT_ARG(e))
-#define ASSERT_ARGS_propagate_need __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(bb) \
- , PARROT_ASSERT_ARG(r))
#define ASSERT_ARGS_sort_loops __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(unit))
@@ -701,243 +670,6 @@
/*
-=item C<void life_analysis(PARROT_INTERP, const IMC_Unit *unit)>
-
-This driver routine calls analyse_life_symbol for each reglist in the specified
-IMC_Unit.
-
-=cut
-
-*/
-
-void
-life_analysis(PARROT_INTERP, ARGIN(const IMC_Unit *unit))
-{
- ASSERT_ARGS(life_analysis)
- SymReg ** const reglist = unit->reglist;
- unsigned int i;
-
- IMCC_info(interp, 2, "life_analysis\n");
-
- for (i = 0; i < unit->n_symbols; i++)
- analyse_life_symbol(interp, unit, reglist[i]);
-}
-
-
-/*
-
-=item C<static void analyse_life_symbol(PARROT_INTERP, const IMC_Unit *unit,
-SymReg* r)>
-
-Analyzes the lifetime for a given symbol.
-
-=cut
-
-*/
-
-static void
-analyse_life_symbol(PARROT_INTERP,
- ARGIN(const IMC_Unit *unit), ARGMOD(SymReg* r))
-{
- ASSERT_ARGS(analyse_life_symbol)
- unsigned int i;
-
-#if IMC_TRACE_HIGH
- fprintf(stderr, "cfg.c: analyse_life_symbol(%s)\n", r->name);
-#endif
-
- if (r->life_info)
- free_life_info(unit, r);
-
- r->life_info = mem_gc_allocate_n_zeroed_typed(interp, unit->n_basic_blocks,
- Life_range *);
-
- /* First we make a pass to each block to gather the information
- * that can be obtained locally */
- for (i = 0; i < unit->n_basic_blocks; i++) {
- analyse_life_block(interp, unit->bb_list[i], r);
- }
-
- /* Now we need to consider the relations between blocks */
- for (i = 0; i < unit->n_basic_blocks; i++) {
- if (r->life_info[i]->flags & LF_use) {
- const Instruction * const ins = unit->bb_list[i]->start;
-
- /* This block uses r, so it must be live at the beginning */
- r->life_info[i]->flags |= LF_lv_in;
-
- /* propagate this info to every predecessor */
- propagate_need(unit->bb_list[i], r, i);
- }
- }
-}
-
-
-/*
-
-=item C<void free_life_info(const IMC_Unit *unit, SymReg *r)>
-
-Frees memory of the life analysis info structures.
-
-=cut
-
-*/
-
-void
-free_life_info(ARGIN(const IMC_Unit *unit), ARGMOD(SymReg *r))
-{
- ASSERT_ARGS(free_life_info)
-#if IMC_TRACE_HIGH
- fprintf(stderr, "free_life_into(%s)\n", r->name);
-#endif
- if (r->life_info) {
- unsigned int i;
-
- for (i = 0; i < unit->n_basic_blocks; i++) {
- mem_sys_free(r->life_info[i]);
- }
-
- mem_sys_free(r->life_info);
- r->life_info = NULL;
- }
-}
-
-
-/*
-
-=item C<static void analyse_life_block(PARROT_INTERP, const Basic_block* bb,
-SymReg *r)>
-
-Studies the state of the var r in the block bb.
-
-Its job is to set the flags LF_use, or LF_read, and record the intervals inside
-the block where the var is alive.
-
-=cut
-
-*/
-
-static void
-analyse_life_block(PARROT_INTERP, ARGIN(const Basic_block* bb), ARGMOD(SymReg *r))
-{
- ASSERT_ARGS(analyse_life_block)
- Life_range * const l = make_life_range(interp, r, bb->index);
- Instruction *special = NULL;
- Instruction *ins;
-
- for (ins = bb->start; ins; ins = ins->next) {
- int is_alias;
-
- /* restoreall and such */
- if (ins_writes2(ins, r->set))
- special = ins;
-
- /*
- * set p, p is basically a read - both are LF_use
- *
- * TODO live range coalescing
- */
- is_alias = (ins->type & ITALIAS) && ins->symregs[0] == r;
-
- if (instruction_reads(ins, r) || is_alias) {
- /* if instruction gets read after a special, consider the first
- * read of this instruction, like if a write had happened at
- * special, so that the reg doesn't pop into life */
- if (! (l->flags & LF_def)) {
- if (special) {
- l->first_ins = special;
- l->flags |= LF_def;
- special = NULL;
- }
- else {
- /* we read before having written before, so the var was
- * live at the beginning of the block */
- l->first_ins = bb->start;
- l->flags |= LF_use;
- }
- }
-
- l->last_ins = ins;
- }
-
- if (!is_alias && instruction_writes(ins, r)) {
- l->flags |= LF_def;
-
- if (!l->first_ins)
- l->first_ins = ins;
-
- l->last_ins = ins;
- }
-
- if (ins == bb->end)
- break;
- }
-
- if (!l->last_ins)
- l->last_ins = l->first_ins;
-
- /* l->last can later be extended if it turns out that another block needs
- * the value resulting from this computation */
-}
-
-
-/*
-
-=item C<static void propagate_need(Basic_block *bb, const SymReg *r, int i)>
-
-Follows the uses of the given symbol through all of the basic blocks of the
-unit.
-
-=cut
-
-*/
-
-static void
-propagate_need(ARGMOD(Basic_block *bb), ARGIN(const SymReg *r), int i)
-{
- ASSERT_ARGS(propagate_need)
- Edge *edge;
- Life_range *l;
- Basic_block *pred;
-
- /* every predecessor of a LF_lv_in block must be in LF_lv_out
- * and, unless itself is LV_def, this should be propagated to its
- * predecessors themselves */
-
- for (edge = bb->pred_list; edge; edge = edge->pred_next) {
- pred = edge->from;
- l = r->life_info[pred->index];
-
- if (l->flags & LF_lv_out) {
- /* this node has already been visited. Ignore it */
- }
- else {
- l->flags |= LF_lv_out;
- l->last_ins = pred->end;
-
- if (! (l->flags & LF_def)) {
- l->flags |= LF_lv_in;
- l->first_ins = pred->start;
- l->last_ins = pred->end;
-
- /* we arrived at block 0
- *
- * emit a warning if -w looking at some Perl 6 examples where
- * this warning is emitted, there seems always to be a code
- * path where the var is not initialized, so this might even be
- * correct :)
- *
- * TT #1244: emit warning in propagate_need()
- */
- propagate_need(pred, r, i);
- }
- }
- }
-}
-
-
-/*
-
=item C<void compute_dominators(PARROT_INTERP, IMC_Unit *unit)>
Computes the dominators tree of the CFG. Basic block A dominates B if each
@@ -1605,28 +1337,6 @@
/*
-=item C<Life_range * make_life_range(PARROT_INTERP, SymReg *r, int idx)>
-
-Creates and returns a Life_range for the given register at the specified index.
-
-=cut
-
-*/
-
-PARROT_MALLOC
-PARROT_CANNOT_RETURN_NULL
-Life_range *
-make_life_range(PARROT_INTERP, ARGMOD(SymReg *r), int idx)
-{
- ASSERT_ARGS(make_life_range)
- Life_range * const l = mem_gc_allocate_zeroed_typed(interp, Life_range);
- r->life_info[idx] = l;
-
- return l;
-}
-
-/*
-
=back
=cut
Modified: trunk/compilers/imcc/cfg.h
==============================================================================
--- trunk/compilers/imcc/cfg.h Sun May 9 05:21:35 2010 (r46429)
+++ trunk/compilers/imcc/cfg.h Sun May 9 05:42:43 2010 (r46430)
@@ -89,22 +89,6 @@
__attribute__nonnull__(2)
FUNC_MODIFIES(*unit);
-void free_life_info(ARGIN(const IMC_Unit *unit), ARGMOD(SymReg *r))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*r);
-
-void life_analysis(PARROT_INTERP, ARGIN(const IMC_Unit *unit))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2);
-
-PARROT_MALLOC
-PARROT_CANNOT_RETURN_NULL
-Life_range * make_life_range(PARROT_INTERP, ARGMOD(SymReg *r), int idx)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*r);
-
PARROT_WARN_UNUSED_RESULT
int natural_preheader(
ARGIN(const IMC_Unit *unit),
@@ -141,15 +125,6 @@
#define ASSERT_ARGS_find_loops __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(unit))
-#define ASSERT_ARGS_free_life_info __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(unit) \
- , PARROT_ASSERT_ARG(r))
-#define ASSERT_ARGS_life_analysis __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp) \
- , PARROT_ASSERT_ARG(unit))
-#define ASSERT_ARGS_make_life_range __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
- PARROT_ASSERT_ARG(interp) \
- , PARROT_ASSERT_ARG(r))
#define ASSERT_ARGS_natural_preheader __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(unit) \
, PARROT_ASSERT_ARG(loop_info))
Modified: trunk/compilers/imcc/debug.c
==============================================================================
--- trunk/compilers/imcc/debug.c Sun May 9 05:21:35 2010 (r46429)
+++ trunk/compilers/imcc/debug.c Sun May 9 05:42:43 2010 (r46430)
@@ -417,86 +417,6 @@
(UINTVAL)r->usage);
}
fprintf(stderr, "\n");
- dump_liveness_status(unit);
-}
-
-/*
-
-=item C<void dump_liveness_status(const IMC_Unit *unit)>
-
-Dumps the list of registers in the current IMC_Unit that need to be
-allocated.
-
-=cut
-
-*/
-
-void
-dump_liveness_status(ARGIN(const IMC_Unit *unit))
-{
- ASSERT_ARGS(dump_liveness_status)
- unsigned int i;
- SymReg ** const reglist = unit->reglist;
-
- fprintf(stderr, "\nSymbols:\n--------------------------------------\n");
-
- for (i = 0; i < unit->n_symbols; i++) {
- const SymReg * const r = reglist[i];
- if (REG_NEEDS_ALLOC(r))
- dump_liveness_status_var(unit, r);
- }
-
- fprintf(stderr, "\n");
-}
-
-
-/*
-
-=item C<void dump_liveness_status_var(const IMC_Unit *unit, const SymReg* r)>
-
-Dumps the state of SymReg C<r> in IMC_Unit C<unit>.
-
-=cut
-
-*/
-
-void
-dump_liveness_status_var(ARGIN(const IMC_Unit *unit), ARGIN(const SymReg* r))
-{
- ASSERT_ARGS(dump_liveness_status_var)
- fprintf(stderr, "\nSymbol %s:", r->name);
- if (r->life_info) {
- unsigned int i;
-
- for (i = 0; i<unit->n_basic_blocks; i++) {
- const Life_range * const l = r->life_info[i];
-
- if (l->flags & LF_lv_all)
- fprintf(stderr, "\n\t%i:ALL\t", i);
- else if (l->flags & LF_lv_inside)
- fprintf(stderr, "\n\t%i:INSIDE", i);
-
- if (l->flags & LF_lv_in)
- fprintf(stderr, "\n\t%i: IN\t", i);
- else if (l->flags & LF_lv_out)
- fprintf(stderr, "\n\t%i: OUT\t", i);
- else if (l->first_ins)
- fprintf(stderr, "\n\t%i: INS\t", i);
-
- if (l->flags & LF_use)
- fprintf(stderr, "u ");
- else if (l->flags & LF_def)
- fprintf(stderr, "d ");
- else
- fprintf(stderr, " ");
-
- if (l->first_ins)
- fprintf(stderr, "[%d, %d]\t", l->first_ins->index,
- l->last_ins->index);
- }
- }
-
- fprintf(stderr, "\n");
}
/*
Modified: trunk/compilers/imcc/imc.h
==============================================================================
--- trunk/compilers/imcc/imc.h Sun May 9 05:21:35 2010 (r46429)
+++ trunk/compilers/imcc/imc.h Sun May 9 05:42:43 2010 (r46430)
@@ -530,11 +530,6 @@
AsmInYield
} AsmState;
-typedef enum _imcc_reg_allocator_t {
- IMCC_VANILLA_ALLOCATOR = 0,
- IMCC_GRAPH_ALLOCATOR
-} imcc_reg_allocator;
-
PARROT_EXPORT void IMCC_push_parser_state(PARROT_INTERP);
PARROT_EXPORT void IMCC_pop_parser_state(PARROT_INTERP, void *yyscanner);
@@ -608,7 +603,6 @@
jmp_buf jump_buf; /* The jump for error handling */
int IMCC_DEBUG;
int allocated;
- int allocator;
int cnr;
int cur_pmc_type;
int debug;
Modified: trunk/compilers/imcc/main.c
==============================================================================
--- trunk/compilers/imcc/main.c Sun May 9 05:21:35 2010 (r46429)
+++ trunk/compilers/imcc/main.c Sun May 9 05:42:43 2010 (r46430)
@@ -243,7 +243,6 @@
if (strchr(opt->opt_arg, 'c'))
IMCC_INFO(interp)->optimizer_level |= OPT_SUB;
- IMCC_INFO(interp)->allocator = IMCC_GRAPH_ALLOCATOR;
/* currently not ok due to different register allocation */
if (strchr(opt->opt_arg, '1')) {
IMCC_INFO(interp)->optimizer_level |= OPT_PRE;
@@ -432,7 +431,6 @@
Parrot_block_GC_sweep(interp);
IMCC_INFO(interp)->yyscanner = yyscanner;
- IMCC_INFO(interp)->allocator = IMCC_VANILLA_ALLOCATOR;
/* Default optimization level is zero; see optimizer.c, imc.h */
if (!IMCC_INFO(interp)->optimizer_level) {
Modified: trunk/compilers/imcc/reg_alloc.c
==============================================================================
--- trunk/compilers/imcc/reg_alloc.c Sun May 9 05:21:35 2010 (r46429)
+++ trunk/compilers/imcc/reg_alloc.c Sun May 9 05:42:43 2010 (r46430)
@@ -215,9 +215,6 @@
build_reglist(interp, unit);
- if (IMCC_INFO(interp)->allocator == IMCC_GRAPH_ALLOCATOR)
- life_analysis(interp, unit);
-
allocate_uniq(interp, unit, 0);
} while (!IMCC_INFO(interp)->dont_optimize && optimize(interp, unit));
@@ -254,11 +251,6 @@
#endif
if (unit->reglist) {
- unsigned int i;
-
- for (i = 0; i < unit->n_symbols; i++)
- free_life_info(unit, unit->reglist[i]);
-
mem_sys_free(unit->reglist);
unit->reglist = NULL;
unit->n_symbols = 0;
Modified: trunk/compilers/imcc/symreg.c
==============================================================================
--- trunk/compilers/imcc/symreg.c Sun May 9 05:21:35 2010 (r46429)
+++ trunk/compilers/imcc/symreg.c Sun May 9 05:42:43 2010 (r46430)
@@ -1631,10 +1631,6 @@
for (p = hsh->data[i]; p;) {
SymReg * const next = p->next;
-
- if (unit && p->life_info)
- free_life_info(unit, p);
-
free_sym(p);
p = next;
}
Modified: trunk/compilers/imcc/symreg.h
==============================================================================
--- trunk/compilers/imcc/symreg.h Sun May 9 05:21:35 2010 (r46429)
+++ trunk/compilers/imcc/symreg.h Sun May 9 05:42:43 2010 (r46430)
@@ -32,23 +32,6 @@
#define VTREGISTER (VTREG | VTIDENTIFIER | VTREGKEY | VTPASM)
#define REG_NEEDS_ALLOC(r) ((r)->type & VTREGISTER)
-enum LIFEFLAG { /* The status of a var inside a basic block can be */
- LF_use = 1 << 0, /* block uses the the var before defining it */
- LF_def = 1 << 1, /* block defines the variable */
- LF_lv_in = 1 << 2, /* variable is alive at the beginning of the block */
- LF_lv_out = 1 << 3, /* variable is alive at the end of the block */
- LF_lv_inside = 1 << 4, /* variable is alive at some moment in the block */
- LF_lv_all = 1 << 5 /* variable is alive throughout the block */
-};
-
-/* Liveness represents the usage of a var inside a basic block
- This is represented by pairs of [definition, usage] in *intervals: */
-typedef struct _Life_range {
- int flags;
- struct _Instruction *first_ins;
- struct _Instruction *last_ins;
-} Life_range;
-
enum USAGE {
U_KEYED = 1 << 0, /* array, hash, keyed */
U_NEW = 1 << 1, /* PMC was inited */
@@ -61,7 +44,6 @@
typedef struct _SymReg {
char *name;
char *subid;
- Life_range **life_info; /* Each block has a Life_range status */
struct _SymReg *nextkey; /* keys */
struct _SymReg *reg; /* key->register for VTREGKEYs */
struct pcc_sub_t *pcc_sub; /* PCC subroutine */
More information about the parrot-commits
mailing list