@@ -30,6 +30,7 @@ constexpr char definitionMacroFlag[] = "GEN_DIALECT_DEF";
3030
3131namespace {
3232
33+ // / The set of strings that can be generated from a Dialect declaraiton
3334struct DialectStrings {
3435 std::string dialectName;
3536 std::string dialectCppName;
@@ -41,11 +42,13 @@ struct DialectStrings {
4142 std::string namespacePath;
4243};
4344
45+ // / The set of strings that can be generated from a Type declaraiton
4446struct TypeStrings {
4547 StringRef typeName;
4648 std::string typeCppName;
4749};
4850
51+ // / The set of strings that can be generated from an Operation declaraiton
4952struct OpStrings {
5053 StringRef opName;
5154 std::string opCppName;
@@ -61,23 +64,27 @@ static std::string joinNameList(llvm::ArrayRef<std::string> names) {
6164 return nameArray;
6265}
6366
67+ // / Generates the C++ type name for a TypeOp
6468static std::string typeToCppName (irdl::TypeOp type) {
6569 return llvm::formatv (" {0}Type" ,
6670 convertToCamelFromSnakeCase (type.getSymName (), true ));
6771}
6872
73+ // / Generates the C++ class name for an OperationOp
6974static std::string opToCppName (irdl::OperationOp op) {
7075 return llvm::formatv (" {0}Op" ,
7176 convertToCamelFromSnakeCase (op.getSymName (), true ));
7277}
7378
79+ // / Generates TypeStrings from a TypeOp
7480static TypeStrings getStrings (irdl::TypeOp type) {
7581 TypeStrings strings;
7682 strings.typeName = type.getSymName ();
7783 strings.typeCppName = typeToCppName (type);
7884 return strings;
7985}
8086
87+ // / Generates OpStrings from an OperatioOp
8188static OpStrings getStrings (irdl::OperationOp op) {
8289 auto operandOp = op.getOp <irdl::OperandsOp>();
8390
@@ -104,12 +111,14 @@ static OpStrings getStrings(irdl::OperationOp op) {
104111 return strings;
105112}
106113
114+ // / Fills a dictionary with values from TypeStrings
107115static void fillDict (irdl::detail::dictionary &dict,
108116 const TypeStrings &strings) {
109117 dict[" TYPE_NAME" ] = strings.typeName ;
110118 dict[" TYPE_CPP_NAME" ] = strings.typeCppName ;
111119}
112120
121+ // / Fills a dictionary with values from OpStrings
113122static void fillDict (irdl::detail::dictionary &dict, const OpStrings &strings) {
114123 const auto operandCount = strings.opOperandNames .size ();
115124 const auto resultCount = strings.opResultNames .size ();
@@ -124,6 +133,7 @@ static void fillDict(irdl::detail::dictionary &dict, const OpStrings &strings) {
124133 resultCount ? joinNameList (strings.opResultNames ) : " {\"\" }" ;
125134}
126135
136+ // / Fills a dictionary with values from DialectStrings
127137static void fillDict (irdl::detail::dictionary &dict,
128138 const DialectStrings &strings) {
129139 dict[" DIALECT_NAME" ] = strings.dialectName ;
0 commit comments