2 * Copyright (C) 2019 Ryan Houdek <Sonicadvance1@gmail.com>
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:
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
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
24 #include "compiler_defines.h"
25 #include "bifrost_print.h"
27 const char *ir_names
[op_last
+ 1] = {
89 print_mir_instruction(struct bifrost_instruction
*instr
, bool post_ra
)
92 if (instr
->dest_components
!= 0) {
94 if (instr
->dest_components
== 1) {
95 printf("r%d = ", instr
->args
.dest
);
97 printf("r%d..r%d = ", instr
->args
.dest
, instr
->args
.dest
+ instr
->dest_components
- 1);
101 printf("%%0x%08x = ", instr
->ssa_args
.dest
);
105 printf("%s ", ir_names
[instr
->op
]);
108 uint32_t sources
[4] = {
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
;
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
? "" : ", ");
124 printf("r%d%s", sources
[i
], last
? "" : ", ");
128 uint32_t sources
[4] = {
129 instr
->ssa_args
.src0
,
130 instr
->ssa_args
.src1
,
131 instr
->ssa_args
.src2
,
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
;
139 printf("%%0x%08x%s", sources
[i
], last
? "" : ", ");
147 print_mir_block(struct bifrost_block
*block
, bool post_ra
)
151 mir_foreach_instr_in_block(block
, instr
) {
152 print_mir_instruction(instr
, post_ra
);