MLIR 24.0.0git
ACCToLLVM.cpp
Go to the documentation of this file.
1//===- ACCToLLVM.cpp - Convert OpenACC to LLVM dialect ----------*- 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
10
18#include "mlir/Pass/Pass.h"
19
20namespace mlir {
21#define GEN_PASS_DEF_CONVERTACCTOLLVMPASS
22#include "mlir/Conversion/Passes.h.inc"
23} // namespace mlir
24
25using namespace mlir;
26
27namespace {
28struct ConvertACCToLLVMPass
29 : public impl::ConvertACCToLLVMPassBase<ConvertACCToLLVMPass> {
30 using Base::Base;
31
32 void runOnOperation() override;
33};
34} // namespace
35
36void ConvertACCToLLVMPass::runOnOperation() {
37 ModuleOp module = getOperation();
38
39 SymbolTable symbolTable(module);
40 LLVMTypeConverter converter(&getContext());
41 RewritePatternSet patterns(&getContext());
42 arith::populateArithToLLVMConversionPatterns(converter, patterns);
44 populateFuncToLLVMConversionPatterns(converter, patterns);
46
47 acc::ACCRuntimeCallConfig runtimeConfig;
48
50 converter, patterns, module.getBodyRegion(), symbolTable, runtimeConfig);
51
52 acc::OpenACCSupport &accSupport = getAnalysis<acc::OpenACCSupport>();
53 populateACCDataDirectivePatterns(converter, patterns, accSupport,
54 module.getBodyRegion(), symbolTable,
55 runtimeConfig);
56 populateACCHostDataPatterns(converter, patterns, module.getBodyRegion(),
57 symbolTable, runtimeConfig);
58 populateACCAtomicPatterns(converter, patterns, accSupport);
59 populateACCDataClauseOpPatterns(converter, patterns, accSupport,
60 module.getBodyRegion(), symbolTable,
61 runtimeConfig);
62
63 LLVMConversionTarget target(getContext());
68 if (failed(applyPartialConversion(module, target, std::move(patterns))))
69 signalPassFailure();
70}
b getContext())
void populateControlFlowToLLVMConversionPatterns(const LLVMTypeConverter &converter, RewritePatternSet &patterns)
Collect the patterns to convert from the ControlFlow dialect to LLVM.
detail::InFlightRemark failed(Location loc, RemarkOpts opts)
Report an optimization remark that failed.
Definition Remarks.h:734
Include the generated interface declarations.
void populateACCDataClauseOpPatterns(LLVMTypeConverter &converter, RewritePatternSet &patterns, acc::OpenACCSupport &accSupport, Region &globalSymbolRegion, SymbolTable &symbolTable, const acc::ACCRuntimeCallConfig &config={})
Populate the patterns that remove OpenACC data clause operations once the constructs holding them hav...
void populateACCAtomicPatterns(const LLVMTypeConverter &converter, RewritePatternSet &patterns, acc::OpenACCSupport &accSupport, ACCAtomicLoadAddressCallback getLoadAddress={})
Populate patterns that lower OpenACC atomic operations to LLVM dialect.
void populateACCDataDirectivePatterns(LLVMTypeConverter &converter, RewritePatternSet &patterns, acc::OpenACCSupport &accSupport, Region &globalSymbolRegion, SymbolTable &symbolTable, const acc::ACCRuntimeCallConfig &config={}, acc::DeviceType clauseDeviceType=acc::DeviceType::None)
Populate patterns that lower OpenACC data directives (acc.data, enter_data, exit_data,...
void populateFuncToLLVMConversionPatterns(const LLVMTypeConverter &converter, RewritePatternSet &patterns, SymbolTableCollection *symbolTables=nullptr)
Collect the patterns to convert from the Func dialect to LLVM.
void configureACCHostDataConversionLegality(ConversionTarget &target)
Configure conversion legality for the OpenACC host_data construct.
void populateFinalizeMemRefToLLVMConversionPatterns(const LLVMTypeConverter &converter, RewritePatternSet &patterns, SymbolTableCollection *symbolTables=nullptr)
Collect a set of patterns to convert memory-related operations from the MemRef dialect to the LLVM di...
void populateACCExecutableDirectivePatterns(LLVMTypeConverter &converter, RewritePatternSet &patterns, Region &globalSymbolRegion, SymbolTable &symbolTable, const acc::ACCRuntimeCallConfig &config={})
Populate patterns that lower OpenACC executable directives (init, shutdown, wait, set) to LLVM runtim...
void configureACCExecutableDirectiveConversionLegality(ConversionTarget &target)
Configure conversion legality for OpenACC executable directives lowered to runtime calls.
void configureACCDataDirectiveConversionLegality(ConversionTarget &target)
Configure conversion legality for OpenACC data directives.
void populateACCHostDataPatterns(LLVMTypeConverter &converter, RewritePatternSet &patterns, Region &globalSymbolRegion, SymbolTable &symbolTable, const acc::ACCRuntimeCallConfig &config={})
Populate patterns that lower the OpenACC host_data construct to runtime calls, one per use_device cla...
void configureACCAtomicConversionLegality(ConversionTarget &target)
Configure conversion legality for OpenACC atomic operations.