Ripped out the old register attribute bitset stuff; the tables now refer
authorDavid Given <dg@cowlark.com>
Mon, 6 Feb 2017 22:30:47 +0000 (23:30 +0100)
committerDavid Given <dg@cowlark.com>
Mon, 6 Feb 2017 22:30:47 +0000 (23:30 +0100)
directly to register classes. Register corruption is done by computing the
actual hardware register corruption set inside mcgg.

12 files changed:
mach/powerpc/mcg/platform.c
mach/proto/mcg/hop.h
mach/proto/mcg/ir.h
mach/proto/mcg/mcg.h
mach/proto/mcg/mcgg_generated_footer.h
mach/proto/mcg/pass_instructionselection.c
mach/proto/mcg/reg.h
util/mcgg/iburg.c
util/mcgg/ircodes.h
util/mcgg/mcgg.h
util/mcgg/registers.c
util/mcgg/registers.h

index e1e4d16..641522f 100644 (file)
@@ -6,7 +6,7 @@
  * |  --------------- <- ab
  * |       old FR
  * |       old FP
- * |  --------------- <- fp (a.k.a. lb) 
+ * |  --------------- <- fp (a.k.a. lb)
  * |      locals
  * |  ---------------
  * |      spills
@@ -27,30 +27,30 @@ void platform_calculate_offsets(void)
     int i;
 
     saved_regs.count = 0;
-    for (i=0; i<current_proc->usedregs.count; i++)
-    {
-        struct hreg* hreg = current_proc->usedregs.item[i];
-
-        if (!(hreg->attrs & burm_volatile_ATTR) &&
-            ((hreg->attrs & burm_long_ATTR) || (hreg->attrs & burm_double_ATTR)))
-        {
-            hreg->offset = current_proc->saved_size;
-            current_proc->saved_size += 8;
-            array_append(&saved_regs, hreg);
-        }
-    }
-    for (i=0; i<current_proc->usedregs.count; i++)
-    {
-        struct hreg* hreg = current_proc->usedregs.item[i];
-
-        if (!(hreg->attrs & burm_volatile_ATTR) &&
-            ((hreg->attrs & burm_int_ATTR) || (hreg->attrs & burm_float_ATTR)))
-        {
-            hreg->offset = current_proc->saved_size;
-            current_proc->saved_size += 4;
-            array_append(&saved_regs, hreg);
-        }
-    }
+    // for (i=0; i<current_proc->usedregs.count; i++)
+    // {
+    //     struct hreg* hreg = current_proc->usedregs.item[i];
+
+    //     if (!(hreg->attrs & burm_volatile_ATTR) &&
+    //         ((hreg->attrs & burm_long_ATTR) || (hreg->attrs & burm_double_ATTR)))
+    //     {
+    //         hreg->offset = current_proc->saved_size;
+    //         current_proc->saved_size += 8;
+    //         array_append(&saved_regs, hreg);
+    //     }
+    // }
+    // for (i=0; i<current_proc->usedregs.count; i++)
+    // {
+    //     struct hreg* hreg = current_proc->usedregs.item[i];
+
+    //     if (!(hreg->attrs & burm_volatile_ATTR) &&
+    //         ((hreg->attrs & burm_int_ATTR) || (hreg->attrs & burm_float_ATTR)))
+    //     {
+    //         hreg->offset = current_proc->saved_size;
+    //         current_proc->saved_size += 4;
+    //         array_append(&saved_regs, hreg);
+    //     }
+    // }
 
        current_proc->fp_to_ab = 8;
        current_proc->fp_to_lb = 0;
@@ -65,40 +65,40 @@ struct hop* platform_prologue(void)
         current_proc->locals_size;
        struct hop* hop = new_hop(current_proc->entry, NULL);
 
