-- the call goes into a loop.
}
-data MidCallTarget -- The target of a MidUnsafeCall
- = ForeignTarget -- A foreign procedure
- CmmExpr -- Its address
- ForeignConvention -- Its calling convention
+data MidCallTarget -- The target of a MidUnsafeCall
+ = ForeignTarget -- A foreign procedure
+ CmmExpr -- Its address
+ ForeignConvention -- Its calling convention
- | PrimTarget -- A possibly-side-effecting machine operation
- CallishMachOp -- Which one
+ | PrimTarget -- A possibly-side-effecting machine operation
+ CallishMachOp -- Which one
deriving Eq
data Convention
foldRegsUsed f z (ForeignTarget e _) = foldRegsUsed f z e
instance UserOfSlots MidCallTarget where
+ foldSlotsUsed f z (ForeignTarget e _) = foldSlotsUsed f z e
foldSlotsUsed _f z (PrimTarget _) = z
- foldSlotsUsed f z (ForeignTarget e _) = foldSlotsUsed f z e
instance (UserOfLocalRegs a) => UserOfLocalRegs (Maybe a) where
foldRegsUsed f z (Just x) = foldRegsUsed f z x
-- call "ccall" foo(x, y)[r1, r2];
-- ToDo ppr volatile
MidForeignCall safety target results args ->
- hsep [ if null results
- then empty
- else parens (commafy $ map ppr results) <+> equals,
- ppr_safety safety,
+ hsep [ ppUnless (null results) $
+ parens (commafy $ map ppr results) <+> equals,
+ ppr_safety safety,
ptext $ sLit "call",
ppr_call_target target <> parens (commafy $ map ppr args) <> semi]
ppr_call_target :: MidCallTarget -> SDoc
ppr_call_target (ForeignTarget fn c) = ppr_fc c <+> ppr_target fn
-ppr_call_target (PrimTarget op) = ppr (CmmLabel (mkForeignLabel (mkFastString (show op)) Nothing False IsFunction))
+ppr_call_target (PrimTarget op) =
+ ppr (CmmLabel (mkForeignLabel (mkFastString (show op)) Nothing False IsFunction))
ppr_target :: CmmExpr -> SDoc
ppr_target t@(CmmLit _) = ppr t