summaryrefslogtreecommitdiff
path: root/compiler/stgSyn
diff options
context:
space:
mode:
authorDuncan Coutts <duncan@well-typed.com>2009-06-09 15:11:55 +0000
committerDuncan Coutts <duncan@well-typed.com>2009-06-09 15:11:55 +0000
commitcbbee4e8727c583daf32d9bf17f00afaa839ef10 (patch)
treeb86e3e566d90444803eb6fc7592cf2a162d04d94 /compiler/stgSyn
parent5b7e2a875b089f31cd8dedb52d47ef9a93f276be (diff)
downloadhaskell-cbbee4e8727c583daf32d9bf17f00afaa839ef10.tar.gz
Add PrimCall to the STG layer and update Core -> STG translation
It adds a third case to StgOp which already hold StgPrimOp and StgFCallOp. The code generation for the new StgPrimCallOp case is almost exactly the same as for out-of-line primops. They now share the tailCallPrim function. In the Core -> STG translation we map foreign calls using the "prim" calling convention to the StgPrimCallOp case. This is because in Core we represent prim calls using the ForeignCall stuff. At the STG level however the prim calls are really much more like primops than foreign calls.
Diffstat (limited to 'compiler/stgSyn')
-rw-r--r--compiler/stgSyn/CoreToStg.lhs7
-rw-r--r--compiler/stgSyn/StgSyn.lhs5
2 files changed, 11 insertions, 1 deletions
diff --git a/compiler/stgSyn/CoreToStg.lhs b/compiler/stgSyn/CoreToStg.lhs
index 6dd0255d60..b2d725796d 100644
--- a/compiler/stgSyn/CoreToStg.lhs
+++ b/compiler/stgSyn/CoreToStg.lhs
@@ -34,6 +34,8 @@ import Outputable
import MonadUtils
import FastString
import Util
+import ForeignCall
+import PrimOp ( PrimCall(..) )
\end{code}
%************************************************************************
@@ -528,6 +530,11 @@ coreToStgApp _ f args = do
DataConWorkId dc | saturated -> StgConApp dc args'
PrimOpId op -> ASSERT( saturated )
StgOpApp (StgPrimOp op) args' res_ty
+ FCallId (CCall (CCallSpec (StaticTarget lbl) PrimCallConv _))
+ -- prim calls are represented as FCalls in core,
+ -- but in stg we distinguish them
+ -> ASSERT( saturated )
+ StgOpApp (StgPrimCallOp (PrimCall lbl)) args' res_ty
FCallId call -> ASSERT( saturated )
StgOpApp (StgFCallOp call (idUnique f)) args' res_ty
TickBoxOpId {} -> pprPanic "coreToStg TickBox" $ ppr (f,args')
diff --git a/compiler/stgSyn/StgSyn.lhs b/compiler/stgSyn/StgSyn.lhs
index 2530843556..973514cbaf 100644
--- a/compiler/stgSyn/StgSyn.lhs
+++ b/compiler/stgSyn/StgSyn.lhs
@@ -56,7 +56,7 @@ import ForeignCall ( ForeignCall )
import DataCon ( DataCon, dataConName )
import CoreSyn ( AltCon )
import PprCore ( {- instances -} )
-import PrimOp ( PrimOp )
+import PrimOp ( PrimOp, PrimCall )
import Outputable
import Type ( Type )
import TyCon ( TyCon )
@@ -557,6 +557,8 @@ in StgOpApp and COpStmt.
\begin{code}
data StgOp = StgPrimOp PrimOp
+ | StgPrimCallOp PrimCall
+
| StgFCallOp ForeignCall Unique
-- The Unique is occasionally needed by the C pretty-printer
-- (which lacks a unique supply), notably when generating a
@@ -765,6 +767,7 @@ pprStgAlt (con, params, _use_mask, expr)
pprStgOp :: StgOp -> SDoc
pprStgOp (StgPrimOp op) = ppr op
+pprStgOp (StgPrimCallOp op)= ppr op
pprStgOp (StgFCallOp op _) = ppr op
instance Outputable AltType where