Commit adaaa7f7 authored by Ben.Lippmeier@anu.edu.au's avatar Ben.Lippmeier@anu.edu.au
Browse files

SPARC: Fix ffi019 split load/store of HsInt64 into two parts to respect alignment constraints

parent 0bff9925
......@@ -152,6 +152,31 @@ rts_mkWord32 (Capability *cap, HsWord32 w)
return p;
}
#ifdef sparc_HOST_ARCH
/* The closures returned by allocateLocal are only guaranteed to be 32 bit
aligned, because that's the size of pointers. SPARC v9 can't do
misaligned loads/stores, so we have to write the 64bit word in chunks */
HaskellObj
rts_mkWord64 (Capability *cap, HsWord64 w_)
{
StgWord64 w = (StgWord64)w_;
StgWord32 *tmp;
StgClosure *p = (StgClosure *)allocateLocal(cap,CONSTR_sizeW(0,2));
/* see mk_Int8 comment */
SET_HDR(p, W64zh_con_info, CCS_SYSTEM);
tmp = (StgWord32*)&(p->payload[0]);
tmp[0] = (StgWord32)((StgWord64)w >> 32);
tmp[1] = (StgWord32)w; /* truncate high 32 bits */
return p;
}
#else
HaskellObj
rts_mkWord64 (Capability *cap, HsWord64 w)
{
......@@ -165,6 +190,9 @@ rts_mkWord64 (Capability *cap, HsWord64 w)
return p;
}
#endif
HaskellObj
rts_mkFloat (Capability *cap, HsFloat f)
{
......@@ -364,6 +392,26 @@ rts_getWord32 (HaskellObj p)
}
#ifdef sparc_HOST_ARCH
/* The closures returned by allocateLocal are only guaranteed to be 32 bit
aligned, because that's the size of pointers. SPARC v9 can't do
misaligned loads/stores, so we have to write the 64bit word in chunks */
HsWord64
rts_getWord64 (HaskellObj p)
{
HsInt32* tmp;
// See comment above:
// ASSERT(p->header.info == I64zh_con_info ||
// p->header.info == I64zh_static_info);
tmp = (HsInt32*)&(UNTAG_CLOSURE(p)->payload[0]);
HsInt64 i = (HsWord64)((HsWord64)(tmp[0]) << 32) | (HsWord64)tmp[1];
return i;
}
#else
HsWord64
rts_getWord64 (HaskellObj p)
{
......@@ -375,6 +423,9 @@ rts_getWord64 (HaskellObj p)
return *tmp;
}
#endif
HsFloat
rts_getFloat (HaskellObj p)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment