diff options
| author | Michael Dusan <michael.dusan@gmail.com> | 2019-11-25 15:04:49 -0500 |
|---|---|---|
| committer | Michael Dusan <michael.dusan@gmail.com> | 2019-11-25 15:04:49 -0500 |
| commit | a647a88dfc6cdef66316399f10084b35f738b093 (patch) | |
| tree | 8b2ea8968a6e273bf4a7b052a8bceb0eadcab1b6 /src/codegen.cpp | |
| parent | 8f3e972da6badf6df82c88ba0c60aca7b545f62c (diff) | |
| download | zig-a647a88dfc6cdef66316399f10084b35f738b093.tar.gz zig-a647a88dfc6cdef66316399f10084b35f738b093.zip | |
const interning for 1-possible-value types
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index 4060bbd069..30ac5af4a1 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -8008,6 +8008,33 @@ static void define_builtin_types(CodeGen *g) { } } +static void define_intern_values(CodeGen *g) { + { + auto& value = g->intern_values.x_undefined; + value.type = g->builtin_types.entry_undef; + value.global_refs = allocate<ConstGlobalRefs>(1, "ConstGlobalRefs.undefined"); + value.special = ConstValSpecialStatic; + } + { + auto& value = g->intern_values.x_void; + value.type = g->builtin_types.entry_void; + value.global_refs = allocate<ConstGlobalRefs>(1, "ConstGlobalRefs.void"); + value.special = ConstValSpecialStatic; + } + { + auto& value = g->intern_values.x_null; + value.type = g->builtin_types.entry_null; + value.global_refs = allocate<ConstGlobalRefs>(1, "ConstGlobalRefs.null"); + value.special = ConstValSpecialStatic; + } + { + auto& value = g->intern_values.x_unreachable; + value.type = g->builtin_types.entry_unreachable; + value.global_refs = allocate<ConstGlobalRefs>(1, "ConstGlobalRefs.unreachable"); + value.special = ConstValSpecialStatic; + } +} + static BuiltinFnEntry *create_builtin_fn(CodeGen *g, BuiltinFnId id, const char *name, size_t count) { BuiltinFnEntry *builtin_fn = allocate<BuiltinFnEntry>(1); buf_init_from_str(&builtin_fn->name, name); @@ -8629,6 +8656,7 @@ static void init(CodeGen *g) { g->dummy_di_file = nullptr; define_builtin_types(g); + define_intern_values(g); IrInstruction *sentinel_instructions = allocate<IrInstruction>(2); g->invalid_instruction = &sentinel_instructions[0]; |
