22 spirv::ImageOperandsAttr attr,
28 return imageOp->
emitError(
"the Image Operands should encode what operands "
29 "follow, as per Image Operands");
33 spirv::ImageOperands noSupportOperands =
34 spirv::ImageOperands::Bias | spirv::ImageOperands::Lod |
35 spirv::ImageOperands::Grad | spirv::ImageOperands::ConstOffset |
36 spirv::ImageOperands::Offset | spirv::ImageOperands::ConstOffsets |
37 spirv::ImageOperands::Sample | spirv::ImageOperands::MinLod |
38 spirv::ImageOperands::MakeTexelAvailable |
39 spirv::ImageOperands::MakeTexelVisible |
40 spirv::ImageOperands::SignExtend | spirv::ImageOperands::ZeroExtend;
42 assert(!spirv::bitEnumContainsAny(attr.getValue(), noSupportOperands) &&
43 "unimplemented operands of Image Operands");
44 (void)noSupportOperands;
55 getOperandArguments());
72 getOperandArguments());
81 llvm::cast<spirv::ImageType>(getImage().
getType());
82 Type resultType = getResult().getType();
84 spirv::Dim dim = imageType.
getDim();
88 case spirv::Dim::Dim1D:
89 case spirv::Dim::Dim2D:
90 case spirv::Dim::Dim3D:
91 case spirv::Dim::Cube:
92 if (samplingInfo != spirv::ImageSamplingInfo::MultiSampled &&
93 samplerInfo != spirv::ImageSamplerUseInfo::SamplerUnknown &&
94 samplerInfo != spirv::ImageSamplerUseInfo::NoSampler)
96 "if Dim is 1D, 2D, 3D, or Cube, "
97 "it must also have either an MS of 1 or a Sampled of 0 or 2");
99 case spirv::Dim::Buffer:
100 case spirv::Dim::Rect:
103 return emitError(
"the Dim operand of the image type must "
104 "be 1D, 2D, 3D, Buffer, Cube, or Rect");
107 unsigned componentNumber = 0;
109 case spirv::Dim::Dim1D:
110 case spirv::Dim::Buffer:
113 case spirv::Dim::Dim2D:
114 case spirv::Dim::Cube:
115 case spirv::Dim::Rect:
118 case spirv::Dim::Dim3D:
125 if (imageType.
getArrayedInfo() == spirv::ImageArrayedInfo::Arrayed)
126 componentNumber += 1;
128 unsigned resultComponentNumber = 1;
129 if (
auto resultVectorType = llvm::dyn_cast<VectorType>(resultType))
130 resultComponentNumber = resultVectorType.getNumElements();
132 if (componentNumber != resultComponentNumber)
133 return emitError(
"expected the result to have ")
134 << componentNumber <<
" component(s), but found "
135 << resultComponentNumber <<
" component(s)";
static LogicalResult verifyImageOperands(Operation *imageOp, spirv::ImageOperandsAttr attr, Operation::operand_range operands)
This class implements the operand iterators for the Operation class.
Operation is the basic unit of execution within MLIR.
InFlightDiagnostic emitError(const Twine &message={})
Emit an error about fatal conditions with this operation, reporting up to any diagnostic handlers tha...
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
ImageArrayedInfo getArrayedInfo() const
ImageSamplerUseInfo getSamplerUseInfo() const
ImageSamplingInfo getSamplingInfo() const
Include the generated interface declarations.
Type getType(OpFoldResult ofr)
Returns the int type of the integer in ofr.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
LogicalResult verify(Operation *op, bool verifyRecursively=true)
Perform (potentially expensive) checks of invariants, used to detect compiler bugs,...