Skip to content

Commit

Permalink
Merge branch 'whiteknight/imcc_info_struct' into whiteknight/imcc_com…
Browse files Browse the repository at this point in the history
…preg_pmc
  • Loading branch information
Whiteknight committed Jan 25, 2011
2 parents 3c75ac6 + 1d11482 commit c26cc03
Show file tree
Hide file tree
Showing 31 changed files with 4,204 additions and 3,800 deletions.
246 changes: 131 additions & 115 deletions compilers/imcc/cfg.c

Large diffs are not rendered by default.

30 changes: 20 additions & 10 deletions compilers/imcc/cfg.h
Expand Up @@ -56,38 +56,48 @@ int blocks_are_connected(
__attribute__nonnull__(1)
__attribute__nonnull__(2);

void build_cfg(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
void build_cfg(ARGMOD(imc_info_t *imcc), ARGMOD(IMC_Unit *unit))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
FUNC_MODIFIES(*imcc)
FUNC_MODIFIES(*unit);

void clear_basic_blocks(ARGMOD(IMC_Unit *unit))
__attribute__nonnull__(1)
FUNC_MODIFIES(*unit);

void compute_dominance_frontiers(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
void compute_dominance_frontiers(
ARGMOD(imc_info_t *imcc),
ARGMOD(IMC_Unit *unit))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
FUNC_MODIFIES(*imcc)
FUNC_MODIFIES(*unit);

void compute_dominators(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
void compute_dominators(ARGMOD(imc_info_t *imcc), ARGMOD(IMC_Unit *unit))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
FUNC_MODIFIES(*imcc)
FUNC_MODIFIES(*unit);

PARROT_WARN_UNUSED_RESULT
PARROT_PURE_FUNCTION
int edge_count(ARGIN(const IMC_Unit *unit))
__attribute__nonnull__(1);

void find_basic_blocks(PARROT_INTERP, ARGMOD(IMC_Unit *unit), int first)
void find_basic_blocks(
ARGMOD(imc_info_t *imcc),
ARGMOD(IMC_Unit *unit),
int first)
__attribute__nonnull__(1)
__attribute__nonnull__(2)
FUNC_MODIFIES(*imcc)
FUNC_MODIFIES(*unit);

void find_loops(PARROT_INTERP, ARGMOD(IMC_Unit *unit))
void find_loops(ARGMOD(imc_info_t *imcc), ARGMOD(IMC_Unit *unit))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
FUNC_MODIFIES(*imcc)
FUNC_MODIFIES(*unit);

PARROT_WARN_UNUSED_RESULT
Expand All @@ -109,23 +119,23 @@ void search_predecessors_not_in(
PARROT_ASSERT_ARG(from) \
, PARROT_ASSERT_ARG(to))
#define ASSERT_ARGS_build_cfg __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
PARROT_ASSERT_ARG(imcc) \
, PARROT_ASSERT_ARG(unit))
#define ASSERT_ARGS_clear_basic_blocks __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(unit))
#define ASSERT_ARGS_compute_dominance_frontiers __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
PARROT_ASSERT_ARG(imcc) \
, PARROT_ASSERT_ARG(unit))
#define ASSERT_ARGS_compute_dominators __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
PARROT_ASSERT_ARG(imcc) \
, PARROT_ASSERT_ARG(unit))
#define ASSERT_ARGS_edge_count __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(unit))
#define ASSERT_ARGS_find_basic_blocks __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
PARROT_ASSERT_ARG(imcc) \
, PARROT_ASSERT_ARG(unit))
#define ASSERT_ARGS_find_loops __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
PARROT_ASSERT_ARG(imcc) \
, PARROT_ASSERT_ARG(unit))
#define ASSERT_ARGS_natural_preheader __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(unit) \
Expand Down
64 changes: 32 additions & 32 deletions compilers/imcc/debug.c
Expand Up @@ -29,7 +29,7 @@ handle info/error/warning messages from imcc

