MLIR 23.0.0git
OpenACCUtilsCG.h
Go to the documentation of this file.
1//===- OpenACCUtilsCG.h - OpenACC Code Generation Utilities -----*- 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// This file defines utility functions for OpenACC code generation, including
10// data layout and type-related utilities.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef MLIR_DIALECT_OPENACC_OPENACCUTILSCG_H_
15#define MLIR_DIALECT_OPENACC_OPENACCUTILSCG_H_
16
18#include "mlir/IR/IRMapping.h"
20#include <optional>
21
22namespace mlir {
23namespace acc {
24
25/// Get the data layout for an operation.
26///
27/// Attempts to get the data layout from the operation or its parent module.
28/// If `allowDefault` is true (default), a default data layout may be
29/// constructed when no explicit data layout spec is found.
30///
31/// \param op The operation to get the data layout for.
32/// \param allowDefault If true, allow returning a default data layout.
33/// \return The data layout if available, std::nullopt otherwise.
34std::optional<DataLayout> getDataLayout(Operation *op,
35 bool allowDefault = true);
36
37/// Build an `acc.compute_region` operation by cloning a source region.
38///
39/// Creates a new `acc.compute_region` with the given launch arguments and
40/// origin string, then clones the operations from `regionToClone` into its
41/// body. Multi-block regions are wrapped with `scf.execute_region`.
42///
43/// The `mapping` is used and updated during cloning, allowing callers to
44/// track value correspondences. Optional `output`, `kernelFuncName`,
45/// `kernelModuleName`, and `stream` arguments are forwarded to the op.
46ComputeRegionOp buildComputeRegion(Location loc, ValueRange launchArgs,
47 ValueRange inputArgs, llvm::StringRef origin,
48 Region &regionToClone,
49 RewriterBase &rewriter, IRMapping &mapping,
50 ValueRange output = {},
51 FlatSymbolRefAttr kernelFuncName = {},
52 FlatSymbolRefAttr kernelModuleName = {},
53 Value stream = {});
54
55} // namespace acc
56} // namespace mlir
57
58#endif // MLIR_DIALECT_OPENACC_OPENACCUTILSCG_H_
std::optional< DataLayout > getDataLayout(Operation *op, bool allowDefault=true)
Get the data layout for an operation.
ComputeRegionOp buildComputeRegion(Location loc, ValueRange launchArgs, ValueRange inputArgs, llvm::StringRef origin, Region &regionToClone, RewriterBase &rewriter, IRMapping &mapping, ValueRange output={}, FlatSymbolRefAttr kernelFuncName={}, FlatSymbolRefAttr kernelModuleName={}, Value stream={})
Build an acc.compute_region operation by cloning a source region.
Include the generated interface declarations.