22 Copyright : (C) 2012-2016, University of Twente,
33 2016-2017, Myrtle Software Ltd,
44 2017-2018, Google Inc.,
5- 2021-2024, QBayLogic B.V.
6- 2022 , Google Inc .
5+ 2022 , Google Inc.,
6+ 2021-2026, QBayLogic B.V .
77 License : BSD2 (see the file LICENSE)
88 Maintainer : QBayLogic B.V. <devops@qbaylogic.com>
99
@@ -314,13 +314,25 @@ mkNetDecl (id_,tm) | (_,_,ticks) <- collectArgsTicks tm = preserveVarEnv $ withT
314314 Annotated attrs hty0 -> Annotated (attrs ++ lAttrs) hty0
315315 hty0 -> annotated lAttrs hty0
316316
317+ -- GHC starts including sources notes on any debug level greater than 0
318+ -- we copy this behaviour here.
319+ emitLocs <- (> 0 ) . opt_ghcDebugLevel <$> Lens. view clashOpts
320+ let
321+ srcNote =
322+ if emitLocs then
323+ addSrcNote $ case tm of
324+ Tick (SrcSpan s) _ -> s
325+ _ -> nameLoc (varName id_)
326+ else
327+ Nothing
328+
317329 if | not (shouldRenderDecl hwTy tm) -> return []
318330 | (Prim pInfo@ PrimInfo {primMultiResult= MultiResult }, args) <- collectArgs tm ->
319- multiDecls pInfo args
320- | otherwise -> pure <$> singleDecl hwTy
331+ multiDecls srcNote pInfo args
332+ | otherwise -> pure <$> singleDecl srcNote hwTy
321333
322334 where
323- multiDecls pInfo args0 = do
335+ multiDecls srcNote pInfo args0 = do
324336 tcm <- Lens. view tcCache
325337 resInits0 <- getResInits (id_, tm)
326338 let
@@ -334,18 +346,14 @@ mkNetDecl (id_,tm) | (_,_,ticks) <- collectArgsTicks tm = preserveVarEnv $ withT
334346 hwTys <- mapM (unsafeCoreTypeToHWTypeM' $ (curLoc)) (mpi_resultTypes mpInfo)
335347 pure (zipWith3 netdecl res hwTys resInits1)
336348
337- singleDecl hwTy = do
349+ singleDecl srcNote hwTy = do
338350 rIM <- listToMaybe <$> getResInits (id_, tm)
339351 return (NetDecl' srcNote (Id. unsafeFromCoreId id_) hwTy rIM)
340352
341353 addSrcNote loc
342354 | isGoodSrcSpan loc = Just (StrictText. pack (showSDocUnsafe (ppr loc)))
343355 | otherwise = Nothing
344356
345- srcNote = addSrcNote $ case tm of
346- Tick (SrcSpan s) _ -> s
347- _ -> nameLoc (varName id_)
348-
349357 isMultiPrimSelect :: Term -> Bool
350358 isMultiPrimSelect t = case collectArgs t of
351359 (Prim (primName -> " c$multiPrimSelect" ), _) -> True
0 commit comments