CIRCT
23.0.0git
Loading...
Searching...
No Matches
lib
Conversion
ImportVerilog
CaptureAnalysis.h
Go to the documentation of this file.
1
//===----------------------------------------------------------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// Pre-pass over the slang AST to determine which non-local, non-global
10
// variables each function captures, either directly or transitively through
11
// calls to other functions.
12
//
13
// This information is needed before any MLIR conversion happens so that
14
// function declarations can be created with the correct signature (including
15
// extra capture parameters) upfront, enabling a clean two-phase
16
// declare-then-define approach for functions.
17
//
18
//===----------------------------------------------------------------------===//
19
20
// NOLINTNEXTLINE(llvm-header-guard)
21
#ifndef CONVERSION_IMPORTVERILOG_CAPTUREANALYSIS_H
22
#define CONVERSION_IMPORTVERILOG_CAPTUREANALYSIS_H
23
24
#include "
circt/Support/LLVM.h
"
25
#include "llvm/ADT/SetVector.h"
26
27
namespace
slang
{
28
namespace
ast {
29
class
RootSymbol;
30
class
SubroutineSymbol;
31
class
ValueSymbol;
32
}
// namespace ast
33
}
// namespace slang
34
35
namespace
circt
{
36
namespace
ImportVerilog {
37
38
/// The result of capture analysis: for each function, the set of non-local,
39
/// non-global variable symbols that the function captures directly or
40
/// transitively through calls.
41
using
CaptureMap
= DenseMap<
const
slang::ast::SubroutineSymbol *,
42
SmallSetVector<const slang::ast::ValueSymbol *, 4>
>;
43
44
/// Analyze the AST rooted at `root` to determine which variables each function
45
/// captures. A variable is considered captured by a function if it is
46
/// referenced inside the function's body (or transitively through called
47
/// functions) and is neither local to the function nor a global variable
48
/// (package-scope or compilation-unit-scope variables that are lowered via
49
/// `get_global_signal`).
50
CaptureMap
analyzeFunctionCaptures
(
const
slang::ast::RootSymbol &root);
51
52
}
// namespace ImportVerilog
53
}
// namespace circt
54
55
#endif
// CONVERSION_IMPORTVERILOG_CAPTUREANALYSIS_H
LLVM.h
llvm::SmallSetVector
Definition
LLVM.h:85
circt::ImportVerilog::analyzeFunctionCaptures
CaptureMap analyzeFunctionCaptures(const slang::ast::RootSymbol &root)
Analyze the AST rooted at root to determine which variables each function captures.
circt::ImportVerilog::CaptureMap
DenseMap< const slang::ast::SubroutineSymbol *, SmallSetVector< const slang::ast::ValueSymbol *, 4 > > CaptureMap
The result of capture analysis: for each function, the set of non-local, non-global variable symbols ...
Definition
CaptureAnalysis.h:42
circt
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition
DebugAnalysis.h:21
slang
Definition
CaptureAnalysis.h:27
Generated on Tue Apr 21 2026 00:18:08 for CIRCT by
1.9.8