1 //===- AMDGPUDialect.cpp - MLIR AMDGPU dialect implementation --------===// 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 implements the AMDGPU dialect and its operations. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #include "mlir/Dialect/AMDGPU/AMDGPUDialect.h" 14 #include "mlir/IR/Builders.h" 15 #include "mlir/IR/OpImplementation.h" 16 #include "mlir/IR/TypeUtilities.h" 17 18 using namespace mlir; 19 20 #include "mlir/Dialect/AMDGPU/AMDGPUDialect.cpp.inc" 21 22 void amdgpu::AMDGPUDialect::initialize() { 23 addOperations< 24 #define GET_OP_LIST 25 #include "mlir/Dialect/AMDGPU/AMDGPU.cpp.inc" 26 >(); 27 } 28 29 //===----------------------------------------------------------------------===// 30 // RawBuffer*Op 31 //===----------------------------------------------------------------------===// 32 template <typename T> 33 static LogicalResult verifyRawBufferOp(T &op) { 34 MemRefType bufferType = op.memref().getType().template cast<MemRefType>(); 35 if (bufferType.getMemorySpaceAsInt() != 0) 36 return op.emitOpError( 37 "Buffer ops must operate on a memref in global memory"); 38 if (!bufferType.hasRank()) 39 return op.emitOpError( 40 "Cannot meaningfully buffer_store to an unranked memref"); 41 if (static_cast<int64_t>(op.indices().size()) != bufferType.getRank()) 42 return op.emitOpError("Expected " + Twine(bufferType.getRank()) + 43 " indices to memref"); 44 return success(); 45 } 46 47 LogicalResult amdgpu::RawBufferLoadOp::verify() { 48 return verifyRawBufferOp(*this); 49 } 50 51 LogicalResult amdgpu::RawBufferStoreOp::verify() { 52 return verifyRawBufferOp(*this); 53 } 54 55 LogicalResult amdgpu::RawBufferAtomicFaddOp::verify() { 56 return verifyRawBufferOp(*this); 57 } 58 59 #define GET_OP_CLASSES 60 #include "mlir/Dialect/AMDGPU/AMDGPU.cpp.inc" 61