From 59fb7b020a5e0bd2d23daab0f74e9cfa23420afc Mon Sep 17 00:00:00 2001 From: Ginger Bill Date: Tue, 18 Jul 2017 19:24:45 +0100 Subject: Merge `raw_union` into `struct` as a memory layout tag `#raw_union` --- src/ir_print.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/ir_print.cpp') 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; -- cgit v1.2.3