-
Notifications
You must be signed in to change notification settings - Fork 175
[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">, | ||
|
||
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 | ||
|
||
// 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.