diff options
author | Chris Lattner <sabre@nondot.org> | 2003-04-22 20:20:28 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-04-22 20:20:28 +0000 |
commit | 62fa743e7501d46d19dffd5714b0e55f406e906f (patch) | |
tree | ec62f85c12774c5971d8b3cb13dcb92c42476a73 | |
parent | dd4745241f023719294440a77b66ea3f10fb27dc (diff) | |
download | bcm5719-llvm-62fa743e7501d46d19dffd5714b0e55f406e906f.tar.gz bcm5719-llvm-62fa743e7501d46d19dffd5714b0e55f406e906f.zip |
Use a union to cast int to fp
llvm-svn: 5849
-rw-r--r-- | llvm/lib/AsmParser/Lexer.l | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/llvm/lib/AsmParser/Lexer.l b/llvm/lib/AsmParser/Lexer.l index 92d4f3424f8..85852e28513 100644 --- a/llvm/lib/AsmParser/Lexer.l +++ b/llvm/lib/AsmParser/Lexer.l @@ -73,15 +73,17 @@ static uint64_t HexIntToVal(const char *Buffer) { // point representation of it. // static double HexToFP(const char *Buffer) { - uint64_t Result = HexIntToVal(Buffer); - - assert(sizeof(double) == sizeof(Result) && - "Data sizes incompatible on this target!"); // Behave nicely in the face of C TBAA rules... see: // http://www.nullstone.com/htmls/category/aliastyp.htm - // - char *ProxyPointer = (char*)&Result; - return *(double*)ProxyPointer; // Cast Hex constant to double + union { + uint64_t UI; + double FP; + } UIntToFP; + UIntToFP.UI = HexIntToVal(Buffer); + + assert(sizeof(double) == sizeof(uint64_t) && + "Data sizes incompatible on this target!"); + return UIntToFP.FP; // Cast Hex constant to double } |