This is an archive of the discontinued LLVM Phabricator instance.

[mlir] NFC: Move the state for managing SSA value names out of OperationPrinter and into a new class SSANameState.
ClosedPublic

Authored by rriddle on Jan 6 2020, 10:38 AM.

Details

Summary

This reduces the complexity of OperationPrinter and simplifies the code by quite a bit. The SSANameState is now held by ModuleState. This is in preparation for a future revision that molds ModuleState into something that can be used by users for caching the printer state, as well as for implementing printAsOperand style methods.

Depends On D72292

Diff Detail

Event Timeline

rriddle created this revision.Jan 6 2020, 10:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 6 2020, 10:38 AM

Unit tests: unknown.

clang-tidy: unknown.

clang-format: unknown.

Build artifacts: diff.json, console-log.txt

rriddle updated this revision to Diff 236752.Jan 7 2020, 8:11 PM

Update diff.

Unit tests: unknown.

clang-tidy: unknown.

clang-format: unknown.

Build artifacts: diff.json, console-log.txt

antiagainst accepted this revision.Jan 9 2020, 10:22 AM

Nice! I assume the changes for the printers are NFC so didn't pay much attention there. Just a few nits.

mlir/lib/IR/AsmPrinter.cpp
421

I see we are using unsigned id values. Not sure whether it will be enough in the future. But to make it easier to extend, what about defining a using IdType = unsigned or something for it?

422–423

With or without? I thought it should be with here?

422–423

The name of this function is slightly misleading. It actually prints a symbol of the value; that symbol can either be a value ID or a value name. What about printValueSymbol? (Or actually by value ID you mean value symbol? Either way, it would also be nice to explain the terms used at the very beginning: what is a value id mean, what is a value symbol (or whatever term).)

422–423

Explain printResultNo?

424

Explain a bit more about the result ArrayRef<int>?

430

Wouldn't a Optional<int> be better here for lookupResultNo?

439

s/~0/NameSentinel/

440

Redundant or operation?

445

You mean the value of the map?

505

Do we have some existing RAII mechanism that we can use for this?

553

Do we need to update lookupValue for this case?

This revision is now accepted and ready to land.Jan 9 2020, 10:22 AM
rriddle updated this revision to Diff 237138.Jan 9 2020, 11:41 AM
rriddle marked 14 inline comments as done.

Address comments.

mlir/lib/IR/AsmPrinter.cpp
421

I don't think this is necessary. 4 billion values is more than enough for a long time.

422–423

Done. Thanks.

553

Nope, only necessary if 'result' is in the middle of a result group, otherwise 'lookupValue' is already the head of the result group.

Unit tests: pass. 61656 tests passed, 0 failed and 778 were skipped.

clang-tidy: fail. Please fix clang-tidy findings.

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

This revision was automatically updated to reflect the committed changes.