cvsuser     03/11/03 23:46:18

  Modified:    imcc     debug.h imc.h imc.c instructions.h instructions.c
                        jit.c main.c
  Log:
  Huge ugly patch that I've been dreading. Finally IMCC collects all
  compilation units before proceeding to the compile and emit steps.
  This is vital for us to move forward. This breaks a couple of things
  with bytecode loading (sub and eval tests failing), will fix soon
  if Leo doesn't get to it first. :)
  
  Revision  Changes    Path
  1.15      +9 -9      parrot/imcc/debug.h
  
  Index: debug.h
  ===================================================================
  RCS file: /cvs/public/parrot/imcc/debug.h,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -w -r1.14 -r1.15
  --- debug.h   23 Oct 2003 17:02:49 -0000      1.14
  +++ debug.h   4 Nov 2003 07:46:18 -0000       1.15
  @@ -20,14 +20,14 @@
   void debug(Parrot_Interp interpreter, int level, const char *fmt, ...);
   void info(Parrot_Interp interpreter, int level, const char *fmt, ...);
   
  -void dump_instructions(Parrot_Interp);
  -void dump_cfg(Parrot_Interp);
  -void dump_loops(Parrot_Interp);
  -void dump_labels(Parrot_Interp);
  -void dump_symreg(Parrot_Interp);
  -void dump_interference_graph(Parrot_Interp);
  -void dump_dominators(Parrot_Interp);
  -void dump_liveness_status(Parrot_Interp);
  -void dump_liveness_status_var(Parrot_Interp, SymReg*);
  +void dump_instructions(IMC_Unit *);
  +void dump_cfg(IMC_Unit *);
  +void dump_loops(IMC_Unit *);
  +void dump_labels(IMC_Unit *);
  +void dump_symreg(IMC_Unit *);
  +void dump_interference_graph(IMC_Unit *);
  +void dump_dominators(IMC_Unit *);
  +void dump_liveness_status(IMC_Unit *);
  +void dump_liveness_status_var(IMC_Unit *, SymReg*);
   
   #endif
  
  
  
  1.54      +17 -25    parrot/imcc/imc.h
  
  Index: imc.h
  ===================================================================
  RCS file: /cvs/public/parrot/imcc/imc.h,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -w -r1.53 -r1.54
  --- imc.h     4 Nov 2003 00:37:30 -0000       1.53
  +++ imc.h     4 Nov 2003 07:46:18 -0000       1.54
  @@ -54,8 +54,9 @@
   /*
    * imc.c
    */
  -void imc_compile_unit(struct Parrot_Interp *, Instruction * unit);
  -
  +void imc_compile_all_units(struct Parrot_Interp *);
  +void imc_compile_unit(struct Parrot_Interp *, IMC_Unit * unit);
  +IMC_Unit * imc_cur_unit(struct Parrot_Interp *);
   
   /*
    * instructions.c
  @@ -70,8 +71,8 @@
   /*
    * reg_alloc.c
    */
  -void imc_reg_alloc(struct Parrot_Interp *, Instruction * unit);
  -void free_reglist(struct Parrot_Interp *);
  +void imc_reg_alloc(struct Parrot_Interp *, IMC_Unit * unit);
  +void free_reglist(IMC_Unit *);
   
   /*
    * parser_util.c
  @@ -88,10 +89,10 @@
   /* 
    * pcc.c
    */
  -void expand_pcc_sub(Parrot_Interp interpreter, Instruction *ins);
  -void expand_pcc_sub_call(Parrot_Interp interpreter, Instruction *ins);
  -void expand_pcc_sub_ret(Parrot_Interp interpreter, Instruction *ins);
  -void pcc_optimize(Parrot_Interp interpreter);
  +void expand_pcc_sub(Parrot_Interp interpreter, IMC_Unit *, Instruction *ins);
  +void expand_pcc_sub_call(Parrot_Interp interpreter, IMC_Unit *, Instruction *ins);
  +void expand_pcc_sub_ret(Parrot_Interp interpreter, IMC_Unit *, Instruction *ins);
  +void pcc_optimize(Parrot_Interp interpreter, IMC_Unit *);
   
   int pcc_sub_reads(Instruction* ins, SymReg* r);
   int pcc_sub_writes(Instruction* ins, SymReg* r);
  @@ -130,27 +131,18 @@
   
   EXTERN struct imcc_ostat ostat;
   
  -typedef struct {
  +typedef struct _imc_info_t {
  +
  +    IMC_Unit * imc_units;
  +    IMC_Unit * cur_unit;
       int imcc_warn;
       int verbose;
       int debug;
  -    /* CFG stuff */
  -    int bb_list_size;
  -    int n_basic_blocks;
  -    Basic_block **bb_list;
  -    Set** dominators;
  -    int n_loops;
  -    Loop_info ** loop_info;
  -    Edge * edge_list;
  -    /* register allocation */
  -    int n_spilled;
  -    SymReg * p31;
  -    SymReg** interference_graph;
  -    SymReg** reglist;
  -    int n_symbols;
  -} imcc_info_t;
  +    int n_comp_units;
  +
  +} imc_info_t;
   
  -#define IMCC_INFO(i) ((imcc_info_t*) (i)->imcc_info)
  +#define IMCC_INFO(i) ((i)->imc_info)
   #endif
   
   
  
  
  
  1.62      +83 -2     parrot/imcc/imc.c
  
  Index: imc.c
  ===================================================================
  RCS file: /cvs/public/parrot/imcc/imc.c,v
  retrieving revision 1.61
  retrieving revision 1.62
  diff -u -w -r1.61 -r1.62
  --- imc.c     4 Nov 2003 00:37:30 -0000       1.61
  +++ imc.c     4 Nov 2003 07:46:18 -0000       1.62
  @@ -12,16 +12,97 @@
   #include "optimizer.h"
   
   
  +static IMC_Unit * imc_units;
  +static IMC_Unit * cur_unit;
  +
  +
  +void
  +imc_compile_all_units(struct Parrot_Interp *interp)
  +{
  +    IMC_Unit * unit;
  +    for(unit = interp->imc_info->imc_units; unit; unit = unit->next) {
  +        imc_compile_unit(interp, unit);
  +        emit_flush(interp, unit);
  +        imc_close_unit(interp, unit);
  +    }
  +}
  +
   /* imc_compile_unit is the main loop of the IMC compiler for each unit. It operates
    * on a single compilation unit at a time.
    */
   void
  -imc_compile_unit(struct Parrot_Interp *interpreter, Instruction * unit)
  +imc_compile_unit(struct Parrot_Interp *interp, IMC_Unit * unit)
   {
       /* Not much here for now except the allocator */
   
  -    imc_reg_alloc(interpreter, unit);
  +    imc_reg_alloc(interp, unit);
   }
  +
  +
  +/*
  + * Create a new IMC_Unit.
  + */
  +IMC_Unit *
  +imc_new_unit(IMC_Unit_Type t)
  +{
  +   IMC_Unit * unit = calloc(1, sizeof(IMC_Unit));
  +   unit->type = t;
  +   return unit;
  +}
  +
  +/*
  + * Create a new IMC_Unit and "open" it for construction.
  + * This sets the current state of the parser. The unit
  + * can be closed later retaining all the current state.
  + */
  +IMC_Unit *
  +imc_open_unit(Parrot_Interp interp, IMC_Unit_Type t)
  +{
  +    IMC_Unit * unit;
  +    unit = imc_new_unit(t);
  +    if(!interp->imc_info->cur_unit)
  +       interp->imc_info->imc_units = unit;
  +    unit->prev = cur_unit;
  +    if(interp->imc_info->cur_unit)
  +       interp->imc_info->cur_unit->next = unit;
  +    interp->imc_info->cur_unit = unit;
  +    interp->imc_info->n_comp_units++;
  +#if 0
  +    fprintf(stderr, "imc_open_unit()\n");
  +#endif
  +    return interp->imc_info->cur_unit;
  +}
  +
  +void
  +imc_close_unit(Parrot_Interp interp, IMC_Unit * unit)
  +{
  +    imc_info_t *imc = interp->imc_info;
  +
  +    free_reglist(unit);
  +    clear_basic_blocks(unit);       /* and cfg ... */
  +    if (!imc->n_comp_units)
  +        fatal(1, "close_comp_unit", "non existent comp_unit\n");
  +    imc->n_comp_units--;
  +    clear_tables(unit, hash);
  +#if 0
  +    fprintf(stderr, "imc_close_unit()\n");
  +#endif
  +/*
  +    imc->cur_unit->instructions = imc->cur_unit->last_ins = NULL;
  +*/
  +}
  +
  +
  +IMC_Unit *
  +imc_cur_unit(Parrot_Interp interp)
  +{
  +   /* Have to put this here as yacc and bison have problems
  +    * with the null pointer deref
  +    */
  +   return interp->imc_info->cur_unit;
  +}
  +
  +
   
   
   /*
  
  
  
  1.38      +18 -12    parrot/imcc/instructions.h
  
  Index: instructions.h
  ===================================================================
  RCS file: /cvs/public/parrot/imcc/instructions.h,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -w -r1.37 -r1.38
  --- instructions.h    26 Oct 2003 18:24:35 -0000      1.37
  +++ instructions.h    4 Nov 2003 07:46:18 -0000       1.38
  @@ -63,6 +63,9 @@
   } Instruction_Flags;
   
   
  +/* Forward decl */
  +struct _IMC_Unit;
  +
   
   /* Functions */
   /*
  @@ -74,15 +77,15 @@
   #else
   #define _mk_instruction(a,b,c,d) dont_use(a,b)
   #endif
  -Instruction * INS(struct Parrot_Interp *, char * name,
  +Instruction * INS(struct Parrot_Interp *, struct _IMC_Unit *, char * name,
        const char *fmt, SymReg **regs, int nargs, int keyv, int emit);
  -Instruction * INS_LABEL(SymReg * r0, int emit);
  +Instruction * INS_LABEL(struct _IMC_Unit *, SymReg * r0, int emit);
   
  -Instruction * iNEW(struct Parrot_Interp *,SymReg * r0, char * type,
  +Instruction * iNEW(struct Parrot_Interp *, struct _IMC_Unit *, SymReg * r0, char * 
type,
        SymReg *init, int emit);
  -Instruction * iNEWSUB(struct Parrot_Interp *,SymReg * r0, int type,
  +Instruction * iNEWSUB(struct Parrot_Interp *, struct _IMC_Unit *, SymReg * r0, int 
type,
        SymReg *init, int emit);
  -Instruction * emitb(Instruction *);
  +Instruction * emitb(struct _IMC_Unit *, Instruction *);
   
   int instruction_reads(Instruction *, SymReg *);
   int instruction_writes(Instruction *, SymReg *);
  @@ -92,29 +95,32 @@
   void free_ins(Instruction *);
   int ins_print(FILE *fd, Instruction * ins);
   
  -Instruction *delete_ins(Instruction *ins, int needs_freeing);
  -void insert_ins(Instruction *ins, Instruction * tmp);
  -Instruction *move_ins(Instruction *cur, Instruction *to);
  -void subst_ins(Instruction *ins, Instruction * tmp, int);
  +Instruction *delete_ins(struct _IMC_Unit *, Instruction *ins, int needs_freeing);
  +void insert_ins(struct _IMC_Unit *, Instruction *ins, Instruction * tmp);
  +Instruction *move_ins(struct _IMC_Unit *, Instruction *cur, Instruction *to);
  +void subst_ins(struct _IMC_Unit *, Instruction *ins, Instruction * tmp, int);
   
   int get_branch_regno(Instruction * ins);
   SymReg *get_branch_reg(Instruction * ins);
   
   /* Globals */
   
  +#if 0
  +/* per-unit instructions now (imc_info->imc_units) */
   EXTERN Instruction* instructions;
  +#endif
   
   typedef struct _emittert {
        int (*open)(void *param);
  -     int (*emit)(void *param, Instruction *ins);
  -     int (*new_sub)(void *param);
  +     int (*emit)(void *param, struct _IMC_Unit *, Instruction *ins);
  +     int (*new_sub)(void *param, struct _IMC_Unit *);
        int (*close)(void *param);
   } Emitter;
   
   enum Emitter_type { EMIT_FILE, EMIT_PBC };
   
   int emit_open(int type, void *param);
  -int emit_flush(void *param);
  +int emit_flush(void *param, struct _IMC_Unit *);
   int emit_close(void *param);
   
   void open_comp_unit(void);
  
  
  
  1.48      +37 -87    parrot/imcc/instructions.c
  
  Index: instructions.c
  ===================================================================
  RCS file: /cvs/public/parrot/imcc/instructions.c,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -w -r1.47 -r1.48
  --- instructions.c    4 Nov 2003 00:03:52 -0000       1.47
  +++ instructions.c    4 Nov 2003 07:46:18 -0000       1.48
  @@ -22,81 +22,31 @@
   
   /* Global variables , forward def */
   
  -static IMC_Unit * imc_units;
  -static IMC_Unit * cur_unit;
  -
  +#if 0
   static Instruction * last_ins;
   
   int n_comp_units;
  +#endif
  +
   
   static int e_file_open(void *);
   static int e_file_close(void *);
  -static int e_file_emit(void *param, Instruction *);
  +static int e_file_emit(void *param, IMC_Unit *, Instruction *);
   
   Emitter emitters[2] = {
  -    {e_file_open, e_file_emit, (int (*)(void *))NULLfunc, e_file_close},
  -    {e_pbc_open, e_pbc_emit, e_pbc_new_sub, e_pbc_close},
  +    {e_file_open,
  +     e_file_emit,
  +     (int (*)(void *))NULLfunc,
  +     e_file_close},
  +
  +    {e_pbc_open,
  +     e_pbc_emit,
  +     e_pbc_new_sub,
  +     e_pbc_close},
   };
   
   static int emitter;
   
  -/* all code is collected in compilation units, which may be:
  - * - .sub/.end
  - * - .emit/.eom
  - * - stuff outside of these
  - */
  -
  -
  -/*
  - * Create a new IMC_Unit.
  - */
  -IMC_Unit *
  -imc_new_unit(IMC_Unit_Type t)
  -{
  -   IMC_Unit * unit = calloc(1, sizeof(IMC_Unit));
  -   unit->type = t;
  -   return unit;
  -}
  -
  -/*
  - * Create a new IMC_Unit and "open" it for construction.
  - * This sets the current state of the parser. The unit
  - * can be closed later retaining all the current state.
  - */
  -IMC_Unit *
  -imc_open_unit(IMC_Unit_Type t)
  -{
  -    IMC_Unit * unit;
  -    unit = imc_new_unit(t);
  -    if(!cur_unit)
  -       imc_units = unit;
  -    unit->prev = cur_unit;
  -    if(cur_unit)
  -       cur_unit->next = unit;
  -    cur_unit = unit;
  -    n_comp_units++;
  -#if 0
  -    fprintf(stderr, "imc_open_unit()\n");
  -#endif
  -    return cur_unit;
  -}
  -
  -
  -void
  -imc_close_unit(Parrot_Interp interpreter)
  -{
  -    free_reglist(interpreter);
  -    clear_basic_blocks(interpreter);       /* and cfg ... */
  -    if (!n_comp_units)
  -        fatal(1, "close_comp_unit", "non existent comp_unit\n");
  -    n_comp_units--;
  -    clear_tables(interpreter, hash);
  -#if 0
  -    fprintf(stderr, "imc_close_unit()\n");
  -#endif
  -    instructions = last_ins = NULL;
  -}
  -
   
   /* Creates a new instruction */
   
  @@ -276,7 +226,7 @@
    * actual new ins is returned
    */
   Instruction *
  -delete_ins(Instruction *ins, int needs_freeing)
  +delete_ins(IMC_Unit *unit, Instruction *ins, int needs_freeing)
   {
       Instruction *next, *prev;
   
  @@ -285,7 +235,7 @@
       if (prev)
           prev->next = next;
       else
  -        instructions = next;
  +        unit->instructions = next;
       if (next)
           next->prev = prev;
       if (needs_freeing)
  @@ -298,12 +248,12 @@
    */
   
   void
  -insert_ins(Instruction *ins, Instruction * tmp)
  +insert_ins(IMC_Unit *unit, Instruction *ins, Instruction * tmp)
   {
       Instruction *next;
       if (!ins) {
  -        next = instructions;
  -        instructions = tmp;
  +        next = unit->instructions;
  +        unit->instructions = tmp;
           tmp->next = next;
           next->prev = tmp;
           tmp->line = next->line;
  @@ -325,13 +275,13 @@
    */
   
   void
  -subst_ins(Instruction *ins, Instruction * tmp, int needs_freeing)
  +subst_ins(IMC_Unit *unit, Instruction *ins, Instruction * tmp, int needs_freeing)
   {
       Instruction *prev = ins->prev;
       if (prev)
           prev->next = tmp;
       else
  -        instructions = tmp;
  +        unit->instructions = tmp;
       tmp->prev = prev;
       tmp->next = ins->next;
       if (ins->next)
  @@ -344,27 +294,27 @@
   
   /* move instruction ins to to */
   Instruction *
  -move_ins(Instruction *ins, Instruction *to)
  +move_ins(IMC_Unit * unit, Instruction *ins, Instruction *to)
   {
  -    Instruction *next = delete_ins(ins, 0);
  -    insert_ins(to, ins);
  +    Instruction *next = delete_ins(unit, ins, 0);
  +    insert_ins(unit, to, ins);
       return next;
   }
   
   
  -/* Emits the instructions buffered in 'instructions' */
  +/* Emit a single instruction into the current unit buffer. */
   Instruction *
  -emitb(Instruction * i)
  +emitb(IMC_Unit * unit, Instruction * i)
   {
   
  -    if (!i)
  +    if (!unit || !i)
        return 0;
  -    if(!instructions)
  -        last_ins = instructions = i;
  +    if(!unit->instructions)
  +        unit->last_ins = unit->instructions = i;
       else {
  -     last_ins->next = i;
  -        i->prev = last_ins;
  -     last_ins = i;
  +     unit->last_ins->next = i;
  +        i->prev = unit->last_ins;
  +     unit->last_ins = i;
       }
       i->line = line - 1;         /* lexer is in next line already */
       return i;
  @@ -488,7 +438,7 @@
   }
   
   static int
  -e_file_emit(void *param, Instruction * ins)
  +e_file_emit(void *param, IMC_Unit * unit, Instruction * ins)
   {
       UNUSED(param);
       if ((ins->type & ITLABEL) || ! *ins->op)
  @@ -510,17 +460,17 @@
   }
   
   int
  -emit_flush(void *param)
  +emit_flush(void *param, IMC_Unit * unit)
   {
       Instruction * ins, *next;
       struct Parrot_Interp *interpreter = (struct Parrot_Interp *)param;
       if (emitters[emitter].new_sub)
  -        (emitters[emitter]).new_sub(param);
  -    for (ins = instructions; ins; ins = ins->next) {
  +        (emitters[emitter]).new_sub(param, unit);
  +    for (ins = unit->instructions; ins; ins = ins->next) {
           debug(interpreter, DEBUG_IMC, "emit %I\n", ins);
  -        (emitters[emitter]).emit(param, ins);
  +        (emitters[emitter]).emit(param, unit, ins);
       }
  -    for (ins = instructions; ins; ) {
  +    for (ins = unit->instructions; ins; ) {
           next = ins->next;
           free_ins(ins);
           ins = next;
  
  
  
  1.10      +27 -27    parrot/imcc/jit.c
  
  Index: jit.c
  ===================================================================
  RCS file: /cvs/public/parrot/imcc/jit.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -w -r1.9 -r1.10
  --- jit.c     23 Oct 2003 17:02:49 -0000      1.9
  +++ jit.c     4 Nov 2003 07:46:18 -0000       1.10
  @@ -65,12 +65,12 @@
    * check life range of all symbols, find the max used mapped
    */
   static int
  -max_used(Parrot_Interp interpreter, int bbi, char t, int typ, int mapped[])
  +max_used(IMC_Unit * unit, int bbi, char t, int typ, int mapped[])
   {
       int max, j, c;
  -    SymReg** reglist = IMCC_INFO(interpreter)->reglist;
  +    SymReg** reglist = unit->reglist;
   
  -    for (j = 0, max = 0; j < IMCC_INFO(interpreter)->n_symbols; j++) {
  +    for (j = 0, max = 0; j < unit->n_symbols; j++) {
           SymReg * r = reglist[j];
           if (r->set != t)
               continue;
  @@ -89,13 +89,13 @@
    * if none found, don't emit load/store for preserved regs
    */
   static int
  -min_used(Parrot_Interp interpreter, int bbi, char t, int typ,
  +min_used(IMC_Unit * unit, int bbi, char t, int typ,
           int preserved[], int mapped[])
   {
       int max, j, c;
  -    SymReg** reglist = IMCC_INFO(interpreter)->reglist;
  +    SymReg** reglist = unit->reglist;
   
  -    for (j = 0, max = mapped[typ]; j < IMCC_INFO(interpreter)->n_symbols; j++) {
  +    for (j = 0, max = mapped[typ]; j < unit->n_symbols; j++) {
           SymReg * r = reglist[j];
           if (r->set != t)
               continue;
  @@ -110,7 +110,7 @@
   }
   
   void
  -allocate_jit(struct Parrot_Interp *interpreter)
  +allocate_jit(struct Parrot_Interp *interpreter, IMC_Unit * unit)
   {
       int c, i, j, k, typ;
       int to_map[4] = {0,0,0,0};
  @@ -129,7 +129,7 @@
       opcode_t pc;
       static int nsubs;
       opcode_t * jit_info_ptr;
  -    SymReg** reglist = IMCC_INFO(interpreter)->reglist;
  +    SymReg** reglist = unit->reglist;
   
       assert(INT_REGISTERS_TO_MAP < MAX_MAPPED);
       assert(FLOAT_REGISTERS_TO_MAP < MAX_MAPPED);
  @@ -156,7 +156,7 @@
        * compiled code - so track PMCs and invokes too
        */
       if (!has_compile && !dont_optimize) {
  -        for (j = 0; j < IMCC_INFO(interpreter)->n_symbols; j++) {
  +        for (j = 0; j < unit->n_symbols; j++) {
               r = reglist[j];
               if (r->set == 'K')
                   continue;
  @@ -176,29 +176,29 @@
       to_map[3] = maxc[3];
       if (!nsubs++) {
           /* clear all used regs at beginning */
  -        last = instructions->type & ITLABEL ? instructions : NULL;
  +        last = unit->instructions->type & ITLABEL ? unit->instructions : NULL;
           for (typ = 0; typ < 4; typ++)
               for (j = 0; j < to_map[typ]; j++) {
                   regs[0] = cpu[typ][j];
                   regs[1] = par[typ][j];
  -                tmp = INS(interpreter, "set", "%s, %s\t# init",
  +                tmp = INS(interpreter, unit, "set", "%s, %s\t# init",
                           regs, 2, 0, 0);
  -                insert_ins(last, tmp);
  +                insert_ins(unit, last, tmp);
               }
       }
       /* now run through basic blocks
        * and insert register save/load instructions where needed
        */
  -    for (i=0; i < IMCC_INFO(interpreter)->n_basic_blocks; i++) {
  -        bb = IMCC_INFO(interpreter)->bb_list[i];
  +    for (i=0; i < unit->n_basic_blocks; i++) {
  +        bb = unit->bb_list[i];
           /* TODO: set minimum register usage for this block */
   
           for (ins = bb->start; ins; ins = ins->next) {
               /* clear preserved regs, set rw of non preserved regs */
  -            for (typ = 0; ins != instructions && typ < 4; typ++)
  +            for (typ = 0; ins != unit->instructions && typ < 4; typ++)
                   for (k = 0; k < to_map[typ]; k++) {
                       reads[typ][k] = writes[typ][k] =
  -                        k >= min_used(interpreter, i, types[typ], typ,
  +                        k >= min_used(unit, i, types[typ], typ,
                                   preserved, to_map);
                   }
               /* if extern, go through regs and check the usage */
  @@ -216,7 +216,7 @@
                        * if a reg was writen, we reload it after the
                        * extern code block
                        */
  -                    for (j = 0; j < IMCC_INFO(interpreter)->n_symbols; j++) {
  +                    for (j = 0; j < unit->n_symbols; j++) {
                           r = reglist[j];
                           if (r->set == 'K')
                               continue;
  @@ -228,7 +228,7 @@
                                   (ins->type & ITSAVES)) {
                               int bb_sub =
                                   find_sym(ins->r[0]->name)->first_ins->bbindex;
  -                            if (max_used(interpreter, bb_sub, types[typ],
  +                            if (max_used(unit, bb_sub, types[typ],
                                           typ, to_map))
                                   reads[typ][c] = writes[typ][c] = nr = nw = 1;
                           }
  @@ -275,9 +275,9 @@
                               continue;
                           regs[0] = cpu[typ][j];
                           regs[1] = par[typ][j];
  -                        tmp = INS(interpreter, "set", "%s, %s\t# load",
  +                        tmp = INS(interpreter, unit,"set", "%s, %s\t# load",
                                   regs, 2, 0, 0);
  -                        insert_ins(last, tmp);
  +                        insert_ins(unit, last, tmp);
                       }
                   nw = 0;
               }
  @@ -289,9 +289,9 @@
                               continue;
                           regs[0] = par[typ][j];
                           regs[1] = cpu[typ][j];
  -                        tmp = INS(interpreter, "set", "%s, %s\t# save",
  +                        tmp = INS(interpreter, unit, "set", "%s, %s\t# save",
                                   regs, 2, 0, 0);
  -                        insert_ins(prev, tmp);
  +                        insert_ins(unit, prev, tmp);
                       }
                   nr = 0;
               }
  @@ -300,15 +300,15 @@
           }
       }
   
  -    find_basic_blocks(interpreter, 0);
  +    find_basic_blocks(interpreter, unit, 0);
       /* allocate a jit_info packfile segment holding
        * some CFG and register usage info
        */
  -    jit_info_ptr = make_jit_info(interpreter);
  +    jit_info_ptr = make_jit_info(interpreter, unit);
       /* write out minimal CFG and register_usage */
  -    for (i = 0, pc = 0; i < IMCC_INFO(interpreter)->n_basic_blocks; i++) {
  +    for (i = 0, pc = 0; i < unit->n_basic_blocks; i++) {
           int branch_target = 0;
  -        bb = IMCC_INFO(interpreter)->bb_list[i];
  +        bb = unit->bb_list[i];
           ins = bb->start;
           /* mark branch targets with hight bit set */
           if (ins->type & ITLABEL)
  @@ -325,7 +325,7 @@
            */
           for (typ = 0; typ < 4; typ++)
               *jit_info_ptr++ = to_map[typ];
  -        /*  = max_used(i, types[typ], typ, to_map); */
  +        /*  = max_used(unit, types[typ], typ, to_map); */
       }
   }
   
  
  
  
  1.60      +13 -10    parrot/imcc/main.c
  
  Index: main.c
  ===================================================================
  RCS file: /cvs/public/parrot/imcc/main.c,v
  retrieving revision 1.59
  retrieving revision 1.60
  diff -u -w -r1.59 -r1.60
  --- main.c    4 Nov 2003 01:25:07 -0000       1.59
  +++ main.c    4 Nov 2003 07:46:18 -0000       1.60
  @@ -191,17 +191,17 @@
                   break;
               case 'd':
                   if (opt.opt_arg) {
  -                    IMCC_INFO(interp)->debug = strtoul(opt.opt_arg, 0, 16);
  +                    interp->imc_info->debug = strtoul(opt.opt_arg, 0, 16);
                   }
                   else {
  -                    IMCC_INFO(interp)->debug++;
  +                    interp->imc_info->debug++;
                   }
  -                if (IMCC_INFO(interp)->debug & 1)
  +                if (interp->imc_info->debug & 1)
                       setopt(PARROT_DEBUG_FLAG);
                   break;
               case 'w':
                   Parrot_setwarnings(interp, PARROT_WARNINGS_ALL_FLAG);
  -                IMCC_INFO(interp)->imcc_warn = 1;
  +                interp->imc_info->imcc_warn = 1;
                   break;
               case 'G':
                   gc_off = 1;
  @@ -231,7 +231,7 @@
                   load_pbc = 1;
                   break;
               case 'v':
  -                IMCC_INFO(interp)->verbose++;
  +                interp->imc_info->verbose++;
                   break;
               case 'y':
                   yydebug = 1;
  @@ -403,7 +403,7 @@
       struct Parrot_Interp *interpreter = Parrot_new();
   
       Parrot_init(interpreter);
  -    interpreter->imcc_info = mem_sys_allocate_zeroed(sizeof(imcc_info_t));
  +    interpreter->imc_info = mem_sys_allocate_zeroed(sizeof(imc_info_t));
   
       interpreter->DOD_block_level++;
   
  @@ -467,8 +467,8 @@
               fatal(1, "main", "outputfile is sourcefile\n");
       }
   
  -    if (IMCC_INFO(interpreter)->verbose) {
  -        info(interpreter, 1,"debug = 0x%x\n", IMCC_INFO(interpreter)->debug);
  +    if (interpreter->imc_info->verbose) {
  +        info(interpreter, 1,"debug = 0x%x\n", interpreter->imc_info->debug);
           info(interpreter, 1,"Reading %s\n", yyin == stdin ? "stdin":sourcefile);
       }
       if (load_pbc) {
  @@ -491,6 +491,9 @@
           info(interpreter, 1, "Starting parse...\n");
   
           yyparse((void *) interpreter);
  +
  +        imc_compile_all_units(interpreter);
  +
           emit_close(interpreter);
           fclose(yyin);
   
  @@ -529,7 +532,7 @@
           load_pbc = 1;
       }
       if (run_pbc) {
  -        if (IMCC_INFO(interpreter)->imcc_warn)
  +        if (interpreter->imc_info->imcc_warn)
               PARROT_WARNINGS_on(interpreter, PARROT_WARNINGS_ALL_FLAG);
           else
               PARROT_WARNINGS_off(interpreter, PARROT_WARNINGS_ALL_FLAG);
  @@ -547,7 +550,7 @@
       Parrot_destroy(interpreter);
       if (output)
           free(output);
  -    mem_sys_free(IMCC_INFO(interpreter));
  +    mem_sys_free(interpreter->imc_info);
       Parrot_exit(0);
   
       return 0;
  
  
  

Reply via email to