MLIR 24.0.0git
NVVMDialect.h
Go to the documentation of this file.
1//===- NVVMDialect.h - MLIR NVVM IR 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// This file defines the NVVM IR dialect in MLIR, containing NVVM operations and
10// NVVM specific extensions to the LLVM type system.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef MLIR_DIALECT_LLVMIR_NVVMDIALECT_H_
15#define MLIR_DIALECT_LLVMIR_NVVMDIALECT_H_
16
24#include "mlir/IR/Dialect.h"
29#include "llvm/IR/IntrinsicsNVPTX.h"
30
31#include "mlir/Dialect/LLVMIR/NVVMOpsEnums.h.inc"
32
33namespace mlir {
34namespace NVVM {
35/// Utility functions to compare NVVMMemorySpace with unsigned values.
36inline bool operator==(unsigned as, NVVMMemorySpace memSpace) {
37 return as == static_cast<unsigned>(memSpace);
38}
39inline bool operator==(NVVMMemorySpace memSpace, unsigned as) {
40 return static_cast<unsigned>(memSpace) == as;
41}
42inline bool operator!=(unsigned as, NVVMMemorySpace memSpace) {
43 return as != static_cast<unsigned>(memSpace);
44}
45inline bool operator!=(NVVMMemorySpace memSpace, unsigned as) {
46 return static_cast<unsigned>(memSpace) != as;
47}
48
49// Shared memory has 128-bit alignment
50constexpr int kSharedMemoryAlignmentBit = 128;
51
52/// A pair type of LLVM's Intrinsic ID and args (which are llvm values).
53/// This type is returned by the getIntrinsicIDAndArgs() methods.
54using IDArgPair =
55 std::pair<llvm::Intrinsic::ID, llvm::SmallVector<llvm::Value *>>;
56
57/// Return the element type and number of elements associated with a wmma matrix
58/// of given chracteristics. This matches the logic in IntrinsicsNVVM.td
59/// WMMA_REGS structure.
60std::pair<mlir::Type, unsigned> inferMMAType(mlir::NVVM::MMATypes type,
61 mlir::NVVM::MMAFrag frag, int nRow,
62 int nCol,
63 mlir::MLIRContext *context);
64} // namespace NVVM
65} // namespace mlir
66
67///// Ops /////
68#define GET_ATTRDEF_CLASSES
69#include "mlir/Dialect/LLVMIR/NVVMOpsAttributes.h.inc"
70
71#define GET_OP_CLASSES
72#include "mlir/Dialect/LLVMIR/NVVMOps.h.inc"
73
74#endif /* MLIR_DIALECT_LLVMIR_NVVMDIALECT_H_ */
MLIRContext is the top-level object for a collection of MLIR operations.
Definition MLIRContext.h:63
constexpr int kSharedMemoryAlignmentBit
Definition NVVMDialect.h:50
bool operator==(unsigned as, NVVMMemorySpace memSpace)
Utility functions to compare NVVMMemorySpace with unsigned values.
Definition NVVMDialect.h:36
bool operator!=(unsigned as, NVVMMemorySpace memSpace)
Definition NVVMDialect.h:42
std::pair< mlir::Type, unsigned > inferMMAType(mlir::NVVM::MMATypes type, mlir::NVVM::MMAFrag frag, int nRow, int nCol, mlir::MLIRContext *context)
Return the element type and number of elements associated with a wmma matrix of given chracteristics.
std::pair< llvm::Intrinsic::ID, llvm::SmallVector< llvm::Value * > > IDArgPair
A pair type of LLVM's Intrinsic ID and args (which are llvm values).
Definition NVVMDialect.h:54
Include the generated interface declarations.