Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global option --no-check #3224

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/GlobalOptions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ data GlobalOptions = GlobalOptions
_globalNoPositivity :: Bool,
_globalNoCoverage :: Bool,
_globalNoStdlib :: Bool,
_globalNoCheck :: Bool,
_globalUnrollLimit :: Int,
_globalNumThreads :: NumThreads,
_globalFieldSize :: Maybe Natural,
Expand Down Expand Up @@ -72,6 +73,7 @@ defaultGlobalOptions =
_globalLogLevel = LogLevelProgress,
_globalNoCoverage = False,
_globalNoStdlib = False,
_globalNoCheck = False,
_globalUnrollLimit = defaultUnrollLimit,
_globalFieldSize = Nothing,
_globalDevShowThreadIds = False,
Expand Down Expand Up @@ -162,6 +164,11 @@ parseGlobalFlags = do
<> intercalate " < " [show l | l <- allElements @LogLevel]
)
)
_globalNoCheck <-
switch
( long "dev-no-check"
<> help "[DEV] Disable input sanity check in Core"
)
_globalShowNameIds <-
switch
( long "show-name-ids"
Expand Down Expand Up @@ -211,6 +218,7 @@ entryPointFromGlobalOptions root mainFile opts = do
_entryPointNoPositivity = opts ^. globalNoPositivity,
_entryPointNoCoverage = opts ^. globalNoCoverage,
_entryPointNoStdlib = opts ^. globalNoStdlib,
_entryPointNoCheck = opts ^. globalNoCheck,
_entryPointUnrollLimit = opts ^. globalUnrollLimit,
_entryPointGenericOptions = project opts,
_entryPointBuildDir = maybe (def ^. entryPointBuildDir) (CustomBuildDir . Abs) mabsBuildDir,
Expand All @@ -232,6 +240,7 @@ entryPointFromGlobalOptionsNoFile root opts = do
_entryPointNoPositivity = opts ^. globalNoPositivity,
_entryPointNoCoverage = opts ^. globalNoCoverage,
_entryPointNoStdlib = opts ^. globalNoStdlib,
_entryPointNoCheck = opts ^. globalNoCheck,
_entryPointUnrollLimit = opts ^. globalUnrollLimit,
_entryPointGenericOptions = project opts,
_entryPointBuildDir = maybe (def ^. entryPointBuildDir) (CustomBuildDir . Abs) mabsBuildDir,
Expand Down
8 changes: 6 additions & 2 deletions src/Juvix/Compiler/Core/Pipeline.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ where
import Juvix.Compiler.Core.Data.InfoTable
import Juvix.Compiler.Core.Options
import Juvix.Compiler.Core.Transformation
import Juvix.Compiler.Pipeline.EntryPoint (EntryPoint)
import Juvix.Compiler.Pipeline.EntryPoint (EntryPoint, entryPointNoCheck)

toTypechecked :: (Members '[Error JuvixError, Reader EntryPoint] r) => Module -> Sem r Module
toTypechecked = mapReader fromEntryPoint . applyTransformations toTypecheckTransformations
Expand All @@ -19,7 +19,11 @@ toStored = mapReader fromEntryPoint . applyTransformations toStoredTransformatio
-- | Perform transformations on stored Core necessary before the translation to
-- Core.Stripped
toStripped :: (Members '[Error JuvixError, Reader EntryPoint] r) => TransformationId -> Module -> Sem r Module
toStripped checkId = mapReader fromEntryPoint . applyTransformations (toStrippedTransformations checkId)
toStripped checkId md = do
noCheck <- asks (^. entryPointNoCheck)
let checkId' = if noCheck then IdentityTrans else checkId
mapReader fromEntryPoint $
applyTransformations (toStrippedTransformations checkId') md

-- | Perform transformations on stored Core necessary before the translation to VampIR
toVampIR :: (Members '[Error JuvixError, Reader EntryPoint] r) => Module -> Sem r Module
Expand Down
3 changes: 3 additions & 0 deletions src/Juvix/Compiler/Pipeline/EntryPoint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ data EntryPoint = EntryPoint
_entryPointTarget :: Maybe Target,
_entryPointDebug :: Bool,
_entryPointUnsafe :: Bool,
-- | Skip the correctness check in the Core pipeline part.
_entryPointNoCheck :: Bool,
_entryPointUnrollLimit :: Int,
_entryPointOptimizationLevel :: Int,
_entryPointInliningDepth :: Int,
Expand Down Expand Up @@ -76,6 +78,7 @@ defaultEntryPointNoFile pkg root =
_entryPointTarget = Nothing,
_entryPointDebug = False,
_entryPointUnsafe = False,
_entryPointNoCheck = False,
_entryPointUnrollLimit = defaultUnrollLimit,
_entryPointOptimizationLevel = defaultOptimizationLevel,
_entryPointInliningDepth = defaultInliningDepth,
Expand Down
Loading