-    hop_add_insel(hop, "! locals_size = %d", current_proc->locals_size);
-    hop_add_insel(hop, "! spills_size = %d", current_proc->spills_size);
-    hop_add_insel(hop, "! saved_size = %d", current_proc->saved_size);
-    hop_add_insel(hop, "! params @ fp+%d", current_proc->fp_to_ab);
-    hop_add_insel(hop, "! lr @ fp+4");  
-    hop_add_insel(hop, "! fp @ fp+0");  
-    hop_add_insel(hop, "! locals @ fp-%d to fp+0",
-        current_proc->locals_size);
-    hop_add_insel(hop, "! spills @ fp-%d to fp-%d",
-        -current_proc->fp_to_sb, current_proc->locals_size);
-    for (i=saved_regs.count-1; i>=0; i--)
-    {
-        struct hreg* hreg = saved_regs.item[i];
-        hop_add_insel(hop, "! %s @ fp-%d",
-            hreg->id, -(current_proc->fp_to_rb + hreg->offset));
-    }
-
-       hop_add_insel(hop, "addi sp, sp, %d", -(spoffset + 8));
-       hop_add_insel(hop, "mfspr r0, lr");
-       hop_add_insel(hop, "stw fp, %d(sp)", spoffset + 0);
-       hop_add_insel(hop, "stw r0, %d(sp)", spoffset + 4);
-       hop_add_insel(hop, "addi fp, sp, %d", spoffset);
-
-    /* Saved reg offsets are negative. */
-    for (i=0; i<saved_regs.count; i++)
-    {
-        struct hreg* hreg = saved_regs.item[i];
-        if (hreg->attrs & burm_int_ATTR)
-            hop_add_insel(hop, "stw %H, %d(fp)",
-                hreg, current_proc->fp_to_rb + hreg->offset);
-        else if (hreg->attrs & burm_float_ATTR)
-            hop_add_insel(hop, "stfs %H, %d(fp)",
-                hreg, current_proc->fp_to_rb + hreg->offset);
-    }
+    // hop_add_insel(hop, "! locals_size = %d", current_proc->locals_size);
+    // hop_add_insel(hop, "! spills_size = %d", current_proc->spills_size);
+    // hop_add_insel(hop, "! saved_size = %d", current_proc->saved_size);
+    // hop_add_insel(hop, "! params @ fp+%d", current_proc->fp_to_ab);
+    // hop_add_insel(hop, "! lr @ fp+4");
+    // hop_add_insel(hop, "! fp @ fp+0");
+    // hop_add_insel(hop, "! locals @ fp-%d to fp+0",
+    //     current_proc->locals_size);
+    // hop_add_insel(hop, "! spills @ fp-%d to fp-%d",
+    //     -current_proc->fp_to_sb, current_proc->locals_size);
+    // for (i=saved_regs.count-1; i>=0; i--)
+    // {
+    //     struct hreg* hreg = saved_regs.item[i];
+    //     hop_add_insel(hop, "! %s @ fp-%d",
+    //         hreg->id, -(current_proc->fp_to_rb + hreg->offset));
+    // }
+
+       // hop_add_insel(hop, "addi sp, sp, %d", -(spoffset + 8));
+       // hop_add_insel(hop, "mfspr r0, lr");
+       // hop_add_insel(hop, "stw fp, %d(sp)", spoffset + 0);
+       // hop_add_insel(hop, "stw r0, %d(sp)", spoffset + 4);
+       // hop_add_insel(hop, "addi fp, sp, %d", spoffset);
+
+    // /* Saved reg offsets are negative. */
+    // for (i=0; i<saved_regs.count; i++)
+    // {
+    //     struct hreg* hreg = saved_regs.item[i];
+    //     if (hreg->attrs & burm_int_ATTR)
+    //         hop_add_insel(hop, "stw %H, %d(fp)",
+    //             hreg, current_proc->fp_to_rb + hreg->offset);
+    //     else if (hreg->attrs & burm_float_ATTR)
+    //         hop_add_insel(hop, "stfs %H, %d(fp)",
+    //             hreg, current_proc->fp_to_rb + hreg->offset);
+    // }
        return hop;
 }
 
@@ -107,16 +107,16 @@ struct hop* platform_epilogue(void)
        struct hop* hop = new_hop(current_proc->exit, NULL);
     int i;
 
-    for (i=0; i<saved_regs.count; i++)
-    {
-        struct hreg* hreg = saved_regs.item[i];
-        if (hreg->attrs & burm_int_ATTR)
-            hop_add_insel(hop, "lwz %H, %d(fp)",
-                hreg, current_proc->fp_to_rb + hreg->offset);
-        else if (hreg->attrs & burm_float_ATTR)
-            hop_add_insel(hop, "lfs %H, %d(fp)",
-                hreg, current_proc->fp_to_rb + hreg->offset);
-    }
+    // for (i=0; i<saved_regs.count; i++)
+    // {
+    //     struct hreg* hreg = saved_regs.item[i];
+    //     if (hreg->attrs & burm_int_ATTR)
+    //         hop_add_insel(hop, "lwz %H, %d(fp)",
+    //             hreg, current_proc->fp_to_rb + hreg->offset);
+    //     else if (hreg->attrs & burm_float_ATTR)
+    //         hop_add_insel(hop, "lfs %H, %d(fp)",
+    //             hreg, current_proc->fp_to_rb + hreg->offset);
+    // }
 
     hop_add_insel(hop, "lwz r0, 4(fp)");
     hop_add_insel(hop, "mtspr lr, r0");
@@ -132,147 +132,147 @@ struct hop* platform_move(struct basicblock* bb, struct hreg* src, struct hreg*
 {
     struct hop* hop = new_hop(bb, NULL);
 
-    if ((src->attrs & TYPE_ATTRS) != (dest->attrs & TYPE_ATTRS))
-    {
-        assert(!src->is_stacked);
-        assert(!dest->is_stacked);
-
-        switch (src->attrs & TYPE_ATTRS)
-        {
-            case burm_int_ATTR:
-                hop_add_insel(hop, "stwu %H, -4(sp)", src);
-                break;
-
-            case burm_long_ATTR:
-                hop_add_insel(hop, "stwu %0H, -4(sp)", src);
-                hop_add_insel(hop, "stwu %1H, -4(sp)", src);
-                break;
-
-            case burm_float_ATTR:
-                hop_add_insel(hop, "stfsu %H, -4(sp)", src);
-                break;
-
-            case burm_double_ATTR:
-                hop_add_insel(hop, "stfdu %H, -8(sp)", src);
-                break;
-
-            default:
-                goto nomove;
-        }
-
-        switch (dest->attrs & TYPE_ATTRS)
-        {
-            case burm_int_ATTR:
-                hop_add_insel(hop, "lwz %H, 0(sp)", dest);
-                break;
-
-            case burm_long_ATTR:
-                hop_add_insel(hop, "lwz %0H, 4(sp)", dest);
-                hop_add_insel(hop, "lwz %1H, 0(sp)", dest);
-                break;
-
-            case burm_float_ATTR:
-                hop_add_insel(hop, "lfs %H, 0(sp)", dest);
-                break;
-
-            case burm_double_ATTR:
-                hop_add_insel(hop, "lfd %H, 0(sp)", dest);
-                break;
-
-            default:
-                goto nomove;
-        }
-
-        switch (dest->attrs & TYPE_ATTRS)
-        {
-            case burm_int_ATTR:
-            case burm_float_ATTR:
-                hop_add_insel(hop, "addi sp, sp, 4");
-                break;
-
-            case burm_double_ATTR:
-            case burm_long_ATTR:
-                hop_add_insel(hop, "addi sp, sp, 8");
-                break;
-
-            default:
-                goto nomove;
-        }
-    }
-    else
-    {
-        uint32_t type = src->attrs & TYPE_ATTRS;
-
-        if (!src->is_stacked && dest->is_stacked)
-        {
-            switch (type)
-            {
-                case burm_int_ATTR:
-                    hop_add_insel(hop, "stw %H, %S(fp) ! %H", src, dest, dest);
-                    break;
-
-                case burm_float_ATTR:
-                    hop_add_insel(hop, "stfs %H, %S(fp) ! %H", src, dest, dest);
-                    break;
-
-                case burm_long_ATTR:
-                    hop_add_insel(hop, "stw %0H, 4+%S(fp) ! %H", src, dest, dest);
-                    hop_add_insel(hop, "stw %1H, 0+%S(fp) ! %H", src, dest, dest);
-                    break;
-
-                case burm_double_ATTR:
-                    hop_add_insel(hop, "stfd %H, %S(fp) ! %H", src, dest, dest);
-                    break;
-
-                default:
-                    goto nomove;
-            }
-        }
-        else if (src->is_stacked && !dest->is_stacked)
-        {
-            switch (type)
-            {
-                case burm_int_ATTR:
-                    hop_add_insel(hop, "lwz %H, %S(fp) ! %H", dest, src, src);
-                    break;
-
-                case burm_float_ATTR:
-                    hop_add_insel(hop, "lfs %H, %S(fp) ! %H", dest, src, src);
-                    break;
-
-                case burm_double_ATTR:
-                    hop_add_insel(hop, "lfd %H, %S(fp) ! %H", dest, src, src);
-                    break;
-
-                default:
-                    goto nomove;
-            }
-        }
-        else if (!src->is_stacked && !dest->is_stacked)
-        {
-            switch (type)
-            {
-                case burm_int_ATTR:
-                    hop_add_insel(hop, "mr %H, %H", dest, src);
-                    break;
-
-                case burm_long_ATTR:
-                    hop_add_insel(hop, "mr %0H, %0H", dest, src);
-                    hop_add_insel(hop, "mr %1H, %1H", dest, src);
-                    break;
-
-                case burm_float_ATTR:
-                case burm_double_ATTR:
-                    hop_add_insel(hop, "fmr %H, %H", dest, src);
-                    break;
-
-                default:
-                    goto nomove;
-            }
-        }
-        else
-            goto nomove;
-    }
+    // if ((src->attrs & TYPE_ATTRS) != (dest->attrs & TYPE_ATTRS))
+    // {
+    //     assert(!src->is_stacked);
+    //     assert(!dest->is_stacked);
+
+    //     switch (src->attrs & TYPE_ATTRS)
+    //     {
+    //         case burm_int_ATTR:
+    //             hop_add_insel(hop, "stwu %H, -4(sp)", src);
+    //             break;
+
+    //         case burm_long_ATTR:
+    //             hop_add_insel(hop, "stwu %0H, -4(sp)", src);
+    //             hop_add_insel(hop, "stwu %1H, -4(sp)", src);
+    //             break;
+
+    //         case burm_float_ATTR:
+    //             hop_add_insel(hop, "stfsu %H, -4(sp)", src);
+    //             break;
+
+    //         case burm_double_ATTR:
+    //             hop_add_insel(hop, "stfdu %H, -8(sp)", src);
+    //             break;
+
+    //         default:
+    //             goto nomove;
+    //     }
+
+    //     switch (dest->attrs & TYPE_ATTRS)
+    //     {
+    //         case burm_int_ATTR:
+    //             hop_add_insel(hop, "lwz %H, 0(sp)", dest);
+    //             break;
+
+    //         case burm_long_ATTR:
+    //             hop_add_insel(hop, "lwz %0H, 4(sp)", dest);
+    //             hop_add_insel(hop, "lwz %1H, 0(sp)", dest);
+    //             break;
+
+    //         case burm_float_ATTR:
+    //             hop_add_insel(hop, "lfs %H, 0(sp)", dest);
+    //             break;
+
+    //         case burm_double_ATTR:
+    //             hop_add_insel(hop, "lfd %H, 0(sp)", dest);
+    //             break;
+
+    //         default:
+    //             goto nomove;
+    //     }
+
+    //     switch (dest->attrs & TYPE_ATTRS)
+    //     {
+    //         case burm_int_ATTR:
+    //         case burm_float_ATTR:
+    //             hop_add_insel(hop, "addi sp, sp, 4");
+    //             break;
+
+    //         case burm_double_ATTR:
+    //         case burm_long_ATTR:
+    //             hop_add_insel(hop, "addi sp, sp, 8");
+    //             break;
+
+    //         default:
+    //             goto nomove;
+    //     }
+    // }
+    // else
+    // {
+    //     uint32_t type = src->attrs & TYPE_ATTRS;
+
+    //     if (!src->is_stacked && dest->is_stacked)
+    //     {
+    //         switch (type)
+    //         {
+    //             case burm_int_ATTR:
+    //                 hop_add_insel(hop, "stw %H, %S(fp) ! %H", src, dest, dest);
+    //                 break;
+
+    //             case burm_float_ATTR:
+    //                 hop_add_insel(hop, "stfs %H, %S(fp) ! %H", src, dest, dest);
+    //                 break;
+
+    //             case burm_long_ATTR:
+    //                 hop_add_insel(hop, "stw %0H, 4+%S(fp) ! %H", src, dest, dest);
+    //                 hop_add_insel(hop, "stw %1H, 0+%S(fp) ! %H", src, dest, dest);
+    //                 break;
+
+    //             case burm_double_ATTR:
+    //                 hop_add_insel(hop, "stfd %H, %S(fp) ! %H", src, dest, dest);
+    //                 break;
+
+    //             default:
+    //                 goto nomove;
+    //         }
+    //     }
+    //     else if (src->is_stacked && !dest->is_stacked)
+    //     {
+    //         switch (type)
+    //         {
+    //             case burm_int_ATTR:
+    //                 hop_add_insel(hop, "lwz %H, %S(fp) ! %H", dest, src, src);
+    //                 break;
+
+    //             case burm_float_ATTR:
+    //                 hop_add_insel(hop, "lfs %H, %S(fp) ! %H", dest, src, src);
+    //                 break;
+
+    //             case burm_double_ATTR:
+    //                 hop_add_insel(hop, "lfd %H, %S(fp) ! %H", dest, src, src);
+    //                 break;
+
+    //             default:
+    //                 goto nomove;
+    //         }
+    //     }
+    //     else if (!src->is_stacked && !dest->is_stacked)
+    //     {
+    //         switch (type)
+    //         {
+    //             case burm_int_ATTR:
+    //                 hop_add_insel(hop, "mr %H, %H", dest, src);
+    //                 break;
+
+    //             case burm_long_ATTR:
+    //                 hop_add_insel(hop, "mr %0H, %0H", dest, src);
+    //                 hop_add_insel(hop, "mr %1H, %1H", dest, src);
+    //                 break;
+
+    //             case burm_float_ATTR:
+    //             case burm_double_ATTR:
+    //                 hop_add_insel(hop, "fmr %H, %H", dest, src);
+    //                 break;
+
+    //             default:
+    //                 goto nomove;
+    //         }
+    //     }
+    //     else
+    //         goto nomove;
+    // }
 
     return hop;
 
@@ -285,35 +285,35 @@ struct hop* platform_swap(struct basicblock* bb, struct hreg* src, struct hreg*
 {
     struct hop* hop = new_hop(bb, NULL);
 
-    assert(!src->is_stacked);
-    assert(!dest->is_stacked);
-    assert((src->attrs & TYPE_ATTRS) == (dest->attrs & TYPE_ATTRS));
-    
-    switch (src->attrs & TYPE_ATTRS)
-    {
-        case burm_int_ATTR:
-            hop_add_insel(hop, "mr r0, %H", src);
-            hop_add_insel(hop, "mr %H, %H", src, dest);
-            hop_add_insel(hop, "mr %H, r0", dest);
-            break;
-
-        case burm_long_ATTR:
-            hop_add_insel(hop, "mr r0, %0H", src);
-            hop_add_insel(hop, "mr %0H, %0H", src, dest);
-            hop_add_insel(hop, "mr %0H, r0", dest);
-
-            hop_add_insel(hop, "mr r0, %1H", src);
-            hop_add_insel(hop, "mr %1H, %1H", src, dest);
-            hop_add_insel(hop, "mr %1H, r0", dest);
-            break;
-
-        case burm_float_ATTR:
-        case burm_double_ATTR:
-            hop_add_insel(hop, "fmr f0, %H", src);
-            hop_add_insel(hop, "fmr %H, %H", src, dest);
-            hop_add_insel(hop, "fmr %H, f0", dest);
-            break;
-    }
+    // assert(!src->is_stacked);
+    // assert(!dest->is_stacked);
+    // assert((src->attrs & TYPE_ATTRS) == (dest->attrs & TYPE_ATTRS));
+
+    // switch (src->attrs & TYPE_ATTRS)
+    // {
+    //     case burm_int_ATTR:
+    //         hop_add_insel(hop, "mr r0, %H", src);
+    //         hop_add_insel(hop, "mr %H, %H", src, dest);
+    //         hop_add_insel(hop, "mr %H, r0", dest);
+    //         break;
+
+    //     case burm_long_ATTR:
+    //         hop_add_insel(hop, "mr r0, %0H", src);
+    //         hop_add_insel(hop, "mr %0H, %0H", src, dest);
+    //         hop_add_insel(hop, "mr %0H, r0", dest);
+
+    //         hop_add_insel(hop, "mr r0, %1H", src);
+    //         hop_add_insel(hop, "mr %1H, %1H", src, dest);
+    //         hop_add_insel(hop, "mr %1H, r0", dest);
+    //         break;
+
+    //     case burm_float_ATTR:
+    //     case burm_double_ATTR:
+    //         hop_add_insel(hop, "fmr f0, %H", src);
+    //         hop_add_insel(hop, "fmr %H, %H", src, dest);
+    //         hop_add_insel(hop, "fmr %H, f0", dest);
+    //         break;
+    // }
 
     return hop;
 }
index 15ca8f4..1d8e0b2 100644 (file)
@@ -30,6 +30,7 @@ struct insel
 
 struct valueusage
 {
+       struct burm_regclass_data* regclass;
        bool input : 1;
        bool output : 1;
        bool through : 1;
@@ -46,6 +47,7 @@ struct hop
        struct value* value;
        bool is_move;
        PMAPOF(struct value, struct value) equals_constraint;
+       burm_register_bitmap_t corrupts;
 
        struct hashtable* valueusage;
        PMAPOF(struct vreg, struct vreg) vregusage;
index e533c0c..0da01a0 100644 (file)
@@ -7,7 +7,7 @@ struct value
 {
        struct ir* ir;
        int subid;
-       uint32_t attrs;
+       int regclass;
 };
 
 extern uint32_t value_hash_function(void* key);
index 26ba4e6..2863177 100644 (file)
 #include "diagnostics.h"
 #include "astring.h"
 #include "ir.h"
+#include "tables.h"
+#include "mcgg.h"
 #include "reg.h"
 #include "hop.h"
 #include "basicblock.h"
 #include "procedure.h"
 #include "graph.h"
-#include "tables.h"
-#include "mcgg.h"
 #include "set.h"
 #include "bigraph.h"
 
index 6de0c52..4724a35 100644 (file)
@@ -19,37 +19,4 @@ static void dumpCover(NODEPTR_TYPE p, int goalnt, int indent) {
 #endif
 }
 
-#if 0
-static NODEPTR_TYPE tree(int op, NODEPTR_TYPE l, NODEPTR_TYPE r) {
-       NODEPTR_TYPE p = malloc(sizeof *p);
-
-       assert(p);
-       p->op = op;
-       p->kids[0] = l; p->kids[1] = r;
-       return p;
-}
-
-int main(void) {
-       NODEPTR_TYPE p;
-
-       p = tree(STORE4,
-                       tree(ADD4,
-                               tree(LABEL4, 0, 0),
-                               tree(CONST4, 0, 0)
-                       ),
-                       tree(ADD4,
-                               tree(LOAD4,
-                                       tree(LABEL4, 0, 0),
-                                       0
-                               ),
-                               tree(CONST4, 0, 0)
-                       )
-               );
-       burm_label(p);
-       dumpCover(p, 1, 0);
-       return 0;
-}
-#endif
-
 /* vim: set sw=4 ts=4 expandtab : */
-
index 9bb7758..2631c1d 100644 (file)
@@ -80,13 +80,13 @@ static void emit_eoi(void)
        hop_add_eoi_insel(current_hop);
 }
 
-static void constrain_input_reg(int child, uint32_t attr)
+static void constrain_input_reg(int child, int regclass)
 {
     struct value* value = find_value_of_child(child);
     struct constraint* c;
 
     hop_get_value_usage(current_hop, value)->input = true;
-    value->attrs = attr;
+    value->regclass = regclass;
 }
 
 static void constrain_input_reg_corrupted(int child)
@@ -97,40 +97,12 @@ static void constrain_input_reg_corrupted(int child)
     hop_get_value_usage(current_hop, value)->corrupted = true;
 }
 
-static uint32_t find_type_from_constraint(uint32_t attr)
-{
-    /* Looks through the registers and finds a concrete register implementing
-     * that attribute, and returns the type. We assume that all registers
-     * implementing an attribute (which anyone is going to ask for, 'volatile'
-     * doesn't count) will have the same type. TODO: mcgg should check for
-     * this. */
-
-    const struct burm_register_data* brd = burm_register_data;
-    while (brd->id)
-    {
-        if (brd->attrs & attr)
-        {
-            const uint32_t type_attrs =
-                (burm_int_ATTR | burm_float_ATTR |
-                 burm_long_ATTR | burm_double_ATTR);
-
-            if (brd->attrs & type_attrs)
-                return brd->attrs & type_attrs;
-            return attr;
-        }
-        brd++;
-    }
-
-    fatal("unable to find a register matching attribute 0x%x", attr);
-    return 0;
-}
-
-static void constrain_output_reg(uint32_t attr)
+static void constrain_output_reg(int regclass)
 {
     struct value* value = &current_insn->value;
 
     hop_get_value_usage(current_hop, value)->output = true;
-    value->attrs = find_type_from_constraint(attr);
+    value->regclass = regclass;
 }
 
 static void constrain_output_reg_equal_to(int child)
index 1e04c62..ef39cc5 100644 (file)
@@ -22,6 +22,8 @@ struct vreg
     int neighbours;
     bool needs_register;
     bool is_spilt;
+    struct burm_regclass_data* regclass;
+    burm_register_bitmap_t registers;
 };
 
 extern struct hreg* new_hreg(const struct burm_register_data* brd);
index 4bbb4c3..17cb56d 100644 (file)
@@ -14,6 +14,7 @@
 #include "ircodes.h"
 #include "astring.h"
 #include "registers.h"
+#include "bitmap.h"
 
 static char rcsid[] = "$Id$";
 
@@ -1003,8 +1004,8 @@ static void emit_input_regs(Tree node, int* index)
                if (node->attr)
                {
                        uint32_t attr = 1<<node->attr->number;
-                       print("%1data->constrain_input_reg(%d, 0x%x /* %s */);\n",
-                               *index, attr, node->attr->name);
+                       print("%1data->constrain_input_reg(%d, %P%s_RC);\n",
+                               *index, node->attr->name);
                }
        }
 
