)
import VarEnv
import VarSet
+import Module ( Module )
import Name ( mkLocalName, tidyOccName, tidyTopName, initTidyOccEnv, isExported,
- Module, NamedThing(..), OccName
+ NamedThing(..), OccName
)
import TyCon ( TyCon, isDataTyCon )
import PrimOp ( PrimOp(..) )
-import PrelInfo ( unpackCStringId, unpackCString2Id,
- integerZeroId, integerPlusOneId,
- integerPlusTwoId, integerMinusOneId,
- int2IntegerId, addr2IntegerId
- )
+import PrelInfo ( unpackCStringId, unpackCString2Id, addr2IntegerId )
import Type ( Type, splitAlgTyConApp_maybe,
- isUnLiftedType, mkTyVarTy,
+ isUnLiftedType,
tidyType, tidyTypes, tidyTopType, tidyTyVar, tidyTyVars,
Type
)
import Class ( Class, classSelIds )
-import TysWiredIn ( isIntegerTy )
+import TysWiredIn ( smallIntegerDataCon, isIntegerTy )
import LiberateCase ( liberateCase )
import SAT ( doStaticArgs )
import Specialise ( specProgram)
import UniqSupply ( UniqSupply, splitUniqSupply, uniqFromSupply )
import Constants ( tARGET_MIN_INT, tARGET_MAX_INT )
import Util ( mapAccumL )
+import SrcLoc ( noSrcLoc )
import Bag
import Maybes
import IO ( hPutStr, stderr )
import Outputable
+
+import Ratio ( numerator, denominator )
\end{code}
\begin{code}
doCorePass us binds CoreDoStaticArgs = _scc_ "CoreStaticArgs" doStaticArgs us binds
doCorePass us binds CoreDoStrictness = _scc_ "CoreStranal" saWwTopBinds us binds
doCorePass us binds CoreDoSpecialising = _scc_ "Specialise" specProgram us binds
+doCorePass us binds CoreDoPrintCore = _scc_ "PrintCore" do
+ putStr (showSDoc $ pprCoreBindings binds)
+ return binds
\end{code}
(us1, us2) = splitUniqSupply us
-simplTopBinds [] = returnSmpl []
-simplTopBinds (bind1 : binds) = (simplBind bind1 $
- simplTopBinds binds) `thenSmpl` \ (binds1', binds') ->
- returnSmpl (binds1' ++ binds')
+simplTopBinds binds = go binds `thenSmpl` \ (binds', _) ->
+ returnSmpl binds'
+ where
+ go [] = returnSmpl ([], ())
+ go (bind1 : binds) = simplBind bind1 (go binds)
\end{code}
(env', vs') = mapAccumL tidyNestedBndr env vs
tidyNote env (Coerce t1 t2) = Coerce (tidyType env t1) (tidyType env t2)
+
+tidyNote env note = note
\end{code}
\begin{code}
= -- Non-top-level variables
let
-- Give the Id a fresh print-name, *and* rename its type
- name' = mkLocalName (getUnique id) occ'
+ -- The SrcLoc isn't important now, though we could extract it from the Id
+ name' = mkLocalName (getUnique id) occ' noSrcLoc
(tidy_env', occ') = tidyOccName tidy_env (getOccName id)
ty' = tidyType env (idType id)
id' = mkUserId name' ty'
info3 = noUnfolding `setUnfoldingInfo` info2
tidy_item (tyvars, tys, rhs)
- = (tyvars', tidyTypes env' tys, tidyExpr env rhs)
+ = (tyvars', tidyTypes env' tys, tidyExpr env' rhs)
where
(env', tyvars') = tidyTyVars env tyvars
\end{code}
If an Integer is small enough (Haskell implementations must support
Ints in the range $[-2^29+1, 2^29-1]$), wrap it up in @int2Integer@;
-otherwise, wrap with @litString2Integer@.
+otherwise, wrap with @addr2Integer@.
\begin{code}
litToRep (NoRepInteger i integer_ty)
= returnPM (integer_ty, rhs)
where
- rhs | i == 0 = Var integerZeroId -- Extremely convenient to look out for
- | i == 1 = Var integerPlusOneId -- a few very common Integer literals!
- | i == 2 = Var integerPlusTwoId
- | i == (-1) = Var integerMinusOneId
-
- | i > tARGET_MIN_INT && -- Small enough, so start from an Int
+ rhs | i > tARGET_MIN_INT && -- Small enough, so start from an Int
i < tARGET_MAX_INT
- = App (Var int2IntegerId) (Con (Literal (mkMachInt i)) [])
+ = Con (DataCon smallIntegerDataCon) [Con (Literal (mkMachInt i)) []]
| otherwise -- Big, so start from a string
= App (Var addr2IntegerId) (Con (Literal (MachStr (_PK_ (show i)))) [])