X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Fprelude%2FPrimOp.lhs;h=29c5644346e8ea47e4f5b31d0d44fcf93b391776;hp=a9a8fa277e588030d03d8e0c715d64faa898f66f;hb=7b5b3b0cab463e108a0132435a28ef19d17cb32b;hpb=cbbee4e8727c583daf32d9bf17f00afaa839ef10 diff --git a/compiler/prelude/PrimOp.lhs b/compiler/prelude/PrimOp.lhs index a9a8fa2..29c5644 100644 --- a/compiler/prelude/PrimOp.lhs +++ b/compiler/prelude/PrimOp.lhs @@ -18,8 +18,8 @@ module PrimOp ( tagToEnumKey, - primOpOutOfLine, primOpNeedsWrapper, - primOpOkForSpeculation, primOpIsCheap, primOpIsDupable, + primOpOutOfLine, primOpCodeSize, + primOpOkForSpeculation, primOpIsCheap, getPrimOpResultInfo, PrimOpResultInfo(..), @@ -31,7 +31,7 @@ module PrimOp ( import TysPrim import TysWiredIn -import NewDemand +import Demand import Var ( TyVar ) import OccName ( OccName, pprOccName, mkVarOccFS ) import TyCon ( TyCon, isPrimTyCon, tyConPrimRep, PrimRep(..) ) @@ -43,6 +43,7 @@ import Unique ( Unique, mkPrimOpIdUnique ) import Outputable import FastTypes import FastString +import Module ( PackageId ) \end{code} %************************************************************************ @@ -362,18 +363,23 @@ primOpIsCheap op = primOpOkForSpeculation op -- even if primOpIsCheap sometimes says 'True'. \end{code} -primOpIsDupable -~~~~~~~~~~~~~~~ -primOpIsDupable means that the use of the primop is small enough to -duplicate into different case branches. See CoreUtils.exprIsDupable. +primOpCodeSize +~~~~~~~~~~~~~~ +Gives an indication of the code size of a primop, for the purposes of +calculating unfolding sizes; see CoreUnfold.sizeExpr. \begin{code} -primOpIsDupable :: PrimOp -> Bool - -- See comments with CoreUtils.exprIsDupable - -- We say it's dupable it isn't implemented by a C call with a wrapper -primOpIsDupable op = not (primOpNeedsWrapper op) -\end{code} +primOpCodeSize :: PrimOp -> Int +#include "primop-code-size.hs-incl" + +primOpCodeSizeDefault :: Int +primOpCodeSizeDefault = 1 + -- CoreUnfold.primOpSize already takes into account primOpOutOfLine + -- and adds some further costs for the args in that case. +primOpCodeSizeForeignCall :: Int +primOpCodeSizeForeignCall = 4 +\end{code} \begin{code} primOpCanFail :: PrimOp -> Bool @@ -420,14 +426,6 @@ primOpHasSideEffects :: PrimOp -> Bool #include "primop-has-side-effects.hs-incl" \end{code} -Inline primitive operations that perform calls need wrappers to save -any live variables that are stored in caller-saves registers. - -\begin{code} -primOpNeedsWrapper :: PrimOp -> Bool -#include "primop-needs-wrapper.hs-incl" -\end{code} - \begin{code} primOpType :: PrimOp -> Type -- you may want to use primOpSig instead primOpType op @@ -517,9 +515,10 @@ pprPrimOp other_op = pprOccName (primOpOcc other_op) %************************************************************************ \begin{code} -newtype PrimCall = PrimCall CLabelString +data PrimCall = PrimCall CLabelString PackageId instance Outputable PrimCall where - ppr (PrimCall lbl) = ppr lbl + ppr (PrimCall lbl pkgId) + = text "__primcall" <+> ppr pkgId <+> ppr lbl \end{code}