7e317abe7a7f5d73da0813b756d2eb18fa7944ea
2 * Copyright 2013 Vadim Girlin <vadimgirlin@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 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the 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 NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
27 #include "sb_shader.h"
32 bool dump::visit(node
& n
, bool enter
) {
48 assert(!"invalid node subtype");
56 bool dump::visit(container_node
& n
, bool enter
) {
63 sblog
<< " preloaded inputs [";
67 dump_live_values(n
, true);
76 sblog
<< " results [";
80 dump_live_values(n
, false);
86 bool dump::visit(bb_node
& n
, bool enter
) {
90 sblog
<< "{ BB_" << n
.id
<< " loop_level = " << n
.loop_level
<< " ";
91 dump_live_values(n
, true);
96 sblog
<< "} end BB_" << n
.id
<< " ";
97 dump_live_values(n
, false);
102 bool dump::visit(alu_group_node
& n
, bool enter
) {
107 dump_live_values(n
, true);
115 dump_live_values(n
, false);
120 bool dump::visit(cf_node
& n
, bool enter
) {
124 dump_op(n
, n
.bc
.op_ptr
->name
);
126 if (n
.bc
.op_ptr
->flags
& CF_BRANCH
) {
127 sblog
<< " @" << (n
.bc
.addr
<< 1);
136 dump_live_values(n
, true);
145 dump_live_values(n
, false);
151 bool dump::visit(alu_node
& n
, bool enter
) {
167 bool dump::visit(alu_packed_node
& n
, bool enter
) {
171 dump_op(n
, n
.op_ptr()->name
);
173 dump_live_values(n
, true);
178 if (!n
.live_after
.empty()) {
180 dump_live_values(n
, false);
184 // proccess children only if their src/dst aren't moved to this node yet
185 return n
.src
.empty();
188 bool dump::visit(fetch_node
& n
, bool enter
) {
192 dump_op(n
, n
.bc
.op_ptr
->name
);
202 bool dump::visit(region_node
& n
, bool enter
) {
206 sblog
<< "region #" << n
.region_id
<< " ";
209 if (!n
.vars_defined
.empty()) {
210 sblog
<< "vars_defined: ";
211 dump_set(sh
, n
.vars_defined
);
214 dump_live_values(n
, true);
227 dump_live_values(n
, false);
232 bool dump::visit(repeat_node
& n
, bool enter
) {
236 sblog
<< "repeat region #" << n
.target
->region_id
;
237 sblog
<< (n
.empty() ? " " : " after { ");
240 dump_live_values(n
, true);
248 sblog
<< "} end_repeat ";
249 dump_live_values(n
, false);
255 bool dump::visit(depart_node
& n
, bool enter
) {
259 sblog
<< "depart region #" << n
.target
->region_id
;
260 sblog
<< (n
.empty() ? " " : " after { ");
263 dump_live_values(n
, true);
270 sblog
<< "} end_depart ";
271 dump_live_values(n
, false);
277 bool dump::visit(if_node
& n
, bool enter
) {
281 sblog
<< "if " << *n
.cond
<< " ";
284 dump_live_values(n
, true);
294 dump_live_values(n
, false);
299 void dump::indent() {
300 sblog
.print_wl("", level
* 4);
303 void dump::dump_vec(const vvec
& vv
) {
305 for(vvec::const_iterator I
= vv
.begin(), E
= vv
.end(); I
!= E
; ++I
) {
320 void dump::dump_rels(vvec
& vv
) {
321 for(vvec::iterator I
= vv
.begin(), E
= vv
.end(); I
!= E
; ++I
) {
324 if (!v
|| !v
->is_rel())
327 sblog
<< "\n\t\t\t\t\t";
328 sblog
<< " rels: " << *v
<< " : ";
335 void dump::dump_op(node
&n
, const char *name
) {
338 alu_node
&a
= static_cast<alu_node
&>(n
);
339 sblog
<< (a
.bc
.pred_sel
-2) << " [" << *a
.pred
<< "] ";
344 bool has_dst
= !n
.dst
.empty();
346 if (n
.subtype
== NST_CF_INST
) {
347 cf_node
*c
= static_cast<cf_node
*>(&n
);
348 if (c
->bc
.op_ptr
->flags
& CF_EXP
) {
349 static const char *exp_type
[] = {"PIXEL", "POS ", "PARAM"};
350 sblog
<< " " << exp_type
[c
->bc
.type
] << " " << c
->bc
.array_base
;
352 } else if (c
->bc
.op_ptr
->flags
& CF_STRM
) {
353 static const char *exp_type
[] = {"WRITE", "WRITE_IND", "WRITE_ACK",
355 sblog
<< " " << exp_type
[c
->bc
.type
] << " " << c
->bc
.array_base
356 << " ES:" << c
->bc
.elem_size
;
371 void dump::dump_set(shader
&sh
, val_set
& v
) {
373 for(val_set::iterator I
= v
.begin(sh
), E
= v
.end(sh
); I
!= E
; ++I
) {
375 sblog
<< *val
<< " ";
380 void dump::dump_common(node
& n
) {
383 void dump::dump_flags(node
&n
) {
384 if (n
.flags
& NF_DEAD
)
385 sblog
<< "### DEAD ";
386 if (n
.flags
& NF_REG_CONSTRAINT
)
388 if (n
.flags
& NF_CHAN_CONSTRAINT
)
390 if (n
.flags
& NF_ALU_4SLOT
)
394 void dump::dump_val(value
* v
) {
398 void dump::dump_alu(alu_node
*n
) {
400 if (n
->is_copy_mov())
404 sblog
<< (n
->bc
.pred_sel
-2) << " [" << *n
->pred
<< "] ";
407 sblog
<< n
->bc
.op_ptr
->name
;
410 static const char *omod_str
[] = {"", "*2", "*4", "/2"};
411 sblog
<< omod_str
[n
->bc
.omod
];
418 bool has_dst
= !n
->dst
.empty();
428 for (vvec::iterator I
= n
->src
.begin(), E
= n
->src
.end(); I
!= E
;
431 bc_alu_src
&src
= n
->bc
.src
[s
];
453 void dump::dump_op(node
* n
) {
454 if (n
->type
== NT_IF
) {
461 dump_alu(static_cast<alu_node
*>(n
));
464 dump_op(*n
, static_cast<fetch_node
*>(n
)->bc
.op_ptr
->name
);
470 dump_op(*n
, static_cast<cf_node
*>(n
)->bc
.op_ptr
->name
);
472 case NST_ALU_PACKED_INST
:
473 dump_op(*n
, static_cast<alu_packed_node
*>(n
)->op_ptr()->name
);
485 dump_op(*n
, "??unknown_op");
489 void dump::dump_op_list(container_node
* c
) {
490 for (node_iterator I
= c
->begin(), E
= c
->end(); I
!= E
; ++I
) {
496 void dump::dump_queue(sched_queue
& q
) {
497 for (sched_queue::iterator I
= q
.begin(), E
= q
.end(); I
!= E
; ++I
) {
503 void dump::dump_live_values(container_node
&n
, bool before
) {
505 if (!n
.live_before
.empty()) {
506 sblog
<< "live_before: ";
507 dump_set(sh
, n
.live_before
);
510 if (!n
.live_after
.empty()) {
511 sblog
<< "live_after: ";
512 dump_set(sh
, n
.live_after
);
518 } // namespace r600_sb