[NFC][Sim] Rename "formatting token" to "formatting fragment"

Avoid the ambigous "token" term and use the same naming as the Moore dialect for
a part of a formatting string.

Signed-off-by: Leon Hielscher <hielscher@fzi.de>
This commit is contained in:
Leon Hielscher 2024-10-31 13:25:32 +01:00
parent 9d92072435
commit f91b47e93d
4 changed files with 26 additions and 26 deletions

View File

@ -150,7 +150,7 @@ def DPICallOp : SimOp<"func.dpi.call",
}
def FormatLitOp : SimOp<"fmt.lit", [Pure, ConstantLike]> {
let summary = "Literal string token";
let summary = "Literal string fragment";
let description = [{
Creates a constant, raw ASCII string literal for formatted printing.
The given string attribute will be outputted as is,
@ -300,7 +300,7 @@ def FormatStringConcatOp : SimOp<"fmt.concat", [Pure]> {
let extraClassDeclaration = [{
/// Returns true iff all of the input strings are primitive
/// (i.e. non-concatenated) tokens or block arguments.
/// (i.e. non-concatenated) fragments or block arguments.
bool isFlat() {
return llvm::none_of(getInputs(), [](Value operand) {
return !!operand.getDefiningOp<circt::sim::FormatStringConcatOp>();

View File

@ -19,10 +19,10 @@ def FormatStringType : SimTypeDef<"FormatString"> {
let summary = "Format string type";
let description = [{
A format string type represents either a single formatting token or the
concatenation of an arbitrary but finite number of tokens.
A formatting token is either a static string literal or the association of
a dynamic hardware value with a format specifier.
A format string type represents either a single formatting fragment or the
concatenation of an arbitrary but finite number of fragments.
A formatting fragment is either a static string literal or the association
of a dynamic hardware value with a format specifier.
}];
}

View File

@ -220,7 +220,7 @@ LogicalResult FormatStringConcatOp::getFlattenedInputs(
bool isCyclic = false;
// Perform a DFS on this operation's concatenated operands,
// collect the leaf format string tokens.
// collect the leaf format string fragments.
concatStack.insert({*this, 0});
while (!concatStack.empty()) {
auto &top = concatStack.back();

View File

@ -44,7 +44,7 @@ public:
private:
LogicalResult proceduralizePrintOps(Value clock,
ArrayRef<PrintFormattedOp> printOps);
SmallVector<Operation *> getPrintTokens(PrintFormattedOp op);
SmallVector<Operation *> getPrintFragments(PrintFormattedOp op);
void cleanup();
// Mapping Clock -> List of printf ops
@ -60,8 +60,8 @@ LogicalResult ProceduralizeSimPass::proceduralizePrintOps(
// List of uniqued values to become arguments of the TriggeredOp.
SmallSetVector<Value, 4> arguments;
// Map printf ops -> flattened list of tokens
SmallDenseMap<PrintFormattedOp, SmallVector<Operation *>, 4> tokenMap;
// Map printf ops -> flattened list of fragments
SmallDenseMap<PrintFormattedOp, SmallVector<Operation *>, 4> fragmentMap;
SmallVector<Location> locs;
SmallDenseSet<Value, 1> alwaysEnabledConditions;
@ -82,7 +82,7 @@ LogicalResult ProceduralizeSimPass::proceduralizePrintOps(
// Accumulate locations
locs.push_back(printOp.getLoc());
// Get the flat list of formatting tokens and collect leaf tokens
// Get the flat list of formatting fragments and collect leaf fragments
SmallVector<Value> flatString;
if (auto concatInput =
printOp.getInput().getDefiningOp<FormatStringConcatOp>()) {
@ -96,22 +96,22 @@ LogicalResult ProceduralizeSimPass::proceduralizePrintOps(
flatString.push_back(printOp.getInput());
}
auto &tokenList = tokenMap[printOp];
assert(tokenList.empty() && "printf operation visited twice.");
auto &fragmentList = fragmentMap[printOp];
assert(fragmentList.empty() && "printf operation visited twice.");
for (auto &token : flatString) {
auto *fmtOp = token.getDefiningOp();
for (auto &fragment : flatString) {
auto *fmtOp = fragment.getDefiningOp();
if (!fmtOp) {
printOp.emitError("Proceduralization of format strings passed as block "
"argument is unsupported.");
return failure();
}
tokenList.push_back(fmtOp);
// For non-literal tokens, the value to be formatted has to become an
fragmentList.push_back(fmtOp);
// For non-literal fragments, the value to be formatted has to become an
// argument.
if (!llvm::isa<FormatLitOp>(fmtOp)) {
auto fmtVal = getFormattedValue(fmtOp);
assert(!!fmtVal && "Unexpected foramtting token op.");
assert(!!fmtVal && "Unexpected foramtting fragment op.");
arguments.insert(fmtVal);
}
}
@ -161,18 +161,18 @@ LogicalResult ProceduralizeSimPass::proceduralizePrintOps(
}
}
// Create a copy of the required token operations within the TriggeredOp's
// body.
auto tokens = tokenMap[printOp];
// Create a copy of the required fragment operations within the
// TriggeredOp's body.
auto fragments = fragmentMap[printOp];
SmallVector<Value> clonedOperands;
builder.setInsertionPointToStart(trigOp.getBodyBlock());
for (auto *token : tokens) {
auto &fmtCloned = cloneMap[token];
for (auto *fragment : fragments) {
auto &fmtCloned = cloneMap[fragment];
if (!fmtCloned)
fmtCloned = builder.clone(*token, argumentMapper);
fmtCloned = builder.clone(*fragment, argumentMapper);
clonedOperands.push_back(fmtCloned->getResult(0));
}
// Concatenate tokens to a single value if necessary.
// Concatenate fragments to a single value if necessary.
Value procPrintInput;
if (clonedOperands.size() != 1)
procPrintInput = builder.createOrFold<FormatStringConcatOp>(
@ -208,7 +208,7 @@ LogicalResult ProceduralizeSimPass::proceduralizePrintOps(
return success();
}
// Prune the DAGs of formatting tokens left outside of the newly created
// Prune the DAGs of formatting fragments left outside of the newly created
// TriggeredOps.
void ProceduralizeSimPass::cleanup() {
SmallVector<Operation *> cleanupNextList;