-
Notifications
You must be signed in to change notification settings - Fork 160
[CIR] Add option to emit MLIR in LLVM dialect. #1316
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
Changes from 3 commits
3af1d49
d51b625
47de848
e3d820f
aec099c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3120,7 +3120,16 @@ def emit_cir_only : Flag<["-"], "emit-cir-only">, | |
def emit_cir_flat : Flag<["-"], "emit-cir-flat">, Visibility<[ClangOption, CC1Option]>, | ||
Group<Action_Group>, HelpText<"Similar to -emit-cir but also lowers structured CFG into basic blocks.">; | ||
def emit_mlir : Flag<["-"], "emit-mlir">, Visibility<[CC1Option]>, Group<Action_Group>, | ||
HelpText<"Build ASTs and then lower through ClangIR to MLIR, emit the .milr file">; | ||
HelpText<"Build ASTs and then lower through ClangIR to MLIR (standard dialects " | ||
"when `-fno-clangir-direct-lowering` is used or the LLVM dialect when " | ||
"`-fclangir-direct-lowering` is used), emit the .mlir file.">; | ||
def emit_mlir_EQ : Joined<["-"], "emit-mlir=">, Visibility<[CC1Option]>, Group<Action_Group>, | ||
HelpText<"Build ASTs and then lower through ClangIR to the selected MLIR dialect, emit the .mlir file. " | ||
"Allowed values are `std` for MLIR standard dialects and `llvm` for the LLVM dialect.">, | ||
Values<"std,llvm">, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can "cir" and "cir-flat" be added here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I asked to remove it but now in light of upstreaming discussion llvm/llvm-project#127835 (comment), we should probably converge to make upstreaming approach easier. @Jezurko sorry for the noise. We should add Andy, should we hold on this until you land to make your life easier or is it enough if @Jezurko applies the changes above? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it makes sense to merge this first, then I can update my upstream patch to align with this and the wishes of the reviewers there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I will update the list of values and update the action. No worries about the noise :) @bcardosolopes what about the non- There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have posted an update in llvm/llvm-project#127835 that uses the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added another small discussion point over there |
||
NormalizedValuesScope<"FrontendOptions">, | ||
NormalizedValues<["MLIR_STD", "MLIR_LLVM"]>, | ||
MarshallingInfoEnum<FrontendOpts<"MLIRTargetDialect">, "MLIR_Default">; | ||
/// ClangIR-specific options - END | ||
|
||
def flto : Flag<["-"], "flto">, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-mlir %s -o - | FileCheck %s -check-prefix=LLVM | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-clangir-direct-lowering -emit-mlir %s -o - | FileCheck %s -check-prefix=STD | ||
|
||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-mlir=llvm %s -o - | FileCheck %s -check-prefix=LLVM | ||
// RUN: not %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-mlir=std %s -o - 2>&1 | FileCheck %s -check-prefix=STD_ERR | ||
|
||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-clangir-direct-lowering -emit-mlir=llvm %s -o - | FileCheck %s -check-prefix=LLVM | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-clangir-direct-lowering -emit-mlir=std %s -o - | FileCheck %s -check-prefix=STD | ||
|
||
// RUN: %clang -fclangir -Xclang -emit-mlir %s -o - -### 2>&1 | FileCheck %s -check-prefix=OPTS_NO_VALUE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the updates! Almost there, few more changes needed (sorry for not catching early):
|
||
// RUN: %clang -fclangir -Xclang -emit-mlir=llvm %s -o - -### 2>&1 | FileCheck %s -check-prefix=OPTS_LLVM | ||
// RUN: %clang -fno-clangir-direct-lowering -Xclang -emit-mlir=std %s -o - -### 2>&1 | FileCheck %s -check-prefix=OPTS_STD | ||
|
||
int foo(int a, int b) { | ||
return a + b; | ||
} | ||
|
||
// LLVM: llvm.func @foo | ||
// STD: func.func @foo | ||
// STD_ERR: ClangIR direct lowering is incompatible with emitting of MLIR standard dialects | ||
// OPTS_NO_VALUE: "-emit-mlir" | ||
// OPTS_LLVM: "-emit-mlir=llvm" | ||
// OPTS_STD: "-emit-mlir=std" |
Uh oh!
There was an error while loading. Please reload this page.