Mesa (nv50-compiler): nv50: minor compiler fixes and cleanups

Christoph Bumiller chrisbmr at kemper.freedesktop.org
Sat Sep 11 16:01:43 PDT 2010


Module: Mesa
Branch: nv50-compiler
Commit: fc31a25afa2d28dea9bbda08ce8deab5aa96b684
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=fc31a25afa2d28dea9bbda08ce8deab5aa96b684

Author: Christoph Bumiller <e0425955 at student.tuwien.ac.at>
Date:   Sun Sep 12 00:56:16 2010 +0200

nv50: minor compiler fixes and cleanups

---

 src/gallium/drivers/nv50/nv50_pc.c           |    4 +++-
 src/gallium/drivers/nv50/nv50_pc_regalloc.c  |    5 +++++
 src/gallium/drivers/nv50/nv50_shader_state.c |    2 +-
 src/gallium/drivers/nv50/nv50_tgsi_to_nc.c   |   16 ++++++++++------
 4 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/nv50/nv50_pc.c b/src/gallium/drivers/nv50/nv50_pc.c
index e063888..26ad9b4 100644
--- a/src/gallium/drivers/nv50/nv50_pc.c
+++ b/src/gallium/drivers/nv50/nv50_pc.c
@@ -237,6 +237,7 @@ nv_pc_free_refs(struct nv_pc *pc)
    int i;
    for (i = 0; i < pc->num_refs; i += 64)
       FREE(pc->refs[i]);
+   FREE(pc->refs);
 }
 
 static const char *
@@ -525,7 +526,8 @@ out:
 
    for (i = 0; i < pc->num_blocks; ++i)
       FREE(pc->bb_list[i]);
-
+   if (pc->root)
+      FREE(pc->root);
    if (ret) { /* on success, these will be referenced by nv50_program */
       if (pc->emit)
          FREE(pc->emit);
diff --git a/src/gallium/drivers/nv50/nv50_pc_regalloc.c b/src/gallium/drivers/nv50/nv50_pc_regalloc.c
index 2998343..b9d5ba5 100644
--- a/src/gallium/drivers/nv50/nv50_pc_regalloc.c
+++ b/src/gallium/drivers/nv50/nv50_pc_regalloc.c
@@ -888,6 +888,10 @@ nv_pc_pass1(struct nv_pc *pc, struct nv_basic_block *root)
    ctx->pc = pc;
 
    ctx->insns = CALLOC(NV_PC_MAX_INSTRUCTIONS, sizeof(struct nv_instruction *));
+   if (!ctx->insns) {
+      FREE(ctx);
+      return -1;
+   }
 
    pc->pass_seq++;
    ret = pass_generate_phi_movs(ctx, root);
@@ -941,6 +945,7 @@ nv_pc_pass1(struct nv_pc *pc, struct nv_basic_block *root)
    NV50_DBGMSG("REGISTER ALLOCATION - leaving\n");
 
 out:
+   FREE(ctx->insns);
    FREE(ctx);
    return ret;
 }
diff --git a/src/gallium/drivers/nv50/nv50_shader_state.c b/src/gallium/drivers/nv50/nv50_shader_state.c
index f187a07..564f7e5 100644
--- a/src/gallium/drivers/nv50/nv50_shader_state.c
+++ b/src/gallium/drivers/nv50/nv50_shader_state.c
@@ -44,7 +44,7 @@ nv50_transfer_constbuf(struct nv50_context *nv50,
    if (!map)
       return;
 
-   count = buf->width0; /* MIN2(buf->width0, size); */
+   count = (buf->width0 + 3) / 4;
    start = 0;
 
    while (count) {
diff --git a/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c b/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c
index 6fd749b..5994d1c 100644
--- a/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c
+++ b/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c
@@ -39,7 +39,7 @@
 #define BLD_MAX_PREDS 4
 #define BLD_MAX_IMMDS 128
 
-#define BLD_MAX_COND_NESTING 4
+#define BLD_MAX_COND_NESTING 8
 #define BLD_MAX_LOOP_NESTING 4
 #define BLD_MAX_CALL_NESTING 2
 
@@ -70,14 +70,14 @@ bld_vals_del_val(struct bld_value_stack *stk, struct nv_value *val)
 {
    unsigned i;
 
-   for (i = stk->size - 1; i >= 0; --i)
-      if (stk->body[i] == val)
+   for (i = stk->size; i > 0; --i)
+      if (stk->body[i - 1] == val)
          break;
-   if (i < 0)
+   if (!i)
       return FALSE;
 
-   if (i != stk->size - 1)
-      stk->body[i] = stk->body[stk->size - 1];
+   if (i != stk->size)
+      stk->body[i - 1] = stk->body[stk->size - 1];
 
    --stk->size; /* XXX: old size in REALLOC */
    return TRUE;
@@ -1643,6 +1643,8 @@ bld_instruction(struct bld_context *bld,
    {
       struct nv_basic_block *b = new_basic_block(bld->pc);
 
+      assert(bld->cond_lvl < BLD_MAX_COND_NESTING);
+
       nvbb_attach_block(bld->pc->current_block, b, CFG_EDGE_FORWARD);
 
       bld->join_bb[bld->cond_lvl] = bld->pc->current_block;
@@ -1695,6 +1697,8 @@ bld_instruction(struct bld_context *bld,
       struct nv_basic_block *bl = new_basic_block(bld->pc);
       struct nv_basic_block *bb = new_basic_block(bld->pc);
 
+      assert(bld->loop_lvl < BLD_MAX_LOOP_NESTING);
+
       bld->loop_bb[bld->loop_lvl] = bl;
       bld->brkt_bb[bld->loop_lvl] = bb;
 



More information about the mesa-commit mailing list