CIRCT 23.0.0git
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
circt::reduce::MetasyntacticNameGenerator Class Reference

A utility class that generates metasyntactic variable names for use in reductions. More...

#include <ReductionUtils.h>

Collaboration diagram for circt::reduce::MetasyntacticNameGenerator:
Collaboration graph
[legend]

Public Member Functions

 MetasyntacticNameGenerator ()=default
 
const char * getNextName ()
 Get the next metasyntactic name in the sequence.
 
StringRef getNextName (Namespace &ns)
 Get the next metasyntactic name that is not already reserved in ns, and reserve it.
 
void reset ()
 Reset the generator to start from the beginning of the sequence.
 

Static Public Member Functions

static bool isMetasyntacticName (StringRef name)
 Return true if name already has a metasyntactic prefix, i.e.
 

Private Attributes

size_t index = 0
 

Static Private Attributes

static constexpr const char * names [48]
 

Detailed Description

A utility class that generates metasyntactic variable names for use in reductions.

This provides a consistent naming scheme across different reduction patterns.

Definition at line 36 of file ReductionUtils.h.

Constructor & Destructor Documentation

◆ MetasyntacticNameGenerator()

circt::reduce::MetasyntacticNameGenerator::MetasyntacticNameGenerator ( )
default

Member Function Documentation

◆ getNextName() [1/2]

const char * MetasyntacticNameGenerator::getNextName ( )

Get the next metasyntactic name in the sequence.

Definition at line 22 of file ReductionUtils.cpp.

References index, and names.

Referenced by getNextName(), and ModuleNameSanitizer::rewrite().

◆ getNextName() [2/2]

StringRef MetasyntacticNameGenerator::getNextName ( Namespace ns)

Get the next metasyntactic name that is not already reserved in ns, and reserve it.

If the candidate name is already taken, ns appends a numeric suffix (e.g. "Foo_0") to make it unique.

Definition at line 28 of file ReductionUtils.cpp.

References getNextName(), and circt::Namespace::newName().

◆ isMetasyntacticName()

bool MetasyntacticNameGenerator::isMetasyntacticName ( StringRef  name)
static

Return true if name already has a metasyntactic prefix, i.e.

the substring before the first '_' (or the whole string if there is no '_') is one of the names in the generator sequence. Examples: isMetasyntacticName("Foo") → true isMetasyntacticName("Foo_0") → true isMetasyntacticName("Foo_0_0_0") → true isMetasyntacticName("FooBar") → false isMetasyntacticName("MyModule") → false

Definition at line 32 of file ReductionUtils.cpp.

References names.

◆ reset()

void circt::reduce::MetasyntacticNameGenerator::reset ( )
inline

Reset the generator to start from the beginning of the sequence.

Definition at line 59 of file ReductionUtils.h.

References index.

Member Data Documentation

◆ index

size_t circt::reduce::MetasyntacticNameGenerator::index = 0
private

Definition at line 62 of file ReductionUtils.h.

Referenced by getNextName(), and reset().

◆ names

constexpr const char* circt::reduce::MetasyntacticNameGenerator::names[48]
staticconstexprprivate
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 63 of file ReductionUtils.h.

Referenced by getNextName(), and isMetasyntacticName().


The documentation for this class was generated from the following files: