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 LLVMTypeConverter converter(&getContext());
40 RewritePatternSet patterns(&getContext());
41 arith::populateArithToLLVMConversionPatterns(converter, patterns);
43 populateFuncToLLVMConversionPatterns(converter, patterns);
45
46 // The device_type numbering is implementation-defined by the target
47 // runtime. For now assume the same numbering as the OpenACC dialect.
48 acc::ACCRuntimeCallConfig runtimeConfig;
50 populateACCExecutableDirectivePatterns(converter, patterns, runtimeConfig);
51
52 acc::OpenACCSupport &accSupport = getAnalysis<acc::OpenACCSupport>();
53 populateACCAtomicPatterns(converter, patterns, accSupport);
54
55 LLVMConversionTarget target(getContext());
58 if (failed(applyPartialConversion(module, target, std::move(patterns))))
59 signalPassFailure();
60}
b getContext())
void populateDialectIdentityDeviceTypeMapping(ACCRuntimeCallConfig &config)
Install a device-type mapping that uses OpenACC dialect enum ordinals as the runtime encoding.
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:717
Include the generated interface declarations.
void populateACCAtomicPatterns(const LLVMTypeConverter &converter, RewritePatternSet &patterns, acc::OpenACCSupport &accSupport, ACCAtomicLoadAddressCallback getLoadAddress={})
Populate patterns that lower OpenACC atomic operations to LLVM dialect.
void populateFuncToLLVMConversionPatterns(const LLVMTypeConverter &converter, RewritePatternSet &patterns, SymbolTableCollection *symbolTables=nullptr)
Collect the patterns to convert from the Func dialect to LLVM.
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 configureACCExecutableDirectiveConversionLegality(ConversionTarget &target)
Configure conversion legality for OpenACC executable directives lowered to runtime calls.
void populateACCExecutableDirectivePatterns(LLVMTypeConverter &converter, RewritePatternSet &patterns, const acc::ACCRuntimeCallConfig &config={})
Populate patterns that lower OpenACC executable directives (init, shutdown, wait, set) to LLVM runtim...
void configureACCAtomicConversionLegality(ConversionTarget &target)
Configure conversion legality for OpenACC atomic operations.