summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2018-08-12 21:01:34 +0800
committerJohn Hodge <tpg@ucc.asn.au>2018-08-12 21:01:34 +0800
commitc8175361ebb5ae99c62d956c475d374a49f90402 (patch)
tree48ea3ef1d3747c4159b3dd881c1d280531b1cfeb /src
parentec907f56199c495db061f2712a5be3977bcb11e8 (diff)
downloadmrust-c8175361ebb5ae99c62d956c475d374a49f90402.tar.gz
Target - Set alignment for u64/i64 to 4 on 32-bit platforms (fixes #78)
Diffstat (limited to 'src')
-rw-r--r--src/trans/target.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/trans/target.cpp b/src/trans/target.cpp
index c1dce972..004b0bf1 100644
--- a/src/trans/target.cpp
+++ b/src/trans/target.cpp
@@ -684,13 +684,14 @@ bool Target_GetSizeAndAlignOf(const Span& sp, const StaticTraitResolve& resolve,
case ::HIR::CoreType::U64:
case ::HIR::CoreType::I64:
out_size = 8;
- out_align = 8;
+ // TODO: on x86, u64/i64 has an alignment of 4, while x86_64 has 8. What do other platforms have?
+ out_align = g_target.m_arch.m_pointer_bits == 32 ? 4 : 8;
return true;
case ::HIR::CoreType::U128:
case ::HIR::CoreType::I128:
out_size = 16;
- // TODO: If i128 is emulated, this can be 8
- out_align = 16;
+ // TODO: If i128 is emulated, this can be 8 (as it is on x86, where it's actually 4 due to the above comment)
+ out_align = g_target.m_arch.m_pointer_bits == 32 ? 4 : 16;
return true;
case ::HIR::CoreType::Usize:
case ::HIR::CoreType::Isize: