From c5c9d98065890eaeb9070cba20e5a1ed48b392af Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 29 Aug 2017 07:30:22 -0400 Subject: introduce align keyword * remove `@setGlobalAlign` * add align keyword for setting alignment on functions and variables. * loads and stores use alignment from pointer * memcpy, memset use alignment from pointer * add syntax for pointer alignment * slices can have volatile * add u2, i2 primitives * ignore preferred align and use abi align everywhere * back to only having alignOf builtin. preferredAlignOf is too tricky to be useful. See #432. Partial revert of e726925e802eddab53cbfd9aacbc5eefe95c356f. See #37 --- src/parseh.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/parseh.cpp') diff --git a/src/parseh.cpp b/src/parseh.cpp index 7b88c901ba..9acbc7c57c 100644 --- a/src/parseh.cpp +++ b/src/parseh.cpp @@ -710,6 +710,7 @@ static TypeTableEntry *resolve_enum_decl(Context *c, const EnumDecl *enum_decl) TypeTableEntry *enum_type = get_partial_container_type(c->codegen, &c->import->decls_scope->base, ContainerKindEnum, c->source_node, buf_ptr(full_type_name), ContainerLayoutExtern); enum_type->data.enumeration.zero_bits_known = true; + enum_type->data.enumeration.abi_alignment = 1; c->enum_type_table.put(bare_name, enum_type); c->decl_table.put(enum_decl, enum_type); replace_with_fwd_decl(c, enum_type, full_type_name); @@ -741,6 +742,7 @@ static TypeTableEntry *resolve_enum_decl(Context *c, const EnumDecl *enum_decl) enum_type->data.enumeration.gen_field_count = 0; enum_type->data.enumeration.complete = true; enum_type->data.enumeration.zero_bits_known = true; + enum_type->data.enumeration.abi_alignment = 1; enum_type->data.enumeration.tag_type = tag_type_entry; enum_type->data.enumeration.src_field_count = field_count; @@ -778,6 +780,9 @@ static TypeTableEntry *resolve_enum_decl(Context *c, const EnumDecl *enum_decl) // create llvm type for root struct enum_type->type_ref = tag_type_entry->type_ref; + enum_type->data.enumeration.abi_alignment = LLVMABIAlignmentOfType(c->codegen->target_data_ref, + enum_type->type_ref); + // create debug type for tag unsigned line = c->source_node ? (c->source_node->line + 1) : 0; uint64_t debug_size_in_bits = 8*LLVMStoreSizeOfType(c->codegen->target_data_ref, enum_type->type_ref); @@ -864,6 +869,7 @@ static TypeTableEntry *resolve_record_decl(Context *c, const RecordDecl *record_ TypeTableEntry *struct_type = get_partial_container_type(c->codegen, &c->import->decls_scope->base, ContainerKindStruct, c->source_node, buf_ptr(full_type_name), ContainerLayoutExtern); struct_type->data.structure.zero_bits_known = true; + struct_type->data.structure.abi_alignment = 1; c->struct_type_table.put(bare_name, struct_type); c->decl_table.put(record_decl, struct_type); @@ -950,6 +956,8 @@ static TypeTableEntry *resolve_record_decl(Context *c, const RecordDecl *record_ struct_type->data.structure.gen_field_count = field_count; struct_type->data.structure.complete = true; + struct_type->data.structure.abi_alignment = LLVMABIAlignmentOfType(c->codegen->target_data_ref, + struct_type->type_ref); uint64_t debug_size_in_bits = 8*LLVMStoreSizeOfType(c->codegen->target_data_ref, struct_type->type_ref); uint64_t debug_align_in_bits = 8*LLVMABISizeOfType(c->codegen->target_data_ref, struct_type->type_ref); -- cgit v1.2.3