/*
=item C<void IMCC_fatal(PARROT_INTERP, int code, const char *fmt, ...)>
=item C<void IMCC_fatal(imc_info_t * imcc, int code, const char *fmt, ...)>
Prints out a fatal error message from IMCC and throws an
IMCC_FATAL_EXCEPTION.
Expand All @@ -40,20 +40,20 @@ IMCC_FATAL_EXCEPTION.

PARROT_DOES_NOT_RETURN
void
IMCC_fatal(PARROT_INTERP, SHIM(int code), ARGIN(const char *fmt), ...)
IMCC_fatal(ARGMOD(imc_info_t * imcc), SHIM(int code), ARGIN(const char *fmt), ...)
{
ASSERT_ARGS(IMCC_fatal)
va_list ap;

va_start(ap, fmt);
IMCC_INFO(interp)->error_message = Parrot_vsprintf_c(interp, fmt, ap);
imcc->error_message = Parrot_vsprintf_c(imcc->interp, fmt, ap);
va_end(ap);
IMCC_THROW(IMCC_INFO(interp)->jump_buf, IMCC_FATAL_EXCEPTION);
IMCC_THROW(imcc->jump_buf, IMCC_FATAL_EXCEPTION);
}

/*
=item C<void IMCC_fataly(PARROT_INTERP, int code, const char *fmt, ...)>
=item C<void IMCC_fataly(imc_info_t * imcc, int code, const char *fmt, ...)>
Throws an IMCC_FATALY_EXCEPTION.
Expand All @@ -63,20 +63,20 @@ Throws an IMCC_FATALY_EXCEPTION.

PARROT_DOES_NOT_RETURN
void
IMCC_fataly(PARROT_INTERP, SHIM(int code), ARGIN(const char *fmt), ...)
IMCC_fataly(ARGMOD(imc_info_t * imcc), SHIM(int code), ARGIN(const char *fmt), ...)
{
ASSERT_ARGS(IMCC_fataly)
va_list ap;

va_start(ap, fmt);
IMCC_INFO(interp)->error_message = Parrot_vsprintf_c(interp, fmt, ap);
imcc->error_message = Parrot_vsprintf_c(imcc->interp, fmt, ap);
va_end(ap);
IMCC_THROW(IMCC_INFO(interp)->jump_buf, IMCC_FATALY_EXCEPTION);
IMCC_THROW(imcc->jump_buf, IMCC_FATALY_EXCEPTION);
}

/*
=item C<void IMCC_fatal_standalone(PARROT_INTERP, int code, const char *fmt,
=item C<void IMCC_fatal_standalone(imc_info_t * imcc, int code, const char *fmt,
...)>
Prints an error message from IMCC and exits Parrot. This is not a
Expand All @@ -88,20 +88,20 @@ recoverable exception but a forced exit.

PARROT_DOES_NOT_RETURN
void
IMCC_fatal_standalone(PARROT_INTERP, int code, ARGIN(const char *fmt), ...)
IMCC_fatal_standalone(ARGMOD(imc_info_t * imcc), int code, ARGIN(const char *fmt), ...)
{
ASSERT_ARGS(IMCC_fatal_standalone)
va_list ap;

va_start(ap, fmt);
imcc_vfprintf(interp, Parrot_io_STDERR(interp), fmt, ap);
imcc_vfprintf(imcc, Parrot_io_STDERR(imcc->interp), fmt, ap);
va_end(ap);
Parrot_x_jump_out_error(interp, code);
Parrot_x_jump_out_error(imcc->interp, code);
}

/*
=item C<void IMCC_warning(PARROT_INTERP, const char *fmt, ...)>
=item C<void IMCC_warning(imc_info_t * imcc, const char *fmt, ...)>
Prints a warning message, but does not throw an exception and does not
cause Parrot to exit.
Expand All @@ -111,18 +111,18 @@ cause Parrot to exit.
*/

void
IMCC_warning(PARROT_INTERP, ARGIN(const char *fmt), ...)
IMCC_warning(ARGMOD(imc_info_t * imcc), ARGIN(const char *fmt), ...)
{
ASSERT_ARGS(IMCC_warning)
va_list ap;
va_start(ap, fmt);
imcc_vfprintf(interp, Parrot_io_STDERR(interp), fmt, ap);
imcc_vfprintf(imcc, Parrot_io_STDERR(imcc->interp), fmt, ap);
va_end(ap);
}

