13
13
14
14
#include " mlir/TableGen/GenInfo.h"
15
15
16
+ #include " llvm/ADT/StringExtras.h"
16
17
#include " llvm/ADT/Twine.h"
17
18
#include " llvm/Support/CommandLine.h"
18
19
#include " llvm/Support/raw_ostream.h"
@@ -25,6 +26,7 @@ using llvm::ClauseVal;
25
26
using llvm::raw_ostream;
26
27
using llvm::Record;
27
28
using llvm::RecordKeeper;
29
+ using llvm::Twine;
28
30
29
31
// LLVM has multiple places (Clang, Flang, MLIR) where information about
30
32
// the directives (OpenMP/OpenACC), and clauses are needed. It is good software
@@ -54,8 +56,7 @@ static bool emitDecls(const RecordKeeper &recordKeeper, llvm::StringRef dialect,
54
56
recordKeeper.getAllDerivedDefinitions (" DirectiveLanguage" );
55
57
assert (!directiveLanguages.empty () && " DirectiveLanguage missing." );
56
58
57
- for (const Record *r : recordKeeper.getAllDerivedDefinitions (" Clause" )) {
58
- Clause c{r};
59
+ for (const Clause c : recordKeeper.getAllDerivedDefinitions (" Clause" )) {
59
60
const auto &clauseVals = c.getClauseVals ();
60
61
if (clauseVals.empty ())
61
62
continue ;
@@ -65,14 +66,13 @@ static bool emitDecls(const RecordKeeper &recordKeeper, llvm::StringRef dialect,
65
66
66
67
std::vector<std::string> cvDefs;
67
68
for (const auto &it : llvm::enumerate (clauseVals)) {
68
- ClauseVal cval{it.value ()};
69
+ const ClauseVal cval{it.value ()};
69
70
if (!cval.isUserVisible ())
70
71
continue ;
71
72
72
73
std::string name = cval.getFormattedName ();
73
74
std::string enumValName (name.length (), ' ' );
74
- std::transform (name.begin (), name.end (), enumValName.begin (),
75
- llvm::toLower);
75
+ llvm::transform (name, enumValName.begin (), llvm::toLower);
76
76
enumValName[0 ] = llvm::toUpper (enumValName[0 ]);
77
77
std::string cvDef{(enumName + llvm::Twine (name)).str ()};
78
78
os << " def " << cvDef << " : I32EnumAttrCase<\" " << enumValName << " \" , "
@@ -84,11 +84,9 @@ static bool emitDecls(const RecordKeeper &recordKeeper, llvm::StringRef dialect,
84
84
os << " \" Clause" << enumName << " \" ,\n " ;
85
85
os << " \" " << enumName << " Clause\" ,\n " ;
86
86
os << " [" ;
87
- for (unsigned int i = 0 ; i < cvDefs.size (); i++) {
88
- os << cvDefs[i];
89
- if (i != cvDefs.size () - 1 )
90
- os << " ," ;
91
- }
87
+ llvm::ListSeparator LS;
88
+ for (const auto &cvDef : cvDefs)
89
+ os << LS << cvDef;
92
90
os << " ]> {\n " ;
93
91
os << " let cppNamespace = \" ::mlir::"
94
92
<< directiveLanguages[0 ]->getValueAsString (" cppNamespace" ) << " \" ;\n " ;
0 commit comments