ir.cpp revision 6315b68f5fbe529bce3497b67c42af1eaa62b8c1
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 <string.h> 24#include "main/imports.h" 25#include "ir.h" 26#include "ir_visitor.h" 27#include "glsl_types.h" 28 29ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs, 30 ir_rvalue *condition) 31{ 32 this->lhs = lhs; 33 this->rhs = rhs; 34 this->condition = condition; 35} 36 37 38ir_expression::ir_expression(int op, const struct glsl_type *type, 39 ir_rvalue *op0, ir_rvalue *op1) 40{ 41 this->type = type; 42 this->operation = ir_expression_operation(op); 43 this->operands[0] = op0; 44 this->operands[1] = op1; 45} 46 47unsigned int 48ir_expression::get_num_operands(ir_expression_operation op) 49{ 50/* Update ir_print_visitor.cpp when updating this list. */ 51 const int num_operands[] = { 52 1, /* ir_unop_bit_not */ 53 1, /* ir_unop_logic_not */ 54 1, /* ir_unop_neg */ 55 1, /* ir_unop_abs */ 56 1, /* ir_unop_sign */ 57 1, /* ir_unop_rcp */ 58 1, /* ir_unop_rsq */ 59 1, /* ir_unop_sqrt */ 60 1, /* ir_unop_exp */ 61 1, /* ir_unop_log */ 62 1, /* ir_unop_exp2 */ 63 1, /* ir_unop_log2 */ 64 1, /* ir_unop_f2i */ 65 1, /* ir_unop_i2f */ 66 1, /* ir_unop_f2b */ 67 1, /* ir_unop_b2f */ 68 1, /* ir_unop_i2b */ 69 1, /* ir_unop_b2i */ 70 1, /* ir_unop_u2f */ 71 72 1, /* ir_unop_trunc */ 73 1, /* ir_unop_ceil */ 74 1, /* ir_unop_floor */ 75 76 1, /* ir_unop_sin */ 77 1, /* ir_unop_cos */ 78 79 1, /* ir_unop_dFdx */ 80 1, /* ir_unop_dFdy */ 81 82 2, /* ir_binop_add */ 83 2, /* ir_binop_sub */ 84 2, /* ir_binop_mul */ 85 2, /* ir_binop_div */ 86 2, /* ir_binop_mod */ 87 88 2, /* ir_binop_less */ 89 2, /* ir_binop_greater */ 90 2, /* ir_binop_lequal */ 91 2, /* ir_binop_gequal */ 92 2, /* ir_binop_equal */ 93 2, /* ir_binop_nequal */ 94 95 2, /* ir_binop_lshift */ 96 2, /* ir_binop_rshift */ 97 2, /* ir_binop_bit_and */ 98 2, /* ir_binop_bit_xor */ 99 2, /* ir_binop_bit_or */ 100 101 2, /* ir_binop_logic_and */ 102 2, /* ir_binop_logic_xor */ 103 2, /* ir_binop_logic_or */ 104 105 2, /* ir_binop_dot */ 106 2, /* ir_binop_min */ 107 2, /* ir_binop_max */ 108 109 2, /* ir_binop_pow */ 110 }; 111 112 assert(sizeof(num_operands) / sizeof(num_operands[0]) == ir_binop_pow + 1); 113 114 return num_operands[op]; 115} 116 117static const char *const operator_strs[] = { 118 "~", 119 "!", 120 "neg", 121 "abs", 122 "sign", 123 "rcp", 124 "rsq", 125 "sqrt", 126 "exp", 127 "log", 128 "exp2", 129 "log2", 130 "f2i", 131 "i2f", 132 "f2b", 133 "b2f", 134 "i2b", 135 "b2i", 136 "u2f", 137 "trunc", 138 "ceil", 139 "floor", 140 "sin", 141 "cos", 142 "dFdx", 143 "dFdy", 144 "+", 145 "-", 146 "*", 147 "/", 148 "%", 149 "<", 150 ">", 151 "<=", 152 ">=", 153 "==", 154 "!=", 155 "<<", 156 ">>", 157 "&", 158 "^", 159 "|", 160 "&&", 161 "^^", 162 "||", 163 "dot", 164 "min", 165 "max", 166 "pow", 167}; 168 169const char *ir_expression::operator_string() 170{ 171 assert((unsigned int) operation <= 172 sizeof(operator_strs) / sizeof(operator_strs[0])); 173 return operator_strs[operation]; 174} 175 176ir_expression_operation 177ir_expression::get_operator(const char *str) 178{ 179 const int operator_count = sizeof(operator_strs) / sizeof(operator_strs[0]); 180 for (int op = 0; op < operator_count; op++) { 181 if (strcmp(str, operator_strs[op]) == 0) 182 return (ir_expression_operation) op; 183 } 184 return (ir_expression_operation) -1; 185} 186 187ir_constant::ir_constant() 188{ 189 /* empty */ 190} 191 192ir_constant::ir_constant(const struct glsl_type *type, 193 const ir_constant_data *data) 194{ 195 assert((type->base_type >= GLSL_TYPE_UINT) 196 && (type->base_type <= GLSL_TYPE_BOOL)); 197 198 this->type = type; 199 memcpy(& this->value, data, sizeof(this->value)); 200} 201 202ir_constant::ir_constant(float f) 203{ 204 this->type = glsl_type::float_type; 205 this->value.f[0] = f; 206} 207 208ir_constant::ir_constant(unsigned int u) 209{ 210 this->type = glsl_type::uint_type; 211 this->value.u[0] = u; 212} 213 214ir_constant::ir_constant(int i) 215{ 216 this->type = glsl_type::int_type; 217 this->value.i[0] = i; 218} 219 220ir_constant::ir_constant(bool b) 221{ 222 this->type = glsl_type::bool_type; 223 this->value.b[0] = b; 224} 225 226ir_constant::ir_constant(const ir_constant *c, unsigned i) 227{ 228 this->type = c->type->get_base_type(); 229 230 switch (this->type->base_type) { 231 case GLSL_TYPE_UINT: this->value.u[0] = c->value.u[i]; break; 232 case GLSL_TYPE_INT: this->value.i[0] = c->value.i[i]; break; 233 case GLSL_TYPE_FLOAT: this->value.f[0] = c->value.f[i]; break; 234 case GLSL_TYPE_BOOL: this->value.b[0] = c->value.b[i]; break; 235 default: assert(!"Should not get here."); break; 236 } 237} 238 239ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list) 240{ 241 this->type = type; 242 243 /* FINISHME: Support array types. */ 244 assert(type->is_scalar() || type->is_vector() || type->is_matrix() 245 || type->is_record()); 246 247 /* If the constant is a record, the types of each of the entries in 248 * value_list must be a 1-for-1 match with the structure components. Each 249 * entry must also be a constant. Just move the nodes from the value_list 250 * to the list in the ir_constant. 251 */ 252 /* FINISHME: Should there be some type checking and / or assertions here? */ 253 /* FINISHME: Should the new constant take ownership of the nodes from 254 * FINISHME: value_list, or should it make copies? 255 */ 256 if (type->is_record()) { 257 value_list->move_nodes_to(& this->components); 258 return; 259 } 260 261 262 ir_constant *value = (ir_constant *) (value_list->head); 263 264 /* Use each component from each entry in the value_list to initialize one 265 * component of the constant being constructed. 266 */ 267 for (unsigned i = 0; i < type->components(); /* empty */) { 268 assert(value->as_constant() != NULL); 269 assert(!value->is_tail_sentinal()); 270 271 for (unsigned j = 0; j < value->type->components(); j++) { 272 switch (type->base_type) { 273 case GLSL_TYPE_UINT: 274 this->value.u[i] = value->get_uint_component(j); 275 break; 276 case GLSL_TYPE_INT: 277 this->value.i[i] = value->get_int_component(j); 278 break; 279 case GLSL_TYPE_FLOAT: 280 this->value.f[i] = value->get_float_component(j); 281 break; 282 case GLSL_TYPE_BOOL: 283 this->value.b[i] = value->get_bool_component(j); 284 break; 285 default: 286 /* FINISHME: What to do? Exceptions are not the answer. 287 */ 288 break; 289 } 290 291 i++; 292 if (i >= type->components()) 293 break; 294 } 295 296 value = (ir_constant *) value->next; 297 } 298} 299 300bool 301ir_constant::get_bool_component(unsigned i) const 302{ 303 switch (this->type->base_type) { 304 case GLSL_TYPE_UINT: return this->value.u[i] != 0; 305 case GLSL_TYPE_INT: return this->value.i[i] != 0; 306 case GLSL_TYPE_FLOAT: return ((int)this->value.f[i]) != 0; 307 case GLSL_TYPE_BOOL: return this->value.b[i]; 308 default: assert(!"Should not get here."); break; 309 } 310 311 /* Must return something to make the compiler happy. This is clearly an 312 * error case. 313 */ 314 return false; 315} 316 317float 318ir_constant::get_float_component(unsigned i) const 319{ 320 switch (this->type->base_type) { 321 case GLSL_TYPE_UINT: return (float) this->value.u[i]; 322 case GLSL_TYPE_INT: return (float) this->value.i[i]; 323 case GLSL_TYPE_FLOAT: return this->value.f[i]; 324 case GLSL_TYPE_BOOL: return this->value.b[i] ? 1.0 : 0.0; 325 default: assert(!"Should not get here."); break; 326 } 327 328 /* Must return something to make the compiler happy. This is clearly an 329 * error case. 330 */ 331 return 0.0; 332} 333 334int 335ir_constant::get_int_component(unsigned i) const 336{ 337 switch (this->type->base_type) { 338 case GLSL_TYPE_UINT: return this->value.u[i]; 339 case GLSL_TYPE_INT: return this->value.i[i]; 340 case GLSL_TYPE_FLOAT: return (int) this->value.f[i]; 341 case GLSL_TYPE_BOOL: return this->value.b[i] ? 1 : 0; 342 default: assert(!"Should not get here."); break; 343 } 344 345 /* Must return something to make the compiler happy. This is clearly an 346 * error case. 347 */ 348 return 0; 349} 350 351unsigned 352ir_constant::get_uint_component(unsigned i) const 353{ 354 switch (this->type->base_type) { 355 case GLSL_TYPE_UINT: return this->value.u[i]; 356 case GLSL_TYPE_INT: return this->value.i[i]; 357 case GLSL_TYPE_FLOAT: return (unsigned) this->value.f[i]; 358 case GLSL_TYPE_BOOL: return this->value.b[i] ? 1 : 0; 359 default: assert(!"Should not get here."); break; 360 } 361 362 /* Must return something to make the compiler happy. This is clearly an 363 * error case. 364 */ 365 return 0; 366} 367 368 369ir_constant * 370ir_constant::get_record_field(const char *name) 371{ 372 int idx = this->type->field_index(name); 373 374 if (idx < 0) 375 return NULL; 376 377 if (this->components.is_empty()) 378 return NULL; 379 380 exec_node *node = this->components.head; 381 for (int i = 0; i < idx; i++) { 382 node = node->next; 383 384 /* If the end of the list is encountered before the element matching the 385 * requested field is found, return NULL. 386 */ 387 if (node->is_tail_sentinal()) 388 return NULL; 389 } 390 391 return (ir_constant *) node; 392} 393 394 395bool 396ir_constant::has_value(const ir_constant *c) const 397{ 398 if (this->type != c->type) 399 return false; 400 401 /* FINISHME: This will probably also handle constant arrays as soon as those 402 * FINISHME: are supported. 403 */ 404 if (this->type->base_type == GLSL_TYPE_STRUCT) { 405 const exec_node *a_node = this->components.head; 406 const exec_node *b_node = c->components.head; 407 408 while (!a_node->is_tail_sentinal()) { 409 assert(!b_node->is_tail_sentinal()); 410 411 const ir_constant *const a_field = (ir_constant *) a_node; 412 const ir_constant *const b_field = (ir_constant *) b_node; 413 414 if (!a_field->has_value(b_field)) 415 return false; 416 417 a_node = a_node->next; 418 b_node = b_node->next; 419 } 420 421 return true; 422 } 423 424 for (unsigned i = 0; i < this->type->components(); i++) { 425 switch (this->type->base_type) { 426 case GLSL_TYPE_UINT: 427 if (this->value.u[i] != c->value.u[i]) 428 return false; 429 break; 430 case GLSL_TYPE_INT: 431 if (this->value.i[i] != c->value.i[i]) 432 return false; 433 break; 434 case GLSL_TYPE_FLOAT: 435 if (this->value.f[i] != c->value.f[i]) 436 return false; 437 break; 438 case GLSL_TYPE_BOOL: 439 if (this->value.b[i] != c->value.b[i]) 440 return false; 441 break; 442 default: 443 assert(!"Should not get here."); 444 return false; 445 } 446 } 447 448 return true; 449} 450 451ir_dereference_variable::ir_dereference_variable(ir_variable *var) 452{ 453 this->var = var; 454 this->type = (var != NULL) ? var->type : glsl_type::error_type; 455} 456 457 458ir_dereference_array::ir_dereference_array(ir_rvalue *value, 459 ir_rvalue *array_index) 460{ 461 this->array_index = array_index; 462 this->set_array(value); 463} 464 465 466ir_dereference_array::ir_dereference_array(ir_variable *var, 467 ir_rvalue *array_index) 468{ 469 void *ctx = talloc_parent(var); 470 471 this->array_index = array_index; 472 this->set_array(new(ctx) ir_dereference_variable(var)); 473} 474 475 476void 477ir_dereference_array::set_array(ir_rvalue *value) 478{ 479 this->array = value; 480 this->type = glsl_type::error_type; 481 482 if (this->array != NULL) { 483 const glsl_type *const vt = this->array->type; 484 485 if (vt->is_array()) { 486 type = vt->element_type(); 487 } else if (vt->is_matrix()) { 488 type = vt->column_type(); 489 } else if (vt->is_vector()) { 490 type = vt->get_base_type(); 491 } 492 } 493} 494 495 496ir_dereference_record::ir_dereference_record(ir_rvalue *value, 497 const char *field) 498{ 499 this->record = value; 500 this->field = field; 501 this->type = (this->record != NULL) 502 ? this->record->type->field_type(field) : glsl_type::error_type; 503} 504 505 506ir_dereference_record::ir_dereference_record(ir_variable *var, 507 const char *field) 508{ 509 void *ctx = talloc_parent(var); 510 511 this->record = new(ctx) ir_dereference_variable(var); 512 this->field = field; 513 this->type = (this->record != NULL) 514 ? this->record->type->field_type(field) : glsl_type::error_type; 515} 516 517 518bool 519ir_dereference::is_lvalue() 520{ 521 ir_variable *var = this->variable_referenced(); 522 523 /* Every l-value derference chain eventually ends in a variable. 524 */ 525 if ((var == NULL) || var->read_only) 526 return false; 527 528 if (this->type->is_array() && !var->array_lvalue) 529 return false; 530 531 return true; 532} 533 534 535const char *tex_opcode_strs[] = { "tex", "txb", "txl", "txd", "txf" }; 536 537const char *ir_texture::opcode_string() 538{ 539 assert((unsigned int) op <= 540 sizeof(tex_opcode_strs) / sizeof(tex_opcode_strs[0])); 541 return tex_opcode_strs[op]; 542} 543 544ir_texture_opcode 545ir_texture::get_opcode(const char *str) 546{ 547 const int count = sizeof(tex_opcode_strs) / sizeof(tex_opcode_strs[0]); 548 for (int op = 0; op < count; op++) { 549 if (strcmp(str, tex_opcode_strs[op]) == 0) 550 return (ir_texture_opcode) op; 551 } 552 return (ir_texture_opcode) -1; 553} 554 555 556void 557ir_texture::set_sampler(ir_dereference *sampler) 558{ 559 assert(sampler != NULL); 560 this->sampler = sampler; 561 562 switch (sampler->type->sampler_type) { 563 case GLSL_TYPE_FLOAT: 564 this->type = glsl_type::vec4_type; 565 break; 566 case GLSL_TYPE_INT: 567 this->type = glsl_type::ivec4_type; 568 break; 569 case GLSL_TYPE_UINT: 570 this->type = glsl_type::uvec4_type; 571 break; 572 } 573} 574 575 576void 577ir_swizzle::init_mask(const unsigned *comp, unsigned count) 578{ 579 assert((count >= 1) && (count <= 4)); 580 581 memset(&this->mask, 0, sizeof(this->mask)); 582 this->mask.num_components = count; 583 584 unsigned dup_mask = 0; 585 switch (count) { 586 case 4: 587 assert(comp[3] <= 3); 588 dup_mask |= (1U << comp[3]) 589 & ((1U << comp[0]) | (1U << comp[1]) | (1U << comp[2])); 590 this->mask.w = comp[3]; 591 592 case 3: 593 assert(comp[2] <= 3); 594 dup_mask |= (1U << comp[2]) 595 & ((1U << comp[0]) | (1U << comp[1])); 596 this->mask.z = comp[2]; 597 598 case 2: 599 assert(comp[1] <= 3); 600 dup_mask |= (1U << comp[1]) 601 & ((1U << comp[0])); 602 this->mask.y = comp[1]; 603 604 case 1: 605 assert(comp[0] <= 3); 606 this->mask.x = comp[0]; 607 } 608 609 this->mask.has_duplicates = dup_mask != 0; 610 611 /* Based on the number of elements in the swizzle and the base type 612 * (i.e., float, int, unsigned, or bool) of the vector being swizzled, 613 * generate the type of the resulting value. 614 */ 615 type = glsl_type::get_instance(val->type->base_type, mask.num_components, 1); 616} 617 618ir_swizzle::ir_swizzle(ir_rvalue *val, unsigned x, unsigned y, unsigned z, 619 unsigned w, unsigned count) 620 : val(val) 621{ 622 const unsigned components[4] = { x, y, z, w }; 623 this->init_mask(components, count); 624} 625 626ir_swizzle::ir_swizzle(ir_rvalue *val, const unsigned *comp, 627 unsigned count) 628 : val(val) 629{ 630 this->init_mask(comp, count); 631} 632 633ir_swizzle::ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask) 634{ 635 this->val = val; 636 this->mask = mask; 637 this->type = glsl_type::get_instance(val->type->base_type, 638 mask.num_components, 1); 639} 640 641#define X 1 642#define R 5 643#define S 9 644#define I 13 645 646ir_swizzle * 647ir_swizzle::create(ir_rvalue *val, const char *str, unsigned vector_length) 648{ 649 void *ctx = talloc_parent(val); 650 651 /* For each possible swizzle character, this table encodes the value in 652 * \c idx_map that represents the 0th element of the vector. For invalid 653 * swizzle characters (e.g., 'k'), a special value is used that will allow 654 * detection of errors. 655 */ 656 static const unsigned char base_idx[26] = { 657 /* a b c d e f g h i j k l m */ 658 R, R, I, I, I, I, R, I, I, I, I, I, I, 659 /* n o p q r s t u v w x y z */ 660 I, I, S, S, R, S, S, I, I, X, X, X, X 661 }; 662 663 /* Each valid swizzle character has an entry in the previous table. This 664 * table encodes the base index encoded in the previous table plus the actual 665 * index of the swizzle character. When processing swizzles, the first 666 * character in the string is indexed in the previous table. Each character 667 * in the string is indexed in this table, and the value found there has the 668 * value form the first table subtracted. The result must be on the range 669 * [0,3]. 670 * 671 * For example, the string "wzyx" will get X from the first table. Each of 672 * the charcaters will get X+3, X+2, X+1, and X+0 from this table. After 673 * subtraction, the swizzle values are { 3, 2, 1, 0 }. 674 * 675 * The string "wzrg" will get X from the first table. Each of the characters 676 * will get X+3, X+2, R+0, and R+1 from this table. After subtraction, the 677 * swizzle values are { 3, 2, 4, 5 }. Since 4 and 5 are outside the range 678 * [0,3], the error is detected. 679 */ 680 static const unsigned char idx_map[26] = { 681 /* a b c d e f g h i j k l m */ 682 R+3, R+2, 0, 0, 0, 0, R+1, 0, 0, 0, 0, 0, 0, 683 /* n o p q r s t u v w x y z */ 684 0, 0, S+2, S+3, R+0, S+0, S+1, 0, 0, X+3, X+0, X+1, X+2 685 }; 686 687 int swiz_idx[4] = { 0, 0, 0, 0 }; 688 unsigned i; 689 690 691 /* Validate the first character in the swizzle string and look up the base 692 * index value as described above. 693 */ 694 if ((str[0] < 'a') || (str[0] > 'z')) 695 return NULL; 696 697 const unsigned base = base_idx[str[0] - 'a']; 698 699 700 for (i = 0; (i < 4) && (str[i] != '\0'); i++) { 701 /* Validate the next character, and, as described above, convert it to a 702 * swizzle index. 703 */ 704 if ((str[i] < 'a') || (str[i] > 'z')) 705 return NULL; 706 707 swiz_idx[i] = idx_map[str[i] - 'a'] - base; 708 if ((swiz_idx[i] < 0) || (swiz_idx[i] >= (int) vector_length)) 709 return NULL; 710 } 711 712 if (str[i] != '\0') 713 return NULL; 714 715 return new(ctx) ir_swizzle(val, swiz_idx[0], swiz_idx[1], swiz_idx[2], 716 swiz_idx[3], i); 717} 718 719#undef X 720#undef R 721#undef S 722#undef I 723 724ir_variable * 725ir_swizzle::variable_referenced() 726{ 727 return this->val->variable_referenced(); 728} 729 730ir_variable::ir_variable(const struct glsl_type *type, const char *name) 731 : max_array_access(0), read_only(false), centroid(false), invariant(false), 732 shader_in(false), shader_out(false), 733 mode(ir_var_auto), interpolation(ir_var_smooth), array_lvalue(false) 734{ 735 this->type = type; 736 this->name = name; 737 this->location = -1; 738 this->warn_extension = NULL; 739 this->constant_value = NULL; 740 741 if (type && type->base_type == GLSL_TYPE_SAMPLER) 742 this->read_only = true; 743} 744 745 746const char * 747ir_variable::interpolation_string() const 748{ 749 if (!this->shader_in && !this->shader_out) 750 return ""; 751 752 switch (this->interpolation) { 753 case ir_var_smooth: return "smooth"; 754 case ir_var_flat: return "flat"; 755 case ir_var_noperspective: return "noperspective"; 756 } 757 758 assert(!"Should not get here."); 759 return ""; 760} 761 762 763unsigned 764ir_variable::component_slots() const 765{ 766 /* FINISHME: Sparsely accessed arrays require fewer slots. */ 767 return this->type->component_slots(); 768} 769 770 771ir_function_signature::ir_function_signature(const glsl_type *return_type) 772 : return_type(return_type), is_defined(false) 773{ 774 /* empty */ 775} 776 777 778const char * 779ir_function_signature::qualifiers_match(exec_list *params) 780{ 781 exec_list_iterator iter_a = parameters.iterator(); 782 exec_list_iterator iter_b = params->iterator(); 783 784 /* check that the qualifiers match. */ 785 while (iter_a.has_next()) { 786 ir_variable *a = (ir_variable *)iter_a.get(); 787 ir_variable *b = (ir_variable *)iter_b.get(); 788 789 if (a->read_only != b->read_only || 790 a->mode != b->mode || 791 a->interpolation != b->interpolation || 792 a->centroid != b->centroid) { 793 794 /* parameter a's qualifiers don't match */ 795 return a->name; 796 } 797 798 iter_a.next(); 799 iter_b.next(); 800 } 801 return NULL; 802} 803 804 805void 806ir_function_signature::replace_parameters(exec_list *new_params) 807{ 808 /* Destroy all of the previous parameter information. If the previous 809 * parameter information comes from the function prototype, it may either 810 * specify incorrect parameter names or not have names at all. 811 */ 812 foreach_iter(exec_list_iterator, iter, parameters) { 813 assert(((ir_instruction *) iter.get())->as_variable() != NULL); 814 815 iter.remove(); 816 } 817 818 new_params->move_nodes_to(¶meters); 819} 820 821 822ir_function::ir_function(const char *name) 823 : name(name) 824{ 825 /* empty */ 826} 827 828 829ir_call * 830ir_call::get_error_instruction(void *ctx) 831{ 832 ir_call *call = new(ctx) ir_call; 833 834 call->type = glsl_type::error_type; 835 return call; 836} 837 838void 839visit_exec_list(exec_list *list, ir_visitor *visitor) 840{ 841 foreach_iter(exec_list_iterator, iter, *list) { 842 ((ir_instruction *)iter.get())->accept(visitor); 843 } 844} 845 846