= case mop of
MO_NatS_Neg -> trivialUCode (SUB False False g0) x
MO_Nat_Not -> trivialUCode (XNOR False g0) x
+ MO_32U_to_8U -> trivialCode (AND False) x (StInt 255)
MO_Flt_Neg -> trivialUFCode FloatRep (FNEG F) x
MO_Dbl_Neg -> trivialUFCode DoubleRep (FNEG DF) x
MO_NatP_to_NatS -> conversionNop IntRep x
-- sign-extending widenings
+ MO_8U_to_32U -> integerExtend False 24 x
MO_8U_to_NatU -> integerExtend False 24 x
MO_8S_to_NatS -> integerExtend True 24 x
MO_16U_to_NatU -> integerExtend False 16 x
#if i386_TARGET_ARCH
-genCCall fn cconv ret_rep [StInt i]
- | isLeft fn && unLeft fn == SLIT ("PerformGC_wrapper")
- = let call = toOL [
- MOV L (OpImm (ImmInt (fromInteger i))) (OpReg eax),
- CALL (Left (ImmLit (ptext (if underscorePrefix
- then (SLIT ("_PerformGC_wrapper"))
- else (SLIT ("PerformGC_wrapper"))))))
- ]
- in
- returnNat call
-
-
genCCall fn cconv ret_rep args
= mapNat push_arg
(reverse args) `thenNat` \ sizes_n_codes ->
-> returnNat (unitOL (CALL (Left (fn__2 tot_arg_size))))
Right dyn
-> get_op dyn `thenNat` \ (dyn_c, dyn_r, dyn_rep) ->
- ASSERT(dyn_rep == L)
+ ASSERT(case dyn_rep of { L -> True; _ -> False})
returnNat (dyn_c `snocOL` CALL (Right dyn_r))
)
`thenNat` \ callinsns ->
| cconv == StdCallConv = '@':show tot_arg_size
| 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 F = 4
arg_size _ = 4
| otherwise
= get_op arg `thenNat` \ (code, reg, sz) ->
getDeltaNat `thenNat` \ delta ->
- arg_size sz `bind` \ size ->
+ let
+ real_sz = promote_size sz
+ size = arg_size real_sz
+ in
setDeltaNat (delta-size) `thenNat` \ _ ->
- if (case sz of DF -> True; F -> True; _ -> False)
+ if (case real_sz of DF -> True; _ -> False)
then returnNat (size,
code `appOL`
toOL [SUB L (OpImm (ImmInt size)) (OpReg esp),
DELTA (delta-size),
- GST sz reg (AddrBaseIndex (Just esp)
+ GST DF reg (AddrBaseIndex (Just esp)
Nothing
(ImmInt 0))]
)