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/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  ValueId
 Unique identifier for a value. More...
 
struct  SymbolTarget
 
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 checkVisibility (mlir::SymbolOpInterface symbol)
 
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 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 40 of file Dedup.cpp.

Function Documentation

◆ checkVisibility()

static bool checkVisibility ( mlir::SymbolOpInterface  symbol)
static

Definition at line 53 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 1539 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 1448 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 1513 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 1506 of file Dedup.cpp.

Referenced by fixupAllModules().

◆ mergeLoc()

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

Definition at line 865 of file Dedup.cpp.

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

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

◆ printHash() [1/2]

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

Definition at line 73 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 77 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 67 of file Dedup.cpp.

Referenced by printHash().