[Mlir-commits] [flang] [mlir] [MLIR][ODS] Add support for overloading interface methods (PR #161828)
Mehdi Amini
llvmlistbot at llvm.org
Mon Oct 6 07:56:55 PDT 2025
================
@@ -83,8 +87,15 @@ Interface::Interface(const Record *def) : def(def) {
// Initialize the interface methods.
auto *listInit = dyn_cast<ListInit>(def->getValueInit("methods"));
- for (const Init *init : listInit->getElements())
- methods.emplace_back(cast<DefInit>(init)->getDef());
+ StringSet<> dedupNames;
+ for (const Init *init : listInit->getElements()) {
+ std::string name =
+ cast<DefInit>(init)->getDef()->getValueAsString("name").str();
+ while (!dedupNames.insert(name).second) {
+ name = name + "_" + std::to_string(dedupNames.size());
----------------
joker-eph wrote:
> When the interface method is called, how do you know which dedup method to call?
The actual deduce method name could be a randomly generated name, as long as the mapping is consistent.
So we can initialize `InterfaceMethod` with any dedup name as long as it is uniqued.
This is all just internal to the "vtables" we generate. The public interface/trait will expose the overloaded methods with their public name, and try to call the method on the Op with the public name as well.
https://github.com/llvm/llvm-project/pull/161828
More information about the Mlir-commits
mailing list