[Mlir-commits] [mlir] [mlir][spirv] Add definition for ImageWriteOp (PR #124124)
Jakub Kuderski
llvmlistbot at llvm.org
Mon Feb 3 10:54:42 PST 2025
================
@@ -2020,6 +2020,65 @@ LogicalResult spirv::ImageDrefGatherOp::verify() {
return verifyImageOperands(*this, attr, operandArguments);
}
+//===----------------------------------------------------------------------===//
+// spirv.ImageWriteOp
+//===----------------------------------------------------------------------===//
+
+LogicalResult spirv::ImageWriteOp::verify() {
+ ImageType imageType = llvm::cast<ImageType>(getImage().getType());
+ Type sampledType = imageType.getElementType();
+ ImageSamplerUseInfo samplerInfo = imageType.getSamplerUseInfo();
+
+ if (samplerInfo != spirv::ImageSamplerUseInfo::SamplerUnknown &&
+ samplerInfo != spirv::ImageSamplerUseInfo::NoSampler) {
+ return emitOpError(
+ "the sampled operand of the underlying image must be 0 or 2");
+ }
+
+ // TODO: Do we need check for: "If the Arrayed operand is 1, then additional
+ // capabilities may be required; e.g., ImageCubeArray, or ImageMSArray.".
+
+ if (imageType.getDim() == spirv::Dim::SubpassData) {
+ return emitOpError(
+ "the Dim operand of the underlying image must not be SubpassData");
+ }
+
+ Type texelType = getTexel().getType();
+ if (llvm::isa<VectorType>(texelType)) {
+ texelType = llvm::cast<VectorType>(texelType).getElementType();
----------------
kuhar wrote:
Does `texelType` have to match `sampledType`? If yes, I think we could have this verified in ODS.
https://github.com/llvm/llvm-project/pull/124124
More information about the Mlir-commits
mailing list