| ... | @@ -549,6 +549,10 @@ static constexpr IrInstructionId ir_instruction_id(IrInstructionTypeId *) { | ... | @@ -549,6 +549,10 @@ static constexpr IrInstructionId ir_instruction_id(IrInstructionTypeId *) { |
| 549 | return IrInstructionIdTypeId; | 549 | return IrInstructionIdTypeId; |
| 550 | } | 550 | } |
| 551 | | 551 | |
| | 552 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSetEvalBranchQuota *) { |
| | 553 | return IrInstructionIdSetEvalBranchQuota; |
| | 554 | } |
| | 555 | |
| 552 | template<typename T> | 556 | template<typename T> |
| 553 | static T *ir_create_instruction(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 557 | static T *ir_create_instruction(IrBuilder *irb, Scope *scope, AstNode *source_node) { |
| 554 | T *special_instruction = allocate<T>(1); | 558 | T *special_instruction = allocate<T>(1); |
| ... | @@ -2192,6 +2196,17 @@ static IrInstruction *ir_build_type_id(IrBuilder *irb, Scope *scope, AstNode *so | ... | @@ -2192,6 +2196,17 @@ static IrInstruction *ir_build_type_id(IrBuilder *irb, Scope *scope, AstNode *so |
| 2192 | return &instruction->base; | 2196 | return &instruction->base; |
| 2193 | } | 2197 | } |
| 2194 | | 2198 | |
| | 2199 | static IrInstruction *ir_build_set_eval_branch_quota(IrBuilder *irb, Scope *scope, AstNode *source_node, |
| | 2200 | IrInstruction *new_quota) |
| | 2201 | { |
| | 2202 | IrInstructionSetEvalBranchQuota *instruction = ir_build_instruction<IrInstructionSetEvalBranchQuota>(irb, scope, source_node); |
| | 2203 | instruction->new_quota = new_quota; |
| | 2204 | |
| | 2205 | ir_ref_instruction(new_quota, irb->current_basic_block); |
| | 2206 | |
| | 2207 | return &instruction->base; |
| | 2208 | } |
| | 2209 | |
| 2195 | static IrInstruction *ir_instruction_br_get_dep(IrInstructionBr *instruction, size_t index) { | 2210 | static IrInstruction *ir_instruction_br_get_dep(IrInstructionBr *instruction, size_t index) { |
| 2196 | return nullptr; | 2211 | return nullptr; |
| 2197 | } | 2212 | } |
| ... | @@ -2881,6 +2896,13 @@ static IrInstruction *ir_instruction_typeid_get_dep(IrInstructionTypeId *instruc | ... | @@ -2881,6 +2896,13 @@ static IrInstruction *ir_instruction_typeid_get_dep(IrInstructionTypeId *instruc |
| 2881 | } | 2896 | } |
| 2882 | } | 2897 | } |
| 2883 | | 2898 | |
| | 2899 | static IrInstruction *ir_instruction_setevalbranchquota_get_dep(IrInstructionSetEvalBranchQuota *instruction, size_t index) { |
| | 2900 | switch (index) { |
| | 2901 | case 0: return instruction->new_quota; |
| | 2902 | default: return nullptr; |
| | 2903 | } |
| | 2904 | } |
| | 2905 | |
| 2884 | static IrInstruction *ir_instruction_get_dep(IrInstruction *instruction, size_t index) { | 2906 | static IrInstruction *ir_instruction_get_dep(IrInstruction *instruction, size_t index) { |
| 2885 | switch (instruction->id) { | 2907 | switch (instruction->id) { |
| 2886 | case IrInstructionIdInvalid: | 2908 | case IrInstructionIdInvalid: |
| ... | @@ -3075,6 +3097,8 @@ static IrInstruction *ir_instruction_get_dep(IrInstruction *instruction, size_t | ... | @@ -3075,6 +3097,8 @@ static IrInstruction *ir_instruction_get_dep(IrInstruction *instruction, size_t |
| 3075 | return ir_instruction_offsetof_get_dep((IrInstructionOffsetOf *) instruction, index); | 3097 | return ir_instruction_offsetof_get_dep((IrInstructionOffsetOf *) instruction, index); |
| 3076 | case IrInstructionIdTypeId: | 3098 | case IrInstructionIdTypeId: |
| 3077 | return ir_instruction_typeid_get_dep((IrInstructionTypeId *) instruction, index); | 3099 | return ir_instruction_typeid_get_dep((IrInstructionTypeId *) instruction, index); |
| | 3100 | case IrInstructionIdSetEvalBranchQuota: |
| | 3101 | return ir_instruction_setevalbranchquota_get_dep((IrInstructionSetEvalBranchQuota *) instruction, index); |
| 3078 | } | 3102 | } |
| 3079 | zig_unreachable(); | 3103 | zig_unreachable(); |
| 3080 | } | 3104 | } |
| ... | @@ -4481,6 +4505,15 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4481,6 +4505,15 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4481 | | 4505 | |
| 4482 | return ir_build_bin_op(irb, scope, node, IrBinOpBitShiftRightExact, arg0_value, arg1_value, true); | 4506 | return ir_build_bin_op(irb, scope, node, IrBinOpBitShiftRightExact, arg0_value, arg1_value, true); |
| 4483 | } | 4507 | } |
| | 4508 | case BuiltinFnIdSetEvalBranchQuota: |
| | 4509 | { |
| | 4510 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| | 4511 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| | 4512 | if (arg0_value == irb->codegen->invalid_instruction) |
| | 4513 | return arg0_value; |
| | 4514 | |
| | 4515 | return ir_build_set_eval_branch_quota(irb, scope, node, arg0_value); |
| | 4516 | } |
| 4484 | } | 4517 | } |
| 4485 | zig_unreachable(); | 4518 | zig_unreachable(); |
| 4486 | } | 4519 | } |
| ... | @@ -12432,6 +12465,21 @@ static TypeTableEntry *ir_analyze_instruction_type_id(IrAnalyze *ira, | ... | @@ -12432,6 +12465,21 @@ static TypeTableEntry *ir_analyze_instruction_type_id(IrAnalyze *ira, |
| 12432 | return result_type; | 12465 | return result_type; |
| 12433 | } | 12466 | } |
| 12434 | | 12467 | |
| | 12468 | static TypeTableEntry *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ira, |
| | 12469 | IrInstructionSetEvalBranchQuota *instruction) |
| | 12470 | { |
| | 12471 | uint64_t new_quota; |
| | 12472 | if (!ir_resolve_usize(ira, instruction->new_quota->other, &new_quota)) |
| | 12473 | return ira->codegen->builtin_types.entry_invalid; |
| | 12474 | |
| | 12475 | if (new_quota > ira->new_irb.exec->backward_branch_quota) { |
| | 12476 | ira->new_irb.exec->backward_branch_quota = new_quota; |
| | 12477 | } |
| | 12478 | |
| | 12479 | ir_build_const_from(ira, &instruction->base); |
| | 12480 | return ira->codegen->builtin_types.entry_void; |
| | 12481 | } |
| | 12482 | |
| 12435 | static TypeTableEntry *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstructionTypeName *instruction) { | 12483 | static TypeTableEntry *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstructionTypeName *instruction) { |
| 12436 | IrInstruction *type_value = instruction->type_value->other; | 12484 | IrInstruction *type_value = instruction->type_value->other; |
| 12437 | TypeTableEntry *type_entry = ir_resolve_type(ira, type_value); | 12485 | TypeTableEntry *type_entry = ir_resolve_type(ira, type_value); |
| ... | @@ -14249,6 +14297,8 @@ static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstructi | ... | @@ -14249,6 +14297,8 @@ static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstructi |
| 14249 | return ir_analyze_instruction_offset_of(ira, (IrInstructionOffsetOf *)instruction); | 14297 | return ir_analyze_instruction_offset_of(ira, (IrInstructionOffsetOf *)instruction); |
| 14250 | case IrInstructionIdTypeId: | 14298 | case IrInstructionIdTypeId: |
| 14251 | return ir_analyze_instruction_type_id(ira, (IrInstructionTypeId *)instruction); | 14299 | return ir_analyze_instruction_type_id(ira, (IrInstructionTypeId *)instruction); |
| | 14300 | case IrInstructionIdSetEvalBranchQuota: |
| | 14301 | return ir_analyze_instruction_set_eval_branch_quota(ira, (IrInstructionSetEvalBranchQuota *)instruction); |
| 14252 | case IrInstructionIdMaybeWrap: | 14302 | case IrInstructionIdMaybeWrap: |
| 14253 | case IrInstructionIdErrWrapCode: | 14303 | case IrInstructionIdErrWrapCode: |
| 14254 | case IrInstructionIdErrWrapPayload: | 14304 | case IrInstructionIdErrWrapPayload: |
| ... | @@ -14365,6 +14415,7 @@ bool ir_has_side_effects(IrInstruction *instruction) { | ... | @@ -14365,6 +14415,7 @@ bool ir_has_side_effects(IrInstruction *instruction) { |
| 14365 | case IrInstructionIdSetGlobalSection: | 14415 | case IrInstructionIdSetGlobalSection: |
| 14366 | case IrInstructionIdSetGlobalLinkage: | 14416 | case IrInstructionIdSetGlobalLinkage: |
| 14367 | case IrInstructionIdPanic: | 14417 | case IrInstructionIdPanic: |
| | 14418 | case IrInstructionIdSetEvalBranchQuota: |
| 14368 | return true; | 14419 | return true; |
| 14369 | case IrInstructionIdPhi: | 14420 | case IrInstructionIdPhi: |
| 14370 | case IrInstructionIdUnOp: | 14421 | case IrInstructionIdUnOp: |