#include "mlir/Dialect/AMDGPU/Transforms/Utils.h" #include "mlir/Dialect/AMDGPU/IR/AMDGPUDialect.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/Vector/IR/VectorOps.h" using namespace mlir; using namespace mlir::amdgpu; std::optional amdgpu::getIndices(Operation *op) { if (auto loadOp = dyn_cast(op)) return loadOp.getIndices(); if (auto storeOp = dyn_cast(op)) return storeOp.getIndices(); if (auto vectorReadOp = dyn_cast(op)) return vectorReadOp.getIndices(); if (auto vectorStoreOp = dyn_cast(op)) return vectorStoreOp.getIndices(); if (auto transferReadOp = dyn_cast(op)) return transferReadOp.getIndices(); if (auto transferWriteOp = dyn_cast(op)) return transferWriteOp.getIndices(); return std::nullopt; } void amdgpu::setIndices(Operation *op, ArrayRef indices) { if (auto loadOp = dyn_cast(op)) return loadOp.getIndicesMutable().assign(indices); if (auto storeOp = dyn_cast(op)) return storeOp.getIndicesMutable().assign(indices); if (auto vectorReadOp = dyn_cast(op)) return vectorReadOp.getIndicesMutable().assign(indices); if (auto vectorStoreOp = dyn_cast(op)) return vectorStoreOp.getIndicesMutable().assign(indices); if (auto transferReadOp = dyn_cast(op)) return transferReadOp.getIndicesMutable().assign(indices); if (auto transferWriteOp = dyn_cast(op)) return transferWriteOp.getIndicesMutable().assign(indices); }