CIRCT 22.0.0git
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Functions
Dedup.cpp File Reference
#include "circt/Dialect/FIRRTL/AnnotationDetails.h"
#include "circt/Dialect/FIRRTL/FIRRTLAttributes.h"
#include "circt/Dialect/FIRRTL/FIRRTLInstanceGraph.h"
#include "circt/Dialect/FIRRTL/FIRRTLOps.h"
#include "circt/Dialect/FIRRTL/FIRRTLTypes.h"
#include "circt/Dialect/FIRRTL/FIRRTLUtils.h"
#include "circt/Dialect/FIRRTL/NLATable.h"
#include "circt/Dialect/FIRRTL/Passes.h"
#include "circt/Dialect/HW/HWAttributes.h"
#include "circt/Dialect/HW/InnerSymbolNamespace.h"
#include "circt/Support/Debug.h"
#include "circt/Support/LLVM.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/IR/Threading.h"
#include "mlir/Pass/Pass.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/SHA256.h"
#include "circt/Dialect/FIRRTL/Passes.h.inc"
Include dependency graph for Dedup.cpp:

Go to the source code of this file.

Classes

struct  ModuleInfo
 
struct  StructuralHasherSharedConstants
 This struct contains constant string attributes shared across different threads. More...
 
struct  StructuralHasher
 
struct  ModuleInfoRef
 A reference to a ModuleInfo that compares and hashes like it. More...
 
struct  llvm::DenseMapInfo< ModuleInfoRef >
 Allow ModuleInfoRef to be used as dense map keys. More...
 
struct  Equivalence
 This class is for reporting differences between two modules which should have been deduplicated. More...
 
struct  Equivalence::ModuleData
 
struct  Deduper
 

Namespaces

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

Macros

#define DEBUG_TYPE   "firrtl-dedup"
 
#define GEN_PASS_DEF_DEDUP
 

Functions

static bool canRemoveModule (mlir::SymbolOpInterface symbol)
 Returns true if the module can be removed.
 
static bool operator== (const ModuleInfo &lhs, const ModuleInfo &rhs)
 
static Location mergeLoc (MLIRContext *context, Location to, Location from)
 
static void fixupConnect (ImplicitLocOpBuilder &builder, Value dst, Value src)
 This fixes up connects when the field names of a bundle type changes.
 
static void fixupSymbolSensitiveOp (Operation *op, InstanceGraph &instanceGraph, const DenseMap< Attribute, StringAttr > &dedupMap)
 Adjust the symbol references in an op.
 
static void fixupSymbolSensitiveOps (InstanceGraph &instanceGraph, const DenseMap< Operation *, ModuleInfoRef > &moduleToModuleInfo, const DenseMap< Attribute, StringAttr > &dedupMap)
 Adjust the symbol references in ops marked as sensitive to them.
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "firrtl-dedup"

Definition at line 37 of file Dedup.cpp.

◆ GEN_PASS_DEF_DEDUP

#define GEN_PASS_DEF_DEDUP

Definition at line 41 of file Dedup.cpp.

Function Documentation

◆ canRemoveModule()

static bool canRemoveModule ( mlir::SymbolOpInterface  symbol)
static

Returns true if the module can be removed.

Definition at line 55 of file Dedup.cpp.

Referenced by Equivalence::check().

◆ fixupConnect()

static void fixupConnect ( ImplicitLocOpBuilder &  builder,
Value  dst,
Value  src 
)
static

This fixes up connects when the field names of a bundle type changes.

It finds all fields which were previously bulk connected and legalizes it into a connect for each field.

Definition at line 1553 of file Dedup.cpp.

References circt::firrtl::emitConnect(), and fixupConnect().

Referenced by fixupConnect(), and fixupSymbolSensitiveOp().

◆ fixupSymbolSensitiveOp()

static void fixupSymbolSensitiveOp ( Operation *  op,
InstanceGraph instanceGraph,
const DenseMap< Attribute, StringAttr > &  dedupMap 
)
static

Adjust the symbol references in an op.

Thsi includes updating its attributes and types.

Definition at line 1579 of file Dedup.cpp.

References fixupConnect().

Referenced by fixupSymbolSensitiveOps().

◆ fixupSymbolSensitiveOps()

static void fixupSymbolSensitiveOps ( InstanceGraph instanceGraph,
const DenseMap< Operation *, ModuleInfoRef > &  moduleToModuleInfo,
const DenseMap< Attribute, StringAttr > &  dedupMap 
)
static

Adjust the symbol references in ops marked as sensitive to them.

This includes updating their attributes and types.

Definition at line 1647 of file Dedup.cpp.

References fixupSymbolSensitiveOp().

◆ mergeLoc()

static Location mergeLoc ( MLIRContext *  context,
Location  to,
Location  from 
)
static

Definition at line 940 of file Dedup.cpp.

Referenced by Deduper::dedup(), Deduper::mergeBlocks(), and Deduper::mergeOps().

◆ operator==()

static bool operator== ( const ModuleInfo lhs,
const ModuleInfo rhs 
)
static

Definition at line 93 of file Dedup.cpp.

References ModuleInfo::referredModuleNames, and ModuleInfo::structuralHash.