diff options
| author | Eugen Wissner <belka@caraus.de> | 2026-09-11 09:11:47 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2026-09-11 09:11:47 +0200 |
| commit | bd2b80d6ac582b9f0bcd96c86d4b79bfdb64eca1 (patch) | |
| tree | a835a5cfe5a9cf48720b9255261e065fd7978849 /gcc | |
| parent | b27872d5c5bfecae74195771f5c1f4e73385b6d6 (diff) | |
| download | elna-bd2b80d6ac582b9f0bcd96c86d4b79bfdb64eca1.tar.gz | |
Implement aligned attribute
Diffstat (limited to 'gcc')
| -rw-r--r-- | gcc/gcc/elna-builtins.cc | 13 | ||||
| -rw-r--r-- | gcc/gcc/elna-generic.cc | 13 |
2 files changed, 21 insertions, 5 deletions
diff --git a/gcc/gcc/elna-builtins.cc b/gcc/gcc/elna-builtins.cc index 7d2f8f0..2dc1147 100644 --- a/gcc/gcc/elna-builtins.cc +++ b/gcc/gcc/elna-builtins.cc @@ -116,14 +116,21 @@ namespace elna::gcc return builtin_table; } - static tree build_composite_type(const boot::ordered_map<boot::type>& fields, + static tree build_composite_type(const boot::ordered_map<boot::field_info>& fields, tree composite_type_node, const std::shared_ptr<symbol_table>& symbols) { for (const auto& field : fields) { - tree rewritten_field = get_inner_alias(field.second, symbols); + tree rewritten_field = get_inner_alias(field.second.field_type, symbols); tree field_declaration = build_field(UNKNOWN_LOCATION, composite_type_node, field.first, rewritten_field); + + if (field.second.alignment.has_value()) + { + SET_DECL_ALIGN(field_declaration, field.second.alignment.value() * BITS_PER_UNIT); + DECL_USER_ALIGN(field_declaration) = 1; + DECL_PACKED(field_declaration) = 1; + } TYPE_FIELDS(composite_type_node) = chainon(TYPE_FIELDS(composite_type_node), field_declaration); } return composite_type_node; @@ -148,6 +155,8 @@ namespace elna::gcc } TYPE_SIZE_UNIT(record_type) = size_int(record_layout.value().size); TYPE_SIZE(record_type) = bitsize_int(record_layout.value().size * BITS_PER_UNIT); + SET_TYPE_ALIGN(record_type, record_layout.value().alignment * BITS_PER_UNIT); + TYPE_USER_ALIGN(record_type) = static_cast<unsigned>(subject->alignment.has_value()); return true; } diff --git a/gcc/gcc/elna-generic.cc b/gcc/gcc/elna-generic.cc index b67e91c..8ab6762 100644 --- a/gcc/gcc/elna-generic.cc +++ b/gcc/gcc/elna-generic.cc @@ -744,13 +744,20 @@ namespace elna::gcc for (const auto& variable_identifier : declaration->identifiers) { const location_t declaration_location = get_location(&declaration->position()); - tree declaration_tree = this->symbols->lookup(variable_identifier.name()); + const std::string& variable_name = variable_identifier.name(); + tree declaration_tree = this->symbols->lookup(variable_name); - auto variable_symbol = this->bag.lookup(variable_identifier.name())->is_variable(); + auto variable_symbol = this->bag.lookup(variable_name)->is_variable(); if (declaration_tree == NULL_TREE) { - declaration_tree = declare_variable(variable_identifier.name(), *variable_symbol, this->symbols); + declaration_tree = declare_variable(variable_name, *variable_symbol, this->symbols); + } + if (variable_symbol->alignment.has_value()) + { + SET_DECL_ALIGN(declaration_tree, + variable_symbol->alignment.value() * BITS_PER_UNIT); + DECL_USER_ALIGN(declaration_tree) = 1; } if (variable_symbol->value.has_value()) { |
