| 51 | //===----------------------------------------------------------------------===// |
| 52 | |
| 53 | void mlir::tblgen::generateAttrVersionCheck( |
| 54 | const BytecodeAttrStructure &structure, raw_ostream &os) { |
| 55 | os << R"( |
| 56 | /// Check if an attribute tag is available in the given bytecode version. |
| 57 | /// Returns true if the attribute is supported, false otherwise. |
| 58 | inline bool isAttrTagAvailableInVersion(uint8_t tag, |
| 59 | const BytecodeVersion &version) { |
| 60 | switch (static_cast<Bytecode::AttributeTag>(tag)) { |
| 61 | )"; |
| 62 | |
| 63 | // Generate version check for each tagged attr. |
| 64 | for (const auto &attr : structure.bytecodeAttrs) { |
| 65 | if (attr.skipsVersionCheck || attr.sinceVersion.empty()) { |
| 66 | os << formatv(R"( case Bytecode::AttributeTag::{0}: |
| 67 | return true; |
| 68 | )", |
| 69 | attr.attrName); |
| 70 | continue; |
| 71 | } |
| 72 | |
| 73 | auto [majorStr, minorStr] = parseVersion(attr.sinceVersion); |
| 74 | os << formatv(R"( case Bytecode::AttributeTag::{0}: |
| 75 | return version >= *BytecodeVersion::fromVersion({1}, {2}, 0); |
| 76 | )", |
| 77 | attr.attrName, majorStr, minorStr); |
| 78 | } |
| 79 | |
| 80 | os << R"( default: |
| 81 | // Unknown/invalid tags are not available. |
| 82 | return false; |
| 83 | } |
| 84 | } |
| 85 | )"; |
| 86 | } |
| 87 | |
| 88 | //===----------------------------------------------------------------------===// |
| 89 | // Code Generation: Enum Type Traits |
nothing calls this directly
no outgoing calls
no test coverage detected