xref: /llvm-project/mlir/lib/CAPI/Dialect/NVGPU.cpp (revision 4f88c2311130791cf69da34b743b1b3ba7584a7b)
1a7d80c50Smax //===- NVGPU.cpp - C Interface for NVGPU dialect ------------------===//
2a7d80c50Smax //
3a7d80c50Smax // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4a7d80c50Smax // See https://llvm.org/LICENSE.txt for license information.
5a7d80c50Smax // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6a7d80c50Smax //
7a7d80c50Smax //===----------------------------------------------------------------------===//
8a7d80c50Smax 
9a7d80c50Smax #include "mlir-c/Dialect/NVGPU.h"
10a7d80c50Smax #include "mlir/CAPI/Registration.h"
11a7d80c50Smax #include "mlir/Dialect/NVGPU/IR/NVGPUDialect.h"
12*4f88c231SGuray Ozen #include "mlir/IR/BuiltinTypes.h"
13*4f88c231SGuray Ozen 
14*4f88c231SGuray Ozen using namespace mlir;
15*4f88c231SGuray Ozen using namespace mlir::nvgpu;
16a7d80c50Smax 
MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(NVGPU,nvgpu,mlir::nvgpu::NVGPUDialect)17a7d80c50Smax MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(NVGPU, nvgpu, mlir::nvgpu::NVGPUDialect)
18*4f88c231SGuray Ozen 
19*4f88c231SGuray Ozen bool mlirTypeIsANVGPUTensorMapDescriptorType(MlirType type) {
20*4f88c231SGuray Ozen   return isa<nvgpu::TensorMapDescriptorType>(unwrap(type));
21*4f88c231SGuray Ozen }
22*4f88c231SGuray Ozen 
mlirNVGPUTensorMapDescriptorTypeGet(MlirContext ctx,MlirType tensorMemrefType,int swizzle,int l2promo,int oobFill,int interleave)23*4f88c231SGuray Ozen MlirType mlirNVGPUTensorMapDescriptorTypeGet(MlirContext ctx,
24*4f88c231SGuray Ozen                                              MlirType tensorMemrefType,
25*4f88c231SGuray Ozen                                              int swizzle, int l2promo,
26*4f88c231SGuray Ozen                                              int oobFill, int interleave) {
27*4f88c231SGuray Ozen   return wrap(nvgpu::TensorMapDescriptorType::get(
28*4f88c231SGuray Ozen       unwrap(ctx), cast<MemRefType>(unwrap(tensorMemrefType)),
29*4f88c231SGuray Ozen       TensorMapSwizzleKind(swizzle), TensorMapL2PromoKind(l2promo),
30*4f88c231SGuray Ozen       TensorMapOOBKind(oobFill), TensorMapInterleaveKind(interleave)));
31*4f88c231SGuray Ozen }
32