File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change
1
+ // Test tco's -emit-final-mlir option.
2
+
3
+ // RUN: tco -emit-final-mlir %s 2>&1 | FileCheck %s
4
+
5
+ // Check that the FIR file is translated into the LLVM IR
6
+ // MLIR dialect, but not into LLVM IR itself.
7
+
8
+ // CHECK-NOT: func.func
9
+ // CHECK-LABEL: llvm.func @_QPfoo()
10
+ // CHECK-NOT: fir.alloca
11
+ // CHECK: %[[VAL_0:.*]] = llvm.mlir.constant(1 : i64) : i64
12
+ // CHECK: %[[VAL_1:.*]] = llvm.alloca %[[VAL_0]] x i32 : (i64) -> !llvm.ptr
13
+ // CHECK: llvm.return
14
+ // CHECK-NOT: func.func
15
+
16
+ func.func @_QPfoo() {
17
+ %1 = fir.alloca i32
18
+ return
19
+ }
Original file line number Diff line number Diff line change @@ -70,6 +70,11 @@ static cl::opt<bool> codeGenLLVM(
70
70
cl::desc (" Run only CodeGen passes and translate FIR to LLVM IR" ),
71
71
cl::init(false ));
72
72
73
+ static cl::opt<bool > emitFinalMLIR (
74
+ " emit-final-mlir" ,
75
+ cl::desc (" Only translate FIR to MLIR, do not lower to LLVM IR" ),
76
+ cl::init(false ));
77
+
73
78
#include " flang/Optimizer/Passes/CommandLineOpts.h"
74
79
#include " flang/Optimizer/Passes/Pipelines.h"
75
80
@@ -149,13 +154,15 @@ compileFIR(const mlir::PassPipelineCLParser &passPipeline) {
149
154
fir::registerDefaultInlinerPass (config);
150
155
fir::createMLIRToLLVMPassPipeline (pm, config);
151
156
}
152
- fir::addLLVMDialectToLLVMPass (pm, out.os ());
157
+ if (!emitFinalMLIR)
158
+ fir::addLLVMDialectToLLVMPass (pm, out.os ());
153
159
}
154
160
155
161
// run the pass manager
156
162
if (mlir::succeeded (pm.run (*owningRef))) {
157
163
// passes ran successfully, so keep the output
158
- if ((emitFir || passPipeline.hasAnyOccurrences ()) && !codeGenLLVM)
164
+ if ((emitFir || passPipeline.hasAnyOccurrences () || emitFinalMLIR) &&
165
+ !codeGenLLVM)
159
166
printModule (*owningRef, out.os ());
160
167
out.keep ();
161
168
return mlir::success ();
You can’t perform that action at this time.
0 commit comments