cvsuser     04/08/07 17:18:15

  Modified:    imcc     reg_alloc.c unit.h
  Log:
  Oops, the patch I sent in earlier had the old data structure comment.
  Also, changed things from 'int' to 'unsigned int' on Greg Bacon's
  recommendation -- it doesn't really change anything, but makes more
  sense.
  
  Though I am now wondering why I used ig_* (_i_nterference _g_raph)
  prefixes for everything, since none of the routines do anything other
  than a simple 2d bitmap; there's nothing specific to interference
  graphs. Oh well.
  
  Revision  Changes    Path
  1.18      +19 -20    parrot/imcc/reg_alloc.c
  
  Index: reg_alloc.c
  ===================================================================
  RCS file: /cvs/public/parrot/imcc/reg_alloc.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -w -r1.17 -r1.18
  --- reg_alloc.c       7 Aug 2004 17:53:41 -0000       1.17
  +++ reg_alloc.c       8 Aug 2004 00:18:15 -0000       1.18
  @@ -41,7 +41,7 @@
   static void compute_du_chain(IMC_Unit * unit);
   static void compute_one_du_chain(SymReg * r, IMC_Unit * unit);
   static int interferes(IMC_Unit *, SymReg * r0, SymReg * r1);
  -static int map_colors(IMC_Unit *, int x, int * graph, int colors[], int typ);
  +static int map_colors(IMC_Unit *, int x, unsigned int * graph, int colors[], int 
typ);
   #ifdef DO_SIMPLIFY
   static int simplify (IMC_Unit *);
   #endif
  @@ -58,44 +58,45 @@
   /* XXX FIXME: Globals: */
   
   static IMCStack nodeStack;
  -static int* interference_graph;
  +static unsigned int* interference_graph;
   static int n_symbols;
   
  -static int* ig_get_word(int i, int j, int N, int* graph, int* bit_ofs)
  +static unsigned int* ig_get_word(int i, int j, int N, unsigned int* graph,
  +                                 int* bit_ofs)
   {
  -    int bit = i * N + j;
  +    unsigned int bit = i * N + j;
       *bit_ofs = bit % sizeof(*graph);
       return &graph[bit / sizeof(*graph)];
   }
   
  -static void ig_set(int i, int j, int N, int* graph)
  +static void ig_set(int i, int j, int N, unsigned int* graph)
   {
       int bit_ofs;
  -    int* word = ig_get_word(i, j, N, graph, &bit_ofs);
  +    unsigned int* word = ig_get_word(i, j, N, graph, &bit_ofs);
       *word |= (1 << bit_ofs);
   }
   
  -static void ig_clear(int i, int j, int N, int* graph)
  +static void ig_clear(int i, int j, int N, unsigned int* graph)
   {
       int bit_ofs;
  -    int* word = ig_get_word(i, j, N, graph, &bit_ofs);
  +    unsigned int* word = ig_get_word(i, j, N, graph, &bit_ofs);
       *word &= ~(1 << bit_ofs);
   }
   
  -static int ig_test(int i, int j, int N, int* graph)
  +static int ig_test(int i, int j, int N, unsigned int* graph)
   {
       int bit_ofs;
  -    int* word = ig_get_word(i, j, N, graph, &bit_ofs);
  +    unsigned int* word = ig_get_word(i, j, N, graph, &bit_ofs);
       return *word & (1 << bit_ofs);
   }
   
  -static int* ig_allocate(int N)
  +static unsigned int* ig_allocate(int N)
   {
       // size is N*N bits, but we want don't want to allocate a partial
       // word, so round up to the nearest multiple of sizeof(int).
       int need_bits = N * N;
       int num_words = (need_bits + sizeof(int) - 1) / sizeof(int);
  -    return (int*) calloc(num_words, sizeof(int));
  +    return (unsigned int*) calloc(num_words, sizeof(int));
   }
   
   /* imc_reg_alloc is the main loop of the allocation algorithm. It operates
  @@ -491,11 +492,9 @@
   
   /* creates the interference graph between the variables.
    *
  - * data structure is a 2-d array 'interference_graph' where row/column
  - * indices represent the same index in the list of all symbols
  - * (unit->reglist) in the current compilation unit. The value in the
  - * 2-d array interference_graph[i][j] is the symbol unit->reglist[j]
  - * itself.
  + * data structure is a 2-d array 'interference_graph' bitmap where
  + * row/column indices represent the same index in the list of all
  + * symbols (unit->reglist) in the current compilation unit.
    *
    * two variables interfere when they are alive at the
    * same time
  @@ -901,7 +900,7 @@
       int x = 0;
       int color, colors[MAX_COLOR];
       int free_colors, t;
  -    int *graph = interference_graph;
  +    unsigned int *graph = interference_graph;
       SymReg ** reglist = unit->reglist;
   
       while ((imcstack_depth(nodeStack) > 0) ) {
  @@ -953,7 +952,7 @@
    * map_colors: calculates what colors can be assigned to the x-th symbol.
    */
   static int
  -map_colors(IMC_Unit* unit, int x, int *graph, int colors[], int typ)
  +map_colors(IMC_Unit* unit, int x, unsigned int *graph, int colors[], int typ)
   {
       int y = 0;
       SymReg * r;
  @@ -1057,7 +1056,7 @@
       SymReg ** reglist = unit->reglist;
       if (old != new) {
           /* n_symbols is already increased */
  -        int *new_graph = ig_allocate(n_symbols);
  +        unsigned int *new_graph = ig_allocate(n_symbols);
           /* old symbols count of previous graph */
           int o = n_symbols - 1;
           for (x = 0; x < o; x++) {
  
  
  
  1.9       +1 -1      parrot/imcc/unit.h
  
  Index: unit.h
  ===================================================================
  RCS file: /cvs/public/parrot/imcc/unit.h,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -w -r1.8 -r1.9
  --- unit.h    7 Aug 2004 17:53:41 -0000       1.8
  +++ unit.h    8 Aug 2004 00:18:15 -0000       1.9
  @@ -31,7 +31,7 @@
       /* register allocation */
       int n_spilled;
       SymReg * p31;
  -    int* interference_graph;
  +    unsigned int* interference_graph;
       SymReg** reglist;
       int n_symbols;
       struct _IMC_Unit * prev;
  
  
  

Reply via email to