| 4 | |
| 5 | namespace mlir::tblgen { |
| 6 | bool gen_enum_param_list_macro(raw_ostream& os, llvm::RecordKeeper& keeper) { |
| 7 | std::vector<std::pair<std::string, std::string>> enums; |
| 8 | std::vector<std::pair<std::string, std::string>> bit_enums; |
| 9 | Environment env; |
| 10 | foreach_operator(keeper, [&](MgbOp& op) { |
| 11 | for (auto&& i : op.getAttributes()) { |
| 12 | if (auto attr = llvm::dyn_cast<MgbEnumAttr>(&i.attr)) { |
| 13 | auto insert = [&](const MgbEnumAttr& attr) { |
| 14 | auto&& item = std::make_pair( |
| 15 | attr.getParentNamespace(), attr.getEnumName()); |
| 16 | if (env.enumAlias |
| 17 | .emplace(attr.getBaseRecord()->getID(), std::move(item)) |
| 18 | .second) { |
| 19 | if (attr.getEnumCombinedFlag()) { |
| 20 | bit_enums.emplace_back(item); |
| 21 | } else { |
| 22 | enums.emplace_back(item); |
| 23 | } |
| 24 | } |
| 25 | }; |
| 26 | if (auto alias = llvm::dyn_cast<MgbAliasAttr>(attr)) { |
| 27 | auto&& aliasBase = alias->getAliasBase(); |
| 28 | insert(llvm::cast<MgbEnumAttr>(aliasBase)); |
| 29 | } else { |
| 30 | insert(*attr); |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | }); |
| 35 | os << "#define FOR_EACH_ENUM_PARAM(cb)"; |
| 36 | for (auto&& i : enums) { |
| 37 | os << formatv(" \\\n cb({0}::{1});", i.first, i.second); |
| 38 | } |
| 39 | os << "\n"; |
| 40 | os << "#define FOR_EACH_BIT_COMBINED_ENUM_PARAM(cb)"; |
| 41 | for (auto&& i : bit_enums) { |
| 42 | os << formatv(" \\\n cb({0}::{1});", i.first, i.second); |
| 43 | } |
| 44 | os << "\n"; |
| 45 | return false; |
| 46 | } |
| 47 | } // namespace mlir::tblgen |
nothing calls this directly
no test coverage detected