-
-
Notifications
You must be signed in to change notification settings - Fork 272
MLIR: Add Support to compile flags output MLIR file #3313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MLIR: Add Support to compile flags output MLIR file #3313
Conversation
Also add description for CL "output-mlir"
thewilsonator
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will have to put all of your code behind a #ifdef for versions of LDC that are not built with MLIR enabled (i.e. old verions of LLVM and those built without MLIR support).
You can restrict #ifdef to the stuff that actually requires MLIR library calls. The rest of the code (like the commandline parsing) you can keep, and then let LDC output an error message saying that MLIR is not supported in case LDC was built without it (for which you do need to #ifdef stuff ;-) ). |
driver/toobj.cpp
Outdated
| } | ||
|
|
||
| #if LDC_MLIR_ENABLED | ||
| void writeMLIRModule(::Module *m, mlir::MLIRContext &mlirContext, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this code not part of writeModule? (see e.g. line 415).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to have it in different functions, but I can also put it on writeModule, the problem is that I'll need some extra arguments on this function, so the function should be something like:
void writeModule(llvm::Module *m, const char *filename, ::Module *module,
mlir::MLIRContext &mlirContext, IRState *irs);In addition, writeAndFreeLLModulefrom CodeGenerator must also be changed to receive a dmodule as an argument to be used on write module
|
@Robertorosmaninho I looked more into this. I think I was confused and actually it looks like you have to fully rewrite the IR building code. I thought the same code can output IR and MLIR, but now it appears to me that those are completely separate IR build libraries. So you'd have to rewrite all D AST->MLIR generation from scratch. In that case, there is no point in trying to merge things into |
|
See my inline comments, otherwise looks good (I still don't like the addition to codegenerator, but let's live with it for now). |
Could you point me some test cases that test whether "file.ll" was created? |
Create folder Add a testcase, similar to anything in |
Thanks!
These tests will be presented with the modifications that actually generate some code, another branch is already being prepared to be sent here as PR (https://github.com/Robertorosmaninho/ldc/tree/Introducing-MLIR-translation/tests/codegen_mlir). |
JohanEngelen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks OK now after fixing my remarks. Looking forward to the next PR that adds actual output testing.
|
lgtm |
|
( Thanks Roberto for hanging on, and the (much needed :)) reviewers. Looking forward to the follow ups. |
No description provided.