diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2020-03-11 19:14:11 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-03-25 22:42:02 -0400 |
commit | 0de03cd78729dc58a846c64b645e71057ec5d24e (patch) | |
tree | 4d893f44db3fa94094376cf4fcad9a1a832ee261 /compiler/GHC/HsToCore/Quote.hs | |
parent | 262e42aa34c4d5705c8d011907c351497dd4e862 (diff) | |
download | haskell-0de03cd78729dc58a846c64b645e71057ec5d24e.tar.gz |
DynFlags refactoring III
Use Platform instead of DynFlags when possible:
* `tARGET_MIN_INT` et al. replaced with `platformMinInt` et al.
* no more DynFlags in PreRules: added a new `RuleOpts` datatype
* don't use `wORD_SIZE` in the compiler
* make `wordAlignment` use `Platform`
* make `dOUBLE_SIZE` a constant
Metric Decrease:
T13035
T1969
Diffstat (limited to 'compiler/GHC/HsToCore/Quote.hs')
-rw-r--r-- | compiler/GHC/HsToCore/Quote.hs | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/compiler/GHC/HsToCore/Quote.hs b/compiler/GHC/HsToCore/Quote.hs index 4ae93bcee8..06ea9e307f 100644 --- a/compiler/GHC/HsToCore/Quote.hs +++ b/compiler/GHC/HsToCore/Quote.hs @@ -27,6 +27,7 @@ module GHC.HsToCore.Quote( dsBracket ) where #include "HsVersions.h" import GhcPrelude +import GHC.Platform import {-# SOURCE #-} GHC.HsToCore.Expr ( dsExpr ) @@ -138,6 +139,9 @@ wrapName n = do -- wrapper type MetaM a = ReaderT MetaWrappers DsM a +getPlatform :: MetaM Platform +getPlatform = targetPlatform <$> getDynFlags + ----------------------------------------------------------------------------- dsBracket :: Maybe QuoteWrapper -- ^ This is Nothing only when we are dealing with a VarBr -> HsBracket GhcRn @@ -2212,10 +2216,10 @@ repPunboxedTup (MkC ps) = rep2 unboxedTupPName [ps] repPunboxedSum :: Core (M TH.Pat) -> TH.SumAlt -> TH.SumArity -> MetaM (Core (M TH.Pat)) -- Note: not Core TH.SumAlt or Core TH.SumArity; it's easier to be direct here repPunboxedSum (MkC p) alt arity - = do { dflags <- getDynFlags + = do { platform <- getPlatform ; rep2 unboxedSumPName [ p - , mkIntExprInt dflags alt - , mkIntExprInt dflags arity ] } + , mkIntExprInt platform alt + , mkIntExprInt platform arity ] } repPcon :: Core TH.Name -> Core [(M TH.Pat)] -> MetaM (Core (M TH.Pat)) repPcon (MkC s) (MkC ps) = rep2 conPName [s, ps] @@ -2282,10 +2286,10 @@ repUnboxedTup (MkC es) = rep2 unboxedTupEName [es] repUnboxedSum :: Core (M TH.Exp) -> TH.SumAlt -> TH.SumArity -> MetaM (Core (M TH.Exp)) -- Note: not Core TH.SumAlt or Core TH.SumArity; it's easier to be direct here repUnboxedSum (MkC e) alt arity - = do { dflags <- getDynFlags + = do { platform <- getPlatform ; rep2 unboxedSumEName [ e - , mkIntExprInt dflags alt - , mkIntExprInt dflags arity ] } + , mkIntExprInt platform alt + , mkIntExprInt platform arity ] } repCond :: Core (M TH.Exp) -> Core (M TH.Exp) -> Core (M TH.Exp) -> MetaM (Core (M TH.Exp)) repCond (MkC x) (MkC y) (MkC z) = rep2 condEName [x,y,z] @@ -2689,18 +2693,18 @@ repTInfix (MkC t1) (MkC name) (MkC t2) = rep2 infixTName [t1,name,t2] repTupleTyCon :: Int -> MetaM (Core (M TH.Type)) -- Note: not Core Int; it's easier to be direct here -repTupleTyCon i = do dflags <- getDynFlags - rep2 tupleTName [mkIntExprInt dflags i] +repTupleTyCon i = do platform <- getPlatform + rep2 tupleTName [mkIntExprInt platform i] repUnboxedTupleTyCon :: Int -> MetaM (Core (M TH.Type)) -- Note: not Core Int; it's easier to be direct here -repUnboxedTupleTyCon i = do dflags <- getDynFlags - rep2 unboxedTupleTName [mkIntExprInt dflags i] +repUnboxedTupleTyCon i = do platform <- getPlatform + rep2 unboxedTupleTName [mkIntExprInt platform i] repUnboxedSumTyCon :: TH.SumArity -> MetaM (Core (M TH.Type)) -- Note: not Core TH.SumArity; it's easier to be direct here -repUnboxedSumTyCon arity = do dflags <- getDynFlags - rep2 unboxedSumTName [mkIntExprInt dflags arity] +repUnboxedSumTyCon arity = do platform <- getPlatform + rep2 unboxedSumTName [mkIntExprInt platform arity] repArrowTyCon :: MetaM (Core (M TH.Type)) repArrowTyCon = rep2 arrowTName [] @@ -2712,8 +2716,8 @@ repPromotedDataCon :: Core TH.Name -> MetaM (Core (M TH.Type)) repPromotedDataCon (MkC s) = rep2 promotedTName [s] repPromotedTupleTyCon :: Int -> MetaM (Core (M TH.Type)) -repPromotedTupleTyCon i = do dflags <- getDynFlags - rep2 promotedTupleTName [mkIntExprInt dflags i] +repPromotedTupleTyCon i = do platform <- getPlatform + rep2 promotedTupleTName [mkIntExprInt platform i] repPromotedNilTyCon :: MetaM (Core (M TH.Type)) repPromotedNilTyCon = rep2 promotedNilTName [] @@ -2746,11 +2750,11 @@ repTyVarSig (MkC bndr) = rep2 tyVarSigName [bndr] repLiteral :: HsLit GhcRn -> MetaM (Core TH.Lit) repLiteral (HsStringPrim _ bs) - = do dflags <- getDynFlags + = do platform <- getPlatform word8_ty <- lookupType word8TyConName let w8s = unpack bs w8s_expr = map (\w8 -> mkCoreConApps word8DataCon - [mkWordLit dflags (toInteger w8)]) w8s + [mkWordLit platform (toInteger w8)]) w8s rep2_nw stringPrimLName [mkListExpr word8_ty w8s_expr] repLiteral lit = do lit' <- case lit of @@ -2935,8 +2939,8 @@ coreNothingList elt_ty = return $ coreNothing' (mkListTy elt_ty) ------------ Literals & Variables ------------------- coreIntLit :: Int -> MetaM (Core Int) -coreIntLit i = do dflags <- getDynFlags - return (MkC (mkIntExprInt dflags i)) +coreIntLit i = do platform <- getPlatform + return (MkC (mkIntExprInt platform i)) coreIntegerLit :: MonadThings m => Integer -> m (Core Integer) coreIntegerLit i = fmap MkC (mkIntegerExpr i) |