Commit c50d5acc authored by simonmar's avatar simonmar
Browse files

[project @ 2002-03-12 16:48:52 by simonmar]

Fix a bug in the native code generator's handling of floating-point
arguments to ccalls: it wasn't correctly promoting float arguments to
doubles.  Amazingly this has gone undetected for quite a while.

Fixes bug #523996.
parent d0bf18ef
...@@ -2752,6 +2752,10 @@ genCCall fn cconv ret_rep args ...@@ -2752,6 +2752,10 @@ genCCall fn cconv ret_rep args
| cconv == StdCallConv = '@':show tot_arg_size | cconv == StdCallConv = '@':show tot_arg_size
| otherwise = "" | otherwise = ""
-- floats are always promoted to doubles when passed to a ccall
promote_size F = DF
promote_size sz = sz
arg_size DF = 8 arg_size DF = 8
arg_size F = 4 arg_size F = 4
arg_size _ = 4 arg_size _ = 4
...@@ -2775,14 +2779,17 @@ genCCall fn cconv ret_rep args ...@@ -2775,14 +2779,17 @@ genCCall fn cconv ret_rep args
| otherwise | otherwise
= get_op arg `thenNat` \ (code, reg, sz) -> = get_op arg `thenNat` \ (code, reg, sz) ->
getDeltaNat `thenNat` \ delta -> getDeltaNat `thenNat` \ delta ->
arg_size sz `bind` \ size -> let
real_sz = promote_size sz
size = arg_size real_sz
in
setDeltaNat (delta-size) `thenNat` \ _ -> setDeltaNat (delta-size) `thenNat` \ _ ->
if (case sz of DF -> True; F -> True; _ -> False) if (case real_sz of DF -> True; _ -> False)
then returnNat (size, then returnNat (size,
code `appOL` code `appOL`
toOL [SUB L (OpImm (ImmInt size)) (OpReg esp), toOL [SUB L (OpImm (ImmInt size)) (OpReg esp),
DELTA (delta-size), DELTA (delta-size),
GST sz reg (AddrBaseIndex (Just esp) GST DF reg (AddrBaseIndex (Just esp)
Nothing Nothing
(ImmInt 0))] (ImmInt 0))]
) )
......
Supports Markdown
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