CIRCT  20.0.0git
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/LLVM.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/Threading.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Support/LogicalResult.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/TypeSwitch.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  Equivalence
 This class is for reporting differences between two modules which should have been deduplicated. More...
 
struct  Equivalence::ModuleData
 
struct  Deduper
 
struct  llvm::DenseMapInfo< ModuleInfo >
 A DenseMapInfo implementation for ModuleInfo that is a pair of llvm::SHA256 hashes, which are represented as std::array<uint8_t, 32>, and an array of string attributes. More...
 

Namespaces

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

Macros

#define GEN_PASS_DEF_DEDUP
 

Functions

static bool canRemoveModule (mlir::SymbolOpInterface symbol)
 Returns true if the module can be removed. More...
 
llvm::raw_ostream & printHex (llvm::raw_ostream &stream, ArrayRef< uint8_t > bytes)
 
llvm::raw_ostream & printHash (llvm::raw_ostream &stream, llvm::SHA256 &data)
 
llvm::raw_ostream & printHash (llvm::raw_ostream &stream, std::string data)
 
static bool operator== (const ModuleInfo &lhs, const ModuleInfo &rhs)
 
static Location mergeLoc (MLIRContext *context, Location to, Location from)
 
bool fixupClassOp (ClassOp classOp)
 This fixes up ClassLikes with ClassType ports, when the classes have deduped. More...
 
void fixupObjectOp (ObjectOp objectOp, ClassType newClassType)
 This fixes up ObjectOps when the signature of their ClassOp changes. More...
 
void fixupConnect (ImplicitLocOpBuilder &builder, Value dst, Value src)
 This fixes up connects when the field names of a bundle type changes. More...
 
void fixupAllModules (InstanceGraph &instanceGraph)
 This is the root method to fixup module references when a module changes. More...
 

Macro Definition Documentation

◆ 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().

◆ fixupAllModules()

void fixupAllModules ( InstanceGraph instanceGraph)

This is the root method to fixup module references when a module changes.

It matches all the results of "to" module with the results of the "from" module.

Definition at line 1554 of file Dedup.cpp.

References fixupClassOp(), fixupConnect(), fixupObjectOp(), circt::firrtl::getNumPorts(), and circt::firrtl::Out.

◆ fixupClassOp()

bool fixupClassOp ( ClassOp  classOp)

This fixes up ClassLikes with ClassType ports, when the classes have deduped.

For each ClassType port, if the object reference being assigned is a different type, update the port type. Returns true if the ClassOp was updated and the associated ObjectOps should be updated.

Definition at line 1463 of file Dedup.cpp.

References assert(), and circt::calyx::direction::get().

Referenced by fixupAllModules().

◆ fixupConnect()

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

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 1528 of file Dedup.cpp.

References circt::firrtl::emitConnect().

Referenced by fixupAllModules().

◆ fixupObjectOp()

void fixupObjectOp ( ObjectOp  objectOp,
ClassType  newClassType 
)

This fixes up ObjectOps when the signature of their ClassOp changes.

This amounts to updating the ObjectOp result type to match the newly updated ClassOp type.

Definition at line 1521 of file Dedup.cpp.

Referenced by fixupAllModules().

◆ mergeLoc()

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

Definition at line 879 of file Dedup.cpp.

References circt::calyx::direction::get().

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

◆ operator==()

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

Definition at line 105 of file Dedup.cpp.

◆ printHash() [1/2]

llvm::raw_ostream& printHash ( llvm::raw_ostream &  stream,
llvm::SHA256 &  data 
)

Definition at line 83 of file Dedup.cpp.

References circt::firrtl::data, and printHex().

◆ printHash() [2/2]

llvm::raw_ostream& printHash ( llvm::raw_ostream &  stream,
std::string  data 
)

Definition at line 87 of file Dedup.cpp.

References circt::firrtl::data, and printHex().

◆ printHex()

llvm::raw_ostream& printHex ( llvm::raw_ostream &  stream,
ArrayRef< uint8_t >  bytes 
)

Definition at line 77 of file Dedup.cpp.

Referenced by printHash().