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