[llvm] [mlir] [utils][TableGen] Implement clause aliases as alternative spellings (PR #141765)
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 5 07:48:24 PDT 2025
================
@@ -109,7 +156,33 @@ class BaseRecord {
public:
BaseRecord(const Record *Def) : Def(Def) {}
- StringRef getName() const { return Def->getValueAsString("name"); }
+ std::vector<Spelling::Value> getSpellings() const {
+ std::vector<Spelling::Value> List;
+ llvm::transform(Def->getValueAsListOfDefs("spellings"),
+ std::back_inserter(List),
+ [](const Record *R) { return Spelling(R).get(); });
+ return List;
+ }
+
+ StringRef getSpellingForIdentifier() const {
+ // From all spellings, pick the first one with the minimum version
+ // (i.e. pick the first from all the oldest ones). This guarantees
+ // that given several equivalent (in terms of versions) names, the
+ // first one is used, e.g. given
+ // Clause<[Spelling<"foo">, Spelling<"bar">]> ...
+ // "foo" will be the selected spelling.
+ //
+ // This is a suitable spelling for generating an identifier name,
+ // since it will remain unchanged when any potential new spellings
+ // are added.
+ Spelling::Value Oldest{"not found", {/*Min=*/INT_MAX, 0}};
+ for (auto V : getSpellings()) {
----------------
kparzysz wrote:
I removed it, but IMO {} make it more readable.
https://github.com/llvm/llvm-project/pull/141765
More information about the llvm-commits
mailing list