@@ -1095,8 +1096,7 @@ static void emitinsndata(Rule rules)
                print("static void %Pemitter_%d(const struct %Pemitter_data* data) {\n", r->ern);
 
                if (r->attr)
-                       print("%1data->constrain_output_reg(0x%x /* %s */);\n",
-                               1<<r->attr->number, r->attr->name);
+                       print("%1data->constrain_output_reg(%P%s_RC);\n", r->attr->name);
 
                {
                        int index = 0;
@@ -1185,11 +1185,11 @@ static void emitinsndata(Rule rules)
 
                print("%2&%Pemitter_%d,\n", r->ern);
 
-               print("%2%s,\n", r->lhs->is_fragment ? "true" : "false");
+               print("%2%s /* is_fragment */,\n", r->lhs->is_fragment ? "true" : "false");
 
                {
                        int i;
-                       uint32_t attrs = 0;
+                       unsigned int* bitmap = bitmap_alloc(real_register_count);
 
                        for (i=0; i<r->constraints.count; i++)
                        {
@@ -1201,11 +1201,14 @@ static void emitinsndata(Rule rules)
                                        if (!p)
                                                yyerror("no such register attribute '%s'", c->left);
 
-                                       attrs |= 1<<(p->number);
+                                       bitmap_or(bitmap, real_register_count, p->bitmap);
                                }
                        }
 
-                       print("%2%d, /* corruption attrs */\n", attrs);
+                       print("%2{ ");
+                       for (i=0; i<WORDS_FOR_BITMAP_SIZE(real_register_count); i++)
+                               print("0x%x, ", bitmap[i]);
+                       print("} /* corrupted registers */,\n");
                }
 
                print("%1},\n");
index d9c0512..7d91b27 100644 (file)
@@ -17,9 +17,6 @@ struct ir_data
 
 extern const struct ir_data ir_data[];
 
-#define TYPE_ATTRS \
-    (burm_int_ATTR | burm_long_ATTR | burm_float_ATTR | burm_double_ATTR)
-
 #include "ircodes-dyn.h"
 
 #endif
index 6aa304f..8119ebe 100644 (file)
@@ -35,9 +35,9 @@ struct burm_emitter_data
     void (*emit_reg)(int child, int index);
     void (*emit_value)(int child);
     void (*emit_eoi)(void);
-    void (*constrain_input_reg)(int child, uint32_t attr);
+    void (*constrain_input_reg)(int child, int regclass);
     void (*constrain_input_reg_corrupted)(int child);
-    void (*constrain_output_reg)(uint32_t attr);
+    void (*constrain_output_reg)(int regclass);
     void (*constrain_output_reg_equal_to)(int child);
 };
 
@@ -48,7 +48,7 @@ struct burm_instruction_data
     const char* name;
     burm_emitter_t* emitter;
     bool is_fragment;
-    uint32_t corrupts;
+    burm_register_bitmap_t corrupts;
 };
 
 extern const struct burm_instruction_data burm_instruction_data[];
index c26cbd3..bad089f 100644 (file)
@@ -15,7 +15,7 @@ static struct hashtable registers = HASHTABLE_OF_STRINGS;
 static struct hashtable registerattrs = HASHTABLE_OF_STRINGS;
 
 static struct reg** real_registers;
