| 84 | } |
| 85 | |
| 86 | std::pair<std::string, std::string> |
| 87 | mlir::tblgen::extractVersionFromOperand(unsigned operandIndex, |
| 88 | const Operator &op) { |
| 89 | assert(operandIndex < static_cast<unsigned>(op.getNumOperands()) && |
| 90 | "TableGen backend bug: operand index out of bounds"); |
| 91 | |
| 92 | // Find argument index by scanning for operands only. |
| 93 | uint32_t currentOperandIndex = 0; |
| 94 | for (int argIndex = 0; argIndex < op.getNumArgs(); ++argIndex) { |
| 95 | auto argToOpOrAttr = op.getArgToOperandAttrOrProp(argIndex); |
| 96 | |
| 97 | // Check if this argument is an operand. |
| 98 | if (argToOpOrAttr.kind() == Operator::OperandAttrOrProp::Kind::Operand) { |
| 99 | if (currentOperandIndex == operandIndex) { |
| 100 | // Found the argument index for this operand - get its decorators. |
| 101 | for (const auto &decorator : op.getArgDecorators(argIndex)) { |
| 102 | if (!decorator.getDef().isSubClassOf("CudaTileArgMetadata")) |
| 103 | continue; |
| 104 | |
| 105 | const std::string version = |
| 106 | decorator.getDef().getValueAsString("sinceVersion").str(); |
| 107 | return parseVersion(version); |
| 108 | } |
| 109 | |
| 110 | // Found operand but no metadata. |
| 111 | const auto &operand = op.getOperand(operandIndex); |
| 112 | PrintFatalError( |
| 113 | op.getLoc(), |
| 114 | "operand '" + operand.name.str() + "' in operation '" + |
| 115 | op.getOperationName() + |
| 116 | "' is missing version metadata (CudaTileArgMetadata)"); |
| 117 | } |
| 118 | ++currentOperandIndex; |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | // Operand not found in operation arguments. |
| 123 | const auto &operand = op.getOperand(operandIndex); |
| 124 | PrintFatalError(op.getLoc(), "operand '" + operand.name.str() + |
| 125 | "' not found in operation '" + |
| 126 | op.getOperationName() + "'"); |
| 127 | } |
| 128 | |
| 129 | std::pair<StringMap<size_t>, std::optional<std::pair<std::string, std::string>>> |
| 130 | mlir::tblgen::getVersionOrderedBitAssignments(const Operator &op) { |
nothing calls this directly
no test coverage detected