@@ -98,6 +98,53 @@ data DebugLevel
9898 -- ^ Show all sub-expressions on which a rewrite is attempted
9999 deriving (Eq ,Ord ,Read ,Enum ,Generic ,Hashable )
100100
101+ -- | Options related to debugging. See 'ClashOpts'
102+ data DebugOpts = DebugOpts
103+ { opt_level :: DebugLevel
104+ -- ^ Set the debugging mode for the compiler, exposing additional output. See
105+ -- "DebugLevel" for the available options.
106+ --
107+ -- Command line flag: -fclash-debug
108+ , opt_transformations :: Set. Set String
109+ -- ^ List the transformations that are to be debugged.
110+ --
111+ -- Command line flag: -fclash-debug-transformations
112+ , opt_transformationsFrom :: Word
113+ -- ^ Only output debug information from (applied) transformation n
114+ --
115+ -- Command line flag: -fclash-debug-transformations-from
116+ , opt_transformationsLimit :: Word
117+ -- ^ Only output debug information for n (applied) transformations. If this
118+ -- limit is exceeded, Clash will stop normalizing.
119+ --
120+ -- Command line flag: -fclash-debug-transformations-limit
121+ , opt_rewriteHistoryFile :: Maybe FilePath
122+ -- ^ Save all applied rewrites to a file
123+ --
124+ -- Command line flag: -fclash-debug-history
125+ }
126+
127+ instance Hashable DebugOpts where
128+ hashWithSalt s DebugOpts {.. } =
129+ s `hashWithSalt`
130+ opt_level `hashSet`
131+ opt_transformations `hashWithSalt`
132+ opt_transformationsFrom `hashWithSalt`
133+ opt_transformationsLimit `hashWithSalt`
134+ opt_rewriteHistoryFile
135+ where
136+ hashSet = Set. foldl' hashWithSalt
137+ infixl 0 `hashSet`
138+
139+ defDebugOpts :: DebugOpts
140+ defDebugOpts = DebugOpts
141+ { opt_level = DebugNone
142+ , opt_transformations = Set. empty
143+ , opt_transformationsFrom = 0
144+ , opt_transformationsLimit = maxBound
145+ , opt_rewriteHistoryFile = Nothing
146+ }
147+
101148-- | Options passed to Clash compiler
102149data ClashOpts = ClashOpts
103150 { opt_inlineLimit :: Int
@@ -124,30 +171,8 @@ data ClashOpts = ClashOpts
124171 -- of zero means no potentially non-terminating binding is unfolded.
125172 --
126173 -- Command line flag: -fclash-evaluator-fuel-limit
127- , opt_dbgLevel :: DebugLevel
128- -- ^ Set the debugging mode for the compiler, exposing additional output. See
129- -- "DebugLevel" for the available options.
130- --
131- -- Command line flag: -fclash-debug
132- , opt_dbgTransformations :: Set. Set String
133- -- ^ List the transformations that are to be debugged.
134- --
135- -- Command line flag: -fclash-debug-transformations
136- , opt_dbgTransformationsFrom :: Word
137- -- ^ Only output debug information from (applied) transformation n
138- --
139- -- Command line flag: -fclash-debug-transformations-from
140- , opt_dbgTransformationsLimit :: Word
141- -- ^ Only output debug information for n (applied) transformations. If this
142- -- limit is exceeded, Clash will stop normalizing.
143- --
144- -- Command line flag: -fclash-debug-transformations-limit
145-
146- , opt_dbgRewriteHistoryFile :: Maybe FilePath
147- -- ^ Save all applied rewrites to a file
148- --
149- -- Command line flag: -fclash-debug-history
150-
174+ , opt_debug :: DebugOpts
175+ -- ^ Options which control debugging. See 'DebugOpts'.
151176 , opt_cachehdl :: Bool
152177 -- ^ Reuse previously generated output from Clash. Only caches topentities.
153178 --
@@ -231,11 +256,6 @@ instance Hashable ClashOpts where
231256 opt_inlineFunctionLimit `hashWithSalt`
232257 opt_inlineConstantLimit `hashWithSalt`
233258 opt_evaluatorFuelLimit `hashWithSalt`
234- opt_dbgLevel `hashSet`
235- opt_dbgTransformations `hashWithSalt`
236- opt_dbgTransformationsFrom `hashWithSalt`
237- opt_dbgTransformationsLimit `hashWithSalt`
238- opt_dbgRewriteHistoryFile `hashWithSalt`
239259 opt_cachehdl `hashWithSalt`
240260 opt_clear `hashWithSalt`
241261 opt_primWarn `hashOverridingBool`
@@ -264,23 +284,15 @@ instance Hashable ClashOpts where
264284 hashOverridingBool s1 Never = hashWithSalt s1 (2 :: Int )
265285 infixl 0 `hashOverridingBool`
266286
267- hashSet :: Hashable a => Int -> Set. Set a -> Int
268- hashSet = Set. foldl' hashWithSalt
269- infixl 0 `hashSet`
270-
271287defClashOpts :: ClashOpts
272288defClashOpts
273289 = ClashOpts
274- { opt_dbgLevel = DebugNone
275- , opt_dbgRewriteHistoryFile = Nothing
276- , opt_dbgTransformations = Set. empty
277- , opt_dbgTransformationsFrom = 0
278- , opt_dbgTransformationsLimit = maxBound
279- , opt_inlineLimit = 20
290+ { opt_inlineLimit = 20
280291 , opt_specLimit = 20
281292 , opt_inlineFunctionLimit = 15
282293 , opt_inlineConstantLimit = 0
283294 , opt_evaluatorFuelLimit = 20
295+ , opt_debug = defDebugOpts
284296 , opt_cachehdl = True
285297 , opt_clear = False
286298 , opt_primWarn = True
0 commit comments