authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-27 20:36:37-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-28 12:58:40-07:00
log2440c08ab02f7d7b82deb3bd4eeaafb33483307f
tree7240e634a8d193b914bbb099a0432f1ca208f0c9
parentb11ac9c5bfb4048eb4aa561f8b3b058a76787f7e

stage1: move next_debug_id from Stage1Zir to IrBuilderSrc

Part of an effort to make Stage1Zir immutable.

2 files changed, 9 insertions(+), 10 deletions(-)

src/stage1/all_types.hpp-2
......@@ -114,8 +114,6 @@ struct Stage1Zir {
114114 ZigList<IrBasicBlockSrc *> basic_block_list;
115115 Buf *name;
116116 ZigFn *name_fn;
117 size_t mem_slot_count;
118 size_t next_debug_id;
119117 ZigFn *fn_entry;
120118 Buf *c_import_buf;
121119 AstNode *source_node;
src/stage1/astgen.cpp+9-8
......@@ -16,6 +16,7 @@ struct IrBuilderSrc {
1616 Stage1Zir *exec;
1717 IrBasicBlockSrc *current_basic_block;
1818 AstNode *main_block_node;
19 size_t next_debug_id;
1920};
2021
2122static IrInstSrc *ir_gen_node(IrBuilderSrc *irb, AstNode *node, Scope *scope);
......@@ -361,9 +362,9 @@ static void ir_instruction_append(IrBasicBlockSrc *basic_block, IrInstSrc *instr
361362 basic_block->instruction_list.append(instruction);
362363}
363364
364static size_t exec_next_debug_id(Stage1Zir *exec) {
365 size_t result = exec->next_debug_id;
366 exec->next_debug_id += 1;
365static size_t irb_next_debug_id(IrBuilderSrc *irb) {
366 size_t result = irb->next_debug_id;
367 irb->next_debug_id += 1;
367368 return result;
368369}
369370
......@@ -393,7 +394,7 @@ static IrBasicBlockSrc *ir_create_basic_block(IrBuilderSrc *irb, Scope *scope, c
393394 IrBasicBlockSrc *result = heap::c_allocator.create<IrBasicBlockSrc>();
394395 result->scope = scope;
395396 result->name_hint = name_hint;
396 result->debug_id = exec_next_debug_id(irb->exec);
397 result->debug_id = irb_next_debug_id(irb);
397398 result->index = UINT32_MAX; // set later
398399 return result;
399400}
......@@ -936,7 +937,7 @@ static T *ir_create_instruction(IrBuilderSrc *irb, Scope *scope, AstNode *source
936937 special_instruction->base.id = ir_inst_id(special_instruction);
937938 special_instruction->base.base.scope = scope;
938939 special_instruction->base.base.source_node = source_node;
939 special_instruction->base.base.debug_id = exec_next_debug_id(irb->exec);
940 special_instruction->base.base.debug_id = irb_next_debug_id(irb);
940941 special_instruction->base.owner_bb = irb->current_basic_block;
941942 return special_instruction;
942943}
......@@ -1325,7 +1326,7 @@ static IrInstSrc *ir_build_ptr_type_simple(IrBuilderSrc *irb, Scope *scope, AstN
13251326 inst->base.id = is_const ? IrInstSrcIdPtrTypeSimpleConst : IrInstSrcIdPtrTypeSimple;
13261327 inst->base.base.scope = scope;
13271328 inst->base.base.source_node = source_node;
1328 inst->base.base.debug_id = exec_next_debug_id(irb->exec);
1329 inst->base.base.debug_id = irb_next_debug_id(irb);
13291330 inst->base.owner_bb = irb->current_basic_block;
13301331 ir_instruction_append(irb->current_basic_block, &inst->base);
13311332
......@@ -2393,7 +2394,7 @@ static IrInstSrc *ir_build_check_switch_prongs(IrBuilderSrc *irb, Scope *scope,
23932394 IrInstSrcIdCheckSwitchProngsUnderYes : IrInstSrcIdCheckSwitchProngsUnderNo;
23942395 instruction->base.base.scope = scope;
23952396 instruction->base.base.source_node = source_node;
2396 instruction->base.base.debug_id = exec_next_debug_id(irb->exec);
2397 instruction->base.base.debug_id = irb_next_debug_id(irb);
23972398 instruction->base.owner_bb = irb->current_basic_block;
23982399 ir_instruction_append(irb->current_basic_block, &instruction->base);
23992400
......@@ -2586,7 +2587,7 @@ static IrInstSrc *ir_build_arg_type(IrBuilderSrc *irb, Scope *scope, AstNode *so
25862587 IrInstSrcIdArgTypeAllowVarTrue : IrInstSrcIdArgTypeAllowVarFalse;
25872588 instruction->base.base.scope = scope;
25882589 instruction->base.base.source_node = source_node;
2589 instruction->base.base.debug_id = exec_next_debug_id(irb->exec);
2590 instruction->base.base.debug_id = irb_next_debug_id(irb);
25902591 instruction->base.owner_bb = irb->current_basic_block;
25912592 ir_instruction_append(irb->current_basic_block, &instruction->base);
25922593