From 2f20fe6ecd15581e356b3dcd3b254611b132c096 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 7 May 2017 23:25:36 -0400 Subject: [PATCH] delete @generatedCode builtin function good riddance --- src/all_types.hpp | 8 ------- src/codegen.cpp | 2 -- src/ir.cpp | 55 --------------------------------------------- src/ir_print.cpp | 9 -------- test/cases/null.zig | 8 +++---- 5 files changed, 4 insertions(+), 78 deletions(-) diff --git a/src/all_types.hpp b/src/all_types.hpp index 9277fa2c6..b17fa7f33 100644 --- a/src/all_types.hpp +++ b/src/all_types.hpp @@ -1182,7 +1182,6 @@ enum BuiltinFnId { BuiltinFnIdCUndef, BuiltinFnIdCompileErr, BuiltinFnIdCompileLog, - BuiltinFnIdGeneratedCode, BuiltinFnIdCtz, BuiltinFnIdClz, BuiltinFnIdImport, @@ -1739,7 +1738,6 @@ enum IrInstructionId { IrInstructionIdEnumTag, IrInstructionIdClz, IrInstructionIdCtz, - IrInstructionIdGeneratedCode, IrInstructionIdImport, IrInstructionIdCImport, IrInstructionIdCInclude, @@ -2153,12 +2151,6 @@ struct IrInstructionEnumTag { IrInstruction *value; }; -struct IrInstructionGeneratedCode { - IrInstruction base; - - IrInstruction *value; -}; - struct IrInstructionImport { IrInstruction base; diff --git a/src/codegen.cpp b/src/codegen.cpp index 3da7fb186..80a956936 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -3007,7 +3007,6 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable, case IrInstructionIdAlignOf: case IrInstructionIdFnProto: case IrInstructionIdTestComptime: - case IrInstructionIdGeneratedCode: case IrInstructionIdCheckSwitchProngs: case IrInstructionIdCheckStatementIsVoid: case IrInstructionIdTestType: @@ -4413,7 +4412,6 @@ static void define_builtin_fns(CodeGen *g) { create_builtin_fn(g, BuiltinFnIdCInclude, "cInclude", 1); create_builtin_fn(g, BuiltinFnIdCDefine, "cDefine", 2); create_builtin_fn(g, BuiltinFnIdCUndef, "cUndef", 1); - create_builtin_fn(g, BuiltinFnIdGeneratedCode, "generatedCode", 1); create_builtin_fn(g, BuiltinFnIdCtz, "ctz", 1); create_builtin_fn(g, BuiltinFnIdClz, "clz", 1); create_builtin_fn(g, BuiltinFnIdImport, "import", 1); diff --git a/src/ir.cpp b/src/ir.cpp index e91a1aad4..963eec30c 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -333,10 +333,6 @@ static constexpr IrInstructionId ir_instruction_id(IrInstructionEnumTag *) { return IrInstructionIdEnumTag; } -static constexpr IrInstructionId ir_instruction_id(IrInstructionGeneratedCode *) { - return IrInstructionIdGeneratedCode; -} - static constexpr IrInstructionId ir_instruction_id(IrInstructionImport *) { return IrInstructionIdImport; } @@ -1435,17 +1431,6 @@ static IrInstruction *ir_build_enum_tag_from(IrBuilder *irb, IrInstruction *old_ return new_instruction; } -static IrInstruction *ir_build_generated_code(IrBuilder *irb, Scope *scope, AstNode *source_node, - IrInstruction *value) -{ - IrInstructionGeneratedCode *instruction = ir_build_instruction(irb, scope, source_node); - instruction->value = value; - - ir_ref_instruction(value, irb->current_basic_block); - - return &instruction->base; -} - static IrInstruction *ir_build_import(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *name) { IrInstructionImport *instruction = ir_build_instruction(irb, scope, source_node); instruction->name = name; @@ -2466,13 +2451,6 @@ static IrInstruction *ir_instruction_ctz_get_dep(IrInstructionCtz *instruction, } } -static IrInstruction *ir_instruction_generatedcode_get_dep(IrInstructionGeneratedCode *instruction, size_t index) { - switch (index) { - case 0: return instruction->value; - default: return nullptr; - } -} - static IrInstruction *ir_instruction_import_get_dep(IrInstructionImport *instruction, size_t index) { switch (index) { case 0: return instruction->name; @@ -2964,8 +2942,6 @@ static IrInstruction *ir_instruction_get_dep(IrInstruction *instruction, size_t return ir_instruction_clz_get_dep((IrInstructionClz *) instruction, index); case IrInstructionIdCtz: return ir_instruction_ctz_get_dep((IrInstructionCtz *) instruction, index); - case IrInstructionIdGeneratedCode: - return ir_instruction_generatedcode_get_dep((IrInstructionGeneratedCode *) instruction, index); case IrInstructionIdImport: return ir_instruction_import_get_dep((IrInstructionImport *) instruction, index); case IrInstructionIdCImport: @@ -3931,15 +3907,6 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo return ir_build_clz(irb, scope, node, arg0_value); } - case BuiltinFnIdGeneratedCode: - { - AstNode *arg0_node = node->data.fn_call_expr.params.at(0); - IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); - if (arg0_value == irb->codegen->invalid_instruction) - return arg0_value; - - return ir_build_generated_code(irb, scope, node, arg0_value); - } case BuiltinFnIdImport: { AstNode *arg0_node = node->data.fn_call_expr.params.at(0); @@ -11227,25 +11194,6 @@ static TypeTableEntry *ir_analyze_instruction_enum_tag(IrAnalyze *ira, IrInstruc return new_instruction->value.type; } -static TypeTableEntry *ir_analyze_instruction_generated_code(IrAnalyze *ira, IrInstructionGeneratedCode *instruction) { - IrInstruction *value = instruction->value->other; - if (type_is_invalid(value->value.type)) - return ira->codegen->builtin_types.entry_invalid; - - if (instr_is_comptime(value)) { - ConstExprValue *val = ir_resolve_const(ira, value, UndefOk); - if (!val) - return ira->codegen->builtin_types.entry_invalid; - - ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); - *out_val = *val; - return value->value.type; - } - - instruction->base.other = value; - return value->value.type; -} - static TypeTableEntry *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructionImport *import_instruction) { IrInstruction *name_value = import_instruction->name->other; Buf *import_target_str = ir_resolve_str(ira, name_value); @@ -13362,8 +13310,6 @@ static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstructi return ir_analyze_instruction_switch_var(ira, (IrInstructionSwitchVar *)instruction); case IrInstructionIdEnumTag: return ir_analyze_instruction_enum_tag(ira, (IrInstructionEnumTag *)instruction); - case IrInstructionIdGeneratedCode: - return ir_analyze_instruction_generated_code(ira, (IrInstructionGeneratedCode *)instruction); case IrInstructionIdImport: return ir_analyze_instruction_import(ira, (IrInstructionImport *)instruction); case IrInstructionIdArrayLen: @@ -13601,7 +13547,6 @@ bool ir_has_side_effects(IrInstruction *instruction) { case IrInstructionIdSwitchVar: case IrInstructionIdSwitchTarget: case IrInstructionIdEnumTag: - case IrInstructionIdGeneratedCode: case IrInstructionIdRef: case IrInstructionIdMinValue: case IrInstructionIdMaxValue: diff --git a/src/ir_print.cpp b/src/ir_print.cpp index 88eff409c..9c4e58bc3 100644 --- a/src/ir_print.cpp +++ b/src/ir_print.cpp @@ -481,12 +481,6 @@ static void ir_print_enum_tag(IrPrint *irp, IrInstructionEnumTag *instruction) { ir_print_other_instruction(irp, instruction->value); } -static void ir_print_generated_code(IrPrint *irp, IrInstructionGeneratedCode *instruction) { - fprintf(irp->f, "@generatedCode("); - ir_print_other_instruction(irp, instruction->value); - fprintf(irp->f, ")"); -} - static void ir_print_import(IrPrint *irp, IrInstructionImport *instruction) { fprintf(irp->f, "@import("); ir_print_other_instruction(irp, instruction->name); @@ -1011,9 +1005,6 @@ static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) { case IrInstructionIdEnumTag: ir_print_enum_tag(irp, (IrInstructionEnumTag *)instruction); break; - case IrInstructionIdGeneratedCode: - ir_print_generated_code(irp, (IrInstructionGeneratedCode *)instruction); - break; case IrInstructionIdImport: ir_print_import(irp, (IrInstructionImport *)instruction); break; diff --git a/test/cases/null.zig b/test/cases/null.zig index 723b5f696..2ed637e8e 100644 --- a/test/cases/null.zig +++ b/test/cases/null.zig @@ -1,7 +1,7 @@ const assert = @import("std").debug.assert; test "nullableType" { - const x : ?bool = @generatedCode(true); + const x : ?bool = true; if (x) |y| { if (y) { @@ -13,13 +13,13 @@ test "nullableType" { unreachable; } - const next_x : ?i32 = @generatedCode(null); + const next_x : ?i32 = null; const z = next_x ?? 1234; assert(z == 1234); - const final_x : ?i32 = @generatedCode(13); + const final_x : ?i32 = 13; const num = final_x ?? unreachable; @@ -38,7 +38,7 @@ test "test maybe object and get a pointer to the inner value" { test "rhsMaybeUnwrapReturn" { - const x: ?bool = @generatedCode(true); + const x: ?bool = true; const y = x ?? return; }