-static int real_register_count;
+int real_register_count;
 
 static struct reg** fake_registers;
 static int fake_register_count;
@@ -225,30 +225,37 @@ void emitregisterattrs(void)
                {
                        struct reg* r = regs[j];
                        if (set_get(&r->classes, rc))
-                               print("&%Pregister_data[%d], ", r->number);
+                               print("%1&%Pregister_data[%d],\n", r->number);
                }
 
-               print("NULL };\n");
+               print("%1NULL\n");
+               print("};\n");
        }
 
        print("\nconst struct %Pregclass_data %Pregclass_data[] = {\n");
+       printh("enum {\n");
        for (i=0; i<registerattrs.size; i++)
        {
                struct regattr* rc = regattrs[i];
                assert(rc->number == i);
 
-               print("%1{ \"%s\", %Pregisters_in_class_%s, { ", rc->name, rc->name);
+               print("%1{\n");
+               print("%2\"%s\",\n", rc->name);
+               print("%2%Pregisters_in_class_%s,\n", rc->name);
+               print("%2{ ");
                for (j=0; j<WORDS_FOR_BITMAP_SIZE(real_register_count); j++)
                {
                        print("0x%x, ", rc->bitmap[j]);
                }
-               print("}, ");
-               print("%d,", rc->weight);
                print("},\n");
-               printh("#define %P%s_ATTR (1U<<%d)\n", rc->name, rc->number);
+               print("%2%d /* weight */,\n", rc->weight);
+               print("%1},\n");
+
+               printh("\t%P%s_RC = %d,\n", rc->name, rc->number);
        }
        print("};\n\n");
