#include "r600_isa.h"
}
+#include <cstdio>
+#include <string>
#include <vector>
#include <stack>
-#include <ostream>
struct r600_bytecode;
struct r600_shader;
class region_node;
class shader;
+class sb_ostream {
+public:
+ sb_ostream() {}
+
+ virtual void write(const char *s) = 0;
+
+ sb_ostream& operator <<(const char *s) {
+ write(s);
+ return *this;
+ }
+
+ sb_ostream& operator <<(const std::string& s) {
+ return *this << s.c_str();
+ }
+
+ sb_ostream& operator <<(void *p) {
+ char b[32];
+ sprintf(b, "%p", p);
+ return *this << b;
+ }
+
+ sb_ostream& operator <<(char c) {
+ char b[2];
+ sprintf(b, "%c", c);
+ return *this << b;
+ }
+
+ sb_ostream& operator <<(int n) {
+ char b[32];
+ sprintf(b, "%d", n);
+ return *this << b;
+ }
+
+ sb_ostream& operator <<(unsigned n) {
+ char b[32];
+ sprintf(b, "%u", n);
+ return *this << b;
+ }
+
+ sb_ostream& operator <<(double d) {
+ char b[32];
+ sprintf(b, "%f", d);
+ return *this << b;
+ }
+
+ // print as field of specified width, right aligned
+ void print_w(int n, int width) {
+ char b[256],f[8];
+ sprintf(f, "%%%dd", width);
+ snprintf(b, 256, f, n);
+ write(b);
+ }
+
+ // print as field of specified width, left aligned
+ void print_wl(int n, int width) {
+ char b[256],f[8];
+ sprintf(f, "%%-%dd", width);
+ snprintf(b, 256, f, n);
+ write(b);
+ }
+
+ // print as field of specified width, left aligned
+ void print_wl(const std::string &s, int width) {
+ write(s.c_str());
+ int l = s.length();
+ while (l++ < width) {
+ write(" ");
+ }
+ }
+
+ // print int as field of specified width, right aligned, zero-padded
+ void print_zw(int n, int width) {
+ char b[256],f[8];
+ sprintf(f, "%%0%dd", width);
+ snprintf(b, 256, f, n);
+ write(b);
+ }
+
+ // print int as field of specified width, right aligned, zero-padded, hex
+ void print_zw_hex(int n, int width) {
+ char b[256],f[8];
+ sprintf(f, "%%0%dx", width);
+ snprintf(b, 256, f, n);
+ write(b);
+ }
+};
+
+class sb_ostringstream : public sb_ostream {
+ std::string data;
+public:
+ sb_ostringstream() : data() {}
+
+ virtual void write(const char *s) {
+ data += s;
+ }
+
+ void clear() { data.clear(); }
+
+ const char* c_str() { return data.c_str(); }
+ std::string& str() { return data; }
+};
+
+class sb_log : public sb_ostream {
+ FILE *o;
+public:
+ sb_log() : o(stderr) {}
+
+ virtual void write(const char *s) {
+ fputs(s, o);
+ }
+};
+
+extern sb_log sblog;
+
enum shader_target
{
TARGET_UNKNOWN,
void collect(node *n);
void accumulate(shader_stats &s);
- void dump(std::ostream &o);
- void dump_diff(std::ostream &o, shader_stats &s);
+ void dump();
+ void dump_diff(shader_stats &s);
};
class sb_context {
* Vadim Girlin
*/
-#include <iostream>
-#include <sstream>
-
#include "sb_bc.h"
#include "sb_shader.h"
#include "sb_pass.h"
namespace r600_sb {
-using std::cerr;
-
bc_builder::bc_builder(shader &s)
: sh(s), ctx(s.get_ctx()), bb(ctx.hw_class_bit()), error(0) {}
* Vadim Girlin
*/
-#include "sstream"
-
#include "sb_bc.h"
namespace r600_sb {
* Vadim Girlin
*/
-#include <sstream>
-#include <iomanip>
-
#include "sb_bc.h"
#include "sb_shader.h"
#include "sb_pass.h"
if ((n.bc.op_ptr->flags & CF_ALU) && n.bc.is_alu_extended()) {
dump_dw(id, 2);
id += 2;
- o << "\n";
+ sblog << "\n";
}
dump_dw(id, 2);
bool bc_dump::visit(alu_node& n, bool enter) {
if (enter) {
- o << " ";
+ sblog << " ";
dump_dw(id, 2);
- if (new_group)
- o << std::setw(5) << ++group_index << " ";
- else
- o << " ";
+ if (new_group) {
+ sblog.print_w(++group_index, 5);
+ sblog << " ";
+ } else
+ sblog << " ";
dump(n);
id += 2;
static_cast<alu_group_node*>(n.get_alu_group_node());
assert(g);
for (unsigned k = 0; k < g->literals.size(); ++k) {
- o << " ";
+ sblog << " ";
dump_dw(id, 1);
id += 1;
- o << "\n";
+ sblog << "\n";
}
id = (id + 1) & ~1u;
bool bc_dump::visit(fetch_node& n, bool enter) {
if (enter) {
- o << " ";
+ sblog << " ";
dump_dw(id, 3);
dump(n);
id += 4;
return false;
}
-static void fill_to(std::ostringstream &s, int pos) {
+static void fill_to(sb_ostringstream &s, int pos) {
int l = s.str().length();
if (l < pos)
s << std::string(pos-l, ' ');
}
void bc_dump::dump(cf_node& n) {
- std::ostringstream s;
+ sb_ostringstream s;
s << n.bc.op_ptr->name;
if (n.bc.op_ptr->flags & CF_EXP) {
static const char *exp_type[] = {"PIXEL", "POS ", "PARAM"};
fill_to(s, 18);
- s << " " << exp_type[n.bc.type];
+ s << " " << exp_type[n.bc.type] << " ";
if (n.bc.burst_count) {
- std::ostringstream s2;
+ sb_ostringstream s2;
s2 << n.bc.array_base << "-" << n.bc.array_base + n.bc.burst_count;
- s << " " << std::setw(5) << std::left << s2.str();
- s << "R" << n.bc.rw_gpr << "-" <<
+ s.print_wl(s2.str(), 5);
+ s << " R" << n.bc.rw_gpr << "-" <<
n.bc.rw_gpr + n.bc.burst_count << ".";
} else {
- s << " " << std::setw(5) << std::left << n.bc.array_base;
- s << "R" << n.bc.rw_gpr << ".";
+ s.print_wl(n.bc.array_base, 5);
+ s << " R" << n.bc.rw_gpr << ".";
}
for (int k = 0; k < 4; ++k)
static const char *exp_type[] = {"WRITE", "WRITE_IND", "WRITE_ACK",
"WRITE_IND_ACK"};
fill_to(s, 18);
- s << " " << exp_type[n.bc.type];
- s << " " << std::setw(5) << std::left << n.bc.array_base;
- s << "R" << n.bc.rw_gpr << ".";
+ s << " " << exp_type[n.bc.type] << " ";
+ s.print_wl(n.bc.array_base, 5);
+ s << " R" << n.bc.rw_gpr << ".";
for (int k = 0; k < 4; ++k)
s << ((n.bc.comp_mask & (1 << k)) ? chans[k] : '_');
if (n.bc.end_of_program)
s << " EOP";
- o << s.str() << "\n";
+ sblog << s.str() << "\n";
}
-static void print_sel(std::ostream &s, int sel, int rel, int index_mode,
+static void print_sel(sb_ostream &s, int sel, int rel, int index_mode,
int need_brackets) {
if (rel && index_mode >= 5 && sel < 128)
s << "G";
}
}
-static void print_dst(std::ostream &s, bc_alu &alu)
+static void print_dst(sb_ostream &s, bc_alu &alu)
{
unsigned sel = alu.dst_gpr;
char reg_char = 'R';
s << chans[alu.dst_chan];
}
-static void print_src(std::ostream &s, bc_alu &alu, unsigned idx)
+static void print_src(sb_ostream &s, bc_alu &alu, unsigned idx)
{
bc_alu_src *src = &alu.src[idx];
unsigned sel = src->sel, need_sel = 1, need_chan = 1, need_brackets = 0;
need_chan = 1;
break;
case ALU_SRC_LITERAL:
- s << "[" << std::hex << std::setfill('0') << std::setw(8)
- << std::showbase << src->value.u << " "
- << std::noshowbase << std::setfill(' ') << std::dec
- << src->value.f << "]";
+ s << "[0x";
+ s.print_zw_hex(src->value.u, 8);
+ s << " " << src->value.f << "]";
need_chan = 1;
break;
case ALU_SRC_0_5:
s << "|";
}
void bc_dump::dump(alu_node& n) {
- std::ostringstream s;
+ sb_ostringstream s;
static const char *omod_str[] = {"","*2","*4","/2"};
static const char *slots = "xyzwt";
- s << (n.bc.update_exec_mask ? 'M' : ' ');
- s << (n.bc.update_pred ? 'P' : ' ');
+ s << (n.bc.update_exec_mask ? "M" : " ");
+ s << (n.bc.update_pred ? "P" : " ");
s << " ";
- s << (n.bc.pred_sel>=2 ? (n.bc.pred_sel == 2 ? '0' : '1') : ' ');
+ s << (n.bc.pred_sel>=2 ? (n.bc.pred_sel == 2 ? "0" : "1") : " ");
s << " ";
s << slots[n.bc.slot] << ": ";
s << " " << vec_bs[n.bc.bank_swizzle];
}
- o << s.str() << "\n";
+ sblog << s.str() << "\n";
}
int bc_dump::init() {
- std::ostringstream s;
+ sb_ostringstream s;
s << "===== SHADER #" << sh.id;
if (sh.optimized)
s << target;
- o << "\n" << s.str() << "\n";
+ sblog << "\n" << s.str() << "\n";
- s.str(std::string());
+ s.clear();
if (bc_data) {
s << "===== " << ndw << " dw ===== " << sh.ngpr
while (s.str().length() < 80)
s << "=";
- o << s.str() << "\n";
+ sblog << s.str() << "\n";
return 0;
}
int bc_dump::done() {
- std::ostringstream s;
+ sb_ostringstream s;
s << "===== SHADER_END ";
while (s.str().length() < 80)
s << "=";
- o << s.str() << "\n\n";
+ sblog << s.str() << "\n\n";
return 0;
}
-bc_dump::bc_dump(shader& s, std::ostream& o, bytecode* bc) :
- vpass(s), o(o), bc_data(), ndw(), id(),
+bc_dump::bc_dump(shader& s, bytecode* bc) :
+ vpass(s), bc_data(), ndw(), id(),
new_group(), group_index() {
if (bc) {
}
void bc_dump::dump(fetch_node& n) {
- std::ostringstream s;
+ sb_ostringstream s;
static const char * fetch_type[] = {"VERTEX", "INSTANCE", ""};
s << n.bc.op_ptr->name;
s << " O" << chans[k] << ":" << n.bc.offset[k];
}
- o << s.str() << "\n";
+ sblog << s.str() << "\n";
}
void bc_dump::dump_dw(unsigned dw_id, unsigned count) {
assert(dw_id + count <= ndw);
- o << std::setfill('0') << std::setw(4) << dw_id << " ";
+ sblog.print_zw(dw_id, 4);
+ sblog << " ";
while (count--) {
- o << std::setw(8) << std::hex << bc_data[dw_id++] << " ";
+ sblog.print_zw_hex(bc_data[dw_id++], 8);
+ sblog << " ";
}
- o << std::setfill(' ') << std::dec;
}
} // namespace r600_sb
#define FBC_DUMP(q)
#endif
-#include <iostream>
-
#include "sb_bc.h"
-
#include "sb_shader.h"
-
#include "sb_pass.h"
namespace r600_sb {
-using std::cerr;
-
int bc_finalizer::run() {
regions_vec &rv = sh.get_regions();
vvec &sv = a->src;
FBC_DUMP(
- cerr << "finalize_alu_src: ";
+ sblog << "finalize_alu_src: ";
dump::dump_op(a);
- cerr << "\n";
+ sblog << "\n";
);
unsigned si = 0;
else if (l == literal(1.0f))
sel = SEL_1;
else {
- cerr << "invalid fetch constant operand " << chan << " ";
+ sblog << "invalid fetch constant operand " << chan << " ";
dump::dump_op(f);
- cerr << "\n";
+ sblog << "\n";
abort();
}
if (reg == -1)
reg = vreg;
else if ((unsigned)reg != vreg) {
- cerr << "invalid fetch source operand " << chan << " ";
+ sblog << "invalid fetch source operand " << chan << " ";
dump::dump_op(f);
- cerr << "\n";
+ sblog << "\n";
abort();
}
sel = vchan;
} else {
- cerr << "invalid fetch source operand " << chan << " ";
+ sblog << "invalid fetch source operand " << chan << " ";
dump::dump_op(f);
- cerr << "\n";
+ sblog << "\n";
abort();
}
else if (l == literal(1.0f))
sel = SEL_1;
else {
- cerr << "invalid fetch constant operand " << chan << " ";
+ sblog << "invalid fetch constant operand " << chan << " ";
dump::dump_op(f);
- cerr << "\n";
+ sblog << "\n";
abort();
}
if (reg == -1)
reg = vreg;
else if ((unsigned)reg != vreg) {
- cerr << "invalid fetch source operand " << chan << " ";
+ sblog << "invalid fetch source operand " << chan << " ";
dump::dump_op(f);
- cerr << "\n";
+ sblog << "\n";
abort();
}
sel = vchan;
} else {
- cerr << "invalid fetch source operand " << chan << " ";
+ sblog << "invalid fetch source operand " << chan << " ";
dump::dump_op(f);
- cerr << "\n";
+ sblog << "\n";
abort();
}
if (reg == -1)
reg = vreg;
else if ((unsigned)reg != vreg) {
- cerr << "invalid fetch dst operand " << chan << " ";
+ sblog << "invalid fetch dst operand " << chan << " ";
dump::dump_op(f);
- cerr << "\n";
+ sblog << "\n";
abort();
}
dst_swz[vchan] = sel;
} else {
- cerr << "invalid fetch dst operand " << chan << " ";
+ sblog << "invalid fetch dst operand " << chan << " ";
dump::dump_op(f);
- cerr << "\n";
+ sblog << "\n";
abort();
}
else if (l == literal(1.0f))
sel = SEL_1;
else {
- cerr << "invalid export constant operand " << chan << " ";
+ sblog << "invalid export constant operand " << chan << " ";
dump::dump_op(c);
- cerr << "\n";
+ sblog << "\n";
abort();
}
if (reg == -1)
reg = vreg;
else if ((unsigned)reg != vreg) {
- cerr << "invalid export source operand " << chan << " ";
+ sblog << "invalid export source operand " << chan << " ";
dump::dump_op(c);
- cerr << "\n";
+ sblog << "\n";
abort();
}
sel = vchan;
} else {
- cerr << "invalid export source operand " << chan << " ";
+ sblog << "invalid export source operand " << chan << " ";
dump::dump_op(c);
- cerr << "\n";
+ sblog << "\n";
abort();
}
continue;
if (!v->is_any_gpr() || v->gpr.chan() != chan) {
- cerr << "invalid source operand " << chan << " ";
+ sblog << "invalid source operand " << chan << " ";
dump::dump_op(c);
- cerr << "\n";
+ sblog << "\n";
abort();
}
unsigned vreg = v->gpr.sel();
if (reg == -1)
reg = vreg;
else if ((unsigned)reg != vreg) {
- cerr << "invalid source operand " << chan << " ";
+ sblog << "invalid source operand " << chan << " ";
dump::dump_op(c);
- cerr << "\n";
+ sblog << "\n";
abort();
}
continue;
if (!v->is_any_gpr() || v->gpr.chan() != chan) {
- cerr << "invalid source operand " << chan << " ";
+ sblog << "invalid source operand " << chan << " ";
dump::dump_op(c);
- cerr << "\n";
+ sblog << "\n";
abort();
}
unsigned vreg = v->gpr.sel();
if (reg == -1)
reg = vreg;
else if ((unsigned)reg != vreg) {
- cerr << "invalid source operand " << chan << " ";
+ sblog << "invalid source operand " << chan << " ";
dump::dump_op(c);
- cerr << "\n";
+ sblog << "\n";
abort();
}
}
namespace r600_sb {
-using std::cerr;
-
int bc_parser::decode() {
dw = bc->bytecode;
cf_node *c_else = NULL, *end = cf_map[c->bc.addr];
BCP_DUMP(
- cerr << "parsing JUMP @" << c->bc.id;
- cerr << "\n";
+ sblog << "parsing JUMP @" << c->bc.id;
+ sblog << "\n";
);
if (end->bc.op == CF_OP_ELSE) {
BCP_DUMP(
- cerr << " found ELSE : ";
+ sblog << " found ELSE : ";
dump::dump_op(end);
- cerr << "\n";
+ sblog << "\n";
);
c_else = end;
end = cf_map[c_else->bc.addr];
} else {
BCP_DUMP(
- cerr << " no else\n";
+ sblog << " no else\n";
);
c_else = end;
namespace r600_sb {
+sb_log sblog;
+
unsigned sb_context::dump_pass = 0;
unsigned sb_context::dump_stat = 0;
unsigned sb_context::dry_run = 0;
#include <stack>
#include <map>
-#include <iostream>
#include "sb_bc.h"
#include "sb_shader.h"
using namespace r600_sb;
-using std::cerr;
-
static sb_hw_class translate_chip_class(enum chip_class cc);
static sb_hw_chip translate_chip(enum radeon_family rf);
sb_context *ctx = static_cast<sb_context*>(sctx);
if (sb_context::dump_stat) {
- cerr << "context src stats: ";
- ctx->src_stats.dump(cerr);
- cerr << "context opt stats: ";
- ctx->opt_stats.dump(cerr);
- cerr << "context diff: ";
- ctx->src_stats.dump_diff(cerr, ctx->opt_stats);
+ sblog << "\ncontext src stats: ";
+ ctx->src_stats.dump();
+ sblog << "context opt stats: ";
+ ctx->opt_stats.dump();
+ sblog << "context diff: ";
+ ctx->src_stats.dump_diff(ctx->opt_stats);
}
delete ctx;
time_start = os_time_get_nano();
}
- SB_DUMP_STAT( cerr << "\nsb: shader " << shader_id << "\n"; );
+ SB_DUMP_STAT( sblog << "\nsb: shader " << shader_id << "\n"; );
bc_parser parser(*ctx, bc, pshader);
shader *sh = parser.get_shader();
if (dump_bytecode) {
- bc_dump(*sh, cerr, bc->bytecode, bc->ndw).run();
+ bc_dump(*sh, bc->bytecode, bc->ndw).run();
}
if (!optimize) {
if ((sb_context::dskip_start <= shader_id &&
shader_id <= sb_context::dskip_end) ==
(sb_context::dskip_mode == 1)) {
- cerr << "sb: skipped shader " << shader_id << " : " << "["
+ sblog << "sb: skipped shader " << shader_id << " : " << "["
<< sb_context::dskip_start << "; "
<< sb_context::dskip_end << "] mode "
<< sb_context::dskip_mode << "\n";
return r;
}
- SB_DUMP_PASS( cerr << "\n\n###### after parse\n"; sh->dump_ir(); );
+ SB_DUMP_PASS( sblog << "\n\n###### after parse\n"; sh->dump_ir(); );
#define SB_RUN_PASS(n, dump) \
do { \
r = n(*sh).run(); \
if (r) { \
- cerr << "sb: error (" << r << ") in the " << #n << " pass.\n"; \
+ sblog << "sb: error (" << r << ") in the " << #n << " pass.\n"; \
if (sb_context::no_fallback) \
return r; \
- cerr << "sb: using unoptimized bytecode...\n"; \
+ sblog << "sb: using unoptimized bytecode...\n"; \
delete sh; \
return 0; \
} \
if (dump) { \
- SB_DUMP_PASS( cerr << "\n\n###### after " << #n << "\n"; \
+ SB_DUMP_PASS( sblog << "\n\n###### after " << #n << "\n"; \
sh->dump_ir();); \
} \
assert(!r); \
bytecode &nbc = builder.get_bytecode();
if (dump_bytecode) {
- bc_dump(*sh, cerr, &nbc).run();
+ bc_dump(*sh, &nbc).run();
}
if (!sb_context::dry_run) {
bc->ngpr = sh->ngpr;
bc->nstack = sh->nstack;
} else {
- SB_DUMP_STAT( cerr << "sb: dry run: optimized bytecode is not used\n"; );
+ SB_DUMP_STAT( sblog << "sb: dry run: optimized bytecode is not used\n"; );
}
if (sb_context::dump_stat) {
int64_t t = os_time_get_nano() - time_start;
- cerr << "sb: processing shader " << shader_id << " done ( "
+ sblog << "sb: processing shader " << shader_id << " done ( "
<< ((double)t)/1000000.0 << " ms ).\n";
sh->opt_stats.ndw = bc->ndw;
sh->collect_stats(true);
- cerr << "src stats: ";
- sh->src_stats.dump(cerr);
- cerr << "opt stats: ";
- sh->opt_stats.dump(cerr);
- cerr << "diff: ";
- sh->src_stats.dump_diff(cerr, sh->opt_stats);
+ sblog << "src stats: ";
+ sh->src_stats.dump();
+ sblog << "opt stats: ";
+ sh->opt_stats.dump();
+ sblog << "diff: ";
+ sh->src_stats.dump_diff(sh->opt_stats);
}
delete sh;
*/
#include "sb_shader.h"
-
#include "sb_pass.h"
namespace r600_sb {
-using std::cerr;
-
int def_use::run() {
run_on(sh.root, true);
run_on(sh.root, false);
if (is_op) {
if (0) {
- cerr << "def_use processing op ";
+ sblog << "def_use processing op ";
dump::dump_op(n);
- cerr << "\n";
+ sblog << "\n";
}
if (defs)
* Vadim Girlin
*/
-#include <iostream>
-#include <iomanip>
-
#include "sb_shader.h"
-
#include "sb_pass.h"
namespace r600_sb {
-using std::cerr;
-
bool dump::visit(node& n, bool enter) {
if (enter) {
indent();
assert(!"invalid node subtype");
break;
}
- cerr << "\n";
+ sblog << "\n";
}
return false;
}
if (!n.empty()) {
indent();
dump_flags(n);
- cerr << "{ ";
+ sblog << "{ ";
if (!n.dst.empty()) {
- cerr << " preloaded inputs [";
+ sblog << " preloaded inputs [";
dump_vec(n.dst);
- cerr << "] ";
+ sblog << "] ";
}
dump_live_values(n, true);
}
--level;
if (!n.empty()) {
indent();
- cerr << "} ";
+ sblog << "} ";
if (!n.src.empty()) {
- cerr << " results [";
+ sblog << " results [";
dump_vec(n.src);
- cerr << "] ";
+ sblog << "] ";
}
dump_live_values(n, false);
}
if (enter) {
indent();
dump_flags(n);
- cerr << "{ BB_" << n.id << " loop_level = " << n.loop_level << " ";
+ sblog << "{ BB_" << n.id << " loop_level = " << n.loop_level << " ";
dump_live_values(n, true);
++level;
} else {
--level;
indent();
- cerr << "} end BB_" << n.id << " ";
+ sblog << "} end BB_" << n.id << " ";
dump_live_values(n, false);
}
return true;
if (enter) {
indent();
dump_flags(n);
- cerr << "[ ";
+ sblog << "[ ";
dump_live_values(n, true);
++level;
--level;
indent();
- cerr << "] ";
+ sblog << "] ";
dump_live_values(n, false);
}
return true;
dump_op(n, n.bc.op_ptr->name);
if (n.bc.op_ptr->flags & CF_BRANCH) {
- cerr << " @" << (n.bc.addr << 1);
+ sblog << " @" << (n.bc.addr << 1);
}
dump_common(n);
- cerr << "\n";
+ sblog << "\n";
if (!n.empty()) {
indent();
- cerr << "< ";
+ sblog << "< ";
dump_live_values(n, true);
}
--level;
if (!n.empty()) {
indent();
- cerr << "> ";
+ sblog << "> ";
dump_live_values(n, false);
}
}
dump_flags(n);
dump_alu(&n);
dump_common(n);
- cerr << "\n";
+ sblog << "\n";
++level;
} else {
indent();
dump_flags(n);
dump_op(n, n.op_ptr()->name);
- cerr << " ";
+ sblog << " ";
dump_live_values(n, true);
++level;
indent();
dump_flags(n);
dump_op(n, n.bc.op_ptr->name);
- cerr << "\n";
+ sblog << "\n";
++level;
} else {
if (enter) {
indent();
dump_flags(n);
- cerr << "region #" << n.region_id << " ";
+ sblog << "region #" << n.region_id << " ";
dump_common(n);
if (!n.vars_defined.empty()) {
- cerr << "vars_defined: ";
+ sblog << "vars_defined: ";
dump_set(sh, n.vars_defined);
}
if (enter) {
indent();
dump_flags(n);
- cerr << "repeat region #" << n.target->region_id;
- cerr << (n.empty() ? " " : " after { ");
+ sblog << "repeat region #" << n.target->region_id;
+ sblog << (n.empty() ? " " : " after { ");
dump_common(n);
- cerr << " ";
+ sblog << " ";
dump_live_values(n, true);
++level;
if (!n.empty()) {
indent();
- cerr << "} end_repeat ";
+ sblog << "} end_repeat ";
dump_live_values(n, false);
}
}
if (enter) {
indent();
dump_flags(n);
- cerr << "depart region #" << n.target->region_id;
- cerr << (n.empty() ? " " : " after { ");
+ sblog << "depart region #" << n.target->region_id;
+ sblog << (n.empty() ? " " : " after { ");
dump_common(n);
- cerr << " ";
+ sblog << " ";
dump_live_values(n, true);
++level;
--level;
if (!n.empty()) {
indent();
- cerr << "} end_depart ";
+ sblog << "} end_depart ";
dump_live_values(n, false);
}
}
if (enter) {
indent();
dump_flags(n);
- cerr << "if " << *n.cond << " ";
+ sblog << "if " << *n.cond << " ";
dump_common(n);
- cerr << " ";
+ sblog << " ";
dump_live_values(n, true);
indent();
- cerr <<"{\n";
+ sblog <<"{\n";
++level;
} else {
--level;
indent();
- cerr << "} endif ";
+ sblog << "} endif ";
dump_live_values(n, false);
}
return true;
}
void dump::indent() {
- cerr << std::setw(level * 4) << "";
+ sblog.print_wl("", level * 4);
}
void dump::dump_vec(const vvec & vv) {
for(vvec::const_iterator I = vv.begin(), E = vv.end(); I != E; ++I) {
value *v = *I;
if (!first)
- cerr << ", ";
+ sblog << ", ";
else
first = false;
if (v) {
- cerr << *v;
+ sblog << *v;
} else {
- cerr << "__";
+ sblog << "__";
}
}
}
if (!v || !v->is_rel())
continue;
- cerr << "\n\t\t\t\t\t";
- cerr << " rels: " << *v << " : ";
+ sblog << "\n\t\t\t\t\t";
+ sblog << " rels: " << *v << " : ";
dump_vec(v->mdef);
- cerr << " <= ";
+ sblog << " <= ";
dump_vec(v->muse);
}
}
if (n.pred) {
alu_node &a = static_cast<alu_node&>(n);
- cerr << (a.bc.pred_sel-2) << " [" << *a.pred << "] ";
+ sblog << (a.bc.pred_sel-2) << " [" << *a.pred << "] ";
}
- cerr << name;
+ sblog << name;
bool has_dst = !n.dst.empty();
cf_node *c = static_cast<cf_node*>(&n);
if (c->bc.op_ptr->flags & CF_EXP) {
static const char *exp_type[] = {"PIXEL", "POS ", "PARAM"};
- cerr << " " << exp_type[c->bc.type] << " " << c->bc.array_base;
+ sblog << " " << exp_type[c->bc.type] << " " << c->bc.array_base;
has_dst = false;
} else if (c->bc.op_ptr->flags & CF_STRM) {
static const char *exp_type[] = {"WRITE", "WRITE_IND", "WRITE_ACK",
"WRITE_IND_ACK"};
- cerr << " " << exp_type[c->bc.type] << " " << c->bc.array_base
+ sblog << " " << exp_type[c->bc.type] << " " << c->bc.array_base
<< " ES:" << c->bc.elem_size;
has_dst = false;
}
}
- cerr << " ";
+ sblog << " ";
if (has_dst) {
dump_vec(n.dst);
- cerr << ", ";
+ sblog << ", ";
}
dump_vec(n.src);
}
void dump::dump_set(shader &sh, val_set& v) {
- cerr << "[";
+ sblog << "[";
for(val_set::iterator I = v.begin(sh), E = v.end(sh); I != E; ++I) {
value *val = *I;
- cerr << *val << " ";
+ sblog << *val << " ";
}
- cerr << "]";
+ sblog << "]";
}
void dump::dump_common(node& n) {
void dump::dump_flags(node &n) {
if (n.flags & NF_DEAD)
- cerr << "### DEAD ";
+ sblog << "### DEAD ";
if (n.flags & NF_REG_CONSTRAINT)
- cerr << "R_CONS ";
+ sblog << "R_CONS ";
if (n.flags & NF_CHAN_CONSTRAINT)
- cerr << "CH_CONS ";
+ sblog << "CH_CONS ";
if (n.flags & NF_ALU_4SLOT)
- cerr << "4S ";
+ sblog << "4S ";
}
void dump::dump_val(value* v) {
- cerr << *v;
+ sblog << *v;
}
void dump::dump_alu(alu_node *n) {
if (n->is_copy_mov())
- cerr << "(copy) ";
+ sblog << "(copy) ";
if (n->pred) {
- cerr << (n->bc.pred_sel-2) << " [" << n->pred << "] ";
+ sblog << (n->bc.pred_sel-2) << " [" << *n->pred << "] ";
}
- cerr << n->bc.op_ptr->name;
+ sblog << n->bc.op_ptr->name;
if (n->bc.omod) {
static const char *omod_str[] = {"", "*2", "*4", "/2"};
- cerr << omod_str[n->bc.omod];
+ sblog << omod_str[n->bc.omod];
}
if (n->bc.clamp) {
- cerr << "_sat";
+ sblog << "_sat";
}
bool has_dst = !n->dst.empty();
- cerr << " ";
+ sblog << " ";
if (has_dst) {
dump_vec(n->dst);
- cerr << ", ";
+ sblog << ", ";
}
unsigned s = 0;
bc_alu_src &src = n->bc.src[s];
if (src.neg)
- cerr << "-";
+ sblog << "-";
if (src.abs)
- cerr << "|";
+ sblog << "|";
dump_val(*I);
if (src.abs)
- cerr << "|";
+ sblog << "|";
if (I + 1 != E)
- cerr << ", ";
+ sblog << ", ";
}
dump_rels(n->dst);
void dump::dump_op_list(container_node* c) {
for (node_iterator I = c->begin(), E = c->end(); I != E; ++I) {
dump_op(*I);
- cerr << "\n";
+ sblog << "\n";
}
}
void dump::dump_queue(sched_queue& q) {
for (sched_queue::iterator I = q.begin(), E = q.end(); I != E; ++I) {
dump_op(*I);
- cerr << "\n";
+ sblog << "\n";
}
}
void dump::dump_live_values(container_node &n, bool before) {
if (before) {
if (!n.live_before.empty()) {
- cerr << "live_before: ";
+ sblog << "live_before: ";
dump_set(sh, n.live_before);
}
} else {
if (!n.live_after.empty()) {
- cerr << "live_after: ";
+ sblog << "live_after: ";
dump_set(sh, n.live_after);
}
}
- cerr << "\n";
+ sblog << "\n";
}
} // namespace r600_sb
#define GCM_DUMP(a)
#endif
-#include <iostream>
#include <map>
#include "sb_bc.h"
#include "sb_shader.h"
-
#include "sb_pass.h"
namespace r600_sb {
-using std::cerr;
-
int gcm::run() {
- GCM_DUMP( cerr << "==== GCM ==== \n"; sh.dump_ir(); );
+ GCM_DUMP( sblog << "==== GCM ==== \n"; sh.dump_ir(); );
collect_instructions(sh.root, true);
node *o = *I;
GCM_DUMP(
- cerr << "pending : ";
+ sblog << "pending : ";
dump::dump_op(o);
- cerr << "\n";
+ sblog << "\n";
);
if (td_is_ready(o)) {
GCM_DUMP(
- cerr << " ready: ";
+ sblog << " ready: ";
dump::dump_op(o);
- cerr << "\n";
+ sblog << "\n";
);
pending.remove_node(o);
ready.push_back(o);
sched_early(sh.root);
if (!pending.empty()) {
- cerr << "##### gcm_sched_early_pass: unscheduled ops:\n";
+ sblog << "##### gcm_sched_early_pass: unscheduled ops:\n";
dump::dump_op(pending.front());
}
GCM_DUMP( sh.dump_ir(); );
- GCM_DUMP( cerr << "\n\n ############## gcm late\n\n"; );
+ GCM_DUMP( sblog << "\n\n ############## gcm late\n\n"; );
collect_instructions(sh.root, false);
sched_late(sh.root);
if (!pending.empty()) {
- cerr << "##### gcm_sched_late_pass: unscheduled ops:\n";
+ sblog << "##### gcm_sched_late_pass: unscheduled ops:\n";
dump::dump_op(pending.front());
}
void gcm::td_schedule(bb_node *bb, node *n) {
GCM_DUMP(
- cerr << "scheduling : ";
+ sblog << "scheduling : ";
dump::dump_op(n);
- cerr << "\n";
+ sblog << "\n";
);
td_release_uses(n->dst);
void gcm::td_sched_bb(bb_node* bb) {
GCM_DUMP(
- cerr << "td scheduling BB_" << bb->id << "\n";
+ sblog << "td scheduling BB_" << bb->id << "\n";
);
while (!ready.empty()) {
void gcm::td_release_val(value *v) {
GCM_DUMP(
- cerr << "td checking uses: ";
+ sblog << "td checking uses: ";
dump::dump_val(v);
- cerr << "\n";
+ sblog << "\n";
);
use_info *u = v->uses;
}
GCM_DUMP(
- cerr << "td used in ";
+ sblog << "td used in ";
dump::dump_op(u->op);
- cerr << "\n";
+ sblog << "\n";
);
if (--uses[u->op] == 0) {
GCM_DUMP(
- cerr << "td released : ";
+ sblog << "td released : ";
dump::dump_op(u->op);
- cerr << "\n";
+ sblog << "\n";
);
pending.remove_node(u->op);
void gcm::bu_sched_bb(bb_node* bb) {
GCM_DUMP(
- cerr << "bu scheduling BB_" << bb->id << "\n";
+ sblog << "bu scheduling BB_" << bb->id << "\n";
);
bu_bb = bb;
if (!pending_nodes.empty()) {
GCM_DUMP(
- cerr << "pending nodes:\n";
+ sblog << "pending nodes:\n";
);
// TODO consider sorting the exports by array_base,
}
pending_nodes.clear();
GCM_DUMP(
- cerr << "pending nodes processed...\n";
+ sblog << "pending nodes processed...\n";
);
}
!bu_ready[SQ_VTX].empty() ||
!bu_ready_next[SQ_TEX].empty() ||
!bu_ready_next[SQ_VTX].empty())) {
- GCM_DUMP( cerr << "switching to fetch (regpressure)\n"; );
+ GCM_DUMP( sblog << "switching to fetch (regpressure)\n"; );
break;
}
bu_bb = NULL;
GCM_DUMP(
- cerr << "bu finished scheduling BB_" << bb->id << "\n";
+ sblog << "bu finished scheduling BB_" << bb->id << "\n";
);
}
void gcm::push_uc_stack() {
GCM_DUMP(
- cerr << "pushing use count stack prev_level " << ucs_level
+ sblog << "pushing use count stack prev_level " << ucs_level
<< " new level " << (ucs_level + 1) << "\n";
);
++ucs_level;
void gcm::bu_schedule(container_node* c, node* n) {
GCM_DUMP(
- cerr << "bu scheduling : ";
+ sblog << "bu scheduling : ";
dump::dump_op(n);
- cerr << "\n";
+ sblog << "\n";
);
assert(op_map[n].bottom_bb == bu_bb);
}
void gcm::dump_uc_stack() {
- cerr << "##### uc_stk start ####\n";
+ sblog << "##### uc_stk start ####\n";
for (unsigned l = 0; l <= ucs_level; ++l) {
nuc_map &m = nuc_stk[l];
- cerr << "nuc_stk[" << l << "] : @" << &m << "\n";
+ sblog << "nuc_stk[" << l << "] : @" << &m << "\n";
for (nuc_map::iterator I = m.begin(), E = m.end(); I != E; ++I) {
- cerr << " uc " << I->second << " for ";
+ sblog << " uc " << I->second << " for ";
dump::dump_op(I->first);
- cerr << "\n";
+ sblog << "\n";
}
}
- cerr << "##### uc_stk end ####\n";
+ sblog << "##### uc_stk end ####\n";
}
void gcm::pop_uc_stack() {
nuc_map &cm = nuc_stk[ucs_level];
GCM_DUMP(
- cerr << "merging use stack from level " << (ucs_level+1)
+ sblog << "merging use stack from level " << (ucs_level+1)
<< " to " << ucs_level << "\n";
);
node *n = I->first;
GCM_DUMP(
- cerr << " " << cm[n] << " += " << I->second << " for ";
+ sblog << " " << cm[n] << " += " << I->second << " for ";
dump::dump_op(n);
- cerr << "\n";
+ sblog << "\n";
);
unsigned uc = cm[n] += I->second;
cm.erase(n);
pending_nodes.push_back(n);
GCM_DUMP(
- cerr << "pushed pending_node due to stack pop ";
+ sblog << "pushed pending_node due to stack pop ";
dump::dump_op(n);
- cerr << "\n";
+ sblog << "\n";
);
}
}
void gcm::bu_find_best_bb(node *n, op_info &oi) {
GCM_DUMP(
- cerr << " find best bb : ";
+ sblog << " find best bb : ";
dump::dump_op(n);
- cerr << "\n";
+ sblog << "\n";
);
if (oi.bottom_bb)
op_info &oi = op_map[n];
GCM_DUMP(
- cerr << " bu release op ";
+ sblog << " bu release op ";
dump::dump_op(n);
);
bu_find_best_bb(n, oi);
if (oi.bottom_bb == bu_bb) {
- GCM_DUMP( cerr << " ready\n";);
+ GCM_DUMP( sblog << " ready\n";);
add_ready(n);
} else {
- GCM_DUMP( cerr << " ready_above\n";);
+ GCM_DUMP( sblog << " ready_above\n";);
ready_above.push_back(n);
}
}
node *n = *I;
unsigned uc = get_uc_vec(n->dst);
GCM_DUMP(
- cerr << "uc " << uc << " ";
+ sblog << "uc " << uc << " ";
dump::dump_op(n);
- cerr << "\n";
+ sblog << "\n";
);
if (!uc) {
pending_nodes.push_back(n);
GCM_DUMP(
- cerr << "pushed pending_node in init ";
+ sblog << "pushed pending_node in init ";
dump::dump_op(n);
- cerr << "\n";
+ sblog << "\n";
);
} else
if (live.add_val(v)) {
++live_count;
- GCM_DUMP ( cerr << "live_count: " << live_count << "\n"; );
+ GCM_DUMP ( sblog << "live_count: " << live_count << "\n"; );
}
GCM_DUMP(
- cerr << "release val ";
+ sblog << "release val ";
dump::dump_val(v);
- cerr << " for node ";
+ sblog << " for node ";
dump::dump_op(n);
- cerr << " new uc=" << uc << ", total " << uc2 << "\n";
+ sblog << " new uc=" << uc << ", total " << uc2 << "\n";
);
if (uc == uc2)
m[n] = dc;
GCM_DUMP(
- cerr << "dc " << dc << " ";
+ sblog << "dc " << dc << " ";
dump::dump_op(n);
- cerr << "\n";
+ sblog << "\n";
);
}
}
#endif
#include "sb_shader.h"
-
#include "sb_pass.h"
-
#include "sb_sched.h"
namespace r600_sb {
-using std::cerr;
-
bool gvn::visit(node& n, bool enter) {
if (enter) {
#endif
#include "sb_shader.h"
-
#include "sb_pass.h"
namespace r600_sb {
-using std::cerr;
-
int if_conversion::run() {
regions_vec &rv = sh.get_regions();
alu_node *n = static_cast<alu_node*>(*I);
IFC_DUMP(
- cerr << "converting ";
+ sblog << "converting ";
dump::dump_op(n);
- cerr << " " << n << "\n";
+ sblog << " " << n << "\n";
);
n->remove();
r->collect_stats(s);
IFC_DUMP(
- cerr << "ifcvt: region " << r->region_id << " :\n";
+ sblog << "ifcvt: region " << r->region_id << " :\n";
s.dump();
);
return false;
}
- IFC_DUMP( cerr << "if_cvt: processing...\n"; );
+ IFC_DUMP( sblog << "if_cvt: processing...\n"; );
depart_node *nd1 = static_cast<depart_node*>(r->first);
if (!nd1->is_depart())
namespace r600_sb {
-using std::cerr;
-
bool node::accept(vpass& p, bool enter) { return p.visit(*this, enter); }
bool container_node::accept(vpass& p, bool enter) { return p.visit(*this, enter); }
bool alu_group_node::accept(vpass& p, bool enter) { return p.visit(*this, enter); }
}
void node_stats::dump() {
- cerr << " alu_count : " << alu_count << "\n";
- cerr << " alu_kill_count : " << alu_kill_count << "\n";
- cerr << " alu_copy_mov_count : " << alu_copy_mov_count << "\n";
- cerr << " cf_count : " << cf_count << "\n";
- cerr << " fetch_count : " << fetch_count << "\n";
- cerr << " region_count : " << region_count << "\n";
- cerr << " loop_count : " << loop_count << "\n";
- cerr << " phi_count : " << phi_count << "\n";
- cerr << " loop_phi_count : " << loop_phi_count << "\n";
- cerr << " depart_count : " << depart_count << "\n";
- cerr << " repeat_count : " << repeat_count << "\n";
- cerr << " if_count : " << if_count << "\n";
+ sblog << " alu_count : " << alu_count << "\n";
+ sblog << " alu_kill_count : " << alu_kill_count << "\n";
+ sblog << " alu_copy_mov_count : " << alu_copy_mov_count << "\n";
+ sblog << " cf_count : " << cf_count << "\n";
+ sblog << " fetch_count : " << fetch_count << "\n";
+ sblog << " region_count : " << region_count << "\n";
+ sblog << " loop_count : " << loop_count << "\n";
+ sblog << " phi_count : " << phi_count << "\n";
+ sblog << " loop_phi_count : " << loop_phi_count << "\n";
+ sblog << " depart_count : " << depart_count << "\n";
+ sblog << " repeat_count : " << repeat_count << "\n";
+ sblog << " if_count : " << if_count << "\n";
}
unsigned alu_node::interp_param() {
#include <algorithm>
#include <stdint.h>
-#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
static unsigned chan(unsigned idx) { return (idx-1) & 3; }
};
-inline std::ostream& operator <<(std::ostream& o, sel_chan r) {
+inline sb_ostream& operator <<(sb_ostream& o, sel_chan r) {
static const char * ch = "xyzw";
o << r.sel() << "." << ch[r.chan()];
return o;
struct value;
-std::ostream& operator << (std::ostream &o, value &v);
+sb_ostream& operator << (sb_ostream &o, value &v);
typedef uint32_t value_hash;
*/
#include "sb_shader.h"
-
#include "sb_pass.h"
#define LIV_DEBUG 0
namespace r600_sb {
-using std::cerr;
-
bool liveness::visit(container_node& n, bool enter) {
if (enter) {
n.live_after = live;
return;
LIV_DUMP(
- cerr << "interf ";
+ sblog << "interf ";
dump::dump_set(sh, live);
- cerr << "\n";
+ sblog << "\n";
);
val_set& s = live;
v->interferences.remove_val(v);
LIV_DUMP(
- cerr << "interferences updated for ";
+ sblog << "interferences updated for ";
dump::dump_val(v);
- cerr << " : ";
+ sblog << " : ";
dump::dump_set(sh, v->interferences);
- cerr << "\n";
+ sblog << "\n";
);
}
live_changed = false;
void liveness::process_op(node& n) {
LIV_DUMP(
- cerr << "process_op: ";
+ sblog << "process_op: ";
dump::dump_op(&n);
- cerr << "\n";
- cerr << "process_op: live_after:";
+ sblog << "\n";
+ sblog << "process_op: live_after:";
dump::dump_set(sh, live);
- cerr << "\n";
+ sblog << "\n";
);
if(!n.dst.empty() || n.is_cf_op(CF_OP_CALL_FS)) {
process_ins(n);
LIV_DUMP(
- cerr << "process_op: live_before:";
+ sblog << "process_op: live_before:";
dump::dump_set(sh, live);
- cerr << "\n";
+ sblog << "\n";
);
}
class bc_dump : public vpass {
using vpass::visit;
- std::ostream &o;
-
uint32_t *bc_data;
unsigned ndw;
public:
- bc_dump(shader &s, std::ostream &o, bytecode *bc = NULL);
+ bc_dump(shader &s, bytecode *bc = NULL);
- bc_dump(shader &s, std::ostream &o, uint32_t *bc_ptr, unsigned ndw) :
- vpass(s), o(o), bc_data(bc_ptr), ndw(ndw), id(), new_group(), group_index() {}
+ bc_dump(shader &s, uint32_t *bc_ptr, unsigned ndw) :
+ vpass(s), bc_data(bc_ptr), ndw(ndw), id(), new_group(), group_index() {}
virtual int init();
virtual int done();
#endif
#include "sb_shader.h"
-
#include "sb_pass.h"
namespace r600_sb {
-using std::cerr;
-
int peephole::run() {
run_on(sh.root);
bool_op_info bop = {};
PPH_DUMP(
- cerr << "optSETcc ";
+ sblog << "optSETcc ";
dump::dump_op(a);
- cerr << "\n";
+ sblog << "\n";
);
if (!get_bool_op_info(s, bop))
}
PPH_DUMP(
- cerr << "boi node: ";
+ sblog << "boi node: ";
dump::dump_op(bop.n);
- cerr << " invert: " << bop.invert << " int_cvt: " << bop.int_cvt;
- cerr <<"\n";
+ sblog << " invert: " << bop.invert << " int_cvt: " << bop.int_cvt;
+ sblog <<"\n";
);
unsigned newop = is_pred ? get_predsetcc_opcode(cc, cmp_type) :
* Vadim Girlin
*/
-#include <sstream>
-
#include "sb_shader.h"
#include "sb_pass.h"
namespace r600_sb {
-using std::cerr;
-
int ra_checker::run() {
rm_stack.clear();
void ra_checker::dump_error(const error_info &e) {
- cerr << "error at : ";
+ sblog << "error at : ";
dump::dump_op(e.n);
- cerr << "\n";
- cerr << " : " << e.message << "\n";
+ sblog << "\n";
+ sblog << " : " << e.message << "\n";
}
void ra_checker::dump_all_errors() {
void ra_checker::check_value_gpr(node *n, unsigned id, value *v) {
sel_chan gpr = v->gpr;
if (!gpr) {
- std::ostringstream o;
+ sb_ostringstream o;
o << "operand value " << *v << " is not allocated";
error(n, id, o.str());
return;
}
reg_value_map::iterator F = rmap().find(v->gpr);
if (F == rmap().end()) {
- std::ostringstream o;
+ sb_ostringstream o;
o << "operand value " << *v << " was not previously written to its gpr";
error(n, id, o.str());
return;
}
if (!F->second->v_equal(v)) {
- std::ostringstream o;
+ sb_ostringstream o;
o << "expected operand value " << *v
<< ", gpr contains " << *(F->second);
error(n, id, o.str());
if (v->is_rel()) {
if (!v->rel) {
- std::ostringstream o;
+ sb_ostringstream o;
o << "expected relative offset in " << *v;
error(n, id, o.str());
return;
if (v->is_sgpr()) {
if (!v->gpr) {
- std::ostringstream o;
+ sb_ostringstream o;
o << "destination operand " << *v << " is not allocated";
error(n, id, o.str());
return;
for (node_iterator I = g->begin(), E = g->end(); I != E; ++I) {
node *a = *I;
if (!a->is_alu_inst()) {
- std::ostringstream o;
+ sb_ostringstream o;
o << "non-alu node inside alu group";
error(a, 0, o.str());
return;
namespace r600_sb {
-using std::cerr;
-
int ra_coalesce::run() {
return sh.coal.run();
}
c->pin = v->pin_gpr;
RA_DUMP(
- cerr << "create_chunk: ";
+ sblog << "create_chunk: ";
dump_chunk(c);
);
ra_chunk *c1 = e->a->chunk, *c2 = e->b->chunk;
RA_DUMP(
- cerr << "unify_chunks: ";
+ sblog << "unify_chunks: ";
dump_chunk(c1);
dump_chunk(c2);
);
}
void coalescer::dump_edges() {
- cerr << "######## affinity edges\n";
+ sblog << "######## affinity edges\n";
for (edge_queue::iterator I = edges.begin(), E = edges.end();
I != E; ++I) {
ra_edge* e = *I;
- cerr << " ra_edge ";
+ sblog << " ra_edge ";
dump::dump_val(e->a);
- cerr << " <-> ";
+ sblog << " <-> ";
dump::dump_val(e->b);
- cerr << " cost = " << e->cost << "\n";
+ sblog << " cost = " << e->cost << "\n";
}
}
void coalescer::dump_chunks() {
- cerr << "######## chunks\n";
+ sblog << "######## chunks\n";
for (chunk_vec::iterator I = all_chunks.begin(), E = all_chunks.end();
I != E; ++I) {
void coalescer::dump_constraint_queue() {
- cerr << "######## constraints\n";
+ sblog << "######## constraints\n";
for (constraint_queue::iterator I = constraints.begin(),
E = constraints.end(); I != E; ++I) {
}
void coalescer::dump_chunk(ra_chunk* c) {
- cerr << " ra_chunk cost = " << c->cost << " : ";
+ sblog << " ra_chunk cost = " << c->cost << " : ";
dump::dump_vec(c->values);
if (c->flags & RCF_PIN_REG)
- cerr << " REG = " << c->pin.sel();
+ sblog << " REG = " << c->pin.sel();
if (c->flags & RCF_PIN_CHAN)
- cerr << " CHAN = " << c->pin.chan();
+ sblog << " CHAN = " << c->pin.chan();
- cerr << (c->flags & RCF_GLOBAL ? " GLOBAL" : "");
+ sblog << (c->flags & RCF_GLOBAL ? " GLOBAL" : "");
- cerr << "\n";
+ sblog << "\n";
}
void coalescer::dump_constraint(ra_constraint* c) {
- cerr << " ra_constraint: ";
+ sblog << " ra_constraint: ";
switch (c->kind) {
- case CK_PACKED_BS: cerr << "PACKED_BS"; break;
- case CK_PHI: cerr << "PHI"; break;
- case CK_SAME_REG: cerr << "SAME_REG"; break;
- default: cerr << "UNKNOWN_KIND"; assert(0); break;
+ case CK_PACKED_BS: sblog << "PACKED_BS"; break;
+ case CK_PHI: sblog << "PHI"; break;
+ case CK_SAME_REG: sblog << "SAME_REG"; break;
+ default: sblog << "UNKNOWN_KIND"; assert(0); break;
}
- cerr << " cost = " << c->cost << " : ";
+ sblog << " cost = " << c->cost << " : ";
dump::dump_vec(c->values);
- cerr << "\n";
+ sblog << "\n";
}
void coalescer::get_chunk_interferences(ra_chunk *c, val_set &s) {
get_chunk_interferences(c, interf);
RA_DUMP(
- cerr << "color_chunks: ";
+ sblog << "color_chunks: ";
dump_chunk(c);
- cerr << "\n interferences: ";
+ sblog << "\n interferences: ";
dump::dump_set(sh,interf);
- cerr << "\n";
+ sblog << "\n";
);
init_reg_bitset(rb, interf);
RA_DUMP(
- cerr << " assigned " << color << " to ";
+ sblog << " assigned " << color << " to ";
dump::dump_val(v);
- cerr << "\n";
+ sblog << "\n";
);
}
}
RA_DUMP(
- cerr << " detached : ";
+ sblog << " detached : ";
dump_chunk(v->chunk);
);
} while (std::next_permutation(swz, swz + 4));
if (!done && pass) {
- cerr << "sb: ra_coalesce - out of registers\n";
+ sblog << "sb: ra_coalesce - out of registers\n";
return -1;
}
assert(done);
RA_DUMP(
- cerr << "min reg = " << min_reg << " min_swz = "
+ sblog << "min reg = " << min_reg << " min_swz = "
<< min_swz[0] << min_swz[1] << min_swz[2] << min_swz[3] << "\n";
);
ra_constraint *c = *I;
RA_DUMP(
- cerr << "color_constraints: ";
+ sblog << "color_constraints: ";
dump_constraint(c);
);
#endif
#include <cstring>
-#include <iostream>
-#include <iomanip>
#include "sb_bc.h"
#include "sb_shader.h"
-
#include "sb_pass.h"
namespace r600_sb {
-using std::cerr;
-
class regbits {
typedef uint32_t basetype;
static const unsigned bt_bytes = sizeof(basetype);
for (unsigned i = 0; i < size * bt_bits; ++i) {
if (!(i & 31))
- cerr << "\n";
+ sblog << "\n";
- if (!(i & 3))
- cerr << " " << std::setw(3) << (i / 4) << " ";
+ if (!(i & 3)) {
+ sblog.print_wl(i / 4, 7);
+ sblog << " ";
+ }
- cerr << (get(i) ? 1 : 0);
+ sblog << (get(i) ? 1 : 0);
}
}
gpr_array *a = *I;
RA_DUMP(
- cerr << "array [" << a->array_size << "] at " << a->base_gpr << "\n";
- cerr << "\n";
+ sblog << "array [" << a->array_size << "] at " << a->base_gpr << "\n";
+ sblog << "\n";
);
// skip preallocated arrays (e.g. with preloaded inputs)
if (a->gpr) {
- RA_DUMP( cerr << " FIXED at " << a->gpr << "\n"; );
+ RA_DUMP( sblog << " FIXED at " << a->gpr << "\n"; );
continue;
}
bool dead = a->is_dead();
if (dead) {
- RA_DUMP( cerr << " DEAD\n"; );
+ RA_DUMP( sblog << " DEAD\n"; );
continue;
}
}
RA_DUMP(
- cerr << " interf: ";
+ sblog << " interf: ";
dump::dump_set(sh, s);
- cerr << "\n";
+ sblog << "\n";
);
regbits rb(sh, s);
sel_chan base = rb.find_free_array(a->array_size,
(1 << a->base_gpr.chan()));
- RA_DUMP( cerr << " found base: " << base << "\n"; );
+ RA_DUMP( sblog << " found base: " << base << "\n"; );
a->gpr = base;
}
bool copy = n->is_copy_mov();
RA_DUMP(
- cerr << "ra_init: process_op : ";
+ sblog << "ra_init: process_op : ";
dump::dump_op(n);
- cerr << "\n";
+ sblog << "\n";
);
if (n->is_alu_packed()) {
assert(vv.size() <= 8);
RA_DUMP(
- cerr << "color_bs_constraint: ";
+ sblog << "color_bs_constraint: ";
dump::dump_vec(vv);
- cerr << "\n";
+ sblog << "\n";
);
regbits rb(ctx.alu_temp_gprs);
interf = v->interferences;
RA_DUMP(
- cerr << " processing " << *v << " interferences : ";
+ sblog << " processing " << *v << " interferences : ";
dump::dump_set(sh, interf);
- cerr << "\n";
+ sblog << "\n";
);
if (gpr) {
rb.from_val_set(sh, interf);
RA_DUMP(
- cerr << " regbits : ";
+ sblog << " regbits : ";
rb.dump();
- cerr << "\n";
+ sblog << "\n";
);
while (allowed_chans && gpr.sel() < sh.num_nontemp_gpr()) {
gpr = gpr + 1;
RA_DUMP(
- cerr << " trying " << gpr << "\n";
+ sblog << " trying " << gpr << "\n";
);
unsigned chan = gpr.chan();
}
if (!gpr) {
- cerr << "color_bs_constraint: failed...\n";
+ sblog << "color_bs_constraint: failed...\n";
assert(!"coloring failed");
}
}
return;
RA_DUMP(
- cerr << "coloring ";
+ sblog << "coloring ";
dump::dump_val(v);
- cerr << " interferences ";
+ sblog << " interferences ";
dump::dump_set(sh, v->interferences);
- cerr << "\n";
+ sblog << "\n";
);
if (v->is_reg_pinned()) {
sel_chan c;
if (v->is_chan_pinned()) {
- RA_DUMP( cerr << "chan_pinned = " << v->pin_gpr.chan() << " "; );
+ RA_DUMP( sblog << "chan_pinned = " << v->pin_gpr.chan() << " "; );
unsigned mask = 1 << v->pin_gpr.chan();
c = rb.find_free_chans(mask) + v->pin_gpr.chan();
} else {
void ra_init::assign_color(value* v, sel_chan c) {
v->gpr = c;
RA_DUMP(
- cerr << "colored ";
+ sblog << "colored ";
dump::dump_val(v);
- cerr << " to " << c << "\n";
+ sblog << " to " << c << "\n";
);
}
#include "sb_bc.h"
#include "sb_shader.h"
-
#include "sb_pass.h"
#include "sb_sched.h"
namespace r600_sb {
-using std::cerr;
-
rp_kcache_tracker::rp_kcache_tracker(shader &sh) : rp(), uc(),
// FIXME: for now we'll use "two const pairs" limit for r600, same as
// for other chips, otherwise additional check in alu_group_tracker is
bool literal_tracker::try_reserve(literal l) {
- PSC_DUMP( cerr << "literal reserve " << l.u << " " << l.f << "\n"; );
+ PSC_DUMP( sblog << "literal reserve " << l.u << " " << l.f << "\n"; );
for (unsigned i = 0; i < MAX_ALU_LITERALS; ++i) {
if (lt[i] == 0) {
lt[i] = l;
++uc[i];
- PSC_DUMP( cerr << " reserved new uc = " << uc[i] << "\n"; );
+ PSC_DUMP( sblog << " reserved new uc = " << uc[i] << "\n"; );
return true;
} else if (lt[i] == l) {
++uc[i];
- PSC_DUMP( cerr << " reserved uc = " << uc[i] << "\n"; );
+ PSC_DUMP( sblog << " reserved uc = " << uc[i] << "\n"; );
return true;
}
}
- PSC_DUMP( cerr << " failed to reserve literal\n"; );
+ PSC_DUMP( sblog << " failed to reserve literal\n"; );
return false;
}
void literal_tracker::unreserve(literal l) {
- PSC_DUMP( cerr << "literal unreserve " << l.u << " " << l.f << "\n"; );
+ PSC_DUMP( sblog << "literal unreserve " << l.u << " " << l.f << "\n"; );
for (unsigned i = 0; i < MAX_ALU_LITERALS; ++i) {
if (lt[i] == l) {
void alu_group_tracker::discard_all_slots(container_node &removed_nodes) {
- PSC_DUMP( cerr << "agt::discard_all_slots\n"; );
+ PSC_DUMP( sblog << "agt::discard_all_slots\n"; );
discard_slots(~available_slots & ((1 << max_slots) - 1), removed_nodes);
}
container_node &removed_nodes) {
PSC_DUMP(
- cerr << "discard_slots : packed_ops : " << packed_ops.size() << "\n";
+ sblog << "discard_slots : packed_ops : " << packed_ops.size() << "\n";
);
for (node_vec::iterator N, I = packed_ops.begin();
unsigned pslots = n->get_slot_mask();
PSC_DUMP(
- cerr << "discard_slots : packed slot_mask : " << pslots << "\n";
+ sblog << "discard_slots : packed slot_mask : " << pslots << "\n";
);
if (pslots & slot_mask) {
PSC_DUMP(
- cerr << "discard_slots : discarding packed...\n";
+ sblog << "discard_slots : discarding packed...\n";
);
removed_nodes.push_back(n);
assert(!(slots[slot]->bc.slot_flags & AF_4SLOT));
PSC_DUMP(
- cerr << "discarding slot " << slot << " : ";
+ sblog << "discarding slot " << slot << " : ";
dump::dump_op(slots[slot]);
- cerr << "\n";
+ sblog << "\n";
);
removed_nodes.push_back(slots[slot]);
unsigned chan = t->bc.dst_chan;
if (!slots[chan]) {
PSC_DUMP(
- cerr << "moving ";
+ sblog << "moving ";
dump::dump_op(t);
- cerr << " from trans slot to free slot " << chan << "\n";
+ sblog << " from trans slot to free slot " << chan << "\n";
);
slots[chan] = t;
while (1) {
PSC_DUMP(
- cerr << " bs: trying s" << i << " bs:" << a->bc.bank_swizzle
+ sblog << " bs: trying s" << i << " bs:" << a->bc.bank_swizzle
<< " bt:" << backtrack << "\n";
);
if (!backtrack && gpr.try_reserve(a)) {
PSC_DUMP(
- cerr << " bs: reserved s" << i << " bs:" << a->bc.bank_swizzle
+ sblog << " bs: reserved s" << i << " bs:" << a->bc.bank_swizzle
<< "\n";
);
++a->bc.bank_swizzle;
PSC_DUMP(
- cerr << " bs: inc s" << i << " bs:" << a->bc.bank_swizzle
+ sblog << " bs: inc s" << i << " bs:" << a->bc.bank_swizzle
<< "\n";
);
break;
a = slots[i];
PSC_DUMP(
- cerr << " bs: unreserve s" << i << " bs:" << a->bc.bank_swizzle
+ sblog << " bs: unreserve s" << i << " bs:" << a->bc.bank_swizzle
<< "\n";
);
gpr.unreserve(a);
for (int i = max_slots - 1; i >= 0; --i) {
if (s[i] && !try_reserve(s[i])) {
- cerr << "alu_group_tracker: reinit error on slot " << i << "\n";
+ sblog << "alu_group_tracker: reinit error on slot " << i << "\n";
for (unsigned i = 0; i < max_slots; ++i) {
- cerr << " slot " << i << " : ";
+ sblog << " slot " << i << " : ";
if (s[i])
dump::dump_op(s[i]);
- cerr << "\n";
+ sblog << "\n";
}
assert(!"alu_group_tracker: reinit error");
}
void post_scheduler::schedule_bb(bb_node* bb) {
PSC_DUMP(
- cerr << "scheduling BB " << bb->id << "\n";
+ sblog << "scheduling BB " << bb->id << "\n";
if (!pending.empty())
dump::dump_op_list(&pending);
);
while ((n = bb_pending.back())) {
PSC_DUMP(
- cerr << "post_sched_bb ";
+ sblog << "post_sched_bb ";
dump::dump_op(n);
- cerr << "\n";
+ sblog << "\n";
);
if (n->subtype == NST_ALU_CLAUSE) {
regmap.clear();
PSC_DUMP(
- cerr << "init_regmap: live: ";
+ sblog << "init_regmap: live: ";
dump::dump_set(sh, live);
- cerr << "\n";
+ sblog << "\n";
);
for (val_set::iterator I = live.begin(sh), E = live.end(sh); I != E; ++I) {
sel_chan r = v->gpr;
PSC_DUMP(
- cerr << "init_regmap: " << r << " <= ";
+ sblog << "init_regmap: " << r << " <= ";
dump::dump_val(v);
- cerr << "\n";
+ sblog << "\n";
);
assert(r);
unsigned uc = init_ucm(c, n);
PSC_DUMP(
- cerr << "process_alu uc=" << uc << " ";
+ sblog << "process_alu uc=" << uc << " ";
dump::dump_op(n);
- cerr << " ";
+ sblog << " ";
);
if (uc) {
n->remove();
pending.push_back(n);
- PSC_DUMP( cerr << "pending\n"; );
+ PSC_DUMP( sblog << "pending\n"; );
} else {
release_op(n);
}
void post_scheduler::update_local_interferences() {
PSC_DUMP(
- cerr << "update_local_interferences : ";
+ sblog << "update_local_interferences : ";
dump::dump_set(sh, live);
- cerr << "\n";
+ sblog << "\n";
);
if (!v->is_prealloc()) {
if (!cleared_interf.contains(v)) {
PSC_DUMP(
- cerr << "clearing interferences for " << *v << "\n";
+ sblog << "clearing interferences for " << *v << "\n";
);
v->interferences.clear();
cleared_interf.add_val(v);
} else if (v->is_any_gpr()) {
if (!live.remove_val(v)) {
PSC_DUMP(
- cerr << "failed to remove ";
+ sblog << "failed to remove ";
dump::dump_val(v);
- cerr << " from live : ";
+ sblog << " from live : ";
dump::dump_set(sh, live);
- cerr << "\n";
+ sblog << "\n";
);
}
}
recolor_locals();
PSC_DUMP(
- cerr << "process_group: live_before : ";
+ sblog << "process_group: live_before : ";
dump::dump_set(sh, live);
- cerr << "\n";
+ sblog << "\n";
);
for (unsigned s = 0; s < ctx.num_slots; ++s) {
}
PSC_DUMP(
- cerr << "process_group: live_after : ";
+ sblog << "process_group: live_after : ";
dump::dump_set(sh, live);
- cerr << "\n";
+ sblog << "\n";
);
update_local_interferences();
void post_scheduler::init_globals(val_set &s, bool prealloc) {
PSC_DUMP(
- cerr << "init_globals: ";
+ sblog << "init_globals: ";
dump::dump_set(sh, s);
- cerr << "\n";
+ sblog << "\n";
);
for (val_set::iterator I = s.begin(sh), E = s.end(sh); I != E; ++I) {
}
if (!ready.empty()) {
- cerr << "##post_scheduler: unscheduled ready instructions :";
+ sblog << "##post_scheduler: unscheduled ready instructions :";
dump::dump_op_list(&ready);
assert(!"unscheduled ready instructions");
}
if (!pending.empty()) {
- cerr << "##post_scheduler: unscheduled pending instructions :";
+ sblog << "##post_scheduler: unscheduled pending instructions :";
dump::dump_op_list(&pending);
assert(!"unscheduled pending instructions");
}
unsigned r = gpr.sel();
PSC_DUMP(
- cerr << "\tadd_interferences: " << *vi << "\n";
+ sblog << "\tadd_interferences: " << *vi << "\n";
);
if (rb.size() <= r)
v->gpr = color;
PSC_DUMP(
- cerr << " recolored: ";
+ sblog << " recolored: ";
dump::dump_val(v);
- cerr << "\n";
+ sblog << "\n";
);
}
unsigned chan = v->gpr.chan();
PSC_DUMP(
- cerr << "recolor_local: ";
+ sblog << "recolor_local: ";
dump::dump_val(v);
- cerr << " interferences: ";
+ sblog << " interferences: ";
dump::dump_set(sh, v->interferences);
- cerr << "\n";
+ sblog << "\n";
if (v->chunk) {
- cerr << " in chunk: ";
+ sblog << " in chunk: ";
coalescer::dump_chunk(v->chunk);
- cerr << "\n";
+ sblog << "\n";
}
);
E = v->chunk->values.end(); I != E; ++I) {
value *v2 = *I;
- PSC_DUMP( cerr << " add_interferences for " << *v2 << " :\n"; );
+ PSC_DUMP( sblog << " add_interferences for " << *v2 << " :\n"; );
add_interferences(v, rb, v2->interferences);
}
PSC_DUMP(
unsigned sz = rb.size();
- cerr << "registers bits: " << sz;
+ sblog << "registers bits: " << sz;
for (unsigned r = 0; r < sz; ++r) {
if ((r & 7) == 0)
- cerr << "\n " << r << " ";
- cerr << (rb.get(r) ? 1 : 0);
+ sblog << "\n " << r << " ";
+ sblog << (rb.get(r) ? 1 : 0);
}
);
alu_node *a = alu.create_ar_load();
if (!rt.try_reserve(a)) {
- cerr << "can't emit AR load : ";
+ sblog << "can't emit AR load : ";
dump::dump_op(a);
- cerr << "\n";
+ sblog << "\n";
}
alu.current_ar = 0;
if (c && c!=d && (!c->chunk || c->chunk != d->chunk)) {
PSC_DUMP(
- cerr << "dst value conflict : ";
+ sblog << "dst value conflict : ";
dump::dump_val(d);
- cerr << " regmap contains ";
+ sblog << " regmap contains ";
dump::dump_val(c);
- cerr << "\n";
+ sblog << "\n";
);
assert(!"scheduler error");
return false;
if (d->is_AR()) {
if (alu.current_ar != d) {
- cerr << "loading wrong ar value\n";
+ sblog << "loading wrong ar value\n";
assert(0);
} else {
alu.current_ar = NULL;
c = F->second;
if (!v->v_equal(c)) {
PSC_DUMP(
- cerr << "can't map src value ";
+ sblog << "can't map src value ";
dump::dump_val(v);
- cerr << ", regmap contains ";
+ sblog << ", regmap contains ";
dump::dump_val(c);
- cerr << "\n";
+ sblog << "\n";
);
return false;
}
if (rel != alu.current_ar) {
if (alu.current_ar) {
PSC_DUMP(
- cerr << " current_AR is " << *alu.current_ar
+ sblog << " current_AR is " << *alu.current_ar
<< " trying to use " << *rel << "\n";
);
return false;
alu.current_ar = rel;
PSC_DUMP(
- cerr << " new current_AR assigned: " << *alu.current_ar
+ sblog << " new current_AR assigned: " << *alu.current_ar
<< "\n";
);
}
void post_scheduler::dump_regmap() {
- cerr << "# REGMAP :\n";
+ sblog << "# REGMAP :\n";
for(rv_map::iterator I = regmap.begin(), E = regmap.end(); I != E; ++I) {
- cerr << " # " << I->first << " => " << *(I->second) << "\n";
+ sblog << " # " << I->first << " => " << *(I->second) << "\n";
}
if (alu.current_ar)
- cerr << " current_AR: " << *alu.current_ar << "\n";
+ sblog << " current_AR: " << *alu.current_ar << "\n";
if (alu.current_pr)
- cerr << " current_PR: " << *alu.current_pr << "\n";
+ sblog << " current_PR: " << *alu.current_pr << "\n";
}
void post_scheduler::recolor_locals() {
bool discarded = false;
PSC_DUMP(
- cerr << "check_interferences: before: \n";
+ sblog << "check_interferences: before: \n";
dump_regmap();
);
PSC_DUMP(
for (unsigned i = 0; i < 5; ++i) {
if (interf_slots & (1 << i)) {
- cerr << "!!!!!! interf slot: " << i << " : ";
+ sblog << "!!!!!! interf slot: " << i << " : ";
dump::dump_op(rt.slot(i));
- cerr << "\n";
+ sblog << "\n";
}
}
);
if (!interf_slots)
break;
- PSC_DUMP( cerr << "ci: discarding slots " << interf_slots << "\n"; );
+ PSC_DUMP( sblog << "ci: discarding slots " << interf_slots << "\n"; );
rt.discard_slots(interf_slots, alu.conflict_nodes);
regmap = prev_regmap;
} while(1);
PSC_DUMP(
- cerr << "check_interferences: after: \n";
+ sblog << "check_interferences: after: \n";
dump_regmap();
);
unsigned cnt = __builtin_popcount(slots);
if ((slots & avail_slots) != slots) {
- PSC_DUMP( cerr << " no slots \n"; );
+ PSC_DUMP( sblog << " no slots \n"; );
return 0;
}
p->update_packed_items(ctx);
if (!rt.try_reserve(p)) {
- PSC_DUMP( cerr << " reservation failed \n"; );
+ PSC_DUMP( sblog << " reservation failed \n"; );
return 0;
}
}
if (!allowed_slots) {
- PSC_DUMP( cerr << " no suitable slots\n"; );
+ PSC_DUMP( sblog << " no suitable slots\n"; );
return 0;
}
slot = __builtin_ctz(allowed_slots);
a->bc.slot = slot;
- PSC_DUMP( cerr << "slot: " << slot << "\n"; );
+ PSC_DUMP( sblog << "slot: " << slot << "\n"; );
if (!rt.try_reserve(a)) {
- PSC_DUMP( cerr << " reservation failed\n"; );
+ PSC_DUMP( sblog << " reservation failed\n"; );
return 0;
}
if (s->gpr == d->gpr) {
PSC_DUMP(
- cerr << "check_copy: ";
+ sblog << "check_copy: ";
dump::dump_op(n);
- cerr << "\n";
+ sblog << "\n";
);
rv_map::iterator F = regmap.find(d->gpr);
if (d->is_prealloc()) {
if (gpr_free) {
- PSC_DUMP( cerr << " copy not ready...\n";);
+ PSC_DUMP( sblog << " copy not ready...\n";);
return true;
}
value *rv = F->second;
if (rv != d && (!rv->chunk || rv->chunk != d->chunk)) {
- PSC_DUMP( cerr << " copy not ready(2)...\n";);
+ PSC_DUMP( sblog << " copy not ready(2)...\n";);
return true;
}
release_src_values(n);
n->remove();
- PSC_DUMP( cerr << " copy coalesced...\n";);
+ PSC_DUMP( sblog << " copy coalesced...\n";);
return true;
}
return false;
for (unsigned i = 0; i < 5; ++i) {
node *n = rt.slot(i);
if (n) {
- cerr << "slot " << i << " : ";
+ sblog << "slot " << i << " : ";
dump::dump_op(n);
- cerr << "\n";
+ sblog << "\n";
}
}
}
unsigned i1 = 0;
PSC_DUMP(
- cerr << "prepare_alu_group: starting...\n";
+ sblog << "prepare_alu_group: starting...\n";
dump_group(rt);
);
node *n = *I;
PSC_DUMP(
- cerr << "p_a_g: ";
+ sblog << "p_a_g: ";
dump::dump_op(n);
- cerr << "\n";
+ sblog << "\n";
);
continue;
PSC_DUMP(
- cerr << "current group:\n";
+ sblog << "current group:\n";
dump_group(rt);
);
if (rt.inst_count() == ctx.num_slots) {
- PSC_DUMP( cerr << " all slots used\n"; );
+ PSC_DUMP( sblog << " all slots used\n"; );
break;
}
}
} while (1);
PSC_DUMP(
- cerr << " prepare_alu_group done, " << rt.inst_count()
+ sblog << " prepare_alu_group done, " << rt.inst_count()
<< " slot(s) \n";
- cerr << "$$$$$$$$PAG i1=" << i1
+ sblog << "$$$$$$$$PAG i1=" << i1
<< " ready " << ready.count()
<< " pending " << pending.count()
<< " conflicting " << alu.conflict_nodes.count()
void post_scheduler::release_op(node *n) {
PSC_DUMP(
- cerr << "release_op ";
+ sblog << "release_op ";
dump::dump_op(n);
- cerr << "\n";
+ sblog << "\n";
);
n->remove();
new_group();
- PSC_DUMP( cerr << " #### group emitted\n"; );
+ PSC_DUMP( sblog << " #### group emitted\n"; );
}
void alu_clause_tracker::emit_clause(container_node *c) {
slot_count = 0;
kt.reset();
- PSC_DUMP( cerr << "######### ALU clause emitted\n"; );
+ PSC_DUMP( sblog << "######### ALU clause emitted\n"; );
}
bool alu_clause_tracker::check_clause_limits() {
g->literals.push_back(lt[i]);
PSC_DUMP(
- cerr << "literal emitted: " << lt[i].f
+ sblog << "literal emitted: " << lt[i].f
<< " 0x" << std::hex << lt[i].u
<< std::dec << " " << lt[i].i << "\n";
);
a->src.push_back(current_ar);
PSC_DUMP(
- cerr << "created AR load: ";
+ sblog << "created AR load: ";
dump::dump_op(a);
- cerr << "\n";
+ sblog << "\n";
);
return a;
}
void alu_clause_tracker::discard_current_group() {
- PSC_DUMP( cerr << "act::discard_current_group\n"; );
+ PSC_DUMP( sblog << "act::discard_current_group\n"; );
grp().discard_all_slots(conflict_nodes);
}
void rp_gpr_tracker::dump() {
- cerr << "=== gpr_tracker dump:\n";
+ sblog << "=== gpr_tracker dump:\n";
for (int c = 0; c < 3; ++c) {
- cerr << "cycle " << c << " ";
+ sblog << "cycle " << c << " ";
for (int h = 0; h < 4; ++h) {
- cerr << rp[c][h] << ":" << uc[c][h] << " ";
+ sblog << rp[c][h] << ":" << uc[c][h] << " ";
}
- cerr << "\n";
+ sblog << "\n";
}
}
#include "sb_bc.h"
#include "sb_shader.h"
-
#include "sb_pass.h"
namespace r600_sb {
-using std::cerr;
-
shader::shader(sb_context &sctx, shader_target t, unsigned id)
: ctx(sctx), next_temp_value_index(temp_regid_offset),
prep_regs_count(), pred_sels(),
gpr_array *a = new gpr_array(
sel_chan(gpr_start, chan), gpr_count);
- SB_DUMP_PASS( cerr << "add_gpr_array: @" << a->base_gpr
+ SB_DUMP_PASS( sblog << "add_gpr_array: @" << a->base_gpr
<< " [" << a->array_size << "]\n";
);
cf += s.cf;
}
-void shader_stats::dump(std::ostream& o) {
- o << "dw:" << ndw << ", gpr:" << ngpr << ", stk:" << nstack
+void shader_stats::dump() {
+ sblog << "dw:" << ndw << ", gpr:" << ngpr << ", stk:" << nstack
<< ", alu groups:" << alu_groups << ", alu clauses: " << alu_clauses
<< ", alu:" << alu << ", fetch:" << fetch
<< ", fetch clauses:" << fetch_clauses
<< ", cf:" << cf;
if (shaders > 1)
- o << ", shaders:" << shaders;
+ sblog << ", shaders:" << shaders;
- o << "\n";
+ sblog << "\n";
}
-static void print_diff(std::ostream &o, unsigned d1, unsigned d2) {
+static void print_diff(unsigned d1, unsigned d2) {
if (d1)
- o << ((int)d2 - (int)d1) * 100 / (int)d1 << "%";
+ sblog << ((int)d2 - (int)d1) * 100 / (int)d1 << "%";
else if (d2)
- o << "N/A";
+ sblog << "N/A";
else
- o << "0%";
-}
-
-void shader_stats::dump_diff(std::ostream& o, shader_stats& s) {
- o << "dw:"; print_diff(o, ndw, s.ndw);
- o << ", gpr:" ; print_diff(o, ngpr, s.ngpr);
- o << ", stk:" ; print_diff(o, nstack, s.nstack);
- o << ", alu groups:" ; print_diff(o, alu_groups, s.alu_groups);
- o << ", alu clauses: " ; print_diff(o, alu_clauses, s.alu_clauses);
- o << ", alu:" ; print_diff(o, alu, s.alu);
- o << ", fetch:" ; print_diff(o, fetch, s.fetch);
- o << ", fetch clauses:" ; print_diff(o, fetch_clauses, s.fetch_clauses);
- o << ", cf:" ; print_diff(o, cf, s.cf);
- o << "\n";
+ sblog << "0%";
+}
+
+void shader_stats::dump_diff(shader_stats& s) {
+ sblog << "dw:"; print_diff(ndw, s.ndw);
+ sblog << ", gpr:" ; print_diff(ngpr, s.ngpr);
+ sblog << ", stk:" ; print_diff(nstack, s.nstack);
+ sblog << ", alu groups:" ; print_diff(alu_groups, s.alu_groups);
+ sblog << ", alu clauses: " ; print_diff(alu_clauses, s.alu_clauses);
+ sblog << ", alu:" ; print_diff(alu, s.alu);
+ sblog << ", fetch:" ; print_diff(fetch, s.fetch);
+ sblog << ", fetch clauses:" ; print_diff(fetch_clauses, s.fetch_clauses);
+ sblog << ", cf:" ; print_diff(cf, s.cf);
+ sblog << "\n";
}
} // namespace r600_sb
#define VT_DUMP(q)
#endif
-#include <iostream>
#include <cstring>
#include "sb_shader.h"
namespace r600_sb {
-using std::cerr;
-
static const char * chans = "xyzw01?_";
-std::ostream& operator << (std::ostream &o, value &v) {
+sb_ostream& operator << (sb_ostream &o, value &v) {
bool dead = v.flags & VLF_DEAD;
}
break;
case VLK_CONST:
- o << v.literal_value.f << "|" << std::hex
- << std::showbase << v.literal_value.u
- << std::dec << std::noshowbase;
+ o << v.literal_value.f << "|";
+ o.print_zw_hex(v.literal_value.u, 8);
break;
case VLK_PARAM:
o << "Param" << (v.select.sel() - ALU_SRC_PARAM_OFFSET)
}
VT_DUMP(
- cerr << "gvn add_value ";
+ sblog << "gvn add_value ";
dump::dump_val(v);
);
if (v->def && ex.try_fold(v)) {
VT_DUMP(
- cerr << " folded: ";
+ sblog << " folded: ";
dump::dump_val(v->gvn_source);
- cerr << "\n";
+ sblog << "\n";
);
return;
}
v->gvn_source = c->gvn_source;
VT_DUMP(
- cerr << " found : equal to ";
+ sblog << " found : equal to ";
dump::dump_val(v->gvn_source);
- cerr << "\n";
+ sblog << "\n";
);
return;
}
v->gvn_source = v;
VT_DUMP(
- cerr << " added new\n";
+ sblog << " added new\n";
);
}
void value::add_use(node* n, use_kind kind, int arg) {
if (0) {
- cerr << "add_use ";
+ sblog << "add_use ";
dump::dump_val(this);
- cerr << " => ";
+ sblog << " => ";
dump::dump_op(n);
- cerr << " kind " << kind << " arg " << arg << "\n";
+ sblog << " kind " << kind << " arg " << arg << "\n";
}
uses = new use_info(n, kind, arg, uses);
}