diff options
author | Jim Laskey <jlaskey@mac.com> | 2005-08-17 19:34:49 +0000 |
---|---|---|
committer | Jim Laskey <jlaskey@mac.com> | 2005-08-17 19:34:49 +0000 |
commit | cb6682fa44e13262bdef7dd22b4ba90f8c2e7b97 (patch) | |
tree | 7007ebf49e8bf80c2f04c0df03980f65ddd88077 /lib/Bytecode/Reader/Reader.cpp | |
parent | 8482dd894d7d64134f999d8e62bc9adf5cb239a9 (diff) |
Culling out use of unions for converting FP to bits and vice versa.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22838 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode/Reader/Reader.cpp')
-rw-r--r-- | lib/Bytecode/Reader/Reader.cpp | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index f56c59ad18..6bb06c3ce4 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -27,6 +27,7 @@ #include "llvm/Config/alloca.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/Compressor.h" +#include "llvm/Support/MathExtras.h" #include "llvm/ADT/StringExtras.h" #include <sstream> #include <algorithm> @@ -162,29 +163,19 @@ inline void BytecodeReader::read_data(void *Ptr, void *End) { inline void BytecodeReader::read_float(float& FloatVal) { /// FIXME: This isn't optimal, it has size problems on some platforms /// where FP is not IEEE. - union { - float f; - uint32_t i; - } FloatUnion; - FloatUnion.i = At[0] | (At[1] << 8) | (At[2] << 16) | (At[3] << 24); + FloatVal = BitsToFloat(At[0] | (At[1] << 8) | (At[2] << 16) | (At[3] << 24)); At+=sizeof(uint32_t); - FloatVal = FloatUnion.f; } /// Read a double value in little-endian order inline void BytecodeReader::read_double(double& DoubleVal) { /// FIXME: This isn't optimal, it has size problems on some platforms /// where FP is not IEEE. - union { - double d; - uint64_t i; - } DoubleUnion; - DoubleUnion.i = (uint64_t(At[0]) << 0) | (uint64_t(At[1]) << 8) | - (uint64_t(At[2]) << 16) | (uint64_t(At[3]) << 24) | - (uint64_t(At[4]) << 32) | (uint64_t(At[5]) << 40) | - (uint64_t(At[6]) << 48) | (uint64_t(At[7]) << 56); + DoubleVal = BitsToDouble((uint64_t(At[0]) << 0) | (uint64_t(At[1]) << 8) | + (uint64_t(At[2]) << 16) | (uint64_t(At[3]) << 24) | + (uint64_t(At[4]) << 32) | (uint64_t(At[5]) << 40) | + (uint64_t(At[6]) << 48) | (uint64_t(At[7]) << 56)); At+=sizeof(uint64_t); - DoubleVal = DoubleUnion.d; } /// Read a block header and obtain its type and size |