| ... | @@ -391,6 +391,10 @@ static constexpr IrInstructionId ir_instruction_id(IrInstructionMemberCount *) { | ... | @@ -391,6 +391,10 @@ static constexpr IrInstructionId ir_instruction_id(IrInstructionMemberCount *) { |
| 391 | return IrInstructionIdMemberCount; | 391 | return IrInstructionIdMemberCount; |
| 392 | } | 392 | } |
| 393 | | 393 | |
| | 394 | static constexpr IrInstructionId ir_instruction_id(IrInstructionBreakpoint *) { |
| | 395 | return IrInstructionIdBreakpoint; |
| | 396 | } |
| | 397 | |
| 394 | template<typename T> | 398 | template<typename T> |
| 395 | static T *ir_create_instruction(IrExecutable *exec, Scope *scope, AstNode *source_node) { | 399 | static T *ir_create_instruction(IrExecutable *exec, Scope *scope, AstNode *source_node) { |
| 396 | T *special_instruction = allocate<T>(1); | 400 | T *special_instruction = allocate<T>(1); |
| ... | @@ -1609,6 +1613,17 @@ static IrInstruction *ir_build_member_count(IrBuilder *irb, Scope *scope, AstNod | ... | @@ -1609,6 +1613,17 @@ static IrInstruction *ir_build_member_count(IrBuilder *irb, Scope *scope, AstNod |
| 1609 | return &instruction->base; | 1613 | return &instruction->base; |
| 1610 | } | 1614 | } |
| 1611 | | 1615 | |
| | 1616 | static IrInstruction *ir_build_breakpoint(IrBuilder *irb, Scope *scope, AstNode *source_node) { |
| | 1617 | IrInstructionBreakpoint *instruction = ir_build_instruction<IrInstructionBreakpoint>(irb, scope, source_node); |
| | 1618 | return &instruction->base; |
| | 1619 | } |
| | 1620 | |
| | 1621 | static IrInstruction *ir_build_breakpoint_from(IrBuilder *irb, IrInstruction *old_instruction) { |
| | 1622 | IrInstruction *new_instruction = ir_build_breakpoint(irb, old_instruction->scope, old_instruction->source_node); |
| | 1623 | ir_link_new_instruction(new_instruction, old_instruction); |
| | 1624 | return new_instruction; |
| | 1625 | } |
| | 1626 | |
| 1612 | static void ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *outer_scope, | 1627 | static void ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *outer_scope, |
| 1613 | bool gen_error_defers, bool gen_maybe_defers) | 1628 | bool gen_error_defers, bool gen_maybe_defers) |
| 1614 | { | 1629 | { |
| ... | @@ -2491,12 +2506,13 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -2491,12 +2506,13 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 2491 | | 2506 | |
| 2492 | return ir_build_member_count(irb, scope, node, arg0_value); | 2507 | return ir_build_member_count(irb, scope, node, arg0_value); |
| 2493 | } | 2508 | } |
| | 2509 | case BuiltinFnIdBreakpoint: |
| | 2510 | return ir_build_breakpoint(irb, scope, node); |
| 2494 | case BuiltinFnIdAlignof: | 2511 | case BuiltinFnIdAlignof: |
| 2495 | case BuiltinFnIdAddWithOverflow: | 2512 | case BuiltinFnIdAddWithOverflow: |
| 2496 | case BuiltinFnIdSubWithOverflow: | 2513 | case BuiltinFnIdSubWithOverflow: |
| 2497 | case BuiltinFnIdMulWithOverflow: | 2514 | case BuiltinFnIdMulWithOverflow: |
| 2498 | case BuiltinFnIdShlWithOverflow: | 2515 | case BuiltinFnIdShlWithOverflow: |
| 2499 | case BuiltinFnIdBreakpoint: | | |
| 2500 | case BuiltinFnIdReturnAddress: | 2516 | case BuiltinFnIdReturnAddress: |
| 2501 | case BuiltinFnIdFrameAddress: | 2517 | case BuiltinFnIdFrameAddress: |
| 2502 | zig_panic("TODO IR gen more builtin functions"); | 2518 | zig_panic("TODO IR gen more builtin functions"); |
| ... | @@ -8456,6 +8472,11 @@ static TypeTableEntry *ir_analyze_instruction_member_count(IrAnalyze *ira, IrIns | ... | @@ -8456,6 +8472,11 @@ static TypeTableEntry *ir_analyze_instruction_member_count(IrAnalyze *ira, IrIns |
| 8456 | return ira->codegen->builtin_types.entry_num_lit_int; | 8472 | return ira->codegen->builtin_types.entry_num_lit_int; |
| 8457 | } | 8473 | } |
| 8458 | | 8474 | |
| | 8475 | static TypeTableEntry *ir_analyze_instruction_breakpoint(IrAnalyze *ira, IrInstructionBreakpoint *instruction) { |
| | 8476 | ir_build_breakpoint_from(&ira->new_irb, &instruction->base); |
| | 8477 | return ira->codegen->builtin_types.entry_void; |
| | 8478 | } |
| | 8479 | |
| 8459 | static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstruction *instruction) { | 8480 | static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstruction *instruction) { |
| 8460 | switch (instruction->id) { | 8481 | switch (instruction->id) { |
| 8461 | case IrInstructionIdInvalid: | 8482 | case IrInstructionIdInvalid: |
| ... | @@ -8580,6 +8601,8 @@ static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstructi | ... | @@ -8580,6 +8601,8 @@ static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstructi |
| 8580 | return ir_analyze_instruction_slice(ira, (IrInstructionSlice *)instruction); | 8601 | return ir_analyze_instruction_slice(ira, (IrInstructionSlice *)instruction); |
| 8581 | case IrInstructionIdMemberCount: | 8602 | case IrInstructionIdMemberCount: |
| 8582 | return ir_analyze_instruction_member_count(ira, (IrInstructionMemberCount *)instruction); | 8603 | return ir_analyze_instruction_member_count(ira, (IrInstructionMemberCount *)instruction); |
| | 8604 | case IrInstructionIdBreakpoint: |
| | 8605 | return ir_analyze_instruction_breakpoint(ira, (IrInstructionBreakpoint *)instruction); |
| 8583 | case IrInstructionIdCast: | 8606 | case IrInstructionIdCast: |
| 8584 | case IrInstructionIdStructFieldPtr: | 8607 | case IrInstructionIdStructFieldPtr: |
| 8585 | case IrInstructionIdEnumFieldPtr: | 8608 | case IrInstructionIdEnumFieldPtr: |
| ... | @@ -8683,6 +8706,7 @@ bool ir_has_side_effects(IrInstruction *instruction) { | ... | @@ -8683,6 +8706,7 @@ bool ir_has_side_effects(IrInstruction *instruction) { |
| 8683 | case IrInstructionIdFence: | 8706 | case IrInstructionIdFence: |
| 8684 | case IrInstructionIdMemset: | 8707 | case IrInstructionIdMemset: |
| 8685 | case IrInstructionIdMemcpy: | 8708 | case IrInstructionIdMemcpy: |
| | 8709 | case IrInstructionIdBreakpoint: |
| 8686 | return true; | 8710 | return true; |
| 8687 | case IrInstructionIdPhi: | 8711 | case IrInstructionIdPhi: |
| 8688 | case IrInstructionIdUnOp: | 8712 | case IrInstructionIdUnOp: |
| ... | @@ -8787,9 +8811,6 @@ bool ir_has_side_effects(IrInstruction *instruction) { | ... | @@ -8787,9 +8811,6 @@ bool ir_has_side_effects(IrInstruction *instruction) { |
| 8787 | // align_in_bytes, false); | 8811 | // align_in_bytes, false); |
| 8788 | // } | 8812 | // } |
| 8789 | // } | 8813 | // } |
| 8790 | // case BuiltinFnIdBreakpoint: | | |
| 8791 | // mark_impure_fn(g, context, node); | | |
| 8792 | // return g->builtin_types.entry_void; | | |
| 8793 | // case BuiltinFnIdReturnAddress: | 8814 | // case BuiltinFnIdReturnAddress: |
| 8794 | // case BuiltinFnIdFrameAddress: | 8815 | // case BuiltinFnIdFrameAddress: |
| 8795 | // mark_impure_fn(g, context, node); | 8816 | // mark_impure_fn(g, context, node); |
| ... | @@ -9035,8 +9056,6 @@ bool ir_has_side_effects(IrInstruction *instruction) { | ... | @@ -9035,8 +9056,6 @@ bool ir_has_side_effects(IrInstruction *instruction) { |
| 9035 | // zig_unreachable(); | 9056 | // zig_unreachable(); |
| 9036 | // case BuiltinFnIdCompileVar: | 9057 | // case BuiltinFnIdCompileVar: |
| 9037 | // return nullptr; | 9058 | // return nullptr; |
| 9038 | // case BuiltinFnIdBreakpoint: | | |
| 9039 | // return LLVMBuildCall(g->builder, g->trap_fn_val, nullptr, 0, ""); | | |
| 9040 | // case BuiltinFnIdFrameAddress: | 9059 | // case BuiltinFnIdFrameAddress: |
| 9041 | // case BuiltinFnIdReturnAddress: | 9060 | // case BuiltinFnIdReturnAddress: |
| 9042 | // { | 9061 | // { |