diff options
author | John Hodge <tpg@mutabah.net> | 2018-02-04 17:38:57 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2018-02-04 17:38:57 +0800 |
commit | 8fb6df4340c186fbc391b18dc026cd868f74b6ac (patch) | |
tree | 85c05f467fad90da983f77dfa6fba971e3cc3ef7 /src/trans/codegen_mmir.cpp | |
parent | 05e399b35d71118b375510d35ca5a89876bcbfcd (diff) | |
download | mrust-8fb6df4340c186fbc391b18dc026cd868f74b6ac.tar.gz |
Trans - mingw32 target attempt (still being worked on)
Diffstat (limited to 'src/trans/codegen_mmir.cpp')
-rw-r--r-- | src/trans/codegen_mmir.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/trans/codegen_mmir.cpp b/src/trans/codegen_mmir.cpp index 9ab406e0..09167486 100644 --- a/src/trans/codegen_mmir.cpp +++ b/src/trans/codegen_mmir.cpp @@ -71,6 +71,13 @@ namespace } ::std::ostream& operator<<(::std::ostream& os, const Fmt<::MIR::Constant>& x) { + struct H { + static uint64_t double_to_u64(double v) { + uint64_t rv; + ::std::memcpy(&rv, &v, sizeof(double)); + return rv; + } + }; const auto& e = x.e; switch(e.tag()) { @@ -83,7 +90,7 @@ namespace break; TU_ARM(e, Float, v) { // TODO: Infinity/nan/... - auto vi = *reinterpret_cast<const uint64_t*>(&v.v); + auto vi = H::double_to_u64(v.v); bool sign = (vi & (1ull << 63)) != 0; int exp = (vi >> 52) & 0x7FF; uint64_t frac = vi & ((1ull << 52) - 1); @@ -222,7 +229,6 @@ namespace m_of << "type " << ty << " {\n"; m_of << "\tSIZE " << repr->size << ", ALIGN " << repr->align << ";\n"; - size_t ofs = 0; for(const auto& e : repr->fields) { m_of << "\t" << e.offset << " = " << e.ty << ";\n"; @@ -277,7 +283,6 @@ namespace MIR_ASSERT(*m_mir_res, repr, "No repr for struct " << ty); m_of << "type " << p << " {\n"; m_of << "\tSIZE " << repr->size << ", ALIGN " << repr->align << ";\n"; - size_t ofs = 0; for(const auto& e : repr->fields) { m_of << "\t" << e.offset << " = " << e.ty << ";\n"; @@ -362,7 +367,6 @@ namespace MIR_ASSERT(*m_mir_res, repr, "No repr for union " << ty); m_of << "type " << p << " {\n"; m_of << "\tSIZE " << repr->size << ", ALIGN " << repr->align << ";\n"; - size_t ofs = 0; for(const auto& e : repr->fields) { m_of << "\t" << e.offset << " = " << e.ty << ";\n"; @@ -407,7 +411,6 @@ namespace MIR_ASSERT(*m_mir_res, repr, "No repr for enum " << ty); m_of << "type " << p << " {\n"; m_of << "\tSIZE " << repr->size << ", ALIGN " << repr->align << ";\n"; - size_t ofs = 0; for(const auto& e : repr->fields) { m_of << "\t" << e.offset << " = " << e.ty << ";\n"; |