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
16#include "mlir/Pass/Pass.h"
17
18namespace mlir {
19#define GEN_PASS_DEF_CONVERTACCTOLLVMPASS
20#include "mlir/Conversion/Passes.h.inc"
21} // namespace mlir
22
23using namespace mlir;
24
25namespace {
26struct ConvertACCToLLVMPass
27 : public impl::ConvertACCToLLVMPassBase<ConvertACCToLLVMPass> {
28 using Base::Base;
29
30 void runOnOperation() override;
31};
32} // namespace
33
34void ConvertACCToLLVMPass::runOnOperation() {
35 ModuleOp module = getOperation();
36
37 LLVMTypeConverter converter(&getContext());
38 RewritePatternSet patterns(&getContext());
39 arith::populateArithToLLVMConversionPatterns(converter, patterns);
41 populateFuncToLLVMConversionPatterns(converter, patterns);
42
43 // The device_type numbering is implementation-defined by the target
44 // runtime. For now assume the same numbering as the OpenACC dialect.
45 acc::ACCRuntimeCallConfig runtimeConfig;
47 populateACCExecutableDirectivePatterns(converter, patterns, runtimeConfig);
48
49 LLVMConversionTarget target(getContext());
51 if (failed(applyPartialConversion(module, target, std::move(patterns))))
52 signalPassFailure();
53}
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 populateFuncToLLVMConversionPatterns(const LLVMTypeConverter &converter, RewritePatternSet &patterns, SymbolTableCollection *symbolTables=nullptr)
Collect the patterns to convert from the Func dialect to LLVM.
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...