| ... | ... | @@ -610,13 +610,12 @@ static IrInstruction *ir_build_return_from(IrBuilder *irb, IrInstruction *old_in |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | static IrInstruction *ir_create_const(IrBuilder *irb, Scope *scope, AstNode *source_node, |
| 613 | | TypeTableEntry *type_entry, bool depends_on_compile_var) |
| 613 | TypeTableEntry *type_entry) |
| 614 | 614 | { |
| 615 | 615 | assert(type_entry); |
| 616 | 616 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); |
| 617 | 617 | const_instruction->base.value.type = type_entry; |
| 618 | 618 | const_instruction->base.value.special = ConstValSpecialStatic; |
| 619 | | const_instruction->base.value.depends_on_compile_var = depends_on_compile_var; |
| 620 | 619 | return &const_instruction->base; |
| 621 | 620 | } |
| 622 | 621 | |
| ... | ... | @@ -667,20 +666,19 @@ static IrInstruction *ir_build_const_usize(IrBuilder *irb, Scope *scope, AstNode |
| 667 | 666 | } |
| 668 | 667 | |
| 669 | 668 | static IrInstruction *ir_create_const_type(IrBuilder *irb, Scope *scope, AstNode *source_node, |
| 670 | | TypeTableEntry *type_entry, bool depends_on_compile_var) |
| 669 | TypeTableEntry *type_entry) |
| 671 | 670 | { |
| 672 | 671 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); |
| 673 | 672 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_type; |
| 674 | 673 | const_instruction->base.value.special = ConstValSpecialStatic; |
| 675 | | const_instruction->base.value.depends_on_compile_var = depends_on_compile_var; |
| 676 | 674 | const_instruction->base.value.data.x_type = type_entry; |
| 677 | 675 | return &const_instruction->base; |
| 678 | 676 | } |
| 679 | 677 | |
| 680 | 678 | static IrInstruction *ir_build_const_type(IrBuilder *irb, Scope *scope, AstNode *source_node, |
| 681 | | TypeTableEntry *type_entry, bool depends_on_compile_var) |
| 679 | TypeTableEntry *type_entry) |
| 682 | 680 | { |
| 683 | | IrInstruction *instruction = ir_create_const_type(irb, scope, source_node, type_entry, depends_on_compile_var); |
| 681 | IrInstruction *instruction = ir_create_const_type(irb, scope, source_node, type_entry); |
| 684 | 682 | ir_instruction_append(irb->current_basic_block, instruction); |
| 685 | 683 | return instruction; |
| 686 | 684 | } |
| ... | ... | @@ -720,12 +718,11 @@ static IrInstruction *ir_build_const_bool(IrBuilder *irb, Scope *scope, AstNode |
| 720 | 718 | } |
| 721 | 719 | |
| 722 | 720 | static IrInstruction *ir_build_const_bound_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, |
| 723 | | FnTableEntry *fn_entry, IrInstruction *first_arg, bool depends_on_compile_var) |
| 721 | FnTableEntry *fn_entry, IrInstruction *first_arg) |
| 724 | 722 | { |
| 725 | 723 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); |
| 726 | 724 | const_instruction->base.value.type = get_bound_fn_type(irb->codegen, fn_entry); |
| 727 | 725 | const_instruction->base.value.special = ConstValSpecialStatic; |
| 728 | | const_instruction->base.value.depends_on_compile_var = depends_on_compile_var; |
| 729 | 726 | const_instruction->base.value.data.x_bound_fn.fn = fn_entry; |
| 730 | 727 | const_instruction->base.value.data.x_bound_fn.first_arg = first_arg; |
| 731 | 728 | return &const_instruction->base; |
| ... | ... | @@ -3609,7 +3606,7 @@ static IrInstruction *ir_gen_null_literal(IrBuilder *irb, Scope *scope, AstNode |
| 3609 | 3606 | static IrInstruction *ir_gen_var_literal(IrBuilder *irb, Scope *scope, AstNode *node) { |
| 3610 | 3607 | assert(node->type == NodeTypeVarLiteral); |
| 3611 | 3608 | |
| 3612 | | return ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_var, false); |
| 3609 | return ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_var); |
| 3613 | 3610 | } |
| 3614 | 3611 | |
| 3615 | 3612 | static IrInstruction *ir_gen_decl_ref(IrBuilder *irb, AstNode *source_node, Tld *tld, |
| ... | ... | @@ -3648,7 +3645,7 @@ static IrInstruction *ir_gen_decl_ref(IrBuilder *irb, AstNode *source_node, Tld |
| 3648 | 3645 | { |
| 3649 | 3646 | TldTypeDef *tld_typedef = (TldTypeDef *)tld; |
| 3650 | 3647 | TypeTableEntry *typedef_type = tld_typedef->type_entry; |
| 3651 | | IrInstruction *ref_instruction = ir_build_const_type(irb, scope, source_node, typedef_type, false); |
| 3648 | IrInstruction *ref_instruction = ir_build_const_type(irb, scope, source_node, typedef_type); |
| 3652 | 3649 | if (lval.is_ptr) |
| 3653 | 3650 | return ir_build_ref(irb, scope, source_node, ref_instruction, true, false); |
| 3654 | 3651 | else |
| ... | ... | @@ -3665,7 +3662,7 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, |
| 3665 | 3662 | |
| 3666 | 3663 | auto primitive_table_entry = irb->codegen->primitive_type_table.maybe_get(variable_name); |
| 3667 | 3664 | if (primitive_table_entry) { |
| 3668 | | IrInstruction *value = ir_build_const_type(irb, scope, node, primitive_table_entry->value, false); |
| 3665 | IrInstruction *value = ir_build_const_type(irb, scope, node, primitive_table_entry->value); |
| 3669 | 3666 | if (lval.is_ptr) { |
| 3670 | 3667 | return ir_build_ref(irb, scope, node, value, lval.is_const, lval.is_volatile); |
| 3671 | 3668 | } else { |
| ... | ... | @@ -4629,7 +4626,7 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo |
| 4629 | 4626 | } |
| 4630 | 4627 | child_scope = index_var->child_scope; |
| 4631 | 4628 | |
| 4632 | | IrInstruction *usize = ir_build_const_type(irb, child_scope, node, irb->codegen->builtin_types.entry_usize, false); |
| 4629 | IrInstruction *usize = ir_build_const_type(irb, child_scope, node, irb->codegen->builtin_types.entry_usize); |
| 4633 | 4630 | IrInstruction *zero = ir_build_const_usize(irb, child_scope, node, 0); |
| 4634 | 4631 | IrInstruction *one = ir_build_const_usize(irb, child_scope, node, 1); |
| 4635 | 4632 | ir_build_var_decl(irb, child_scope, index_var_source_node, index_var, usize, zero); |
| ... | ... | @@ -4693,7 +4690,7 @@ static IrInstruction *ir_gen_this_literal(IrBuilder *irb, Scope *scope, AstNode |
| 4693 | 4690 | ScopeDecls *decls_scope = (ScopeDecls *)scope; |
| 4694 | 4691 | TypeTableEntry *container_type = decls_scope->container_type; |
| 4695 | 4692 | assert(container_type); |
| 4696 | | return ir_build_const_type(irb, scope, node, container_type, false); |
| 4693 | return ir_build_const_type(irb, scope, node, container_type); |
| 4697 | 4694 | } |
| 4698 | 4695 | |
| 4699 | 4696 | if (scope->id == ScopeIdBlock) |
| ... | ... | @@ -5260,12 +5257,12 @@ static IrInstruction *ir_gen_continue(IrBuilder *irb, Scope *scope, AstNode *nod |
| 5260 | 5257 | |
| 5261 | 5258 | static IrInstruction *ir_gen_type_literal(IrBuilder *irb, Scope *scope, AstNode *node) { |
| 5262 | 5259 | assert(node->type == NodeTypeTypeLiteral); |
| 5263 | | return ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_type, false); |
| 5260 | return ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_type); |
| 5264 | 5261 | } |
| 5265 | 5262 | |
| 5266 | 5263 | static IrInstruction *ir_gen_error_type(IrBuilder *irb, Scope *scope, AstNode *node) { |
| 5267 | 5264 | assert(node->type == NodeTypeErrorType); |
| 5268 | | return ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_pure_error, false); |
| 5265 | return ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_pure_error); |
| 5269 | 5266 | } |
| 5270 | 5267 | |
| 5271 | 5268 | static IrInstruction *ir_gen_defer(IrBuilder *irb, Scope *parent_scope, AstNode *node) { |
| ... | ... | @@ -5339,7 +5336,7 @@ static IrInstruction *ir_gen_err_ok_or(IrBuilder *irb, Scope *parent_scope, AstN |
| 5339 | 5336 | if (var_node) { |
| 5340 | 5337 | assert(var_node->type == NodeTypeSymbol); |
| 5341 | 5338 | IrInstruction *var_type = ir_build_const_type(irb, parent_scope, node, |
| 5342 | | irb->codegen->builtin_types.entry_pure_error, false); |
| 5339 | irb->codegen->builtin_types.entry_pure_error); |
| 5343 | 5340 | Buf *var_name = var_node->data.symbol_expr.symbol; |
| 5344 | 5341 | bool is_const = true; |
| 5345 | 5342 | bool is_shadowable = false; |
| ... | ... | @@ -5427,7 +5424,7 @@ static IrInstruction *ir_gen_container_decl(IrBuilder *irb, Scope *parent_scope, |
| 5427 | 5424 | } |
| 5428 | 5425 | irb->codegen->resolve_queue.append(&tld_container->base); |
| 5429 | 5426 | |
| 5430 | | return ir_build_const_type(irb, parent_scope, node, container_type, false); |
| 5427 | return ir_build_const_type(irb, parent_scope, node, container_type); |
| 5431 | 5428 | } |
| 5432 | 5429 | |
| 5433 | 5430 | static IrInstruction *ir_gen_fn_proto(IrBuilder *irb, Scope *parent_scope, AstNode *node) { |
| ... | ... | @@ -5997,7 +5994,6 @@ static void eval_const_expr_implicit_cast(CastOp cast_op, |
| 5997 | 5994 | ConstExprValue *other_val, TypeTableEntry *other_type, |
| 5998 | 5995 | ConstExprValue *const_val, TypeTableEntry *new_type) |
| 5999 | 5996 | { |
| 6000 | | const_val->depends_on_compile_var = other_val->depends_on_compile_var; |
| 6001 | 5997 | const_val->special = other_val->special; |
| 6002 | 5998 | |
| 6003 | 5999 | assert(other_val != const_val); |
| ... | ... | @@ -6045,7 +6041,7 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 6045 | 6041 | { |
| 6046 | 6042 | if (value->value.special != ConstValSpecialRuntime) { |
| 6047 | 6043 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, |
| 6048 | | source_instr->source_node, wanted_type, false); |
| 6044 | source_instr->source_node, wanted_type); |
| 6049 | 6045 | eval_const_expr_implicit_cast(cast_op, &value->value, value->value.type, |
| 6050 | 6046 | &result->value, wanted_type); |
| 6051 | 6047 | return result; |
| ... | ... | @@ -6179,9 +6175,7 @@ static TypeTableEntry *ir_finish_anal(IrAnalyze *ira, TypeTableEntry *result_typ |
| 6179 | 6175 | return result_type; |
| 6180 | 6176 | } |
| 6181 | 6177 | |
| 6182 | | static ConstExprValue *ir_build_const_from(IrAnalyze *ira, IrInstruction *old_instruction, |
| 6183 | | bool depends_on_compile_var) |
| 6184 | | { |
| 6178 | static ConstExprValue *ir_build_const_from(IrAnalyze *ira, IrInstruction *old_instruction) { |
| 6185 | 6179 | IrInstruction *new_instruction; |
| 6186 | 6180 | if (old_instruction->id == IrInstructionIdVarPtr) { |
| 6187 | 6181 | IrInstructionVarPtr *old_var_ptr_instruction = (IrInstructionVarPtr *)old_instruction; |
| ... | ... | @@ -6205,17 +6199,16 @@ static ConstExprValue *ir_build_const_from(IrAnalyze *ira, IrInstruction *old_in |
| 6205 | 6199 | ir_link_new_instruction(new_instruction, old_instruction); |
| 6206 | 6200 | ConstExprValue *const_val = &new_instruction->value; |
| 6207 | 6201 | const_val->special = ConstValSpecialStatic; |
| 6208 | | const_val->depends_on_compile_var = depends_on_compile_var; |
| 6209 | 6202 | return const_val; |
| 6210 | 6203 | } |
| 6211 | 6204 | |
| 6212 | 6205 | static TypeTableEntry *ir_analyze_void(IrAnalyze *ira, IrInstruction *instruction) { |
| 6213 | | ir_build_const_from(ira, instruction, false); |
| 6206 | ir_build_const_from(ira, instruction); |
| 6214 | 6207 | return ira->codegen->builtin_types.entry_void; |
| 6215 | 6208 | } |
| 6216 | 6209 | |
| 6217 | 6210 | static TypeTableEntry *ir_analyze_const_ptr(IrAnalyze *ira, IrInstruction *instruction, |
| 6218 | | ConstExprValue *pointee, TypeTableEntry *pointee_type, bool depends_on_compile_var, |
| 6211 | ConstExprValue *pointee, TypeTableEntry *pointee_type, |
| 6219 | 6212 | ConstPtrSpecial special, bool ptr_is_const, bool ptr_is_volatile) |
| 6220 | 6213 | { |
| 6221 | 6214 | if (pointee_type->id == TypeTableEntryIdMetaType) { |
| ... | ... | @@ -6225,8 +6218,7 @@ static TypeTableEntry *ir_analyze_const_ptr(IrAnalyze *ira, IrInstruction *instr |
| 6225 | 6218 | return ira->codegen->builtin_types.entry_invalid; |
| 6226 | 6219 | } |
| 6227 | 6220 | |
| 6228 | | ConstExprValue *const_val = ir_build_const_from(ira, instruction, |
| 6229 | | depends_on_compile_var || pointee->depends_on_compile_var); |
| 6221 | ConstExprValue *const_val = ir_build_const_from(ira, instruction); |
| 6230 | 6222 | type_ensure_zero_bits_known(ira->codegen, type_entry); |
| 6231 | 6223 | const_val->data.x_type = get_pointer_to_type_volatile(ira->codegen, type_entry, |
| 6232 | 6224 | ptr_is_const, ptr_is_volatile); |
| ... | ... | @@ -6234,8 +6226,7 @@ static TypeTableEntry *ir_analyze_const_ptr(IrAnalyze *ira, IrInstruction *instr |
| 6234 | 6226 | } else { |
| 6235 | 6227 | TypeTableEntry *ptr_type = get_pointer_to_type_volatile(ira->codegen, pointee_type, |
| 6236 | 6228 | ptr_is_const, ptr_is_volatile); |
| 6237 | | ConstExprValue *const_val = ir_build_const_from(ira, instruction, |
| 6238 | | depends_on_compile_var || pointee->depends_on_compile_var); |
| 6229 | ConstExprValue *const_val = ir_build_const_from(ira, instruction); |
| 6239 | 6230 | const_val->data.x_ptr.base_ptr = pointee; |
| 6240 | 6231 | const_val->data.x_ptr.index = SIZE_MAX; |
| 6241 | 6232 | const_val->data.x_ptr.special = special; |
| ... | ... | @@ -6243,10 +6234,8 @@ static TypeTableEntry *ir_analyze_const_ptr(IrAnalyze *ira, IrInstruction *instr |
| 6243 | 6234 | } |
| 6244 | 6235 | } |
| 6245 | 6236 | |
| 6246 | | static TypeTableEntry *ir_analyze_const_usize(IrAnalyze *ira, IrInstruction *instruction, uint64_t value, |
| 6247 | | bool depends_on_compile_var) |
| 6248 | | { |
| 6249 | | ConstExprValue *const_val = ir_build_const_from(ira, instruction, depends_on_compile_var); |
| 6237 | static TypeTableEntry *ir_analyze_const_usize(IrAnalyze *ira, IrInstruction *instruction, uint64_t value) { |
| 6238 | ConstExprValue *const_val = ir_build_const_from(ira, instruction); |
| 6250 | 6239 | bignum_init_unsigned(&const_val->data.x_bignum, value); |
| 6251 | 6240 | return ira->codegen->builtin_types.entry_usize; |
| 6252 | 6241 | } |
| ... | ... | @@ -6376,7 +6365,6 @@ static IrInstruction *ir_analyze_maybe_wrap(IrAnalyze *ira, IrInstruction *sourc |
| 6376 | 6365 | source_instr->scope, source_instr->source_node); |
| 6377 | 6366 | const_instruction->base.value.type = wanted_type; |
| 6378 | 6367 | const_instruction->base.value.special = ConstValSpecialStatic; |
| 6379 | | const_instruction->base.value.depends_on_compile_var = val->depends_on_compile_var; |
| 6380 | 6368 | const_instruction->base.value.data.x_maybe = val; |
| 6381 | 6369 | return &const_instruction->base; |
| 6382 | 6370 | } |
| ... | ... | @@ -6435,7 +6423,6 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction |
| 6435 | 6423 | source_instr->scope, source_instr->source_node); |
| 6436 | 6424 | const_instruction->base.value.type = wanted_type; |
| 6437 | 6425 | const_instruction->base.value.special = ConstValSpecialStatic; |
| 6438 | | const_instruction->base.value.depends_on_compile_var = val->depends_on_compile_var; |
| 6439 | 6426 | const_instruction->base.value.data.x_err_union.err = nullptr; |
| 6440 | 6427 | const_instruction->base.value.data.x_err_union.payload = val; |
| 6441 | 6428 | return &const_instruction->base; |
| ... | ... | @@ -6460,7 +6447,6 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so |
| 6460 | 6447 | source_instr->scope, source_instr->source_node); |
| 6461 | 6448 | const_instruction->base.value.type = wanted_type; |
| 6462 | 6449 | const_instruction->base.value.special = ConstValSpecialStatic; |
| 6463 | | const_instruction->base.value.depends_on_compile_var = val->depends_on_compile_var; |
| 6464 | 6450 | const_instruction->base.value.data.x_err_union.err = val->data.x_pure_err; |
| 6465 | 6451 | const_instruction->base.value.data.x_err_union.payload = nullptr; |
| 6466 | 6452 | return &const_instruction->base; |
| ... | ... | @@ -6485,7 +6471,6 @@ static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_ |
| 6485 | 6471 | source_instr->scope, source_instr->source_node); |
| 6486 | 6472 | const_instruction->base.value.type = wanted_type; |
| 6487 | 6473 | const_instruction->base.value.special = ConstValSpecialStatic; |
| 6488 | | const_instruction->base.value.depends_on_compile_var = val->depends_on_compile_var; |
| 6489 | 6474 | const_instruction->base.value.data.x_ptr.base_ptr = val; |
| 6490 | 6475 | const_instruction->base.value.data.x_ptr.index = SIZE_MAX; |
| 6491 | 6476 | return &const_instruction->base; |
| ... | ... | @@ -6519,7 +6504,6 @@ static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *so |
| 6519 | 6504 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| 6520 | 6505 | const_instruction->base.value.type = wanted_type; |
| 6521 | 6506 | const_instruction->base.value.special = ConstValSpecialStatic; |
| 6522 | | const_instruction->base.value.depends_on_compile_var = val->depends_on_compile_var; |
| 6523 | 6507 | const_instruction->base.value.data.x_maybe = nullptr; |
| 6524 | 6508 | return &const_instruction->base; |
| 6525 | 6509 | } |
| ... | ... | @@ -6534,17 +6518,17 @@ static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *s |
| 6534 | 6518 | |
| 6535 | 6519 | if (instr_is_comptime(array)) { |
| 6536 | 6520 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, |
| 6537 | | source_instr->source_node, wanted_type, false); |
| 6521 | source_instr->source_node, wanted_type); |
| 6538 | 6522 | init_const_slice(ira->codegen, &result->value, &array->value, 0, array_type->data.array.len, true); |
| 6539 | 6523 | return result; |
| 6540 | 6524 | } |
| 6541 | 6525 | |
| 6542 | 6526 | IrInstruction *start = ir_create_const(&ira->new_irb, source_instr->scope, |
| 6543 | | source_instr->source_node, ira->codegen->builtin_types.entry_usize, false); |
| 6527 | source_instr->source_node, ira->codegen->builtin_types.entry_usize); |
| 6544 | 6528 | init_const_usize(ira->codegen, &start->value, 0); |
| 6545 | 6529 | |
| 6546 | 6530 | IrInstruction *end = ir_create_const(&ira->new_irb, source_instr->scope, |
| 6547 | | source_instr->source_node, ira->codegen->builtin_types.entry_usize, false); |
| 6531 | source_instr->source_node, ira->codegen->builtin_types.entry_usize); |
| 6548 | 6532 | init_const_usize(ira->codegen, &end->value, array_type->data.array.len); |
| 6549 | 6533 | |
| 6550 | 6534 | bool is_const; |
| ... | ... | @@ -6573,7 +6557,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour |
| 6573 | 6557 | if (!val) |
| 6574 | 6558 | return ira->codegen->invalid_instruction; |
| 6575 | 6559 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, |
| 6576 | | source_instr->source_node, wanted_type, val->depends_on_compile_var); |
| 6560 | source_instr->source_node, wanted_type); |
| 6577 | 6561 | init_const_unsigned_negative(&result->value, wanted_type, val->data.x_enum.tag, false); |
| 6578 | 6562 | return result; |
| 6579 | 6563 | } |
| ... | ... | @@ -6588,7 +6572,7 @@ static IrInstruction *ir_analyze_undefined_to_anything(IrAnalyze *ira, IrInstruc |
| 6588 | 6572 | IrInstruction *target, TypeTableEntry *wanted_type) |
| 6589 | 6573 | { |
| 6590 | 6574 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, |
| 6591 | | source_instr->source_node, wanted_type, target->value.depends_on_compile_var); |
| 6575 | source_instr->source_node, wanted_type); |
| 6592 | 6576 | init_const_undefined(ira->codegen, &result->value); |
| 6593 | 6577 | return result; |
| 6594 | 6578 | } |
| ... | ... | @@ -6603,7 +6587,7 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction |
| 6603 | 6587 | if (!val) |
| 6604 | 6588 | return ira->codegen->invalid_instruction; |
| 6605 | 6589 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, |
| 6606 | | source_instr->source_node, wanted_type, val->depends_on_compile_var); |
| 6590 | source_instr->source_node, wanted_type); |
| 6607 | 6591 | result->value = *val; |
| 6608 | 6592 | result->value.type = wanted_type; |
| 6609 | 6593 | return result; |
| ... | ... | @@ -6626,7 +6610,7 @@ static IrInstruction *ir_analyze_ptr_to_int(IrAnalyze *ira, IrInstruction *sourc |
| 6626 | 6610 | return ira->codegen->invalid_instruction; |
| 6627 | 6611 | if (val->data.x_ptr.special == ConstPtrSpecialRuntime) { |
| 6628 | 6612 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, |
| 6629 | | source_instr->source_node, wanted_type, val->depends_on_compile_var); |
| 6613 | source_instr->source_node, wanted_type); |
| 6630 | 6614 | bignum_init_unsigned(&result->value.data.x_bignum, val->data.x_ptr.index); |
| 6631 | 6615 | return result; |
| 6632 | 6616 | } |
| ... | ... | @@ -6648,7 +6632,7 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc |
| 6648 | 6632 | if (!val) |
| 6649 | 6633 | return ira->codegen->invalid_instruction; |
| 6650 | 6634 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, |
| 6651 | | source_instr->source_node, wanted_type, val->depends_on_compile_var); |
| 6635 | source_instr->source_node, wanted_type); |
| 6652 | 6636 | result->value.data.x_ptr.base_ptr = nullptr; |
| 6653 | 6637 | result->value.data.x_ptr.index = bignum_to_twos_complement(&val->data.x_bignum); |
| 6654 | 6638 | result->value.data.x_ptr.special = ConstPtrSpecialRuntime; |
| ... | ... | @@ -6675,7 +6659,7 @@ static IrInstruction *ir_analyze_int_lit_to_ptr(IrAnalyze *ira, IrInstruction *s |
| 6675 | 6659 | return ira->codegen->invalid_instruction; |
| 6676 | 6660 | |
| 6677 | 6661 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, |
| 6678 | | source_instr->source_node, wanted_type, val->depends_on_compile_var); |
| 6662 | source_instr->source_node, wanted_type); |
| 6679 | 6663 | result->value.data.x_ptr.base_ptr = nullptr; |
| 6680 | 6664 | result->value.data.x_ptr.index = bignum_to_twos_complement(&val->data.x_bignum); |
| 6681 | 6665 | result->value.data.x_ptr.special = ConstPtrSpecialRuntime; |
| ... | ... | @@ -6692,7 +6676,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour |
| 6692 | 6676 | if (!val) |
| 6693 | 6677 | return ira->codegen->invalid_instruction; |
| 6694 | 6678 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, |
| 6695 | | source_instr->source_node, wanted_type, val->depends_on_compile_var); |
| 6679 | source_instr->source_node, wanted_type); |
| 6696 | 6680 | result->value.data.x_enum.tag = val->data.x_bignum.data.x_uint; |
| 6697 | 6681 | return result; |
| 6698 | 6682 | } |
| ... | ... | @@ -6711,7 +6695,7 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction |
| 6711 | 6695 | return ira->codegen->invalid_instruction; |
| 6712 | 6696 | |
| 6713 | 6697 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, |
| 6714 | | source_instr->source_node, wanted_type, true); |
| 6698 | source_instr->source_node, wanted_type); |
| 6715 | 6699 | bignum_init_bignum(&result->value.data.x_bignum, &val->data.x_bignum); |
| 6716 | 6700 | return result; |
| 6717 | 6701 | } |
| ... | ... | @@ -7026,10 +7010,8 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc |
| 7026 | 7010 | ConstExprValue *pointee = const_ptr_pointee(&ptr->value); |
| 7027 | 7011 | if (pointee->special != ConstValSpecialRuntime) { |
| 7028 | 7012 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instruction->scope, |
| 7029 | | source_instruction->source_node, child_type, false); |
| 7013 | source_instruction->source_node, child_type); |
| 7030 | 7014 | result->value = *pointee; |
| 7031 | | result->value.depends_on_compile_var = pointee->depends_on_compile_var || |
| 7032 | | ptr->value.depends_on_compile_var; |
| 7033 | 7015 | return result; |
| 7034 | 7016 | } |
| 7035 | 7017 | } |
| ... | ... | @@ -7046,7 +7028,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc |
| 7046 | 7028 | if (ptr_type->id == TypeTableEntryIdPointer) { |
| 7047 | 7029 | TypeTableEntry *child_type = ptr_type->data.pointer.child_type; |
| 7048 | 7030 | return ir_create_const_type(&ira->new_irb, source_instruction->scope, |
| 7049 | | source_instruction->source_node, child_type, ptr_val->depends_on_compile_var); |
| 7031 | source_instruction->source_node, child_type); |
| 7050 | 7032 | } else { |
| 7051 | 7033 | ir_add_error(ira, source_instruction, |
| 7052 | 7034 | buf_sprintf("attempt to dereference non pointer type '%s'", buf_ptr(&ptr_type->name))); |
| ... | ... | @@ -7071,7 +7053,7 @@ static TypeTableEntry *ir_analyze_ref(IrAnalyze *ira, IrInstruction *source_inst |
| 7071 | 7053 | if (!val) |
| 7072 | 7054 | return ira->codegen->builtin_types.entry_invalid; |
| 7073 | 7055 | return ir_analyze_const_ptr(ira, source_instruction, val, value->value.type, |
| 7074 | | value->value.depends_on_compile_var, ConstPtrSpecialNone, is_const, is_volatile); |
| 7056 | ConstPtrSpecialNone, is_const, is_volatile); |
| 7075 | 7057 | } |
| 7076 | 7058 | |
| 7077 | 7059 | TypeTableEntry *ptr_type = get_pointer_to_type_volatile(ira->codegen, value->value.type, is_const, is_volatile); |
| ... | ... | @@ -7187,8 +7169,7 @@ static TypeTableEntry *ir_analyze_instruction_return(IrAnalyze *ira, |
| 7187 | 7169 | } |
| 7188 | 7170 | |
| 7189 | 7171 | static TypeTableEntry *ir_analyze_instruction_const(IrAnalyze *ira, IrInstructionConst *const_instruction) { |
| 7190 | | bool depends_on_compile_var = const_instruction->base.value.depends_on_compile_var; |
| 7191 | | ConstExprValue *out_val = ir_build_const_from(ira, &const_instruction->base, depends_on_compile_var); |
| 7172 | ConstExprValue *out_val = ir_build_const_from(ira, &const_instruction->base); |
| 7192 | 7173 | *out_val = const_instruction->base.value; |
| 7193 | 7174 | return const_instruction->base.value.type; |
| 7194 | 7175 | } |
| ... | ... | @@ -7215,8 +7196,7 @@ static TypeTableEntry *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp |
| 7215 | 7196 | ConstExprValue *op1_val = &casted_op1->value; |
| 7216 | 7197 | ConstExprValue *op2_val = &casted_op2->value; |
| 7217 | 7198 | if (op1_val->special != ConstValSpecialRuntime && op2_val->special != ConstValSpecialRuntime) { |
| 7218 | | bool depends_on_compile_var = op1_val->depends_on_compile_var || op2_val->depends_on_compile_var; |
| 7219 | | ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base, depends_on_compile_var); |
| 7199 | ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base); |
| 7220 | 7200 | |
| 7221 | 7201 | assert(casted_op1->value.type->id == TypeTableEntryIdBool); |
| 7222 | 7202 | assert(casted_op2->value.type->id == TypeTableEntryIdBool); |
| ... | ... | @@ -7246,9 +7226,8 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp |
| 7246 | 7226 | (op2->value.type->id == TypeTableEntryIdNullLit && op1->value.type->id == TypeTableEntryIdMaybe) || |
| 7247 | 7227 | (op1->value.type->id == TypeTableEntryIdNullLit && op2->value.type->id == TypeTableEntryIdNullLit))) |
| 7248 | 7228 | { |
| 7249 | | bool depends_on_compile_var = op1->value.depends_on_compile_var || op2->value.depends_on_compile_var; |
| 7250 | 7229 | if (op1->value.type->id == TypeTableEntryIdNullLit && op2->value.type->id == TypeTableEntryIdNullLit) { |
| 7251 | | ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base, depends_on_compile_var); |
| 7230 | ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base); |
| 7252 | 7231 | out_val->data.x_bool = (op_id == IrBinOpCmpEq); |
| 7253 | 7232 | return ira->codegen->builtin_types.entry_bool; |
| 7254 | 7233 | } |
| ... | ... | @@ -7265,7 +7244,7 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp |
| 7265 | 7244 | if (!maybe_val) |
| 7266 | 7245 | return ira->codegen->builtin_types.entry_invalid; |
| 7267 | 7246 | bool is_null = (maybe_val->data.x_maybe == nullptr); |
| 7268 | | ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base, depends_on_compile_var); |
| 7247 | ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base); |
| 7269 | 7248 | out_val->data.x_bool = (op_id == IrBinOpCmpEq) ? is_null : !is_null; |
| 7270 | 7249 | return ira->codegen->builtin_types.entry_bool; |
| 7271 | 7250 | } |
| ... | ... | @@ -7389,8 +7368,7 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp |
| 7389 | 7368 | } |
| 7390 | 7369 | } |
| 7391 | 7370 | |
| 7392 | | bool depends_on_compile_var = op1_val->depends_on_compile_var || op2_val->depends_on_compile_var; |
| 7393 | | ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base, depends_on_compile_var); |
| 7371 | ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base); |
| 7394 | 7372 | out_val->data.x_bool = answer; |
| 7395 | 7373 | return ira->codegen->builtin_types.entry_bool; |
| 7396 | 7374 | } |
| ... | ... | @@ -7463,7 +7441,6 @@ static int ir_eval_bignum(ConstExprValue *op1_val, ConstExprValue *op2_val, |
| 7463 | 7441 | } |
| 7464 | 7442 | |
| 7465 | 7443 | out_val->special = ConstValSpecialStatic; |
| 7466 | | out_val->depends_on_compile_var = op1_val->depends_on_compile_var || op2_val->depends_on_compile_var; |
| 7467 | 7444 | return 0; |
| 7468 | 7445 | } |
| 7469 | 7446 | |
| ... | ... | @@ -7682,8 +7659,7 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp * |
| 7682 | 7659 | return ira->codegen->builtin_types.entry_invalid; |
| 7683 | 7660 | } |
| 7684 | 7661 | |
| 7685 | | bool depends_on_compile_var = op1->value.depends_on_compile_var || op2->value.depends_on_compile_var; |
| 7686 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); |
| 7662 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 7687 | 7663 | |
| 7688 | 7664 | TypeTableEntry *result_type; |
| 7689 | 7665 | ConstExprValue *out_array_val; |
| ... | ... | @@ -7757,8 +7733,7 @@ static TypeTableEntry *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp |
| 7757 | 7733 | return ira->codegen->builtin_types.entry_invalid; |
| 7758 | 7734 | } |
| 7759 | 7735 | |
| 7760 | | bool depends_on_compile_var = op1->value.depends_on_compile_var || op2->value.depends_on_compile_var; |
| 7761 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); |
| 7736 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 7762 | 7737 | |
| 7763 | 7738 | uint64_t new_array_len = array_len.data.x_uint; |
| 7764 | 7739 | out_val->data.x_array.size = new_array_len; |
| ... | ... | @@ -7913,7 +7888,7 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc |
| 7913 | 7888 | *mem_slot = casted_init_value->value; |
| 7914 | 7889 | |
| 7915 | 7890 | if (is_comptime) { |
| 7916 | | ir_build_const_from(ira, &decl_var_instruction->base, false); |
| 7891 | ir_build_const_from(ira, &decl_var_instruction->base); |
| 7917 | 7892 | return ira->codegen->builtin_types.entry_void; |
| 7918 | 7893 | } |
| 7919 | 7894 | } |
| ... | ... | @@ -7954,7 +7929,6 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node |
| 7954 | 7929 | Buf *param_name = param_decl_node->data.param_decl.name; |
| 7955 | 7930 | VariableTableEntry *var = add_variable(ira->codegen, param_decl_node, |
| 7956 | 7931 | *exec_scope, param_name, true, arg_val); |
| 7957 | | var->value.depends_on_compile_var = true; |
| 7958 | 7932 | *exec_scope = var->child_scope; |
| 7959 | 7933 | *next_proto_i += 1; |
| 7960 | 7934 | |
| ... | ... | @@ -8000,9 +7974,6 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 8000 | 7974 | arg_val = ir_resolve_const(ira, casted_arg, UndefBad); |
| 8001 | 7975 | if (!arg_val) |
| 8002 | 7976 | return false; |
| 8003 | | // This generic function instance could be called with anything, so when this variable is read it |
| 8004 | | // needs to know that it depends on compile time variable data. |
| 8005 | | arg_val->depends_on_compile_var = true; |
| 8006 | 7977 | } else { |
| 8007 | 7978 | arg_val = create_const_runtime(casted_arg->value.type); |
| 8008 | 7979 | } |
| ... | ... | @@ -8015,7 +7986,6 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 8015 | 7986 | if (!is_var_args) { |
| 8016 | 7987 | VariableTableEntry *var = add_variable(ira->codegen, param_decl_node, |
| 8017 | 7988 | *child_scope, param_name, true, arg_val); |
| 8018 | | var->value.depends_on_compile_var = true; |
| 8019 | 7989 | *child_scope = var->child_scope; |
| 8020 | 7990 | var->shadowable = !comptime_arg; |
| 8021 | 7991 | |
| ... | ... | @@ -8133,8 +8103,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal |
| 8133 | 8103 | ira->codegen->memoized_fn_eval_table.put(exec_scope, result); |
| 8134 | 8104 | } |
| 8135 | 8105 | |
| 8136 | | ConstExprValue *out_val = ir_build_const_from(ira, &call_instruction->base, |
| 8137 | | result->value.depends_on_compile_var); |
| 8106 | ConstExprValue *out_val = ir_build_const_from(ira, &call_instruction->base); |
| 8138 | 8107 | *out_val = result->value; |
| 8139 | 8108 | return ir_finish_anal(ira, return_type); |
| 8140 | 8109 | } |
| ... | ... | @@ -8212,7 +8181,6 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal |
| 8212 | 8181 | first_var_arg, inst_fn_type_id.param_count); |
| 8213 | 8182 | VariableTableEntry *var = add_variable(ira->codegen, param_decl_node, |
| 8214 | 8183 | impl_fn->child_scope, param_name, true, var_args_val); |
| 8215 | | var->value.depends_on_compile_var = true; |
| 8216 | 8184 | impl_fn->child_scope = var->child_scope; |
| 8217 | 8185 | } |
| 8218 | 8186 | { |
| ... | ... | @@ -8398,8 +8366,7 @@ static TypeTableEntry *ir_analyze_unary_prefix_op_err(IrAnalyze *ira, IrInstruct |
| 8398 | 8366 | case TypeTableEntryIdBoundFn: |
| 8399 | 8367 | case TypeTableEntryIdEnumTag: |
| 8400 | 8368 | { |
| 8401 | | ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base, |
| 8402 | | value->value.depends_on_compile_var); |
| 8369 | ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base); |
| 8403 | 8370 | TypeTableEntry *result_type = get_error_type(ira->codegen, meta_type); |
| 8404 | 8371 | out_val->data.x_type = result_type; |
| 8405 | 8372 | return ira->codegen->builtin_types.entry_type; |
| ... | ... | @@ -8443,7 +8410,7 @@ static TypeTableEntry *ir_analyze_dereference(IrAnalyze *ira, IrInstructionUnOp |
| 8443 | 8410 | // one of the ptr instructions |
| 8444 | 8411 | |
| 8445 | 8412 | if (value->value.special != ConstValSpecialRuntime) { |
| 8446 | | ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base, false); |
| 8413 | ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base); |
| 8447 | 8414 | ConstExprValue *pointee = const_ptr_pointee(&value->value); |
| 8448 | 8415 | *out_val = *pointee; |
| 8449 | 8416 | return child_type; |
| ... | ... | @@ -8488,8 +8455,7 @@ static TypeTableEntry *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op |
| 8488 | 8455 | case TypeTableEntryIdEnumTag: |
| 8489 | 8456 | case TypeTableEntryIdArgTuple: |
| 8490 | 8457 | { |
| 8491 | | ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base, |
| 8492 | | value->value.depends_on_compile_var); |
| 8458 | ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base); |
| 8493 | 8459 | out_val->data.x_type = get_maybe_type(ira->codegen, type_entry); |
| 8494 | 8460 | return ira->codegen->builtin_types.entry_type; |
| 8495 | 8461 | } |
| ... | ... | @@ -8519,8 +8485,7 @@ static TypeTableEntry *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un |
| 8519 | 8485 | if (!target_const_val) |
| 8520 | 8486 | return ira->codegen->builtin_types.entry_invalid; |
| 8521 | 8487 | |
| 8522 | | bool depends_on_compile_var = value->value.depends_on_compile_var; |
| 8523 | | ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base, depends_on_compile_var); |
| 8488 | ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base); |
| 8524 | 8489 | bignum_negate(&out_val->data.x_bignum, &target_const_val->data.x_bignum); |
| 8525 | 8490 | if (expr_type->id == TypeTableEntryIdFloat || |
| 8526 | 8491 | expr_type->id == TypeTableEntryIdNumLitFloat || |
| ... | ... | @@ -8561,8 +8526,7 @@ static TypeTableEntry *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *ins |
| 8561 | 8526 | if (!target_const_val) |
| 8562 | 8527 | return ira->codegen->builtin_types.entry_invalid; |
| 8563 | 8528 | |
| 8564 | | bool depends_on_compile_var = value->value.depends_on_compile_var; |
| 8565 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); |
| 8529 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 8566 | 8530 | bignum_not(&out_val->data.x_bignum, &target_const_val->data.x_bignum, |
| 8567 | 8531 | expr_type->data.integral.bit_count, expr_type->data.integral.is_signed); |
| 8568 | 8532 | return expr_type; |
| ... | ... | @@ -8669,9 +8633,8 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP |
| 8669 | 8633 | return ira->codegen->builtin_types.entry_invalid; |
| 8670 | 8634 | |
| 8671 | 8635 | if (value->value.special != ConstValSpecialRuntime) { |
| 8672 | | ConstExprValue *out_val = ir_build_const_from(ira, &phi_instruction->base, true); |
| 8636 | ConstExprValue *out_val = ir_build_const_from(ira, &phi_instruction->base); |
| 8673 | 8637 | *out_val = value->value; |
| 8674 | | out_val->depends_on_compile_var = true; |
| 8675 | 8638 | } else { |
| 8676 | 8639 | phi_instruction->base.other = value; |
| 8677 | 8640 | } |
| ... | ... | @@ -8705,7 +8668,7 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP |
| 8705 | 8668 | } |
| 8706 | 8669 | |
| 8707 | 8670 | if (new_incoming_blocks.length == 0) { |
| 8708 | | ir_build_const_from(ira, &phi_instruction->base, true); |
| 8671 | ir_build_const_from(ira, &phi_instruction->base); |
| 8709 | 8672 | return ira->codegen->builtin_types.entry_void; |
| 8710 | 8673 | } |
| 8711 | 8674 | |
| ... | ... | @@ -8752,7 +8715,7 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP |
| 8752 | 8715 | } |
| 8753 | 8716 | |
| 8754 | 8717 | static TypeTableEntry *ir_analyze_var_ptr(IrAnalyze *ira, IrInstruction *instruction, |
| 8755 | | VariableTableEntry *var, bool is_const_ptr, bool is_volatile_ptr, bool depends_on_compile_var) |
| 8718 | VariableTableEntry *var, bool is_const_ptr, bool is_volatile_ptr) |
| 8756 | 8719 | { |
| 8757 | 8720 | assert(var->value.type); |
| 8758 | 8721 | if (var->value.type->id == TypeTableEntryIdInvalid) |
| ... | ... | @@ -8775,9 +8738,7 @@ static TypeTableEntry *ir_analyze_var_ptr(IrAnalyze *ira, IrInstruction *instruc |
| 8775 | 8738 | bool is_volatile = (var->value.type->id == TypeTableEntryIdMetaType) ? is_volatile_ptr : false; |
| 8776 | 8739 | if (mem_slot && mem_slot->special != ConstValSpecialRuntime) { |
| 8777 | 8740 | ConstPtrSpecial ptr_special = is_comptime ? ConstPtrSpecialInline : ConstPtrSpecialNone; |
| 8778 | | depends_on_compile_var = mem_slot->depends_on_compile_var || depends_on_compile_var || is_comptime; |
| 8779 | | return ir_analyze_const_ptr(ira, instruction, mem_slot, var->value.type, |
| 8780 | | depends_on_compile_var, ptr_special, is_const, is_volatile); |
| 8741 | return ir_analyze_const_ptr(ira, instruction, mem_slot, var->value.type, ptr_special, is_const, is_volatile); |
| 8781 | 8742 | } else { |
| 8782 | 8743 | ir_build_var_ptr_from(&ira->new_irb, instruction, var, is_const, is_volatile); |
| 8783 | 8744 | type_ensure_zero_bits_known(ira->codegen, var->value.type); |
| ... | ... | @@ -8788,7 +8749,7 @@ static TypeTableEntry *ir_analyze_var_ptr(IrAnalyze *ira, IrInstruction *instruc |
| 8788 | 8749 | static TypeTableEntry *ir_analyze_instruction_var_ptr(IrAnalyze *ira, IrInstructionVarPtr *var_ptr_instruction) { |
| 8789 | 8750 | VariableTableEntry *var = var_ptr_instruction->var; |
| 8790 | 8751 | return ir_analyze_var_ptr(ira, &var_ptr_instruction->base, var, var_ptr_instruction->is_const, |
| 8791 | | var_ptr_instruction->is_volatile, false); |
| 8752 | var_ptr_instruction->is_volatile); |
| 8792 | 8753 | } |
| 8793 | 8754 | |
| 8794 | 8755 | static VariableTableEntry *get_fn_var_by_index(FnTableEntry *fn_entry, size_t index) { |
| ... | ... | @@ -8858,16 +8819,14 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc |
| 8858 | 8819 | FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec); |
| 8859 | 8820 | assert(fn_entry); |
| 8860 | 8821 | VariableTableEntry *var = get_fn_var_by_index(fn_entry, abs_index); |
| 8861 | | bool depends_on_compile_var = array_ptr->value.depends_on_compile_var || |
| 8862 | | elem_index->value.depends_on_compile_var; |
| 8863 | 8822 | bool is_const = true; |
| 8864 | 8823 | bool is_volatile = false; |
| 8865 | 8824 | if (var) { |
| 8866 | 8825 | return ir_analyze_var_ptr(ira, &elem_ptr_instruction->base, var, |
| 8867 | | is_const, is_volatile, depends_on_compile_var); |
| 8826 | is_const, is_volatile); |
| 8868 | 8827 | } else { |
| 8869 | 8828 | return ir_analyze_const_ptr(ira, &elem_ptr_instruction->base, &ira->codegen->const_void_val, |
| 8870 | | ira->codegen->builtin_types.entry_void, depends_on_compile_var, ConstPtrSpecialNone, |
| 8829 | ira->codegen->builtin_types.entry_void, ConstPtrSpecialNone, |
| 8871 | 8830 | is_const, is_volatile); |
| 8872 | 8831 | } |
| 8873 | 8832 | } else { |
| ... | ... | @@ -8901,9 +8860,7 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc |
| 8901 | 8860 | array_ptr_val->special != ConstValSpecialRuntime && |
| 8902 | 8861 | (array_type->id != TypeTableEntryIdPointer || array_ptr_val->data.x_ptr.special != ConstPtrSpecialRuntime)) |
| 8903 | 8862 | { |
| 8904 | | bool depends_on_compile_var = array_ptr_val->depends_on_compile_var || |
| 8905 | | casted_elem_index->value.depends_on_compile_var; |
| 8906 | | ConstExprValue *out_val = ir_build_const_from(ira, &elem_ptr_instruction->base, depends_on_compile_var); |
| 8863 | ConstExprValue *out_val = ir_build_const_from(ira, &elem_ptr_instruction->base); |
| 8907 | 8864 | if (array_type->id == TypeTableEntryIdPointer) { |
| 8908 | 8865 | size_t offset = array_ptr_val->data.x_ptr.index; |
| 8909 | 8866 | size_t new_index; |
| ... | ... | @@ -8974,9 +8931,8 @@ static TypeTableEntry *ir_analyze_container_member_access_inner(IrAnalyze *ira, |
| 8974 | 8931 | return ira->codegen->builtin_types.entry_invalid; |
| 8975 | 8932 | TldFn *tld_fn = (TldFn *)tld; |
| 8976 | 8933 | FnTableEntry *fn_entry = tld_fn->fn_entry; |
| 8977 | | bool depends_on_compile_var = container_ptr->value.depends_on_compile_var; |
| 8978 | 8934 | IrInstruction *bound_fn_value = ir_build_const_bound_fn(&ira->new_irb, field_ptr_instruction->base.scope, |
| 8979 | | field_ptr_instruction->base.source_node, fn_entry, container_ptr, depends_on_compile_var); |
| 8935 | field_ptr_instruction->base.source_node, fn_entry, container_ptr); |
| 8980 | 8936 | return ir_analyze_ref(ira, &field_ptr_instruction->base, bound_fn_value, true, false); |
| 8981 | 8937 | } |
| 8982 | 8938 | } |
| ... | ... | @@ -9011,11 +8967,8 @@ static TypeTableEntry *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field |
| 9011 | 8967 | if (value_is_comptime(struct_val)) { |
| 9012 | 8968 | ConstExprValue *field_val = &struct_val->data.x_struct.fields[field->src_index]; |
| 9013 | 8969 | if (value_is_comptime(field_val)) { |
| 9014 | | bool depends_on_compile_var = field_val->depends_on_compile_var || |
| 9015 | | struct_val->depends_on_compile_var || ptr_val->depends_on_compile_var; |
| 9016 | 8970 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, field_val, |
| 9017 | | field_val->type, depends_on_compile_var, ConstPtrSpecialNone, |
| 9018 | | is_const, is_volatile); |
| 8971 | field_val->type, ConstPtrSpecialNone, is_const, is_volatile); |
| 9019 | 8972 | } |
| 9020 | 8973 | } |
| 9021 | 8974 | } |
| ... | ... | @@ -9045,9 +8998,7 @@ static TypeTableEntry *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field |
| 9045 | 8998 | } |
| 9046 | 8999 | } |
| 9047 | 9000 | |
| 9048 | | static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_instruction, Tld *tld, |
| 9049 | | bool depends_on_compile_var) |
| 9050 | | { |
| 9001 | static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_instruction, Tld *tld) { |
| 9051 | 9002 | bool pointer_only = false; |
| 9052 | 9003 | resolve_top_level_decl(ira->codegen, tld, pointer_only); |
| 9053 | 9004 | if (tld->resolution == TldResolutionInvalid) |
| ... | ... | @@ -9060,7 +9011,7 @@ static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source |
| 9060 | 9011 | { |
| 9061 | 9012 | TldVar *tld_var = (TldVar *)tld; |
| 9062 | 9013 | VariableTableEntry *var = tld_var->var; |
| 9063 | | return ir_analyze_var_ptr(ira, source_instruction, var, false, false, depends_on_compile_var); |
| 9014 | return ir_analyze_var_ptr(ira, source_instruction, var, false, false); |
| 9064 | 9015 | } |
| 9065 | 9016 | case TldIdFn: |
| 9066 | 9017 | { |
| ... | ... | @@ -9081,7 +9032,7 @@ static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source |
| 9081 | 9032 | bool ptr_is_const = true; |
| 9082 | 9033 | bool ptr_is_volatile = false; |
| 9083 | 9034 | return ir_analyze_const_ptr(ira, source_instruction, const_val, fn_entry->type_entry, |
| 9084 | | depends_on_compile_var, ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile); |
| 9035 | ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile); |
| 9085 | 9036 | } |
| 9086 | 9037 | case TldIdTypeDef: |
| 9087 | 9038 | { |
| ... | ... | @@ -9098,7 +9049,7 @@ static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source |
| 9098 | 9049 | bool ptr_is_const = true; |
| 9099 | 9050 | bool ptr_is_volatile = false; |
| 9100 | 9051 | return ir_analyze_const_ptr(ira, source_instruction, const_val, ira->codegen->builtin_types.entry_type, |
| 9101 | | depends_on_compile_var, ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile); |
| 9052 | ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile); |
| 9102 | 9053 | } |
| 9103 | 9054 | } |
| 9104 | 9055 | zig_unreachable(); |
| ... | ... | @@ -9118,7 +9069,6 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru |
| 9118 | 9069 | zig_unreachable(); |
| 9119 | 9070 | } |
| 9120 | 9071 | |
| 9121 | | bool depends_on_compile_var = container_ptr->value.depends_on_compile_var; |
| 9122 | 9072 | Buf *field_name = field_ptr_instruction->field_name; |
| 9123 | 9073 | AstNode *source_node = field_ptr_instruction->base.source_node; |
| 9124 | 9074 | |
| ... | ... | @@ -9142,7 +9092,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru |
| 9142 | 9092 | bool ptr_is_const = true; |
| 9143 | 9093 | bool ptr_is_volatile = false; |
| 9144 | 9094 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, len_val, |
| 9145 | | usize, depends_on_compile_var, ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile); |
| 9095 | usize, ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile); |
| 9146 | 9096 | } else { |
| 9147 | 9097 | ir_add_error_node(ira, source_node, |
| 9148 | 9098 | buf_sprintf("no member named '%s' in '%s'", buf_ptr(field_name), |
| ... | ... | @@ -9166,7 +9116,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru |
| 9166 | 9116 | bool ptr_is_const = true; |
| 9167 | 9117 | bool ptr_is_volatile = false; |
| 9168 | 9118 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, len_val, |
| 9169 | | usize, depends_on_compile_var, ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile); |
| 9119 | usize, ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile); |
| 9170 | 9120 | } else { |
| 9171 | 9121 | ir_add_error_node(ira, source_node, |
| 9172 | 9122 | buf_sprintf("no member named '%s' in '%s'", buf_ptr(field_name), |
| ... | ... | @@ -9204,14 +9154,14 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru |
| 9204 | 9154 | bool ptr_is_const = true; |
| 9205 | 9155 | bool ptr_is_volatile = false; |
| 9206 | 9156 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, |
| 9207 | | create_const_enum_tag(child_type, field->value), child_type, depends_on_compile_var, |
| 9157 | create_const_enum_tag(child_type, field->value), child_type, |
| 9208 | 9158 | ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile); |
| 9209 | 9159 | } else { |
| 9210 | 9160 | bool ptr_is_const = true; |
| 9211 | 9161 | bool ptr_is_volatile = false; |
| 9212 | 9162 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, |
| 9213 | 9163 | create_const_unsigned_negative(child_type->data.enumeration.tag_type, field->value, false), |
| 9214 | | child_type->data.enumeration.tag_type, depends_on_compile_var, |
| 9164 | child_type->data.enumeration.tag_type, |
| 9215 | 9165 | ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile); |
| 9216 | 9166 | } |
| 9217 | 9167 | } |
| ... | ... | @@ -9220,7 +9170,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru |
| 9220 | 9170 | auto entry = container_scope->decl_table.maybe_get(field_name); |
| 9221 | 9171 | Tld *tld = entry ? entry->value : nullptr; |
| 9222 | 9172 | if (tld) { |
| 9223 | | return ir_analyze_decl_ref(ira, &field_ptr_instruction->base, tld, depends_on_compile_var); |
| 9173 | return ir_analyze_decl_ref(ira, &field_ptr_instruction->base, tld); |
| 9224 | 9174 | } |
| 9225 | 9175 | ir_add_error(ira, &field_ptr_instruction->base, |
| 9226 | 9176 | buf_sprintf("container '%s' has no member called '%s'", |
| ... | ... | @@ -9237,7 +9187,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru |
| 9237 | 9187 | bool ptr_is_const = true; |
| 9238 | 9188 | bool ptr_is_volatile = false; |
| 9239 | 9189 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, const_val, |
| 9240 | | child_type, depends_on_compile_var, ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile); |
| 9190 | child_type, ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile); |
| 9241 | 9191 | } |
| 9242 | 9192 | |
| 9243 | 9193 | ir_add_error(ira, &field_ptr_instruction->base, |
| ... | ... | @@ -9250,14 +9200,14 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru |
| 9250 | 9200 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, |
| 9251 | 9201 | create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int, |
| 9252 | 9202 | child_type->data.integral.bit_count, false), |
| 9253 | | ira->codegen->builtin_types.entry_num_lit_int, depends_on_compile_var, |
| 9203 | ira->codegen->builtin_types.entry_num_lit_int, |
| 9254 | 9204 | ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile); |
| 9255 | 9205 | } else if (buf_eql_str(field_name, "is_signed")) { |
| 9256 | 9206 | bool ptr_is_const = true; |
| 9257 | 9207 | bool ptr_is_volatile = false; |
| 9258 | 9208 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, |
| 9259 | 9209 | create_const_bool(ira->codegen, child_type->data.integral.is_signed), |
| 9260 | | ira->codegen->builtin_types.entry_bool, depends_on_compile_var, |
| 9210 | ira->codegen->builtin_types.entry_bool, |
| 9261 | 9211 | ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile); |
| 9262 | 9212 | } else { |
| 9263 | 9213 | ir_add_error(ira, &field_ptr_instruction->base, |
| ... | ... | @@ -9303,7 +9253,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru |
| 9303 | 9253 | add_error_note(ira->codegen, msg, tld->source_node, buf_sprintf("declared here")); |
| 9304 | 9254 | return ira->codegen->builtin_types.entry_invalid; |
| 9305 | 9255 | } |
| 9306 | | return ir_analyze_decl_ref(ira, &field_ptr_instruction->base, tld, depends_on_compile_var); |
| 9256 | return ir_analyze_decl_ref(ira, &field_ptr_instruction->base, tld); |
| 9307 | 9257 | } else { |
| 9308 | 9258 | const char *import_name = namespace_import->path ? buf_ptr(namespace_import->path) : "(C import)"; |
| 9309 | 9259 | ir_add_error_node(ira, source_node, |
| ... | ... | @@ -9401,10 +9351,7 @@ static TypeTableEntry *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructi |
| 9401 | 9351 | case TypeTableEntryIdEnumTag: |
| 9402 | 9352 | case TypeTableEntryIdArgTuple: |
| 9403 | 9353 | { |
| 9404 | | ConstExprValue *out_val = ir_build_const_from(ira, &typeof_instruction->base, true); |
| 9405 | | // TODO depends_on_compile_var should be set based on whether the type of the expression |
| 9406 | | // depends_on_compile_var. but we currently don't have a thing to tell us if the type of |
| 9407 | | // something depends on a compile var |
| 9354 | ConstExprValue *out_val = ir_build_const_from(ira, &typeof_instruction->base); |
| 9408 | 9355 | out_val->data.x_type = type_entry; |
| 9409 | 9356 | |
| 9410 | 9357 | return ira->codegen->builtin_types.entry_type; |
| ... | ... | @@ -9438,8 +9385,7 @@ static TypeTableEntry *ir_analyze_instruction_to_ptr_type(IrAnalyze *ira, |
| 9438 | 9385 | return ira->codegen->builtin_types.entry_invalid; |
| 9439 | 9386 | } |
| 9440 | 9387 | |
| 9441 | | ConstExprValue *out_val = ir_build_const_from(ira, &to_ptr_type_instruction->base, |
| 9442 | | value->value.depends_on_compile_var); |
| 9388 | ConstExprValue *out_val = ir_build_const_from(ira, &to_ptr_type_instruction->base); |
| 9443 | 9389 | out_val->data.x_type = ptr_type; |
| 9444 | 9390 | return ira->codegen->builtin_types.entry_type; |
| 9445 | 9391 | } |
| ... | ... | @@ -9459,8 +9405,7 @@ static TypeTableEntry *ir_analyze_instruction_ptr_type_child(IrAnalyze *ira, |
| 9459 | 9405 | return ira->codegen->builtin_types.entry_invalid; |
| 9460 | 9406 | } |
| 9461 | 9407 | |
| 9462 | | ConstExprValue *out_val = ir_build_const_from(ira, &ptr_type_child_instruction->base, |
| 9463 | | type_value->value.depends_on_compile_var); |
| 9408 | ConstExprValue *out_val = ir_build_const_from(ira, &ptr_type_child_instruction->base); |
| 9464 | 9409 | out_val->data.x_type = type_entry->data.pointer.child_type; |
| 9465 | 9410 | return ira->codegen->builtin_types.entry_type; |
| 9466 | 9411 | } |
| ... | ... | @@ -9479,7 +9424,7 @@ static TypeTableEntry *ir_analyze_instruction_set_fn_test(IrAnalyze *ira, |
| 9479 | 9424 | ira->codegen->test_fn_count += 1; |
| 9480 | 9425 | } |
| 9481 | 9426 | |
| 9482 | | ir_build_const_from(ira, &set_fn_test_instruction->base, false); |
| 9427 | ir_build_const_from(ira, &set_fn_test_instruction->base); |
| 9483 | 9428 | return ira->codegen->builtin_types.entry_void; |
| 9484 | 9429 | } |
| 9485 | 9430 | |
| ... | ... | @@ -9515,7 +9460,7 @@ static TypeTableEntry *ir_analyze_instruction_set_fn_visible(IrAnalyze *ira, |
| 9515 | 9460 | } |
| 9516 | 9461 | fn_entry->internal_linkage = !want_export; |
| 9517 | 9462 | |
| 9518 | | ir_build_const_from(ira, &set_fn_visible_instruction->base, false); |
| 9463 | ir_build_const_from(ira, &set_fn_visible_instruction->base); |
| 9519 | 9464 | return ira->codegen->builtin_types.entry_void; |
| 9520 | 9465 | } |
| 9521 | 9466 | |
| ... | ... | @@ -9564,7 +9509,7 @@ static TypeTableEntry *ir_analyze_instruction_set_global_align(IrAnalyze *ira, |
| 9564 | 9509 | *set_global_align_node = source_node; |
| 9565 | 9510 | *alignment_ptr = scalar_align; |
| 9566 | 9511 | |
| 9567 | | ir_build_const_from(ira, &instruction->base, false); |
| 9512 | ir_build_const_from(ira, &instruction->base); |
| 9568 | 9513 | return ira->codegen->builtin_types.entry_void; |
| 9569 | 9514 | } |
| 9570 | 9515 | |
| ... | ... | @@ -9603,7 +9548,7 @@ static TypeTableEntry *ir_analyze_instruction_set_global_section(IrAnalyze *ira, |
| 9603 | 9548 | *set_global_section_node = source_node; |
| 9604 | 9549 | *section_name_ptr = section_name; |
| 9605 | 9550 | |
| 9606 | | ir_build_const_from(ira, &instruction->base, false); |
| 9551 | ir_build_const_from(ira, &instruction->base); |
| 9607 | 9552 | return ira->codegen->builtin_types.entry_void; |
| 9608 | 9553 | } |
| 9609 | 9554 | |
| ... | ... | @@ -9620,7 +9565,7 @@ static TypeTableEntry *ir_analyze_instruction_set_debug_safety(IrAnalyze *ira, |
| 9620 | 9565 | |
| 9621 | 9566 | if (ira->new_irb.exec->is_inline) { |
| 9622 | 9567 | // ignore setDebugSafety when running functions at compile time |
| 9623 | | ir_build_const_from(ira, &set_debug_safety_instruction->base, false); |
| 9568 | ir_build_const_from(ira, &set_debug_safety_instruction->base); |
| 9624 | 9569 | return ira->codegen->builtin_types.entry_void; |
| 9625 | 9570 | } |
| 9626 | 9571 | |
| ... | ... | @@ -9672,7 +9617,7 @@ static TypeTableEntry *ir_analyze_instruction_set_debug_safety(IrAnalyze *ira, |
| 9672 | 9617 | *safety_set_node_ptr = source_node; |
| 9673 | 9618 | *safety_off_ptr = !want_debug_safety; |
| 9674 | 9619 | |
| 9675 | | ir_build_const_from(ira, &set_debug_safety_instruction->base, false); |
| 9620 | ir_build_const_from(ira, &set_debug_safety_instruction->base); |
| 9676 | 9621 | return ira->codegen->builtin_types.entry_void; |
| 9677 | 9622 | } |
| 9678 | 9623 | |
| ... | ... | @@ -9723,8 +9668,7 @@ static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira, |
| 9723 | 9668 | { |
| 9724 | 9669 | type_ensure_zero_bits_known(ira->codegen, resolved_child_type); |
| 9725 | 9670 | TypeTableEntry *result_type = get_slice_type(ira->codegen, resolved_child_type, is_const); |
| 9726 | | ConstExprValue *out_val = ir_build_const_from(ira, &slice_type_instruction->base, |
| 9727 | | child_type->value.depends_on_compile_var); |
| 9671 | ConstExprValue *out_val = ir_build_const_from(ira, &slice_type_instruction->base); |
| 9728 | 9672 | out_val->data.x_type = result_type; |
| 9729 | 9673 | return ira->codegen->builtin_types.entry_type; |
| 9730 | 9674 | } |
| ... | ... | @@ -9814,10 +9758,7 @@ static TypeTableEntry *ir_analyze_instruction_array_type(IrAnalyze *ira, |
| 9814 | 9758 | case TypeTableEntryIdEnumTag: |
| 9815 | 9759 | { |
| 9816 | 9760 | TypeTableEntry *result_type = get_array_type(ira->codegen, child_type, size); |
| 9817 | | bool depends_on_compile_var = child_type_value->value.depends_on_compile_var || |
| 9818 | | size_value->value.depends_on_compile_var; |
| 9819 | | ConstExprValue *out_val = ir_build_const_from(ira, &array_type_instruction->base, |
| 9820 | | depends_on_compile_var); |
| 9761 | ConstExprValue *out_val = ir_build_const_from(ira, &array_type_instruction->base); |
| 9821 | 9762 | out_val->data.x_type = result_type; |
| 9822 | 9763 | return ira->codegen->builtin_types.entry_type; |
| 9823 | 9764 | } |
| ... | ... | @@ -9833,7 +9774,7 @@ static TypeTableEntry *ir_analyze_instruction_compile_var(IrAnalyze *ira, |
| 9833 | 9774 | if (!var_name) |
| 9834 | 9775 | return ira->codegen->builtin_types.entry_invalid; |
| 9835 | 9776 | |
| 9836 | | ConstExprValue *out_val = ir_build_const_from(ira, &compile_var_instruction->base, true); |
| 9777 | ConstExprValue *out_val = ir_build_const_from(ira, &compile_var_instruction->base); |
| 9837 | 9778 | if (buf_eql_str(var_name, "is_big_endian")) { |
| 9838 | 9779 | out_val->data.x_bool = ira->codegen->is_big_endian; |
| 9839 | 9780 | return ira->codegen->builtin_types.entry_bool; |
| ... | ... | @@ -9905,8 +9846,7 @@ static TypeTableEntry *ir_analyze_instruction_size_of(IrAnalyze *ira, |
| 9905 | 9846 | case TypeTableEntryIdEnumTag: |
| 9906 | 9847 | { |
| 9907 | 9848 | uint64_t size_in_bytes = type_size(ira->codegen, type_entry); |
| 9908 | | ConstExprValue *out_val = ir_build_const_from(ira, &size_of_instruction->base, |
| 9909 | | type_entry->size_depends_on_compile_var); |
| 9849 | ConstExprValue *out_val = ir_build_const_from(ira, &size_of_instruction->base); |
| 9910 | 9850 | bignum_init_unsigned(&out_val->data.x_bignum, size_in_bytes); |
| 9911 | 9851 | return ira->codegen->builtin_types.entry_num_lit_int; |
| 9912 | 9852 | } |
| ... | ... | @@ -9927,8 +9867,7 @@ static TypeTableEntry *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrIn |
| 9927 | 9867 | if (!maybe_val) |
| 9928 | 9868 | return ira->codegen->builtin_types.entry_invalid; |
| 9929 | 9869 | |
| 9930 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, |
| 9931 | | maybe_val->depends_on_compile_var); |
| 9870 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 9932 | 9871 | out_val->data.x_bool = (maybe_val->data.x_maybe != nullptr); |
| 9933 | 9872 | return ira->codegen->builtin_types.entry_bool; |
| 9934 | 9873 | } |
| ... | ... | @@ -9936,11 +9875,11 @@ static TypeTableEntry *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrIn |
| 9936 | 9875 | ir_build_test_nonnull_from(&ira->new_irb, &instruction->base, value); |
| 9937 | 9876 | return ira->codegen->builtin_types.entry_bool; |
| 9938 | 9877 | } else if (type_entry->id == TypeTableEntryIdNullLit) { |
| 9939 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, false); |
| 9878 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 9940 | 9879 | out_val->data.x_bool = false; |
| 9941 | 9880 | return ira->codegen->builtin_types.entry_bool; |
| 9942 | 9881 | } else { |
| 9943 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, false); |
| 9882 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 9944 | 9883 | out_val->data.x_bool = true; |
| 9945 | 9884 | return ira->codegen->builtin_types.entry_bool; |
| 9946 | 9885 | } |
| ... | ... | @@ -9981,9 +9920,7 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_maybe(IrAnalyze *ira, |
| 9981 | 9920 | ir_add_error(ira, &unwrap_maybe_instruction->base, buf_sprintf("unable to unwrap null")); |
| 9982 | 9921 | return ira->codegen->builtin_types.entry_invalid; |
| 9983 | 9922 | } |
| 9984 | | bool depends_on_compile_var = maybe_val->depends_on_compile_var; |
| 9985 | | ConstExprValue *out_val = ir_build_const_from(ira, &unwrap_maybe_instruction->base, |
| 9986 | | depends_on_compile_var); |
| 9923 | ConstExprValue *out_val = ir_build_const_from(ira, &unwrap_maybe_instruction->base); |
| 9987 | 9924 | out_val->data.x_ptr.base_ptr = maybe_val->data.x_maybe; |
| 9988 | 9925 | out_val->data.x_ptr.index = SIZE_MAX; |
| 9989 | 9926 | return result_type; |
| ... | ... | @@ -10003,9 +9940,7 @@ static TypeTableEntry *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionC |
| 10003 | 9940 | if (value->value.special != ConstValSpecialRuntime) { |
| 10004 | 9941 | uint32_t result = bignum_ctz(&value->value.data.x_bignum, |
| 10005 | 9942 | value->value.type->data.integral.bit_count); |
| 10006 | | bool depends_on_compile_var = value->value.depends_on_compile_var; |
| 10007 | | ConstExprValue *out_val = ir_build_const_from(ira, &ctz_instruction->base, |
| 10008 | | depends_on_compile_var); |
| 9943 | ConstExprValue *out_val = ir_build_const_from(ira, &ctz_instruction->base); |
| 10009 | 9944 | bignum_init_unsigned(&out_val->data.x_bignum, result); |
| 10010 | 9945 | return value->value.type; |
| 10011 | 9946 | } |
| ... | ... | @@ -10027,9 +9962,7 @@ static TypeTableEntry *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionC |
| 10027 | 9962 | if (value->value.special != ConstValSpecialRuntime) { |
| 10028 | 9963 | uint32_t result = bignum_clz(&value->value.data.x_bignum, |
| 10029 | 9964 | value->value.type->data.integral.bit_count); |
| 10030 | | bool depends_on_compile_var = value->value.depends_on_compile_var; |
| 10031 | | ConstExprValue *out_val = ir_build_const_from(ira, &clz_instruction->base, |
| 10032 | | depends_on_compile_var); |
| 9965 | ConstExprValue *out_val = ir_build_const_from(ira, &clz_instruction->base); |
| 10033 | 9966 | bignum_init_unsigned(&out_val->data.x_bignum, result); |
| 10034 | 9967 | return value->value.type; |
| 10035 | 9968 | } |
| ... | ... | @@ -10062,7 +9995,6 @@ static IrInstruction *ir_analyze_enum_tag(IrAnalyze *ira, IrInstruction *source_ |
| 10062 | 9995 | source_instr->scope, source_instr->source_node); |
| 10063 | 9996 | const_instruction->base.value.type = value->value.type->data.enumeration.tag_type; |
| 10064 | 9997 | const_instruction->base.value.special = ConstValSpecialStatic; |
| 10065 | | const_instruction->base.value.depends_on_compile_var = val->depends_on_compile_var; |
| 10066 | 9998 | bignum_init_unsigned(&const_instruction->base.value.data.x_bignum, val->data.x_enum.tag); |
| 10067 | 9999 | return &const_instruction->base; |
| 10068 | 10000 | } |
| ... | ... | @@ -10178,7 +10110,6 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 10178 | 10110 | |
| 10179 | 10111 | assert(target_value_ptr->value.type->id == TypeTableEntryIdPointer); |
| 10180 | 10112 | TypeTableEntry *target_type = target_value_ptr->value.type->data.pointer.child_type; |
| 10181 | | bool depends_on_compile_var = target_value_ptr->value.depends_on_compile_var; |
| 10182 | 10113 | ConstExprValue *pointee_val = nullptr; |
| 10183 | 10114 | if (target_value_ptr->value.special != ConstValSpecialRuntime) { |
| 10184 | 10115 | pointee_val = const_ptr_pointee(&target_value_ptr->value); |
| ... | ... | @@ -10205,8 +10136,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 10205 | 10136 | case TypeTableEntryIdNamespace: |
| 10206 | 10137 | case TypeTableEntryIdPureError: |
| 10207 | 10138 | if (pointee_val) { |
| 10208 | | ConstExprValue *out_val = ir_build_const_from(ira, &switch_target_instruction->base, |
| 10209 | | depends_on_compile_var); |
| 10139 | ConstExprValue *out_val = ir_build_const_from(ira, &switch_target_instruction->base); |
| 10210 | 10140 | *out_val = *pointee_val; |
| 10211 | 10141 | out_val->type = target_type; |
| 10212 | 10142 | return target_type; |
| ... | ... | @@ -10218,8 +10148,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 10218 | 10148 | { |
| 10219 | 10149 | TypeTableEntry *tag_type = target_type->data.enumeration.tag_type; |
| 10220 | 10150 | if (pointee_val) { |
| 10221 | | ConstExprValue *out_val = ir_build_const_from(ira, &switch_target_instruction->base, |
| 10222 | | depends_on_compile_var); |
| 10151 | ConstExprValue *out_val = ir_build_const_from(ira, &switch_target_instruction->base); |
| 10223 | 10152 | bignum_init_unsigned(&out_val->data.x_bignum, pointee_val->data.x_enum.tag); |
| 10224 | 10153 | return tag_type; |
| 10225 | 10154 | } |
| ... | ... | @@ -10285,8 +10214,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstr |
| 10285 | 10214 | |
| 10286 | 10215 | ConstExprValue *pointee_val = const_ptr_pointee(target_val_ptr); |
| 10287 | 10216 | if (pointee_val->type->id == TypeTableEntryIdEnum) { |
| 10288 | | bool depends_on_compile_var = target_value_ptr->value.depends_on_compile_var; |
| 10289 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); |
| 10217 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 10290 | 10218 | out_val->data.x_ptr.base_ptr = pointee_val->data.x_enum.payload; |
| 10291 | 10219 | out_val->data.x_ptr.index = SIZE_MAX; |
| 10292 | 10220 | return get_pointer_to_type(ira->codegen, pointee_val->type, target_value_ptr->value.type->data.pointer.is_const); |
| ... | ... | @@ -10323,9 +10251,8 @@ static TypeTableEntry *ir_analyze_instruction_generated_code(IrAnalyze *ira, IrI |
| 10323 | 10251 | if (!val) |
| 10324 | 10252 | return ira->codegen->builtin_types.entry_invalid; |
| 10325 | 10253 | |
| 10326 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, false); |
| 10254 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 10327 | 10255 | *out_val = *val; |
| 10328 | | out_val->depends_on_compile_var = true; |
| 10329 | 10256 | return value->value.type; |
| 10330 | 10257 | } |
| 10331 | 10258 | |
| ... | ... | @@ -10338,7 +10265,6 @@ static TypeTableEntry *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructi |
| 10338 | 10265 | Buf *import_target_str = ir_resolve_str(ira, name_value); |
| 10339 | 10266 | if (!import_target_str) |
| 10340 | 10267 | return ira->codegen->builtin_types.entry_invalid; |
| 10341 | | bool depends_on_compile_var = name_value->value.depends_on_compile_var; |
| 10342 | 10268 | |
| 10343 | 10269 | AstNode *source_node = import_instruction->base.source_node; |
| 10344 | 10270 | ImportTableEntry *import = source_node->owner; |
| ... | ... | @@ -10380,7 +10306,7 @@ static TypeTableEntry *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructi |
| 10380 | 10306 | |
| 10381 | 10307 | auto import_entry = ira->codegen->import_table.maybe_get(abs_full_path); |
| 10382 | 10308 | if (import_entry) { |
| 10383 | | ConstExprValue *out_val = ir_build_const_from(ira, &import_instruction->base, depends_on_compile_var); |
| 10309 | ConstExprValue *out_val = ir_build_const_from(ira, &import_instruction->base); |
| 10384 | 10310 | out_val->data.x_import = import_entry->value; |
| 10385 | 10311 | return ira->codegen->builtin_types.entry_namespace; |
| 10386 | 10312 | } |
| ... | ... | @@ -10401,7 +10327,7 @@ static TypeTableEntry *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructi |
| 10401 | 10327 | |
| 10402 | 10328 | scan_decls(ira->codegen, target_import->decls_scope, target_import->root); |
| 10403 | 10329 | |
| 10404 | | ConstExprValue *out_val = ir_build_const_from(ira, &import_instruction->base, depends_on_compile_var); |
| 10330 | ConstExprValue *out_val = ir_build_const_from(ira, &import_instruction->base); |
| 10405 | 10331 | out_val->data.x_import = target_import; |
| 10406 | 10332 | return ira->codegen->builtin_types.entry_namespace; |
| 10407 | 10333 | |
| ... | ... | @@ -10415,16 +10341,14 @@ static TypeTableEntry *ir_analyze_instruction_array_len(IrAnalyze *ira, |
| 10415 | 10341 | if (canon_type->id == TypeTableEntryIdInvalid) { |
| 10416 | 10342 | return ira->codegen->builtin_types.entry_invalid; |
| 10417 | 10343 | } else if (canon_type->id == TypeTableEntryIdArray) { |
| 10418 | | bool depends_on_compile_var = array_value->value.depends_on_compile_var; |
| 10419 | 10344 | return ir_analyze_const_usize(ira, &array_len_instruction->base, |
| 10420 | | canon_type->data.array.len, depends_on_compile_var); |
| 10345 | canon_type->data.array.len); |
| 10421 | 10346 | } else if (is_slice(canon_type)) { |
| 10422 | 10347 | if (array_value->value.special != ConstValSpecialRuntime) { |
| 10423 | 10348 | ConstExprValue *len_val = &array_value->value.data.x_struct.fields[slice_len_index]; |
| 10424 | 10349 | if (len_val->special != ConstValSpecialRuntime) { |
| 10425 | | bool depends_on_compile_var = len_val->depends_on_compile_var; |
| 10426 | 10350 | return ir_analyze_const_usize(ira, &array_len_instruction->base, |
| 10427 | | len_val->data.x_bignum.data.x_uint, depends_on_compile_var); |
| 10351 | len_val->data.x_bignum.data.x_uint); |
| 10428 | 10352 | } |
| 10429 | 10353 | } |
| 10430 | 10354 | TypeStructField *field = &canon_type->data.structure.fields[slice_len_index]; |
| ... | ... | @@ -10447,8 +10371,7 @@ static TypeTableEntry *ir_analyze_instruction_ref(IrAnalyze *ira, IrInstructionR |
| 10447 | 10371 | } |
| 10448 | 10372 | |
| 10449 | 10373 | static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruction *instruction, |
| 10450 | | TypeTableEntry *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields, |
| 10451 | | bool depends_on_compile_var) |
| 10374 | TypeTableEntry *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields) |
| 10452 | 10375 | { |
| 10453 | 10376 | if (container_type->id != TypeTableEntryIdStruct || is_slice(container_type)) { |
| 10454 | 10377 | ir_add_error(ira, instruction, |
| ... | ... | @@ -10473,7 +10396,6 @@ static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstru |
| 10473 | 10396 | ConstExprValue const_val = {}; |
| 10474 | 10397 | const_val.special = ConstValSpecialStatic; |
| 10475 | 10398 | const_val.type = container_type; |
| 10476 | | const_val.depends_on_compile_var = depends_on_compile_var; |
| 10477 | 10399 | const_val.data.x_struct.fields = allocate<ConstExprValue>(actual_field_count); |
| 10478 | 10400 | for (size_t i = 0; i < instr_field_count; i += 1) { |
| 10479 | 10401 | IrInstructionContainerInitFieldsField *field = &fields[i]; |
| ... | ... | @@ -10516,7 +10438,6 @@ static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstru |
| 10516 | 10438 | return ira->codegen->builtin_types.entry_invalid; |
| 10517 | 10439 | |
| 10518 | 10440 | const_val.data.x_struct.fields[field_index] = *field_val; |
| 10519 | | const_val.depends_on_compile_var = const_val.depends_on_compile_var || field_val->depends_on_compile_var; |
| 10520 | 10441 | } else { |
| 10521 | 10442 | first_non_const_instruction = casted_field_value; |
| 10522 | 10443 | const_val.special = ConstValSpecialRuntime; |
| ... | ... | @@ -10536,7 +10457,7 @@ static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstru |
| 10536 | 10457 | return ira->codegen->builtin_types.entry_invalid; |
| 10537 | 10458 | |
| 10538 | 10459 | if (const_val.special == ConstValSpecialStatic) { |
| 10539 | | ConstExprValue *out_val = ir_build_const_from(ira, instruction, const_val.depends_on_compile_var); |
| 10460 | ConstExprValue *out_val = ir_build_const_from(ira, instruction); |
| 10540 | 10461 | *out_val = const_val; |
| 10541 | 10462 | return container_type; |
| 10542 | 10463 | } |
| ... | ... | @@ -10567,11 +10488,9 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira |
| 10567 | 10488 | if (container_type->id == TypeTableEntryIdInvalid) |
| 10568 | 10489 | return ira->codegen->builtin_types.entry_invalid; |
| 10569 | 10490 | |
| 10570 | | bool depends_on_compile_var = container_type_value->value.depends_on_compile_var; |
| 10571 | | |
| 10572 | 10491 | if (container_type->id == TypeTableEntryIdStruct && !is_slice(container_type) && elem_count == 0) { |
| 10573 | 10492 | return ir_analyze_container_init_fields(ira, &instruction->base, container_type, |
| 10574 | | 0, nullptr, depends_on_compile_var); |
| 10493 | 0, nullptr); |
| 10575 | 10494 | } else if (is_slice(container_type)) { |
| 10576 | 10495 | TypeTableEntry *pointer_type = container_type->data.structure.fields[slice_ptr_index].type_entry; |
| 10577 | 10496 | assert(pointer_type->id == TypeTableEntryIdPointer); |
| ... | ... | @@ -10581,7 +10500,6 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira |
| 10581 | 10500 | ConstExprValue const_val = {}; |
| 10582 | 10501 | const_val.special = ConstValSpecialStatic; |
| 10583 | 10502 | const_val.type = fixed_size_array_type; |
| 10584 | | const_val.depends_on_compile_var = depends_on_compile_var; |
| 10585 | 10503 | const_val.data.x_array.elements = allocate<ConstExprValue>(elem_count); |
| 10586 | 10504 | const_val.data.x_array.size = elem_count; |
| 10587 | 10505 | |
| ... | ... | @@ -10609,7 +10527,6 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira |
| 10609 | 10527 | return ira->codegen->builtin_types.entry_invalid; |
| 10610 | 10528 | |
| 10611 | 10529 | const_val.data.x_array.elements[i] = *elem_val; |
| 10612 | | const_val.depends_on_compile_var = const_val.depends_on_compile_var || elem_val->depends_on_compile_var; |
| 10613 | 10530 | } else { |
| 10614 | 10531 | first_non_const_instruction = casted_arg; |
| 10615 | 10532 | const_val.special = ConstValSpecialRuntime; |
| ... | ... | @@ -10618,7 +10535,7 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira |
| 10618 | 10535 | } |
| 10619 | 10536 | |
| 10620 | 10537 | if (const_val.special == ConstValSpecialStatic) { |
| 10621 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, const_val.depends_on_compile_var); |
| 10538 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 10622 | 10539 | *out_val = const_val; |
| 10623 | 10540 | for (size_t i = 0; i < elem_count; i += 1) { |
| 10624 | 10541 | ConstExprValue *elem_val = &out_val->data.x_array.elements[i]; |
| ... | ... | @@ -10681,8 +10598,7 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira |
| 10681 | 10598 | ConstExprValue *init_val = ir_resolve_const(ira, casted_init_value, UndefOk); |
| 10682 | 10599 | if (!init_val) |
| 10683 | 10600 | return ira->codegen->builtin_types.entry_invalid; |
| 10684 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, |
| 10685 | | casted_init_value->value.depends_on_compile_var); |
| 10601 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 10686 | 10602 | out_val->data.x_enum.tag = tag_uint; |
| 10687 | 10603 | out_val->data.x_enum.payload = init_val; |
| 10688 | 10604 | return enum_type; |
| ... | ... | @@ -10705,37 +10621,34 @@ static TypeTableEntry *ir_analyze_instruction_container_init_fields(IrAnalyze *i |
| 10705 | 10621 | if (type_is_invalid(container_type)) |
| 10706 | 10622 | return ira->codegen->builtin_types.entry_invalid; |
| 10707 | 10623 | |
| 10708 | | bool depends_on_compile_var = container_type_value->value.depends_on_compile_var; |
| 10709 | | |
| 10710 | 10624 | return ir_analyze_container_init_fields(ira, &instruction->base, container_type, |
| 10711 | | instruction->field_count, instruction->fields, depends_on_compile_var); |
| 10625 | instruction->field_count, instruction->fields); |
| 10712 | 10626 | } |
| 10713 | 10627 | |
| 10714 | 10628 | static TypeTableEntry *ir_analyze_min_max(IrAnalyze *ira, IrInstruction *source_instruction, |
| 10715 | 10629 | IrInstruction *target_type_value, bool is_max) |
| 10716 | 10630 | { |
| 10717 | 10631 | TypeTableEntry *target_type = ir_resolve_type(ira, target_type_value); |
| 10718 | | bool depends_on_compile_var = target_type_value->value.depends_on_compile_var; |
| 10719 | 10632 | TypeTableEntry *canon_type = get_underlying_type(target_type); |
| 10720 | 10633 | switch (canon_type->id) { |
| 10721 | 10634 | case TypeTableEntryIdInvalid: |
| 10722 | 10635 | return ira->codegen->builtin_types.entry_invalid; |
| 10723 | 10636 | case TypeTableEntryIdInt: |
| 10724 | 10637 | { |
| 10725 | | ConstExprValue *out_val = ir_build_const_from(ira, source_instruction, depends_on_compile_var); |
| 10638 | ConstExprValue *out_val = ir_build_const_from(ira, source_instruction); |
| 10726 | 10639 | eval_min_max_value(ira->codegen, canon_type, out_val, is_max); |
| 10727 | 10640 | return ira->codegen->builtin_types.entry_num_lit_int; |
| 10728 | 10641 | } |
| 10729 | 10642 | case TypeTableEntryIdFloat: |
| 10730 | 10643 | { |
| 10731 | | ConstExprValue *out_val = ir_build_const_from(ira, source_instruction, depends_on_compile_var); |
| 10644 | ConstExprValue *out_val = ir_build_const_from(ira, source_instruction); |
| 10732 | 10645 | eval_min_max_value(ira->codegen, canon_type, out_val, is_max); |
| 10733 | 10646 | return ira->codegen->builtin_types.entry_num_lit_float; |
| 10734 | 10647 | } |
| 10735 | 10648 | case TypeTableEntryIdBool: |
| 10736 | 10649 | case TypeTableEntryIdVoid: |
| 10737 | 10650 | { |
| 10738 | | ConstExprValue *out_val = ir_build_const_from(ira, source_instruction, depends_on_compile_var); |
| 10651 | ConstExprValue *out_val = ir_build_const_from(ira, source_instruction); |
| 10739 | 10652 | eval_min_max_value(ira->codegen, canon_type, out_val, is_max); |
| 10740 | 10653 | return target_type; |
| 10741 | 10654 | } |
| ... | ... | @@ -10815,7 +10728,7 @@ static TypeTableEntry *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInst |
| 10815 | 10728 | |
| 10816 | 10729 | ir_add_error(ira, &instruction->base, buf_sprintf("found compile log statement")); |
| 10817 | 10730 | |
| 10818 | | ir_build_const_from(ira, &instruction->base, false); |
| 10731 | ir_build_const_from(ira, &instruction->base); |
| 10819 | 10732 | return ira->codegen->builtin_types.entry_void; |
| 10820 | 10733 | } |
| 10821 | 10734 | |
| ... | ... | @@ -10835,8 +10748,7 @@ static TypeTableEntry *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruc |
| 10835 | 10748 | ConstExprValue *array_val = create_const_str_lit(ira->codegen, &err->name); |
| 10836 | 10749 | err->cached_error_name_val = create_const_slice(ira->codegen, array_val, 0, buf_len(&err->name), true); |
| 10837 | 10750 | } |
| 10838 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, |
| 10839 | | casted_value->value.depends_on_compile_var); |
| 10751 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 10840 | 10752 | *out_val = *err->cached_error_name_val; |
| 10841 | 10753 | return str_type; |
| 10842 | 10754 | } |
| ... | ... | @@ -10855,8 +10767,7 @@ static TypeTableEntry *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstru |
| 10855 | 10767 | if (!type_entry->cached_const_name_val) { |
| 10856 | 10768 | type_entry->cached_const_name_val = create_const_str_lit(ira->codegen, &type_entry->name); |
| 10857 | 10769 | } |
| 10858 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, |
| 10859 | | type_value->value.depends_on_compile_var); |
| 10770 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 10860 | 10771 | *out_val = *type_entry->cached_const_name_val; |
| 10861 | 10772 | return out_val->type; |
| 10862 | 10773 | } |
| ... | ... | @@ -10905,10 +10816,7 @@ static TypeTableEntry *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruc |
| 10905 | 10816 | ast_render_decls(stderr, 4, child_import); |
| 10906 | 10817 | } |
| 10907 | 10818 | |
| 10908 | | // TODO to get fewer false negatives on this, we would need to track this value in |
| 10909 | | // the ir executable |
| 10910 | | bool depends_on_compile_var = true; |
| 10911 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); |
| 10819 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 10912 | 10820 | out_val->data.x_import = child_import; |
| 10913 | 10821 | return ira->codegen->builtin_types.entry_namespace; |
| 10914 | 10822 | } |
| ... | ... | @@ -10928,7 +10836,7 @@ static TypeTableEntry *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstru |
| 10928 | 10836 | |
| 10929 | 10837 | buf_appendf(c_import_buf, "#include <%s>\n", buf_ptr(include_name)); |
| 10930 | 10838 | |
| 10931 | | ir_build_const_from(ira, &instruction->base, false); |
| 10839 | ir_build_const_from(ira, &instruction->base); |
| 10932 | 10840 | return ira->codegen->builtin_types.entry_void; |
| 10933 | 10841 | } |
| 10934 | 10842 | |
| ... | ... | @@ -10955,7 +10863,7 @@ static TypeTableEntry *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstruc |
| 10955 | 10863 | |
| 10956 | 10864 | buf_appendf(c_import_buf, "#define %s %s\n", buf_ptr(define_name), buf_ptr(define_value)); |
| 10957 | 10865 | |
| 10958 | | ir_build_const_from(ira, &instruction->base, false); |
| 10866 | ir_build_const_from(ira, &instruction->base); |
| 10959 | 10867 | return ira->codegen->builtin_types.entry_void; |
| 10960 | 10868 | } |
| 10961 | 10869 | |
| ... | ... | @@ -10974,7 +10882,7 @@ static TypeTableEntry *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstruct |
| 10974 | 10882 | |
| 10975 | 10883 | buf_appendf(c_import_buf, "#undef %s\n", buf_ptr(undef_name)); |
| 10976 | 10884 | |
| 10977 | | ir_build_const_from(ira, &instruction->base, false); |
| 10885 | ir_build_const_from(ira, &instruction->base); |
| 10978 | 10886 | return ira->codegen->builtin_types.entry_void; |
| 10979 | 10887 | } |
| 10980 | 10888 | |
| ... | ... | @@ -11011,8 +10919,7 @@ static TypeTableEntry *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstr |
| 11011 | 10919 | // TODO add dependency on the file we embedded so that we know if it changes |
| 11012 | 10920 | // we'll have to invalidate the cache |
| 11013 | 10921 | |
| 11014 | | bool depends_on_compile_var = true; |
| 11015 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); |
| 10922 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11016 | 10923 | init_const_str_lit(ira->codegen, out_val, &file_contents); |
| 11017 | 10924 | |
| 11018 | 10925 | return get_array_type(ira->codegen, ira->codegen->builtin_types.entry_u8, buf_len(&file_contents)); |
| ... | ... | @@ -11161,9 +11068,7 @@ static TypeTableEntry *ir_analyze_instruction_div_exact(IrAnalyze *ira, IrInstru |
| 11161 | 11068 | return ira->codegen->builtin_types.entry_invalid; |
| 11162 | 11069 | } |
| 11163 | 11070 | |
| 11164 | | bool depends_on_compile_var = casted_op1->value.depends_on_compile_var || |
| 11165 | | casted_op2->value.depends_on_compile_var; |
| 11166 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); |
| 11071 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11167 | 11072 | bignum_div(&out_val->data.x_bignum, &op1_val->data.x_bignum, &op2_val->data.x_bignum); |
| 11168 | 11073 | return result_type; |
| 11169 | 11074 | } |
| ... | ... | @@ -11215,8 +11120,7 @@ static TypeTableEntry *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruc |
| 11215 | 11120 | } |
| 11216 | 11121 | |
| 11217 | 11122 | if (target->value.special == ConstValSpecialStatic) { |
| 11218 | | bool depends_on_compile_var = dest_type_value->value.depends_on_compile_var || target->value.depends_on_compile_var; |
| 11219 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); |
| 11123 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11220 | 11124 | bignum_init_bignum(&out_val->data.x_bignum, &target->value.data.x_bignum); |
| 11221 | 11125 | bignum_truncate(&out_val->data.x_bignum, canon_dest_type->data.integral.bit_count); |
| 11222 | 11126 | return dest_type; |
| ... | ... | @@ -11237,10 +11141,7 @@ static TypeTableEntry *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstruc |
| 11237 | 11141 | if (!ir_resolve_usize(ira, bit_count_value, &bit_count)) |
| 11238 | 11142 | return ira->codegen->builtin_types.entry_invalid; |
| 11239 | 11143 | |
| 11240 | | bool depends_on_compile_var = is_signed_value->value.depends_on_compile_var || |
| 11241 | | bit_count_value->value.depends_on_compile_var; |
| 11242 | | |
| 11243 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); |
| 11144 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11244 | 11145 | out_val->data.x_type = get_int_type(ira->codegen, is_signed, bit_count); |
| 11245 | 11146 | return ira->codegen->builtin_types.entry_type; |
| 11246 | 11147 | } |
| ... | ... | @@ -11257,8 +11158,7 @@ static TypeTableEntry *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstruc |
| 11257 | 11158 | return ira->codegen->builtin_types.entry_invalid; |
| 11258 | 11159 | |
| 11259 | 11160 | if (casted_value->value.special != ConstValSpecialRuntime) { |
| 11260 | | bool depends_on_compile_var = casted_value->value.depends_on_compile_var; |
| 11261 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); |
| 11161 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11262 | 11162 | out_val->data.x_bool = !casted_value->value.data.x_bool; |
| 11263 | 11163 | return bool_type; |
| 11264 | 11164 | } |
| ... | ... | @@ -11357,7 +11257,7 @@ static TypeTableEntry *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructi |
| 11357 | 11257 | dest_elements[i] = *byte_val; |
| 11358 | 11258 | } |
| 11359 | 11259 | |
| 11360 | | ir_build_const_from(ira, &instruction->base, false); |
| 11260 | ir_build_const_from(ira, &instruction->base); |
| 11361 | 11261 | return ira->codegen->builtin_types.entry_void; |
| 11362 | 11262 | } |
| 11363 | 11263 | |
| ... | ... | @@ -11454,7 +11354,7 @@ static TypeTableEntry *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructi |
| 11454 | 11354 | dest_elements[dest_start + i] = src_elements[src_start + i]; |
| 11455 | 11355 | } |
| 11456 | 11356 | |
| 11457 | | ir_build_const_from(ira, &instruction->base, false); |
| 11357 | ir_build_const_from(ira, &instruction->base); |
| 11458 | 11358 | return ira->codegen->builtin_types.entry_void; |
| 11459 | 11359 | } |
| 11460 | 11360 | |
| ... | ... | @@ -11515,11 +11415,6 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio |
| 11515 | 11415 | casted_start->value.special == ConstValSpecialStatic && |
| 11516 | 11416 | (!end || end->value.special == ConstValSpecialStatic)) |
| 11517 | 11417 | { |
| 11518 | | bool depends_on_compile_var = |
| 11519 | | ptr->value.depends_on_compile_var || |
| 11520 | | casted_start->value.depends_on_compile_var || |
| 11521 | | (end ? end->value.depends_on_compile_var : false); |
| 11522 | | |
| 11523 | 11418 | ConstExprValue *base_ptr; |
| 11524 | 11419 | size_t abs_offset; |
| 11525 | 11420 | size_t rel_end; |
| ... | ... | @@ -11571,7 +11466,7 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio |
| 11571 | 11466 | return ira->codegen->builtin_types.entry_invalid; |
| 11572 | 11467 | } |
| 11573 | 11468 | |
| 11574 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); |
| 11469 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11575 | 11470 | out_val->data.x_struct.fields = allocate<ConstExprValue>(2); |
| 11576 | 11471 | |
| 11577 | 11472 | ConstExprValue *ptr_val = &out_val->data.x_struct.fields[slice_ptr_index]; |
| ... | ... | @@ -11612,8 +11507,7 @@ static TypeTableEntry *ir_analyze_instruction_member_count(IrAnalyze *ira, IrIns |
| 11612 | 11507 | return ira->codegen->builtin_types.entry_invalid; |
| 11613 | 11508 | } |
| 11614 | 11509 | |
| 11615 | | bool depends_on_compile_var = container->value.depends_on_compile_var; |
| 11616 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); |
| 11510 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11617 | 11511 | bignum_init_unsigned(&out_val->data.x_bignum, result); |
| 11618 | 11512 | return ira->codegen->builtin_types.entry_num_lit_int; |
| 11619 | 11513 | } |
| ... | ... | @@ -11653,8 +11547,7 @@ static TypeTableEntry *ir_analyze_instruction_alignof(IrAnalyze *ira, IrInstruct |
| 11653 | 11547 | return ira->codegen->builtin_types.entry_invalid; |
| 11654 | 11548 | } else { |
| 11655 | 11549 | uint64_t align_in_bytes = LLVMABISizeOfType(ira->codegen->target_data_ref, type_entry->type_ref); |
| 11656 | | bool depends_on_compile_var = type_value->value.depends_on_compile_var; |
| 11657 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); |
| 11550 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11658 | 11551 | bignum_init_unsigned(&out_val->data.x_bignum, align_in_bytes); |
| 11659 | 11552 | return ira->codegen->builtin_types.entry_num_lit_int; |
| 11660 | 11553 | } |
| ... | ... | @@ -11705,10 +11598,7 @@ static TypeTableEntry *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInst |
| 11705 | 11598 | casted_op2->value.special == ConstValSpecialStatic && |
| 11706 | 11599 | casted_result_ptr->value.special == ConstValSpecialStatic) |
| 11707 | 11600 | { |
| 11708 | | bool depends_on_compile_var = type_value->value.depends_on_compile_var || |
| 11709 | | casted_op1->value.depends_on_compile_var || casted_op2->value.depends_on_compile_var || |
| 11710 | | casted_result_ptr->value.depends_on_compile_var; |
| 11711 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); |
| 11601 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11712 | 11602 | BigNum *op1_bignum = &casted_op1->value.data.x_bignum; |
| 11713 | 11603 | BigNum *op2_bignum = &casted_op2->value.data.x_bignum; |
| 11714 | 11604 | ConstExprValue *pointee_val = const_ptr_pointee(&casted_result_ptr->value); |
| ... | ... | @@ -11759,8 +11649,7 @@ static TypeTableEntry *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruc |
| 11759 | 11649 | return ira->codegen->builtin_types.entry_invalid; |
| 11760 | 11650 | |
| 11761 | 11651 | if (err_union_val->special != ConstValSpecialRuntime) { |
| 11762 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, |
| 11763 | | err_union_val->depends_on_compile_var); |
| 11652 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11764 | 11653 | out_val->data.x_bool = (err_union_val->data.x_err_union.err != nullptr); |
| 11765 | 11654 | return ira->codegen->builtin_types.entry_bool; |
| 11766 | 11655 | } |
| ... | ... | @@ -11769,11 +11658,11 @@ static TypeTableEntry *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruc |
| 11769 | 11658 | ir_build_test_err_from(&ira->new_irb, &instruction->base, value); |
| 11770 | 11659 | return ira->codegen->builtin_types.entry_bool; |
| 11771 | 11660 | } else if (canon_type->id == TypeTableEntryIdPureError) { |
| 11772 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, false); |
| 11661 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11773 | 11662 | out_val->data.x_bool = true; |
| 11774 | 11663 | return ira->codegen->builtin_types.entry_bool; |
| 11775 | 11664 | } else { |
| 11776 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, false); |
| 11665 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11777 | 11666 | out_val->data.x_bool = false; |
| 11778 | 11667 | return ira->codegen->builtin_types.entry_bool; |
| 11779 | 11668 | } |
| ... | ... | @@ -11805,8 +11694,7 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira, |
| 11805 | 11694 | ErrorTableEntry *err = err_union_val->data.x_err_union.err; |
| 11806 | 11695 | assert(err); |
| 11807 | 11696 | |
| 11808 | | bool depends_on_compile_var = ptr_val->depends_on_compile_var || err_union_val->depends_on_compile_var; |
| 11809 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); |
| 11697 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11810 | 11698 | out_val->data.x_pure_err = err; |
| 11811 | 11699 | return ira->codegen->builtin_types.entry_pure_error; |
| 11812 | 11700 | } |
| ... | ... | @@ -11855,8 +11743,7 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira, |
| 11855 | 11743 | return ira->codegen->builtin_types.entry_invalid; |
| 11856 | 11744 | } |
| 11857 | 11745 | |
| 11858 | | bool depends_on_compile_var = ptr_val->depends_on_compile_var || err_union_val->depends_on_compile_var; |
| 11859 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); |
| 11746 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11860 | 11747 | out_val->data.x_ptr.base_ptr = err_union_val->data.x_err_union.payload; |
| 11861 | 11748 | out_val->data.x_ptr.index = SIZE_MAX; |
| 11862 | 11749 | return result_type; |
| ... | ... | @@ -11881,8 +11768,6 @@ static TypeTableEntry *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruc |
| 11881 | 11768 | FnTypeId fn_type_id = {0}; |
| 11882 | 11769 | init_fn_type_id(&fn_type_id, proto_node, proto_node->data.fn_proto.params.length); |
| 11883 | 11770 | |
| 11884 | | bool depends_on_compile_var = false; |
| 11885 | | |
| 11886 | 11771 | for (; fn_type_id.next_param_index < fn_type_id.param_count; fn_type_id.next_param_index += 1) { |
| 11887 | 11772 | AstNode *param_node = proto_node->data.fn_proto.params.at(fn_type_id.next_param_index); |
| 11888 | 11773 | assert(param_node->type == NodeTypeParamDecl); |
| ... | ... | @@ -11894,17 +11779,14 @@ static TypeTableEntry *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruc |
| 11894 | 11779 | param_info->type = ir_resolve_type(ira, param_type_value); |
| 11895 | 11780 | if (param_info->type->id == TypeTableEntryIdInvalid) |
| 11896 | 11781 | return ira->codegen->builtin_types.entry_invalid; |
| 11897 | | |
| 11898 | | depends_on_compile_var = depends_on_compile_var || param_type_value->value.depends_on_compile_var; |
| 11899 | 11782 | } |
| 11900 | 11783 | |
| 11901 | 11784 | IrInstruction *return_type_value = instruction->return_type->other; |
| 11902 | 11785 | fn_type_id.return_type = ir_resolve_type(ira, return_type_value); |
| 11903 | 11786 | if (fn_type_id.return_type->id == TypeTableEntryIdInvalid) |
| 11904 | 11787 | return ira->codegen->builtin_types.entry_invalid; |
| 11905 | | depends_on_compile_var = depends_on_compile_var || return_type_value->value.depends_on_compile_var; |
| 11906 | 11788 | |
| 11907 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); |
| 11789 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11908 | 11790 | out_val->data.x_type = get_fn_type(ira->codegen, &fn_type_id); |
| 11909 | 11791 | return ira->codegen->builtin_types.entry_type; |
| 11910 | 11792 | } |
| ... | ... | @@ -11914,7 +11796,7 @@ static TypeTableEntry *ir_analyze_instruction_test_comptime(IrAnalyze *ira, IrIn |
| 11914 | 11796 | if (value->value.type->id == TypeTableEntryIdInvalid) |
| 11915 | 11797 | return ira->codegen->builtin_types.entry_invalid; |
| 11916 | 11798 | |
| 11917 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, false); |
| 11799 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11918 | 11800 | out_val->data.x_bool = instr_is_comptime(value); |
| 11919 | 11801 | return ira->codegen->builtin_types.entry_bool; |
| 11920 | 11802 | } |
| ... | ... | @@ -11978,7 +11860,7 @@ static TypeTableEntry *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira |
| 11978 | 11860 | } else { |
| 11979 | 11861 | // TODO check prongs of types other than enumtag |
| 11980 | 11862 | } |
| 11981 | | ir_build_const_from(ira, &instruction->base, false); |
| 11863 | ir_build_const_from(ira, &instruction->base); |
| 11982 | 11864 | return ira->codegen->builtin_types.entry_void; |
| 11983 | 11865 | } |
| 11984 | 11866 | |
| ... | ... | @@ -11988,7 +11870,7 @@ static TypeTableEntry *ir_analyze_instruction_test_type(IrAnalyze *ira, IrInstru |
| 11988 | 11870 | if (type_entry->id == TypeTableEntryIdInvalid) |
| 11989 | 11871 | return ira->codegen->builtin_types.entry_invalid; |
| 11990 | 11872 | |
| 11991 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, type_value->value.depends_on_compile_var); |
| 11873 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11992 | 11874 | out_val->data.x_bool = (type_entry->id == instruction->type_id); |
| 11993 | 11875 | return ira->codegen->builtin_types.entry_bool; |
| 11994 | 11876 | } |
| ... | ... | @@ -12012,10 +11894,7 @@ static TypeTableEntry *ir_analyze_instruction_can_implicit_cast(IrAnalyze *ira, |
| 12012 | 11894 | zig_panic("TODO refactor implicit cast tester to return bool without reporting errors"); |
| 12013 | 11895 | } |
| 12014 | 11896 | |
| 12015 | | // TODO in order to known depends_on_compile_var we have to known if the type of the target |
| 12016 | | // depends on a compile var |
| 12017 | | bool depends_on_compile_var = true; |
| 12018 | | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); |
| 11897 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 12019 | 11898 | out_val->data.x_bool = (result == ImplicitCastMatchResultYes); |
| 12020 | 11899 | return ira->codegen->builtin_types.entry_bool; |
| 12021 | 11900 | } |