MLIR 24.0.0git
NVVMOps.h
Go to the documentation of this file.
1//===- NVVMOps.h - NVVM operation implementation helpers -------*- 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 the helpers that the source files of several op
10// partitions of the NVVM dialect use. Helpers used by one op partition are
11// defined in its source file only.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef MLIR_LIB_DIALECT_LLVMIR_IR_NVVMOPS_H
16#define MLIR_LIB_DIALECT_LLVMIR_IR_NVVMOPS_H
17
20#include "mlir/IR/Value.h"
21#include "llvm/IR/Intrinsics.h"
22#include "llvm/Support/Casting.h"
23
24namespace llvm {
25class IRBuilderBase;
26class Value;
27} // namespace llvm
28
29namespace mlir::NVVM {
30/// The ID of no intrinsic, used in the intrinsic tables of the ops.
31constexpr unsigned notIntrinsic = llvm::Intrinsic::not_intrinsic;
32
33/// Returns whether `ptr` is a pointer into the address space `targetAS`.
34inline bool isPtrInAddrSpace(mlir::Value ptr, NVVMMemorySpace targetAS) {
35 auto ptrTy = llvm::cast<LLVM::LLVMPointerType>(ptr.getType());
36 return ptrTy.getAddressSpace() == static_cast<unsigned>(targetAS);
37}
38
39/// Returns whether `ptr` is a pointer into the shared memory of the CTA.
41 return isPtrInAddrSpace(ptr, NVVMMemorySpace::Shared);
42}
43
44/// Returns `addr` cast to the kernel parameter address space.
45llvm::Value *getParamCastedAddr(llvm::Value *addr,
46 llvm::IRBuilderBase &builder);
47} // namespace mlir::NVVM
48
49#endif // MLIR_LIB_DIALECT_LLVMIR_IR_NVVMOPS_H
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Definition Value.h:96
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Definition CallGraph.h:229
llvm::Value * getParamCastedAddr(llvm::Value *addr, llvm::IRBuilderBase &builder)
Returns addr cast to the kernel parameter address space.
constexpr unsigned notIntrinsic
The ID of no intrinsic, used in the intrinsic tables of the ops.
Definition NVVMOps.h:31
bool isPtrInAddrSpace(mlir::Value ptr, NVVMMemorySpace targetAS)
Returns whether ptr is a pointer into the address space targetAS.
Definition NVVMOps.h:34
bool isPtrInSharedCTASpace(mlir::Value ptr)
Returns whether ptr is a pointer into the shared memory of the CTA.
Definition NVVMOps.h:40