| ... | @@ -168,6 +168,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -168,6 +168,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 168 | static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, ZigVar *var); | 168 | static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, ZigVar *var); |
| 169 | static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op); | 169 | static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op); |
| 170 | static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction *value, LVal lval, ResultLoc *result_loc); | 170 | static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction *value, LVal lval, ResultLoc *result_loc); |
| | 171 | static IrInstruction *ir_expr_wrap(IrBuilder *irb, Scope *scope, IrInstruction *inst, ResultLoc *result_loc); |
| 171 | static ZigType *adjust_ptr_align(CodeGen *g, ZigType *ptr_type, uint32_t new_align); | 172 | static ZigType *adjust_ptr_align(CodeGen *g, ZigType *ptr_type, uint32_t new_align); |
| 172 | static ZigType *adjust_slice_align(CodeGen *g, ZigType *slice_type, uint32_t new_align); | 173 | static ZigType *adjust_slice_align(CodeGen *g, ZigType *slice_type, uint32_t new_align); |
| 173 | static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, uint8_t *buf, ConstExprValue *val); | 174 | static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, uint8_t *buf, ConstExprValue *val); |
| ... | @@ -4011,7 +4012,7 @@ static void populate_invalid_variable_in_scope(CodeGen *g, Scope *scope, AstNode | ... | @@ -4011,7 +4012,7 @@ static void populate_invalid_variable_in_scope(CodeGen *g, Scope *scope, AstNode |
| 4011 | scope_decls->decl_table.put(var_name, &tld_var->base); | 4012 | scope_decls->decl_table.put(var_name, &tld_var->base); |
| 4012 | } | 4013 | } |
| 4013 | | 4014 | |
| 4014 | static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval) { | 4015 | static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { |
| 4015 | Error err; | 4016 | Error err; |
| 4016 | assert(node->type == NodeTypeSymbol); | 4017 | assert(node->type == NodeTypeSymbol); |
| 4017 | | 4018 | |
| ... | @@ -4053,10 +4054,11 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4053,10 +4054,11 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4053 | ZigVar *var = find_variable(irb->codegen, scope, variable_name, &crossed_fndef_scope); | 4054 | ZigVar *var = find_variable(irb->codegen, scope, variable_name, &crossed_fndef_scope); |
| 4054 | if (var) { | 4055 | if (var) { |
| 4055 | IrInstruction *var_ptr = ir_build_var_ptr_x(irb, scope, node, var, crossed_fndef_scope); | 4056 | IrInstruction *var_ptr = ir_build_var_ptr_x(irb, scope, node, var, crossed_fndef_scope); |
| 4056 | if (lval == LValPtr) | 4057 | if (lval == LValPtr) { |
| 4057 | return var_ptr; | 4058 | return var_ptr; |
| 4058 | else | 4059 | } else { |
| 4059 | return ir_build_load_ptr(irb, scope, node, var_ptr); | 4060 | return ir_expr_wrap(irb, scope, ir_build_load_ptr(irb, scope, node, var_ptr), result_loc); |
| | 4061 | } |
| 4060 | } | 4062 | } |
| 4061 | | 4063 | |
| 4062 | Tld *tld = find_decl(irb->codegen, scope, variable_name); | 4064 | Tld *tld = find_decl(irb->codegen, scope, variable_name); |
| ... | @@ -5389,6 +5391,12 @@ static IrInstruction *ir_gen_prefix_op_id(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -5389,6 +5391,12 @@ static IrInstruction *ir_gen_prefix_op_id(IrBuilder *irb, Scope *scope, AstNode |
| 5389 | return ir_gen_prefix_op_id_lval(irb, scope, node, op_id, LValNone); | 5391 | return ir_gen_prefix_op_id_lval(irb, scope, node, op_id, LValNone); |
| 5390 | } | 5392 | } |
| 5391 | | 5393 | |
| | 5394 | static IrInstruction *ir_expr_wrap(IrBuilder *irb, Scope *scope, IrInstruction *inst, ResultLoc *result_loc) { |
| | 5395 | // TODO remove the lval parameter here |
| | 5396 | ir_build_end_expr(irb, scope, inst->source_node, inst, LValNone, result_loc); |
| | 5397 | return inst; |
| | 5398 | } |
| | 5399 | |
| 5392 | static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction *value, LVal lval, | 5400 | static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction *value, LVal lval, |
| 5393 | ResultLoc *result_loc) | 5401 | ResultLoc *result_loc) |
| 5394 | { | 5402 | { |
| ... | @@ -5408,9 +5416,7 @@ static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction * | ... | @@ -5408,9 +5416,7 @@ static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction * |
| 5408 | return ir_build_ref(irb, scope, value->source_node, value, false, false); | 5416 | return ir_build_ref(irb, scope, value->source_node, value, false, false); |
| 5409 | } | 5417 | } |
| 5410 | | 5418 | |
| 5411 | // TODO remove the lval parameter here | 5419 | return ir_expr_wrap(irb, scope, value, result_loc); |
| 5412 | ir_build_end_expr(irb, scope, value->source_node, value, lval, result_loc); | | |
| 5413 | return value; | | |
| 5414 | } | 5420 | } |
| 5415 | | 5421 | |
| 5416 | static PtrLen star_token_to_ptr_len(TokenId token_id) { | 5422 | static PtrLen star_token_to_ptr_len(TokenId token_id) { |
| ... | @@ -7747,7 +7753,7 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop | ... | @@ -7747,7 +7753,7 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop |
| 7747 | case NodeTypeCharLiteral: | 7753 | case NodeTypeCharLiteral: |
| 7748 | return ir_lval_wrap(irb, scope, ir_gen_char_lit(irb, scope, node), lval, result_loc); | 7754 | return ir_lval_wrap(irb, scope, ir_gen_char_lit(irb, scope, node), lval, result_loc); |
| 7749 | case NodeTypeSymbol: | 7755 | case NodeTypeSymbol: |
| 7750 | return ir_gen_symbol(irb, scope, node, lval); | 7756 | return ir_gen_symbol(irb, scope, node, lval, result_loc); |
| 7751 | case NodeTypeFnCallExpr: | 7757 | case NodeTypeFnCallExpr: |
| 7752 | return ir_gen_fn_call(irb, scope, node, lval, result_loc); | 7758 | return ir_gen_fn_call(irb, scope, node, lval, result_loc); |
| 7753 | case NodeTypeIfBoolExpr: | 7759 | case NodeTypeIfBoolExpr: |
| ... | @@ -14345,8 +14351,6 @@ static ZigType *ir_result_loc_expected_type(IrAnalyze *ira, ResultLoc *result_lo | ... | @@ -14345,8 +14351,6 @@ static ZigType *ir_result_loc_expected_type(IrAnalyze *ira, ResultLoc *result_lo |
| 14345 | static IrInstruction *ir_resolve_result(IrAnalyze *ira, ResultLoc *result_loc, ZigType *value_type, | 14351 | static IrInstruction *ir_resolve_result(IrAnalyze *ira, ResultLoc *result_loc, ZigType *value_type, |
| 14346 | IrInstruction *value) | 14352 | IrInstruction *value) |
| 14347 | { | 14353 | { |
| 14348 | bool is_comptime = value != nullptr && value->value.special != ConstValSpecialRuntime; | | |
| 14349 | | | |
| 14350 | result_loc->gen_instruction = value; | 14354 | result_loc->gen_instruction = value; |
| 14351 | result_loc->implicit_elem_type = value_type; | 14355 | result_loc->implicit_elem_type = value_type; |
| 14352 | switch (result_loc->id) { | 14356 | switch (result_loc->id) { |
| ... | @@ -14357,10 +14361,12 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, ResultLoc *result_loc, Z | ... | @@ -14357,10 +14361,12 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, ResultLoc *result_loc, Z |
| 14357 | return nullptr; | 14361 | return nullptr; |
| 14358 | case ResultLocIdVar: { | 14362 | case ResultLocIdVar: { |
| 14359 | // TODO implicit cast? | 14363 | // TODO implicit cast? |
| 14360 | //ResultLocVar *result_loc_var = reinterpret_cast<ResultLocVar *>(result_loc); | 14364 | ResultLocVar *result_loc_var = reinterpret_cast<ResultLocVar *>(result_loc); |
| 14361 | assert(result_loc->source_instruction->id == IrInstructionIdAllocaSrc); | 14365 | assert(result_loc->source_instruction->id == IrInstructionIdAllocaSrc); |
| 14362 | IrInstructionAllocaSrc *alloca_src = | 14366 | IrInstructionAllocaSrc *alloca_src = |
| 14363 | reinterpret_cast<IrInstructionAllocaSrc *>(result_loc->source_instruction); | 14367 | reinterpret_cast<IrInstructionAllocaSrc *>(result_loc->source_instruction); |
| | 14368 | bool is_comptime = value != nullptr && value->value.special != ConstValSpecialRuntime && |
| | 14369 | result_loc_var->var->gen_is_const; |
| 14364 | if (alloca_src->base.child == nullptr) { | 14370 | if (alloca_src->base.child == nullptr) { |
| 14365 | uint32_t align = 0; // TODO | 14371 | uint32_t align = 0; // TODO |
| 14366 | bool force_comptime = false; // TODO | 14372 | bool force_comptime = false; // TODO |