diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-07-18 19:24:45 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-07-18 19:24:45 +0100 |
| commit | 59fb7b020a5e0bd2d23daab0f74e9cfa23420afc (patch) | |
| tree | 435bd10ec767d4bdf56bfc3d232c0c9debea18d8 /src/ir_print.cpp | |
| parent | 65f079ebc474f9decc7afb222630c04b4da32690 (diff) | |
Merge `raw_union` into `struct` as a memory layout tag `#raw_union`
Diffstat (limited to 'src/ir_print.cpp')
| -rw-r--r-- | src/ir_print.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/ir_print.cpp b/src/ir_print.cpp index e2b4fcb1a..e2d33054b 100644 --- a/src/ir_print.cpp +++ b/src/ir_print.cpp @@ -300,8 +300,14 @@ void ir_print_type(irFileBuffer *f, irModule *m, Type *t) { } return; case Type_Record: { - switch (t->Record.kind) { - case TypeRecord_Struct: + if (t->Record.is_raw_union) { + // NOTE(bill): The zero size array is used to fix the alignment used in a structure as + // LLVM takes the first element's alignment as the entire alignment (like C) + i64 size_of_union = type_size_of(heap_allocator(), t); + i64 align_of_union = type_align_of(heap_allocator(), t); + ir_fprintf(f, "{[0 x <%lld x i8>], [%lld x i8]}", align_of_union, size_of_union); + return; + } else { if (t->Record.is_packed) { ir_fprintf(f, "<"); } @@ -323,13 +329,6 @@ void ir_print_type(irFileBuffer *f, irModule *m, Type *t) { ir_fprintf(f, ">"); } return; - case TypeRecord_RawUnion: { - // NOTE(bill): The zero size array is used to fix the alignment used in a structure as - // LLVM takes the first element's alignment as the entire alignment (like C) - i64 size_of_union = type_size_of(heap_allocator(), t); - i64 align_of_union = type_align_of(heap_allocator(), t); - ir_fprintf(f, "{[0 x <%lld x i8>], [%lld x i8]}", align_of_union, size_of_union); - } return; } } break; |