Path: blob/21.2-virgl/src/panfrost/bifrost/bi_print.c
4564 views
/*1* Copyright (C) 2019 Connor Abbott <[email protected]>2* Copyright (C) 2019 Lyude Paul <[email protected]>3* Copyright (C) 2019 Ryan Houdek <[email protected]>4* Copyright (C) 2019-2020 Collabora, Ltd.5*6* Permission is hereby granted, free of charge, to any person obtaining a7* copy of this software and associated documentation files (the "Software"),8* to deal in the Software without restriction, including without limitation9* the rights to use, copy, modify, merge, publish, distribute, sublicense,10* and/or sell copies of the Software, and to permit persons to whom the11* Software is furnished to do so, subject to the following conditions:12*13* The above copyright notice and this permission notice (including the next14* paragraph) shall be included in all copies or substantial portions of the15* Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR18* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,19* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL20* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER21* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,22* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE23* SOFTWARE.24*/2526#include "compiler.h"27#include "bi_print_common.h"2829static const char *30bi_reg_op_name(enum bifrost_reg_op op)31{32switch (op) {33case BIFROST_OP_IDLE: return "idle";34case BIFROST_OP_READ: return "read";35case BIFROST_OP_WRITE: return "write";36case BIFROST_OP_WRITE_LO: return "write lo";37case BIFROST_OP_WRITE_HI: return "write hi";38default: return "invalid";39}40}4142void43bi_print_slots(bi_registers *regs, FILE *fp)44{45for (unsigned i = 0; i < 2; ++i) {46if (regs->enabled[i])47fprintf(fp, "slot %u: %u\n", i, regs->slot[i]);48}4950if (regs->slot23.slot2) {51fprintf(fp, "slot 2 (%s%s): %u\n",52bi_reg_op_name(regs->slot23.slot2),53regs->slot23.slot2 >= BIFROST_OP_WRITE ?54" FMA": "",55regs->slot[2]);56}5758if (regs->slot23.slot3) {59fprintf(fp, "slot 3 (%s %s): %u\n",60bi_reg_op_name(regs->slot23.slot3),61regs->slot23.slot3_fma ? "FMA" : "ADD",62regs->slot[3]);63}64}6566void67bi_print_tuple(bi_tuple *tuple, FILE *fp)68{69bi_instr *ins[2] = { tuple->fma, tuple->add };7071for (unsigned i = 0; i < 2; ++i) {72fprintf(fp, (i == 0) ? "\t* " : "\t+ ");7374if (ins[i])75bi_print_instr(ins[i], fp);76else77fprintf(fp, "NOP\n");78}79}8081void82bi_print_clause(bi_clause *clause, FILE *fp)83{84fprintf(fp, "id(%u)", clause->scoreboard_id);8586if (clause->dependencies) {87fprintf(fp, " wait(");8889for (unsigned i = 0; i < 8; ++i) {90if (clause->dependencies & (1 << i))91fprintf(fp, "%u ", i);92}9394fprintf(fp, ")");95}9697fprintf(fp, " %s", bi_flow_control_name(clause->flow_control));9899if (!clause->next_clause_prefetch)100fprintf(fp, " no_prefetch");101102if (clause->staging_barrier)103fprintf(fp, " osrb");104105if (clause->td)106fprintf(fp, " td");107108if (clause->pcrel_idx != ~0)109fprintf(fp, " pcrel(%u)", clause->pcrel_idx);110111fprintf(fp, "\n");112113for (unsigned i = 0; i < clause->tuple_count; ++i)114bi_print_tuple(&clause->tuples[i], fp);115116if (clause->constant_count) {117for (unsigned i = 0; i < clause->constant_count; ++i)118fprintf(fp, "%" PRIx64 " ", clause->constants[i]);119120if (clause->branch_constant)121fprintf(fp, "*");122123fprintf(fp, "\n");124}125126fprintf(fp, "\n");127}128129void130bi_print_block(bi_block *block, FILE *fp)131{132fprintf(fp, "block%u {\n", block->base.name);133134if (block->scheduled) {135bi_foreach_clause_in_block(block, clause)136bi_print_clause(clause, fp);137} else {138bi_foreach_instr_in_block(block, ins)139bi_print_instr((bi_instr *) ins, fp);140}141142fprintf(fp, "}");143144if (block->base.successors[0]) {145fprintf(fp, " -> ");146147pan_foreach_successor((&block->base), succ)148fprintf(fp, "block%u ", succ->name);149}150151if (block->base.predecessors->entries) {152fprintf(fp, " from");153154bi_foreach_predecessor(block, pred)155fprintf(fp, " block%u", pred->base.name);156}157158fprintf(fp, "\n\n");159}160161void162bi_print_shader(bi_context *ctx, FILE *fp)163{164bi_foreach_block(ctx, block)165bi_print_block((bi_block *) block, fp);166}167168169