28#include "llvm/ADT/Sequence.h"
29#include "llvm/ADT/StringExtras.h"
30#include "llvm/ADT/TypeSwitch.h"
37#include "mlir/Dialect/SPIRV/IR/SPIRVOpsDialect.cpp.inc"
46 return llvm::any_of(region, [](
Block &block) {
48 return isa<spirv::ReturnOp, spirv::ReturnValueOp>(terminator);
54struct SPIRVInlinerInterface :
public DialectInlinerInterface {
55 using DialectInlinerInterface::DialectInlinerInterface;
59 bool wouldBeCloned)
const final {
66 IRMapping &)
const final {
69 auto *op = dest->getParentOp();
70 return isa<spirv::FuncOp, spirv::SelectionOp, spirv::LoopOp>(op);
77 IRMapping &)
const final {
79 if ((isa<spirv::SelectionOp, spirv::LoopOp>(op)) &&
87 if (isa<spirv::KillOp>(op))
95 void handleTerminator(Operation *op,
Block *newDest)
const final {
96 if (
auto returnOp = dyn_cast<spirv::ReturnOp>(op)) {
97 auto builder = OpBuilder(op);
98 spirv::BranchOp::create(builder, op->getLoc(), newDest);
100 }
else if (
auto retValOp = dyn_cast<spirv::ReturnValueOp>(op)) {
101 auto builder = OpBuilder(op);
102 spirv::BranchOp::create(builder, retValOp->getLoc(), newDest,
103 retValOp->getOperands());
110 void handleTerminator(Operation *op,
ValueRange valuesToRepl)
const final {
112 auto retValOp = dyn_cast<spirv::ReturnValueOp>(op);
117 assert(valuesToRepl.size() == 1 &&
118 "spirv.ReturnValue expected to only handle one result");
119 valuesToRepl.front().replaceAllUsesWith(retValOp.getValue());
128void SPIRVDialect::initialize() {
129 registerAttributes();
132 addInterfaces<SPIRVInlinerInterface>();
135 allowUnknownOperations();
136 declarePromisedInterface<gpu::TargetAttrInterface, TargetEnvAttr>();
139std::string SPIRVDialect::getAttributeName(Decoration decoration) {
148template <
typename ValTy>
149static std::optional<ValTy>
parseAndVerify(SPIRVDialect
const &dialect,
161 bool allowFunctionType =
false) {
172 if (
auto t = dyn_cast<FunctionType>(type); t && allowFunctionType) {
173 if (t.getNumResults() > 1) {
174 parser.
emitError(typeLoc,
"function type must have at most one result");
177 for (
Type elementType :
178 llvm::concat<const Type>(t.getInputs(), t.getResults())) {
179 if (!isa<SPIRVType>(elementType)) {
181 << elementType <<
" to compose SPIR-V types";
185 }
else if (
auto t = dyn_cast<FloatType>(type)) {
188 "only 8/16/32/64-bit float type allowed but found ")
192 }
else if (
auto t = dyn_cast<IntegerType>(type)) {
195 "only 1/8/16/32/64-bit integer type allowed but found ")
199 }
else if (
auto t = dyn_cast<VectorType>(type)) {
200 if (t.getRank() != 1) {
201 parser.
emitError(typeLoc,
"only 1-D vector allowed but found ") << t;
204 if (t.getNumElements() < 2) {
205 parser.
emitError(typeLoc,
"SPIR-V does not allow one-element vectors");
208 if (t.getNumElements() > 4) {
210 typeLoc,
"vector length has to be less than or equal to 4 but found ")
211 << t.getNumElements();
214 if (!isa<ScalarType>(t.getElementType())) {
217 "vector element type must be a SPIR-V scalar type but found ")
218 << t.getElementType();
221 }
else if (
auto t = dyn_cast<TensorArmType>(type)) {
222 if (!isa<ScalarType>(t.getElementType())) {
224 typeLoc,
"only scalar element type allowed in tensor type but found ")
225 << t.getElementType();
230 << type <<
" to compose SPIR-V types";
244 if (
auto t = dyn_cast<VectorType>(type)) {
245 if (t.getRank() != 1) {
246 parser.
emitError(typeLoc,
"only 1-D vector allowed but found ") << t;
249 if (t.getNumElements() > 4 || t.getNumElements() < 2) {
251 "matrix columns size has to be less than or equal "
252 "to 4 and greater than or equal 2, but found ")
253 << t.getNumElements();
257 if (!isa<FloatType>(t.getElementType())) {
258 parser.
emitError(typeLoc,
"matrix columns' elements must be of "
260 << t.getElementType();
264 parser.
emitError(typeLoc,
"matrix must be composed using vector "
280 auto imageType = dyn_cast<ImageType>(type);
283 "sampled image must be composed using image type, got ")
288 if (llvm::is_contained({Dim::SubpassData, Dim::Buffer}, imageType.getDim())) {
290 typeLoc,
"sampled image Dim must not be SubpassData or Buffer, got ")
291 << stringifyDim(imageType.getDim());
317 if (!(stride = *optStride)) {
318 parser.
emitError(strideLoc,
"ArrayStride must be greater than zero");
340 if (countDims.size() != 1) {
342 "expected single integer for array element count");
350 parser.
emitError(countLoc,
"expected array length greater than 0");
380 if (dims.size() != 2) {
381 parser.
emitError(countLoc,
"expected row and column count");
394 CooperativeMatrixUseKHR use;
404 elementTy.getContext(), elementTy, dims[0], dims[1], scope, use);
414 bool unranked =
false;
426 if (!unranked && dims.empty()) {
427 parser.
emitError(countLoc,
"arm.tensors do not support rank zero");
431 if (llvm::is_contained(dims, 0)) {
432 parser.
emitError(countLoc,
"arm.tensors do not support zero dimensions");
436 if (llvm::any_of(dims, [](
int64_t dim) {
return dim < 0; }) &&
437 llvm::any_of(dims, [](
int64_t dim) {
return dim > 0; })) {
438 parser.
emitError(countLoc,
"arm.tensor shape dimensions must be either "
439 "fully dynamic or completed shaped");
472 StringRef storageClassSpec;
477 auto storageClass = symbolizeStorageClass(storageClassSpec);
479 parser.
emitError(storageClassLoc,
"unknown storage class: ")
486 [&] {
return parser.
emitError(storageClassLoc); },
487 pointeeType.getContext(), pointeeType, *storageClass);
496 StringRef storageClassSpec;
501 auto storageClass = symbolizeStorageClass(storageClassSpec);
503 parser.
emitError(storageClassLoc,
"unknown storage class: ")
542 if (countDims.size() != 1) {
543 parser.
emitError(countLoc,
"expected single unsigned "
544 "integer for number of columns");
548 int64_t columnCount = countDims[0];
550 if (columnCount < 2 || columnCount > 4) {
551 parser.
emitError(countLoc,
"matrix is expected to have 2, 3, or 4 "
570template <
typename ValTy>
579 auto val = spirv::symbolizeEnum<ValTy>(enumSpec);
581 parser.
emitError(enumLoc,
"unknown attribute: '") << enumSpec <<
"'";
595template <
typename IntTy>
598 IntTy offsetVal = std::numeric_limits<IntTy>::max();
615template <
typename ParseType,
typename... Args>
616struct ParseCommaSeparatedList {
617 std::optional<std::tuple<ParseType, Args...>>
618 operator()(SPIRVDialect
const &dialect, DialectAsmParser &parser)
const {
623 auto numArgs = std::tuple_size<std::tuple<Args...>>::value;
626 auto remainingValues = ParseCommaSeparatedList<Args...>{}(dialect, parser);
627 if (!remainingValues)
629 return std::tuple_cat(std::tuple<ParseType>(parseVal.value()),
630 remainingValues.value());
636template <
typename ParseType>
637struct ParseCommaSeparatedList<ParseType> {
638 std::optional<std::tuple<ParseType>>
639 operator()(SPIRVDialect
const &dialect, DialectAsmParser &parser)
const {
641 return std::tuple<ParseType>(*value);
668 ParseCommaSeparatedList<
Type, Dim, ImageDepthInfo, ImageArrayedInfo,
669 ImageSamplingInfo, ImageSamplerUseInfo,
670 ImageFormat>{}(dialect, parser);
678 std::get<0>(*value).getContext(), *value);
708 if (failed(*offsetParseResult))
711 if (offsetInfo.size() != memberTypes.size() - 1) {
713 "offset specification must be given for "
716 offsetInfo.push_back(offset);
728 auto parseDecorations = [&]() {
730 if (!memberDecoration)
739 memberDecorationInfo.emplace_back(
740 static_cast<uint32_t
>(memberTypes.size() - 1),
741 memberDecoration.value(), memberDecorationValue);
743 memberDecorationInfo.emplace_back(
744 static_cast<uint32_t
>(memberTypes.size() - 1),
745 memberDecoration.value(), UnitAttr::get(dialect.getContext()));
771 StringRef identifier;
772 FailureOr<DialectAsmParser::CyclicParseReset> cyclicParse;
781 if (succeeded(cyclicParse)) {
784 "recursive struct reference not nested in struct definition");
795 if (failed(cyclicParse)) {
797 "identifier already used for an enclosing struct");
812 if (!identifier.empty())
823 if (!isa<SPIRVType>(memberType)) {
825 "member type must be a valid SPIR-V type");
828 memberTypes.push_back(memberType);
832 memberDecorationInfo))
836 if (!offsetInfo.empty() && memberTypes.size() != offsetInfo.size()) {
838 "offset specification must be given for all members");
847 auto parseStructDecoration = [&]() {
848 std::optional<spirv::Decoration> decoration =
859 structDecorationInfo.emplace_back(decoration.value(), decorationValue);
861 structDecorationInfo.emplace_back(decoration.value(),
862 UnitAttr::get(dialect.getContext()));
868 if (failed(parseStructDecoration()))
874 if (!identifier.empty()) {
875 if (failed(idStructTy.
trySetBody(memberTypes, offsetInfo,
876 memberDecorationInfo,
877 structDecorationInfo)))
883 structDecorationInfo);
898 if (keyword ==
"array")
900 if (keyword ==
"coopmatrix")
902 if (keyword ==
"image")
904 if (keyword ==
"ptr")
906 if (keyword ==
"rtarray")
908 if (keyword ==
"sampled_image")
910 if (keyword ==
"sampler")
912 if (keyword ==
"named_barrier")
914 if (keyword ==
"untyped_ptr")
916 if (keyword ==
"struct")
918 if (keyword ==
"matrix")
920 if (keyword ==
"arm.tensor")
933 os <<
", stride=" << stride;
940 os <<
", stride=" << stride;
951 <<
", " << stringifyImageDepthInfo(type.
getDepthInfo()) <<
", "
965 os <<
"named_barrier";
969 os <<
"untyped_ptr<" << stringifyStorageClass(type.
getStorageClass()) <<
">";
973 FailureOr<AsmPrinter::CyclicPrintReset> cyclicPrint;
981 if (failed(cyclicPrint)) {
991 auto printMember = [&](
unsigned i) {
995 if (type.
hasOffset() || !decorations.empty()) {
999 if (!decorations.empty())
1003 os << stringifyDecoration(decoration.decoration);
1004 if (decoration.hasValue()) {
1009 llvm::interleaveComma(decorations, os, eachFn);
1013 llvm::interleaveComma(llvm::seq<unsigned>(0, type.
getNumElements()), os,
1019 if (!decorations.empty()) {
1022 os << stringifyDecoration(decoration.decoration);
1023 if (decoration.hasValue()) {
1028 llvm::interleaveComma(decorations, os, eachFn);
1046 os <<
"arm.tensor<";
1051 if (ShapedType::isDynamic(dim))
1068 [&](
auto type) {
print(type, os); })
1069 .DefaultUnreachable(
"Unhandled SPIR-V type");
1079 if (
auto poison = dyn_cast<ub::PoisonAttr>(value))
1080 return ub::PoisonOp::create(builder, loc, type, poison);
1082 if (!spirv::ConstantOp::isBuildableWith(type))
1085 return spirv::ConstantOp::create(builder, loc, type, value);
1092LogicalResult SPIRVDialect::verifyOperationAttribute(
Operation *op,
1094 StringRef symbol = attribute.
getName().strref();
1098 if (!isa<spirv::EntryPointABIAttr>(attr)) {
1100 << symbol <<
"' attribute must be an entry point ABI attribute";
1103 if (!isa<spirv::TargetEnvAttr>(attr))
1104 return op->
emitError(
"'") << symbol <<
"' must be a spirv::TargetEnvAttr";
1106 if (!isa<spirv::LoopControlAttr>(attr))
1108 << symbol <<
"' must be a spirv::LoopControlAttr";
1110 if (!isa<spirv::SelectionControlAttr>(attr))
1112 << symbol <<
"' must be a spirv::SelectionControlAttr";
1114 return op->
emitError(
"found unsupported '")
1115 << symbol <<
"' attribute on operation";
1125 StringRef symbol = attribute.
getName().strref();
1129 auto varABIAttr = dyn_cast<spirv::InterfaceVarABIAttr>(attr);
1132 << symbol <<
"' must be a spirv::InterfaceVarABIAttr";
1136 <<
"' attribute cannot specify storage class "
1137 "when attaching to a non-scalar value";
1140 if (symbol == spirv::DecorationAttr::name) {
1141 if (!isa<spirv::DecorationAttr>(attr))
1143 << symbol <<
"' must be a spirv::DecorationAttr";
1147 return emitError(loc,
"found unsupported '")
1148 << symbol <<
"' attribute on region argument";
1155 std::optional<unsigned>
index = std::nullopt) {
1156 auto attrs = dyn_cast<ArrayAttr>(attr);
1157 if (!attrs || attrs.empty() ||
1158 !llvm::all_of(attrs,
1159 llvm::IsaPred<spirv::FunctionParameterAttributeAttr>))
1161 <<
"' must be a non-empty array of "
1162 "spirv::FunctionParameterAttributeAttr";
1165 bool hasZext =
false, hasSext =
false;
1168 cast<spirv::FunctionParameterAttributeAttr>(element).getValue();
1169 if (llvm::is_contained(seen, value))
1170 return emitError(loc,
"duplicate function parameter attribute '")
1171 << spirv::stringifyFunctionParameterAttribute(value) <<
"'";
1172 seen.push_back(value);
1175 case spirv::FunctionParameterAttribute::Zext:
1176 case spirv::FunctionParameterAttribute::Sext:
1177 if (!isa<IntegerType>(type))
1178 return emitError(loc,
"function parameter attribute '")
1179 << spirv::stringifyFunctionParameterAttribute(value)
1180 <<
"' requires an integer " << (
index ?
"parameter" :
"result");
1181 hasZext |= value == spirv::FunctionParameterAttribute::Zext;
1182 hasSext |= value == spirv::FunctionParameterAttribute::Sext;
1186 return emitError(loc,
"function parameter attribute '")
1187 << spirv::stringifyFunctionParameterAttribute(value)
1188 <<
"' is not valid on function results";
1189 if (!isa<spirv::PointerType>(type))
1190 return emitError(loc,
"function parameter attribute '")
1191 << spirv::stringifyFunctionParameterAttribute(value)
1192 <<
"' requires a pointer parameter";
1193 if (value == spirv::FunctionParameterAttribute::Sret && *
index != 0)
1195 "function parameter attribute 'Sret' requires the "
1200 if (hasZext && hasSext)
1201 return emitError(loc,
"function parameter attributes 'Zext' and 'Sext' are "
1202 "mutually exclusive");
1206LogicalResult SPIRVDialect::verifyRegionArgAttribute(
Operation *op,
1207 unsigned regionIndex,
1210 auto funcOp = dyn_cast<FunctionOpInterface>(op);
1213 Type argType = funcOp.getArgumentTypes()[argIndex];
1216 auto alignment = dyn_cast<IntegerAttr>(attribute.
getValue());
1217 if (!alignment || !alignment.getType().isSignlessInteger(32))
1220 <<
"' must be a 32-bit signless integer attribute";
1221 if (!isa<spirv::PointerType>(argType))
1223 <<
"' requires a pointer parameter";
1233LogicalResult SPIRVDialect::verifyRegionResultAttribute(
1234 Operation *op,
unsigned ,
unsigned resultIndex,
1236 if (
auto funcOp = dyn_cast<spirv::FuncOp>(op)) {
1239 op->
getLoc(), funcOp.getResultTypes()[resultIndex],
1241 return op->
emitError(
"found unsupported '")
1242 << attribute.
getName().strref() <<
"' attribute on function result";
1244 if (
auto graphOp = dyn_cast<spirv::GraphARMOp>(op))
1246 op->
getLoc(), graphOp.getResultTypes()[resultIndex], attribute);
1248 "cannot attach SPIR-V attributes to region result which is "
1249 "not part of a spirv::GraphARMOp type");
static bool isLegalToInline(InlinerInterface &interface, Region *src, Region *insertRegion, bool shouldCloneInlinedRegion, IRMapping &valueMapping)
Utility to check that all of the operations within 'src' can be inlined.
std::optional< unsigned > parseAndVerify< unsigned >(SPIRVDialect const &dialect, DialectAsmParser &parser)
static std::optional< IntTy > parseAndVerifyInteger(SPIRVDialect const &dialect, DialectAsmParser &parser)
static LogicalResult parseOptionalArrayStride(const SPIRVDialect &dialect, DialectAsmParser &parser, unsigned &stride)
Parses an optional , stride = N assembly segment.
static LogicalResult verifyRegionAttribute(Location loc, Type valueType, NamedAttribute attribute)
Verifies the given SPIR-V attribute attached to a value of the given valueType is valid.
static Type parseTensorArmType(SPIRVDialect const &dialect, DialectAsmParser &parser)
static void print(ArrayType type, DialectAsmPrinter &os)
static LogicalResult verifyFunctionParameterAttributes(Location loc, Type type, Attribute attr, std::optional< unsigned > index=std::nullopt)
Verifies FuncParamAttr decorations.
static Type parseSampledImageType(SPIRVDialect const &dialect, DialectAsmParser &parser)
static ParseResult parseStructMemberDecorations(SPIRVDialect const &dialect, DialectAsmParser &parser, ArrayRef< Type > memberTypes, SmallVectorImpl< StructType::OffsetInfo > &offsetInfo, SmallVectorImpl< StructType::MemberDecorationInfo > &memberDecorationInfo)
static Type parseAndVerifyType(SPIRVDialect const &dialect, DialectAsmParser &parser, bool allowFunctionType=false)
static Type parseAndVerifySampledImageType(SPIRVDialect const &dialect, DialectAsmParser &parser)
static Type parseUntypedPointerType(SPIRVDialect const &dialect, DialectAsmParser &parser)
static Type parseCooperativeMatrixType(SPIRVDialect const &dialect, DialectAsmParser &parser)
std::optional< Type > parseAndVerify< Type >(SPIRVDialect const &dialect, DialectAsmParser &parser)
static Type parseAndVerifyMatrixType(SPIRVDialect const &dialect, DialectAsmParser &parser)
static Type parseArrayType(SPIRVDialect const &dialect, DialectAsmParser &parser)
static bool containsReturn(Region ®ion)
Returns true if the given region contains spirv.Return or spirv.ReturnValue ops.
static Type parseStructType(SPIRVDialect const &dialect, DialectAsmParser &parser)
static Type parseRuntimeArrayType(SPIRVDialect const &dialect, DialectAsmParser &parser)
static Type parseMatrixType(SPIRVDialect const &dialect, DialectAsmParser &parser)
static Type parseImageType(SPIRVDialect const &dialect, DialectAsmParser &parser)
static std::optional< ValTy > parseAndVerify(SPIRVDialect const &dialect, DialectAsmParser &parser)
static Type parsePointerType(SPIRVDialect const &dialect, DialectAsmParser &parser)
virtual OptionalParseResult parseOptionalInteger(APInt &result)=0
Parse an optional integer value from the stream.
virtual ParseResult parseCommaSeparatedList(Delimiter delimiter, function_ref< ParseResult()> parseElementFn, StringRef contextMessage=StringRef())=0
Parse a list of comma-separated items with an optional delimiter.
virtual ParseResult parseOptionalEqual()=0
Parse a = token if present.
virtual ParseResult parseOptionalKeyword(StringRef keyword)=0
Parse the given keyword if present.
virtual ParseResult parseRParen()=0
Parse a ) token.
virtual InFlightDiagnostic emitError(SMLoc loc, const Twine &message={})=0
Emit a diagnostic at the specified location and return failure.
virtual ParseResult parseRSquare()=0
Parse a ] token.
ParseResult parseInteger(IntT &result)
Parse an integer value from the stream.
virtual ParseResult parseOptionalRParen()=0
Parse a ) token if present.
virtual ParseResult parseLess()=0
Parse a '<' token.
virtual ParseResult parseDimensionList(SmallVectorImpl< int64_t > &dimensions, bool allowDynamic=true, bool withTrailingX=true)=0
Parse a dimension list of a tensor or memref type.
virtual ParseResult parseOptionalGreater()=0
Parse a '>' token if present.
virtual ParseResult parseEqual()=0
Parse a = token.
virtual SMLoc getCurrentLocation()=0
Get the location of the next token and store it into the argument.
virtual ParseResult parseOptionalComma()=0
Parse a , token if present.
virtual SMLoc getNameLoc() const =0
Return the location of the original name token.
virtual ParseResult parseOptionalStar()=0
Parse a '*' token if present.
FailureOr< CyclicParseReset > tryStartCyclicParse(AttrOrTypeT attrOrType)
Attempts to start a cyclic parsing region for attrOrType.
virtual ParseResult parseOptionalRSquare()=0
Parse a ] token if present.
virtual ParseResult parseGreater()=0
Parse a '>' token.
virtual ParseResult parseLParen()=0
Parse a ( token.
virtual ParseResult parseType(Type &result)=0
Parse a type.
virtual ParseResult parseComma()=0
Parse a , token.
ParseResult parseKeyword(StringRef keyword)
Parse a given keyword.
virtual ParseResult parseOptionalLSquare()=0
Parse a [ token if present.
virtual ParseResult parseAttribute(Attribute &result, Type type={})=0
Parse an arbitrary attribute of a given type and return it in result.
virtual ParseResult parseXInDimensionList()=0
Parse an 'x' token in a dimension list, handling the case where the x is juxtaposed with an element t...
virtual void printAttributeWithoutType(Attribute attr)
Print the given attribute without its type.
FailureOr< CyclicPrintReset > tryStartCyclicPrint(AttrOrTypeT attrOrType)
Attempts to start a cyclic printing region for attrOrType.
Attributes are known-constant values of operations.
Block represents an ordered list of Operations.
Operation * getTerminator()
Get the terminator operation of this block.
The DialectAsmParser has methods for interacting with the asm parser when parsing attributes and type...
This is a pure-virtual base class that exposes the asmprinter hooks necessary to implement a custom p...
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
NamedAttribute represents a combination of a name and an Attribute value.
StringAttr getName() const
Return the name of the attribute.
Attribute getValue() const
Return the value of the attribute.
This class helps build Operations.
Operation is the basic unit of execution within MLIR.
Location getLoc()
The source location the operation was defined or derived from.
InFlightDiagnostic emitError(const Twine &message={})
Emit an error about fatal conditions with this operation, reporting up to any diagnostic handlers tha...
This class implements Optional functionality for ParseResult.
bool has_value() const
Returns true if we contain a valid ParseResult value.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Dialect & getDialect() const
Get the dialect this type is registered to.
bool isIntOrIndexOrFloat() const
Return true if this is an integer (of any signedness), index, or float type.
Type getElementType() const
unsigned getArrayStride() const
Returns the array stride in bytes.
unsigned getNumElements() const
static ArrayType get(Type elementType, unsigned elementCount)
Scope getScope() const
Returns the scope of the matrix.
uint32_t getRows() const
Returns the number of rows of the matrix.
uint32_t getColumns() const
Returns the number of columns of the matrix.
static CooperativeMatrixType getChecked(function_ref< InFlightDiagnostic()> emitError, MLIRContext *context, Type elementType, uint32_t rows, uint32_t columns, Scope scope, CooperativeMatrixUseKHR use)
Type getElementType() const
CooperativeMatrixUseKHR getUse() const
Returns the use parameter of the cooperative matrix.
ImageDepthInfo getDepthInfo() const
ImageArrayedInfo getArrayedInfo() const
ImageFormat getImageFormat() const
ImageSamplerUseInfo getSamplerUseInfo() const
static ImageType getChecked(function_ref< InFlightDiagnostic()> emitError, MLIRContext *context, std::tuple< Type, Dim, ImageDepthInfo, ImageArrayedInfo, ImageSamplingInfo, ImageSamplerUseInfo, ImageFormat > value)
Type getElementType() const
ImageSamplingInfo getSamplingInfo() const
static MatrixType getChecked(function_ref< InFlightDiagnostic()> emitError, Type columnType, uint32_t columnCount)
Type getColumnType() const
unsigned getNumColumns() const
Returns the number of columns.
static NamedBarrierType get(MLIRContext *context)
Type getPointeeType() const
StorageClass getStorageClass() const
static PointerType getChecked(function_ref< InFlightDiagnostic()> emitError, MLIRContext *context, Type pointeeType, StorageClass storageClass)
Type getElementType() const
unsigned getArrayStride() const
Returns the array stride in bytes.
static RuntimeArrayType get(Type elementType)
Type getImageType() const
static SampledImageType get(Type imageType)
static SamplerType get(MLIRContext *context)
static bool isValid(FloatType)
Returns true if the given float type is valid for the SPIR-V dialect.
void getStructDecorations(SmallVectorImpl< StructType::StructDecorationInfo > &structDecorations) const
void getMemberDecorations(SmallVectorImpl< StructType::MemberDecorationInfo > &memberDecorations) const
static StructType getIdentified(MLIRContext *context, StringRef identifier)
Construct an identified StructType.
bool isIdentified() const
Returns true if the StructType is identified.
StringRef getIdentifier() const
For literal structs, return an empty string.
static StructType getEmpty(MLIRContext *context, StringRef identifier="")
Construct a (possibly identified) StructType with no members.
unsigned getNumElements() const
Type getElementType(unsigned) const
LogicalResult trySetBody(ArrayRef< Type > memberTypes, ArrayRef< OffsetInfo > offsetInfo={}, ArrayRef< MemberDecorationInfo > memberDecorations={}, ArrayRef< StructDecorationInfo > structDecorations={})
Sets the contents of an incomplete identified StructType.
static StructType get(ArrayRef< Type > memberTypes, ArrayRef< OffsetInfo > offsetInfo={}, ArrayRef< MemberDecorationInfo > memberDecorations={}, ArrayRef< StructDecorationInfo > structDecorations={})
Construct a literal StructType with at least one member.
uint64_t getMemberOffset(unsigned) const
Type getElementType() const
static TensorArmType get(ArrayRef< int64_t > shape, Type elementType)
ArrayRef< int64_t > getShape() const
StorageClass getStorageClass() const
static UntypedPointerType get(MLIRContext *context, StorageClass storageClass)
StringRef getInterfaceVarABIAttrName()
Returns the attribute name for specifying argument ABI information.
StringRef getLoopControlAttrName()
Returns the attribute name for specifying loop control.
ParseResult parseEnumKeywordAttr(EnumClass &value, ParserType &parser, StringRef attrName=spirv::attributeName< EnumClass >())
Parses the next keyword in parser as an enumerant of the given EnumClass.
StringRef getTargetEnvAttrName()
Returns the attribute name for specifying SPIR-V target environment.
StringRef getFuncParamAttrName()
Returns the attribute name for specifying function parameter and result attributes.
StringRef getFuncParamAlignmentAttrName()
Returns the attribute name for specifying function parameter alignment.
std::string getDecorationString(Decoration decoration)
Converts a SPIR-V Decoration enum value to its snake_case string representation for use in MLIR attri...
StringRef getSelectionControlAttrName()
Returns the attribute name for specifying selection control.
StringRef getEntryPointABIAttrName()
Returns the attribute name for specifying entry point information.
Include the generated interface declarations.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
llvm::TypeSwitch< T, ResultT > TypeSwitch