CIRCT  19.0.0git
Classes | Namespaces | Macros | Functions
FIRRTLReductions.cpp File Reference
#include "circt/Dialect/FIRRTL/FIRRTLReductions.h"
#include "circt/Dialect/FIRRTL/CHIRRTLDialect.h"
#include "circt/Dialect/FIRRTL/FIRRTLInstanceGraph.h"
#include "circt/Dialect/FIRRTL/FIRRTLOps.h"
#include "circt/Dialect/FIRRTL/FIRRTLUtils.h"
#include "circt/Dialect/FIRRTL/Passes.h"
#include "circt/Reduce/ReductionUtils.h"
#include "circt/Support/Namespace.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/Support/Debug.h"
Include dependency graph for FIRRTLReductions.cpp:

Go to the source code of this file.

Classes

struct  detail::SymbolCache
 A utility doing lazy construction of SymbolTables and SymbolUserMaps, which is handy for reductions that need to look up a lot of symbols. More...
 
struct  ModuleSizeCache
 Utility to track the transitive size of modules. More...
 
struct  NLARemover
 A tracker for track NLAs affected by a reduction. More...
 
struct  FIRRTLModuleExternalizer
 A sample reduction pattern that maps firrtl.module to firrtl.extmodule. More...
 
struct  InstanceStubber
 A sample reduction pattern that maps firrtl.instance to a set of invalidated wires. More...
 
struct  MemoryStubber
 A sample reduction pattern that maps firrtl.mem to a set of invalidated wires. More...
 
struct  FIRRTLOperandForwarder< OpNum >
 A sample reduction pattern that replaces all uses of an operation with one of its operands. More...
 
struct  FIRRTLConstantifier
 A sample reduction pattern that replaces FIRRTL operations with a constant zero of their type. More...
 
struct  ConnectInvalidator
 A sample reduction pattern that replaces the right-hand-side of firrtl.connect and firrtl.strictconnect operations with a firrtl.invalidvalue. More...
 
struct  AnnotationRemover
 A sample reduction pattern that removes FIRRTL annotations from ports and operations. More...
 
struct  RootPortPruner
 A sample reduction pattern that removes ports from the root firrtl.module if the port is not used or just invalidated. More...
 
struct  ExtmoduleInstanceRemover
 A sample reduction pattern that replaces instances of firrtl.extmodule with wires. More...
 
struct  ConnectForwarder
 A sample reduction pattern that pushes connected values through wires. More...
 
struct  ConnectSourceOperandForwarder< OpNum >
 A sample reduction pattern that replaces a single-use wire and register with an operand of the source value of the connection. More...
 
struct  DetachSubaccesses
 A sample reduction pattern that tries to remove aggregate wires by replacing all subaccesses with new independent wires. More...
 
struct  NodeSymbolRemover
 This reduction removes symbols on node ops. More...
 
struct  EagerInliner
 A sample reduction pattern that eagerly inlines instances. More...
 
struct  ModuleInternalNameSanitizer
 Psuedo-reduction that sanitizes the names of things inside modules. More...
 
struct  ModuleNameSanitizer
 Psuedo-reduction that sanitizes module, instance, and port names. More...
 

Namespaces

 detail
 

Macros

#define DEBUG_TYPE   "firrtl-reductions"
 

Functions

static std::optional< firrtl::FModuleOp > findInstantiatedModule (firrtl::InstanceOp instOp, ::detail::SymbolCache &symbols)
 Utility to easily get the instantiated firrtl::FModuleOp or an empty optional in case another type of module is instantiated. More...
 
static bool onlyInvalidated (Value arg)
 Check that all connections to a value are invalids. More...
 
static void invalidateOutputs (ImplicitLocOpBuilder &builder, Value value, SmallDenseMap< Type, Value, 8 > &invalidCache, bool flip=false)
 Invalidate all the leaf fields of a value with a given flippedness by connecting an invalid value to them. More...
 
static void connectToLeafs (ImplicitLocOpBuilder &builder, Value dest, Value value)
 Connect a value to every leave of a destination value. More...
 
static void reduceXor (ImplicitLocOpBuilder &builder, Value &into, Value value)
 Reduce all leaf fields of a value through an XOR tree. More...
 
static bool isFlowSensitiveOp (Operation *op)
 Check whether an operation interacts with flows in any way, which can make replacement and operand forwarding harder in some cases. More...
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "firrtl-reductions"

Definition at line 22 of file FIRRTLReductions.cpp.

Function Documentation

◆ connectToLeafs()

static void connectToLeafs ( ImplicitLocOpBuilder &  builder,
Value  dest,
Value  value 
)
static

Connect a value to every leave of a destination value.

Definition at line 257 of file FIRRTLReductions.cpp.

References builder, and circt::firrtl::FIRRTLBaseType::getBitWidthOrSentinel().

Referenced by MemoryStubber::rewrite().

◆ findInstantiatedModule()

static std::optional<firrtl::FModuleOp> findInstantiatedModule ( firrtl::InstanceOp  instOp,
::detail::SymbolCache symbols 
)
static

Utility to easily get the instantiated firrtl::FModuleOp or an empty optional in case another type of module is instantiated.

Definition at line 66 of file FIRRTLReductions.cpp.

References detail::SymbolCache::getSymbolTable().

Referenced by ModuleSizeCache::getModuleSize(), and InstanceStubber::match().

◆ invalidateOutputs()

static void invalidateOutputs ( ImplicitLocOpBuilder &  builder,
Value  value,
SmallDenseMap< Type, Value, 8 > &  invalidCache,
bool  flip = false 
)
static

Invalidate all the leaf fields of a value with a given flippedness by connecting an invalid value to them.

This is useful for ensuring that all output ports of an instance or memory (including those nested in bundles) are properly invalidated.

Definition at line 214 of file FIRRTLReductions.cpp.

References builder, and circt::firrtl::direction::flip().

Referenced by InstanceStubber::rewrite(), and MemoryStubber::rewrite().

◆ isFlowSensitiveOp()

static bool isFlowSensitiveOp ( Operation *  op)
static

Check whether an operation interacts with flows in any way, which can make replacement and operand forwarding harder in some cases.

Definition at line 486 of file FIRRTLReductions.cpp.

Referenced by FIRRTLOperandForwarder< OpNum >::match(), and FIRRTLConstantifier::match().

◆ onlyInvalidated()

static bool onlyInvalidated ( Value  arg)
static

Check that all connections to a value are invalids.

Definition at line 97 of file FIRRTLReductions.cpp.

Referenced by RootPortPruner::rewrite().

◆ reduceXor()

static void reduceXor ( ImplicitLocOpBuilder &  builder,
Value &  into,
Value  value 
)
static

Reduce all leaf fields of a value through an XOR tree.

Definition at line 292 of file FIRRTLReductions.cpp.

References builder.

Referenced by MemoryStubber::rewrite().