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_constant_expression.cpp 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  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. /**
  24. * \file ir_constant_expression.cpp
  25. * Evaluate and process constant valued expressions
  26. *
  27. * In GLSL, constant valued expressions are used in several places. These
  28. * must be processed and evaluated very early in the compilation process.
  29. *
  30. * * Sizes of arrays
  31. * * Initializers for uniforms
  32. * * Initializers for \c const variables
  33. */
  34. #define NULL 0
  35. #include <math.h>
  36. #include "ir.h"
  37. #include "ir_visitor.h"
  38. #include "glsl_types.h"
  39. /**
  40. * Visitor class for evaluating constant expressions
  41. */
  42. class ir_constant_visitor : public ir_visitor {
  43. public:
  44. ir_constant_visitor()
  45. : value(NULL)
  46. {
  47. /* empty */
  48. }
  49. virtual ~ir_constant_visitor()
  50. {
  51. /* empty */
  52. }
  53. /**
  54. * \name Visit methods
  55. *
  56. * As typical for the visitor pattern, there must be one \c visit method for
  57. * each concrete subclass of \c ir_instruction. Virtual base classes within
  58. * the hierarchy should not have \c visit methods.
  59. */
  60. /*@{*/
  61. virtual void visit(ir_variable *);
  62. virtual void visit(ir_function_signature *);
  63. virtual void visit(ir_function *);
  64. virtual void visit(ir_expression *);
  65. virtual void visit(ir_texture *);
  66. virtual void visit(ir_swizzle *);
  67. virtual void visit(ir_dereference_variable *);
  68. virtual void visit(ir_dereference_array *);
  69. virtual void visit(ir_dereference_record *);
  70. virtual void visit(ir_assignment *);
  71. virtual void visit(ir_constant *);
  72. virtual void visit(ir_call *);
  73. virtual void visit(ir_return *);
  74. virtual void visit(ir_if *);
  75. virtual void visit(ir_loop *);
  76. virtual void visit(ir_loop_jump *);
  77. /*@}*/
  78. /**
  79. * Value of the constant expression.
  80. *
  81. * \note
  82. * This field will be \c NULL if the expression is not constant valued.
  83. */
  84. /* FINIHSME: This cannot hold values for constant arrays or structures. */
  85. ir_constant *value;
  86. };
  87. ir_constant *
  88. ir_instruction::constant_expression_value()
  89. {
  90. ir_constant_visitor visitor;
  91. this->accept(& visitor);
  92. return visitor.value;
  93. }
  94. void
  95. ir_constant_visitor::visit(ir_variable *ir)
  96. {
  97. (void) ir;
  98. value = NULL;
  99. }
  100. void
  101. ir_constant_visitor::visit(ir_function_signature *ir)
  102. {
  103. (void) ir;
  104. value = NULL;
  105. }
  106. void
  107. ir_constant_visitor::visit(ir_function *ir)
  108. {
  109. (void) ir;
  110. value = NULL;
  111. }
  112. void
  113. ir_constant_visitor::visit(ir_expression *ir)
  114. {
  115. value = NULL;
  116. ir_constant *op[2];
  117. unsigned int operand, c;
  118. ir_constant_data data;
  119. const glsl_type *type = NULL;
  120. for (operand = 0; operand < ir->get_num_operands(); operand++) {
  121. op[operand] = ir->operands[operand]->constant_expression_value();
  122. if (!op[operand])
  123. return;
  124. }
  125. switch (ir->operation) {
  126. case ir_unop_logic_not:
  127. type = ir->operands[0]->type;
  128. assert(type->base_type == GLSL_TYPE_BOOL);
  129. for (c = 0; c < ir->operands[0]->type->components(); c++)
  130. data.b[c] = !op[0]->value.b[c];
  131. break;
  132. case ir_unop_f2i:
  133. assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
  134. type = ir->type;
  135. for (c = 0; c < ir->operands[0]->type->components(); c++) {
  136. data.i[c] = op[0]->value.f[c];
  137. }
  138. break;
  139. case ir_unop_i2f:
  140. assert(op[0]->type->base_type == GLSL_TYPE_UINT ||
  141. op[0]->type->base_type == GLSL_TYPE_INT);
  142. type = ir->type;
  143. for (c = 0; c < ir->operands[0]->type->components(); c++) {
  144. if (op[0]->type->base_type == GLSL_TYPE_INT)
  145. data.f[c] = op[0]->value.i[c];
  146. else
  147. data.f[c] = op[0]->value.u[c];
  148. }
  149. break;
  150. case ir_unop_b2f:
  151. assert(op[0]->type->base_type == GLSL_TYPE_BOOL);
  152. type = ir->type;
  153. for (c = 0; c < ir->operands[0]->type->components(); c++) {
  154. data.f[c] = op[0]->value.b[c] ? 1.0 : 0.0;
  155. }
  156. break;
  157. case ir_unop_f2b:
  158. assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
  159. type = ir->type;
  160. for (c = 0; c < ir->operands[0]->type->components(); c++) {
  161. data.b[c] = bool(op[0]->value.f[c]);
  162. }
  163. break;
  164. case ir_unop_b2i:
  165. assert(op[0]->type->base_type == GLSL_TYPE_BOOL);
  166. type = ir->type;
  167. for (c = 0; c < ir->operands[0]->type->components(); c++) {
  168. data.u[c] = op[0]->value.b[c] ? 1 : 0;
  169. }
  170. break;
  171. case ir_unop_i2b:
  172. assert(op[0]->type->is_integer());
  173. type = ir->type;
  174. for (c = 0; c < ir->operands[0]->type->components(); c++) {
  175. data.b[c] = bool(op[0]->value.u[c]);
  176. }
  177. break;
  178. case ir_unop_neg:
  179. type = ir->type;
  180. for (c = 0; c < ir->operands[0]->type->components(); c++) {
  181. switch (type->base_type) {
  182. case GLSL_TYPE_UINT:
  183. data.u[c] = -op[0]->value.u[c];
  184. break;
  185. case GLSL_TYPE_INT:
  186. data.i[c] = -op[0]->value.i[c];
  187. break;
  188. case GLSL_TYPE_FLOAT:
  189. data.f[c] = -op[0]->value.f[c];
  190. break;
  191. default:
  192. assert(0);
  193. }
  194. }
  195. break;
  196. case ir_unop_abs:
  197. assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
  198. type = ir->type;
  199. for (c = 0; c < ir->operands[0]->type->components(); c++) {
  200. switch (type->base_type) {
  201. case GLSL_TYPE_UINT:
  202. data.u[c] = op[0]->value.u[c];
  203. break;
  204. case GLSL_TYPE_INT:
  205. data.i[c] = op[0]->value.i[c];
  206. if (data.i[c] < 0)
  207. data.i[c] = -data.i[c];
  208. break;
  209. case GLSL_TYPE_FLOAT:
  210. data.f[c] = fabs(op[0]->value.f[c]);
  211. break;
  212. default:
  213. assert(0);
  214. }
  215. }
  216. break;
  217. case ir_unop_rcp:
  218. assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
  219. type = ir->type;
  220. for (c = 0; c < ir->operands[0]->type->components(); c++) {
  221. switch (type->base_type) {
  222. case GLSL_TYPE_UINT:
  223. if (op[0]->value.u[c] != 0.0)
  224. data.u[c] = 1 / op[0]->value.u[c];
  225. break;
  226. case GLSL_TYPE_INT:
  227. if (op[0]->value.i[c] != 0.0)
  228. data.i[c] = 1 / op[0]->value.i[c];
  229. break;
  230. case GLSL_TYPE_FLOAT:
  231. if (op[0]->value.f[c] != 0.0)
  232. data.f[c] = 1.0 / op[0]->value.f[c];
  233. break;
  234. default:
  235. assert(0);
  236. }
  237. }
  238. break;
  239. case ir_unop_rsq:
  240. assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
  241. type = ir->type;
  242. for (c = 0; c < ir->operands[0]->type->components(); c++) {
  243. data.f[c] = 1.0 / sqrtf(op[0]->value.f[c]);
  244. }
  245. break;
  246. case ir_unop_sqrt:
  247. assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
  248. type = ir->type;
  249. for (c = 0; c < ir->operands[0]->type->components(); c++) {
  250. data.f[c] = sqrtf(op[0]->value.f[c]);
  251. }
  252. break;
  253. case ir_unop_exp:
  254. assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
  255. type = ir->type;
  256. for (c = 0; c < ir->operands[0]->type->components(); c++) {
  257. data.f[c] = expf(op[0]->value.f[c]);
  258. }
  259. break;
  260. case ir_unop_log:
  261. assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
  262. type = ir->type;
  263. for (c = 0; c < ir->operands[0]->type->components(); c++) {
  264. data.f[c] = logf(op[0]->value.f[c]);
  265. }
  266. break;
  267. case ir_unop_dFdx:
  268. case ir_unop_dFdy:
  269. assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
  270. type = ir->type;
  271. for (c = 0; c < ir->operands[0]->type->components(); c++) {
  272. data.f[c] = 0.0;
  273. }
  274. break;
  275. case ir_binop_add:
  276. if (ir->operands[0]->type == ir->operands[1]->type) {
  277. type = ir->operands[0]->type;
  278. for (c = 0; c < ir->operands[0]->type->components(); c++) {
  279. switch (ir->operands[0]->type->base_type) {
  280. case GLSL_TYPE_UINT:
  281. data.u[c] = op[0]->value.u[c] + op[1]->value.u[c];
  282. break;
  283. case GLSL_TYPE_INT:
  284. data.i[c] = op[0]->value.i[c] + op[1]->value.i[c];
  285. break;
  286. case GLSL_TYPE_FLOAT:
  287. data.f[c] = op[0]->value.f[c] + op[1]->value.f[c];
  288. break;
  289. default:
  290. assert(0);
  291. }
  292. }
  293. }
  294. break;
  295. case ir_binop_sub:
  296. if (ir->operands[0]->type == ir->operands[1]->type) {
  297. type = ir->operands[0]->type;
  298. for (c = 0; c < ir->operands[0]->type->components(); c++) {
  299. switch (ir->operands[0]->type->base_type) {
  300. case GLSL_TYPE_UINT:
  301. data.u[c] = op[0]->value.u[c] - op[1]->value.u[c];
  302. break;
  303. case GLSL_TYPE_INT:
  304. data.i[c] = op[0]->value.i[c] - op[1]->value.i[c];
  305. break;
  306. case GLSL_TYPE_FLOAT:
  307. data.f[c] = op[0]->value.f[c] - op[1]->value.f[c];
  308. break;
  309. default:
  310. assert(0);
  311. }
  312. }
  313. }
  314. break;
  315. case ir_binop_mul:
  316. if (ir->operands[0]->type == ir->operands[1]->type &&
  317. !ir->operands[0]->type->is_matrix()) {
  318. type = ir->operands[0]->type;
  319. for (c = 0; c < ir->operands[0]->type->components(); c++) {
  320. switch (ir->operands[0]->type->base_type) {
  321. case GLSL_TYPE_UINT:
  322. data.u[c] = op[0]->value.u[c] * op[1]->value.u[c];
  323. break;
  324. case GLSL_TYPE_INT:
  325. data.i[c] = op[0]->value.i[c] * op[1]->value.i[c];
  326. break;
  327. case GLSL_TYPE_FLOAT:
  328. data.f[c] = op[0]->value.f[c] * op[1]->value.f[c];
  329. break;
  330. default:
  331. assert(0);
  332. }
  333. }
  334. }
  335. break;
  336. case ir_binop_div:
  337. if (ir->operands[0]->type == ir->operands[1]->type) {
  338. type = ir->operands[0]->type;
  339. for (c = 0; c < ir->operands[0]->type->components(); c++) {
  340. switch (ir->operands[0]->type->base_type) {
  341. case GLSL_TYPE_UINT:
  342. data.u[c] = op[0]->value.u[c] / op[1]->value.u[c];
  343. break;
  344. case GLSL_TYPE_INT:
  345. data.i[c] = op[0]->value.i[c] / op[1]->value.i[c];
  346. break;
  347. case GLSL_TYPE_FLOAT:
  348. data.f[c] = op[0]->value.f[c] / op[1]->value.f[c];
  349. break;
  350. default:
  351. assert(0);
  352. }
  353. }
  354. }
  355. break;
  356. case ir_binop_logic_and:
  357. type = ir->operands[0]->type;
  358. assert(type->base_type == GLSL_TYPE_BOOL);
  359. for (c = 0; c < ir->operands[0]->type->components(); c++)
  360. data.b[c] = op[0]->value.b[c] && op[1]->value.b[c];
  361. break;
  362. case ir_binop_logic_xor:
  363. type = ir->operands[0]->type;
  364. assert(type->base_type == GLSL_TYPE_BOOL);
  365. for (c = 0; c < ir->operands[0]->type->components(); c++)
  366. data.b[c] = op[0]->value.b[c] ^ op[1]->value.b[c];
  367. break;
  368. case ir_binop_logic_or:
  369. type = ir->operands[0]->type;
  370. assert(type->base_type == GLSL_TYPE_BOOL);
  371. for (c = 0; c < ir->operands[0]->type->components(); c++)
  372. data.b[c] = op[0]->value.b[c] || op[1]->value.b[c];
  373. break;
  374. case ir_binop_less:
  375. type = glsl_type::bool_type;
  376. switch (ir->operands[0]->type->base_type) {
  377. case GLSL_TYPE_UINT:
  378. data.b[0] = op[0]->value.u[0] < op[1]->value.u[0];
  379. break;
  380. case GLSL_TYPE_INT:
  381. data.b[0] = op[0]->value.i[0] < op[1]->value.i[0];
  382. break;
  383. case GLSL_TYPE_FLOAT:
  384. data.b[0] = op[0]->value.f[0] < op[1]->value.f[0];
  385. break;
  386. default:
  387. assert(0);
  388. }
  389. break;
  390. case ir_binop_greater:
  391. type = glsl_type::bool_type;
  392. switch (ir->operands[0]->type->base_type) {
  393. case GLSL_TYPE_UINT:
  394. data.b[0] = op[0]->value.u[0] > op[1]->value.u[0];
  395. break;
  396. case GLSL_TYPE_INT:
  397. data.b[0] = op[0]->value.i[0] > op[1]->value.i[0];
  398. break;
  399. case GLSL_TYPE_FLOAT:
  400. data.b[0] = op[0]->value.f[0] > op[1]->value.f[0];
  401. break;
  402. default:
  403. assert(0);
  404. }
  405. break;
  406. case ir_binop_lequal:
  407. type = glsl_type::bool_type;
  408. switch (ir->operands[0]->type->base_type) {
  409. case GLSL_TYPE_UINT:
  410. data.b[0] = op[0]->value.u[0] <= op[1]->value.u[0];
  411. break;
  412. case GLSL_TYPE_INT:
  413. data.b[0] = op[0]->value.i[0] <= op[1]->value.i[0];
  414. break;
  415. case GLSL_TYPE_FLOAT:
  416. data.b[0] = op[0]->value.f[0] <= op[1]->value.f[0];
  417. break;
  418. default:
  419. assert(0);
  420. }
  421. break;
  422. case ir_binop_gequal:
  423. type = glsl_type::bool_type;
  424. switch (ir->operands[0]->type->base_type) {
  425. case GLSL_TYPE_UINT:
  426. data.b[0] = op[0]->value.u[0] >= op[1]->value.u[0];
  427. break;
  428. case GLSL_TYPE_INT:
  429. data.b[0] = op[0]->value.i[0] >= op[1]->value.i[0];
  430. break;
  431. case GLSL_TYPE_FLOAT:
  432. data.b[0] = op[0]->value.f[0] >= op[1]->value.f[0];
  433. break;
  434. default:
  435. assert(0);
  436. }
  437. break;
  438. case ir_binop_equal:
  439. type = glsl_type::bool_type;
  440. data.b[0] = true;
  441. for (c = 0; c < ir->operands[0]->type->components(); c++) {
  442. switch (ir->operands[0]->type->base_type) {
  443. case GLSL_TYPE_UINT:
  444. data.b[0] = data.b[0] && op[0]->value.u[c] == op[1]->value.u[c];
  445. break;
  446. case GLSL_TYPE_INT:
  447. data.b[0] = data.b[0] && op[0]->value.i[c] == op[1]->value.i[c];
  448. break;
  449. case GLSL_TYPE_FLOAT:
  450. data.b[0] = data.b[0] && op[0]->value.f[c] == op[1]->value.f[c];
  451. break;
  452. case GLSL_TYPE_BOOL:
  453. data.b[0] = data.b[0] && op[0]->value.b[c] == op[1]->value.b[c];
  454. break;
  455. default:
  456. assert(0);
  457. }
  458. }
  459. break;
  460. case ir_binop_nequal:
  461. type = glsl_type::bool_type;
  462. data.b[0] = false;
  463. for (c = 0; c < ir->operands[0]->type->components(); c++) {
  464. switch (ir->operands[0]->type->base_type) {
  465. case GLSL_TYPE_UINT:
  466. data.b[0] = data.b[0] || op[0]->value.u[c] != op[1]->value.u[c];
  467. break;
  468. case GLSL_TYPE_INT:
  469. data.b[0] = data.b[0] || op[0]->value.i[c] != op[1]->value.i[c];
  470. break;
  471. case GLSL_TYPE_FLOAT:
  472. data.b[0] = data.b[0] || op[0]->value.f[c] != op[1]->value.f[c];
  473. break;
  474. case GLSL_TYPE_BOOL:
  475. data.b[0] = data.b[0] || op[0]->value.b[c] != op[1]->value.b[c];
  476. break;
  477. default:
  478. assert(0);
  479. }
  480. }
  481. break;
  482. default:
  483. break;
  484. }
  485. if (type) {
  486. this->value = new ir_constant(type, &data);
  487. }
  488. }
  489. void
  490. ir_constant_visitor::visit(ir_texture *ir)
  491. {
  492. // FINISHME: Do stuff with texture lookups
  493. (void) ir;
  494. value = NULL;
  495. }
  496. void
  497. ir_constant_visitor::visit(ir_swizzle *ir)
  498. {
  499. ir_constant *v = ir->val->constant_expression_value();
  500. this->value = NULL;
  501. if (v != NULL) {
  502. ir_constant_data data;
  503. const unsigned swiz_idx[4] = {
  504. ir->mask.x, ir->mask.y, ir->mask.z, ir->mask.w
  505. };
  506. for (unsigned i = 0; i < ir->mask.num_components; i++) {
  507. switch (v->type->base_type) {
  508. case GLSL_TYPE_UINT:
  509. case GLSL_TYPE_INT: data.u[i] = v->value.u[swiz_idx[i]]; break;
  510. case GLSL_TYPE_FLOAT: data.f[i] = v->value.f[swiz_idx[i]]; break;
  511. case GLSL_TYPE_BOOL: data.b[i] = v->value.b[swiz_idx[i]]; break;
  512. default: assert(!"Should not get here."); break;
  513. }
  514. }
  515. this->value = new ir_constant(ir->type, &data);
  516. }
  517. }
  518. void
  519. ir_constant_visitor::visit(ir_dereference_variable *ir)
  520. {
  521. value = NULL;
  522. ir_variable *var = ir->variable_referenced();
  523. if (var && var->constant_value)
  524. value = var->constant_value->clone();
  525. }
  526. void
  527. ir_constant_visitor::visit(ir_dereference_array *ir)
  528. {
  529. ir_constant *array = ir->array->constant_expression_value();
  530. ir_constant *idx = ir->array_index->constant_expression_value();
  531. this->value = NULL;
  532. if ((array != NULL) && (idx != NULL)) {
  533. if (array->type->is_matrix()) {
  534. /* Array access of a matrix results in a vector.
  535. */
  536. const unsigned column = idx->value.u[0];
  537. const glsl_type *const column_type = array->type->column_type();
  538. /* Offset in the constant matrix to the first element of the column
  539. * to be extracted.
  540. */
  541. const unsigned mat_idx = column * column_type->vector_elements;
  542. ir_constant_data data;
  543. switch (column_type->base_type) {
  544. case GLSL_TYPE_UINT:
  545. case GLSL_TYPE_INT:
  546. for (unsigned i = 0; i < column_type->vector_elements; i++)
  547. data.u[i] = array->value.u[mat_idx + i];
  548. break;
  549. case GLSL_TYPE_FLOAT:
  550. for (unsigned i = 0; i < column_type->vector_elements; i++)
  551. data.f[i] = array->value.f[mat_idx + i];
  552. break;
  553. default:
  554. assert(!"Should not get here.");
  555. break;
  556. }
  557. this->value = new ir_constant(column_type, &data);
  558. } else if (array->type->is_vector()) {
  559. const unsigned component = idx->value.u[0];
  560. this->value = new ir_constant(array, component);
  561. } else {
  562. /* FINISHME: Handle access of constant arrays. */
  563. }
  564. }
  565. }
  566. void
  567. ir_constant_visitor::visit(ir_dereference_record *ir)
  568. {
  569. ir_constant *v = ir->record->constant_expression_value();
  570. this->value = (v != NULL) ? v->get_record_field(ir->field) : NULL;
  571. }
  572. void
  573. ir_constant_visitor::visit(ir_assignment *ir)
  574. {
  575. (void) ir;
  576. value = NULL;
  577. }
  578. void
  579. ir_constant_visitor::visit(ir_constant *ir)
  580. {
  581. value = ir;
  582. }
  583. void
  584. ir_constant_visitor::visit(ir_call *ir)
  585. {
  586. (void) ir;
  587. value = NULL;
  588. }
  589. void
  590. ir_constant_visitor::visit(ir_return *ir)
  591. {
  592. (void) ir;
  593. value = NULL;
  594. }
  595. void
  596. ir_constant_visitor::visit(ir_if *ir)
  597. {
  598. (void) ir;
  599. value = NULL;
  600. }
  601. void
  602. ir_constant_visitor::visit(ir_loop *ir)
  603. {
  604. (void) ir;
  605. value = NULL;
  606. }
  607. void
  608. ir_constant_visitor::visit(ir_loop_jump *ir)
  609. {
  610. (void) ir;
  611. value = NULL;
  612. }