CIRCT 22.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/Pass/Pass.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 FailureOr< bool > handleCollidingOps (SymbolOpInterface collidingOp, SymbolOpInterface incomingOp)
 Handles colliding symbols when merging circuits.
 

Macro Definition Documentation

◆ GEN_PASS_DEF_LINKCIRCUITS

#define GEN_PASS_DEF_LINKCIRCUITS

Definition at line 32 of file LinkCircuits.cpp.

Function Documentation

◆ handleCollidingOps()

static FailureOr< bool > handleCollidingOps ( SymbolOpInterface  collidingOp,
SymbolOpInterface  incomingOp 
)
static

Handles colliding symbols when merging circuits.

This function resolves symbol collisions between operations in different circuits during the linking process. It handles three specific cases:

  1. Identical extmodules: When two extmodules have identical attributes, the incoming one is removed as they are duplicates.
  2. Extmodule declaration + module definition: When an extmodule (declaration) collides with a module (definition), the declaration is removed in favor of the definition if their attributes match.
  3. Extmodule with empty parameters (Zaozi workaround): When two extmodules collide and one has empty parameters, the one without parameters (placeholder declaration) is removed. This handles a limitation in Zaozi's module generation where placeholder extmodule declarations are created from instance ops without knowing the actual parameters or defname.
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
This workaround for empty parameters should ultimately be removed once ODS is updated to properly support placeholder declarations.

Definition at line 186 of file LinkCircuits.cpp.

◆ mangleCircuitSymbols()

static LogicalResult mangleCircuitSymbols ( CircuitOp  circuit)
static

Definition at line 73 of file LinkCircuits.cpp.

References updateType().

◆ transformAnnotationTarget()

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

Definition at line 56 of file LinkCircuits.cpp.