| ... | @@ -610,13 +610,12 @@ static IrInstruction *ir_build_return_from(IrBuilder *irb, IrInstruction *old_in | ... | @@ -610,13 +610,12 @@ static IrInstruction *ir_build_return_from(IrBuilder *irb, IrInstruction *old_in |
| 610 | } | 610 | } |
| 611 | | 611 | |
| 612 | static IrInstruction *ir_create_const(IrBuilder *irb, Scope *scope, AstNode *source_node, | 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 | assert(type_entry); | 615 | assert(type_entry); |
| 616 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); | 616 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); |
| 617 | const_instruction->base.value.type = type_entry; | 617 | const_instruction->base.value.type = type_entry; |
| 618 | const_instruction->base.value.special = ConstValSpecialStatic; | 618 | const_instruction->base.value.special = ConstValSpecialStatic; |
| 619 | const_instruction->base.value.depends_on_compile_var = depends_on_compile_var; | | |
| 620 | return &const_instruction->base; | 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,20 +666,19 @@ static IrInstruction *ir_build_const_usize(IrBuilder *irb, Scope *scope, AstNode |
| 667 | } | 666 | } |
| 668 | | 667 | |
| 669 | static IrInstruction *ir_create_const_type(IrBuilder *irb, Scope *scope, AstNode *source_node, | 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 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); | 671 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); |
| 673 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_type; | 672 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_type; |
| 674 | const_instruction->base.value.special = ConstValSpecialStatic; | 673 | const_instruction->base.value.special = ConstValSpecialStatic; |
| 675 | const_instruction->base.value.depends_on_compile_var = depends_on_compile_var; | | |
| 676 | const_instruction->base.value.data.x_type = type_entry; | 674 | const_instruction->base.value.data.x_type = type_entry; |
| 677 | return &const_instruction->base; | 675 | return &const_instruction->base; |
| 678 | } | 676 | } |
| 679 | | 677 | |
| 680 | static IrInstruction *ir_build_const_type(IrBuilder *irb, Scope *scope, AstNode *source_node, | 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 | ir_instruction_append(irb->current_basic_block, instruction); | 682 | ir_instruction_append(irb->current_basic_block, instruction); |
| 685 | return instruction; | 683 | return instruction; |
| 686 | } | 684 | } |
| ... | @@ -720,12 +718,11 @@ static IrInstruction *ir_build_const_bool(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -720,12 +718,11 @@ static IrInstruction *ir_build_const_bool(IrBuilder *irb, Scope *scope, AstNode |
| 720 | } | 718 | } |
| 721 | | 719 | |
| 722 | static IrInstruction *ir_build_const_bound_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, | 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 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 723 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); |
| 726 | const_instruction->base.value.type = get_bound_fn_type(irb->codegen, fn_entry); | 724 | const_instruction->base.value.type = get_bound_fn_type(irb->codegen, fn_entry); |
| 727 | const_instruction->base.value.special = ConstValSpecialStatic; | 725 | const_instruction->base.value.special = ConstValSpecialStatic; |
| 728 | const_instruction->base.value.depends_on_compile_var = depends_on_compile_var; | | |
| 729 | const_instruction->base.value.data.x_bound_fn.fn = fn_entry; | 726 | const_instruction->base.value.data.x_bound_fn.fn = fn_entry; |
| 730 | const_instruction->base.value.data.x_bound_fn.first_arg = first_arg; | 727 | const_instruction->base.value.data.x_bound_fn.first_arg = first_arg; |
| 731 | return &const_instruction->base; | 728 | return &const_instruction->base; |
| ... | @@ -3609,7 +3606,7 @@ static IrInstruction *ir_gen_null_literal(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -3609,7 +3606,7 @@ static IrInstruction *ir_gen_null_literal(IrBuilder *irb, Scope *scope, AstNode |
| 3609 | static IrInstruction *ir_gen_var_literal(IrBuilder *irb, Scope *scope, AstNode *node) { | 3606 | static IrInstruction *ir_gen_var_literal(IrBuilder *irb, Scope *scope, AstNode *node) { |
| 3610 | assert(node->type == NodeTypeVarLiteral); | 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 | static IrInstruction *ir_gen_decl_ref(IrBuilder *irb, AstNode *source_node, Tld *tld, | 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,7 +3645,7 @@ static IrInstruction *ir_gen_decl_ref(IrBuilder *irb, AstNode *source_node, Tld |
| 3648 | { | 3645 | { |
| 3649 | TldTypeDef *tld_typedef = (TldTypeDef *)tld; | 3646 | TldTypeDef *tld_typedef = (TldTypeDef *)tld; |
| 3650 | TypeTableEntry *typedef_type = tld_typedef->type_entry; | 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 | if (lval.is_ptr) | 3649 | if (lval.is_ptr) |
| 3653 | return ir_build_ref(irb, scope, source_node, ref_instruction, true, false); | 3650 | return ir_build_ref(irb, scope, source_node, ref_instruction, true, false); |
| 3654 | else | 3651 | else |
| ... | @@ -3665,7 +3662,7 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -3665,7 +3662,7 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, |
| 3665 | | 3662 | |
| 3666 | auto primitive_table_entry = irb->codegen->primitive_type_table.maybe_get(variable_name); | 3663 | auto primitive_table_entry = irb->codegen->primitive_type_table.maybe_get(variable_name); |
| 3667 | if (primitive_table_entry) { | 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 | if (lval.is_ptr) { | 3666 | if (lval.is_ptr) { |
| 3670 | return ir_build_ref(irb, scope, node, value, lval.is_const, lval.is_volatile); | 3667 | return ir_build_ref(irb, scope, node, value, lval.is_const, lval.is_volatile); |
| 3671 | } else { | 3668 | } else { |
| ... | @@ -4629,7 +4626,7 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo | ... | @@ -4629,7 +4626,7 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo |
| 4629 | } | 4626 | } |
| 4630 | child_scope = index_var->child_scope; | 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 | IrInstruction *zero = ir_build_const_usize(irb, child_scope, node, 0); | 4630 | IrInstruction *zero = ir_build_const_usize(irb, child_scope, node, 0); |
| 4634 | IrInstruction *one = ir_build_const_usize(irb, child_scope, node, 1); | 4631 | IrInstruction *one = ir_build_const_usize(irb, child_scope, node, 1); |
| 4635 | ir_build_var_decl(irb, child_scope, index_var_source_node, index_var, usize, zero); | 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,7 +4690,7 @@ static IrInstruction *ir_gen_this_literal(IrBuilder *irb, Scope *scope, AstNode |
| 4693 | ScopeDecls *decls_scope = (ScopeDecls *)scope; | 4690 | ScopeDecls *decls_scope = (ScopeDecls *)scope; |
| 4694 | TypeTableEntry *container_type = decls_scope->container_type; | 4691 | TypeTableEntry *container_type = decls_scope->container_type; |
| 4695 | assert(container_type); | 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 | if (scope->id == ScopeIdBlock) | 4696 | if (scope->id == ScopeIdBlock) |
| ... | @@ -5260,12 +5257,12 @@ static IrInstruction *ir_gen_continue(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -5260,12 +5257,12 @@ static IrInstruction *ir_gen_continue(IrBuilder *irb, Scope *scope, AstNode *nod |
| 5260 | | 5257 | |
| 5261 | static IrInstruction *ir_gen_type_literal(IrBuilder *irb, Scope *scope, AstNode *node) { | 5258 | static IrInstruction *ir_gen_type_literal(IrBuilder *irb, Scope *scope, AstNode *node) { |
| 5262 | assert(node->type == NodeTypeTypeLiteral); | 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 | static IrInstruction *ir_gen_error_type(IrBuilder *irb, Scope *scope, AstNode *node) { | 5263 | static IrInstruction *ir_gen_error_type(IrBuilder *irb, Scope *scope, AstNode *node) { |
| 5267 | assert(node->type == NodeTypeErrorType); | 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 | static IrInstruction *ir_gen_defer(IrBuilder *irb, Scope *parent_scope, AstNode *node) { | 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,7 +5336,7 @@ static IrInstruction *ir_gen_err_ok_or(IrBuilder *irb, Scope *parent_scope, AstN |
| 5339 | if (var_node) { | 5336 | if (var_node) { |
| 5340 | assert(var_node->type == NodeTypeSymbol); | 5337 | assert(var_node->type == NodeTypeSymbol); |
| 5341 | IrInstruction *var_type = ir_build_const_type(irb, parent_scope, node, | 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 | Buf *var_name = var_node->data.symbol_expr.symbol; | 5340 | Buf *var_name = var_node->data.symbol_expr.symbol; |
| 5344 | bool is_const = true; | 5341 | bool is_const = true; |
| 5345 | bool is_shadowable = false; | 5342 | bool is_shadowable = false; |
| ... | @@ -5427,7 +5424,7 @@ static IrInstruction *ir_gen_container_decl(IrBuilder *irb, Scope *parent_scope, | ... | @@ -5427,7 +5424,7 @@ static IrInstruction *ir_gen_container_decl(IrBuilder *irb, Scope *parent_scope, |
| 5427 | } | 5424 | } |
| 5428 | irb->codegen->resolve_queue.append(&tld_container->base); | 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 | static IrInstruction *ir_gen_fn_proto(IrBuilder *irb, Scope *parent_scope, AstNode *node) { | 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,7 +5994,6 @@ static void eval_const_expr_implicit_cast(CastOp cast_op, |
| 5997 | ConstExprValue *other_val, TypeTableEntry *other_type, | 5994 | ConstExprValue *other_val, TypeTableEntry *other_type, |
| 5998 | ConstExprValue *const_val, TypeTableEntry *new_type) | 5995 | ConstExprValue *const_val, TypeTableEntry *new_type) |
| 5999 | { | 5996 | { |
| 6000 | const_val->depends_on_compile_var = other_val->depends_on_compile_var; | | |
| 6001 | const_val->special = other_val->special; | 5997 | const_val->special = other_val->special; |
| 6002 | | 5998 | |
| 6003 | assert(other_val != const_val); | 5999 | assert(other_val != const_val); |
| ... | @@ -6045,7 +6041,7 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -6045,7 +6041,7 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 6045 | { | 6041 | { |
| 6046 | if (value->value.special != ConstValSpecialRuntime) { | 6042 | if (value->value.special != ConstValSpecialRuntime) { |
| 6047 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, | 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 | eval_const_expr_implicit_cast(cast_op, &value->value, value->value.type, | 6045 | eval_const_expr_implicit_cast(cast_op, &value->value, value->value.type, |
| 6050 | &result->value, wanted_type); | 6046 | &result->value, wanted_type); |
| 6051 | return result; | 6047 | return result; |
| ... | @@ -6179,9 +6175,7 @@ static TypeTableEntry *ir_finish_anal(IrAnalyze *ira, TypeTableEntry *result_typ | ... | @@ -6179,9 +6175,7 @@ static TypeTableEntry *ir_finish_anal(IrAnalyze *ira, TypeTableEntry *result_typ |
| 6179 | return result_type; | 6175 | return result_type; |
| 6180 | } | 6176 | } |
| 6181 | | 6177 | |
| 6182 | static ConstExprValue *ir_build_const_from(IrAnalyze *ira, IrInstruction *old_instruction, | 6178 | static ConstExprValue *ir_build_const_from(IrAnalyze *ira, IrInstruction *old_instruction) { |
| 6183 | bool depends_on_compile_var) | | |
| 6184 | { | | |
| 6185 | IrInstruction *new_instruction; | 6179 | IrInstruction *new_instruction; |
| 6186 | if (old_instruction->id == IrInstructionIdVarPtr) { | 6180 | if (old_instruction->id == IrInstructionIdVarPtr) { |
| 6187 | IrInstructionVarPtr *old_var_ptr_instruction = (IrInstructionVarPtr *)old_instruction; | 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,17 +6199,16 @@ static ConstExprValue *ir_build_const_from(IrAnalyze *ira, IrInstruction *old_in |
| 6205 | ir_link_new_instruction(new_instruction, old_instruction); | 6199 | ir_link_new_instruction(new_instruction, old_instruction); |
| 6206 | ConstExprValue *const_val = &new_instruction->value; | 6200 | ConstExprValue *const_val = &new_instruction->value; |
| 6207 | const_val->special = ConstValSpecialStatic; | 6201 | const_val->special = ConstValSpecialStatic; |
| 6208 | const_val->depends_on_compile_var = depends_on_compile_var; | | |
| 6209 | return const_val; | 6202 | return const_val; |
| 6210 | } | 6203 | } |
| 6211 | | 6204 | |
| 6212 | static TypeTableEntry *ir_analyze_void(IrAnalyze *ira, IrInstruction *instruction) { | 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 | return ira->codegen->builtin_types.entry_void; | 6207 | return ira->codegen->builtin_types.entry_void; |
| 6215 | } | 6208 | } |
| 6216 | | 6209 | |
| 6217 | static TypeTableEntry *ir_analyze_const_ptr(IrAnalyze *ira, IrInstruction *instruction, | 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 | ConstPtrSpecial special, bool ptr_is_const, bool ptr_is_volatile) | 6212 | ConstPtrSpecial special, bool ptr_is_const, bool ptr_is_volatile) |
| 6220 | { | 6213 | { |
| 6221 | if (pointee_type->id == TypeTableEntryIdMetaType) { | 6214 | if (pointee_type->id == TypeTableEntryIdMetaType) { |
| ... | @@ -6225,8 +6218,7 @@ static TypeTableEntry *ir_analyze_const_ptr(IrAnalyze *ira, IrInstruction *instr | ... | @@ -6225,8 +6218,7 @@ static TypeTableEntry *ir_analyze_const_ptr(IrAnalyze *ira, IrInstruction *instr |
| 6225 | return ira->codegen->builtin_types.entry_invalid; | 6218 | return ira->codegen->builtin_types.entry_invalid; |
| 6226 | } | 6219 | } |
| 6227 | | 6220 | |
| 6228 | ConstExprValue *const_val = ir_build_const_from(ira, instruction, | 6221 | ConstExprValue *const_val = ir_build_const_from(ira, instruction); |
| 6229 | depends_on_compile_var || pointee->depends_on_compile_var); | | |
| 6230 | type_ensure_zero_bits_known(ira->codegen, type_entry); | 6222 | type_ensure_zero_bits_known(ira->codegen, type_entry); |
| 6231 | const_val->data.x_type = get_pointer_to_type_volatile(ira->codegen, type_entry, | 6223 | const_val->data.x_type = get_pointer_to_type_volatile(ira->codegen, type_entry, |
| 6232 | ptr_is_const, ptr_is_volatile); | 6224 | ptr_is_const, ptr_is_volatile); |
| ... | @@ -6234,8 +6226,7 @@ static TypeTableEntry *ir_analyze_const_ptr(IrAnalyze *ira, IrInstruction *instr | ... | @@ -6234,8 +6226,7 @@ static TypeTableEntry *ir_analyze_const_ptr(IrAnalyze *ira, IrInstruction *instr |
| 6234 | } else { | 6226 | } else { |
| 6235 | TypeTableEntry *ptr_type = get_pointer_to_type_volatile(ira->codegen, pointee_type, | 6227 | TypeTableEntry *ptr_type = get_pointer_to_type_volatile(ira->codegen, pointee_type, |
| 6236 | ptr_is_const, ptr_is_volatile); | 6228 | ptr_is_const, ptr_is_volatile); |
| 6237 | ConstExprValue *const_val = ir_build_const_from(ira, instruction, | 6229 | ConstExprValue *const_val = ir_build_const_from(ira, instruction); |
| 6238 | depends_on_compile_var || pointee->depends_on_compile_var); | | |
| 6239 | const_val->data.x_ptr.base_ptr = pointee; | 6230 | const_val->data.x_ptr.base_ptr = pointee; |
| 6240 | const_val->data.x_ptr.index = SIZE_MAX; | 6231 | const_val->data.x_ptr.index = SIZE_MAX; |
| 6241 | const_val->data.x_ptr.special = special; | 6232 | const_val->data.x_ptr.special = special; |
| ... | @@ -6243,10 +6234,8 @@ static TypeTableEntry *ir_analyze_const_ptr(IrAnalyze *ira, IrInstruction *instr | ... | @@ -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, | 6237 | static TypeTableEntry *ir_analyze_const_usize(IrAnalyze *ira, IrInstruction *instruction, uint64_t value) { |
| 6247 | bool depends_on_compile_var) | 6238 | ConstExprValue *const_val = ir_build_const_from(ira, instruction); |
| 6248 | { | | |
| 6249 | ConstExprValue *const_val = ir_build_const_from(ira, instruction, depends_on_compile_var); | | |
| 6250 | bignum_init_unsigned(&const_val->data.x_bignum, value); | 6239 | bignum_init_unsigned(&const_val->data.x_bignum, value); |
| 6251 | return ira->codegen->builtin_types.entry_usize; | 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,7 +6365,6 @@ static IrInstruction *ir_analyze_maybe_wrap(IrAnalyze *ira, IrInstruction *sourc |
| 6376 | source_instr->scope, source_instr->source_node); | 6365 | source_instr->scope, source_instr->source_node); |
| 6377 | const_instruction->base.value.type = wanted_type; | 6366 | const_instruction->base.value.type = wanted_type; |
| 6378 | const_instruction->base.value.special = ConstValSpecialStatic; | 6367 | const_instruction->base.value.special = ConstValSpecialStatic; |
| 6379 | const_instruction->base.value.depends_on_compile_var = val->depends_on_compile_var; | | |
| 6380 | const_instruction->base.value.data.x_maybe = val; | 6368 | const_instruction->base.value.data.x_maybe = val; |
| 6381 | return &const_instruction->base; | 6369 | return &const_instruction->base; |
| 6382 | } | 6370 | } |
| ... | @@ -6435,7 +6423,6 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction | ... | @@ -6435,7 +6423,6 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction |
| 6435 | source_instr->scope, source_instr->source_node); | 6423 | source_instr->scope, source_instr->source_node); |
| 6436 | const_instruction->base.value.type = wanted_type; | 6424 | const_instruction->base.value.type = wanted_type; |
| 6437 | const_instruction->base.value.special = ConstValSpecialStatic; | 6425 | const_instruction->base.value.special = ConstValSpecialStatic; |
| 6438 | const_instruction->base.value.depends_on_compile_var = val->depends_on_compile_var; | | |
| 6439 | const_instruction->base.value.data.x_err_union.err = nullptr; | 6426 | const_instruction->base.value.data.x_err_union.err = nullptr; |
| 6440 | const_instruction->base.value.data.x_err_union.payload = val; | 6427 | const_instruction->base.value.data.x_err_union.payload = val; |
| 6441 | return &const_instruction->base; | 6428 | return &const_instruction->base; |
| ... | @@ -6460,7 +6447,6 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so | ... | @@ -6460,7 +6447,6 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so |
| 6460 | source_instr->scope, source_instr->source_node); | 6447 | source_instr->scope, source_instr->source_node); |
| 6461 | const_instruction->base.value.type = wanted_type; | 6448 | const_instruction->base.value.type = wanted_type; |
| 6462 | const_instruction->base.value.special = ConstValSpecialStatic; | 6449 | const_instruction->base.value.special = ConstValSpecialStatic; |
| 6463 | const_instruction->base.value.depends_on_compile_var = val->depends_on_compile_var; | | |
| 6464 | const_instruction->base.value.data.x_err_union.err = val->data.x_pure_err; | 6450 | const_instruction->base.value.data.x_err_union.err = val->data.x_pure_err; |
| 6465 | const_instruction->base.value.data.x_err_union.payload = nullptr; | 6451 | const_instruction->base.value.data.x_err_union.payload = nullptr; |
| 6466 | return &const_instruction->base; | 6452 | return &const_instruction->base; |
| ... | @@ -6485,7 +6471,6 @@ static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -6485,7 +6471,6 @@ static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_ |
| 6485 | source_instr->scope, source_instr->source_node); | 6471 | source_instr->scope, source_instr->source_node); |
| 6486 | const_instruction->base.value.type = wanted_type; | 6472 | const_instruction->base.value.type = wanted_type; |
| 6487 | const_instruction->base.value.special = ConstValSpecialStatic; | 6473 | const_instruction->base.value.special = ConstValSpecialStatic; |
| 6488 | const_instruction->base.value.depends_on_compile_var = val->depends_on_compile_var; | | |
| 6489 | const_instruction->base.value.data.x_ptr.base_ptr = val; | 6474 | const_instruction->base.value.data.x_ptr.base_ptr = val; |
| 6490 | const_instruction->base.value.data.x_ptr.index = SIZE_MAX; | 6475 | const_instruction->base.value.data.x_ptr.index = SIZE_MAX; |
| 6491 | return &const_instruction->base; | 6476 | return &const_instruction->base; |
| ... | @@ -6519,7 +6504,6 @@ static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *so | ... | @@ -6519,7 +6504,6 @@ static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *so |
| 6519 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, source_instr->scope, source_instr->source_node); | 6504 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| 6520 | const_instruction->base.value.type = wanted_type; | 6505 | const_instruction->base.value.type = wanted_type; |
| 6521 | const_instruction->base.value.special = ConstValSpecialStatic; | 6506 | const_instruction->base.value.special = ConstValSpecialStatic; |
| 6522 | const_instruction->base.value.depends_on_compile_var = val->depends_on_compile_var; | | |
| 6523 | const_instruction->base.value.data.x_maybe = nullptr; | 6507 | const_instruction->base.value.data.x_maybe = nullptr; |
| 6524 | return &const_instruction->base; | 6508 | return &const_instruction->base; |
| 6525 | } | 6509 | } |
| ... | @@ -6534,17 +6518,17 @@ static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *s | ... | @@ -6534,17 +6518,17 @@ static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *s |
| 6534 | | 6518 | |
| 6535 | if (instr_is_comptime(array)) { | 6519 | if (instr_is_comptime(array)) { |
| 6536 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, | 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 | init_const_slice(ira->codegen, &result->value, &array->value, 0, array_type->data.array.len, true); | 6522 | init_const_slice(ira->codegen, &result->value, &array->value, 0, array_type->data.array.len, true); |
| 6539 | return result; | 6523 | return result; |
| 6540 | } | 6524 | } |
| 6541 | | 6525 | |
| 6542 | IrInstruction *start = ir_create_const(&ira->new_irb, source_instr->scope, | 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 | init_const_usize(ira->codegen, &start->value, 0); | 6528 | init_const_usize(ira->codegen, &start->value, 0); |
| 6545 | | 6529 | |
| 6546 | IrInstruction *end = ir_create_const(&ira->new_irb, source_instr->scope, | 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 | init_const_usize(ira->codegen, &end->value, array_type->data.array.len); | 6532 | init_const_usize(ira->codegen, &end->value, array_type->data.array.len); |
| 6549 | | 6533 | |
| 6550 | bool is_const; | 6534 | bool is_const; |
| ... | @@ -6573,7 +6557,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour | ... | @@ -6573,7 +6557,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour |
| 6573 | if (!val) | 6557 | if (!val) |
| 6574 | return ira->codegen->invalid_instruction; | 6558 | return ira->codegen->invalid_instruction; |
| 6575 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, | 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 | init_const_unsigned_negative(&result->value, wanted_type, val->data.x_enum.tag, false); | 6561 | init_const_unsigned_negative(&result->value, wanted_type, val->data.x_enum.tag, false); |
| 6578 | return result; | 6562 | return result; |
| 6579 | } | 6563 | } |
| ... | @@ -6588,7 +6572,7 @@ static IrInstruction *ir_analyze_undefined_to_anything(IrAnalyze *ira, IrInstruc | ... | @@ -6588,7 +6572,7 @@ static IrInstruction *ir_analyze_undefined_to_anything(IrAnalyze *ira, IrInstruc |
| 6588 | IrInstruction *target, TypeTableEntry *wanted_type) | 6572 | IrInstruction *target, TypeTableEntry *wanted_type) |
| 6589 | { | 6573 | { |
| 6590 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, | 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 | init_const_undefined(ira->codegen, &result->value); | 6576 | init_const_undefined(ira->codegen, &result->value); |
| 6593 | return result; | 6577 | return result; |
| 6594 | } | 6578 | } |
| ... | @@ -6603,7 +6587,7 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction | ... | @@ -6603,7 +6587,7 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction |
| 6603 | if (!val) | 6587 | if (!val) |
| 6604 | return ira->codegen->invalid_instruction; | 6588 | return ira->codegen->invalid_instruction; |
| 6605 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, | 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 | result->value = *val; | 6591 | result->value = *val; |
| 6608 | result->value.type = wanted_type; | 6592 | result->value.type = wanted_type; |
| 6609 | return result; | 6593 | return result; |
| ... | @@ -6626,7 +6610,7 @@ static IrInstruction *ir_analyze_ptr_to_int(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -6626,7 +6610,7 @@ static IrInstruction *ir_analyze_ptr_to_int(IrAnalyze *ira, IrInstruction *sourc |
| 6626 | return ira->codegen->invalid_instruction; | 6610 | return ira->codegen->invalid_instruction; |
| 6627 | if (val->data.x_ptr.special == ConstPtrSpecialRuntime) { | 6611 | if (val->data.x_ptr.special == ConstPtrSpecialRuntime) { |
| 6628 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, | 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 | bignum_init_unsigned(&result->value.data.x_bignum, val->data.x_ptr.index); | 6614 | bignum_init_unsigned(&result->value.data.x_bignum, val->data.x_ptr.index); |
| 6631 | return result; | 6615 | return result; |
| 6632 | } | 6616 | } |
| ... | @@ -6648,7 +6632,7 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -6648,7 +6632,7 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc |
| 6648 | if (!val) | 6632 | if (!val) |
| 6649 | return ira->codegen->invalid_instruction; | 6633 | return ira->codegen->invalid_instruction; |
| 6650 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, | 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 | result->value.data.x_ptr.base_ptr = nullptr; | 6636 | result->value.data.x_ptr.base_ptr = nullptr; |
| 6653 | result->value.data.x_ptr.index = bignum_to_twos_complement(&val->data.x_bignum); | 6637 | result->value.data.x_ptr.index = bignum_to_twos_complement(&val->data.x_bignum); |
| 6654 | result->value.data.x_ptr.special = ConstPtrSpecialRuntime; | 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,7 +6659,7 @@ static IrInstruction *ir_analyze_int_lit_to_ptr(IrAnalyze *ira, IrInstruction *s |
| 6675 | return ira->codegen->invalid_instruction; | 6659 | return ira->codegen->invalid_instruction; |
| 6676 | | 6660 | |
| 6677 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, | 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 | result->value.data.x_ptr.base_ptr = nullptr; | 6663 | result->value.data.x_ptr.base_ptr = nullptr; |
| 6680 | result->value.data.x_ptr.index = bignum_to_twos_complement(&val->data.x_bignum); | 6664 | result->value.data.x_ptr.index = bignum_to_twos_complement(&val->data.x_bignum); |
| 6681 | result->value.data.x_ptr.special = ConstPtrSpecialRuntime; | 6665 | result->value.data.x_ptr.special = ConstPtrSpecialRuntime; |
| ... | @@ -6692,7 +6676,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour | ... | @@ -6692,7 +6676,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour |
| 6692 | if (!val) | 6676 | if (!val) |
| 6693 | return ira->codegen->invalid_instruction; | 6677 | return ira->codegen->invalid_instruction; |
| 6694 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, | 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 | result->value.data.x_enum.tag = val->data.x_bignum.data.x_uint; | 6680 | result->value.data.x_enum.tag = val->data.x_bignum.data.x_uint; |
| 6697 | return result; | 6681 | return result; |
| 6698 | } | 6682 | } |
| ... | @@ -6711,7 +6695,7 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction | ... | @@ -6711,7 +6695,7 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction |
| 6711 | return ira->codegen->invalid_instruction; | 6695 | return ira->codegen->invalid_instruction; |
| 6712 | | 6696 | |
| 6713 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, | 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 | bignum_init_bignum(&result->value.data.x_bignum, &val->data.x_bignum); | 6699 | bignum_init_bignum(&result->value.data.x_bignum, &val->data.x_bignum); |
| 6716 | return result; | 6700 | return result; |
| 6717 | } | 6701 | } |
| ... | @@ -7026,10 +7010,8 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc | ... | @@ -7026,10 +7010,8 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc |
| 7026 | ConstExprValue *pointee = const_ptr_pointee(&ptr->value); | 7010 | ConstExprValue *pointee = const_ptr_pointee(&ptr->value); |
| 7027 | if (pointee->special != ConstValSpecialRuntime) { | 7011 | if (pointee->special != ConstValSpecialRuntime) { |
| 7028 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instruction->scope, | 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 | result->value = *pointee; | 7014 | result->value = *pointee; |
| 7031 | result->value.depends_on_compile_var = pointee->depends_on_compile_var || | | |
| 7032 | ptr->value.depends_on_compile_var; | | |
| 7033 | return result; | 7015 | return result; |
| 7034 | } | 7016 | } |
| 7035 | } | 7017 | } |
| ... | @@ -7046,7 +7028,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc | ... | @@ -7046,7 +7028,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc |
| 7046 | if (ptr_type->id == TypeTableEntryIdPointer) { | 7028 | if (ptr_type->id == TypeTableEntryIdPointer) { |
| 7047 | TypeTableEntry *child_type = ptr_type->data.pointer.child_type; | 7029 | TypeTableEntry *child_type = ptr_type->data.pointer.child_type; |
| 7048 | return ir_create_const_type(&ira->new_irb, source_instruction->scope, | 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 | } else { | 7032 | } else { |
| 7051 | ir_add_error(ira, source_instruction, | 7033 | ir_add_error(ira, source_instruction, |
| 7052 | buf_sprintf("attempt to dereference non pointer type '%s'", buf_ptr(&ptr_type->name))); | 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,7 +7053,7 @@ static TypeTableEntry *ir_analyze_ref(IrAnalyze *ira, IrInstruction *source_inst |
| 7071 | if (!val) | 7053 | if (!val) |
| 7072 | return ira->codegen->builtin_types.entry_invalid; | 7054 | return ira->codegen->builtin_types.entry_invalid; |
| 7073 | return ir_analyze_const_ptr(ira, source_instruction, val, value->value.type, | 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 | TypeTableEntry *ptr_type = get_pointer_to_type_volatile(ira->codegen, value->value.type, is_const, is_volatile); | 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,8 +7169,7 @@ static TypeTableEntry *ir_analyze_instruction_return(IrAnalyze *ira, |
| 7187 | } | 7169 | } |
| 7188 | | 7170 | |
| 7189 | static TypeTableEntry *ir_analyze_instruction_const(IrAnalyze *ira, IrInstructionConst *const_instruction) { | 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; | 7172 | ConstExprValue *out_val = ir_build_const_from(ira, &const_instruction->base); |
| 7191 | ConstExprValue *out_val = ir_build_const_from(ira, &const_instruction->base, depends_on_compile_var); | | |
| 7192 | *out_val = const_instruction->base.value; | 7173 | *out_val = const_instruction->base.value; |
| 7193 | return const_instruction->base.value.type; | 7174 | return const_instruction->base.value.type; |
| 7194 | } | 7175 | } |
| ... | @@ -7215,8 +7196,7 @@ static TypeTableEntry *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -7215,8 +7196,7 @@ static TypeTableEntry *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp |
| 7215 | ConstExprValue *op1_val = &casted_op1->value; | 7196 | ConstExprValue *op1_val = &casted_op1->value; |
| 7216 | ConstExprValue *op2_val = &casted_op2->value; | 7197 | ConstExprValue *op2_val = &casted_op2->value; |
| 7217 | if (op1_val->special != ConstValSpecialRuntime && op2_val->special != ConstValSpecialRuntime) { | 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; | 7199 | ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base); |
| 7219 | ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base, depends_on_compile_var); | | |
| 7220 | | 7200 | |
| 7221 | assert(casted_op1->value.type->id == TypeTableEntryIdBool); | 7201 | assert(casted_op1->value.type->id == TypeTableEntryIdBool); |
| 7222 | assert(casted_op2->value.type->id == TypeTableEntryIdBool); | 7202 | assert(casted_op2->value.type->id == TypeTableEntryIdBool); |
| ... | @@ -7246,9 +7226,8 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -7246,9 +7226,8 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp |
| 7246 | (op2->value.type->id == TypeTableEntryIdNullLit && op1->value.type->id == TypeTableEntryIdMaybe) || | 7226 | (op2->value.type->id == TypeTableEntryIdNullLit && op1->value.type->id == TypeTableEntryIdMaybe) || |
| 7247 | (op1->value.type->id == TypeTableEntryIdNullLit && op2->value.type->id == TypeTableEntryIdNullLit))) | 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 | if (op1->value.type->id == TypeTableEntryIdNullLit && op2->value.type->id == TypeTableEntryIdNullLit) { | 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 | out_val->data.x_bool = (op_id == IrBinOpCmpEq); | 7231 | out_val->data.x_bool = (op_id == IrBinOpCmpEq); |
| 7253 | return ira->codegen->builtin_types.entry_bool; | 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,7 +7244,7 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp |
| 7265 | if (!maybe_val) | 7244 | if (!maybe_val) |
| 7266 | return ira->codegen->builtin_types.entry_invalid; | 7245 | return ira->codegen->builtin_types.entry_invalid; |
| 7267 | bool is_null = (maybe_val->data.x_maybe == nullptr); | 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 | out_val->data.x_bool = (op_id == IrBinOpCmpEq) ? is_null : !is_null; | 7248 | out_val->data.x_bool = (op_id == IrBinOpCmpEq) ? is_null : !is_null; |
| 7270 | return ira->codegen->builtin_types.entry_bool; | 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,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; | 7371 | ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base); |
| 7393 | ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base, depends_on_compile_var); | | |
| 7394 | out_val->data.x_bool = answer; | 7372 | out_val->data.x_bool = answer; |
| 7395 | return ira->codegen->builtin_types.entry_bool; | 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,7 +7441,6 @@ static int ir_eval_bignum(ConstExprValue *op1_val, ConstExprValue *op2_val, |
| 7463 | } | 7441 | } |
| 7464 | | 7442 | |
| 7465 | out_val->special = ConstValSpecialStatic; | 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 | return 0; | 7444 | return 0; |
| 7468 | } | 7445 | } |
| 7469 | | 7446 | |
| ... | @@ -7682,8 +7659,7 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -7682,8 +7659,7 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp * |
| 7682 | return ira->codegen->builtin_types.entry_invalid; | 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; | 7662 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 7686 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); | | |
| 7687 | | 7663 | |
| 7688 | TypeTableEntry *result_type; | 7664 | TypeTableEntry *result_type; |
| 7689 | ConstExprValue *out_array_val; | 7665 | ConstExprValue *out_array_val; |
| ... | @@ -7757,8 +7733,7 @@ static TypeTableEntry *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -7757,8 +7733,7 @@ static TypeTableEntry *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp |
| 7757 | return ira->codegen->builtin_types.entry_invalid; | 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; | 7736 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 7761 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); | | |
| 7762 | | 7737 | |
| 7763 | uint64_t new_array_len = array_len.data.x_uint; | 7738 | uint64_t new_array_len = array_len.data.x_uint; |
| 7764 | out_val->data.x_array.size = new_array_len; | 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,7 +7888,7 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc |
| 7913 | *mem_slot = casted_init_value->value; | 7888 | *mem_slot = casted_init_value->value; |
| 7914 | | 7889 | |
| 7915 | if (is_comptime) { | 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 | return ira->codegen->builtin_types.entry_void; | 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,7 +7929,6 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node |
| 7954 | Buf *param_name = param_decl_node->data.param_decl.name; | 7929 | Buf *param_name = param_decl_node->data.param_decl.name; |
| 7955 | VariableTableEntry *var = add_variable(ira->codegen, param_decl_node, | 7930 | VariableTableEntry *var = add_variable(ira->codegen, param_decl_node, |
| 7956 | *exec_scope, param_name, true, arg_val); | 7931 | *exec_scope, param_name, true, arg_val); |
| 7957 | var->value.depends_on_compile_var = true; | | |
| 7958 | *exec_scope = var->child_scope; | 7932 | *exec_scope = var->child_scope; |
| 7959 | *next_proto_i += 1; | 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,9 +7974,6 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 8000 | arg_val = ir_resolve_const(ira, casted_arg, UndefBad); | 7974 | arg_val = ir_resolve_const(ira, casted_arg, UndefBad); |
| 8001 | if (!arg_val) | 7975 | if (!arg_val) |
| 8002 | return false; | 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 | } else { | 7977 | } else { |
| 8007 | arg_val = create_const_runtime(casted_arg->value.type); | 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,7 +7986,6 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 8015 | if (!is_var_args) { | 7986 | if (!is_var_args) { |
| 8016 | VariableTableEntry *var = add_variable(ira->codegen, param_decl_node, | 7987 | VariableTableEntry *var = add_variable(ira->codegen, param_decl_node, |
| 8017 | *child_scope, param_name, true, arg_val); | 7988 | *child_scope, param_name, true, arg_val); |
| 8018 | var->value.depends_on_compile_var = true; | | |
| 8019 | *child_scope = var->child_scope; | 7989 | *child_scope = var->child_scope; |
| 8020 | var->shadowable = !comptime_arg; | 7990 | var->shadowable = !comptime_arg; |
| 8021 | | 7991 | |
| ... | @@ -8133,8 +8103,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal | ... | @@ -8133,8 +8103,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal |
| 8133 | ira->codegen->memoized_fn_eval_table.put(exec_scope, result); | 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, | 8106 | ConstExprValue *out_val = ir_build_const_from(ira, &call_instruction->base); |
| 8137 | result->value.depends_on_compile_var); | | |
| 8138 | *out_val = result->value; | 8107 | *out_val = result->value; |
| 8139 | return ir_finish_anal(ira, return_type); | 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,7 +8181,6 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal |
| 8212 | first_var_arg, inst_fn_type_id.param_count); | 8181 | first_var_arg, inst_fn_type_id.param_count); |
| 8213 | VariableTableEntry *var = add_variable(ira->codegen, param_decl_node, | 8182 | VariableTableEntry *var = add_variable(ira->codegen, param_decl_node, |
| 8214 | impl_fn->child_scope, param_name, true, var_args_val); | 8183 | impl_fn->child_scope, param_name, true, var_args_val); |
| 8215 | var->value.depends_on_compile_var = true; | | |
| 8216 | impl_fn->child_scope = var->child_scope; | 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,8 +8366,7 @@ static TypeTableEntry *ir_analyze_unary_prefix_op_err(IrAnalyze *ira, IrInstruct |
| 8398 | case TypeTableEntryIdBoundFn: | 8366 | case TypeTableEntryIdBoundFn: |
| 8399 | case TypeTableEntryIdEnumTag: | 8367 | case TypeTableEntryIdEnumTag: |
| 8400 | { | 8368 | { |
| 8401 | ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base, | 8369 | ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base); |
| 8402 | value->value.depends_on_compile_var); | | |
| 8403 | TypeTableEntry *result_type = get_error_type(ira->codegen, meta_type); | 8370 | TypeTableEntry *result_type = get_error_type(ira->codegen, meta_type); |
| 8404 | out_val->data.x_type = result_type; | 8371 | out_val->data.x_type = result_type; |
| 8405 | return ira->codegen->builtin_types.entry_type; | 8372 | return ira->codegen->builtin_types.entry_type; |
| ... | @@ -8443,7 +8410,7 @@ static TypeTableEntry *ir_analyze_dereference(IrAnalyze *ira, IrInstructionUnOp | ... | @@ -8443,7 +8410,7 @@ static TypeTableEntry *ir_analyze_dereference(IrAnalyze *ira, IrInstructionUnOp |
| 8443 | // one of the ptr instructions | 8410 | // one of the ptr instructions |
| 8444 | | 8411 | |
| 8445 | if (value->value.special != ConstValSpecialRuntime) { | 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 | ConstExprValue *pointee = const_ptr_pointee(&value->value); | 8414 | ConstExprValue *pointee = const_ptr_pointee(&value->value); |
| 8448 | *out_val = *pointee; | 8415 | *out_val = *pointee; |
| 8449 | return child_type; | 8416 | return child_type; |
| ... | @@ -8488,8 +8455,7 @@ static TypeTableEntry *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op | ... | @@ -8488,8 +8455,7 @@ static TypeTableEntry *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op |
| 8488 | case TypeTableEntryIdEnumTag: | 8455 | case TypeTableEntryIdEnumTag: |
| 8489 | case TypeTableEntryIdArgTuple: | 8456 | case TypeTableEntryIdArgTuple: |
| 8490 | { | 8457 | { |
| 8491 | ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base, | 8458 | ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base); |
| 8492 | value->value.depends_on_compile_var); | | |
| 8493 | out_val->data.x_type = get_maybe_type(ira->codegen, type_entry); | 8459 | out_val->data.x_type = get_maybe_type(ira->codegen, type_entry); |
| 8494 | return ira->codegen->builtin_types.entry_type; | 8460 | return ira->codegen->builtin_types.entry_type; |
| 8495 | } | 8461 | } |
| ... | @@ -8519,8 +8485,7 @@ static TypeTableEntry *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un | ... | @@ -8519,8 +8485,7 @@ static TypeTableEntry *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un |
| 8519 | if (!target_const_val) | 8485 | if (!target_const_val) |
| 8520 | return ira->codegen->builtin_types.entry_invalid; | 8486 | return ira->codegen->builtin_types.entry_invalid; |
| 8521 | | 8487 | |
| 8522 | bool depends_on_compile_var = value->value.depends_on_compile_var; | 8488 | ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base); |
| 8523 | ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base, depends_on_compile_var); | | |
| 8524 | bignum_negate(&out_val->data.x_bignum, &target_const_val->data.x_bignum); | 8489 | bignum_negate(&out_val->data.x_bignum, &target_const_val->data.x_bignum); |
| 8525 | if (expr_type->id == TypeTableEntryIdFloat || | 8490 | if (expr_type->id == TypeTableEntryIdFloat || |
| 8526 | expr_type->id == TypeTableEntryIdNumLitFloat || | 8491 | expr_type->id == TypeTableEntryIdNumLitFloat || |
| ... | @@ -8561,8 +8526,7 @@ static TypeTableEntry *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *ins | ... | @@ -8561,8 +8526,7 @@ static TypeTableEntry *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *ins |
| 8561 | if (!target_const_val) | 8526 | if (!target_const_val) |
| 8562 | return ira->codegen->builtin_types.entry_invalid; | 8527 | return ira->codegen->builtin_types.entry_invalid; |
| 8563 | | 8528 | |
| 8564 | bool depends_on_compile_var = value->value.depends_on_compile_var; | 8529 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 8565 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); | | |
| 8566 | bignum_not(&out_val->data.x_bignum, &target_const_val->data.x_bignum, | 8530 | bignum_not(&out_val->data.x_bignum, &target_const_val->data.x_bignum, |
| 8567 | expr_type->data.integral.bit_count, expr_type->data.integral.is_signed); | 8531 | expr_type->data.integral.bit_count, expr_type->data.integral.is_signed); |
| 8568 | return expr_type; | 8532 | return expr_type; |
| ... | @@ -8669,9 +8633,8 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP | ... | @@ -8669,9 +8633,8 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP |
| 8669 | return ira->codegen->builtin_types.entry_invalid; | 8633 | return ira->codegen->builtin_types.entry_invalid; |
| 8670 | | 8634 | |
| 8671 | if (value->value.special != ConstValSpecialRuntime) { | 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 | *out_val = value->value; | 8637 | *out_val = value->value; |
| 8674 | out_val->depends_on_compile_var = true; | | |
| 8675 | } else { | 8638 | } else { |
| 8676 | phi_instruction->base.other = value; | 8639 | phi_instruction->base.other = value; |
| 8677 | } | 8640 | } |
| ... | @@ -8705,7 +8668,7 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP | ... | @@ -8705,7 +8668,7 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP |
| 8705 | } | 8668 | } |
| 8706 | | 8669 | |
| 8707 | if (new_incoming_blocks.length == 0) { | 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 | return ira->codegen->builtin_types.entry_void; | 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,7 +8715,7 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP |
| 8752 | } | 8715 | } |
| 8753 | | 8716 | |
| 8754 | static TypeTableEntry *ir_analyze_var_ptr(IrAnalyze *ira, IrInstruction *instruction, | 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 | assert(var->value.type); | 8720 | assert(var->value.type); |
| 8758 | if (var->value.type->id == TypeTableEntryIdInvalid) | 8721 | if (var->value.type->id == TypeTableEntryIdInvalid) |
| ... | @@ -8775,9 +8738,7 @@ static TypeTableEntry *ir_analyze_var_ptr(IrAnalyze *ira, IrInstruction *instruc | ... | @@ -8775,9 +8738,7 @@ static TypeTableEntry *ir_analyze_var_ptr(IrAnalyze *ira, IrInstruction *instruc |
| 8775 | bool is_volatile = (var->value.type->id == TypeTableEntryIdMetaType) ? is_volatile_ptr : false; | 8738 | bool is_volatile = (var->value.type->id == TypeTableEntryIdMetaType) ? is_volatile_ptr : false; |
| 8776 | if (mem_slot && mem_slot->special != ConstValSpecialRuntime) { | 8739 | if (mem_slot && mem_slot->special != ConstValSpecialRuntime) { |
| 8777 | ConstPtrSpecial ptr_special = is_comptime ? ConstPtrSpecialInline : ConstPtrSpecialNone; | 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; | 8741 | return ir_analyze_const_ptr(ira, instruction, mem_slot, var->value.type, ptr_special, is_const, is_volatile); |
| 8779 | return ir_analyze_const_ptr(ira, instruction, mem_slot, var->value.type, | | |
| 8780 | depends_on_compile_var, ptr_special, is_const, is_volatile); | | |
| 8781 | } else { | 8742 | } else { |
| 8782 | ir_build_var_ptr_from(&ira->new_irb, instruction, var, is_const, is_volatile); | 8743 | ir_build_var_ptr_from(&ira->new_irb, instruction, var, is_const, is_volatile); |
| 8783 | type_ensure_zero_bits_known(ira->codegen, var->value.type); | 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,7 +8749,7 @@ static TypeTableEntry *ir_analyze_var_ptr(IrAnalyze *ira, IrInstruction *instruc |
| 8788 | static TypeTableEntry *ir_analyze_instruction_var_ptr(IrAnalyze *ira, IrInstructionVarPtr *var_ptr_instruction) { | 8749 | static TypeTableEntry *ir_analyze_instruction_var_ptr(IrAnalyze *ira, IrInstructionVarPtr *var_ptr_instruction) { |
| 8789 | VariableTableEntry *var = var_ptr_instruction->var; | 8750 | VariableTableEntry *var = var_ptr_instruction->var; |
| 8790 | return ir_analyze_var_ptr(ira, &var_ptr_instruction->base, var, var_ptr_instruction->is_const, | 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 | static VariableTableEntry *get_fn_var_by_index(FnTableEntry *fn_entry, size_t index) { | 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,16 +8819,14 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc |
| 8858 | FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec); | 8819 | FnTableEntry *fn_entry = exec_fn_entry(ira->new_irb.exec); |
| 8859 | assert(fn_entry); | 8820 | assert(fn_entry); |
| 8860 | VariableTableEntry *var = get_fn_var_by_index(fn_entry, abs_index); | 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 | bool is_const = true; | 8822 | bool is_const = true; |
| 8864 | bool is_volatile = false; | 8823 | bool is_volatile = false; |
| 8865 | if (var) { | 8824 | if (var) { |
| 8866 | return ir_analyze_var_ptr(ira, &elem_ptr_instruction->base, var, | 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 | } else { | 8827 | } else { |
| 8869 | return ir_analyze_const_ptr(ira, &elem_ptr_instruction->base, &ira->codegen->const_void_val, | 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 | is_const, is_volatile); | 8830 | is_const, is_volatile); |
| 8872 | } | 8831 | } |
| 8873 | } else { | 8832 | } else { |
| ... | @@ -8901,9 +8860,7 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -8901,9 +8860,7 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc |
| 8901 | array_ptr_val->special != ConstValSpecialRuntime && | 8860 | array_ptr_val->special != ConstValSpecialRuntime && |
| 8902 | (array_type->id != TypeTableEntryIdPointer || array_ptr_val->data.x_ptr.special != ConstPtrSpecialRuntime)) | 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 || | 8863 | ConstExprValue *out_val = ir_build_const_from(ira, &elem_ptr_instruction->base); |
| 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); | | |
| 8907 | if (array_type->id == TypeTableEntryIdPointer) { | 8864 | if (array_type->id == TypeTableEntryIdPointer) { |
| 8908 | size_t offset = array_ptr_val->data.x_ptr.index; | 8865 | size_t offset = array_ptr_val->data.x_ptr.index; |
| 8909 | size_t new_index; | 8866 | size_t new_index; |
| ... | @@ -8974,9 +8931,8 @@ static TypeTableEntry *ir_analyze_container_member_access_inner(IrAnalyze *ira, | ... | @@ -8974,9 +8931,8 @@ static TypeTableEntry *ir_analyze_container_member_access_inner(IrAnalyze *ira, |
| 8974 | return ira->codegen->builtin_types.entry_invalid; | 8931 | return ira->codegen->builtin_types.entry_invalid; |
| 8975 | TldFn *tld_fn = (TldFn *)tld; | 8932 | TldFn *tld_fn = (TldFn *)tld; |
| 8976 | FnTableEntry *fn_entry = tld_fn->fn_entry; | 8933 | FnTableEntry *fn_entry = tld_fn->fn_entry; |
| 8977 | bool depends_on_compile_var = container_ptr->value.depends_on_compile_var; | | |
| 8978 | IrInstruction *bound_fn_value = ir_build_const_bound_fn(&ira->new_irb, field_ptr_instruction->base.scope, | 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 | return ir_analyze_ref(ira, &field_ptr_instruction->base, bound_fn_value, true, false); | 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,11 +8967,8 @@ static TypeTableEntry *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field |
| 9011 | if (value_is_comptime(struct_val)) { | 8967 | if (value_is_comptime(struct_val)) { |
| 9012 | ConstExprValue *field_val = &struct_val->data.x_struct.fields[field->src_index]; | 8968 | ConstExprValue *field_val = &struct_val->data.x_struct.fields[field->src_index]; |
| 9013 | if (value_is_comptime(field_val)) { | 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 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, field_val, | 8970 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, field_val, |
| 9017 | field_val->type, depends_on_compile_var, ConstPtrSpecialNone, | 8971 | field_val->type, ConstPtrSpecialNone, is_const, is_volatile); |
| 9018 | 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,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, | 9001 | static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_instruction, Tld *tld) { |
| 9049 | bool depends_on_compile_var) | | |
| 9050 | { | | |
| 9051 | bool pointer_only = false; | 9002 | bool pointer_only = false; |
| 9052 | resolve_top_level_decl(ira->codegen, tld, pointer_only); | 9003 | resolve_top_level_decl(ira->codegen, tld, pointer_only); |
| 9053 | if (tld->resolution == TldResolutionInvalid) | 9004 | if (tld->resolution == TldResolutionInvalid) |
| ... | @@ -9060,7 +9011,7 @@ static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source | ... | @@ -9060,7 +9011,7 @@ static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source |
| 9060 | { | 9011 | { |
| 9061 | TldVar *tld_var = (TldVar *)tld; | 9012 | TldVar *tld_var = (TldVar *)tld; |
| 9062 | VariableTableEntry *var = tld_var->var; | 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 | case TldIdFn: | 9016 | case TldIdFn: |
| 9066 | { | 9017 | { |
| ... | @@ -9081,7 +9032,7 @@ static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source | ... | @@ -9081,7 +9032,7 @@ static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source |
| 9081 | bool ptr_is_const = true; | 9032 | bool ptr_is_const = true; |
| 9082 | bool ptr_is_volatile = false; | 9033 | bool ptr_is_volatile = false; |
| 9083 | return ir_analyze_const_ptr(ira, source_instruction, const_val, fn_entry->type_entry, | 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 | case TldIdTypeDef: | 9037 | case TldIdTypeDef: |
| 9087 | { | 9038 | { |
| ... | @@ -9098,7 +9049,7 @@ static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source | ... | @@ -9098,7 +9049,7 @@ static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source |
| 9098 | bool ptr_is_const = true; | 9049 | bool ptr_is_const = true; |
| 9099 | bool ptr_is_volatile = false; | 9050 | bool ptr_is_volatile = false; |
| 9100 | return ir_analyze_const_ptr(ira, source_instruction, const_val, ira->codegen->builtin_types.entry_type, | 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 | zig_unreachable(); | 9055 | zig_unreachable(); |
| ... | @@ -9118,7 +9069,6 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru | ... | @@ -9118,7 +9069,6 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru |
| 9118 | zig_unreachable(); | 9069 | zig_unreachable(); |
| 9119 | } | 9070 | } |
| 9120 | | 9071 | |
| 9121 | bool depends_on_compile_var = container_ptr->value.depends_on_compile_var; | | |
| 9122 | Buf *field_name = field_ptr_instruction->field_name; | 9072 | Buf *field_name = field_ptr_instruction->field_name; |
| 9123 | AstNode *source_node = field_ptr_instruction->base.source_node; | 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,7 +9092,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru |
| 9142 | bool ptr_is_const = true; | 9092 | bool ptr_is_const = true; |
| 9143 | bool ptr_is_volatile = false; | 9093 | bool ptr_is_volatile = false; |
| 9144 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, len_val, | 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 | } else { | 9096 | } else { |
| 9147 | ir_add_error_node(ira, source_node, | 9097 | ir_add_error_node(ira, source_node, |
| 9148 | buf_sprintf("no member named '%s' in '%s'", buf_ptr(field_name), | 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,7 +9116,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru |
| 9166 | bool ptr_is_const = true; | 9116 | bool ptr_is_const = true; |
| 9167 | bool ptr_is_volatile = false; | 9117 | bool ptr_is_volatile = false; |
| 9168 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, len_val, | 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 | } else { | 9120 | } else { |
| 9171 | ir_add_error_node(ira, source_node, | 9121 | ir_add_error_node(ira, source_node, |
| 9172 | buf_sprintf("no member named '%s' in '%s'", buf_ptr(field_name), | 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,14 +9154,14 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru |
| 9204 | bool ptr_is_const = true; | 9154 | bool ptr_is_const = true; |
| 9205 | bool ptr_is_volatile = false; | 9155 | bool ptr_is_volatile = false; |
| 9206 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, | 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 | ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile); | 9158 | ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile); |
| 9209 | } else { | 9159 | } else { |
| 9210 | bool ptr_is_const = true; | 9160 | bool ptr_is_const = true; |
| 9211 | bool ptr_is_volatile = false; | 9161 | bool ptr_is_volatile = false; |
| 9212 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, | 9162 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, |
| 9213 | create_const_unsigned_negative(child_type->data.enumeration.tag_type, field->value, false), | 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 | ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile); | 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,7 +9170,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru |
| 9220 | auto entry = container_scope->decl_table.maybe_get(field_name); | 9170 | auto entry = container_scope->decl_table.maybe_get(field_name); |
| 9221 | Tld *tld = entry ? entry->value : nullptr; | 9171 | Tld *tld = entry ? entry->value : nullptr; |
| 9222 | if (tld) { | 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 | ir_add_error(ira, &field_ptr_instruction->base, | 9175 | ir_add_error(ira, &field_ptr_instruction->base, |
| 9226 | buf_sprintf("container '%s' has no member called '%s'", | 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,7 +9187,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru |
| 9237 | bool ptr_is_const = true; | 9187 | bool ptr_is_const = true; |
| 9238 | bool ptr_is_volatile = false; | 9188 | bool ptr_is_volatile = false; |
| 9239 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, const_val, | 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 | ir_add_error(ira, &field_ptr_instruction->base, | 9193 | ir_add_error(ira, &field_ptr_instruction->base, |
| ... | @@ -9250,14 +9200,14 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru | ... | @@ -9250,14 +9200,14 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru |
| 9250 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, | 9200 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, |
| 9251 | create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int, | 9201 | create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int, |
| 9252 | child_type->data.integral.bit_count, false), | 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 | ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile); | 9204 | ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile); |
| 9255 | } else if (buf_eql_str(field_name, "is_signed")) { | 9205 | } else if (buf_eql_str(field_name, "is_signed")) { |
| 9256 | bool ptr_is_const = true; | 9206 | bool ptr_is_const = true; |
| 9257 | bool ptr_is_volatile = false; | 9207 | bool ptr_is_volatile = false; |
| 9258 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, | 9208 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, |
| 9259 | create_const_bool(ira->codegen, child_type->data.integral.is_signed), | 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 | ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile); | 9211 | ConstPtrSpecialNone, ptr_is_const, ptr_is_volatile); |
| 9262 | } else { | 9212 | } else { |
| 9263 | ir_add_error(ira, &field_ptr_instruction->base, | 9213 | ir_add_error(ira, &field_ptr_instruction->base, |
| ... | @@ -9303,7 +9253,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru | ... | @@ -9303,7 +9253,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru |
| 9303 | add_error_note(ira->codegen, msg, tld->source_node, buf_sprintf("declared here")); | 9253 | add_error_note(ira->codegen, msg, tld->source_node, buf_sprintf("declared here")); |
| 9304 | return ira->codegen->builtin_types.entry_invalid; | 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 | } else { | 9257 | } else { |
| 9308 | const char *import_name = namespace_import->path ? buf_ptr(namespace_import->path) : "(C import)"; | 9258 | const char *import_name = namespace_import->path ? buf_ptr(namespace_import->path) : "(C import)"; |
| 9309 | ir_add_error_node(ira, source_node, | 9259 | ir_add_error_node(ira, source_node, |
| ... | @@ -9401,10 +9351,7 @@ static TypeTableEntry *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructi | ... | @@ -9401,10 +9351,7 @@ static TypeTableEntry *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructi |
| 9401 | case TypeTableEntryIdEnumTag: | 9351 | case TypeTableEntryIdEnumTag: |
| 9402 | case TypeTableEntryIdArgTuple: | 9352 | case TypeTableEntryIdArgTuple: |
| 9403 | { | 9353 | { |
| 9404 | ConstExprValue *out_val = ir_build_const_from(ira, &typeof_instruction->base, true); | 9354 | ConstExprValue *out_val = ir_build_const_from(ira, &typeof_instruction->base); |
| 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 | | |
| 9408 | out_val->data.x_type = type_entry; | 9355 | out_val->data.x_type = type_entry; |
| 9409 | | 9356 | |
| 9410 | return ira->codegen->builtin_types.entry_type; | 9357 | return ira->codegen->builtin_types.entry_type; |
| ... | @@ -9438,8 +9385,7 @@ static TypeTableEntry *ir_analyze_instruction_to_ptr_type(IrAnalyze *ira, | ... | @@ -9438,8 +9385,7 @@ static TypeTableEntry *ir_analyze_instruction_to_ptr_type(IrAnalyze *ira, |
| 9438 | return ira->codegen->builtin_types.entry_invalid; | 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, | 9388 | ConstExprValue *out_val = ir_build_const_from(ira, &to_ptr_type_instruction->base); |
| 9442 | value->value.depends_on_compile_var); | | |
| 9443 | out_val->data.x_type = ptr_type; | 9389 | out_val->data.x_type = ptr_type; |
| 9444 | return ira->codegen->builtin_types.entry_type; | 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,8 +9405,7 @@ static TypeTableEntry *ir_analyze_instruction_ptr_type_child(IrAnalyze *ira, |
| 9459 | return ira->codegen->builtin_types.entry_invalid; | 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, | 9408 | ConstExprValue *out_val = ir_build_const_from(ira, &ptr_type_child_instruction->base); |
| 9463 | type_value->value.depends_on_compile_var); | | |
| 9464 | out_val->data.x_type = type_entry->data.pointer.child_type; | 9409 | out_val->data.x_type = type_entry->data.pointer.child_type; |
| 9465 | return ira->codegen->builtin_types.entry_type; | 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,7 +9424,7 @@ static TypeTableEntry *ir_analyze_instruction_set_fn_test(IrAnalyze *ira, |
| 9479 | ira->codegen->test_fn_count += 1; | 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 | return ira->codegen->builtin_types.entry_void; | 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,7 +9460,7 @@ static TypeTableEntry *ir_analyze_instruction_set_fn_visible(IrAnalyze *ira, |
| 9515 | } | 9460 | } |
| 9516 | fn_entry->internal_linkage = !want_export; | 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 | return ira->codegen->builtin_types.entry_void; | 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,7 +9509,7 @@ static TypeTableEntry *ir_analyze_instruction_set_global_align(IrAnalyze *ira, |
| 9564 | *set_global_align_node = source_node; | 9509 | *set_global_align_node = source_node; |
| 9565 | *alignment_ptr = scalar_align; | 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 | return ira->codegen->builtin_types.entry_void; | 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,7 +9548,7 @@ static TypeTableEntry *ir_analyze_instruction_set_global_section(IrAnalyze *ira, |
| 9603 | *set_global_section_node = source_node; | 9548 | *set_global_section_node = source_node; |
| 9604 | *section_name_ptr = section_name; | 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 | return ira->codegen->builtin_types.entry_void; | 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,7 +9565,7 @@ static TypeTableEntry *ir_analyze_instruction_set_debug_safety(IrAnalyze *ira, |
| 9620 | | 9565 | |
| 9621 | if (ira->new_irb.exec->is_inline) { | 9566 | if (ira->new_irb.exec->is_inline) { |
| 9622 | // ignore setDebugSafety when running functions at compile time | 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 | return ira->codegen->builtin_types.entry_void; | 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,7 +9617,7 @@ static TypeTableEntry *ir_analyze_instruction_set_debug_safety(IrAnalyze *ira, |
| 9672 | *safety_set_node_ptr = source_node; | 9617 | *safety_set_node_ptr = source_node; |
| 9673 | *safety_off_ptr = !want_debug_safety; | 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 | return ira->codegen->builtin_types.entry_void; | 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,8 +9668,7 @@ static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira, |
| 9723 | { | 9668 | { |
| 9724 | type_ensure_zero_bits_known(ira->codegen, resolved_child_type); | 9669 | type_ensure_zero_bits_known(ira->codegen, resolved_child_type); |
| 9725 | TypeTableEntry *result_type = get_slice_type(ira->codegen, resolved_child_type, is_const); | 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, | 9671 | ConstExprValue *out_val = ir_build_const_from(ira, &slice_type_instruction->base); |
| 9727 | child_type->value.depends_on_compile_var); | | |
| 9728 | out_val->data.x_type = result_type; | 9672 | out_val->data.x_type = result_type; |
| 9729 | return ira->codegen->builtin_types.entry_type; | 9673 | return ira->codegen->builtin_types.entry_type; |
| 9730 | } | 9674 | } |
| ... | @@ -9814,10 +9758,7 @@ static TypeTableEntry *ir_analyze_instruction_array_type(IrAnalyze *ira, | ... | @@ -9814,10 +9758,7 @@ static TypeTableEntry *ir_analyze_instruction_array_type(IrAnalyze *ira, |
| 9814 | case TypeTableEntryIdEnumTag: | 9758 | case TypeTableEntryIdEnumTag: |
| 9815 | { | 9759 | { |
| 9816 | TypeTableEntry *result_type = get_array_type(ira->codegen, child_type, size); | 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 || | 9761 | ConstExprValue *out_val = ir_build_const_from(ira, &array_type_instruction->base); |
| 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); | | |
| 9821 | out_val->data.x_type = result_type; | 9762 | out_val->data.x_type = result_type; |
| 9822 | return ira->codegen->builtin_types.entry_type; | 9763 | return ira->codegen->builtin_types.entry_type; |
| 9823 | } | 9764 | } |
| ... | @@ -9833,7 +9774,7 @@ static TypeTableEntry *ir_analyze_instruction_compile_var(IrAnalyze *ira, | ... | @@ -9833,7 +9774,7 @@ static TypeTableEntry *ir_analyze_instruction_compile_var(IrAnalyze *ira, |
| 9833 | if (!var_name) | 9774 | if (!var_name) |
| 9834 | return ira->codegen->builtin_types.entry_invalid; | 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 | if (buf_eql_str(var_name, "is_big_endian")) { | 9778 | if (buf_eql_str(var_name, "is_big_endian")) { |
| 9838 | out_val->data.x_bool = ira->codegen->is_big_endian; | 9779 | out_val->data.x_bool = ira->codegen->is_big_endian; |
| 9839 | return ira->codegen->builtin_types.entry_bool; | 9780 | return ira->codegen->builtin_types.entry_bool; |
| ... | @@ -9905,8 +9846,7 @@ static TypeTableEntry *ir_analyze_instruction_size_of(IrAnalyze *ira, | ... | @@ -9905,8 +9846,7 @@ static TypeTableEntry *ir_analyze_instruction_size_of(IrAnalyze *ira, |
| 9905 | case TypeTableEntryIdEnumTag: | 9846 | case TypeTableEntryIdEnumTag: |
| 9906 | { | 9847 | { |
| 9907 | uint64_t size_in_bytes = type_size(ira->codegen, type_entry); | 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, | 9849 | ConstExprValue *out_val = ir_build_const_from(ira, &size_of_instruction->base); |
| 9909 | type_entry->size_depends_on_compile_var); | | |
| 9910 | bignum_init_unsigned(&out_val->data.x_bignum, size_in_bytes); | 9850 | bignum_init_unsigned(&out_val->data.x_bignum, size_in_bytes); |
| 9911 | return ira->codegen->builtin_types.entry_num_lit_int; | 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,8 +9867,7 @@ static TypeTableEntry *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrIn |
| 9927 | if (!maybe_val) | 9867 | if (!maybe_val) |
| 9928 | return ira->codegen->builtin_types.entry_invalid; | 9868 | return ira->codegen->builtin_types.entry_invalid; |
| 9929 | | 9869 | |
| 9930 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, | 9870 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 9931 | maybe_val->depends_on_compile_var); | | |
| 9932 | out_val->data.x_bool = (maybe_val->data.x_maybe != nullptr); | 9871 | out_val->data.x_bool = (maybe_val->data.x_maybe != nullptr); |
| 9933 | return ira->codegen->builtin_types.entry_bool; | 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,11 +9875,11 @@ static TypeTableEntry *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrIn |
| 9936 | ir_build_test_nonnull_from(&ira->new_irb, &instruction->base, value); | 9875 | ir_build_test_nonnull_from(&ira->new_irb, &instruction->base, value); |
| 9937 | return ira->codegen->builtin_types.entry_bool; | 9876 | return ira->codegen->builtin_types.entry_bool; |
| 9938 | } else if (type_entry->id == TypeTableEntryIdNullLit) { | 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 | out_val->data.x_bool = false; | 9879 | out_val->data.x_bool = false; |
| 9941 | return ira->codegen->builtin_types.entry_bool; | 9880 | return ira->codegen->builtin_types.entry_bool; |
| 9942 | } else { | 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 | out_val->data.x_bool = true; | 9883 | out_val->data.x_bool = true; |
| 9945 | return ira->codegen->builtin_types.entry_bool; | 9884 | return ira->codegen->builtin_types.entry_bool; |
| 9946 | } | 9885 | } |
| ... | @@ -9981,9 +9920,7 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_maybe(IrAnalyze *ira, | ... | @@ -9981,9 +9920,7 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_maybe(IrAnalyze *ira, |
| 9981 | ir_add_error(ira, &unwrap_maybe_instruction->base, buf_sprintf("unable to unwrap null")); | 9920 | ir_add_error(ira, &unwrap_maybe_instruction->base, buf_sprintf("unable to unwrap null")); |
| 9982 | return ira->codegen->builtin_types.entry_invalid; | 9921 | return ira->codegen->builtin_types.entry_invalid; |
| 9983 | } | 9922 | } |
| 9984 | bool depends_on_compile_var = maybe_val->depends_on_compile_var; | 9923 | ConstExprValue *out_val = ir_build_const_from(ira, &unwrap_maybe_instruction->base); |
| 9985 | ConstExprValue *out_val = ir_build_const_from(ira, &unwrap_maybe_instruction->base, | | |
| 9986 | depends_on_compile_var); | | |
| 9987 | out_val->data.x_ptr.base_ptr = maybe_val->data.x_maybe; | 9924 | out_val->data.x_ptr.base_ptr = maybe_val->data.x_maybe; |
| 9988 | out_val->data.x_ptr.index = SIZE_MAX; | 9925 | out_val->data.x_ptr.index = SIZE_MAX; |
| 9989 | return result_type; | 9926 | return result_type; |
| ... | @@ -10003,9 +9940,7 @@ static TypeTableEntry *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionC | ... | @@ -10003,9 +9940,7 @@ static TypeTableEntry *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionC |
| 10003 | if (value->value.special != ConstValSpecialRuntime) { | 9940 | if (value->value.special != ConstValSpecialRuntime) { |
| 10004 | uint32_t result = bignum_ctz(&value->value.data.x_bignum, | 9941 | uint32_t result = bignum_ctz(&value->value.data.x_bignum, |
| 10005 | value->value.type->data.integral.bit_count); | 9942 | value->value.type->data.integral.bit_count); |
| 10006 | bool depends_on_compile_var = value->value.depends_on_compile_var; | 9943 | ConstExprValue *out_val = ir_build_const_from(ira, &ctz_instruction->base); |
| 10007 | ConstExprValue *out_val = ir_build_const_from(ira, &ctz_instruction->base, | | |
| 10008 | depends_on_compile_var); | | |
| 10009 | bignum_init_unsigned(&out_val->data.x_bignum, result); | 9944 | bignum_init_unsigned(&out_val->data.x_bignum, result); |
| 10010 | return value->value.type; | 9945 | return value->value.type; |
| 10011 | } | 9946 | } |
| ... | @@ -10027,9 +9962,7 @@ static TypeTableEntry *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionC | ... | @@ -10027,9 +9962,7 @@ static TypeTableEntry *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionC |
| 10027 | if (value->value.special != ConstValSpecialRuntime) { | 9962 | if (value->value.special != ConstValSpecialRuntime) { |
| 10028 | uint32_t result = bignum_clz(&value->value.data.x_bignum, | 9963 | uint32_t result = bignum_clz(&value->value.data.x_bignum, |
| 10029 | value->value.type->data.integral.bit_count); | 9964 | value->value.type->data.integral.bit_count); |
| 10030 | bool depends_on_compile_var = value->value.depends_on_compile_var; | 9965 | ConstExprValue *out_val = ir_build_const_from(ira, &clz_instruction->base); |
| 10031 | ConstExprValue *out_val = ir_build_const_from(ira, &clz_instruction->base, | | |
| 10032 | depends_on_compile_var); | | |
| 10033 | bignum_init_unsigned(&out_val->data.x_bignum, result); | 9966 | bignum_init_unsigned(&out_val->data.x_bignum, result); |
| 10034 | return value->value.type; | 9967 | return value->value.type; |
| 10035 | } | 9968 | } |
| ... | @@ -10062,7 +9995,6 @@ static IrInstruction *ir_analyze_enum_tag(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -10062,7 +9995,6 @@ static IrInstruction *ir_analyze_enum_tag(IrAnalyze *ira, IrInstruction *source_ |
| 10062 | source_instr->scope, source_instr->source_node); | 9995 | source_instr->scope, source_instr->source_node); |
| 10063 | const_instruction->base.value.type = value->value.type->data.enumeration.tag_type; | 9996 | const_instruction->base.value.type = value->value.type->data.enumeration.tag_type; |
| 10064 | const_instruction->base.value.special = ConstValSpecialStatic; | 9997 | const_instruction->base.value.special = ConstValSpecialStatic; |
| 10065 | const_instruction->base.value.depends_on_compile_var = val->depends_on_compile_var; | | |
| 10066 | bignum_init_unsigned(&const_instruction->base.value.data.x_bignum, val->data.x_enum.tag); | 9998 | bignum_init_unsigned(&const_instruction->base.value.data.x_bignum, val->data.x_enum.tag); |
| 10067 | return &const_instruction->base; | 9999 | return &const_instruction->base; |
| 10068 | } | 10000 | } |
| ... | @@ -10178,7 +10110,6 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -10178,7 +10110,6 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 10178 | | 10110 | |
| 10179 | assert(target_value_ptr->value.type->id == TypeTableEntryIdPointer); | 10111 | assert(target_value_ptr->value.type->id == TypeTableEntryIdPointer); |
| 10180 | TypeTableEntry *target_type = target_value_ptr->value.type->data.pointer.child_type; | 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 | ConstExprValue *pointee_val = nullptr; | 10113 | ConstExprValue *pointee_val = nullptr; |
| 10183 | if (target_value_ptr->value.special != ConstValSpecialRuntime) { | 10114 | if (target_value_ptr->value.special != ConstValSpecialRuntime) { |
| 10184 | pointee_val = const_ptr_pointee(&target_value_ptr->value); | 10115 | pointee_val = const_ptr_pointee(&target_value_ptr->value); |
| ... | @@ -10205,8 +10136,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -10205,8 +10136,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 10205 | case TypeTableEntryIdNamespace: | 10136 | case TypeTableEntryIdNamespace: |
| 10206 | case TypeTableEntryIdPureError: | 10137 | case TypeTableEntryIdPureError: |
| 10207 | if (pointee_val) { | 10138 | if (pointee_val) { |
| 10208 | ConstExprValue *out_val = ir_build_const_from(ira, &switch_target_instruction->base, | 10139 | ConstExprValue *out_val = ir_build_const_from(ira, &switch_target_instruction->base); |
| 10209 | depends_on_compile_var); | | |
| 10210 | *out_val = *pointee_val; | 10140 | *out_val = *pointee_val; |
| 10211 | out_val->type = target_type; | 10141 | out_val->type = target_type; |
| 10212 | return target_type; | 10142 | return target_type; |
| ... | @@ -10218,8 +10148,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -10218,8 +10148,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 10218 | { | 10148 | { |
| 10219 | TypeTableEntry *tag_type = target_type->data.enumeration.tag_type; | 10149 | TypeTableEntry *tag_type = target_type->data.enumeration.tag_type; |
| 10220 | if (pointee_val) { | 10150 | if (pointee_val) { |
| 10221 | ConstExprValue *out_val = ir_build_const_from(ira, &switch_target_instruction->base, | 10151 | ConstExprValue *out_val = ir_build_const_from(ira, &switch_target_instruction->base); |
| 10222 | depends_on_compile_var); | | |
| 10223 | bignum_init_unsigned(&out_val->data.x_bignum, pointee_val->data.x_enum.tag); | 10152 | bignum_init_unsigned(&out_val->data.x_bignum, pointee_val->data.x_enum.tag); |
| 10224 | return tag_type; | 10153 | return tag_type; |
| 10225 | } | 10154 | } |
| ... | @@ -10285,8 +10214,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstr | ... | @@ -10285,8 +10214,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstr |
| 10285 | | 10214 | |
| 10286 | ConstExprValue *pointee_val = const_ptr_pointee(target_val_ptr); | 10215 | ConstExprValue *pointee_val = const_ptr_pointee(target_val_ptr); |
| 10287 | if (pointee_val->type->id == TypeTableEntryIdEnum) { | 10216 | if (pointee_val->type->id == TypeTableEntryIdEnum) { |
| 10288 | bool depends_on_compile_var = target_value_ptr->value.depends_on_compile_var; | 10217 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 10289 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); | | |
| 10290 | out_val->data.x_ptr.base_ptr = pointee_val->data.x_enum.payload; | 10218 | out_val->data.x_ptr.base_ptr = pointee_val->data.x_enum.payload; |
| 10291 | out_val->data.x_ptr.index = SIZE_MAX; | 10219 | out_val->data.x_ptr.index = SIZE_MAX; |
| 10292 | return get_pointer_to_type(ira->codegen, pointee_val->type, target_value_ptr->value.type->data.pointer.is_const); | 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,9 +10251,8 @@ static TypeTableEntry *ir_analyze_instruction_generated_code(IrAnalyze *ira, IrI |
| 10323 | if (!val) | 10251 | if (!val) |
| 10324 | return ira->codegen->builtin_types.entry_invalid; | 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 | *out_val = *val; | 10255 | *out_val = *val; |
| 10328 | out_val->depends_on_compile_var = true; | | |
| 10329 | return value->value.type; | 10256 | return value->value.type; |
| 10330 | } | 10257 | } |
| 10331 | | 10258 | |
| ... | @@ -10338,7 +10265,6 @@ static TypeTableEntry *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructi | ... | @@ -10338,7 +10265,6 @@ static TypeTableEntry *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructi |
| 10338 | Buf *import_target_str = ir_resolve_str(ira, name_value); | 10265 | Buf *import_target_str = ir_resolve_str(ira, name_value); |
| 10339 | if (!import_target_str) | 10266 | if (!import_target_str) |
| 10340 | return ira->codegen->builtin_types.entry_invalid; | 10267 | return ira->codegen->builtin_types.entry_invalid; |
| 10341 | bool depends_on_compile_var = name_value->value.depends_on_compile_var; | | |
| 10342 | | 10268 | |
| 10343 | AstNode *source_node = import_instruction->base.source_node; | 10269 | AstNode *source_node = import_instruction->base.source_node; |
| 10344 | ImportTableEntry *import = source_node->owner; | 10270 | ImportTableEntry *import = source_node->owner; |
| ... | @@ -10380,7 +10306,7 @@ static TypeTableEntry *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructi | ... | @@ -10380,7 +10306,7 @@ static TypeTableEntry *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructi |
| 10380 | | 10306 | |
| 10381 | auto import_entry = ira->codegen->import_table.maybe_get(abs_full_path); | 10307 | auto import_entry = ira->codegen->import_table.maybe_get(abs_full_path); |
| 10382 | if (import_entry) { | 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 | out_val->data.x_import = import_entry->value; | 10310 | out_val->data.x_import = import_entry->value; |
| 10385 | return ira->codegen->builtin_types.entry_namespace; | 10311 | return ira->codegen->builtin_types.entry_namespace; |
| 10386 | } | 10312 | } |
| ... | @@ -10401,7 +10327,7 @@ static TypeTableEntry *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructi | ... | @@ -10401,7 +10327,7 @@ static TypeTableEntry *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructi |
| 10401 | | 10327 | |
| 10402 | scan_decls(ira->codegen, target_import->decls_scope, target_import->root); | 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 | out_val->data.x_import = target_import; | 10331 | out_val->data.x_import = target_import; |
| 10406 | return ira->codegen->builtin_types.entry_namespace; | 10332 | return ira->codegen->builtin_types.entry_namespace; |
| 10407 | | 10333 | |
| ... | @@ -10415,16 +10341,14 @@ static TypeTableEntry *ir_analyze_instruction_array_len(IrAnalyze *ira, | ... | @@ -10415,16 +10341,14 @@ static TypeTableEntry *ir_analyze_instruction_array_len(IrAnalyze *ira, |
| 10415 | if (canon_type->id == TypeTableEntryIdInvalid) { | 10341 | if (canon_type->id == TypeTableEntryIdInvalid) { |
| 10416 | return ira->codegen->builtin_types.entry_invalid; | 10342 | return ira->codegen->builtin_types.entry_invalid; |
| 10417 | } else if (canon_type->id == TypeTableEntryIdArray) { | 10343 | } else if (canon_type->id == TypeTableEntryIdArray) { |
| 10418 | bool depends_on_compile_var = array_value->value.depends_on_compile_var; | | |
| 10419 | return ir_analyze_const_usize(ira, &array_len_instruction->base, | 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 | } else if (is_slice(canon_type)) { | 10346 | } else if (is_slice(canon_type)) { |
| 10422 | if (array_value->value.special != ConstValSpecialRuntime) { | 10347 | if (array_value->value.special != ConstValSpecialRuntime) { |
| 10423 | ConstExprValue *len_val = &array_value->value.data.x_struct.fields[slice_len_index]; | 10348 | ConstExprValue *len_val = &array_value->value.data.x_struct.fields[slice_len_index]; |
| 10424 | if (len_val->special != ConstValSpecialRuntime) { | 10349 | if (len_val->special != ConstValSpecialRuntime) { |
| 10425 | bool depends_on_compile_var = len_val->depends_on_compile_var; | | |
| 10426 | return ir_analyze_const_usize(ira, &array_len_instruction->base, | 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 | TypeStructField *field = &canon_type->data.structure.fields[slice_len_index]; | 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,8 +10371,7 @@ static TypeTableEntry *ir_analyze_instruction_ref(IrAnalyze *ira, IrInstructionR |
| 10447 | } | 10371 | } |
| 10448 | | 10372 | |
| 10449 | static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruction *instruction, | 10373 | static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruction *instruction, |
| 10450 | TypeTableEntry *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields, | 10374 | TypeTableEntry *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields) |
| 10451 | bool depends_on_compile_var) | | |
| 10452 | { | 10375 | { |
| 10453 | if (container_type->id != TypeTableEntryIdStruct || is_slice(container_type)) { | 10376 | if (container_type->id != TypeTableEntryIdStruct || is_slice(container_type)) { |
| 10454 | ir_add_error(ira, instruction, | 10377 | ir_add_error(ira, instruction, |
| ... | @@ -10473,7 +10396,6 @@ static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstru | ... | @@ -10473,7 +10396,6 @@ static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstru |
| 10473 | ConstExprValue const_val = {}; | 10396 | ConstExprValue const_val = {}; |
| 10474 | const_val.special = ConstValSpecialStatic; | 10397 | const_val.special = ConstValSpecialStatic; |
| 10475 | const_val.type = container_type; | 10398 | const_val.type = container_type; |
| 10476 | const_val.depends_on_compile_var = depends_on_compile_var; | | |
| 10477 | const_val.data.x_struct.fields = allocate<ConstExprValue>(actual_field_count); | 10399 | const_val.data.x_struct.fields = allocate<ConstExprValue>(actual_field_count); |
| 10478 | for (size_t i = 0; i < instr_field_count; i += 1) { | 10400 | for (size_t i = 0; i < instr_field_count; i += 1) { |
| 10479 | IrInstructionContainerInitFieldsField *field = &fields[i]; | 10401 | IrInstructionContainerInitFieldsField *field = &fields[i]; |
| ... | @@ -10516,7 +10438,6 @@ static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstru | ... | @@ -10516,7 +10438,6 @@ static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstru |
| 10516 | return ira->codegen->builtin_types.entry_invalid; | 10438 | return ira->codegen->builtin_types.entry_invalid; |
| 10517 | | 10439 | |
| 10518 | const_val.data.x_struct.fields[field_index] = *field_val; | 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 | } else { | 10441 | } else { |
| 10521 | first_non_const_instruction = casted_field_value; | 10442 | first_non_const_instruction = casted_field_value; |
| 10522 | const_val.special = ConstValSpecialRuntime; | 10443 | const_val.special = ConstValSpecialRuntime; |
| ... | @@ -10536,7 +10457,7 @@ static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstru | ... | @@ -10536,7 +10457,7 @@ static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstru |
| 10536 | return ira->codegen->builtin_types.entry_invalid; | 10457 | return ira->codegen->builtin_types.entry_invalid; |
| 10537 | | 10458 | |
| 10538 | if (const_val.special == ConstValSpecialStatic) { | 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 | *out_val = const_val; | 10461 | *out_val = const_val; |
| 10541 | return container_type; | 10462 | return container_type; |
| 10542 | } | 10463 | } |
| ... | @@ -10567,11 +10488,9 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira | ... | @@ -10567,11 +10488,9 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira |
| 10567 | if (container_type->id == TypeTableEntryIdInvalid) | 10488 | if (container_type->id == TypeTableEntryIdInvalid) |
| 10568 | return ira->codegen->builtin_types.entry_invalid; | 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 | if (container_type->id == TypeTableEntryIdStruct && !is_slice(container_type) && elem_count == 0) { | 10491 | if (container_type->id == TypeTableEntryIdStruct && !is_slice(container_type) && elem_count == 0) { |
| 10573 | return ir_analyze_container_init_fields(ira, &instruction->base, container_type, | 10492 | return ir_analyze_container_init_fields(ira, &instruction->base, container_type, |
| 10574 | 0, nullptr, depends_on_compile_var); | 10493 | 0, nullptr); |
| 10575 | } else if (is_slice(container_type)) { | 10494 | } else if (is_slice(container_type)) { |
| 10576 | TypeTableEntry *pointer_type = container_type->data.structure.fields[slice_ptr_index].type_entry; | 10495 | TypeTableEntry *pointer_type = container_type->data.structure.fields[slice_ptr_index].type_entry; |
| 10577 | assert(pointer_type->id == TypeTableEntryIdPointer); | 10496 | assert(pointer_type->id == TypeTableEntryIdPointer); |
| ... | @@ -10581,7 +10500,6 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira | ... | @@ -10581,7 +10500,6 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira |
| 10581 | ConstExprValue const_val = {}; | 10500 | ConstExprValue const_val = {}; |
| 10582 | const_val.special = ConstValSpecialStatic; | 10501 | const_val.special = ConstValSpecialStatic; |
| 10583 | const_val.type = fixed_size_array_type; | 10502 | const_val.type = fixed_size_array_type; |
| 10584 | const_val.depends_on_compile_var = depends_on_compile_var; | | |
| 10585 | const_val.data.x_array.elements = allocate<ConstExprValue>(elem_count); | 10503 | const_val.data.x_array.elements = allocate<ConstExprValue>(elem_count); |
| 10586 | const_val.data.x_array.size = elem_count; | 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,7 +10527,6 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira |
| 10609 | return ira->codegen->builtin_types.entry_invalid; | 10527 | return ira->codegen->builtin_types.entry_invalid; |
| 10610 | | 10528 | |
| 10611 | const_val.data.x_array.elements[i] = *elem_val; | 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 | } else { | 10530 | } else { |
| 10614 | first_non_const_instruction = casted_arg; | 10531 | first_non_const_instruction = casted_arg; |
| 10615 | const_val.special = ConstValSpecialRuntime; | 10532 | const_val.special = ConstValSpecialRuntime; |
| ... | @@ -10618,7 +10535,7 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira | ... | @@ -10618,7 +10535,7 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira |
| 10618 | } | 10535 | } |
| 10619 | | 10536 | |
| 10620 | if (const_val.special == ConstValSpecialStatic) { | 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 | *out_val = const_val; | 10539 | *out_val = const_val; |
| 10623 | for (size_t i = 0; i < elem_count; i += 1) { | 10540 | for (size_t i = 0; i < elem_count; i += 1) { |
| 10624 | ConstExprValue *elem_val = &out_val->data.x_array.elements[i]; | 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,8 +10598,7 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira |
| 10681 | ConstExprValue *init_val = ir_resolve_const(ira, casted_init_value, UndefOk); | 10598 | ConstExprValue *init_val = ir_resolve_const(ira, casted_init_value, UndefOk); |
| 10682 | if (!init_val) | 10599 | if (!init_val) |
| 10683 | return ira->codegen->builtin_types.entry_invalid; | 10600 | return ira->codegen->builtin_types.entry_invalid; |
| 10684 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, | 10601 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 10685 | casted_init_value->value.depends_on_compile_var); | | |
| 10686 | out_val->data.x_enum.tag = tag_uint; | 10602 | out_val->data.x_enum.tag = tag_uint; |
| 10687 | out_val->data.x_enum.payload = init_val; | 10603 | out_val->data.x_enum.payload = init_val; |
| 10688 | return enum_type; | 10604 | return enum_type; |
| ... | @@ -10705,37 +10621,34 @@ static TypeTableEntry *ir_analyze_instruction_container_init_fields(IrAnalyze *i | ... | @@ -10705,37 +10621,34 @@ static TypeTableEntry *ir_analyze_instruction_container_init_fields(IrAnalyze *i |
| 10705 | if (type_is_invalid(container_type)) | 10621 | if (type_is_invalid(container_type)) |
| 10706 | return ira->codegen->builtin_types.entry_invalid; | 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 | return ir_analyze_container_init_fields(ira, &instruction->base, container_type, | 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 | static TypeTableEntry *ir_analyze_min_max(IrAnalyze *ira, IrInstruction *source_instruction, | 10628 | static TypeTableEntry *ir_analyze_min_max(IrAnalyze *ira, IrInstruction *source_instruction, |
| 10715 | IrInstruction *target_type_value, bool is_max) | 10629 | IrInstruction *target_type_value, bool is_max) |
| 10716 | { | 10630 | { |
| 10717 | TypeTableEntry *target_type = ir_resolve_type(ira, target_type_value); | 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 | TypeTableEntry *canon_type = get_underlying_type(target_type); | 10632 | TypeTableEntry *canon_type = get_underlying_type(target_type); |
| 10720 | switch (canon_type->id) { | 10633 | switch (canon_type->id) { |
| 10721 | case TypeTableEntryIdInvalid: | 10634 | case TypeTableEntryIdInvalid: |
| 10722 | return ira->codegen->builtin_types.entry_invalid; | 10635 | return ira->codegen->builtin_types.entry_invalid; |
| 10723 | case TypeTableEntryIdInt: | 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 | eval_min_max_value(ira->codegen, canon_type, out_val, is_max); | 10639 | eval_min_max_value(ira->codegen, canon_type, out_val, is_max); |
| 10727 | return ira->codegen->builtin_types.entry_num_lit_int; | 10640 | return ira->codegen->builtin_types.entry_num_lit_int; |
| 10728 | } | 10641 | } |
| 10729 | case TypeTableEntryIdFloat: | 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 | eval_min_max_value(ira->codegen, canon_type, out_val, is_max); | 10645 | eval_min_max_value(ira->codegen, canon_type, out_val, is_max); |
| 10733 | return ira->codegen->builtin_types.entry_num_lit_float; | 10646 | return ira->codegen->builtin_types.entry_num_lit_float; |
| 10734 | } | 10647 | } |
| 10735 | case TypeTableEntryIdBool: | 10648 | case TypeTableEntryIdBool: |
| 10736 | case TypeTableEntryIdVoid: | 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 | eval_min_max_value(ira->codegen, canon_type, out_val, is_max); | 10652 | eval_min_max_value(ira->codegen, canon_type, out_val, is_max); |
| 10740 | return target_type; | 10653 | return target_type; |
| 10741 | } | 10654 | } |
| ... | @@ -10815,7 +10728,7 @@ static TypeTableEntry *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInst | ... | @@ -10815,7 +10728,7 @@ static TypeTableEntry *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInst |
| 10815 | | 10728 | |
| 10816 | ir_add_error(ira, &instruction->base, buf_sprintf("found compile log statement")); | 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 | return ira->codegen->builtin_types.entry_void; | 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,8 +10748,7 @@ static TypeTableEntry *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruc |
| 10835 | ConstExprValue *array_val = create_const_str_lit(ira->codegen, &err->name); | 10748 | ConstExprValue *array_val = create_const_str_lit(ira->codegen, &err->name); |
| 10836 | err->cached_error_name_val = create_const_slice(ira->codegen, array_val, 0, buf_len(&err->name), true); | 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, | 10751 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 10839 | casted_value->value.depends_on_compile_var); | | |
| 10840 | *out_val = *err->cached_error_name_val; | 10752 | *out_val = *err->cached_error_name_val; |
| 10841 | return str_type; | 10753 | return str_type; |
| 10842 | } | 10754 | } |
| ... | @@ -10855,8 +10767,7 @@ static TypeTableEntry *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstru | ... | @@ -10855,8 +10767,7 @@ static TypeTableEntry *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstru |
| 10855 | if (!type_entry->cached_const_name_val) { | 10767 | if (!type_entry->cached_const_name_val) { |
| 10856 | type_entry->cached_const_name_val = create_const_str_lit(ira->codegen, &type_entry->name); | 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, | 10770 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 10859 | type_value->value.depends_on_compile_var); | | |
| 10860 | *out_val = *type_entry->cached_const_name_val; | 10771 | *out_val = *type_entry->cached_const_name_val; |
| 10861 | return out_val->type; | 10772 | return out_val->type; |
| 10862 | } | 10773 | } |
| ... | @@ -10905,10 +10816,7 @@ static TypeTableEntry *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruc | ... | @@ -10905,10 +10816,7 @@ static TypeTableEntry *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruc |
| 10905 | ast_render_decls(stderr, 4, child_import); | 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 | 10819 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 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); | | |
| 10912 | out_val->data.x_import = child_import; | 10820 | out_val->data.x_import = child_import; |
| 10913 | return ira->codegen->builtin_types.entry_namespace; | 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,7 +10836,7 @@ static TypeTableEntry *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstru |
| 10928 | | 10836 | |
| 10929 | buf_appendf(c_import_buf, "#include <%s>\n", buf_ptr(include_name)); | 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 | return ira->codegen->builtin_types.entry_void; | 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,7 +10863,7 @@ static TypeTableEntry *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstruc |
| 10955 | | 10863 | |
| 10956 | buf_appendf(c_import_buf, "#define %s %s\n", buf_ptr(define_name), buf_ptr(define_value)); | 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 | return ira->codegen->builtin_types.entry_void; | 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,7 +10882,7 @@ static TypeTableEntry *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstruct |
| 10974 | | 10882 | |
| 10975 | buf_appendf(c_import_buf, "#undef %s\n", buf_ptr(undef_name)); | 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 | return ira->codegen->builtin_types.entry_void; | 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,8 +10919,7 @@ static TypeTableEntry *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstr |
| 11011 | // TODO add dependency on the file we embedded so that we know if it changes | 10919 | // TODO add dependency on the file we embedded so that we know if it changes |
| 11012 | // we'll have to invalidate the cache | 10920 | // we'll have to invalidate the cache |
| 11013 | | 10921 | |
| 11014 | bool depends_on_compile_var = true; | 10922 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11015 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); | | |
| 11016 | init_const_str_lit(ira->codegen, out_val, &file_contents); | 10923 | init_const_str_lit(ira->codegen, out_val, &file_contents); |
| 11017 | | 10924 | |
| 11018 | return get_array_type(ira->codegen, ira->codegen->builtin_types.entry_u8, buf_len(&file_contents)); | 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,9 +11068,7 @@ static TypeTableEntry *ir_analyze_instruction_div_exact(IrAnalyze *ira, IrInstru |
| 11161 | return ira->codegen->builtin_types.entry_invalid; | 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 || | 11071 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11165 | casted_op2->value.depends_on_compile_var; | | |
| 11166 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); | | |
| 11167 | bignum_div(&out_val->data.x_bignum, &op1_val->data.x_bignum, &op2_val->data.x_bignum); | 11072 | bignum_div(&out_val->data.x_bignum, &op1_val->data.x_bignum, &op2_val->data.x_bignum); |
| 11168 | return result_type; | 11073 | return result_type; |
| 11169 | } | 11074 | } |
| ... | @@ -11215,8 +11120,7 @@ static TypeTableEntry *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruc | ... | @@ -11215,8 +11120,7 @@ static TypeTableEntry *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruc |
| 11215 | } | 11120 | } |
| 11216 | | 11121 | |
| 11217 | if (target->value.special == ConstValSpecialStatic) { | 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; | 11123 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11219 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); | | |
| 11220 | bignum_init_bignum(&out_val->data.x_bignum, &target->value.data.x_bignum); | 11124 | bignum_init_bignum(&out_val->data.x_bignum, &target->value.data.x_bignum); |
| 11221 | bignum_truncate(&out_val->data.x_bignum, canon_dest_type->data.integral.bit_count); | 11125 | bignum_truncate(&out_val->data.x_bignum, canon_dest_type->data.integral.bit_count); |
| 11222 | return dest_type; | 11126 | return dest_type; |
| ... | @@ -11237,10 +11141,7 @@ static TypeTableEntry *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstruc | ... | @@ -11237,10 +11141,7 @@ static TypeTableEntry *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstruc |
| 11237 | if (!ir_resolve_usize(ira, bit_count_value, &bit_count)) | 11141 | if (!ir_resolve_usize(ira, bit_count_value, &bit_count)) |
| 11238 | return ira->codegen->builtin_types.entry_invalid; | 11142 | return ira->codegen->builtin_types.entry_invalid; |
| 11239 | | 11143 | |
| 11240 | bool depends_on_compile_var = is_signed_value->value.depends_on_compile_var || | 11144 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 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); | | |
| 11244 | out_val->data.x_type = get_int_type(ira->codegen, is_signed, bit_count); | 11145 | out_val->data.x_type = get_int_type(ira->codegen, is_signed, bit_count); |
| 11245 | return ira->codegen->builtin_types.entry_type; | 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,8 +11158,7 @@ static TypeTableEntry *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstruc |
| 11257 | return ira->codegen->builtin_types.entry_invalid; | 11158 | return ira->codegen->builtin_types.entry_invalid; |
| 11258 | | 11159 | |
| 11259 | if (casted_value->value.special != ConstValSpecialRuntime) { | 11160 | if (casted_value->value.special != ConstValSpecialRuntime) { |
| 11260 | bool depends_on_compile_var = casted_value->value.depends_on_compile_var; | 11161 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11261 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); | | |
| 11262 | out_val->data.x_bool = !casted_value->value.data.x_bool; | 11162 | out_val->data.x_bool = !casted_value->value.data.x_bool; |
| 11263 | return bool_type; | 11163 | return bool_type; |
| 11264 | } | 11164 | } |
| ... | @@ -11357,7 +11257,7 @@ static TypeTableEntry *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructi | ... | @@ -11357,7 +11257,7 @@ static TypeTableEntry *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructi |
| 11357 | dest_elements[i] = *byte_val; | 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 | return ira->codegen->builtin_types.entry_void; | 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,7 +11354,7 @@ static TypeTableEntry *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructi |
| 11454 | dest_elements[dest_start + i] = src_elements[src_start + i]; | 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 | return ira->codegen->builtin_types.entry_void; | 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,11 +11415,6 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio |
| 11515 | casted_start->value.special == ConstValSpecialStatic && | 11415 | casted_start->value.special == ConstValSpecialStatic && |
| 11516 | (!end || end->value.special == ConstValSpecialStatic)) | 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 | ConstExprValue *base_ptr; | 11418 | ConstExprValue *base_ptr; |
| 11524 | size_t abs_offset; | 11419 | size_t abs_offset; |
| 11525 | size_t rel_end; | 11420 | size_t rel_end; |
| ... | @@ -11571,7 +11466,7 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio | ... | @@ -11571,7 +11466,7 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio |
| 11571 | return ira->codegen->builtin_types.entry_invalid; | 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 | out_val->data.x_struct.fields = allocate<ConstExprValue>(2); | 11470 | out_val->data.x_struct.fields = allocate<ConstExprValue>(2); |
| 11576 | | 11471 | |
| 11577 | ConstExprValue *ptr_val = &out_val->data.x_struct.fields[slice_ptr_index]; | 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,8 +11507,7 @@ static TypeTableEntry *ir_analyze_instruction_member_count(IrAnalyze *ira, IrIns |
| 11612 | return ira->codegen->builtin_types.entry_invalid; | 11507 | return ira->codegen->builtin_types.entry_invalid; |
| 11613 | } | 11508 | } |
| 11614 | | 11509 | |
| 11615 | bool depends_on_compile_var = container->value.depends_on_compile_var; | 11510 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11616 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); | | |
| 11617 | bignum_init_unsigned(&out_val->data.x_bignum, result); | 11511 | bignum_init_unsigned(&out_val->data.x_bignum, result); |
| 11618 | return ira->codegen->builtin_types.entry_num_lit_int; | 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,8 +11547,7 @@ static TypeTableEntry *ir_analyze_instruction_alignof(IrAnalyze *ira, IrInstruct |
| 11653 | return ira->codegen->builtin_types.entry_invalid; | 11547 | return ira->codegen->builtin_types.entry_invalid; |
| 11654 | } else { | 11548 | } else { |
| 11655 | uint64_t align_in_bytes = LLVMABISizeOfType(ira->codegen->target_data_ref, type_entry->type_ref); | 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; | 11550 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11657 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); | | |
| 11658 | bignum_init_unsigned(&out_val->data.x_bignum, align_in_bytes); | 11551 | bignum_init_unsigned(&out_val->data.x_bignum, align_in_bytes); |
| 11659 | return ira->codegen->builtin_types.entry_num_lit_int; | 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,10 +11598,7 @@ static TypeTableEntry *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInst |
| 11705 | casted_op2->value.special == ConstValSpecialStatic && | 11598 | casted_op2->value.special == ConstValSpecialStatic && |
| 11706 | casted_result_ptr->value.special == ConstValSpecialStatic) | 11599 | casted_result_ptr->value.special == ConstValSpecialStatic) |
| 11707 | { | 11600 | { |
| 11708 | bool depends_on_compile_var = type_value->value.depends_on_compile_var || | 11601 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 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); | | |
| 11712 | BigNum *op1_bignum = &casted_op1->value.data.x_bignum; | 11602 | BigNum *op1_bignum = &casted_op1->value.data.x_bignum; |
| 11713 | BigNum *op2_bignum = &casted_op2->value.data.x_bignum; | 11603 | BigNum *op2_bignum = &casted_op2->value.data.x_bignum; |
| 11714 | ConstExprValue *pointee_val = const_ptr_pointee(&casted_result_ptr->value); | 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,8 +11649,7 @@ static TypeTableEntry *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruc |
| 11759 | return ira->codegen->builtin_types.entry_invalid; | 11649 | return ira->codegen->builtin_types.entry_invalid; |
| 11760 | | 11650 | |
| 11761 | if (err_union_val->special != ConstValSpecialRuntime) { | 11651 | if (err_union_val->special != ConstValSpecialRuntime) { |
| 11762 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, | 11652 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11763 | err_union_val->depends_on_compile_var); | | |
| 11764 | out_val->data.x_bool = (err_union_val->data.x_err_union.err != nullptr); | 11653 | out_val->data.x_bool = (err_union_val->data.x_err_union.err != nullptr); |
| 11765 | return ira->codegen->builtin_types.entry_bool; | 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,11 +11658,11 @@ static TypeTableEntry *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruc |
| 11769 | ir_build_test_err_from(&ira->new_irb, &instruction->base, value); | 11658 | ir_build_test_err_from(&ira->new_irb, &instruction->base, value); |
| 11770 | return ira->codegen->builtin_types.entry_bool; | 11659 | return ira->codegen->builtin_types.entry_bool; |
| 11771 | } else if (canon_type->id == TypeTableEntryIdPureError) { | 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 | out_val->data.x_bool = true; | 11662 | out_val->data.x_bool = true; |
| 11774 | return ira->codegen->builtin_types.entry_bool; | 11663 | return ira->codegen->builtin_types.entry_bool; |
| 11775 | } else { | 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 | out_val->data.x_bool = false; | 11666 | out_val->data.x_bool = false; |
| 11778 | return ira->codegen->builtin_types.entry_bool; | 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,8 +11694,7 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira, |
| 11805 | ErrorTableEntry *err = err_union_val->data.x_err_union.err; | 11694 | ErrorTableEntry *err = err_union_val->data.x_err_union.err; |
| 11806 | assert(err); | 11695 | assert(err); |
| 11807 | | 11696 | |
| 11808 | bool depends_on_compile_var = ptr_val->depends_on_compile_var || err_union_val->depends_on_compile_var; | 11697 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11809 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); | | |
| 11810 | out_val->data.x_pure_err = err; | 11698 | out_val->data.x_pure_err = err; |
| 11811 | return ira->codegen->builtin_types.entry_pure_error; | 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,8 +11743,7 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira, |
| 11855 | return ira->codegen->builtin_types.entry_invalid; | 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; | 11746 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11859 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, depends_on_compile_var); | | |
| 11860 | out_val->data.x_ptr.base_ptr = err_union_val->data.x_err_union.payload; | 11747 | out_val->data.x_ptr.base_ptr = err_union_val->data.x_err_union.payload; |
| 11861 | out_val->data.x_ptr.index = SIZE_MAX; | 11748 | out_val->data.x_ptr.index = SIZE_MAX; |
| 11862 | return result_type; | 11749 | return result_type; |
| ... | @@ -11881,8 +11768,6 @@ static TypeTableEntry *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruc | ... | @@ -11881,8 +11768,6 @@ static TypeTableEntry *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruc |
| 11881 | FnTypeId fn_type_id = {0}; | 11768 | FnTypeId fn_type_id = {0}; |
| 11882 | init_fn_type_id(&fn_type_id, proto_node, proto_node->data.fn_proto.params.length); | 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 | for (; fn_type_id.next_param_index < fn_type_id.param_count; fn_type_id.next_param_index += 1) { | 11771 | for (; fn_type_id.next_param_index < fn_type_id.param_count; fn_type_id.next_param_index += 1) { |
| 11887 | AstNode *param_node = proto_node->data.fn_proto.params.at(fn_type_id.next_param_index); | 11772 | AstNode *param_node = proto_node->data.fn_proto.params.at(fn_type_id.next_param_index); |
| 11888 | assert(param_node->type == NodeTypeParamDecl); | 11773 | assert(param_node->type == NodeTypeParamDecl); |
| ... | @@ -11894,17 +11779,14 @@ static TypeTableEntry *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruc | ... | @@ -11894,17 +11779,14 @@ static TypeTableEntry *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruc |
| 11894 | param_info->type = ir_resolve_type(ira, param_type_value); | 11779 | param_info->type = ir_resolve_type(ira, param_type_value); |
| 11895 | if (param_info->type->id == TypeTableEntryIdInvalid) | 11780 | if (param_info->type->id == TypeTableEntryIdInvalid) |
| 11896 | return ira->codegen->builtin_types.entry_invalid; | 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 | IrInstruction *return_type_value = instruction->return_type->other; | 11784 | IrInstruction *return_type_value = instruction->return_type->other; |
| 11902 | fn_type_id.return_type = ir_resolve_type(ira, return_type_value); | 11785 | fn_type_id.return_type = ir_resolve_type(ira, return_type_value); |
| 11903 | if (fn_type_id.return_type->id == TypeTableEntryIdInvalid) | 11786 | if (fn_type_id.return_type->id == TypeTableEntryIdInvalid) |
| 11904 | return ira->codegen->builtin_types.entry_invalid; | 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 | out_val->data.x_type = get_fn_type(ira->codegen, &fn_type_id); | 11790 | out_val->data.x_type = get_fn_type(ira->codegen, &fn_type_id); |
| 11909 | return ira->codegen->builtin_types.entry_type; | 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,7 +11796,7 @@ static TypeTableEntry *ir_analyze_instruction_test_comptime(IrAnalyze *ira, IrIn |
| 11914 | if (value->value.type->id == TypeTableEntryIdInvalid) | 11796 | if (value->value.type->id == TypeTableEntryIdInvalid) |
| 11915 | return ira->codegen->builtin_types.entry_invalid; | 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 | out_val->data.x_bool = instr_is_comptime(value); | 11800 | out_val->data.x_bool = instr_is_comptime(value); |
| 11919 | return ira->codegen->builtin_types.entry_bool; | 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,7 +11860,7 @@ static TypeTableEntry *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira |
| 11978 | } else { | 11860 | } else { |
| 11979 | // TODO check prongs of types other than enumtag | 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 | return ira->codegen->builtin_types.entry_void; | 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,7 +11870,7 @@ static TypeTableEntry *ir_analyze_instruction_test_type(IrAnalyze *ira, IrInstru |
| 11988 | if (type_entry->id == TypeTableEntryIdInvalid) | 11870 | if (type_entry->id == TypeTableEntryIdInvalid) |
| 11989 | return ira->codegen->builtin_types.entry_invalid; | 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 | out_val->data.x_bool = (type_entry->id == instruction->type_id); | 11874 | out_val->data.x_bool = (type_entry->id == instruction->type_id); |
| 11993 | return ira->codegen->builtin_types.entry_bool; | 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,10 +11894,7 @@ static TypeTableEntry *ir_analyze_instruction_can_implicit_cast(IrAnalyze *ira, |
| 12012 | zig_panic("TODO refactor implicit cast tester to return bool without reporting errors"); | 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 | 11897 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 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); | | |
| 12019 | out_val->data.x_bool = (result == ImplicitCastMatchResultYes); | 11898 | out_val->data.x_bool = (result == ImplicitCastMatchResultYes); |
| 12020 | return ira->codegen->builtin_types.entry_bool; | 11899 | return ira->codegen->builtin_types.entry_bool; |
| 12021 | } | 11900 | } |