panfrost: Add note about preloaded varyings
[mesa.git] / src / panfrost / bifrost / bifrost_print.c
1 /*
2 * Copyright (C) 2019 Ryan Houdek <Sonicadvance1@gmail.com>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24 #include "compiler_defines.h"
25 #include "bifrost_print.h"
26
27 const char *ir_names[op_last + 1] = {
28 "fma.f32",
29 "fmul.f32",
30 "fadd.f32",
31 "frcp_fast.f32",
32 "max.f32",
33 "min.f32",
34 "add.i32",
35 "sub.i32",
36 "imad",
37 "mul.i32",
38 "or.i32",
39 "and.i32",
40 "lshift.i32",
41 "xor.i32",
42 "rshift.i32",
43 "arshift.i32",
44 "csel.i32",
45 "imin3.i32",
46 "umin3.i32",
47 "imax3.i32",
48 "umax3.i32",
49
50 "branch",
51
52 // unary
53 "trunc",
54 "ceil",
55 "floor",
56 "round",
57 "roundeven",
58
59 "mov",
60 "movi",
61
62 "ld_ubo.v1",
63 "ld_ubo.v2",
64 "ld_ubo.v3",
65 "ld_ubo.v4",
66
67 "ld_attr.v1",
68 "ld_attr.v2",
69 "ld_attr.v3",
70 "ld_attr.v4",
71
72 "ld_var_addr",
73 "st_vary.v1",
74 "st_vary.v2",
75 "st_vary.v3",
76 "st_vary.v4",
77
78 "store.v1",
79 "store.v2",
80 "store.v3",
81 "store.v4",
82
83 "create_vector",
84 "extract_element",
85 "last",
86 };
87
88 void
89 print_mir_instruction(struct bifrost_instruction *instr, bool post_ra)
90 {
91 printf("\t");
92 if (instr->dest_components != 0) {
93 if (post_ra) {
94 if (instr->dest_components == 1) {
95 printf("r%d = ", instr->args.dest);
96 } else {
97 printf("r%d..r%d = ", instr->args.dest, instr->args.dest + instr->dest_components - 1);
98
99 }
100 } else {
101 printf("%%0x%08x = ", instr->ssa_args.dest);
102 }
103 }
104
105 printf("%s ", ir_names[instr->op]);
106
107 if (post_ra) {
108 uint32_t sources[4] = {
109 instr->args.src0,
110 instr->args.src1,
111 instr->args.src2,
112 instr->args.src3
113 };
114 for (unsigned i = 0; i < 4; ++i) {
115 if (sources[i] == SSA_INVALID_VALUE) break;
116 bool last = i + 1 == 4 ||
117 sources[i + 1] == SSA_INVALID_VALUE;
118
119 if (sources[i] == SSA_FIXED_CONST_0) {
120 printf("#0%s", last ? "" : ", ");
121 } else if (sources[i] >= SSA_FIXED_UREG_MINIMUM) {
122 printf("u%d%s", SSA_UREG_FROM_FIXED(sources[i]), last ? "" : ", ");
123 } else {
124 printf("r%d%s", sources[i], last ? "" : ", ");
125 }
126 }
127 } else {
128 uint32_t sources[4] = {
129 instr->ssa_args.src0,
130 instr->ssa_args.src1,
131 instr->ssa_args.src2,
132 instr->ssa_args.src3
133 };
134 for (unsigned i = 0; i < 4; ++i) {
135 if (sources[i] == SSA_INVALID_VALUE) break;
136 bool last = i + 1 == 4 ||
137 sources[i + 1] == SSA_INVALID_VALUE;
138
139 printf("%%0x%08x%s", sources[i], last ? "" : ", ");
140 }
141 }
142
143 printf("\n");
144 }
145
146 void
147 print_mir_block(struct bifrost_block *block, bool post_ra)
148 {
149 printf("{\n");
150
151 mir_foreach_instr_in_block(block, instr) {
152 print_mir_instruction(instr, post_ra);
153 }
154
155 printf("}\n");
156 }