| ... | @@ -64,8 +64,16 @@ ConstExprValue *const_ptr_pointee(ConstExprValue *const_val) { | ... | @@ -64,8 +64,16 @@ ConstExprValue *const_ptr_pointee(ConstExprValue *const_val) { |
| 64 | } | 64 | } |
| 65 | } | 65 | } |
| 66 | | 66 | |
| 67 | static bool ir_should_inline(IrBuilder *irb) { | 67 | static bool ir_should_inline(IrExecutable *exec, Scope *scope) { |
| 68 | return irb->exec->is_inline; | 68 | if (exec->is_inline) |
| | 69 | return true; |
| | 70 | |
| | 71 | while (scope != nullptr) { |
| | 72 | if (scope->id == ScopeIdCompTime) |
| | 73 | return true; |
| | 74 | scope = scope->parent; |
| | 75 | } |
| | 76 | return false; |
| 69 | } | 77 | } |
| 70 | | 78 | |
| 71 | static void ir_instruction_append(IrBasicBlock *basic_block, IrInstruction *instruction) { | 79 | static void ir_instruction_append(IrBasicBlock *basic_block, IrInstruction *instruction) { |
| ... | @@ -2904,7 +2912,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -2904,7 +2912,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, |
| 2904 | IrInstruction *is_err = ir_build_test_err(irb, scope, node, return_value); | 2912 | IrInstruction *is_err = ir_build_test_err(irb, scope, node, return_value); |
| 2905 | | 2913 | |
| 2906 | IrInstruction *is_comptime; | 2914 | IrInstruction *is_comptime; |
| 2907 | if (ir_should_inline(irb)) { | 2915 | if (ir_should_inline(irb->exec, scope)) { |
| 2908 | is_comptime = ir_build_const_bool(irb, scope, node, true); | 2916 | is_comptime = ir_build_const_bool(irb, scope, node, true); |
| 2909 | } else { | 2917 | } else { |
| 2910 | is_comptime = ir_build_test_comptime(irb, scope, node, is_err); | 2918 | is_comptime = ir_build_test_comptime(irb, scope, node, is_err); |
| ... | @@ -2926,7 +2934,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -2926,7 +2934,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, |
| 2926 | IrInstruction *is_non_null = ir_build_test_nonnull(irb, scope, node, return_value); | 2934 | IrInstruction *is_non_null = ir_build_test_nonnull(irb, scope, node, return_value); |
| 2927 | | 2935 | |
| 2928 | IrInstruction *is_comptime; | 2936 | IrInstruction *is_comptime; |
| 2929 | if (ir_should_inline(irb)) { | 2937 | if (ir_should_inline(irb->exec, scope)) { |
| 2930 | is_comptime = ir_build_const_bool(irb, scope, node, true); | 2938 | is_comptime = ir_build_const_bool(irb, scope, node, true); |
| 2931 | } else { | 2939 | } else { |
| 2932 | is_comptime = ir_build_test_comptime(irb, scope, node, is_non_null); | 2940 | is_comptime = ir_build_test_comptime(irb, scope, node, is_non_null); |
| ... | @@ -2958,7 +2966,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -2958,7 +2966,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, |
| 2958 | | 2966 | |
| 2959 | IrBasicBlock *return_block = ir_build_basic_block(irb, scope, "ErrRetReturn"); | 2967 | IrBasicBlock *return_block = ir_build_basic_block(irb, scope, "ErrRetReturn"); |
| 2960 | IrBasicBlock *continue_block = ir_build_basic_block(irb, scope, "ErrRetContinue"); | 2968 | IrBasicBlock *continue_block = ir_build_basic_block(irb, scope, "ErrRetContinue"); |
| 2961 | IrInstruction *is_comptime = ir_build_const_bool(irb, scope, node, ir_should_inline(irb)); | 2969 | IrInstruction *is_comptime = ir_build_const_bool(irb, scope, node, ir_should_inline(irb->exec, scope)); |
| 2962 | ir_mark_gen(ir_build_cond_br(irb, scope, node, is_err_val, return_block, continue_block, is_comptime)); | 2970 | ir_mark_gen(ir_build_cond_br(irb, scope, node, is_err_val, return_block, continue_block, is_comptime)); |
| 2963 | | 2971 | |
| 2964 | ir_set_cursor_at_end(irb, return_block); | 2972 | ir_set_cursor_at_end(irb, return_block); |
| ... | @@ -2984,7 +2992,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -2984,7 +2992,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, |
| 2984 | | 2992 | |
| 2985 | IrBasicBlock *return_block = ir_build_basic_block(irb, scope, "MaybeRetReturn"); | 2993 | IrBasicBlock *return_block = ir_build_basic_block(irb, scope, "MaybeRetReturn"); |
| 2986 | IrBasicBlock *continue_block = ir_build_basic_block(irb, scope, "MaybeRetContinue"); | 2994 | IrBasicBlock *continue_block = ir_build_basic_block(irb, scope, "MaybeRetContinue"); |
| 2987 | IrInstruction *is_comptime = ir_build_const_bool(irb, scope, node, ir_should_inline(irb)); | 2995 | IrInstruction *is_comptime = ir_build_const_bool(irb, scope, node, ir_should_inline(irb->exec, scope)); |
| 2988 | ir_mark_gen(ir_build_cond_br(irb, scope, node, is_non_null, continue_block, return_block, is_comptime)); | 2996 | ir_mark_gen(ir_build_cond_br(irb, scope, node, is_non_null, continue_block, return_block, is_comptime)); |
| 2989 | | 2997 | |
| 2990 | ir_set_cursor_at_end(irb, return_block); | 2998 | ir_set_cursor_at_end(irb, return_block); |
| ... | @@ -3128,7 +3136,7 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode | ... | @@ -3128,7 +3136,7 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode |
| 3128 | | 3136 | |
| 3129 | if (!return_value || !instr_is_unreachable(return_value)) { | 3137 | if (!return_value || !instr_is_unreachable(return_value)) { |
| 3130 | IrInstruction *is_comptime = ir_mark_gen(ir_build_const_bool(irb, child_scope, statement_node, | 3138 | IrInstruction *is_comptime = ir_mark_gen(ir_build_const_bool(irb, child_scope, statement_node, |
| 3131 | ir_should_inline(irb))); | 3139 | ir_should_inline(irb->exec, child_scope))); |
| 3132 | ir_mark_gen(ir_build_br(irb, child_scope, statement_node, label_block, is_comptime)); | 3140 | ir_mark_gen(ir_build_br(irb, child_scope, statement_node, label_block, is_comptime)); |
| 3133 | } | 3141 | } |
| 3134 | ir_set_cursor_at_end(irb, label_block); | 3142 | ir_set_cursor_at_end(irb, label_block); |
| ... | @@ -3207,7 +3215,7 @@ static IrInstruction *ir_gen_bool_or(IrBuilder *irb, Scope *scope, AstNode *node | ... | @@ -3207,7 +3215,7 @@ static IrInstruction *ir_gen_bool_or(IrBuilder *irb, Scope *scope, AstNode *node |
| 3207 | IrBasicBlock *post_val1_block = irb->current_basic_block; | 3215 | IrBasicBlock *post_val1_block = irb->current_basic_block; |
| 3208 | | 3216 | |
| 3209 | IrInstruction *is_comptime; | 3217 | IrInstruction *is_comptime; |
| 3210 | if (ir_should_inline(irb)) { | 3218 | if (ir_should_inline(irb->exec, scope)) { |
| 3211 | is_comptime = ir_build_const_bool(irb, scope, node, true); | 3219 | is_comptime = ir_build_const_bool(irb, scope, node, true); |
| 3212 | } else { | 3220 | } else { |
| 3213 | is_comptime = ir_build_test_comptime(irb, scope, node, val1); | 3221 | is_comptime = ir_build_test_comptime(irb, scope, node, val1); |
| ... | @@ -3249,7 +3257,7 @@ static IrInstruction *ir_gen_bool_and(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -3249,7 +3257,7 @@ static IrInstruction *ir_gen_bool_and(IrBuilder *irb, Scope *scope, AstNode *nod |
| 3249 | IrBasicBlock *post_val1_block = irb->current_basic_block; | 3257 | IrBasicBlock *post_val1_block = irb->current_basic_block; |
| 3250 | | 3258 | |
| 3251 | IrInstruction *is_comptime; | 3259 | IrInstruction *is_comptime; |
| 3252 | if (ir_should_inline(irb)) { | 3260 | if (ir_should_inline(irb->exec, scope)) { |
| 3253 | is_comptime = ir_build_const_bool(irb, scope, node, true); | 3261 | is_comptime = ir_build_const_bool(irb, scope, node, true); |
| 3254 | } else { | 3262 | } else { |
| 3255 | is_comptime = ir_build_test_comptime(irb, scope, node, val1); | 3263 | is_comptime = ir_build_test_comptime(irb, scope, node, val1); |
| ... | @@ -3296,7 +3304,7 @@ static IrInstruction *ir_gen_maybe_ok_or(IrBuilder *irb, Scope *parent_scope, As | ... | @@ -3296,7 +3304,7 @@ static IrInstruction *ir_gen_maybe_ok_or(IrBuilder *irb, Scope *parent_scope, As |
| 3296 | IrInstruction *is_non_null = ir_build_test_nonnull(irb, parent_scope, node, maybe_val); | 3304 | IrInstruction *is_non_null = ir_build_test_nonnull(irb, parent_scope, node, maybe_val); |
| 3297 | | 3305 | |
| 3298 | IrInstruction *is_comptime; | 3306 | IrInstruction *is_comptime; |
| 3299 | if (ir_should_inline(irb)) { | 3307 | if (ir_should_inline(irb->exec, parent_scope)) { |
| 3300 | is_comptime = ir_build_const_bool(irb, parent_scope, node, true); | 3308 | is_comptime = ir_build_const_bool(irb, parent_scope, node, true); |
| 3301 | } else { | 3309 | } else { |
| 3302 | is_comptime = ir_build_test_comptime(irb, parent_scope, node, is_non_null); | 3310 | is_comptime = ir_build_test_comptime(irb, parent_scope, node, is_non_null); |
| ... | @@ -4042,8 +4050,7 @@ static IrInstruction *ir_gen_fn_call(IrBuilder *irb, Scope *scope, AstNode *node | ... | @@ -4042,8 +4050,7 @@ static IrInstruction *ir_gen_fn_call(IrBuilder *irb, Scope *scope, AstNode *node |
| 4042 | return args[i]; | 4050 | return args[i]; |
| 4043 | } | 4051 | } |
| 4044 | | 4052 | |
| 4045 | bool is_comptime = node->data.fn_call_expr.is_comptime; | 4053 | return ir_build_call(irb, scope, node, nullptr, fn_ref, arg_count, args, false); |
| 4046 | return ir_build_call(irb, scope, node, nullptr, fn_ref, arg_count, args, is_comptime); | | |
| 4047 | } | 4054 | } |
| 4048 | | 4055 | |
| 4049 | static IrInstruction *ir_gen_if_bool_expr(IrBuilder *irb, Scope *scope, AstNode *node) { | 4056 | static IrInstruction *ir_gen_if_bool_expr(IrBuilder *irb, Scope *scope, AstNode *node) { |
| ... | @@ -4054,7 +4061,7 @@ static IrInstruction *ir_gen_if_bool_expr(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -4054,7 +4061,7 @@ static IrInstruction *ir_gen_if_bool_expr(IrBuilder *irb, Scope *scope, AstNode |
| 4054 | return condition; | 4061 | return condition; |
| 4055 | | 4062 | |
| 4056 | IrInstruction *is_comptime; | 4063 | IrInstruction *is_comptime; |
| 4057 | if (ir_should_inline(irb) || node->data.if_bool_expr.is_inline) { | 4064 | if (ir_should_inline(irb->exec, scope) || node->data.if_bool_expr.is_inline) { |
| 4058 | is_comptime = ir_build_const_bool(irb, scope, node, true); | 4065 | is_comptime = ir_build_const_bool(irb, scope, node, true); |
| 4059 | } else { | 4066 | } else { |
| 4060 | is_comptime = ir_build_test_comptime(irb, scope, node, condition); | 4067 | is_comptime = ir_build_test_comptime(irb, scope, node, condition); |
| ... | @@ -4281,7 +4288,7 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -4281,7 +4288,7 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod |
| 4281 | bool is_const = variable_declaration->is_const; | 4288 | bool is_const = variable_declaration->is_const; |
| 4282 | bool is_extern = variable_declaration->is_extern; | 4289 | bool is_extern = variable_declaration->is_extern; |
| 4283 | IrInstruction *is_comptime = ir_build_const_bool(irb, scope, node, | 4290 | IrInstruction *is_comptime = ir_build_const_bool(irb, scope, node, |
| 4284 | ir_should_inline(irb) || variable_declaration->is_inline); | 4291 | ir_should_inline(irb->exec, scope) || variable_declaration->is_inline); |
| 4285 | VariableTableEntry *var = ir_create_var(irb, node, scope, variable_declaration->symbol, | 4292 | VariableTableEntry *var = ir_create_var(irb, node, scope, variable_declaration->symbol, |
| 4286 | is_const, is_const, is_shadowable, is_comptime); | 4293 | is_const, is_const, is_shadowable, is_comptime); |
| 4287 | // we detect IrInstructionIdDeclVar in gen_block to make sure the next node | 4294 | // we detect IrInstructionIdDeclVar in gen_block to make sure the next node |
| ... | @@ -4312,7 +4319,7 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -4312,7 +4319,7 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 4312 | IrBasicBlock *end_block = ir_build_basic_block(irb, scope, "WhileEnd"); | 4319 | IrBasicBlock *end_block = ir_build_basic_block(irb, scope, "WhileEnd"); |
| 4313 | | 4320 | |
| 4314 | IrInstruction *is_comptime = ir_build_const_bool(irb, scope, node, | 4321 | IrInstruction *is_comptime = ir_build_const_bool(irb, scope, node, |
| 4315 | ir_should_inline(irb) || node->data.while_expr.is_inline); | 4322 | ir_should_inline(irb->exec, scope) || node->data.while_expr.is_inline); |
| 4316 | ir_build_br(irb, scope, node, cond_block, is_comptime); | 4323 | ir_build_br(irb, scope, node, cond_block, is_comptime); |
| 4317 | | 4324 | |
| 4318 | if (continue_expr_node) { | 4325 | if (continue_expr_node) { |
| ... | @@ -4381,7 +4388,7 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo | ... | @@ -4381,7 +4388,7 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo |
| 4381 | } | 4388 | } |
| 4382 | | 4389 | |
| 4383 | IrInstruction *is_comptime = ir_build_const_bool(irb, parent_scope, node, | 4390 | IrInstruction *is_comptime = ir_build_const_bool(irb, parent_scope, node, |
| 4384 | ir_should_inline(irb) || node->data.for_expr.is_inline); | 4391 | ir_should_inline(irb->exec, parent_scope) || node->data.for_expr.is_inline); |
| 4385 | | 4392 | |
| 4386 | Scope *child_scope = create_loop_scope(node, parent_scope); | 4393 | Scope *child_scope = create_loop_scope(node, parent_scope); |
| 4387 | | 4394 | |
| ... | @@ -4602,7 +4609,7 @@ static IrInstruction *ir_gen_if_var_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -4602,7 +4609,7 @@ static IrInstruction *ir_gen_if_var_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 4602 | IrBasicBlock *endif_block = ir_build_basic_block(irb, scope, "MaybeEndIf"); | 4609 | IrBasicBlock *endif_block = ir_build_basic_block(irb, scope, "MaybeEndIf"); |
| 4603 | | 4610 | |
| 4604 | IrInstruction *is_comptime; | 4611 | IrInstruction *is_comptime; |
| 4605 | if (ir_should_inline(irb) || node->data.if_var_expr.is_inline) { | 4612 | if (ir_should_inline(irb->exec, scope) || node->data.if_var_expr.is_inline) { |
| 4606 | is_comptime = ir_build_const_bool(irb, scope, node, true); | 4613 | is_comptime = ir_build_const_bool(irb, scope, node, true); |
| 4607 | } else { | 4614 | } else { |
| 4608 | is_comptime = ir_build_test_comptime(irb, scope, node, is_non_null); | 4615 | is_comptime = ir_build_test_comptime(irb, scope, node, is_non_null); |
| ... | @@ -4714,7 +4721,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -4714,7 +4721,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 4714 | ZigList<IrInstructionSwitchBrCase> cases = {0}; | 4721 | ZigList<IrInstructionSwitchBrCase> cases = {0}; |
| 4715 | | 4722 | |
| 4716 | IrInstruction *is_comptime; | 4723 | IrInstruction *is_comptime; |
| 4717 | if (ir_should_inline(irb) || node->data.switch_expr.is_inline) { | 4724 | if (ir_should_inline(irb->exec, scope) || node->data.switch_expr.is_inline) { |
| 4718 | is_comptime = ir_build_const_bool(irb, scope, node, true); | 4725 | is_comptime = ir_build_const_bool(irb, scope, node, true); |
| 4719 | } else { | 4726 | } else { |
| 4720 | is_comptime = ir_build_test_comptime(irb, scope, node, target_value); | 4727 | is_comptime = ir_build_test_comptime(irb, scope, node, target_value); |
| ... | @@ -4892,6 +4899,13 @@ static IrInstruction *ir_gen_goto(IrBuilder *irb, Scope *scope, AstNode *node) { | ... | @@ -4892,6 +4899,13 @@ static IrInstruction *ir_gen_goto(IrBuilder *irb, Scope *scope, AstNode *node) { |
| 4892 | return ir_build_unreachable(irb, scope, node); | 4899 | return ir_build_unreachable(irb, scope, node); |
| 4893 | } | 4900 | } |
| 4894 | | 4901 | |
| | 4902 | static IrInstruction *ir_gen_comptime(IrBuilder *irb, Scope *parent_scope, AstNode *node, LValPurpose lval) { |
| | 4903 | assert(node->type == NodeTypeCompTime); |
| | 4904 | |
| | 4905 | Scope *child_scope = create_comptime_scope(node, parent_scope); |
| | 4906 | return ir_gen_node_extra(irb, node->data.comptime_expr.expr, child_scope, lval); |
| | 4907 | } |
| | 4908 | |
| 4895 | static IrInstruction *ir_gen_break(IrBuilder *irb, Scope *scope, AstNode *node) { | 4909 | static IrInstruction *ir_gen_break(IrBuilder *irb, Scope *scope, AstNode *node) { |
| 4896 | assert(node->type == NodeTypeBreak); | 4910 | assert(node->type == NodeTypeBreak); |
| 4897 | | 4911 | |
| ... | @@ -4904,7 +4918,7 @@ static IrInstruction *ir_gen_break(IrBuilder *irb, Scope *scope, AstNode *node) | ... | @@ -4904,7 +4918,7 @@ static IrInstruction *ir_gen_break(IrBuilder *irb, Scope *scope, AstNode *node) |
| 4904 | LoopStackItem *loop_stack_item = &irb->loop_stack.last(); | 4918 | LoopStackItem *loop_stack_item = &irb->loop_stack.last(); |
| 4905 | | 4919 | |
| 4906 | IrInstruction *is_comptime; | 4920 | IrInstruction *is_comptime; |
| 4907 | if (ir_should_inline(irb) || node->data.break_expr.is_inline) { | 4921 | if (ir_should_inline(irb->exec, scope) || node->data.break_expr.is_inline) { |
| 4908 | is_comptime = ir_build_const_bool(irb, scope, node, true); | 4922 | is_comptime = ir_build_const_bool(irb, scope, node, true); |
| 4909 | } else { | 4923 | } else { |
| 4910 | is_comptime = loop_stack_item->is_comptime; | 4924 | is_comptime = loop_stack_item->is_comptime; |
| ... | @@ -4927,7 +4941,7 @@ static IrInstruction *ir_gen_continue(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -4927,7 +4941,7 @@ static IrInstruction *ir_gen_continue(IrBuilder *irb, Scope *scope, AstNode *nod |
| 4927 | LoopStackItem *loop_stack_item = &irb->loop_stack.last(); | 4941 | LoopStackItem *loop_stack_item = &irb->loop_stack.last(); |
| 4928 | | 4942 | |
| 4929 | IrInstruction *is_comptime; | 4943 | IrInstruction *is_comptime; |
| 4930 | if (ir_should_inline(irb) || node->data.continue_expr.is_inline) { | 4944 | if (ir_should_inline(irb->exec, scope) || node->data.continue_expr.is_inline) { |
| 4931 | is_comptime = ir_build_const_bool(irb, scope, node, true); | 4945 | is_comptime = ir_build_const_bool(irb, scope, node, true); |
| 4932 | } else { | 4946 | } else { |
| 4933 | is_comptime = loop_stack_item->is_comptime; | 4947 | is_comptime = loop_stack_item->is_comptime; |
| ... | @@ -5003,7 +5017,7 @@ static IrInstruction *ir_gen_err_ok_or(IrBuilder *irb, Scope *parent_scope, AstN | ... | @@ -5003,7 +5017,7 @@ static IrInstruction *ir_gen_err_ok_or(IrBuilder *irb, Scope *parent_scope, AstN |
| 5003 | IrInstruction *is_err = ir_build_test_err(irb, parent_scope, node, err_union_val); | 5017 | IrInstruction *is_err = ir_build_test_err(irb, parent_scope, node, err_union_val); |
| 5004 | | 5018 | |
| 5005 | IrInstruction *is_comptime; | 5019 | IrInstruction *is_comptime; |
| 5006 | if (ir_should_inline(irb)) { | 5020 | if (ir_should_inline(irb->exec, parent_scope)) { |
| 5007 | is_comptime = ir_build_const_bool(irb, parent_scope, node, true); | 5021 | is_comptime = ir_build_const_bool(irb, parent_scope, node, true); |
| 5008 | } else { | 5022 | } else { |
| 5009 | is_comptime = ir_build_test_comptime(irb, parent_scope, node, is_err); | 5023 | is_comptime = ir_build_test_comptime(irb, parent_scope, node, is_err); |
| ... | @@ -5197,6 +5211,8 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop | ... | @@ -5197,6 +5211,8 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop |
| 5197 | return ir_lval_wrap(irb, scope, ir_gen_switch_expr(irb, scope, node), lval); | 5211 | return ir_lval_wrap(irb, scope, ir_gen_switch_expr(irb, scope, node), lval); |
| 5198 | case NodeTypeGoto: | 5212 | case NodeTypeGoto: |
| 5199 | return ir_lval_wrap(irb, scope, ir_gen_goto(irb, scope, node), lval); | 5213 | return ir_lval_wrap(irb, scope, ir_gen_goto(irb, scope, node), lval); |
| | 5214 | case NodeTypeCompTime: |
| | 5215 | return ir_gen_comptime(irb, scope, node, lval); |
| 5200 | case NodeTypeTypeLiteral: | 5216 | case NodeTypeTypeLiteral: |
| 5201 | return ir_lval_wrap(irb, scope, ir_gen_type_literal(irb, scope, node), lval); | 5217 | return ir_lval_wrap(irb, scope, ir_gen_type_literal(irb, scope, node), lval); |
| 5202 | case NodeTypeErrorType: | 5218 | case NodeTypeErrorType: |
| ... | @@ -5259,7 +5275,7 @@ static bool ir_goto_pass2(IrBuilder *irb) { | ... | @@ -5259,7 +5275,7 @@ static bool ir_goto_pass2(IrBuilder *irb) { |
| 5259 | label->used = true; | 5275 | label->used = true; |
| 5260 | | 5276 | |
| 5261 | IrInstruction *is_comptime = ir_build_const_bool(irb, goto_item->scope, source_node, | 5277 | IrInstruction *is_comptime = ir_build_const_bool(irb, goto_item->scope, source_node, |
| 5262 | ir_should_inline(irb) || source_node->data.goto_expr.is_inline); | 5278 | ir_should_inline(irb->exec, goto_item->scope) || source_node->data.goto_expr.is_inline); |
| 5263 | if (!ir_gen_defers_for_block(irb, goto_item->scope, label->bb->scope, false, false)) { | 5279 | if (!ir_gen_defers_for_block(irb, goto_item->scope, label->bb->scope, false, false)) { |
| 5264 | add_node_error(irb->codegen, source_node, | 5280 | add_node_error(irb->codegen, source_node, |
| 5265 | buf_sprintf("no label in scope named '%s'", buf_ptr(label_name))); | 5281 | buf_sprintf("no label in scope named '%s'", buf_ptr(label_name))); |
| ... | @@ -5379,7 +5395,7 @@ static IrInstruction *ir_exec_const_result(CodeGen *codegen, IrExecutable *exec) | ... | @@ -5379,7 +5395,7 @@ static IrInstruction *ir_exec_const_result(CodeGen *codegen, IrExecutable *exec) |
| 5379 | } | 5395 | } |
| 5380 | | 5396 | |
| 5381 | static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInstruction *source_instruction) { | 5397 | static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInstruction *source_instruction) { |
| 5382 | if (ir_should_inline(&ira->new_irb)) { | 5398 | if (ir_should_inline(ira->new_irb.exec, source_instruction->scope)) { |
| 5383 | ir_add_error(ira, source_instruction, buf_sprintf("unable to evaluate constant expression")); | 5399 | ir_add_error(ira, source_instruction, buf_sprintf("unable to evaluate constant expression")); |
| 5384 | return false; | 5400 | return false; |
| 5385 | } | 5401 | } |
| ... | @@ -7841,7 +7857,8 @@ static TypeTableEntry *ir_analyze_instruction_call(IrAnalyze *ira, IrInstruction | ... | @@ -7841,7 +7857,8 @@ static TypeTableEntry *ir_analyze_instruction_call(IrAnalyze *ira, IrInstruction |
| 7841 | if (fn_ref->value.type->id == TypeTableEntryIdInvalid) | 7857 | if (fn_ref->value.type->id == TypeTableEntryIdInvalid) |
| 7842 | return ira->codegen->builtin_types.entry_invalid; | 7858 | return ira->codegen->builtin_types.entry_invalid; |
| 7843 | | 7859 | |
| 7844 | bool is_inline = call_instruction->is_comptime || ir_should_inline(&ira->new_irb); | 7860 | bool is_inline = call_instruction->is_comptime || |
| | 7861 | ir_should_inline(ira->new_irb.exec, call_instruction->base.scope); |
| 7845 | | 7862 | |
| 7846 | if (is_inline || instr_is_comptime(fn_ref)) { | 7863 | if (is_inline || instr_is_comptime(fn_ref)) { |
| 7847 | if (fn_ref->value.type->id == TypeTableEntryIdMetaType) { | 7864 | if (fn_ref->value.type->id == TypeTableEntryIdMetaType) { |
| ... | @@ -8146,7 +8163,7 @@ static TypeTableEntry *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstruct | ... | @@ -8146,7 +8163,7 @@ static TypeTableEntry *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstruct |
| 8146 | return ir_unreach_error(ira); | 8163 | return ir_unreach_error(ira); |
| 8147 | | 8164 | |
| 8148 | if (!cond_br_instruction->base.is_gen && !condition->value.depends_on_compile_var && | 8165 | if (!cond_br_instruction->base.is_gen && !condition->value.depends_on_compile_var && |
| 8149 | !ir_should_inline(&ira->new_irb)) | 8166 | !ir_should_inline(ira->new_irb.exec, cond_br_instruction->base.scope)) |
| 8150 | { | 8167 | { |
| 8151 | const char *true_or_false = cond_is_true ? "true" : "false"; | 8168 | const char *true_or_false = cond_is_true ? "true" : "false"; |
| 8152 | ir_add_error(ira, &cond_br_instruction->base, | 8169 | ir_add_error(ira, &cond_br_instruction->base, |
| ... | @@ -9814,7 +9831,7 @@ static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstru | ... | @@ -9814,7 +9831,7 @@ static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstru |
| 9814 | | 9831 | |
| 9815 | IrInstructionStructInitField *new_fields = allocate<IrInstructionStructInitField>(actual_field_count); | 9832 | IrInstructionStructInitField *new_fields = allocate<IrInstructionStructInitField>(actual_field_count); |
| 9816 | | 9833 | |
| 9817 | bool is_comptime = ir_should_inline(&ira->new_irb); | 9834 | bool is_comptime = ir_should_inline(ira->new_irb.exec, instruction->scope); |
| 9818 | | 9835 | |
| 9819 | ConstExprValue const_val = {}; | 9836 | ConstExprValue const_val = {}; |
| 9820 | const_val.special = ConstValSpecialStatic; | 9837 | const_val.special = ConstValSpecialStatic; |
| ... | @@ -9931,7 +9948,7 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira | ... | @@ -9931,7 +9948,7 @@ static TypeTableEntry *ir_analyze_instruction_container_init_list(IrAnalyze *ira |
| 9931 | const_val.data.x_array.elements = allocate<ConstExprValue>(elem_count); | 9948 | const_val.data.x_array.elements = allocate<ConstExprValue>(elem_count); |
| 9932 | const_val.data.x_array.size = elem_count; | 9949 | const_val.data.x_array.size = elem_count; |
| 9933 | | 9950 | |
| 9934 | bool is_comptime = ir_should_inline(&ira->new_irb); | 9951 | bool is_comptime = ir_should_inline(ira->new_irb.exec, instruction->base.scope); |
| 9935 | | 9952 | |
| 9936 | IrInstruction **new_items = allocate<IrInstruction *>(elem_count); | 9953 | IrInstruction **new_items = allocate<IrInstruction *>(elem_count); |
| 9937 | | 9954 | |