Skip to content

Commit cdaccda

Browse files
committed
add -fclash-concurrent-normalization flag
1 parent c0220f9 commit cdaccda

File tree

3 files changed

+46
-32
lines changed

3 files changed

+46
-32
lines changed

clash-ghc/src-ghc/Clash/GHC/ClashFlags.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ flagsClash r = [
8989
, defFlag "fclash-inline-workfree-limit" $ IntSuffix (liftEwM . setInlineWFLimit r)
9090
, defFlag "fclash-edalize" $ NoArg (liftEwM (setEdalize r))
9191
, defFlag "fclash-no-render-enums" $ NoArg (liftEwM (setNoRenderEnums r))
92+
, defFlag "fclash-concurrent-normalization" $ NoArg (liftEwM (setConcurrentNormalization r))
9293
]
9394

9495
-- | Print deprecated flag warning
@@ -313,6 +314,9 @@ setAggressiveXOptBB r = modifyIORef r (\c -> c { opt_aggressiveXOptBB = True })
313314
setEdalize :: IORef ClashOpts -> IO ()
314315
setEdalize r = modifyIORef r (\c -> c { opt_edalize = True })
315316

317+
setConcurrentNormalization :: IORef ClashOpts -> IO ()
318+
setConcurrentNormalization r = modifyIORef r (\c -> c { opt_concurrentNormalization = True })
319+
316320
setRewriteHistoryFile :: IORef ClashOpts -> String -> IO ()
317321
setRewriteHistoryFile r arg = do
318322
let fileNm = case drop (length "-fclash-debug-history=") arg of

clash-lib/src/Clash/Driver/Types.hs

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,8 @@ data ClashOpts = ClashOpts
392392
, opt_renderEnums :: Bool
393393
-- ^ Render sum types with all zero-width fields as enums where supported, as
394394
-- opposed to rendering them as bitvectors.
395+
, opt_concurrentNormalization :: Bool
396+
-- ^ Toggle concurrent normalization (usually slower, faster on large designs)
395397
}
396398
deriving (Show)
397399

@@ -424,6 +426,7 @@ instance NFData ClashOpts where
424426
opt_inlineWFCacheLimit o `deepseq`
425427
opt_edalize o `deepseq`
426428
opt_renderEnums o `deepseq`
429+
opt_concurrentNormalization o `deepseq`
427430
()
428431

429432
instance Eq ClashOpts where
@@ -454,7 +457,8 @@ instance Eq ClashOpts where
454457
opt_aggressiveXOptBB s0 == opt_aggressiveXOptBB s1 &&
455458
opt_inlineWFCacheLimit s0 == opt_inlineWFCacheLimit s1 &&
456459
opt_edalize s0 == opt_edalize s1 &&
457-
opt_renderEnums s0 == opt_renderEnums s1
460+
opt_renderEnums s0 == opt_renderEnums s1 &&
461+
opt_concurrentNormalization s0 == opt_concurrentNormalization s1
458462

459463
where
460464
eqOverridingBool :: OverridingBool -> OverridingBool -> Bool
@@ -492,7 +496,8 @@ instance Hashable ClashOpts where
492496
opt_aggressiveXOptBB `hashWithSalt`
493497
opt_inlineWFCacheLimit `hashWithSalt`
494498
opt_edalize `hashWithSalt`
495-
opt_renderEnums
499+
opt_renderEnums `hashWithSalt`
500+
opt_concurrentNormalization
496501
where
497502
hashOverridingBool :: Int -> OverridingBool -> Int
498503
hashOverridingBool s1 Auto = hashWithSalt s1 (0 :: Int)
@@ -501,36 +506,36 @@ instance Hashable ClashOpts where
501506
infixl 0 `hashOverridingBool`
502507

503508
defClashOpts :: ClashOpts
504-
defClashOpts
505-
= ClashOpts
506-
{ opt_werror = False
507-
, opt_inlineLimit = 20
508-
, opt_specLimit = 20
509-
, opt_inlineFunctionLimit = 15
510-
, opt_inlineConstantLimit = 0
511-
, opt_evaluatorFuelLimit = 20
512-
, opt_debug = debugNone
513-
, opt_cachehdl = True
514-
, opt_clear = False
515-
, opt_primWarn = True
516-
, opt_color = Auto
517-
, opt_intWidth = WORD_SIZE_IN_BITS
518-
, opt_hdlDir = Nothing
519-
, opt_hdlSyn = Other
520-
, opt_errorExtra = False
521-
, opt_importPaths = []
522-
, opt_componentPrefix = Nothing
523-
, opt_newInlineStrat = True
524-
, opt_escapedIds = True
525-
, opt_lowerCaseBasicIds = PreserveCase
526-
, opt_ultra = False
527-
, opt_forceUndefined = Nothing
528-
, opt_checkIDir = True
529-
, opt_aggressiveXOpt = False
530-
, opt_aggressiveXOptBB = False
531-
, opt_inlineWFCacheLimit = 10 -- TODO: find "optimal" value
532-
, opt_edalize = False
533-
, opt_renderEnums = True
509+
defClashOpts = ClashOpts
510+
{ opt_werror = False
511+
, opt_inlineLimit = 20
512+
, opt_specLimit = 20
513+
, opt_inlineFunctionLimit = 15
514+
, opt_inlineConstantLimit = 0
515+
, opt_evaluatorFuelLimit = 20
516+
, opt_debug = debugNone
517+
, opt_cachehdl = True
518+
, opt_clear = False
519+
, opt_primWarn = True
520+
, opt_color = Auto
521+
, opt_intWidth = WORD_SIZE_IN_BITS
522+
, opt_hdlDir = Nothing
523+
, opt_hdlSyn = Other
524+
, opt_errorExtra = False
525+
, opt_importPaths = []
526+
, opt_componentPrefix = Nothing
527+
, opt_newInlineStrat = True
528+
, opt_escapedIds = True
529+
, opt_lowerCaseBasicIds = PreserveCase
530+
, opt_ultra = False
531+
, opt_forceUndefined = Nothing
532+
, opt_checkIDir = True
533+
, opt_aggressiveXOpt = False
534+
, opt_aggressiveXOptBB = False
535+
, opt_inlineWFCacheLimit = 10 -- TODO: find "optimal" value
536+
, opt_edalize = False
537+
, opt_renderEnums = True
538+
, opt_concurrentNormalization = False
534539
}
535540

536541
-- | Synopsys Design Constraint (SDC) information for a component.

docs/developing-hardware/flags.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ Clash Compiler Flags
271271

272272
.. _`Edalize`: https://github.com/olofk/edalize
273273

274+
-fclash-concurrent-normaliztation
275+
Toggle concurrent normalization. Faster for large designs.
276+
277+
**Default:** False
278+
274279
-main-is
275280
When using one of ``--vhdl``, ``--verilog``, or ``--systemverilog``, this
276281
flag refers to synthesis target. For example, running Clash with

0 commit comments

Comments
 (0)