anv: Move the physical device dispatch table to anv_instance
[mesa.git] / src / freedreno / ir3 / ir3.c
index a0a2dcbd8051586d8bec8b2461a272fc86e33002..18c2936caa720b9fc733d2a98d8f0f69d3c7b2e0 100644 (file)
@@ -45,18 +45,12 @@ 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, unsigned nin, unsigned nout)
+struct ir3 * ir3_create(struct ir3_compiler *compiler, gl_shader_stage type)
 {
        struct ir3 *shader = rzalloc(NULL, struct ir3);
 
        shader->compiler = compiler;
        shader->type = type;
-       shader->ninputs = nin;
-       shader->inputs = ir3_alloc(shader, sizeof(shader->inputs[0]) * nin);
-
-       shader->noutputs = nout;
-       shader->outputs = ir3_alloc(shader, sizeof(shader->outputs[0]) * nout);
 
        list_inithead(&shader->block_list);
        list_inithead(&shader->array_list);
@@ -154,8 +148,15 @@ static int emit_cat0(struct ir3_instruction *instr, void *ptr,
        cat0->sync     = !!(instr->flags & IR3_INSTR_SY);
        cat0->opc_cat  = 0;
 
-       if (instr->opc == OPC_CONDEND || instr->opc == OPC_ENDPATCH)
+       switch (instr->opc) {
+       case OPC_IF:
+       case OPC_ELSE:
+       case OPC_ENDIF:
                cat0->dummy4 = 16;
+               break;
+       default:
+               break;
+       }
 
        return 0;
 }
@@ -838,11 +839,11 @@ static int emit_cat6(struct ir3_instruction *instr, void *ptr,
        if (instr->cat6.dst_offset || (instr->opc == OPC_STG) ||
                        (instr->opc == OPC_STL) || (instr->opc == OPC_STLW)) {
                instr_cat6c_t *cat6c = ptr;
-               struct ir3_register *src3 = instr->regs[4];
                cat6->dst_off = true;
                cat6c->dst = reg(dst, info, instr->repeat, IR3_REG_R | IR3_REG_HALF);
 
                if (instr->flags & IR3_INSTR_G) {
+                       struct ir3_register *src3 = instr->regs[4];
                        cat6c->off = reg(src3, info, instr->repeat, IR3_REG_R | IR3_REG_HALF);
                        if (src3->flags & IR3_REG_IMMED) {
                                /* Immediate offsets are in bytes... */
@@ -898,8 +899,8 @@ void * ir3_assemble(struct ir3 *shader, struct ir3_info *info,
        info->sizedwords    = 0;
        info->ss = info->sy = 0;
 
-       list_for_each_entry (struct ir3_block, block, &shader->block_list, node) {
-               list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node) {
+       foreach_block (block, &shader->block_list) {
+               foreach_instr (instr, &block->instr_list) {
                        info->sizedwords += 2;
                }
        }
@@ -916,12 +917,19 @@ void * ir3_assemble(struct ir3 *shader, struct ir3_info *info,
 
        ptr = dwords = calloc(4, info->sizedwords);
 
-       list_for_each_entry (struct ir3_block, block, &shader->block_list, node) {
-               list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node) {
+       foreach_block (block, &shader->block_list) {
+               foreach_instr (instr, &block->instr_list) {
                        int ret = emit[opc_cat(instr->opc)](instr, dwords, info);
                        if (ret)
                                goto fail;
+
+                       if ((instr->opc == OPC_BARY_F) && (instr->regs[0]->flags & IR3_REG_EI))
+                               info->last_baryf = info->instrs_count;
+
                        info->instrs_count += 1 + instr->repeat + instr->nop;
+                       info->nops_count += instr->nop;
+                       if (instr->opc == OPC_NOP)
+                               info->nops_count += 1 + instr->repeat;
                        dwords += 2;
 
                        if (instr->flags & IR3_INSTR_SS)
@@ -1081,14 +1089,14 @@ ir3_instr_set_address(struct ir3_instruction *instr,
 void
 ir3_block_clear_mark(struct ir3_block *block)
 {
-       list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node)
+       foreach_instr (instr, &block->instr_list)
                instr->flags &= ~IR3_INSTR_MARK;
 }
 
 void
 ir3_clear_mark(struct ir3 *ir)
 {
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
+       foreach_block (block, &ir->block_list) {
                ir3_block_clear_mark(block);
        }
 }
@@ -1098,10 +1106,10 @@ unsigned
 ir3_count_instructions(struct ir3 *ir)
 {
        unsigned cnt = 0;
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
+       foreach_block (block, &ir->block_list) {
                block->start_ip = cnt;
                block->end_ip = cnt;
-               list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node) {
+               foreach_instr (instr, &block->instr_list) {
                        instr->ip = cnt++;
                        block->end_ip = instr->ip;
                }
@@ -1112,7 +1120,7 @@ ir3_count_instructions(struct ir3 *ir)
 struct ir3_array *
 ir3_lookup_array(struct ir3 *ir, unsigned id)
 {
-       list_for_each_entry (struct ir3_array, arr, &ir->array_list, node)
+       foreach_array (arr, &ir->array_list)
                if (arr->id == id)
                        return arr;
        return NULL;