This is an archive of the discontinued LLVM Phabricator instance.

[mlir][sparse] Adding `{Var,DimLvlExpr,DimSpec,LvlSpec,DimLvlMap}::str` methods
ClosedPublic

Authored by wrengr on Aug 10 2023, 12:34 PM.

Details

Summary

These methods are needed for use with Diagnostic::operator<< etc.

The definitions follow the pattern of Diagnostic::str by simply wrapping the underlying print(raw_ostream) method. Although there is some overhead for constructing the std::string, this seems like the overall most-efficient option: since this overhead only occurs on the error path (under the current intended usage). An alternative approach would be to have one method construct a Twine directly, and then have the print method pass the twine to the stream; however, that would mean introducing the overhead of twine construction on the common/happy path of simply printing things out.

Diff Detail

Event Timeline

wrengr created this revision.Aug 10 2023, 12:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2023, 12:34 PM
wrengr requested review of this revision.Aug 10 2023, 12:34 PM
aartbik accepted this revision.Aug 10 2023, 4:35 PM
This revision is now accepted and ready to land.Aug 10 2023, 4:35 PM
aartbik updated this revision to Diff 552583.Aug 22 2023, 8:03 PM

rebased with main