/*
=item C<void IMCC_info(PARROT_INTERP, int level, const char *fmt, ...)>
=item C<void IMCC_info(imc_info_t * imcc, int level, const char *fmt, ...)>
Prints some information, if the level of the information is higher
then IMCC's verbose mode.
Expand All @@ -132,22 +132,22 @@ then IMCC's verbose mode.
*/

void
IMCC_info(PARROT_INTERP, int level, ARGIN(const char *fmt), ...)
IMCC_info(ARGMOD(imc_info_t * imcc), int level, ARGIN(const char *fmt), ...)
{
ASSERT_ARGS(IMCC_info)
va_list ap;

if (level > IMCC_INFO(interp)->verbose)
if (level > imcc->verbose)
return;

va_start(ap, fmt);
imcc_vfprintf(interp, Parrot_io_STDERR(interp), fmt, ap);
imcc_vfprintf(imcc, Parrot_io_STDERR(imcc->interp), fmt, ap);
va_end(ap);
}

/*
=item C<void IMCC_debug(PARROT_INTERP, int level, const char *fmt, ...)>
=item C<void IMCC_debug(imc_info_t * imcc, int level, const char *fmt, ...)>
Prints a debug message, if IMCC's debug mode is turned on.
Expand All @@ -156,21 +156,21 @@ Prints a debug message, if IMCC's debug mode is turned on.
*/

void
IMCC_debug(PARROT_INTERP, int level, ARGIN(const char *fmt), ...)
IMCC_debug(ARGMOD(imc_info_t * imcc), int level, ARGIN(const char *fmt), ...)
{
ASSERT_ARGS(IMCC_debug)
va_list ap;

if (!(level & IMCC_INFO(interp)->debug))
if (!(level & imcc->debug))
return;
va_start(ap, fmt);
imcc_vfprintf(interp, Parrot_io_STDERR(interp), fmt, ap);
imcc_vfprintf(imcc, Parrot_io_STDERR(imcc->interp), fmt, ap);
va_end(ap);
}

/*
=item C<void dump_instructions(PARROT_INTERP, const IMC_Unit *unit)>
=item C<void dump_instructions(imc_info_t * imcc, const IMC_Unit *unit)>
Dumps the current instruction status of IMCC
Expand All @@ -179,38 +179,38 @@ Dumps the current instruction status of IMCC
*/

void
dump_instructions(PARROT_INTERP, ARGIN(const IMC_Unit *unit))
dump_instructions(ARGMOD(imc_info_t * imcc), ARGIN(const IMC_Unit *unit))
{
ASSERT_ARGS(dump_instructions)
const Instruction *ins;
int pc;

Parrot_io_eprintf(interp,
Parrot_io_eprintf(imcc->interp,
"\nDumping the instructions status:"
"\n-------------------------------\n");
Parrot_io_eprintf(interp,
Parrot_io_eprintf(imcc->interp,
"nins line blck deep flags\t type opnr size pc X ins\n");

for (pc = 0, ins = unit->instructions; ins; ins = ins->next) {
const Basic_block * const bb = unit->bb_list[ins->bbindex];

if (bb) {
Parrot_io_eprintf(interp,
Parrot_io_eprintf(imcc->interp,
"%4i %4d %4d %4d\t%x\t%8x %4d %4d %4d ",
ins->index, ins->line, bb->index, bb->loop_depth,
ins->flags, ins->type, OP_INFO_OPNUM(ins->op),
ins->opsize, pc);
}
else {
Parrot_io_eprintf(interp, "\t");
Parrot_io_eprintf(imcc->interp, "\t");
}

Parrot_io_eprintf(interp, "%s\n", ins->opname);
ins_print(interp, PIO_STDHANDLE(interp, PIO_STDERR_FILENO), ins);
Parrot_io_eprintf(imcc->interp, "%s\n", ins->opname);
ins_print(imcc, PIO_STDHANDLE(imcc->interp, PIO_STDERR_FILENO), ins);
pc += ins->opsize;
}

Parrot_io_eprintf(interp, "\n");
Parrot_io_eprintf(imcc->interp, "\n");
}

/*
Expand Down

0 comments on commit c26cc03

Please sign in to comment.