aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/codegen.cpp
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2016-09-30 20:38:46 +0100
committerGinger Bill <bill@gingerbill.org>2016-09-30 20:38:46 +0100
commitc6aac264fa8001ff5e55e5ac6f56289ff0a755ee (patch)
tree4ff0521b330e5a2b0183d3bab2f762a669b5efa5 /src/codegen/codegen.cpp
parent04b5d8c132e8aabb3bb5dff31683cb45d4dff9c0 (diff)
Begin work on const llvm aggregate literals
Diffstat (limited to 'src/codegen/codegen.cpp')
-rw-r--r--src/codegen/codegen.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/codegen/codegen.cpp b/src/codegen/codegen.cpp
index ca6771962..87aaab101 100644
--- a/src/codegen/codegen.cpp
+++ b/src/codegen/codegen.cpp
@@ -151,13 +151,12 @@ void ssa_gen_tree(ssaGen *s) {
if (decl->init_expr != NULL) {
TypeAndValue *tav = map_get(&info->types, hash_pointer(decl->init_expr));
- if (tav != NULL && tav->value.kind != ExactValue_Invalid) {
- ExactValue v = tav->value;
- if (v.kind == ExactValue_String) {
- // NOTE(bill): The printer will fix the value correctly
- // g->Global.value = ssa_add_global_string_array(m, v.value_string);
- } else {
- g->Global.value = ssa_make_value_constant(a, tav->type, v);
+ if (tav != NULL) {
+ if (tav->value.kind != ExactValue_Invalid) {
+ ExactValue v = tav->value;
+ if (v.kind != ExactValue_String) {
+ g->Global.value = ssa_add_module_constant(m, tav->type, v);
+ }
}
}
}
@@ -444,10 +443,10 @@ void ssa_gen_tree(ssaGen *s) {
type_set_offsets(m->sizes, a, t); // NOTE(bill): Just incase the offsets have not been set yet
for (isize i = 0; i < t->Record.field_count; i++) {
- // NOTE(bill): Order fields in source order not layout order
- Entity *f = t->Record.fields[i];
+ // TODO(bill): Order fields in source order not layout order
+ Entity *f = t->Record.fields_in_src_order[i];
ssaValue *tip = get_type_info_ptr(proc, type_info_data, f->type);
- i64 foffset = t->Record.struct_offsets[i];
+ i64 foffset = t->Record.struct_offsets[f->Variable.field_index];
GB_ASSERT(f->kind == Entity_Variable && f->Variable.is_field);
isize source_index = f->Variable.field_index;