r600g/sb: get rid of standard c++ streams
authorVadim Girlin <vadimgirlin@gmail.com>
Tue, 14 May 2013 13:08:38 +0000 (17:08 +0400)
committerVadim Girlin <vadimgirlin@gmail.com>
Tue, 14 May 2013 13:36:25 +0000 (17:36 +0400)
Static initialization of internal libstdc++ data related to iostream
causes segfaults with some apps.

This patch replaces all uses of std::ostream and std::ostringstream in sb
with custom lightweight classes.

Prevents segfaults with ut2004demo and probably some other old apps.

Signed-off-by: Vadim Girlin <vadimgirlin@gmail.com>
24 files changed:
src/gallium/drivers/r600/sb/sb_bc.h
src/gallium/drivers/r600/sb/sb_bc_builder.cpp
src/gallium/drivers/r600/sb/sb_bc_decoder.cpp
src/gallium/drivers/r600/sb/sb_bc_dump.cpp
src/gallium/drivers/r600/sb/sb_bc_finalize.cpp
src/gallium/drivers/r600/sb/sb_bc_parser.cpp
src/gallium/drivers/r600/sb/sb_context.cpp
src/gallium/drivers/r600/sb/sb_core.cpp
src/gallium/drivers/r600/sb/sb_def_use.cpp
src/gallium/drivers/r600/sb/sb_dump.cpp
src/gallium/drivers/r600/sb/sb_gcm.cpp
src/gallium/drivers/r600/sb/sb_gvn.cpp
src/gallium/drivers/r600/sb/sb_if_conversion.cpp
src/gallium/drivers/r600/sb/sb_ir.cpp
src/gallium/drivers/r600/sb/sb_ir.h
src/gallium/drivers/r600/sb/sb_liveness.cpp
src/gallium/drivers/r600/sb/sb_pass.h
src/gallium/drivers/r600/sb/sb_peephole.cpp
src/gallium/drivers/r600/sb/sb_ra_checker.cpp
src/gallium/drivers/r600/sb/sb_ra_coalesce.cpp
src/gallium/drivers/r600/sb/sb_ra_init.cpp
src/gallium/drivers/r600/sb/sb_sched.cpp
src/gallium/drivers/r600/sb/sb_shader.cpp
src/gallium/drivers/r600/sb/sb_valtable.cpp

index 9f65098848df1d6437b0469818c7007cf1ae777a..8b932634c551f75adeb52f37c074600e325aa9dd 100644 (file)
@@ -32,9 +32,10 @@ extern "C" {
 #include "r600_isa.h"
 }
 
+#include <cstdio>
+#include <string>
 #include <vector>
 #include <stack>
-#include <ostream>
 
 struct r600_bytecode;
 struct r600_shader;
@@ -50,6 +51,120 @@ class alu_group_node;
 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,
