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 *)
580580 return IrInstructionIdFrameAddress;
581581}
582582
583static constexpr IrInstructionId ir_instruction_id(IrInstructionHandle *) {
584 return IrInstructionIdHandle;
585}
586
583587static constexpr IrInstructionId ir_instruction_id(IrInstructionAlignOf *) {
584588 return IrInstructionIdAlignOf;
585589}
......@@ -2240,6 +2244,17 @@ static IrInstruction *ir_build_frame_address_from(IrBuilder *irb, IrInstruction
22402244 return new_instruction;
22412245}
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
22432258static IrInstruction *ir_build_overflow_op(IrBuilder *irb, Scope *scope, AstNode *source_node,
22442259 IrOverflowOp op, IrInstruction *type_value, IrInstruction *op1, IrInstruction *op2,
22452260 IrInstruction *result_ptr, TypeTableEntry *result_ptr_type)
......@@ -4475,6 +4490,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo
44754490 return ir_lval_wrap(irb, scope, ir_build_return_address(irb, scope, node), lval);
44764491 case BuiltinFnIdFrameAddress:
44774492 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);
44784495 case BuiltinFnIdAlignOf:
44794496 {
44804497 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
1900719024 return u8_ptr_const;
1900819025}
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
1901019034static TypeTableEntry *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstructionAlignOf *instruction) {
1901119035 IrInstruction *type_value = instruction->type_value->other;
1901219036 if (type_is_invalid(type_value->value.type))
......@@ -20982,6 +21006,8 @@ static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstructi
2098221006 return ir_analyze_instruction_return_address(ira, (IrInstructionReturnAddress *)instruction);
2098321007 case IrInstructionIdFrameAddress:
2098421008 return ir_analyze_instruction_frame_address(ira, (IrInstructionFrameAddress *)instruction);
21009 case IrInstructionIdHandle:
21010 return ir_analyze_instruction_handle(ira, (IrInstructionHandle *)instruction);
2098521011 case IrInstructionIdAlignOf:
2098621012 return ir_analyze_instruction_align_of(ira, (IrInstructionAlignOf *)instruction);
2098721013 case IrInstructionIdOverflowOp:
......@@ -21274,6 +21300,7 @@ bool ir_has_side_effects(IrInstruction *instruction) {
2127421300 case IrInstructionIdAlignOf:
2127521301 case IrInstructionIdReturnAddress:
2127621302 case IrInstructionIdFrameAddress:
21303 case IrInstructionIdHandle:
2127721304 case IrInstructionIdTestErr:
2127821305 case IrInstructionIdUnwrapErrCode:
2127921306 case IrInstructionIdOptionalWrap: