import AbsCSyn
import AbsCUtils ( getAmodeRep, mixedTypeLocn )
+import CallConv ( cCallConv )
import Constants ( spARelToInt, spBRelToInt )
import CostCentre ( noCostCentreAttached )
import HeapOffs ( hpRelToInt, subOff )
\end{code}
The @ErrorIO@ primitive is actually a bit weird...assign a new value
-to the root closure, flush stdout and stderr, and jump to the
-@ErrorIO_innards@.
+to the root closure, and jump to the @ErrorIO_innards@.
\begin{code}
primCode [] ErrorIOPrimOp [rhs]
= let
changeTop = StAssign PtrRep topClosure (amodeToStix rhs)
in
- returnUs (\xs -> changeTop : flushStdout : flushStderr : errorIO : xs)
+ returnUs (\xs -> changeTop : errorIO : xs)
\end{code}
@newArray#@ ops allocate heap space.
loc = StIndex PtrRep stgHp
(StPrim IntNegOp [StPrim IntSubOp [space, StInt 1]])
assign = StAssign PtrRep result loc
- initialise = StCall SLIT("newArrZh_init") VoidRep [result, n, initial]
+ initialise = StCall SLIT("newArrZh_init") cCallConv VoidRep [result, n, initial]
in
heapCheck liveness space (StInt 0) `thenUs` \ heap_chk ->
lhs' = amodeToStix lhs
pk = getAmodeRep lhs
sp' = amodeToStix sp
- call = StCall SLIT("deRefStablePointer") pk [sp', smStablePtrTable]
+ call = StCall SLIT("deRefStablePointer") cCallConv pk [sp', smStablePtrTable]
assign = StAssign pk lhs' call
in
returnUs (\xs -> assign : xs)
lhs' = amodeToStix lhs
a' = amodeToStix a
pk = getAmodeRep lhs -- an IntRep
- call = StCall SLIT("SeqZhCode") pk [a']
+ call = StCall SLIT("SeqZhCode") cCallConv pk [a']
assign = StAssign pk lhs' call
in
-- trace "SeqOp" $
returnUs (\xs -> assign : xs)
-primCode lhs (CCallOp fn is_asm may_gc arg_tys result_ty) rhs
+primCode lhs (CCallOp (Just fn) is_asm may_gc cconv arg_tys result_ty) rhs
| is_asm = error "ERROR: Native code generator can't handle casm"
| otherwise
= case lhs of
- [] -> returnUs (\xs -> (StCall fn VoidRep args) : xs)
+ [] -> returnUs (\xs -> (StCall fn cconv VoidRep args) : xs)
[lhs] ->
let lhs' = amodeToStix lhs
pk = if isFloatingRep (getAmodeRep lhs) then DoubleRep else IntRep
- call = StAssign pk lhs' (StCall fn pk args)
+ call = StAssign pk lhs' (StCall fn cconv pk args)
in
returnUs (\xs -> call : xs)
where
amodeToStix (CIntLike (CLit (MachInt i _)))
= StPrim IntAddOp [intLikePtr, StInt off]
where
- off = toInteger intLikeSize * i
+ off = toInteger intLikeSize * toInteger i
amodeToStix (CIntLike x)
= StPrim IntAddOp [intLikePtr, off]
MachChar c -> StInt (toInteger (ord c))
MachStr s -> StString s
MachAddr a -> StInt a
- MachInt i _ -> StInt i
+ MachInt i _ -> StInt (toInteger i)
MachLitLit s _ -> StLitLit s
MachFloat d -> StDouble d
MachDouble d -> StDouble d
-- Trees for the ErrorIOPrimOp
-topClosure, flushStdout, flushStderr, errorIO :: StixTree
+topClosure, errorIO :: StixTree
topClosure = StInd PtrRep (sStLitLbl SLIT("TopClosure"))
-flushStdout = StCall SLIT("fflush") VoidRep [StLitLit SLIT("stdout")]
-flushStderr = StCall SLIT("fflush") VoidRep [StLitLit SLIT("stderr")]
errorIO = StJump (StInd PtrRep (sStLitLbl SLIT("ErrorIO_innards")))
\end{code}