-- And some particular Ids; see below for why they are wired in
wiredInIds,
- unsafeCoerceId, realWorldPrimId,
+ unsafeCoerceId, realWorldPrimId, nullAddrId,
eRROR_ID, eRROR_CSTRING_ID, rEC_SEL_ERROR_ID, pAT_ERROR_ID, rEC_CON_ERROR_ID,
rEC_UPD_ERROR_ID, iRREFUT_PAT_ERROR_ID, nON_EXHAUSTIVE_GUARDS_ERROR_ID,
nO_METHOD_BINDING_ERROR_ID, aBSENT_ERROR_ID, pAR_ERROR_ID
import Module ( Module )
import CoreUtils ( mkInlineMe )
import CoreUnfold ( mkTopUnfolding, mkCompulsoryUnfolding, mkOtherCon )
-import Literal ( Literal(..) )
+import Literal ( Literal(..), nullAddrLit )
import TyCon ( TyCon, isNewTyCon, tyConTyVars, tyConDataCons,
tyConTheta, isProductTyCon, isDataTyCon, isRecursiveTyCon )
import Class ( Class, classTyCon, classTyVars, classSelIds )
, rEC_CON_ERROR_ID
, rEC_UPD_ERROR_ID
- -- These three can't be defined in Haskell
+ -- These can't be defined in Haskell, but they have
+ -- perfectly reasonable unfoldings in Core
, realWorldPrimId
, unsafeCoerceId
+ , nullAddrId
, getTagId
, seqId
]
These Ids can't be defined in Haskell. They could be defined in
unfoldings in PrelGHC.hi-boot, but we'd have to ensure that they
were definitely, definitely inlined, because there is no curried
-identifier for them. Thats what mkCompulsoryUnfolding does.
+identifier for them. That's what mkCompulsoryUnfolding does.
If we had a way to get a compulsory unfolding from an interface file,
we could do that, but we don't right now.
rhs = mkLams [openAlphaTyVar,openBetaTyVar,x] $
Note (Coerce openBetaTy openAlphaTy) (Var x)
+-- nullAddr# :: Addr#
+-- The reason is is here is because we don't provide
+-- a way to write this literal in Haskell.
+nullAddrId
+ = pcMiscPrelId nullAddrIdKey pREL_GHC SLIT("nullAddr#") addrPrimTy info
+ where
+ info = noCafNoTyGenIdInfo `setUnfoldingInfo`
+ mkCompulsoryUnfolding (Lit nullAddrLit)
+
seqId
= pcMiscPrelId seqIdKey pREL_GHC SLIT("seq") ty info
where
printIdKey = mkPreludeMiscIdUnique 43
failIOIdKey = mkPreludeMiscIdUnique 44
unpackCStringListIdKey = mkPreludeMiscIdUnique 45
+nullAddrIdKey = mkPreludeMiscIdUnique 46
\end{code}
Certain class operations from Prelude classes. They get their own
, narrow8WordLit, narrow16WordLit, narrow32WordLit
, char2IntLit, int2CharLit
, float2IntLit, int2FloatLit, double2IntLit, int2DoubleLit
- , nullAddrLit, float2DoubleLit, double2FloatLit
+ , float2DoubleLit, double2FloatLit
)
import PrimOp ( PrimOp(..), primOpOcc )
import TysWiredIn ( trueDataConId, falseDataConId )
-- ToDo: something for integer-shift ops?
-- NotOp
- primop_rule AddrNullOp = one_rule nullAddrRule
primop_rule SeqOp = one_rule seqRule
primop_rule TagToEnumOp = one_rule tagToEnumRule
primop_rule DataToTagOp = one_rule dataToTagRule
mkDoubleVal d = Lit (convFloating (MachDouble d))
\end{code}
-\begin{code}
-nullAddrRule _ = Just(Lit nullAddrLit)
-\end{code}
-
%************************************************************************
%* *
-----------------------------------------------------------------------
--- $Id: primops.txt.pp,v 1.7 2001/10/16 13:31:56 simonmar Exp $
+-- $Id: primops.txt.pp,v 1.8 2001/10/17 11:26:04 simonpj Exp $
--
-- Primitive Operations
--
--
-- To add a new primop, you currently need to update the following files:
--
--- - this file (ghc/compiler/prelude/primops.txt), which includes
+-- - this file (ghc/compiler/prelude/primops.txt.pp), which includes
-- the type of the primop, and various other properties (its
-- strictness attributes, whether it is defined as a macro
-- or as out-of-line code, etc.)
------------------------------------------------------------------------
section "Addr#"
{Addr\# is an arbitrary machine address assumed to point outside
- the garbage-collected heap.}
+ the garbage-collected heap.
+
+ NB: {\tt nullAddr\#::Addr\#} is not a primop, but is defined in MkId.lhs.
+ It is the null address.}
------------------------------------------------------------------------
-primop AddrNullOp "nullAddr#" GenPrimOp Int# -> Addr#
- {Returns null address. Argument is ignored (nullary primops
- don't quite work!)}
primop AddrAddOp "plusAddr#" GenPrimOp Addr# -> Int# -> Addr#
primop AddrSubOp "minusAddr#" GenPrimOp Addr# -> Addr# -> Int#
{Result is meaningless if two Addr\#s are so far apart that their
out_of_line = True
------------------------------------------------------------------------
+section "Coercion"
+ {{\tt unsafeCoerce# :: a -> b} is not a primop, but is defined in MkId.lhs.}
+
+------------------------------------------------------------------------
+
+
+------------------------------------------------------------------------
--- ---
------------------------------------------------------------------------
isEmptyMVarzh
-- Seq
- seq
+ seq -- Defined in MkId
-- Parallel
seqzh
#endif
Addrzh
- nullAddrzh
+ nullAddrzh -- Defined in MkId
plusAddrzh
minusAddrzh
remAddrzh
BCOzh
mkApUpd0zh
- unsafeCoercezh
+ unsafeCoercezh -- Defined in MkId
addrToHValuezh
;
-----------------------------------------------------------------------------
--- $Id: PrelPtr.lhs,v 1.3 2001/08/17 17:18:54 apt Exp $
+-- $Id: PrelPtr.lhs,v 1.4 2001/10/17 11:26:04 simonpj Exp $
--
-- (c) 2000
--
data Ptr a = Ptr Addr# deriving (Eq, Ord)
nullPtr :: Ptr a
-nullPtr = Ptr (nullAddr# 0#)
+nullPtr = Ptr nullAddr#
castPtr :: Ptr a -> Ptr b
castPtr (Ptr addr) = Ptr addr
data FunPtr a = FunPtr Addr# deriving (Eq, Ord)
nullFunPtr :: FunPtr a
-nullFunPtr = FunPtr (nullAddr# 0#)
+nullFunPtr = FunPtr nullAddr#
castFunPtr :: FunPtr a -> FunPtr b
castFunPtr (FunPtr addr) = FunPtr addr