r600g/sb: improve error checking in ra_coalesce pass
authorVadim Girlin <vadimgirlin@gmail.com>
Tue, 23 Apr 2013 06:34:42 +0000 (10:34 +0400)
committerVadim Girlin <vadimgirlin@gmail.com>
Tue, 30 Apr 2013 17:50:47 +0000 (21:50 +0400)
src/gallium/drivers/r600/sb/sb_ra_coalesce.cpp
src/gallium/drivers/r600/sb/sb_shader.h

index 52e76687b957de4ac949375d59ef5c3730e9ff4b..cec4bbc74de8ed0d1b50915478bb5ae314ac8b2f 100644 (file)
@@ -40,10 +40,7 @@ namespace r600_sb {
 using std::cerr;
 
 int ra_coalesce::run() {
-
-       sh.coal.run();
-
-       return 0;
+       return sh.coal.run();
 }
 
 void coalescer::add_edge(value* a, value* b, unsigned cost) {
@@ -417,7 +414,9 @@ coalescer::~coalescer() {
        }
 }
 
-void coalescer::run() {
+int coalescer::run() {
+       int r;
+
        RA_DUMP( dump_edges(); );
 
        build_chunks();
@@ -426,10 +425,13 @@ void coalescer::run() {
        build_constraint_queue();
        RA_DUMP( dump_constraint_queue(); );
 
-       color_constraints();
+       if ((r = color_constraints()))
+               return r;
 
        build_chunk_queue();
        color_chunks();
+
+       return 0;
 }
 
 void coalescer::color_phi_constraint(ra_constraint* c) {
@@ -457,7 +459,7 @@ ra_chunk* coalescer::detach_value(value *v) {
 
 }
 
-void coalescer::color_reg_constraint(ra_constraint *c) {
+int coalescer::color_reg_constraint(ra_constraint *c) {
        unsigned k, cnt = c->values.size();
        vvec & cv = c->values;
 
@@ -558,6 +560,11 @@ void 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";
+                       return -1;
+               }
+
                if (pass == 0 && done)
                        break;
 
@@ -585,9 +592,13 @@ void coalescer::color_reg_constraint(ra_constraint *c) {
                color_chunk(cc, color);
                cc->fix();
        }
+
+       return 0;
 }
 
-void coalescer::color_constraints() {
+int coalescer::color_constraints() {
+       int r;
+
        for (constraint_queue::iterator I = constraints.begin(),
                        E = constraints.end(); I != E; ++I) {
 
@@ -598,11 +609,13 @@ void coalescer::color_constraints() {
                        dump_constraint(c);
                );
 
-               if (c->kind == CK_SAME_REG)
-                       color_reg_constraint(c);
-               else if (c->kind == CK_PHI)
+               if (c->kind == CK_SAME_REG) {
+                       if ((r = color_reg_constraint(c)))
+                               return r;
+               } else if (c->kind == CK_PHI)
                        color_phi_constraint(c);
        }
+       return 0;
 }
 
 } // namespace r600_sb
index 5531fdaa092e35c5aa44e77d89a5a40991421193..039d1fa5c845e1382f1bb811d445238acc0e1a9b 100644 (file)
@@ -192,13 +192,13 @@ public:
        coalescer(shader &sh) : sh(sh), edges(), chunks(), constraints() {}
        ~coalescer();
 
-       void run();
+       int run();
 
        void add_edge(value *a, value *b, unsigned cost);
        void build_chunks();
        void build_constraint_queue();
        void build_chunk_queue();
-       void color_constraints();
+       int color_constraints();
        void color_chunks();
 
        ra_constraint* create_constraint(constraint_kind kind);
@@ -223,7 +223,7 @@ private:
        void unify_chunks(ra_edge *e);
        bool chunks_interference(ra_chunk *c1, ra_chunk *c2);
 
-       void color_reg_constraint(ra_constraint *c);
+       int color_reg_constraint(ra_constraint *c);
        void color_phi_constraint(ra_constraint *c);