| ... | @@ -315,10 +315,6 @@ static constexpr IrInstructionId ir_instruction_id(IrInstructionEnumTag *) { | ... | @@ -315,10 +315,6 @@ static constexpr IrInstructionId ir_instruction_id(IrInstructionEnumTag *) { |
| 315 | return IrInstructionIdEnumTag; | 315 | return IrInstructionIdEnumTag; |
| 316 | } | 316 | } |
| 317 | | 317 | |
| 318 | static constexpr IrInstructionId ir_instruction_id(IrInstructionStaticEval *) { | | |
| 319 | return IrInstructionIdStaticEval; | | |
| 320 | } | | |
| 321 | | | |
| 322 | static constexpr IrInstructionId ir_instruction_id(IrInstructionGeneratedCode *) { | 318 | static constexpr IrInstructionId ir_instruction_id(IrInstructionGeneratedCode *) { |
| 323 | return IrInstructionIdGeneratedCode; | 319 | return IrInstructionIdGeneratedCode; |
| 324 | } | 320 | } |
| ... | @@ -1403,15 +1399,6 @@ static IrInstruction *ir_build_enum_tag_from(IrBuilder *irb, IrInstruction *old_ | ... | @@ -1403,15 +1399,6 @@ static IrInstruction *ir_build_enum_tag_from(IrBuilder *irb, IrInstruction *old_ |
| 1403 | return new_instruction; | 1399 | return new_instruction; |
| 1404 | } | 1400 | } |
| 1405 | | 1401 | |
| 1406 | static IrInstruction *ir_build_static_eval(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *value) { | | |
| 1407 | IrInstructionStaticEval *instruction = ir_build_instruction<IrInstructionStaticEval>(irb, scope, source_node); | | |
| 1408 | instruction->value = value; | | |
| 1409 | | | |
| 1410 | ir_ref_instruction(value, irb->current_basic_block); | | |
| 1411 | | | |
| 1412 | return &instruction->base; | | |
| 1413 | } | | |
| 1414 | | | |
| 1415 | static IrInstruction *ir_build_generated_code(IrBuilder *irb, Scope *scope, AstNode *source_node, | 1402 | static IrInstruction *ir_build_generated_code(IrBuilder *irb, Scope *scope, AstNode *source_node, |
| 1416 | IrInstruction *value) | 1403 | IrInstruction *value) |
| 1417 | { | 1404 | { |
| ... | @@ -2300,13 +2287,6 @@ static IrInstruction *ir_instruction_ctz_get_dep(IrInstructionCtz *instruction, | ... | @@ -2300,13 +2287,6 @@ static IrInstruction *ir_instruction_ctz_get_dep(IrInstructionCtz *instruction, |
| 2300 | } | 2287 | } |
| 2301 | } | 2288 | } |
| 2302 | | 2289 | |
| 2303 | static IrInstruction *ir_instruction_staticeval_get_dep(IrInstructionStaticEval *instruction, size_t index) { | | |
| 2304 | switch (index) { | | |
| 2305 | case 0: return instruction->value; | | |
| 2306 | default: return nullptr; | | |
| 2307 | } | | |
| 2308 | } | | |
| 2309 | | | |
| 2310 | static IrInstruction *ir_instruction_generatedcode_get_dep(IrInstructionGeneratedCode *instruction, size_t index) { | 2290 | static IrInstruction *ir_instruction_generatedcode_get_dep(IrInstructionGeneratedCode *instruction, size_t index) { |
| 2311 | switch (index) { | 2291 | switch (index) { |
| 2312 | case 0: return instruction->value; | 2292 | case 0: return instruction->value; |
| ... | @@ -2711,8 +2691,6 @@ static IrInstruction *ir_instruction_get_dep(IrInstruction *instruction, size_t | ... | @@ -2711,8 +2691,6 @@ static IrInstruction *ir_instruction_get_dep(IrInstruction *instruction, size_t |
| 2711 | return ir_instruction_clz_get_dep((IrInstructionClz *) instruction, index); | 2691 | return ir_instruction_clz_get_dep((IrInstructionClz *) instruction, index); |
| 2712 | case IrInstructionIdCtz: | 2692 | case IrInstructionIdCtz: |
| 2713 | return ir_instruction_ctz_get_dep((IrInstructionCtz *) instruction, index); | 2693 | return ir_instruction_ctz_get_dep((IrInstructionCtz *) instruction, index); |
| 2714 | case IrInstructionIdStaticEval: | | |
| 2715 | return ir_instruction_staticeval_get_dep((IrInstructionStaticEval *) instruction, index); | | |
| 2716 | case IrInstructionIdGeneratedCode: | 2694 | case IrInstructionIdGeneratedCode: |
| 2717 | return ir_instruction_generatedcode_get_dep((IrInstructionGeneratedCode *) instruction, index); | 2695 | return ir_instruction_generatedcode_get_dep((IrInstructionGeneratedCode *) instruction, index); |
| 2718 | case IrInstructionIdImport: | 2696 | case IrInstructionIdImport: |
| ... | @@ -3727,15 +3705,6 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3727,15 +3705,6 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3727 | | 3705 | |
| 3728 | return ir_build_clz(irb, scope, node, arg0_value); | 3706 | return ir_build_clz(irb, scope, node, arg0_value); |
| 3729 | } | 3707 | } |
| 3730 | case BuiltinFnIdStaticEval: | | |
| 3731 | { | | |
| 3732 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | | |
| 3733 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | | |
| 3734 | if (arg0_value == irb->codegen->invalid_instruction) | | |
| 3735 | return arg0_value; | | |
| 3736 | | | |
| 3737 | return ir_build_static_eval(irb, scope, node, arg0_value); | | |
| 3738 | } | | |
| 3739 | case BuiltinFnIdGeneratedCode: | 3708 | case BuiltinFnIdGeneratedCode: |
| 3740 | { | 3709 | { |
| 3741 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 3710 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| ... | @@ -4731,6 +4700,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -4731,6 +4700,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 4731 | ZigList<IrBasicBlock *> incoming_blocks = {0}; | 4700 | ZigList<IrBasicBlock *> incoming_blocks = {0}; |
| 4732 | ZigList<IrInstructionCheckSwitchProngsRange> check_ranges = {0}; | 4701 | ZigList<IrInstructionCheckSwitchProngsRange> check_ranges = {0}; |
| 4733 | | 4702 | |
| | 4703 | Scope *comptime_scope = create_comptime_scope(node, scope); |
| 4734 | AstNode *else_prong = nullptr; | 4704 | AstNode *else_prong = nullptr; |
| 4735 | for (size_t prong_i = 0; prong_i < prong_count; prong_i += 1) { | 4705 | for (size_t prong_i = 0; prong_i < prong_count; prong_i += 1) { |
| 4736 | AstNode *prong_node = node->data.switch_expr.prongs.at(prong_i); | 4706 | AstNode *prong_node = node->data.switch_expr.prongs.at(prong_i); |
| ... | @@ -4764,11 +4734,11 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -4764,11 +4734,11 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 4764 | AstNode *start_node = item_node->data.switch_range.start; | 4734 | AstNode *start_node = item_node->data.switch_range.start; |
| 4765 | AstNode *end_node = item_node->data.switch_range.end; | 4735 | AstNode *end_node = item_node->data.switch_range.end; |
| 4766 | | 4736 | |
| 4767 | IrInstruction *start_value = ir_gen_node(irb, start_node, scope); | 4737 | IrInstruction *start_value = ir_gen_node(irb, start_node, comptime_scope); |
| 4768 | if (start_value == irb->codegen->invalid_instruction) | 4738 | if (start_value == irb->codegen->invalid_instruction) |
| 4769 | return irb->codegen->invalid_instruction; | 4739 | return irb->codegen->invalid_instruction; |
| 4770 | | 4740 | |
| 4771 | IrInstruction *end_value = ir_gen_node(irb, end_node, scope); | 4741 | IrInstruction *end_value = ir_gen_node(irb, end_node, comptime_scope); |
| 4772 | if (end_value == irb->codegen->invalid_instruction) | 4742 | if (end_value == irb->codegen->invalid_instruction) |
| 4773 | return irb->codegen->invalid_instruction; | 4743 | return irb->codegen->invalid_instruction; |
| 4774 | | 4744 | |
| ... | @@ -4776,13 +4746,10 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -4776,13 +4746,10 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 4776 | check_range->start = start_value; | 4746 | check_range->start = start_value; |
| 4777 | check_range->end = end_value; | 4747 | check_range->end = end_value; |
| 4778 | | 4748 | |
| 4779 | IrInstruction *start_value_const = ir_build_static_eval(irb, scope, start_node, start_value); | | |
| 4780 | IrInstruction *end_value_const = ir_build_static_eval(irb, scope, start_node, end_value); | | |
| 4781 | | | |
| 4782 | IrInstruction *lower_range_ok = ir_build_bin_op(irb, scope, item_node, IrBinOpCmpGreaterOrEq, | 4749 | IrInstruction *lower_range_ok = ir_build_bin_op(irb, scope, item_node, IrBinOpCmpGreaterOrEq, |
| 4783 | target_value, start_value_const, false); | 4750 | target_value, start_value, false); |
| 4784 | IrInstruction *upper_range_ok = ir_build_bin_op(irb, scope, item_node, IrBinOpCmpLessOrEq, | 4751 | IrInstruction *upper_range_ok = ir_build_bin_op(irb, scope, item_node, IrBinOpCmpLessOrEq, |
| 4785 | target_value, end_value_const, false); | 4752 | target_value, end_value, false); |
| 4786 | IrInstruction *both_ok = ir_build_bin_op(irb, scope, item_node, IrBinOpBoolAnd, | 4753 | IrInstruction *both_ok = ir_build_bin_op(irb, scope, item_node, IrBinOpBoolAnd, |
| 4787 | lower_range_ok, upper_range_ok, false); | 4754 | lower_range_ok, upper_range_ok, false); |
| 4788 | if (ok_bit) { | 4755 | if (ok_bit) { |
| ... | @@ -4791,7 +4758,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -4791,7 +4758,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 4791 | ok_bit = both_ok; | 4758 | ok_bit = both_ok; |
| 4792 | } | 4759 | } |
| 4793 | } else { | 4760 | } else { |
| 4794 | IrInstruction *item_value = ir_gen_node(irb, item_node, scope); | 4761 | IrInstruction *item_value = ir_gen_node(irb, item_node, comptime_scope); |
| 4795 | if (item_value == irb->codegen->invalid_instruction) | 4762 | if (item_value == irb->codegen->invalid_instruction) |
| 4796 | return irb->codegen->invalid_instruction; | 4763 | return irb->codegen->invalid_instruction; |
| 4797 | | 4764 | |
| ... | @@ -4833,7 +4800,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -4833,7 +4800,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 4833 | AstNode *item_node = prong_node->data.switch_prong.items.at(item_i); | 4800 | AstNode *item_node = prong_node->data.switch_prong.items.at(item_i); |
| 4834 | assert(item_node->type != NodeTypeSwitchRange); | 4801 | assert(item_node->type != NodeTypeSwitchRange); |
| 4835 | | 4802 | |
| 4836 | IrInstruction *item_value = ir_gen_node(irb, item_node, scope); | 4803 | IrInstruction *item_value = ir_gen_node(irb, item_node, comptime_scope); |
| 4837 | if (item_value == irb->codegen->invalid_instruction) | 4804 | if (item_value == irb->codegen->invalid_instruction) |
| 4838 | return irb->codegen->invalid_instruction; | 4805 | return irb->codegen->invalid_instruction; |
| 4839 | | 4806 | |
| ... | @@ -9660,22 +9627,6 @@ static TypeTableEntry *ir_analyze_instruction_enum_tag(IrAnalyze *ira, IrInstruc | ... | @@ -9660,22 +9627,6 @@ static TypeTableEntry *ir_analyze_instruction_enum_tag(IrAnalyze *ira, IrInstruc |
| 9660 | return new_instruction->value.type; | 9627 | return new_instruction->value.type; |
| 9661 | } | 9628 | } |
| 9662 | | 9629 | |
| 9663 | static TypeTableEntry *ir_analyze_instruction_static_eval(IrAnalyze *ira, | | |
| 9664 | IrInstructionStaticEval *static_eval_instruction) | | |
| 9665 | { | | |
| 9666 | IrInstruction *value = static_eval_instruction->value->other; | | |
| 9667 | if (value->value.type->id == TypeTableEntryIdInvalid) | | |
| 9668 | return ira->codegen->builtin_types.entry_invalid; | | |
| 9669 | | | |
| 9670 | ConstExprValue *val = ir_resolve_const(ira, value, UndefBad); | | |
| 9671 | if (!val) | | |
| 9672 | return ira->codegen->builtin_types.entry_invalid; | | |
| 9673 | | | |
| 9674 | ConstExprValue *out_val = ir_build_const_from(ira, &static_eval_instruction->base, val->depends_on_compile_var); | | |
| 9675 | *out_val = *val; | | |
| 9676 | return value->value.type; | | |
| 9677 | } | | |
| 9678 | | | |
| 9679 | static TypeTableEntry *ir_analyze_instruction_generated_code(IrAnalyze *ira, IrInstructionGeneratedCode *instruction) { | 9630 | static TypeTableEntry *ir_analyze_instruction_generated_code(IrAnalyze *ira, IrInstructionGeneratedCode *instruction) { |
| 9680 | IrInstruction *value = instruction->value->other; | 9631 | IrInstruction *value = instruction->value->other; |
| 9681 | if (value->value.type->id == TypeTableEntryIdInvalid) | 9632 | if (value->value.type->id == TypeTableEntryIdInvalid) |
| ... | @@ -11379,8 +11330,6 @@ static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstructi | ... | @@ -11379,8 +11330,6 @@ static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstructi |
| 11379 | return ir_analyze_instruction_switch_var(ira, (IrInstructionSwitchVar *)instruction); | 11330 | return ir_analyze_instruction_switch_var(ira, (IrInstructionSwitchVar *)instruction); |
| 11380 | case IrInstructionIdEnumTag: | 11331 | case IrInstructionIdEnumTag: |
| 11381 | return ir_analyze_instruction_enum_tag(ira, (IrInstructionEnumTag *)instruction); | 11332 | return ir_analyze_instruction_enum_tag(ira, (IrInstructionEnumTag *)instruction); |
| 11382 | case IrInstructionIdStaticEval: | | |
| 11383 | return ir_analyze_instruction_static_eval(ira, (IrInstructionStaticEval *)instruction); | | |
| 11384 | case IrInstructionIdGeneratedCode: | 11333 | case IrInstructionIdGeneratedCode: |
| 11385 | return ir_analyze_instruction_generated_code(ira, (IrInstructionGeneratedCode *)instruction); | 11334 | return ir_analyze_instruction_generated_code(ira, (IrInstructionGeneratedCode *)instruction); |
| 11386 | case IrInstructionIdImport: | 11335 | case IrInstructionIdImport: |
| ... | @@ -11591,7 +11540,6 @@ bool ir_has_side_effects(IrInstruction *instruction) { | ... | @@ -11591,7 +11540,6 @@ bool ir_has_side_effects(IrInstruction *instruction) { |
| 11591 | case IrInstructionIdSwitchVar: | 11540 | case IrInstructionIdSwitchVar: |
| 11592 | case IrInstructionIdSwitchTarget: | 11541 | case IrInstructionIdSwitchTarget: |
| 11593 | case IrInstructionIdEnumTag: | 11542 | case IrInstructionIdEnumTag: |
| 11594 | case IrInstructionIdStaticEval: | | |
| 11595 | case IrInstructionIdGeneratedCode: | 11543 | case IrInstructionIdGeneratedCode: |
| 11596 | case IrInstructionIdRef: | 11544 | case IrInstructionIdRef: |
| 11597 | case IrInstructionIdMinValue: | 11545 | case IrInstructionIdMinValue: |