Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright 2013 Vadim Girlin <vadimgirlin@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.  
  29. #include "sb_pass.h"
  30.  
  31. namespace r600_sb {
  32.  
  33. bool dce_cleanup::visit(node& n, bool enter) {
  34.         if (enter) {
  35.         } else {
  36.                 if (n.flags & NF_DEAD)
  37.                         n.remove();
  38.                 else
  39.                         cleanup_dst(n);
  40.         }
  41.         return true;
  42. }
  43.  
  44. bool dce_cleanup::visit(alu_group_node& n, bool enter) {
  45.         if (enter) {
  46.         } else {
  47.                 n.expand();
  48.         }
  49.         return true;
  50. }
  51.  
  52. bool dce_cleanup::visit(cf_node& n, bool enter) {
  53.         if (enter) {
  54.                 if (n.flags & NF_DEAD)
  55.                         n.remove();
  56.                 else
  57.                         cleanup_dst(n);
  58.         } else {
  59.                 if (n.bc.op_ptr->flags & (CF_CLAUSE | CF_BRANCH | CF_LOOP))
  60.                         n.expand();
  61.         }
  62.         return true;
  63. }
  64.  
  65. bool dce_cleanup::visit(alu_node& n, bool enter) {
  66.         if (enter) {
  67.         } else {
  68.                 if (n.flags & NF_DEAD)
  69.                         n.remove();
  70.                 else
  71.                         cleanup_dst(n);
  72.         }
  73.         return true;
  74. }
  75.  
  76. bool dce_cleanup::visit(alu_packed_node& n, bool enter) {
  77.         if (enter) {
  78.         } else {
  79.                 if (n.flags & NF_DEAD)
  80.                         n.remove();
  81.                 else
  82.                         cleanup_dst(n);
  83.         }
  84.         return false;
  85. }
  86.  
  87. bool dce_cleanup::visit(fetch_node& n, bool enter) {
  88.         if (enter) {
  89.         } else {
  90.                 if (n.flags & NF_DEAD)
  91.                         n.remove();
  92.                 else
  93.                         cleanup_dst(n);
  94.         }
  95.         return true;
  96. }
  97.  
  98. bool dce_cleanup::visit(region_node& n, bool enter) {
  99.         if (enter) {
  100.                 if (n.loop_phi)
  101.                         run_on(*n.loop_phi);
  102.         } else {
  103.                 if (n.phi)
  104.                         run_on(*n.phi);
  105.         }
  106.         return true;
  107. }
  108.  
  109. void dce_cleanup::cleanup_dst(node& n) {
  110.         cleanup_dst_vec(n.dst);
  111. }
  112.  
  113. bool dce_cleanup::visit(container_node& n, bool enter) {
  114.         if (enter) {
  115.                 cleanup_dst(n);
  116.         } else {
  117.  
  118.         }
  119.         return true;
  120. }
  121.  
  122. void dce_cleanup::cleanup_dst_vec(vvec& vv) {
  123.         for (vvec::iterator I = vv.begin(), E = vv.end(); I != E; ++I) {
  124.                 value* &v = *I;
  125.                 if (!v)
  126.                         continue;
  127.  
  128.                 if (v->gvn_source && v->gvn_source->is_dead())
  129.                         v->gvn_source = NULL;
  130.  
  131.                 if (v->is_dead())
  132.                         v = NULL;
  133.         }
  134. }
  135.  
  136. } // namespace r600_sb
  137.