diff options
author | David Faust <david.faust@oracle.com> | 2022-04-27 11:27:49 -0700 |
---|---|---|
committer | David Faust <david.faust@oracle.com> | 2022-04-27 12:00:18 -0700 |
commit | fd51331270ed0318144cb0031b21ef710218e2fe (patch) | |
tree | d3adea79abd3b1793c79a2474f037cc328736af9 /gcc/rust/backend | |
parent | 9a9bb44058a8406b41bb1ab3110e08a897772bb0 (diff) | |
download | gcc-fd51331270ed0318144cb0031b21ef710218e2fe.zip gcc-fd51331270ed0318144cb0031b21ef710218e2fe.tar.gz gcc-fd51331270ed0318144cb0031b21ef710218e2fe.tar.bz2 |
Support align and packed repr on structs
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r-- | gcc/rust/backend/rust-compile-type.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-type.cc b/gcc/rust/backend/rust-compile-type.cc index 07b95c7..16029ba 100644 --- a/gcc/rust/backend/rust-compile-type.cc +++ b/gcc/rust/backend/rust-compile-type.cc @@ -280,6 +280,26 @@ TyTyResolveCompile::visit (const TyTy::ADTType &type) type_record = ctx->get_backend ()->union_type (enum_fields); } + // Handle repr options + // TODO: "packed" should only narrow type alignment and "align" should only + // widen it. Do we need to check and enforce this here, or is it taken care of + // later on in the gcc middle-end? + TyTy::ADTType::ReprOptions repr = type.get_repr_options (); + if (repr.pack) + { + TYPE_PACKED (type_record); + if (repr.pack > 1) + { + SET_TYPE_ALIGN (type_record, repr.pack * 8); + TYPE_USER_ALIGN (type_record) = 1; + } + } + else if (repr.align) + { + SET_TYPE_ALIGN (type_record, repr.align * 8); + TYPE_USER_ALIGN (type_record) = 1; + } + std::string named_struct_str = type.get_ident ().path.get () + type.subst_as_string (); tree named_struct |