Skip to content

Commit 9f8f0e6

Browse files
committed
[flang][cuda][NFC] Split allocation related operation conversion from other
Split AllocOp, FreeOp, AllocateOp and DeallocateOp from other conversion. Patterns are currently added to the base CUFOpConversion.
1 parent 411a53e commit 9f8f0e6

File tree

5 files changed

+524
-375
lines changed

5 files changed

+524
-375
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//===------- CUFAllocationConversion.h --------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef FORTRAN_OPTIMIZER_TRANSFORMS_CUDA_CUFALLOCATIONCONVERSION_H_
10+
#define FORTRAN_OPTIMIZER_TRANSFORMS_CUDA_CUFALLOCATIONCONVERSION_H_
11+
12+
#include "mlir/Pass/Pass.h"
13+
#include "mlir/Pass/PassRegistry.h"
14+
15+
namespace fir {
16+
class LLVMTypeConverter;
17+
}
18+
19+
namespace mlir {
20+
class DataLayout;
21+
class SymbolTable;
22+
} // namespace mlir
23+
24+
namespace cuf {
25+
26+
/// Patterns that convert CUF operations to runtime calls.
27+
void populateCUFAllocationConversionPatterns(
28+
const fir::LLVMTypeConverter &converter, mlir::DataLayout &dl,
29+
const mlir::SymbolTable &symtab, mlir::RewritePatternSet &patterns);
30+
31+
} // namespace cuf
32+
33+
#endif // FORTRAN_OPTIMIZER_TRANSFORMS_CUDA_CUFALLOCATIONCONVERSION_H_

flang/include/flang/Optimizer/Transforms/Passes.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,11 +471,19 @@ def AssumedRankOpConversion : Pass<"fir-assumed-rank-op", "mlir::ModuleOp"> {
471471
];
472472
}
473473

474+
def CUFAllocationConversion : Pass<"cuf-allocation-convert", "mlir::ModuleOp"> {
475+
let summary = "Convert allocation related CUF operations to runtime calls";
476+
let dependentDialects = ["fir::FIROpsDialect"];
477+
}
478+
474479
def CUFOpConversion : Pass<"cuf-convert", "mlir::ModuleOp"> {
475480
let summary = "Convert some CUF operations to runtime calls";
476481
let dependentDialects = [
477482
"fir::FIROpsDialect", "mlir::gpu::GPUDialect", "mlir::DLTIDialect"
478483
];
484+
let options = [Option<"allocationConversion", "allocation-conversion", "bool",
485+
/*default=*/"true",
486+
"Convert allocation related operation with this pass">];
479487
}
480488

481489
def CUFDeviceGlobal :

flang/lib/Optimizer/Transforms/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ add_flang_library(FIRTransforms
99
CompilerGeneratedNames.cpp
1010
ConstantArgumentGlobalisation.cpp
1111
ControlFlowConverter.cpp
12+
CUDA/CUFAllocationConversion.cpp
1213
CUFAddConstructor.cpp
1314
CUFDeviceGlobal.cpp
1415
CUFOpConversion.cpp

0 commit comments

Comments
 (0)