[Mlir-commits] [mlir] [mlir][ODS] Allow inferring operand types from multiple variables (PR #127517)
Jeff Niu
llvmlistbot at llvm.org
Tue Feb 18 09:52:50 PST 2025
================
@@ -303,22 +303,33 @@ struct OperationFormat {
std::optional<int> getBuilderIdx() const { return builderIdx; }
void setBuilderIdx(int idx) { builderIdx = idx; }
+ int getNumArgs() const { return resolver.size(); }
+
/// Get the variable this type is resolved to, or nullptr.
- const NamedTypeConstraint *getVariable() const {
- return llvm::dyn_cast_if_present<const NamedTypeConstraint *>(resolver);
+ const NamedTypeConstraint *getVariable(int i) const {
+ return resolver.empty()
+ ? nullptr
+ : llvm::dyn_cast_if_present<const NamedTypeConstraint *>(
+ resolver[i]);
----------------
Mogball wrote:
```suggestion
if (resolver.empty())
return nullptr
return llvm::dyn_cast_if_present<const NamedTypeConstraint *>(resolver[i]);
```
1 less line of code
https://github.com/llvm/llvm-project/pull/127517
More information about the Mlir-commits
mailing list