summaryrefslogtreecommitdiff
path: root/compiler/GHC/Cmm/Parser/Monad.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/GHC/Cmm/Parser/Monad.hs')
-rw-r--r--compiler/GHC/Cmm/Parser/Monad.hs16
1 files changed, 11 insertions, 5 deletions
diff --git a/compiler/GHC/Cmm/Parser/Monad.hs b/compiler/GHC/Cmm/Parser/Monad.hs
index e7d763497a..b13321d491 100644
--- a/compiler/GHC/Cmm/Parser/Monad.hs
+++ b/compiler/GHC/Cmm/Parser/Monad.hs
@@ -11,9 +11,11 @@ module GHC.Cmm.Parser.Monad (
PD(..)
, liftP
, failMsgPD
+ , getPDConfig
, getProfile
, getPlatform
, getHomeUnitId
+ , PDConfig(..)
) where
import GHC.Prelude
@@ -23,7 +25,6 @@ import GHC.Platform.Profile
import Control.Monad
-import GHC.Driver.Session
import GHC.Parser.Lexer
import GHC.Parser.Errors.Types
import GHC.Types.Error ( MsgEnvelope )
@@ -31,7 +32,12 @@ import GHC.Types.SrcLoc
import GHC.Unit.Types
import GHC.Unit.Home
-newtype PD a = PD { unPD :: DynFlags -> HomeUnit -> PState -> ParseResult a }
+data PDConfig = PDConfig
+ { pdProfile :: !Profile
+ , pdSanitizeAlignment :: !Bool -- ^ Insert alignment checks (cf @-falignment-sanitisation@)
+ }
+
+newtype PD a = PD { unPD :: PDConfig -> HomeUnit -> PState -> ParseResult a }
instance Functor PD where
fmap = liftM
@@ -58,11 +64,11 @@ thenPD :: PD a -> (a -> PD b) -> PD b
POk s1 a -> unPD (k a) d hu s1
PFailed s1 -> PFailed s1
-instance HasDynFlags PD where
- getDynFlags = PD $ \d _ s -> POk s d
+getPDConfig :: PD PDConfig
+getPDConfig = PD $ \pdc _ s -> POk s pdc
getProfile :: PD Profile
-getProfile = targetProfile <$> getDynFlags
+getProfile = PD $ \pdc _ s -> POk s (pdProfile pdc)
getPlatform :: PD Platform
getPlatform = profilePlatform <$> getProfile