1 /* 2 * Copyright 2013 Vadim Girlin <vadimgirlin (at) gmail.com> 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * on the rights to use, copy, modify, merge, publish, distribute, sub 8 * license, and/or sell copies of the Software, and to permit persons to whom 9 * the Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 21 * USE OR OTHER DEALINGS IN THE SOFTWARE. 22 * 23 * Authors: 24 * Vadim Girlin 25 */ 26 27 #include "sb_shader.h" 28 #include "sb_pass.h" 29 30 namespace r600_sb { 31 32 pass::pass(shader &s) : ctx(s.get_ctx()), sh(s) {} 33 34 int pass::run() { return -1; } 35 36 int vpass::init() { return 0; } 37 int vpass::done() { return 0; } 38 39 int vpass::run() { 40 int r; 41 if ((r = init())) 42 return r; 43 44 run_on(*sh.root); 45 46 if ((r = done())) 47 return r; 48 49 return 0; 50 } 51 52 void vpass::run_on(container_node &n) { 53 if (n.accept(*this, true)) { 54 55 for (node_iterator N, I = n.begin(), E = n.end(); I != E; I = N) { 56 N = I; 57 ++N; 58 59 if (I->is_container()) { 60 container_node *c = static_cast<container_node*>(*I); 61 run_on(*c); 62 } else { 63 I->accept(*this, true); 64 I->accept(*this, false); 65 } 66 } 67 68 } 69 n.accept(*this, false); 70 } 71 72 bool vpass::visit(node& n, bool enter) { return true; } 73 bool vpass::visit(container_node& n, bool enter) { return true; } 74 bool vpass::visit(alu_group_node& n, bool enter) { return true; } 75 bool vpass::visit(cf_node& n, bool enter) { return true; } 76 bool vpass::visit(alu_node& n, bool enter) { return true; } 77 bool vpass::visit(alu_packed_node& n, bool enter) { return true; } 78 bool vpass::visit(fetch_node& n, bool enter) { return true; } 79 bool vpass::visit(region_node& n, bool enter) { return true; } 80 bool vpass::visit(repeat_node& n, bool enter) { return true; } 81 bool vpass::visit(depart_node& n, bool enter) { return true; } 82 bool vpass::visit(if_node& n, bool enter) { return true; } 83 bool vpass::visit(bb_node& n, bool enter) { return true; } 84 85 void rev_vpass::run_on(container_node& n) { 86 if (n.accept(*this, true)) { 87 88 for (node_riterator N, I = n.rbegin(), E = n.rend(); I != E; I = N) { 89 N = I; 90 ++N; 91 92 if (I->is_container()) { 93 container_node *c = static_cast<container_node*>(*I); 94 run_on(*c); 95 } else { 96 I->accept(*this, true); 97 I->accept(*this, false); 98 } 99 } 100 101 } 102 n.accept(*this, false); 103 } 104 105 } // namespace r600_sb 106