aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
diff options
context:
space:
mode:
authorMichael Dusan <michael.dusan@gmail.com>2019-11-25 17:18:56 -0500
committerMichael Dusan <michael.dusan@gmail.com>2019-11-25 17:18:56 -0500
commit6c89f96df1484fc5017eb484f0f8270ab4be341f (patch)
tree8c5e0e68f2d6294690903fd4c0fefbc86975a461 /src/codegen.cpp
parent35d65cceb8aa4360accc0db30b2b1448159e7d26 (diff)
downloadzig-6c89f96df1484fc5017eb484f0f8270ab4be341f.tar.gz
zig-6c89f96df1484fc5017eb484f0f8270ab4be341f.zip
stage1: consolodate interning
- merge const_void_val → intern.x_void - move const_zero_byte → intern.zero_byte - wrap intern access
Diffstat (limited to 'src/codegen.cpp')
-rw-r--r--src/codegen.cpp59
1 files changed, 46 insertions, 13 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 30ac5af4a1..327ab76425 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -8010,29 +8010,36 @@ static void define_builtin_types(CodeGen *g) {
static void define_intern_values(CodeGen *g) {
{
- auto& value = g->intern_values.x_undefined;
+ auto& value = g->intern.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;
+ auto& value = g->intern.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;
+ auto& value = g->intern.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;
+ auto& value = g->intern.x_unreachable;
value.type = g->builtin_types.entry_unreachable;
value.global_refs = allocate<ConstGlobalRefs>(1, "ConstGlobalRefs.unreachable");
value.special = ConstValSpecialStatic;
}
+ {
+ auto& value = g->intern.zero_byte;
+ value.type = g->builtin_types.entry_u8;
+ value.global_refs = allocate<ConstGlobalRefs>(1, "ConstGlobalRefs.zero_byte");
+ value.special = ConstValSpecialStatic;
+ bigint_init_unsigned(&value.data.x_bigint, 0);
+ }
}
static BuiltinFnEntry *create_builtin_fn(CodeGen *g, BuiltinFnId id, const char *name, size_t count) {
@@ -8669,15 +8676,6 @@ static void init(CodeGen *g) {
g->unreach_instruction->value->type = g->builtin_types.entry_unreachable;
g->unreach_instruction->value->global_refs = allocate<ConstGlobalRefs>(1);
- g->const_void_val.special = ConstValSpecialStatic;
- g->const_void_val.type = g->builtin_types.entry_void;
- g->const_void_val.global_refs = allocate<ConstGlobalRefs>(1);
-
- g->const_zero_byte.special = ConstValSpecialStatic;
- g->const_zero_byte.type = g->builtin_types.entry_u8;
- g->const_zero_byte.global_refs = allocate<ConstGlobalRefs>(1);
- bigint_init_unsigned(&g->const_zero_byte.data.x_bigint, 0);
-
{
ConstGlobalRefs *global_refs = allocate<ConstGlobalRefs>(PanicMsgIdCount);
for (size_t i = 0; i < PanicMsgIdCount; i += 1) {
@@ -10564,3 +10562,38 @@ void codegen_switch_sub_prog_node(CodeGen *g, Stage2ProgressNode *node) {
}
g->sub_progress_node = node;
}
+
+ZigValue *CodeGen::Intern::for_undefined() {
+#ifdef ZIG_ENABLE_MEM_PROFILE
+ memprof_intern_count.x_undefined += 1;
+#endif
+ return &this->x_undefined;
+}
+
+ZigValue *CodeGen::Intern::for_void() {
+#ifdef ZIG_ENABLE_MEM_PROFILE
+ memprof_intern_count.x_void += 1;
+#endif
+ return &this->x_void;
+}
+
+ZigValue *CodeGen::Intern::for_null() {
+#ifdef ZIG_ENABLE_MEM_PROFILE
+ memprof_intern_count.x_null += 1;
+#endif
+ return &this->x_null;
+}
+
+ZigValue *CodeGen::Intern::for_unreachable() {
+#ifdef ZIG_ENABLE_MEM_PROFILE
+ memprof_intern_count.x_unreachable += 1;
+#endif
+ return &this->x_unreachable;
+}
+
+ZigValue *CodeGen::Intern::for_zero_byte() {
+#ifdef ZIG_ENABLE_MEM_PROFILE
+ memprof_intern_count.zero_byte += 1;
+#endif
+ return &this->zero_byte;
+}