mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-16 14:31:59 +00:00
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
This commit is contained in:
parent
8829dcd15b
commit
7a5a1f790f
@ -73,15 +73,17 @@ static uint64_t HexIntToVal(const char *Buffer) {
|
|||||||
// point representation of it.
|
// point representation of it.
|
||||||
//
|
//
|
||||||
static double HexToFP(const char *Buffer) {
|
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:
|
// Behave nicely in the face of C TBAA rules... see:
|
||||||
// http://www.nullstone.com/htmls/category/aliastyp.htm
|
// http://www.nullstone.com/htmls/category/aliastyp.htm
|
||||||
//
|
union {
|
||||||
char *ProxyPointer = (char*)&Result;
|
uint64_t UI;
|
||||||
return *(double*)ProxyPointer; // Cast Hex constant to double
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user