freedreno: deduplicate a3xx+ disasm
[mesa.git] / src / freedreno / ir3 / ir3.c
index fd2b8eab9cce07610a7c3249527b11777876589a..b170093ce4304c682a3ecb375b6a59bdcab20702 100644 (file)
@@ -35,7 +35,7 @@
 #include "util/u_math.h"
 
 #include "instr-a3xx.h"
-#include "ir3_compiler.h"
+#include "ir3_shader.h"
 
 /* simple allocator to carve allocations out of an up-front allocated heap,
  * so that we can free everything easily in one shot.
@@ -45,12 +45,13 @@ void * ir3_alloc(struct ir3 *shader, int sz)
        return rzalloc_size(shader, sz); /* TODO: don't use rzalloc */
 }
 
-struct ir3 * ir3_create(struct ir3_compiler *compiler, gl_shader_stage type)
+struct ir3 * ir3_create(struct ir3_compiler *compiler,
+               struct ir3_shader_variant *v)
 {
-       struct ir3 *shader = rzalloc(NULL, struct ir3);
+       struct ir3 *shader = rzalloc(v, struct ir3);
 
        shader->compiler = compiler;
-       shader->type = type;
+       shader->type = v->type;
 
        list_inithead(&shader->block_list);
        list_inithead(&shader->array_list);
@@ -487,7 +488,6 @@ static int emit_cat5(struct ir3_instruction *instr, void *ptr,
 
        if (instr->flags & IR3_INSTR_S2EN) {
                struct ir3_register *samp_tex = instr->regs[1];
-               iassert(samp_tex->flags & IR3_REG_HALF);
                cat5->s2en_bindless.src3 = reg(samp_tex, info, instr->repeat,
                                                                           (instr->flags & IR3_INSTR_B) ? 0 : IR3_REG_HALF);
                if (instr->flags & IR3_INSTR_B) {
@@ -881,6 +881,7 @@ static int emit_cat6(struct ir3_instruction *instr, void *ptr,
                        }
                } else {
                        cat6c->off = instr->cat6.dst_offset;
+                       cat6c->off_high = instr->cat6.dst_offset >> 8;
                }
        } else {
                instr_cat6d_t *cat6d = ptr;
@@ -943,7 +944,7 @@ void * ir3_assemble(struct ir3_shader_variant *v)
                info->sizedwords = align(info->sizedwords, 4 * 2);
        }
 
-       ptr = dwords = calloc(4, info->sizedwords);
+       ptr = dwords = rzalloc_size(v, 4 * info->sizedwords);
 
        foreach_block (block, &shader->block_list) {
                unsigned sfu_delay = 0;