CIRCT 23.0.0git
Loading...
Searching...
No Matches
Namespaces | Macros | Functions
LinkCircuits.cpp File Reference
#include "circt/Dialect/FIRRTL/FIRRTLAnnotationHelper.h"
#include "circt/Dialect/FIRRTL/FIRRTLAnnotations.h"
#include "circt/Dialect/FIRRTL/FIRRTLOps.h"
#include "circt/Dialect/FIRRTL/FIRRTLTypes.h"
#include "circt/Dialect/FIRRTL/Passes.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/Diagnostics.h"
#include "mlir/IR/Operation.h"
#include "mlir/IR/SymbolTable.h"
#include "mlir/Support/LLVM.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/STLExtras.h"
#include <iterator>
#include "circt/Dialect/FIRRTL/Passes.h.inc"
Include dependency graph for LinkCircuits.cpp:

Go to the source code of this file.

Namespaces

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

Macros

#define GEN_PASS_DEF_LINKCIRCUITS
 

Functions

template<typename CallableT >
static DictionaryAttr transformAnnotationTarget (DictionaryAttr anno, CallableT transformTokensFn)
 
static LogicalResult mangleCircuitSymbols (CircuitOp circuit)
 
static void collectLayerSymbols (LayerOp layer, SmallVectorImpl< FlatSymbolRefAttr > &stack, llvm::DenseSet< Attribute > &layers)
 
static void collectLayerSymbols (CircuitOp circuit, llvm::DenseSet< Attribute > &layers)
 
static LogicalResult verifyKnownLayers (FExtModuleOp extModule, const llvm::DenseSet< Attribute > &availableLayers)
 
static LogicalResult mergeLayer (LayerOp dst, LayerOp src)
 
static FailureOr< bool > handleCollidingOps (SymbolOpInterface collidingOp, SymbolOpInterface incomingOp, const llvm::DenseSet< Attribute > &mergedLayers, const llvm::DenseSet< Attribute > &incomingLayers)
 Resolves symbol collisions during circuit merging.
 

Macro Definition Documentation

◆ GEN_PASS_DEF_LINKCIRCUITS

#define GEN_PASS_DEF_LINKCIRCUITS

Definition at line 31 of file LinkCircuits.cpp.

Function Documentation

◆ collectLayerSymbols() [1/2]

static void collectLayerSymbols ( CircuitOp  circuit,
llvm::DenseSet< Attribute > &  layers 
)
static

Definition at line 170 of file LinkCircuits.cpp.

References collectLayerSymbols().

◆ collectLayerSymbols() [2/2]

static void collectLayerSymbols ( LayerOp  layer,
SmallVectorImpl< FlatSymbolRefAttr > &  stack,
llvm::DenseSet< Attribute > &  layers 
)
static

Definition at line 159 of file LinkCircuits.cpp.

References collectLayerSymbols().

Referenced by collectLayerSymbols(), and collectLayerSymbols().

◆ handleCollidingOps()

static FailureOr< bool > handleCollidingOps ( SymbolOpInterface  collidingOp,
SymbolOpInterface  incomingOp,
const llvm::DenseSet< Attribute > &  mergedLayers,
const llvm::DenseSet< Attribute > &  incomingLayers 
)
static

Resolves symbol collisions during circuit merging.

Handles:

  1. Extmodule + module: declaration is removed in favor of the definition if their port attributes match. The definition must be public.
  2. Identical extmodules: duplicates are removed.
  3. Extmodule with empty parameters: the placeholder (without parameters) is removed in favor of the fully-parameterized one.
  4. Layers: recursively merged.
Parameters
collidingOpThe operation already present in the merged circuit
incomingOpThe operation being added from another circuit
Returns
FailureOr<bool> Returns success with true if incomingOp was erased, success with false if collidingOp was erased, or failure if the collision cannot be resolved
Note
The empty parameters workaround (case 3) should be removed once ODS is updated to properly support placeholder declarations.

Definition at line 237 of file LinkCircuits.cpp.

References mergeLayer(), and verifyKnownLayers().

◆ mangleCircuitSymbols()

static LogicalResult mangleCircuitSymbols ( CircuitOp  circuit)
static

Definition at line 72 of file LinkCircuits.cpp.

References updateType().

◆ mergeLayer()

static LogicalResult mergeLayer ( LayerOp  dst,
LayerOp  src 
)
static

Definition at line 200 of file LinkCircuits.cpp.

References mergeLayer().

Referenced by handleCollidingOps(), and mergeLayer().

◆ transformAnnotationTarget()

template<typename CallableT >
static DictionaryAttr transformAnnotationTarget ( DictionaryAttr  anno,
CallableT  transformTokensFn 
)
static

Definition at line 55 of file LinkCircuits.cpp.

◆ verifyKnownLayers()

static LogicalResult verifyKnownLayers ( FExtModuleOp  extModule,
const llvm::DenseSet< Attribute > &  availableLayers 
)
static

Definition at line 178 of file LinkCircuits.cpp.

Referenced by handleCollidingOps().