[llvm-commits] CVS: llvm/lib/AsmParser/Lexer.l
Chris Lattner
lattner at cs.uiuc.edu
Tue Apr 22 15:21:04 PDT 2003
Changes in directory llvm/lib/AsmParser:
Lexer.l updated: 1.32 -> 1.33
---
Log message:
Use a union to cast int to fp
---
Diffs of the changes:
Index: llvm/lib/AsmParser/Lexer.l
diff -u llvm/lib/AsmParser/Lexer.l:1.32 llvm/lib/AsmParser/Lexer.l:1.33
--- llvm/lib/AsmParser/Lexer.l:1.32 Tue Apr 22 14:07:06 2003
+++ llvm/lib/AsmParser/Lexer.l Tue Apr 22 15:20:28 2003
@@ -73,15 +73,17 @@
// 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
}
More information about the llvm-commits
mailing list