authorgravatar for kt@connectfree.co.jpkristopher tate <kt@connectfree.co.jp> 2018-07-27 19:17:38+09:00
committergravatar for kt@connectfree.co.jpkristopher tate <kt@connectfree.co.jp> 2018-08-02 16:50:08+09:00
loga9ea22d4f9816998cccfca4df2ef56d5069e1814
tree7c9d5787dc30de33ba87769727b5c827a733f4f2
parente79c913cbcb03834fcc04e2258ed5da7d533c9db

src/ir.cpp: wire-up IR for handle builtin;

Tracking Issue #1296 ;

1 files changed, 27 insertions(+), 0 deletions(-)

src/ir.cpp+27
...@@ -580,6 +580,10 @@ static constexpr IrInstructionId ir_instruction_id(IrInstructionFrameAddress *)...@@ -580,6 +580,10 @@ static constexpr IrInstructionId ir_instruction_id(IrInstructionFrameAddress *)
580 return IrInstructionIdFrameAddress;580 return IrInstructionIdFrameAddress;
581}581}
582582
583static constexpr IrInstructionId ir_instruction_id(IrInstructionHandle *) {
584 return IrInstructionIdHandle;
585}
586
583static constexpr IrInstructionId ir_instruction_id(IrInstructionAlignOf *) {587static constexpr IrInstructionId ir_instruction_id(IrInstructionAlignOf *) {
584 return IrInstructionIdAlignOf;588 return IrInstructionIdAlignOf;
585}589}
...@@ -2240,6 +2244,17 @@ static IrInstruction *ir_build_frame_address_from(IrBuilder *irb, IrInstruction...@@ -2240,6 +2244,17 @@ static IrInstruction *ir_build_frame_address_from(IrBuilder *irb, IrInstruction
2240 return new_instruction;2244 return new_instruction;
2241}2245}
22422246
2247static IrInstruction *ir_build_handle(IrBuilder *irb, Scope *scope, AstNode *source_node) {
2248 IrInstructionHandle *instruction = ir_build_instruction<IrInstructionHandle>(irb, scope, source_node);
2249 return &instruction->base;
2250}
2251
2252static IrInstruction *ir_build_handle_from(IrBuilder *irb, IrInstruction *old_instruction) {
2253 IrInstruction *new_instruction = ir_build_handle(irb, old_instruction->scope, old_instruction->source_node);
2254 ir_link_new_instruction(new_instruction, old_instruction);
2255 return new_instruction;
2256}
2257
2243static IrInstruction *ir_build_overflow_op(IrBuilder *irb, Scope *scope, AstNode *source_node,2258static IrInstruction *ir_build_overflow_op(IrBuilder *irb, Scope *scope, AstNode *source_node,
2244 IrOverflowOp op, IrInstruction *type_value, IrInstruction *op1, IrInstruction *op2,2259 IrOverflowOp op, IrInstruction *type_value, IrInstruction *op1, IrInstruction *op2,
2245 IrInstruction *result_ptr, TypeTableEntry *result_ptr_type)2260 IrInstruction *result_ptr, TypeTableEntry *result_ptr_type)
...@@ -4475,6 +4490,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo...@@ -4475,6 +4490,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo
4475 return ir_lval_wrap(irb, scope, ir_build_return_address(irb, scope, node), lval);4490 return ir_lval_wrap(irb, scope, ir_build_return_address(irb, scope, node), lval);
4476 case BuiltinFnIdFrameAddress:4491 case BuiltinFnIdFrameAddress:
4477 return ir_lval_wrap(irb, scope, ir_build_frame_address(irb, scope, node), lval);4492 return ir_lval_wrap(irb, scope, ir_build_frame_address(irb, scope, node), lval);
4493 case BuiltinFnIdHandle:
4494 return ir_lval_wrap(irb, scope, ir_build_handle(irb, scope, node), lval);
4478 case BuiltinFnIdAlignOf:4495 case BuiltinFnIdAlignOf:
4479 {4496 {
4480 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);4497 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
...@@ -19007,6 +19024,13 @@ static TypeTableEntry *ir_analyze_instruction_frame_address(IrAnalyze *ira, IrIn...@@ -19007,6 +19024,13 @@ static TypeTableEntry *ir_analyze_instruction_frame_address(IrAnalyze *ira, IrIn
19007 return u8_ptr_const;19024 return u8_ptr_const;
19008}19025}
1900919026
19027static TypeTableEntry *ir_analyze_instruction_handle(IrAnalyze *ira, IrInstructionHandle *instruction) {
19028 ir_build_handle_from(&ira->new_irb, &instruction->base);
19029
19030 TypeTableEntry *promise_type = get_promise_type(ira->codegen, nullptr);
19031 return promise_type;
19032}
19033
19010static TypeTableEntry *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstructionAlignOf *instruction) {19034static TypeTableEntry *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstructionAlignOf *instruction) {
19011 IrInstruction *type_value = instruction->type_value->other;19035 IrInstruction *type_value = instruction->type_value->other;
19012 if (type_is_invalid(type_value->value.type))19036 if (type_is_invalid(type_value->value.type))
...@@ -20982,6 +21006,8 @@ static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstructi...@@ -20982,6 +21006,8 @@ static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstructi
20982 return ir_analyze_instruction_return_address(ira, (IrInstructionReturnAddress *)instruction);21006 return ir_analyze_instruction_return_address(ira, (IrInstructionReturnAddress *)instruction);
20983 case IrInstructionIdFrameAddress:21007 case IrInstructionIdFrameAddress:
20984 return ir_analyze_instruction_frame_address(ira, (IrInstructionFrameAddress *)instruction);21008 return ir_analyze_instruction_frame_address(ira, (IrInstructionFrameAddress *)instruction);
21009 case IrInstructionIdHandle:
21010 return ir_analyze_instruction_handle(ira, (IrInstructionHandle *)instruction);
20985 case IrInstructionIdAlignOf:21011 case IrInstructionIdAlignOf:
20986 return ir_analyze_instruction_align_of(ira, (IrInstructionAlignOf *)instruction);21012 return ir_analyze_instruction_align_of(ira, (IrInstructionAlignOf *)instruction);
20987 case IrInstructionIdOverflowOp:21013 case IrInstructionIdOverflowOp:
...@@ -21274,6 +21300,7 @@ bool ir_has_side_effects(IrInstruction *instruction) {...@@ -21274,6 +21300,7 @@ bool ir_has_side_effects(IrInstruction *instruction) {
21274 case IrInstructionIdAlignOf:21300 case IrInstructionIdAlignOf:
21275 case IrInstructionIdReturnAddress:21301 case IrInstructionIdReturnAddress:
21276 case IrInstructionIdFrameAddress:21302 case IrInstructionIdFrameAddress:
21303 case IrInstructionIdHandle:
21277 case IrInstructionIdTestErr:21304 case IrInstructionIdTestErr:
21278 case IrInstructionIdUnwrapErrCode:21305 case IrInstructionIdUnwrapErrCode:
21279 case IrInstructionIdOptionalWrap:21306 case IrInstructionIdOptionalWrap: