MLIR 24.0.0git
ACCToLLVM.h
Go to the documentation of this file.
1//===- ACCToLLVM.h - 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
9#ifndef MLIR_CONVERSION_OPENACCTOLLVM_ACCTOLLVM_H
10#define MLIR_CONVERSION_OPENACCTOLLVM_ACCTOLLVM_H
11
13#include "mlir/IR/BuiltinOps.h"
14#include "mlir/IR/Value.h"
15
16#include <functional>
17#include <memory>
18
19namespace mlir {
20class ConversionTarget;
22class Operation;
23class Pass;
25class Region;
26class SymbolTable;
27
28namespace acc {
29class OpenACCSupport;
30} // namespace acc
31
32#define GEN_PASS_DECL_CONVERTACCTOLLVMPASS
33#include "mlir/Conversion/Passes.h.inc"
34
35/// Configure conversion legality for OpenACC executable directives lowered to
36/// runtime calls.
39
40/// Populate patterns that lower OpenACC executable directives (init, shutdown,
41/// wait, set) to LLVM runtime calls. The runtime declarations and globals the
42/// patterns add are created in \p globalSymbolRegion and registered in
43/// \p symbolTable.
45 LLVMTypeConverter &converter, RewritePatternSet &patterns,
46 Region &globalSymbolRegion, SymbolTable &symbolTable,
47 const acc::ACCRuntimeCallConfig &config = {});
48
49/// Returns the address operand of a dialect-specific load operation. Used when
50/// moving capture/update dependencies into a cmpxchg loop. Patterns already
51/// recognize `llvm.load` and `memref.load`; this callback covers other dialect
52/// specific loads.
54
55/// Configure conversion legality for OpenACC atomic operations.
57
58/// Populate patterns that lower OpenACC atomic operations to LLVM dialect.
60 const LLVMTypeConverter &converter, RewritePatternSet &patterns,
61 acc::OpenACCSupport &accSupport,
62 ACCAtomicLoadAddressCallback getLoadAddress = {});
63
64/// Configure conversion legality for OpenACC data directives.
66
67/// Populate patterns that lower OpenACC data directives (`acc.data`,
68/// `enter_data`, `exit_data`, `update`, `declare_enter`, `declare_exit`) to
69/// `__tgt_acc_data_*`, `__tgt_acc_declare`, and `__tgt_acc_mirror_*` runtime
70/// calls. Clauses that can be repeated per device type are taken from the ones
71/// that apply to \p clauseDeviceType. The runtime declarations and globals the
72/// patterns add are created in \p globalSymbolRegion and registered in
73/// \p symbolTable.
75 LLVMTypeConverter &converter, RewritePatternSet &patterns,
76 acc::OpenACCSupport &accSupport, Region &globalSymbolRegion,
77 SymbolTable &symbolTable, const acc::ACCRuntimeCallConfig &config = {},
78 acc::DeviceType clauseDeviceType = acc::DeviceType::None);
79
80/// Configure conversion legality for the OpenACC `host_data` construct.
82
83/// Populate patterns that lower the OpenACC `host_data` construct to runtime
84/// calls, one per `use_device` clause, so that the body of the construct works
85/// on device addresses. The runtime declarations and globals the patterns add
86/// are created in \p globalSymbolRegion and registered in \p symbolTable.
88 RewritePatternSet &patterns,
89 Region &globalSymbolRegion,
90 SymbolTable &symbolTable,
91 const acc::ACCRuntimeCallConfig &config = {});
92
93/// Populate the patterns that remove OpenACC data clause operations once the
94/// constructs holding them have turned their mappings into runtime calls. A
95/// data entry operation is replaced by the address of the object it named, and
96/// a data exit or bounds operation is erased. Clause operations whose result
97/// is not that address stay with the construct that holds them.
98///
99/// A conversion has to populate these only once every construct holding such a
100/// clause operation is lowered in the same conversion, as the mappings would
101/// otherwise be lost.
103 LLVMTypeConverter &converter, RewritePatternSet &patterns,
104 acc::OpenACCSupport &accSupport, Region &globalSymbolRegion,
105 SymbolTable &symbolTable, const acc::ACCRuntimeCallConfig &config = {});
106
107} // namespace mlir
108
109#endif // MLIR_CONVERSION_OPENACCTOLLVM_ACCTOLLVM_H
Conversion from types to the LLVM IR dialect.
Operation is the basic unit of execution within MLIR.
Definition Operation.h:87
The abstract base pass class.
Definition Pass.h:52
This class contains a list of basic blocks and a link to the parent operation it is attached to.
Definition Region.h:26
This class allows for representing and managing the symbol table used by operations with the 'SymbolT...
Definition SymbolTable.h:25
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Definition Value.h:96
Configuration for OpenACC to LLVM runtime lowering.
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 configureACCHostDataConversionLegality(ConversionTarget &target)
Configure conversion legality for the OpenACC host_data construct.
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.
std::function< Value(Operation *)> ACCAtomicLoadAddressCallback
Returns the address operand of a dialect-specific load operation.
Definition ACCToLLVM.h:53
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.