101e04c3fSmrg/*
201e04c3fSmrg * Copyright © 2016-2017 Broadcom
301e04c3fSmrg *
401e04c3fSmrg * Permission is hereby granted, free of charge, to any person obtaining a
501e04c3fSmrg * copy of this software and associated documentation files (the "Software"),
601e04c3fSmrg * to deal in the Software without restriction, including without limitation
701e04c3fSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
801e04c3fSmrg * and/or sell copies of the Software, and to permit persons to whom the
901e04c3fSmrg * Software is furnished to do so, subject to the following conditions:
1001e04c3fSmrg *
1101e04c3fSmrg * The above copyright notice and this permission notice (including the next
1201e04c3fSmrg * paragraph) shall be included in all copies or substantial portions of the
1301e04c3fSmrg * Software.
1401e04c3fSmrg *
1501e04c3fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1601e04c3fSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1701e04c3fSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1801e04c3fSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1901e04c3fSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2001e04c3fSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
2101e04c3fSmrg * IN THE SOFTWARE.
2201e04c3fSmrg */
2301e04c3fSmrg
2401e04c3fSmrg#include "broadcom/common/v3d_device_info.h"
2501e04c3fSmrg#include "v3d_compiler.h"
2601e04c3fSmrg
27ed98bd31Smaya/* Prints a human-readable description of the uniform reference. */
28ed98bd31Smayavoid
29ed98bd31Smayavir_dump_uniform(enum quniform_contents contents,
30ed98bd31Smaya                 uint32_t data)
3101e04c3fSmrg{
3201e04c3fSmrg        static const char *quniform_names[] = {
337ec681f3Smrg                [QUNIFORM_LINE_WIDTH] = "line_width",
347ec681f3Smrg                [QUNIFORM_AA_LINE_WIDTH] = "aa_line_width",
3501e04c3fSmrg                [QUNIFORM_VIEWPORT_X_SCALE] = "vp_x_scale",
3601e04c3fSmrg                [QUNIFORM_VIEWPORT_Y_SCALE] = "vp_y_scale",
3701e04c3fSmrg                [QUNIFORM_VIEWPORT_Z_OFFSET] = "vp_z_offset",
3801e04c3fSmrg                [QUNIFORM_VIEWPORT_Z_SCALE] = "vp_z_scale",
39ed98bd31Smaya                [QUNIFORM_SHARED_OFFSET] = "shared_offset",
4001e04c3fSmrg        };
4101e04c3fSmrg
42ed98bd31Smaya        switch (contents) {
43ed98bd31Smaya        case QUNIFORM_CONSTANT:
44ed98bd31Smaya                fprintf(stderr, "0x%08x / %f", data, uif(data));
45ed98bd31Smaya                break;
46ed98bd31Smaya
47ed98bd31Smaya        case QUNIFORM_UNIFORM:
48ed98bd31Smaya                fprintf(stderr, "push[%d]", data);
49ed98bd31Smaya                break;
50ed98bd31Smaya
51ed98bd31Smaya        case QUNIFORM_TEXTURE_CONFIG_P1:
52ed98bd31Smaya                fprintf(stderr, "tex[%d].p1", data);
53ed98bd31Smaya                break;
54ed98bd31Smaya
55ed98bd31Smaya        case QUNIFORM_TMU_CONFIG_P0:
56ed98bd31Smaya                fprintf(stderr, "tex[%d].p0 | 0x%x",
57ed98bd31Smaya                        v3d_unit_data_get_unit(data),
58ed98bd31Smaya                        v3d_unit_data_get_offset(data));
59ed98bd31Smaya                break;
60ed98bd31Smaya
61ed98bd31Smaya        case QUNIFORM_TMU_CONFIG_P1:
62ed98bd31Smaya                fprintf(stderr, "tex[%d].p1 | 0x%x",
63ed98bd31Smaya                        v3d_unit_data_get_unit(data),
64ed98bd31Smaya                        v3d_unit_data_get_offset(data));
65ed98bd31Smaya                break;
66ed98bd31Smaya
67ed98bd31Smaya        case QUNIFORM_IMAGE_TMU_CONFIG_P0:
68ed98bd31Smaya                fprintf(stderr, "img[%d].p0 | 0x%x",
69ed98bd31Smaya                        v3d_unit_data_get_unit(data),
70ed98bd31Smaya                        v3d_unit_data_get_offset(data));
71ed98bd31Smaya                break;
72ed98bd31Smaya
73ed98bd31Smaya        case QUNIFORM_TEXTURE_WIDTH:
74ed98bd31Smaya                fprintf(stderr, "tex[%d].width", data);
75ed98bd31Smaya                break;
76ed98bd31Smaya        case QUNIFORM_TEXTURE_HEIGHT:
77ed98bd31Smaya                fprintf(stderr, "tex[%d].height", data);
78ed98bd31Smaya                break;
79ed98bd31Smaya        case QUNIFORM_TEXTURE_DEPTH:
80ed98bd31Smaya                fprintf(stderr, "tex[%d].depth", data);
81ed98bd31Smaya                break;
82ed98bd31Smaya        case QUNIFORM_TEXTURE_ARRAY_SIZE:
83ed98bd31Smaya                fprintf(stderr, "tex[%d].array_size", data);
84ed98bd31Smaya                break;
85ed98bd31Smaya        case QUNIFORM_TEXTURE_LEVELS:
86ed98bd31Smaya                fprintf(stderr, "tex[%d].levels", data);
87ed98bd31Smaya                break;
88ed98bd31Smaya
89ed98bd31Smaya        case QUNIFORM_IMAGE_WIDTH:
90ed98bd31Smaya                fprintf(stderr, "img[%d].width", data);
91ed98bd31Smaya                break;
92ed98bd31Smaya        case QUNIFORM_IMAGE_HEIGHT:
93ed98bd31Smaya                fprintf(stderr, "img[%d].height", data);
94ed98bd31Smaya                break;
95ed98bd31Smaya        case QUNIFORM_IMAGE_DEPTH:
96ed98bd31Smaya                fprintf(stderr, "img[%d].depth", data);
97ed98bd31Smaya                break;
98ed98bd31Smaya        case QUNIFORM_IMAGE_ARRAY_SIZE:
99ed98bd31Smaya                fprintf(stderr, "img[%d].array_size", data);
100ed98bd31Smaya                break;
101ed98bd31Smaya
102ed98bd31Smaya        case QUNIFORM_SPILL_OFFSET:
103ed98bd31Smaya                fprintf(stderr, "spill_offset");
104ed98bd31Smaya                break;
105ed98bd31Smaya
106ed98bd31Smaya        case QUNIFORM_SPILL_SIZE_PER_THREAD:
107ed98bd31Smaya                fprintf(stderr, "spill_size_per_thread");
108ed98bd31Smaya                break;
109ed98bd31Smaya
110ed98bd31Smaya        case QUNIFORM_UBO_ADDR:
111ed98bd31Smaya                fprintf(stderr, "ubo[%d]+0x%x",
112ed98bd31Smaya                        v3d_unit_data_get_unit(data),
113ed98bd31Smaya                        v3d_unit_data_get_offset(data));
114ed98bd31Smaya                break;
115ed98bd31Smaya
116ed98bd31Smaya        case QUNIFORM_SSBO_OFFSET:
117ed98bd31Smaya                fprintf(stderr, "ssbo[%d]", data);
118ed98bd31Smaya                break;
119ed98bd31Smaya
1207ec681f3Smrg        case QUNIFORM_GET_SSBO_SIZE:
121ed98bd31Smaya                fprintf(stderr, "ssbo_size[%d]", data);
122ed98bd31Smaya                break;
123ed98bd31Smaya
1247ec681f3Smrg        case QUNIFORM_GET_UBO_SIZE:
1257ec681f3Smrg                fprintf(stderr, "ubo_size[%d]", data);
1267ec681f3Smrg                break;
1277ec681f3Smrg
128ed98bd31Smaya        case QUNIFORM_NUM_WORK_GROUPS:
129ed98bd31Smaya                fprintf(stderr, "num_wg.%c", data < 3 ? "xyz"[data] : '?');
130ed98bd31Smaya                break;
131ed98bd31Smaya
132ed98bd31Smaya        default:
133ed98bd31Smaya                if (quniform_contents_is_texture_p0(contents)) {
134ed98bd31Smaya                        fprintf(stderr, "tex[%d].p0: 0x%08x",
135ed98bd31Smaya                                contents - QUNIFORM_TEXTURE_CONFIG_P0_0,
136ed98bd31Smaya                                data);
137ed98bd31Smaya                } else if (contents < ARRAY_SIZE(quniform_names) &&
138ed98bd31Smaya                           quniform_names[contents]) {
139ed98bd31Smaya                        fprintf(stderr, "%s",
140ed98bd31Smaya                                quniform_names[contents]);
141ed98bd31Smaya                } else {
142ed98bd31Smaya                        fprintf(stderr, "%d / 0x%08x", contents, data);
143ed98bd31Smaya                }
144ed98bd31Smaya        }
145ed98bd31Smaya}
146ed98bd31Smaya
147ed98bd31Smayastatic void
148ed98bd31Smayavir_print_reg(struct v3d_compile *c, const struct qinst *inst,
149ed98bd31Smaya              struct qreg reg)
150ed98bd31Smaya{
15101e04c3fSmrg        switch (reg.file) {
15201e04c3fSmrg
15301e04c3fSmrg        case QFILE_NULL:
15401e04c3fSmrg                fprintf(stderr, "null");
15501e04c3fSmrg                break;
15601e04c3fSmrg
15701e04c3fSmrg        case QFILE_LOAD_IMM:
15801e04c3fSmrg                fprintf(stderr, "0x%08x (%f)", reg.index, uif(reg.index));
15901e04c3fSmrg                break;
16001e04c3fSmrg
16101e04c3fSmrg        case QFILE_REG:
16201e04c3fSmrg                fprintf(stderr, "rf%d", reg.index);
16301e04c3fSmrg                break;
16401e04c3fSmrg
16501e04c3fSmrg        case QFILE_MAGIC:
1667ec681f3Smrg                fprintf(stderr, "%s",
1677ec681f3Smrg                        v3d_qpu_magic_waddr_name(c->devinfo, reg.index));
16801e04c3fSmrg                break;
16901e04c3fSmrg
17001e04c3fSmrg        case QFILE_SMALL_IMM: {
17101e04c3fSmrg                uint32_t unpacked;
17201e04c3fSmrg                bool ok = v3d_qpu_small_imm_unpack(c->devinfo,
17301e04c3fSmrg                                                   inst->qpu.raddr_b,
17401e04c3fSmrg                                                   &unpacked);
17501e04c3fSmrg                assert(ok); (void) ok;
17601e04c3fSmrg
1777ec681f3Smrg                int8_t *p = (int8_t *)&inst->qpu.raddr_b;
1787ec681f3Smrg                if (*p >= -16 && *p <= 15)
17901e04c3fSmrg                        fprintf(stderr, "%d", unpacked);
18001e04c3fSmrg                else
18101e04c3fSmrg                        fprintf(stderr, "%f", uif(unpacked));
18201e04c3fSmrg                break;
18301e04c3fSmrg        }
18401e04c3fSmrg
18501e04c3fSmrg        case QFILE_VPM:
18601e04c3fSmrg                fprintf(stderr, "vpm%d.%d",
18701e04c3fSmrg                        reg.index / 4, reg.index % 4);
18801e04c3fSmrg                break;
18901e04c3fSmrg
190ed98bd31Smaya        case QFILE_TEMP:
191ed98bd31Smaya                fprintf(stderr, "t%d", reg.index);
19201e04c3fSmrg                break;
19301e04c3fSmrg        }
19401e04c3fSmrg}
19501e04c3fSmrg
19601e04c3fSmrgstatic void
19701e04c3fSmrgvir_dump_sig_addr(const struct v3d_device_info *devinfo,
19801e04c3fSmrg                  const struct v3d_qpu_instr *instr)
19901e04c3fSmrg{
20001e04c3fSmrg        if (devinfo->ver < 41)
20101e04c3fSmrg                return;
20201e04c3fSmrg
20301e04c3fSmrg        if (!instr->sig_magic)
20401e04c3fSmrg                fprintf(stderr, ".rf%d", instr->sig_addr);
20501e04c3fSmrg        else {
2067ec681f3Smrg                const char *name =
2077ec681f3Smrg                         v3d_qpu_magic_waddr_name(devinfo, instr->sig_addr);
20801e04c3fSmrg                if (name)
20901e04c3fSmrg                        fprintf(stderr, ".%s", name);
21001e04c3fSmrg                else
21101e04c3fSmrg                        fprintf(stderr, ".UNKNOWN%d", instr->sig_addr);
21201e04c3fSmrg        }
21301e04c3fSmrg}
21401e04c3fSmrg
21501e04c3fSmrgstatic void
21601e04c3fSmrgvir_dump_sig(struct v3d_compile *c, struct qinst *inst)
21701e04c3fSmrg{
21801e04c3fSmrg        struct v3d_qpu_sig *sig = &inst->qpu.sig;
21901e04c3fSmrg
22001e04c3fSmrg        if (sig->thrsw)
22101e04c3fSmrg                fprintf(stderr, "; thrsw");
22201e04c3fSmrg        if (sig->ldvary) {
22301e04c3fSmrg                fprintf(stderr, "; ldvary");
22401e04c3fSmrg                vir_dump_sig_addr(c->devinfo, &inst->qpu);
22501e04c3fSmrg        }
22601e04c3fSmrg        if (sig->ldvpm)
22701e04c3fSmrg                fprintf(stderr, "; ldvpm");
22801e04c3fSmrg        if (sig->ldtmu) {
22901e04c3fSmrg                fprintf(stderr, "; ldtmu");
23001e04c3fSmrg                vir_dump_sig_addr(c->devinfo, &inst->qpu);
23101e04c3fSmrg        }
23201e04c3fSmrg        if (sig->ldtlb) {
23301e04c3fSmrg                fprintf(stderr, "; ldtlb");
23401e04c3fSmrg                vir_dump_sig_addr(c->devinfo, &inst->qpu);
23501e04c3fSmrg        }
23601e04c3fSmrg        if (sig->ldtlbu) {
23701e04c3fSmrg                fprintf(stderr, "; ldtlbu");
23801e04c3fSmrg                vir_dump_sig_addr(c->devinfo, &inst->qpu);
23901e04c3fSmrg        }
24001e04c3fSmrg        if (sig->ldunif)
24101e04c3fSmrg                fprintf(stderr, "; ldunif");
24201e04c3fSmrg        if (sig->ldunifrf) {
24301e04c3fSmrg                fprintf(stderr, "; ldunifrf");
24401e04c3fSmrg                vir_dump_sig_addr(c->devinfo, &inst->qpu);
24501e04c3fSmrg        }
24601e04c3fSmrg        if (sig->ldunifa)
24701e04c3fSmrg                fprintf(stderr, "; ldunifa");
24801e04c3fSmrg        if (sig->ldunifarf) {
24901e04c3fSmrg                fprintf(stderr, "; ldunifarf");
25001e04c3fSmrg                vir_dump_sig_addr(c->devinfo, &inst->qpu);
25101e04c3fSmrg        }
25201e04c3fSmrg        if (sig->wrtmuc)
25301e04c3fSmrg                fprintf(stderr, "; wrtmuc");
25401e04c3fSmrg}
25501e04c3fSmrg
25601e04c3fSmrgstatic void
25701e04c3fSmrgvir_dump_alu(struct v3d_compile *c, struct qinst *inst)
25801e04c3fSmrg{
25901e04c3fSmrg        struct v3d_qpu_instr *instr = &inst->qpu;
260ed98bd31Smaya        int nsrc = vir_get_nsrc(inst);
26101e04c3fSmrg        enum v3d_qpu_input_unpack unpack[2];
26201e04c3fSmrg
26301e04c3fSmrg        if (inst->qpu.alu.add.op != V3D_QPU_A_NOP) {
26401e04c3fSmrg                fprintf(stderr, "%s", v3d_qpu_add_op_name(instr->alu.add.op));
26501e04c3fSmrg                fprintf(stderr, "%s", v3d_qpu_cond_name(instr->flags.ac));
26601e04c3fSmrg                fprintf(stderr, "%s", v3d_qpu_pf_name(instr->flags.apf));
26701e04c3fSmrg                fprintf(stderr, "%s", v3d_qpu_uf_name(instr->flags.auf));
26801e04c3fSmrg                fprintf(stderr, " ");
26901e04c3fSmrg
27001e04c3fSmrg                vir_print_reg(c, inst, inst->dst);
27101e04c3fSmrg                fprintf(stderr, "%s", v3d_qpu_pack_name(instr->alu.add.output_pack));
27201e04c3fSmrg
27301e04c3fSmrg                unpack[0] = instr->alu.add.a_unpack;
27401e04c3fSmrg                unpack[1] = instr->alu.add.b_unpack;
27501e04c3fSmrg        } else {
27601e04c3fSmrg                fprintf(stderr, "%s", v3d_qpu_mul_op_name(instr->alu.mul.op));
27701e04c3fSmrg                fprintf(stderr, "%s", v3d_qpu_cond_name(instr->flags.mc));
27801e04c3fSmrg                fprintf(stderr, "%s", v3d_qpu_pf_name(instr->flags.mpf));
27901e04c3fSmrg                fprintf(stderr, "%s", v3d_qpu_uf_name(instr->flags.muf));
28001e04c3fSmrg                fprintf(stderr, " ");
28101e04c3fSmrg
28201e04c3fSmrg                vir_print_reg(c, inst, inst->dst);
28301e04c3fSmrg                fprintf(stderr, "%s", v3d_qpu_pack_name(instr->alu.mul.output_pack));
28401e04c3fSmrg
28501e04c3fSmrg                unpack[0] = instr->alu.mul.a_unpack;
28601e04c3fSmrg                unpack[1] = instr->alu.mul.b_unpack;
28701e04c3fSmrg        }
28801e04c3fSmrg
289ed98bd31Smaya        for (int i = 0; i < nsrc; i++) {
29001e04c3fSmrg                fprintf(stderr, ", ");
29101e04c3fSmrg                vir_print_reg(c, inst, inst->src[i]);
292ed98bd31Smaya                fprintf(stderr, "%s", v3d_qpu_unpack_name(unpack[i]));
29301e04c3fSmrg        }
29401e04c3fSmrg
29501e04c3fSmrg        vir_dump_sig(c, inst);
29601e04c3fSmrg}
29701e04c3fSmrg
29801e04c3fSmrgvoid
29901e04c3fSmrgvir_dump_inst(struct v3d_compile *c, struct qinst *inst)
30001e04c3fSmrg{
30101e04c3fSmrg        struct v3d_qpu_instr *instr = &inst->qpu;
30201e04c3fSmrg
30301e04c3fSmrg        switch (inst->qpu.type) {
30401e04c3fSmrg        case V3D_QPU_INSTR_TYPE_ALU:
30501e04c3fSmrg                vir_dump_alu(c, inst);
30601e04c3fSmrg                break;
30701e04c3fSmrg        case V3D_QPU_INSTR_TYPE_BRANCH:
30801e04c3fSmrg                fprintf(stderr, "b");
30901e04c3fSmrg                if (instr->branch.ub)
31001e04c3fSmrg                        fprintf(stderr, "u");
31101e04c3fSmrg
31201e04c3fSmrg                fprintf(stderr, "%s",
31301e04c3fSmrg                        v3d_qpu_branch_cond_name(instr->branch.cond));
31401e04c3fSmrg                fprintf(stderr, "%s", v3d_qpu_msfign_name(instr->branch.msfign));
31501e04c3fSmrg
31601e04c3fSmrg                switch (instr->branch.bdi) {
31701e04c3fSmrg                case V3D_QPU_BRANCH_DEST_ABS:
31801e04c3fSmrg                        fprintf(stderr, "  zero_addr+0x%08x", instr->branch.offset);
31901e04c3fSmrg                        break;
32001e04c3fSmrg
32101e04c3fSmrg                case V3D_QPU_BRANCH_DEST_REL:
32201e04c3fSmrg                        fprintf(stderr, "  %d", instr->branch.offset);
32301e04c3fSmrg                        break;
32401e04c3fSmrg
32501e04c3fSmrg                case V3D_QPU_BRANCH_DEST_LINK_REG:
32601e04c3fSmrg                        fprintf(stderr, "  lri");
32701e04c3fSmrg                        break;
32801e04c3fSmrg
32901e04c3fSmrg                case V3D_QPU_BRANCH_DEST_REGFILE:
33001e04c3fSmrg                        fprintf(stderr, "  rf%d", instr->branch.raddr_a);
33101e04c3fSmrg                        break;
33201e04c3fSmrg                }
33301e04c3fSmrg
33401e04c3fSmrg                if (instr->branch.ub) {
33501e04c3fSmrg                        switch (instr->branch.bdu) {
33601e04c3fSmrg                        case V3D_QPU_BRANCH_DEST_ABS:
33701e04c3fSmrg                                fprintf(stderr, ", a:unif");
33801e04c3fSmrg                                break;
33901e04c3fSmrg
34001e04c3fSmrg                        case V3D_QPU_BRANCH_DEST_REL:
34101e04c3fSmrg                                fprintf(stderr, ", r:unif");
34201e04c3fSmrg                                break;
34301e04c3fSmrg
34401e04c3fSmrg                        case V3D_QPU_BRANCH_DEST_LINK_REG:
34501e04c3fSmrg                                fprintf(stderr, ", lri");
34601e04c3fSmrg                                break;
34701e04c3fSmrg
34801e04c3fSmrg                        case V3D_QPU_BRANCH_DEST_REGFILE:
34901e04c3fSmrg                                fprintf(stderr, ", rf%d", instr->branch.raddr_a);
35001e04c3fSmrg                                break;
35101e04c3fSmrg                        }
35201e04c3fSmrg                }
35301e04c3fSmrg                break;
35401e04c3fSmrg        }
355ed98bd31Smaya
356ed98bd31Smaya        if (vir_has_uniform(inst)) {
357ed98bd31Smaya                fprintf(stderr, " (");
358ed98bd31Smaya                vir_dump_uniform(c->uniform_contents[inst->uniform],
359ed98bd31Smaya                                 c->uniform_data[inst->uniform]);
360ed98bd31Smaya                fprintf(stderr, ")");
361ed98bd31Smaya        }
36201e04c3fSmrg}
36301e04c3fSmrg
36401e04c3fSmrgvoid
36501e04c3fSmrgvir_dump(struct v3d_compile *c)
36601e04c3fSmrg{
36701e04c3fSmrg        int ip = 0;
368ed98bd31Smaya        int pressure = 0;
36901e04c3fSmrg
37001e04c3fSmrg        vir_for_each_block(block, c) {
37101e04c3fSmrg                fprintf(stderr, "BLOCK %d:\n", block->index);
37201e04c3fSmrg                vir_for_each_inst(inst, block) {
37301e04c3fSmrg                        if (c->live_intervals_valid) {
374ed98bd31Smaya                                for (int i = 0; i < c->num_temps; i++) {
375ed98bd31Smaya                                        if (c->temp_start[i] == ip)
376ed98bd31Smaya                                                pressure++;
377ed98bd31Smaya                                }
378ed98bd31Smaya
379ed98bd31Smaya                                fprintf(stderr, "P%4d ", pressure);
380ed98bd31Smaya
38101e04c3fSmrg                                bool first = true;
38201e04c3fSmrg
38301e04c3fSmrg                                for (int i = 0; i < c->num_temps; i++) {
38401e04c3fSmrg                                        if (c->temp_start[i] != ip)
38501e04c3fSmrg                                                continue;
38601e04c3fSmrg
38701e04c3fSmrg                                        if (first) {
38801e04c3fSmrg                                                first = false;
38901e04c3fSmrg                                        } else {
39001e04c3fSmrg                                                fprintf(stderr, ", ");
39101e04c3fSmrg                                        }
392ed98bd31Smaya                                        if (BITSET_TEST(c->spillable, i))
393ed98bd31Smaya                                                fprintf(stderr, "S%4d", i);
394ed98bd31Smaya                                        else
395ed98bd31Smaya                                                fprintf(stderr, "U%4d", i);
39601e04c3fSmrg                                }
39701e04c3fSmrg
39801e04c3fSmrg                                if (first)
39901e04c3fSmrg                                        fprintf(stderr, "      ");
40001e04c3fSmrg                                else
40101e04c3fSmrg                                        fprintf(stderr, " ");
40201e04c3fSmrg                        }
40301e04c3fSmrg
40401e04c3fSmrg                        if (c->live_intervals_valid) {
40501e04c3fSmrg                                bool first = true;
40601e04c3fSmrg
40701e04c3fSmrg                                for (int i = 0; i < c->num_temps; i++) {
40801e04c3fSmrg                                        if (c->temp_end[i] != ip)
40901e04c3fSmrg                                                continue;
41001e04c3fSmrg
41101e04c3fSmrg                                        if (first) {
41201e04c3fSmrg                                                first = false;
41301e04c3fSmrg                                        } else {
41401e04c3fSmrg                                                fprintf(stderr, ", ");
41501e04c3fSmrg                                        }
41601e04c3fSmrg                                        fprintf(stderr, "E%4d", i);
417ed98bd31Smaya                                        pressure--;
41801e04c3fSmrg                                }
41901e04c3fSmrg
42001e04c3fSmrg                                if (first)
42101e04c3fSmrg                                        fprintf(stderr, "      ");
42201e04c3fSmrg                                else
42301e04c3fSmrg                                        fprintf(stderr, " ");
42401e04c3fSmrg                        }
42501e04c3fSmrg
42601e04c3fSmrg                        vir_dump_inst(c, inst);
42701e04c3fSmrg                        fprintf(stderr, "\n");
42801e04c3fSmrg                        ip++;
42901e04c3fSmrg                }
43001e04c3fSmrg                if (block->successors[1]) {
43101e04c3fSmrg                        fprintf(stderr, "-> BLOCK %d, %d\n",
43201e04c3fSmrg                                block->successors[0]->index,
43301e04c3fSmrg                                block->successors[1]->index);
43401e04c3fSmrg                } else if (block->successors[0]) {
43501e04c3fSmrg                        fprintf(stderr, "-> BLOCK %d\n",
43601e04c3fSmrg                                block->successors[0]->index);
43701e04c3fSmrg                }
43801e04c3fSmrg        }
43901e04c3fSmrg}
440