import MachOp ( MachOp(..) )
import PrimRep ( PrimRep(..), getPrimRepSizeInBytes )
import UniqSupply ( returnUs, thenUs, getUniqueUs, UniqSM )
-import Constants ( wORD_SIZE,
- mIN_INTLIKE, mIN_CHARLIKE, uF_UPDATEE, bLOCK_SIZE,
+import Constants ( mIN_INTLIKE, mIN_CHARLIKE, bLOCK_SIZE,
rESERVED_STACK_WORDS )
import CLabel ( mkIntlikeClosureLabel, mkCharlikeClosureLabel,
- mkMAP_FROZEN_infoLabel,
mkForeignLabel )
import ForeignCall ( ForeignCall(..), CCallSpec(..), CCallTarget(..),
CCallConv(..), playSafe, playThreadSafe )
import Outputable
import Util ( notNull )
+import FastString
import FastTypes
#include "NCG.h"
%* *
%************************************************************************
-First, the dreaded @ccall@. We can't handle @casm@s.
+First, the dreaded @ccall@.
Usually, this compiles to an assignment, but when the left-hand side
is empty, we just perform the call and ignore the result.
-btw Why not let programmer use casm to provide assembly code instead
-of C code? ADR
-
ToDo: saving/restoring of volatile regs around ccalls.
JRS, 001113: always do the call of suspendThread and resumeThread as a ccall
StaticTarget nm -> (rhs, Left nm)
DynamicTarget | notNull rhs -- an assertion
-> (tail rhs, Right (amodeToStix (head rhs)))
- CasmTarget _
- -> ncgPrimopMoan "Native code generator can't handle foreign call"
- (ppr call)
stix_args = map amodeToStix' cargs
Int64Rep -> Int64Rep
Word64Rep -> Word64Rep
other -> IntRep
+
+-- a bit late to catch this here..
+foreignCallCode _ DNCall{} _
+ = panic "foreignCallCode: .NET interop not supported via NCG; compile with -fvia-C"
\end{code}
%************************************************************************
amodeToStix (CVal rr pk) = StInd pk (amodeToStix (CAddr rr))
-amodeToStix CBytesPerWord
- = StInt (toInteger wORD_SIZE)
-
amodeToStix (CAddr (SpRel off))
= StIndex PtrRep (StReg stgSp) (StInt (toInteger (iBox off)))
= case core of
MachChar c -> StInt (toInteger c)
MachStr s -> StString s
- MachAddr a -> StInt a
+ MachNullAddr -> StInt 0
MachInt i -> StInt i
MachWord w -> case word2IntLit core of MachInt iw -> StInt iw
- MachLitLit s _ -> litLitErr
- MachLabel l -> StCLbl (mkForeignLabel l False{-ToDo: dynamic-})
+ -- dreadful, but rare.
+ MachLabel l (Just x) -> StCLbl (mkForeignLabel (mkFastString (unpackFS l ++ '@':show x)) False)
+ MachLabel l _ -> StCLbl (mkForeignLabel l False{-ToDo: dynamic-})
MachFloat d -> StFloat d
MachDouble d -> StDouble d
_ -> panic "amodeToStix:core literal"
(StInt (toInteger (-1)))),
StInt 16]
#endif
- UPD_FRAME_UPDATEE
- -> StInd PtrRep (StIndex PtrRep arg_amode
- (StInt (toInteger uF_UPDATEE)))
-
BYTE_ARR_CTS -> StIndex IntRep arg_amode arrWordsHS
PTRS_ARR_CTS -> StIndex PtrRep arg_amode arrPtrsHS
ForeignObj_CLOSURE_DATA -> StInd PtrRep (StIndex PtrRep arg_amode fixedHS)
amodeToStix other
= pprPanic "StixPrim.amodeToStix" (pprAmode other)
-
-litLitErr
- = ncgPrimopMoan "native code generator can't handle lit-lits" empty
\end{code}
Sizes of the CharLike and IntLike closures that are arranged as arrays
cHARLIKE_closure :: StixExpr
cHARLIKE_closure = StCLbl mkCharlikeClosureLabel
-mutArrPtrsFrozen_info = StCLbl mkMAP_FROZEN_infoLabel
-
-- these are the sizes of charLike and intLike closures, in _bytes_.
charLikeSize = (fixedHdrSize + 1) * (getPrimRepSizeInBytes PtrRep)
intLikeSize = (fixedHdrSize + 1) * (getPrimRepSizeInBytes PtrRep)