llvm.org GIT mirror llvm / 7a5a1f7
Use a union to cast int to fp git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5849 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 17 years ago
1 changed file(s) with 9 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
7272 // point representation of it.
7373 //
7474 static double HexToFP(const char *Buffer) {
75 uint64_t Result = HexIntToVal(Buffer);
76
77 assert(sizeof(double) == sizeof(Result) &&
78 "Data sizes incompatible on this target!");
7975 // Behave nicely in the face of C TBAA rules... see:
8076 // http://www.nullstone.com/htmls/category/aliastyp.htm
81 //
82 char *ProxyPointer = (char*)&Result;
83 return *(double*)ProxyPointer; // Cast Hex constant to double
77 union {
78 uint64_t UI;
79 double FP;
80 } UIntToFP;
81 UIntToFP.UI = HexIntToVal(Buffer);
82
83 assert(sizeof(double) == sizeof(uint64_t) &&
84 "Data sizes incompatible on this target!");
85 return UIntToFP.FP; // Cast Hex constant to double
8486 }
8587
8688