@@ -477,8 +592,8 @@ struct shader_stats {
 
        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 {
index f40e4694b8d738f672297a515f0cc078eb0a197a..55e2a8508ece4da1b20f6221f43a292c54bfb6a5 100644 (file)
  *      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) {}
 
index 273969f473b6e5a903e3c93dea14138686aafa28..5e233f982ea3aa26ec2a28cc533c4b35e40e8524 100644 (file)
@@ -24,8 +24,6 @@
  *      Vadim Girlin
  */
 
-#include "sstream"
-
 #include "sb_bc.h"
 
 namespace r600_sb {
index 28ae32c230012e2d996c685981b2232be339ceff..9d76465b36fae7fb5257bf7eca4c99ebd080a37d 100644 (file)
@@ -24,9 +24,6 @@
  *      Vadim Girlin
  */
 
-#include <sstream>
-#include <iomanip>
-
 #include "sb_bc.h"
 #include "sb_shader.h"
 #include "sb_pass.h"
@@ -52,7 +49,7 @@ bool bc_dump::visit(cf_node& n, bool enter) {
                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);
@@ -68,13 +65,14 @@ bool bc_dump::visit(cf_node& n, bool enter) {
 
 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;
@@ -86,10 +84,10 @@ bool bc_dump::visit(alu_node& n, bool enter) {
                                        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;
@@ -101,7 +99,7 @@ bool bc_dump::visit(alu_node& n, bool enter) {
 
 bool bc_dump::visit(fetch_node& n, bool enter) {
        if (enter) {
-               o << " ";
+               sblog << " ";
                dump_dw(id, 3);
                dump(n);
                id += 4;
@@ -109,31 +107,31 @@ bool bc_dump::visit(fetch_node& n, bool enter) {
        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)
@@ -143,9 +141,9 @@ void bc_dump::dump(cf_node& n) {
                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] : '_');
 
@@ -194,11 +192,11 @@ void bc_dump::dump(cf_node& n) {
        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";
@@ -217,7 +215,7 @@ static void print_sel(std::ostream &s, int sel, int rel, int index_mode,
        }
 }
 
-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';
@@ -236,7 +234,7 @@ static void print_dst(std::ostream &s, bc_alu &alu)
        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;
@@ -282,10 +280,9 @@ static void print_src(std::ostream &s, bc_alu &alu, unsigned idx)
                        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:
@@ -320,14 +317,14 @@ static void print_src(std::ostream &s, bc_alu &alu, unsigned idx)
                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] << ": ";
@@ -350,11 +347,11 @@ void bc_dump::dump(alu_node& n) {
                        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)
@@ -370,9 +367,9 @@ int bc_dump::init() {
 
        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
@@ -382,25 +379,25 @@ int bc_dump::init() {
        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) {
@@ -410,7 +407,7 @@ bc_dump::bc_dump(shader& s, std::ostream& o, bytecode* 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;
@@ -462,7 +459,7 @@ void bc_dump::dump(fetch_node& n) {
                                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) {
@@ -471,11 +468,12 @@ 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
index c883e5e5a67f4df8085aac76fc58a79ad889f488..c56c866bafc222dad44f1ef5dabf6f749d8b57ba 100644 (file)
 #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();
@@ -294,9 +288,9 @@ void bc_finalizer::finalize_alu_src(alu_group_node* g, alu_node* a) {
        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;
@@ -417,9 +411,9 @@ void bc_finalizer::emit_set_grad(fetch_node* f) {
                                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();
                                }
 
@@ -430,18 +424,18 @@ void bc_finalizer::emit_set_grad(fetch_node* f) {
                                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();
                        }
 
@@ -492,9 +486,9 @@ void bc_finalizer::finalize_fetch(fetch_node* f) {
                        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();
                        }
 
@@ -505,18 +499,18 @@ void bc_finalizer::finalize_fetch(fetch_node* f) {
                        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();
                }
 
@@ -552,18 +546,18 @@ void bc_finalizer::finalize_fetch(fetch_node* f) {
                        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();
                }
 
@@ -615,9 +609,9 @@ void bc_finalizer::finalize_cf(cf_node* c) {
                                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();
                                }
 
@@ -628,18 +622,18 @@ void bc_finalizer::finalize_cf(cf_node* c) {
                                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();
                        }
 
@@ -662,18 +656,18 @@ void bc_finalizer::finalize_cf(cf_node* c) {
                                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();
                        }
 
@@ -698,18 +692,18 @@ void bc_finalizer::finalize_cf(cf_node* c) {
                                        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();
                                }
                        }
index 9f3ecc51cd9c907836124542a59de1577a01b150..a78ca4b91d80b9b7da8337a3f89d64cc972a5bd0 100644 (file)
@@ -45,8 +45,6 @@ extern "C" {
 
 namespace r600_sb {
 
-using std::cerr;
-
 int bc_parser::decode() {
 
        dw = bc->bytecode;
@@ -728,22 +726,22 @@ int bc_parser::prepare_if(cf_node* c) {
        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;
index 034631376b5a54ade73ba82459c0e0a8c86aee1d..9723a841c99aee1264bb9b116f0d162dd5aed24c 100644 (file)
@@ -28,6 +28,8 @@
 
 namespace r600_sb {
 
+sb_log sblog;
+
 unsigned sb_context::dump_pass = 0;
 unsigned sb_context::dump_stat = 0;
 unsigned sb_context::dry_run = 0;
index 17a8b878e0f69b340fdb6c8ef279e37f76f14996..f0755ddfdd4a8c95d562424a6220075689141f76 100644 (file)
@@ -36,7 +36,6 @@ extern "C" {
 
 #include <stack>
 #include <map>
-#include <iostream>
 
 #include "sb_bc.h"
 #include "sb_shader.h"
@@ -45,8 +44,6 @@ extern "C" {
 
 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);
 
@@ -79,12 +76,12 @@ void r600_sb_context_destroy(void * sctx) {
                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;
@@ -109,7 +106,7 @@ int r600_sb_bytecode_process(struct r600_context *rctx,
                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);
 
@@ -121,7 +118,7 @@ int r600_sb_bytecode_process(struct r600_context *rctx,
        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) {
@@ -146,7 +143,7 @@ int r600_sb_bytecode_process(struct r600_context *rctx,
                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";
@@ -159,21 +156,21 @@ int r600_sb_bytecode_process(struct r600_context *rctx,
                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); \
@@ -240,7 +237,7 @@ int r600_sb_bytecode_process(struct r600_context *rctx,
        bytecode &nbc = builder.get_bytecode();
 
        if (dump_bytecode) {
-               bc_dump(*sh, cerr, &nbc).run();
+               bc_dump(*sh, &nbc).run();
        }
 
        if (!sb_context::dry_run) {
@@ -253,24 +250,24 @@ int r600_sb_bytecode_process(struct r600_context *rctx,
                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;
index f35f592c929410a0b0e658f4dd31d0ca67d24855..a512d9208659d6f97926b780ea9c5b47f2d58991 100644 (file)
  */
 
 #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);
@@ -57,9 +54,9 @@ void def_use::run_on(node* n, bool defs) {
        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)
index c2ee34dc0afbf03b0e5c71158b9afec81c5e700a..7e317abe7a7f5d73da0813b756d2eb18fa7944ea 100644 (file)
  *      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();
@@ -54,7 +48,7 @@ bool dump::visit(node& n, bool enter) {
                                assert(!"invalid node subtype");
                                break;
                }
-               cerr << "\n";
+               sblog << "\n";
        }
        return false;
 }
@@ -64,11 +58,11 @@ bool dump::visit(container_node& n, bool enter) {
                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);
                }
@@ -77,11 +71,11 @@ bool dump::visit(container_node& n, bool enter) {
                --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);
                }
@@ -93,13 +87,13 @@ bool dump::visit(bb_node& n, bool enter) {
        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;
@@ -109,7 +103,7 @@ bool dump::visit(alu_group_node& n, bool enter) {
        if (enter) {
                indent();
                dump_flags(n);
-               cerr << "[  ";
+               sblog << "[  ";
                dump_live_values(n, true);
 
                ++level;
@@ -117,7 +111,7 @@ bool dump::visit(alu_group_node& n, bool enter) {
                --level;
 
                indent();
-               cerr << "]  ";
+               sblog << "]  ";
                dump_live_values(n, false);
        }
        return true;
@@ -130,15 +124,15 @@ bool dump::visit(cf_node& n, bool enter) {
                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);
                }
 
@@ -147,7 +141,7 @@ bool dump::visit(cf_node& n, bool enter) {
                --level;
                if (!n.empty()) {
                        indent();
-                       cerr << ">  ";
+                       sblog << ">  ";
                        dump_live_values(n, false);
                }
        }
@@ -160,7 +154,7 @@ bool dump::visit(alu_node& n, bool enter) {
                dump_flags(n);
                dump_alu(&n);
                dump_common(n);
-               cerr << "\n";
+               sblog << "\n";
 
                ++level;
        } else {
@@ -175,7 +169,7 @@ bool dump::visit(alu_packed_node& n, bool enter) {
                indent();
                dump_flags(n);
                dump_op(n, n.op_ptr()->name);
-               cerr << "  ";
+               sblog << "  ";
                dump_live_values(n, true);
 
                ++level;
@@ -196,7 +190,7 @@ bool dump::visit(fetch_node& n, bool enter) {
                indent();
                dump_flags(n);
                dump_op(n, n.bc.op_ptr->name);
-               cerr << "\n";
+               sblog << "\n";
 
                ++level;
        } else {
@@ -209,11 +203,11 @@ bool dump::visit(region_node& n, bool enter) {
        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);
                }
 
@@ -239,10 +233,10 @@ bool dump::visit(repeat_node& n, bool enter) {
        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;
@@ -251,7 +245,7 @@ bool dump::visit(repeat_node& n, bool enter) {
 
                if (!n.empty()) {
                        indent();
-                       cerr << "} end_repeat   ";
+                       sblog << "} end_repeat   ";
                        dump_live_values(n, false);
                }
        }
@@ -262,10 +256,10 @@ bool dump::visit(depart_node& n, bool enter) {
        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;
@@ -273,7 +267,7 @@ bool dump::visit(depart_node& n, bool enter) {
                --level;
                if (!n.empty()) {
                        indent();
-                       cerr << "} end_depart   ";
+                       sblog << "} end_depart   ";
                        dump_live_values(n, false);
                }
        }
@@ -284,26 +278,26 @@ bool dump::visit(if_node& n, bool enter) {
        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) {
@@ -311,14 +305,14 @@ 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 << "__";
                }
        }
 }
@@ -330,10 +324,10 @@ void dump::dump_rels(vvec & vv) {
                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);
        }
 }
@@ -342,10 +336,10 @@ void dump::dump_op(node &n, const char *name) {
 
        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();
 
@@ -353,34 +347,34 @@ void dump::dump_op(node &n, const char *name) {
                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) {
@@ -388,46 +382,46 @@ 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;
@@ -437,18 +431,18 @@ void dump::dump_alu(alu_node *n) {
                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);
@@ -495,30 +489,30 @@ void dump::dump_op(node* n) {
 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
index 2bae0a357260f0ae4d5862249c43a60e7665cd9e..b09008c6f0851e9dfaaf9532fe1b7b1df0385dea 100644 (file)
 #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);
 
@@ -59,17 +55,17 @@ int gcm::run() {
                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);
@@ -80,7 +76,7 @@ int gcm::run() {
        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());
        }
 
@@ -88,7 +84,7 @@ int gcm::run() {
 
        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);
 
@@ -96,7 +92,7 @@ int gcm::run() {
 
        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());
        }
 
@@ -163,9 +159,9 @@ void gcm::sched_early(container_node *n) {
 
 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);
 
@@ -177,7 +173,7 @@ void gcm::td_schedule(bb_node *bb, node *n) {
 
 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()) {
@@ -197,9 +193,9 @@ bool gcm::td_is_ready(node* n) {
 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;
@@ -210,16 +206,16 @@ void gcm::td_release_val(value *v) {
                }
 
                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);
@@ -288,14 +284,14 @@ void gcm::sched_late(container_node *n) {
 
 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,
@@ -307,7 +303,7 @@ void gcm::bu_sched_bb(bb_node* bb) {
                }
                pending_nodes.clear();
                GCM_DUMP(
-                       cerr << "pending nodes processed...\n";
+                       sblog << "pending nodes processed...\n";
                );
        }
 
@@ -390,7 +386,7 @@ void gcm::bu_sched_bb(bb_node* bb) {
                                                 !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;
                                }
 
@@ -436,7 +432,7 @@ void gcm::bu_sched_bb(bb_node* bb) {
        bu_bb = NULL;
 
        GCM_DUMP(
-               cerr << "bu finished scheduling BB_" << bb->id << "\n";
+               sblog << "bu finished scheduling BB_" << bb->id << "\n";
        );
 }
 
@@ -462,7 +458,7 @@ void gcm::bu_release_defs(vvec& v, bool src) {
 
 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;
@@ -483,9 +479,9 @@ bool gcm::bu_is_ready(node* n) {
 
 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);
@@ -497,19 +493,19 @@ void gcm::bu_schedule(container_node* c, node* n) {
 }
 
 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() {
@@ -518,7 +514,7 @@ 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";
        );
 
@@ -526,9 +522,9 @@ void gcm::pop_uc_stack() {
                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;
@@ -537,9 +533,9 @@ void gcm::pop_uc_stack() {
                        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";
                        );
                }
        }
@@ -548,9 +544,9 @@ void gcm::pop_uc_stack() {
 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)
@@ -611,7 +607,7 @@ void gcm::bu_release_op(node * n) {
        op_info &oi = op_map[n];
 
        GCM_DUMP(
-       cerr << "  bu release op  ";
+       sblog << "  bu release op  ";
        dump::dump_op(n);
        );
 
@@ -621,10 +617,10 @@ void gcm::bu_release_op(node * 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);
        }
 }
@@ -661,16 +657,16 @@ void gcm::init_use_count(nuc_map& m, container_node &s) {
                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
@@ -688,15 +684,15 @@ void gcm::bu_release_val(value* v) {
 
                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)
@@ -713,9 +709,9 @@ void gcm::init_def_count(nuc_map& m, container_node& s) {
                m[n] = dc;
 
                GCM_DUMP(
-                       cerr << "dc " << dc << "  ";
+                       sblog << "dc " << dc << "  ";
                        dump::dump_op(n);
-                       cerr << "\n";
+                       sblog << "\n";
                );
        }
 }
index fe4f884e21f1ecc35a88592554c332900370d046..12cdb1c024077a027d45c2fd15d9b9cc1ecd5356 100644 (file)
 #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) {
 
index 489b049490c6e757e23df319f43dcc70061cb598..6411d06bdf6f9b0bd7e7f597daa1cf81cb20db06 100644 (file)
 #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();
@@ -116,9 +113,9 @@ unsigned if_conversion::try_convert_kills(region_node* r) {
                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();
@@ -148,7 +145,7 @@ bool if_conversion::run_on(region_node* r) {
        r->collect_stats(s);
 
        IFC_DUMP(
-               cerr << "ifcvt: region " << r->region_id << " :\n";
+               sblog << "ifcvt: region " << r->region_id << " :\n";
                s.dump();
        );
 
@@ -198,7 +195,7 @@ bool if_conversion::run_on(region_node* r) {
                        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())
index cbb32378f91278a736cf103da89c5a641a01ea47..382fceed08c42f98a81c5e64ba4c25e38ff1bbb9 100644 (file)
@@ -30,8 +30,6 @@
 
 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); }
@@ -512,18 +510,18 @@ void region_node::expand_repeat(repeat_node *r) {
 }
 
 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() {
index 47f0a5da99c106a550493c2bb44c4d8be64f7026..d55f4de67b87d7cdd4b9e15f524b9469f8ee4861 100644 (file)
@@ -29,7 +29,6 @@
 
 #include <algorithm>
 #include <stdint.h>
-#include <iostream>
 #include <vector>
 #include <set>
 #include <algorithm>
@@ -64,7 +63,7 @@ struct sel_chan
        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;
@@ -428,7 +427,7 @@ inline value_flags& operator &=(value_flags &l, value_flags r) {
 
 struct value;
 
-std::ostream& operator << (std::ostream &o, value &v);
+sb_ostream& operator << (sb_ostream &o, value &v);
 
 typedef uint32_t value_hash;
 
index 50988d4f0bba7a323c83e6cc119d47df473a98bb..8ecc9a598728839ccafc0f360f372ab5599b0d06 100644 (file)
@@ -25,7 +25,6 @@
  */
 
 #include "sb_shader.h"
-
 #include "sb_pass.h"
 
 #define LIV_DEBUG 0
@@ -38,8 +37,6 @@
 
 namespace r600_sb {
 
-using std::cerr;
-
 bool liveness::visit(container_node& n, bool enter) {
        if (enter) {
                n.live_after = live;
@@ -191,9 +188,9 @@ void liveness::update_interferences() {
                return;
 
        LIV_DUMP(
-               cerr << "interf ";
+               sblog << "interf ";
                dump::dump_set(sh, live);
-               cerr << "\n";
+               sblog << "\n";
        );
 
        val_set& s = live;
@@ -209,11 +206,11 @@ void liveness::update_interferences() {
                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;
@@ -320,12 +317,12 @@ void liveness::process_ins(node& n) {
 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)) {
@@ -339,9 +336,9 @@ void liveness::process_op(node& n) {
        process_ins(n);
 
        LIV_DUMP(
-               cerr << "process_op: live_before:";
+               sblog << "process_op: live_before:";
                dump::dump_set(sh, live);
-               cerr << "\n";
+               sblog << "\n";
        );
 }
 
index a8a657fbb6fb511ea58e2010ec0baf2aabc48193..d5d48c3c740ebd5d4856e69f2941adb83c4bb3a5 100644 (file)
@@ -87,8 +87,6 @@ class bytecode;
 class bc_dump : public vpass {
        using vpass::visit;
 
-       std::ostream &o;
-
        uint32_t *bc_data;
        unsigned ndw;
 
@@ -98,10 +96,10 @@ class bc_dump : public vpass {
 
 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();
index 444765e87790da0d3d30b6cf819a08b91e6e1541..db51ad523701eb07c4ecc78e18fa94cbb66ac9aa 100644 (file)
 #endif
 
 #include "sb_shader.h"
-
 #include "sb_pass.h"
 
 namespace r600_sb {
 
-using std::cerr;
-
 int peephole::run() {
 
        run_on(sh.root);
@@ -112,9 +109,9 @@ void peephole::optimize_SETcc_op(alu_node* a) {
                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))
@@ -136,10 +133,10 @@ void peephole::optimize_SETcc_op(alu_node* a) {
                }
 
                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) :
index 83510b0215898033016bbcb1334bf501cd0f6cb4..9681e69f6cd34b3f81cee49e3dd847c19c43814a 100644 (file)
  *      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();
@@ -54,11 +50,11 @@ int ra_checker::run() {
 
 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() {
@@ -96,20 +92,20 @@ void ra_checker::kill_alu_only_regs() {
 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());
@@ -128,7 +124,7 @@ void ra_checker::check_src_vec(node *n, unsigned id, vvec &vv, bool src) {
 
                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;
@@ -159,7 +155,7 @@ void ra_checker::process_op_dst(node *n) {
                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;
@@ -201,7 +197,7 @@ void ra_checker::check_alu_group(alu_group_node *g) {
        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;
index 25c46f79c8e67a29a07ee10a45cfea03c4bc7415..582f553db0e18f4d0c6f682edcd787a60f4faead 100644 (file)
@@ -37,8 +37,6 @@
 
 namespace r600_sb {
 
-using std::cerr;
-
 int ra_coalesce::run() {
        return sh.coal.run();
 }
@@ -65,7 +63,7 @@ void coalescer::create_chunk(value *v) {
        c->pin = v->pin_gpr;
 
        RA_DUMP(
-               cerr << "create_chunk: ";
+               sblog << "create_chunk: ";
                dump_chunk(c);
        );
 
@@ -78,7 +76,7 @@ void coalescer::unify_chunks(ra_edge *e) {
        ra_chunk *c1 = e->a->chunk, *c2 = e->b->chunk;
 
        RA_DUMP(
-               cerr << "unify_chunks: ";
+               sblog << "unify_chunks: ";
                dump_chunk(c1);
                dump_chunk(c2);
        );
@@ -166,21 +164,21 @@ ra_constraint* coalescer::create_constraint(constraint_kind kind) {
 }
 
 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) {
@@ -191,7 +189,7 @@ void coalescer::dump_chunks() {
 
 
 void coalescer::dump_constraint_queue() {
-       cerr << "######## constraints\n";
+       sblog << "######## constraints\n";
 
        for (constraint_queue::iterator I = constraints.begin(),
                        E = constraints.end(); I != E; ++I) {
@@ -201,33 +199,33 @@ void coalescer::dump_constraint_queue() {
 }
 
 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) {
@@ -289,11 +287,11 @@ void coalescer::color_chunks() {
                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);
@@ -385,9 +383,9 @@ void coalescer::color_chunk(ra_chunk *c, sel_chan color) {
 
 
                RA_DUMP(
-                       cerr << " assigned " << color << " to ";
+                       sblog << " assigned " << color << " to ";
                        dump::dump_val(v);
-                       cerr << "\n";
+                       sblog << "\n";
                );
        }
 
@@ -455,7 +453,7 @@ ra_chunk* coalescer::detach_value(value *v) {
        }
 
        RA_DUMP(
-               cerr << "           detached : ";
+               sblog << "           detached : ";
                dump_chunk(v->chunk);
        );
 
@@ -565,7 +563,7 @@ int coalescer::color_reg_constraint(ra_constraint *c) {
                } 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;
                }
 
@@ -578,7 +576,7 @@ int coalescer::color_reg_constraint(ra_constraint *c) {
        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";
        );
 
@@ -609,7 +607,7 @@ int coalescer::color_constraints() {
                ra_constraint *c = *I;
 
                RA_DUMP(
-                       cerr << "color_constraints: ";
+                       sblog << "color_constraints: ";
                        dump_constraint(c);
                );
 
index 03b8efde4c10269be5aa5079c74cb6697fc06870..d5fe4f95e5a5f27f3a51c763fbb55742eeb0fa9c 100644 (file)
 #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);
@@ -88,12 +83,14 @@ void regbits::dump() {
        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);
        }
 }
 
@@ -237,20 +234,20 @@ void ra_init::alloc_arrays() {
                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;
                }
 
@@ -264,9 +261,9 @@ void ra_init::alloc_arrays() {
                }
 
                RA_DUMP(
-                       cerr << "  interf: ";
+                       sblog << "  interf: ";
                        dump::dump_set(sh, s);
-                       cerr << "\n";
+                       sblog << "\n";
                );
 
                regbits rb(sh, s);
@@ -274,7 +271,7 @@ void ra_init::alloc_arrays() {
                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;
        }
@@ -307,9 +304,9 @@ void ra_init::process_op(node* n) {
        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()) {
@@ -355,9 +352,9 @@ void ra_init::color_bs_constraint(ra_constraint* c) {
        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);
@@ -380,9 +377,9 @@ void ra_init::color_bs_constraint(ra_constraint* c) {
                        interf = v->interferences;
 
                RA_DUMP(
-                       cerr << "   processing " << *v << "  interferences : ";
+                       sblog << "   processing " << *v << "  interferences : ";
                        dump::dump_set(sh, interf);
-                       cerr << "\n";
+                       sblog << "\n";
                );
 
                if (gpr) {
@@ -406,9 +403,9 @@ void ra_init::color_bs_constraint(ra_constraint* c) {
                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()) {
@@ -417,7 +414,7 @@ void ra_init::color_bs_constraint(ra_constraint* c) {
                                gpr = gpr + 1;
 
                        RA_DUMP(
-                               cerr << "    trying " << gpr << "\n";
+                               sblog << "    trying " << gpr << "\n";
                        );
 
                        unsigned chan = gpr.chan();
@@ -441,7 +438,7 @@ void ra_init::color_bs_constraint(ra_constraint* c) {
                }
 
                if (!gpr) {
-                       cerr << "color_bs_constraint: failed...\n";
+                       sblog << "color_bs_constraint: failed...\n";
                        assert(!"coloring failed");
                }
        }
@@ -458,11 +455,11 @@ void ra_init::color(value* v) {
                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()) {
@@ -475,7 +472,7 @@ void ra_init::color(value* v) {
        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 {
@@ -489,9 +486,9 @@ void ra_init::color(value* v) {
 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";
        );
 }
 
index d0045ce75efdd80b1b20fa4ac39c5168f5f580d6..f99d64279f495fe8300be39b29bbb94d7bb6c6c8 100644 (file)
 
 #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
@@ -156,27 +153,27 @@ void literal_tracker::unreserve(alu_node* n) {
 
 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) {
@@ -343,7 +340,7 @@ void alu_group_tracker::assign_slot(unsigned slot, alu_node* n) {
 
 
 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);
 }
 
@@ -351,7 +348,7 @@ void alu_group_tracker::discard_slots(unsigned slot_mask,
                                     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();
@@ -362,13 +359,13 @@ void alu_group_tracker::discard_slots(unsigned slot_mask,
                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);
@@ -392,9 +389,9 @@ void alu_group_tracker::discard_slots(unsigned slot_mask,
                        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]);
@@ -408,9 +405,9 @@ void alu_group_tracker::discard_slots(unsigned slot_mask,
                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;
@@ -557,13 +554,13 @@ bool alu_group_tracker::try_reserve(alu_node* n) {
        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";
                        );
 
@@ -580,7 +577,7 @@ bool alu_group_tracker::try_reserve(alu_node* 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";
                                );
 
@@ -592,7 +589,7 @@ bool alu_group_tracker::try_reserve(alu_node* 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);
@@ -661,13 +658,13 @@ void alu_group_tracker::reinit() {
 
        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");
                }
@@ -761,7 +758,7 @@ unsigned post_scheduler::init_ucm(container_node *c, node *n) {
 
 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);
        );
@@ -778,9 +775,9 @@ void post_scheduler::schedule_bb(bb_node* bb) {
        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) {
@@ -801,9 +798,9 @@ void post_scheduler::init_regmap() {
        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) {
@@ -815,9 +812,9 @@ void post_scheduler::init_regmap() {
                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);
@@ -847,15 +844,15 @@ void post_scheduler::process_alu(container_node *c) {
                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);
                }
@@ -867,9 +864,9 @@ void post_scheduler::process_alu(container_node *c) {
 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";
        );
 
 
@@ -894,7 +891,7 @@ void post_scheduler::update_live_src_vec(vvec &vv, val_set *born, bool src) {
                                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);
@@ -922,11 +919,11 @@ void post_scheduler::update_live_dst_vec(vvec &vv) {
                } 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";
                                );
                        }
                }
@@ -947,9 +944,9 @@ void post_scheduler::process_group() {
        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) {
@@ -961,9 +958,9 @@ void post_scheduler::process_group() {
        }
 
        PSC_DUMP(
-               cerr << "process_group: live_after : ";
+               sblog << "process_group: live_after : ";
                dump::dump_set(sh, live);
-               cerr << "\n";
+               sblog << "\n";
        );
 
        update_local_interferences();
@@ -979,9 +976,9 @@ void post_scheduler::process_group() {
 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) {
@@ -1039,13 +1036,13 @@ void post_scheduler::schedule_alu(container_node *c) {
        }
 
        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");
        }
@@ -1066,7 +1063,7 @@ void post_scheduler::add_interferences(value *v, sb_bitset &rb, val_set &vs) {
                        unsigned r = gpr.sel();
 
                        PSC_DUMP(
-                               cerr << "\tadd_interferences: " << *vi << "\n";
+                               sblog << "\tadd_interferences: " << *vi << "\n";
                        );
 
                        if (rb.size() <= r)
@@ -1080,9 +1077,9 @@ void post_scheduler::set_color_local_val(value *v, sel_chan color) {
        v->gpr = color;
 
        PSC_DUMP(
-               cerr << "     recolored: ";
+               sblog << "     recolored: ";
                dump::dump_val(v);
-               cerr << "\n";
+               sblog << "\n";
        );
 }
 
@@ -1111,15 +1108,15 @@ bool post_scheduler::recolor_local(value *v) {
        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";
                }
        );
 
@@ -1128,7 +1125,7 @@ bool post_scheduler::recolor_local(value *v) {
                                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);
                }
@@ -1138,11 +1135,11 @@ bool post_scheduler::recolor_local(value *v) {
 
        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);
                }
        );
 
@@ -1182,9 +1179,9 @@ void post_scheduler::emit_load_ar() {
        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;
@@ -1206,11 +1203,11 @@ bool post_scheduler::unmap_dst_val(value *d) {
 
                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;
@@ -1232,7 +1229,7 @@ bool post_scheduler::unmap_dst(alu_node *n) {
 
                        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;
@@ -1271,11 +1268,11 @@ bool post_scheduler::map_src_val(value *v) {
                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;
                }
@@ -1305,7 +1302,7 @@ bool post_scheduler::map_src_vec(vvec &vv, bool src) {
                                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;
@@ -1314,7 +1311,7 @@ bool post_scheduler::map_src_vec(vvec &vv, bool src) {
                                        alu.current_ar = rel;
 
                                        PSC_DUMP(
-                                               cerr << "  new current_AR assigned: " << *alu.current_ar
+                                               sblog << "  new current_AR assigned: " << *alu.current_ar
                                                        << "\n";
                                        );
                                }
@@ -1341,16 +1338,16 @@ bool post_scheduler::map_src(alu_node *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() {
@@ -1377,7 +1374,7 @@ bool post_scheduler::check_interferences() {
        bool discarded = false;
 
        PSC_DUMP(
-                       cerr << "check_interferences: before: \n";
+                       sblog << "check_interferences: before: \n";
        dump_regmap();
        );
 
@@ -1406,9 +1403,9 @@ bool post_scheduler::check_interferences() {
                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";
                                        }
                                }
                );
@@ -1416,7 +1413,7 @@ bool post_scheduler::check_interferences() {
                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;
@@ -1425,7 +1422,7 @@ bool post_scheduler::check_interferences() {
        } while(1);
 
        PSC_DUMP(
-               cerr << "check_interferences: after: \n";
+               sblog << "check_interferences: after: \n";
                dump_regmap();
        );
 
@@ -1446,14 +1443,14 @@ unsigned post_scheduler::try_add_instruction(node *n) {
                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;
                }
 
@@ -1497,17 +1494,17 @@ unsigned post_scheduler::try_add_instruction(node *n) {
                }
 
                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;
                }
 
@@ -1533,9 +1530,9 @@ bool post_scheduler::check_copy(node *n) {
        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);
@@ -1543,13 +1540,13 @@ bool post_scheduler::check_copy(node *n) {
 
                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;
                        }
 
@@ -1563,7 +1560,7 @@ bool post_scheduler::check_copy(node *n) {
 
                release_src_values(n);
                n->remove();
-               PSC_DUMP( cerr << "    copy coalesced...\n";);
+               PSC_DUMP( sblog << "    copy coalesced...\n";);
                return true;
        }
        return false;
@@ -1573,9 +1570,9 @@ void post_scheduler::dump_group(alu_group_tracker &rt) {
        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";
                }
        }
 }
@@ -1611,7 +1608,7 @@ bool post_scheduler::prepare_alu_group() {
        unsigned i1 = 0;
 
        PSC_DUMP(
-               cerr << "prepare_alu_group: starting...\n";
+               sblog << "prepare_alu_group: starting...\n";
                dump_group(rt);
        );
 
@@ -1631,9 +1628,9 @@ bool post_scheduler::prepare_alu_group() {
                        node *n = *I;
 
                        PSC_DUMP(
-                               cerr << "p_a_g: ";
+                               sblog << "p_a_g: ";
                                dump::dump_op(n);
-                               cerr << "\n";
+                               sblog << "\n";
                        );
 
 
@@ -1643,12 +1640,12 @@ bool post_scheduler::prepare_alu_group() {
                                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;
                        }
                }
@@ -1671,10 +1668,10 @@ bool post_scheduler::prepare_alu_group() {
        } 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()
@@ -1692,9 +1689,9 @@ void post_scheduler::release_src_values(node* n) {
 
 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();
@@ -1790,7 +1787,7 @@ void alu_clause_tracker::emit_group() {
 
        new_group();
 
-       PSC_DUMP( cerr << "   #### group emitted\n"; );
+       PSC_DUMP( sblog << "   #### group emitted\n"; );
 }
 
 void alu_clause_tracker::emit_clause(container_node *c) {
@@ -1811,7 +1808,7 @@ 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() {
@@ -1851,7 +1848,7 @@ void literal_tracker::init_group_literals(alu_group_node* g) {
                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";
                );
@@ -1948,27 +1945,27 @@ alu_node* alu_clause_tracker::create_ar_load() {
        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";
        }
 }
 
index f0665efb2caada2a733d1e26db5fdae420eb3166..e8da20ce7245cc8eff54b63af9a8cddbd6138e31 100644 (file)
 
 #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(),
@@ -400,7 +397,7 @@ void shader::add_gpr_array(unsigned gpr_start, unsigned gpr_count,
                        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";
                        );
 
@@ -696,39 +693,39 @@ void shader_stats::accumulate(shader_stats& s) {
        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
index 2aaccd00dc50ea708abdba4dda59aaf9eb9e1ce3..5e6aca04928f5c550fdffac32272531e661bf1f3 100644 (file)
@@ -32,7 +32,6 @@
 #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;
 
@@ -73,9 +70,8 @@ std::ostream& operator << (std::ostream &o, value &v) {
        }
                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)
@@ -137,7 +133,7 @@ void value_table::add_value(value* v) {
        }
 
        VT_DUMP(
-               cerr << "gvn add_value ";
+               sblog << "gvn add_value ";
                dump::dump_val(v);
        );
 
@@ -148,9 +144,9 @@ void value_table::add_value(value* 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;
        }
@@ -166,9 +162,9 @@ void value_table::add_value(value* v) {
                        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;
                }
@@ -176,7 +172,7 @@ void value_table::add_value(value* v) {
 
        v->gvn_source = v;
        VT_DUMP(
-               cerr << " added new\n";
+               sblog << " added new\n";
        );
 }
 
@@ -217,11 +213,11 @@ void value_table::get_values(vvec& v) {
 
 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);
 }