Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ir_hierarchical_visitor.cpp 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. /*
  2. * Copyright © 2010 Intel Corporation
  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. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * 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 NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  21. * DEALINGS IN THE SOFTWARE.
  22. */
  23. #include "ir.h"
  24. #include "ir_hierarchical_visitor.h"
  25. ir_hierarchical_visitor::ir_hierarchical_visitor()
  26. {
  27. this->callback = NULL;
  28. this->data = NULL;
  29. }
  30. ir_visitor_status
  31. ir_hierarchical_visitor::visit(ir_variable *ir)
  32. {
  33. if (this->callback != NULL)
  34. this->callback(ir, this->data);
  35. return visit_continue;
  36. }
  37. ir_visitor_status
  38. ir_hierarchical_visitor::visit(ir_constant *ir)
  39. {
  40. if (this->callback != NULL)
  41. this->callback(ir, this->data);
  42. return visit_continue;
  43. }
  44. ir_visitor_status
  45. ir_hierarchical_visitor::visit(ir_loop_jump *ir)
  46. {
  47. if (this->callback != NULL)
  48. this->callback(ir, this->data);
  49. return visit_continue;
  50. }
  51. ir_visitor_status
  52. ir_hierarchical_visitor::visit(ir_dereference_variable *ir)
  53. {
  54. if (this->callback != NULL)
  55. this->callback(ir, this->data);
  56. return visit_continue;
  57. }
  58. ir_visitor_status
  59. ir_hierarchical_visitor::visit_enter(ir_loop *ir)
  60. {
  61. if (this->callback != NULL)
  62. this->callback(ir, this->data);
  63. return visit_continue;
  64. }
  65. ir_visitor_status
  66. ir_hierarchical_visitor::visit_leave(ir_loop *ir)
  67. {
  68. (void) ir;
  69. return visit_continue;
  70. }
  71. ir_visitor_status
  72. ir_hierarchical_visitor::visit_enter(ir_function_signature *ir)
  73. {
  74. if (this->callback != NULL)
  75. this->callback(ir, this->data);
  76. return visit_continue;
  77. }
  78. ir_visitor_status
  79. ir_hierarchical_visitor::visit_leave(ir_function_signature *ir)
  80. {
  81. (void) ir;
  82. return visit_continue;
  83. }
  84. ir_visitor_status
  85. ir_hierarchical_visitor::visit_enter(ir_function *ir)
  86. {
  87. if (this->callback != NULL)
  88. this->callback(ir, this->data);
  89. return visit_continue;
  90. }
  91. ir_visitor_status
  92. ir_hierarchical_visitor::visit_leave(ir_function *ir)
  93. {
  94. (void) ir;
  95. return visit_continue;
  96. }
  97. ir_visitor_status
  98. ir_hierarchical_visitor::visit_enter(ir_expression *ir)
  99. {
  100. if (this->callback != NULL)
  101. this->callback(ir, this->data);
  102. return visit_continue;
  103. }
  104. ir_visitor_status
  105. ir_hierarchical_visitor::visit_leave(ir_expression *ir)
  106. {
  107. (void) ir;
  108. return visit_continue;
  109. }
  110. ir_visitor_status
  111. ir_hierarchical_visitor::visit_enter(ir_texture *ir)
  112. {
  113. if (this->callback != NULL)
  114. this->callback(ir, this->data);
  115. return visit_continue;
  116. }
  117. ir_visitor_status
  118. ir_hierarchical_visitor::visit_leave(ir_texture *ir)
  119. {
  120. (void) ir;
  121. return visit_continue;
  122. }
  123. ir_visitor_status
  124. ir_hierarchical_visitor::visit_enter(ir_swizzle *ir)
  125. {
  126. if (this->callback != NULL)
  127. this->callback(ir, this->data);
  128. return visit_continue;
  129. }
  130. ir_visitor_status
  131. ir_hierarchical_visitor::visit_leave(ir_swizzle *ir)
  132. {
  133. (void) ir;
  134. return visit_continue;
  135. }
  136. ir_visitor_status
  137. ir_hierarchical_visitor::visit_enter(ir_dereference_array *ir)
  138. {
  139. if (this->callback != NULL)
  140. this->callback(ir, this->data);
  141. return visit_continue;
  142. }
  143. ir_visitor_status
  144. ir_hierarchical_visitor::visit_leave(ir_dereference_array *ir)
  145. {
  146. (void) ir;
  147. return visit_continue;
  148. }
  149. ir_visitor_status
  150. ir_hierarchical_visitor::visit_enter(ir_dereference_record *ir)
  151. {
  152. if (this->callback != NULL)
  153. this->callback(ir, this->data);
  154. return visit_continue;
  155. }
  156. ir_visitor_status
  157. ir_hierarchical_visitor::visit_leave(ir_dereference_record *ir)
  158. {
  159. (void) ir;
  160. return visit_continue;
  161. }
  162. ir_visitor_status
  163. ir_hierarchical_visitor::visit_enter(ir_assignment *ir)
  164. {
  165. if (this->callback != NULL)
  166. this->callback(ir, this->data);
  167. return visit_continue;
  168. }
  169. ir_visitor_status
  170. ir_hierarchical_visitor::visit_leave(ir_assignment *ir)
  171. {
  172. (void) ir;
  173. return visit_continue;
  174. }
  175. ir_visitor_status
  176. ir_hierarchical_visitor::visit_enter(ir_call *ir)
  177. {
  178. if (this->callback != NULL)
  179. this->callback(ir, this->data);
  180. return visit_continue;
  181. }
  182. ir_visitor_status
  183. ir_hierarchical_visitor::visit_leave(ir_call *ir)
  184. {
  185. (void) ir;
  186. return visit_continue;
  187. }
  188. ir_visitor_status
  189. ir_hierarchical_visitor::visit_enter(ir_return *ir)
  190. {
  191. if (this->callback != NULL)
  192. this->callback(ir, this->data);
  193. return visit_continue;
  194. }
  195. ir_visitor_status
  196. ir_hierarchical_visitor::visit_leave(ir_return *ir)
  197. {
  198. (void) ir;
  199. return visit_continue;
  200. }
  201. ir_visitor_status
  202. ir_hierarchical_visitor::visit_enter(ir_if *ir)
  203. {
  204. if (this->callback != NULL)
  205. this->callback(ir, this->data);
  206. return visit_continue;
  207. }
  208. ir_visitor_status
  209. ir_hierarchical_visitor::visit_leave(ir_if *ir)
  210. {
  211. (void) ir;
  212. return visit_continue;
  213. }
  214. void
  215. ir_hierarchical_visitor::run(exec_list *instructions)
  216. {
  217. foreach_list(n, instructions) {
  218. ir_instruction *ir = (ir_instruction *) n;
  219. if (ir->accept(this) != visit_continue)
  220. break;
  221. }
  222. }