-       printh("\n");
+       printh("\t%Pmax_rc\n");
+       printh("};\n\n");
 }
 
 void emitregisters(void)
@@ -291,14 +298,17 @@ void emitregisters(void)
                struct reg* r = regs[i];
 
                assert(r->number == i);
-               print("%1{ \"%s\", 0x%x, %Pregister_names_%s, ",
-                       r->name, r->attrs, r->name, r->name);
-               print("{ ");
+               print("%1{\n");
+               print("%2\"%s\" /* name */,\n", r->name);
+               print("%20x%x /* classes */,\n", r->attrs);
+               print("%2%Pregister_names_%s,\n", r->name);
+               print("%2{ ");
                for (j=0; j<WORDS_FOR_BITMAP_SIZE(real_register_count); j++)
                {
                        print("0x%x, ", r->bitmap[j]);
                }
-               print("}},\n");
+               print("},\n");
+               print("%1},\n");
        }
        print("};\n\n");
 }
index 6b0bc43..53145f1 100644 (file)
@@ -24,6 +24,8 @@ struct regattr
        int weight;            /* maximum weight of all registers in this class */
 };
 
+extern int real_register_count;
+
 extern struct reg* makereg(const char* name);
 extern void setregnames(struct reg* reg, struct stringlist* names);
 extern void addregattr(struct reg* reg, const char* regattr);