I plan to expand func.call to support nested reference, I am not very familiar with SymbolTable in mlir, I think I may only need to modify these two methods?
gpu.launch_func has implemented nested reference, I think I can learn something from it. I still hope someone can give me a little hint.
Have you looked at how the callee arguments is defined in ODS between func.call and gpu.launch_func? That should provide some good info I think (I suspect func.call is a FlatSymbolRef)
I don’t know what component you’re saying you need to modify, but in general “module” has nothing specific: you should get the closest enclosing SymbolTable operation, it may or may not be a ModuleOp.
Lowering to LLVM IR should not touch a call to a nested symbol and leave it as-is: it is the kind of thing to handle at a higher-level.
It all depends on the cmake configuration… For the basics: are you using clang, lld, ninja, and ccache? Are you building in Release+Assert mode?
I am translating AST(or CST) to MLIR. And I need to translate classAst and manage a module system . Organizing them with Module Op and then using nested symbols to access the Op/Value in each Module looks pretty nice! Just like what I mentioned before.
The call to nested reference (@Foo::@foo) is not correct in the code below.
This is contrary to what I was trying to accomplish (e.g., calling a function of class b from within class a). If you want to do this, you might as well rename the function.
Option 1
So why not just design a new FuncCallOp on the top of func.call.
The new FuncCallOp will probably require these parameter inputs:
When lowring, rename function name to _moduleA_moduleB_classC_funcName.
Or just define a new SymbolType which will do renaming by default, and let FuncCallOp use this new type as input.
Option 2
Manually manage a table of symbols and use the information recorded in this table directly to generate the renamed function.
More
For compiling multiple mlir files, I think it’s better to just copy everything from the other modules into the module where the entry function is located. Then use a few passes to eliminate unused functions and other components.
I’m using MSVC Build system. Release+Assert mode. I found that cmake will rebuild all components, it seems like it is not cached. Maybe using clang and set -DLLVM_CCACHE_BUILD=ON will speed things up.