summaryrefslogtreecommitdiff
path: root/src/trans/target.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2018-10-03 21:03:27 +0800
committerJohn Hodge <tpg@mutabah.net>2018-10-03 21:03:27 +0800
commit8adb6f6acf4fd5d2ebf527d749cf77faaf889b65 (patch)
tree405f6b6e6844428c1d43d754701416dbe4b5bebb /src/trans/target.cpp
parente42b7877ac1f7c173d42600b220b1f50a143b9b4 (diff)
parentbd3d69813cc54439fdc0db33943fa1254db3df06 (diff)
downloadmrust-8adb6f6acf4fd5d2ebf527d749cf77faaf889b65.tar.gz
Merge branch 'master' into nightly-1.29
Diffstat (limited to 'src/trans/target.cpp')
-rw-r--r--src/trans/target.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/trans/target.cpp b/src/trans/target.cpp
index c1dce972..f91b679a 100644
--- a/src/trans/target.cpp
+++ b/src/trans/target.cpp
@@ -684,13 +684,19 @@ 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_name == "x86" ? 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)
+ if( g_target.m_arch.m_name == "x86" )
+ out_align = 4;
+ else if( /*g_target.m_arch.m_name == "x86_64" && */g_target.m_backend_c.m_codegen_mode == CodegenMode::Msvc )
+ out_align = 8;
+ else
+ out_align = 16;
return true;
case ::HIR::CoreType::Usize:
case ::HIR::CoreType::Isize:
@@ -703,7 +709,7 @@ bool Target_GetSizeAndAlignOf(const Span& sp, const StaticTraitResolve& resolve,
return true;
case ::HIR::CoreType::F64:
out_size = 8;
- out_align = 8;
+ out_align = g_target.m_arch.m_name == "x86" ? 4 : 8;
return true;
case ::HIR::CoreType::Str:
DEBUG("sizeof on a `str` - unsized");