CIRCT 23.0.0git
Loading...
Searching...
No Matches
Namespaces | Macros | Functions
SVMaskNonSynthesizable.cpp File Reference
#include "circt/Dialect/HW/HWOps.h"
#include "circt/Dialect/SV/SVAttributes.h"
#include "circt/Dialect/SV/SVOps.h"
#include "circt/Dialect/SV/SVPasses.h"
#include "circt/Support/Namespace.h"
#include "circt/Support/ProceduralRegionTrait.h"
#include "circt/Support/Utils.h"
#include "mlir/IR/Builders.h"
#include "mlir/Pass/Pass.h"
#include "llvm/ADT/TypeSwitch.h"
#include "circt/Dialect/SV/SVPasses.h.inc"
Include dependency graph for SVMaskNonSynthesizable.cpp:

Go to the source code of this file.

Namespaces

namespace  circt
 The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
 
namespace  circt::sv
 

Macros

#define GEN_PASS_DEF_SVMASKNONSYNTHESIZABLE
 

Functions

static bool isMaskedOp (Operation *op)
 Returns true if op is one of the SV ops we mask.
 
static Region * getMatchingIfDefElseRegion (Operation *op, StringRef expectedMacro)
 If op is an sv.ifdef/sv.ifdef.procedural whose macro matches expectedMacro, returns its else region; otherwise returns nullptr.
 
static StringAttr resolveMacroSymName (mlir::ModuleOp moduleOp, StringRef verilogName, bool &created)
 Resolve the symbol name to use for the sv.macro.decl referenced by ifdef mode's sv.ifdef ops.
 
static void processBlockDelete (Block &block)
 delete mode: walk the block and erase every masked op.
 
static void maskOpByIfdef (Operation *op, StringRef macro)
 Wrap a single masked op in its own sv.ifdef/sv.ifdef.procedural.
 
static bool processBlockIfdef (Block &block, StringRef macro)
 ifdef mode: wrap each masked op in its own sv.ifdef/sv.ifdef.procedural.
 

Macro Definition Documentation

◆ GEN_PASS_DEF_SVMASKNONSYNTHESIZABLE

#define GEN_PASS_DEF_SVMASKNONSYNTHESIZABLE

Definition at line 34 of file SVMaskNonSynthesizable.cpp.

Function Documentation

◆ getMatchingIfDefElseRegion()

static Region * getMatchingIfDefElseRegion ( Operation *  op,
StringRef  expectedMacro 
)
static

If op is an sv.ifdef/sv.ifdef.procedural whose macro matches expectedMacro, returns its else region; otherwise returns nullptr.

Used to identify the region that need not be re-wrapped in ifdef mode.

Definition at line 56 of file SVMaskNonSynthesizable.cpp.

Referenced by processBlockIfdef().

◆ isMaskedOp()

static bool isMaskedOp ( Operation *  op)
static

Returns true if op is one of the SV ops we mask.

Definition at line 47 of file SVMaskNonSynthesizable.cpp.

Referenced by processBlockDelete(), and processBlockIfdef().

◆ maskOpByIfdef()

static void maskOpByIfdef ( Operation *  op,
StringRef  macro 
)
static

Wrap a single masked op in its own sv.ifdef/sv.ifdef.procedural.

Picks the procedural variant based on the enclosing region.

Definition at line 100 of file SVMaskNonSynthesizable.cpp.

References circt::isInProceduralRegion().

Referenced by processBlockIfdef().

◆ processBlockDelete()

static void processBlockDelete ( Block &  block)
static

delete mode: walk the block and erase every masked op.

Definition at line 91 of file SVMaskNonSynthesizable.cpp.

References isMaskedOp().

◆ processBlockIfdef()

static bool processBlockIfdef ( Block &  block,
StringRef  macro 
)
static

ifdef mode: wrap each masked op in its own sv.ifdef/sv.ifdef.procedural.

Recurse into nested regions of non-masked ops, but skip recursion into the else region of a matching sv.ifdef @<macro> – those ops are already guarded.

Definition at line 125 of file SVMaskNonSynthesizable.cpp.

References getMatchingIfDefElseRegion(), isMaskedOp(), maskOpByIfdef(), and processBlockIfdef().

Referenced by processBlockIfdef().

◆ resolveMacroSymName()

static StringAttr resolveMacroSymName ( mlir::ModuleOp  moduleOp,
StringRef  verilogName,
bool &  created 
)
static

Resolve the symbol name to use for the sv.macro.decl referenced by ifdef mode's sv.ifdef ops.

Returns the existing decl's sym_name if a sv.macro.decl whose Verilog identifier matches verilogName already exists at top level; otherwise returns a fresh sym_name that does not collide with any existing top-level symbol (which may differ from verilogName if a non-sv.macro.decl symbol of that name is present). created is set to true iff the returned name belongs to a decl that the caller still needs to materialize.

Definition at line 75 of file SVMaskNonSynthesizable.cpp.

References circt::Namespace::add(), and circt::Namespace::newName().