CIRCT  19.0.0git
Public Member Functions | Public Attributes | List of all members
ModuleNameSanitizer Struct Reference

Psuedo-reduction that sanitizes module, instance, and port names. More...

Inheritance diagram for ModuleNameSanitizer:
Inheritance graph
[legend]
Collaboration diagram for ModuleNameSanitizer:
Collaboration graph
[legend]

Public Member Functions

const char * getName ()
 
char getPortName ()
 
void beforeReduction (mlir::ModuleOp op) override
 Called before the reduction is applied to a new subset of operations. More...
 
LogicalResult rewrite (firrtl::CircuitOp circuitOp) override
 
std::string getName () const override
 Return a human-readable name for this reduction pattern. More...
 
bool acceptSizeIncrease () const override
 Return true if the tool should accept the transformation this reduction performs on the module even if the overall size of the output increases. More...
 
bool isOneShot () const override
 Return true if the tool should not try to reapply this reduction after it has been successful. More...
 
- Public Member Functions inherited from circt::OpReduction< firrtl::CircuitOp >
uint64_t match (Operation *op) override
 Check if the reduction can apply to a specific operation. More...
 
virtual uint64_t match (firrtl::CircuitOp op)
 
LogicalResult rewrite (Operation *op) override
 Apply the reduction to a specific operation. More...
 
- Public Member Functions inherited from circt::Reduction
virtual ~Reduction ()
 
virtual void afterReduction (mlir::ModuleOp)
 Called after the reduction has been applied to a subset of operations. More...
 
void notifyOpErased (Operation *op)
 

Public Attributes

const char * names [48]
 
size_t nameIndex = 0
 
size_t portNameIndex = 0
 
- Public Attributes inherited from circt::Reduction
std::function< void(Operation *)> notifyOpErasedCallback = nullptr
 An optional callback for reductions to communicate removal of operations. More...
 

Detailed Description

Psuedo-reduction that sanitizes module, instance, and port names.

This makes the following changes:

- All modules are given metasyntactic names ("Foo", "Bar", etc.)
- All instances are renamed to match the new module name
- All module ports are renamed in the following way:
    - All clocks are reanemd to "clk"
    - All resets are renamed to "rst"
    - All references are renamed to "ref"
    - Anything else is renamed to "port"

Definition at line 1000 of file FIRRTLReductions.cpp.

Member Function Documentation

◆ acceptSizeIncrease()

bool ModuleNameSanitizer::acceptSizeIncrease ( ) const
inlineoverridevirtual

Return true if the tool should accept the transformation this reduction performs on the module even if the overall size of the output increases.

This can be handy for patterns that reduce the complexity of the IR at the cost of some verbosity.

Reimplemented from circt::Reduction.

Definition at line 1088 of file FIRRTLReductions.cpp.

◆ beforeReduction()

void ModuleNameSanitizer::beforeReduction ( mlir::ModuleOp  )
inlineoverridevirtual

Called before the reduction is applied to a new subset of operations.

Reductions may use this callback to collect information such as symbol tables about the module upfront.

Reimplemented from circt::Reduction.

Definition at line 1027 of file FIRRTLReductions.cpp.

◆ getName() [1/2]

const char* ModuleNameSanitizer::getName ( )
inline

Definition at line 1013 of file FIRRTLReductions.cpp.

◆ getName() [2/2]

std::string ModuleNameSanitizer::getName ( ) const
inlineoverridevirtual

Return a human-readable name for this reduction pattern.

Implements circt::Reduction.

Definition at line 1086 of file FIRRTLReductions.cpp.

◆ getPortName()

char ModuleNameSanitizer::getPortName ( )
inline

Definition at line 1021 of file FIRRTLReductions.cpp.

◆ isOneShot()

bool ModuleNameSanitizer::isOneShot ( ) const
inlineoverridevirtual

Return true if the tool should not try to reapply this reduction after it has been successful.

This is useful for reductions whose match() function keeps returning true even after the reduction has reached a fixed-point and no longer performs any change. An example of this are reductions that apply a lowering pass which always applies but may leave the input unmodified.

This is mainly useful in conjunction with returning true from acceptSizeIncrease(). For reductions that don't accept an increase, the module size has to decrease for them to be considered useful, which prevents the tool from getting stuck at a local point where the reduction applies but produces no change in the input. However, reductions that do accept a size increase can get stuck in this local fixed-point as they keep applying to the same operations and the tool keeps accepting the unmodified input as an improvement.

Reimplemented from circt::Reduction.

Definition at line 1090 of file FIRRTLReductions.cpp.

◆ rewrite()

LogicalResult ModuleNameSanitizer::rewrite ( firrtl::CircuitOp  circuitOp)
inlineoverridevirtual

Member Data Documentation

◆ nameIndex

size_t ModuleNameSanitizer::nameIndex = 0

Definition at line 1011 of file FIRRTLReductions.cpp.

◆ names

const char* ModuleNameSanitizer::names[48]
Initial value:
= {
"Foo", "Bar", "Baz", "Qux", "Quux", "Quuux", "Quuuux",
"Quz", "Corge", "Grault", "Bazola", "Ztesch", "Thud", "Grunt",
"Bletch", "Fum", "Fred", "Jim", "Sheila", "Barney", "Flarp",
"Zxc", "Spqr", "Wombat", "Shme", "Bongo", "Spam", "Eggs",
"Snork", "Zot", "Blarg", "Wibble", "Toto", "Titi", "Tata",
"Tutu", "Pippo", "Pluto", "Paperino", "Aap", "Noot", "Mies",
"Oogle", "Foogle", "Boogle", "Zork", "Gork", "Bork"}

Definition at line 1002 of file FIRRTLReductions.cpp.

◆ portNameIndex

size_t ModuleNameSanitizer::portNameIndex = 0

Definition at line 1019 of file FIRRTLReductions.cpp.


The documentation for this struct was generated from the following file: