25 spirv::Scope executionScope;
26 GroupOperation groupOperation;
28 if (spirv::parseEnumStrAttr<spirv::ScopeAttr>(executionScope, parser, state,
30 spirv::parseEnumStrAttr<GroupOperationAttr>(groupOperation, parser, state,
35 std::optional<OpAsmParser::UnresolvedOperand> clusterSizeInfo;
50 if (clusterSizeInfo) {
52 if (parser.
resolveOperand(*clusterSizeInfo, i32Type, state.operands))
67 << stringifyGroupOperation(
81 if (scope != spirv::Scope::Workgroup && scope != spirv::Scope::Subgroup)
83 "execution scope must be 'Workgroup' or 'Subgroup'");
85 GroupOperation operation =
88 if (operation == GroupOperation::ClusteredReduce &&
90 return groupOp->
emitOpError(
"cluster size operand must be provided for "
91 "'ClusteredReduce' group operation");
94 int32_t clusterSize = 0;
99 "cluster size operand must come from a constant op");
101 if (!llvm::isPowerOf2_32(clusterSize))
103 "cluster size operand must be a power of two");
113 spirv::Scope scope = getExecutionScope();
114 if (scope != spirv::Scope::Workgroup && scope != spirv::Scope::Subgroup)
115 return emitOpError(
"execution scope must be 'Workgroup' or 'Subgroup'");
117 if (
auto localIdTy = llvm::dyn_cast<VectorType>(getLocalid().getType()))
118 if (localIdTy.getNumElements() != 2 && localIdTy.getNumElements() != 3)
119 return emitOpError(
"localid is a vector and can be with only "
120 " 2 or 3 components, actual number is ")
121 << localIdTy.getNumElements();
131 spirv::Scope scope = getExecutionScope();
132 if (scope != spirv::Scope::Workgroup && scope != spirv::Scope::Subgroup)
133 return emitOpError(
"execution scope must be 'Workgroup' or 'Subgroup'");
143 spirv::Scope scope = getExecutionScope();
144 if (scope != spirv::Scope::Workgroup && scope != spirv::Scope::Subgroup)
145 return emitOpError(
"execution scope must be 'Workgroup' or 'Subgroup'");
150 if (
auto spirvModule = (*this)->getParentOfType<spirv::ModuleOp>())
153 if (targetEnv.getVersion() < spirv::Version::V_1_5) {
154 auto *idOp = getId().getDefiningOp();
155 if (!idOp || !isa<spirv::ConstantOp,
156 spirv::ReferenceOfOp>(idOp))
157 return emitOpError(
"id must be the result of a constant op");
167 template <
typename OpTy>
169 spirv::Scope scope = op.getExecutionScope();
170 if (scope != spirv::Scope::Workgroup && scope != spirv::Scope::Subgroup)
171 return op.emitOpError(
"execution scope must be 'Workgroup' or 'Subgroup'");
173 if (op.getOperands().back().getType().isSignedInteger())
174 return op.emitOpError(
"second operand must be a singless/unsigned integer");
197 spirv::Scope scope = getExecutionScope();
198 if (scope != spirv::Scope::Workgroup && scope != spirv::Scope::Subgroup)
199 return emitOpError(
"execution scope must be 'Workgroup' or 'Subgroup'");
213 OperationState &result) {
230 OperationState &result) {
247 OperationState &result) {
264 OperationState &result) {
281 OperationState &result) {
298 OperationState &result) {
315 OperationState &result) {
332 OperationState &result) {
349 OperationState &result) {
366 OperationState &result) {
383 OperationState &result) {
400 OperationState &result) {
417 OperationState &result) {
434 OperationState &result) {
451 OperationState &result) {
468 OperationState &result) {
480 template <
typename Op>
482 spirv::Scope scope = op.getExecutionScope();
483 if (scope != spirv::Scope::Workgroup && scope != spirv::Scope::Subgroup)
484 return op.emitOpError(
"execution scope must be 'Workgroup' or 'Subgroup'");
static MLIRContext * getContext(OpFoldResult val)
static void print(spirv::VerCapExtAttr triple, DialectAsmPrinter &printer)
virtual Builder & getBuilder() const =0
Return a builder which provides useful access to MLIRContext, global objects like types and attribute...
virtual ParseResult parseOptionalKeyword(StringRef keyword)=0
Parse the given keyword if present.
virtual ParseResult parseRParen()=0
Parse a ) token.
ParseResult addTypeToList(Type type, SmallVectorImpl< Type > &result)
Add the specified type to the end of the specified type list and return success.
virtual ParseResult parseColonType(Type &result)=0
Parse a colon followed by a type.
virtual ParseResult parseLParen()=0
Parse a ( token.
IntegerType getIntegerType(unsigned width)
The OpAsmParser has methods for interacting with the asm parser: parsing things from it,...
virtual ParseResult resolveOperand(const UnresolvedOperand &operand, Type type, SmallVectorImpl< Value > &result)=0
Resolve an operand to an SSA value, emitting an error on failure.
virtual ParseResult parseOperand(UnresolvedOperand &result, bool allowResultNumber=true)=0
Parse a single SSA value operand name along with a result number if allowResultNumber is true.
This is a pure-virtual base class that exposes the asmprinter hooks necessary to implement a custom p...
This provides public APIs that all operations should have.
Operation is the basic unit of execution within MLIR.
Value getOperand(unsigned idx)
AttrClass getAttrOfType(StringAttr name)
OpResult getResult(unsigned idx)
Get the 'idx'th result of this operation.
unsigned getNumOperands()
InFlightDiagnostic emitOpError(const Twine &message={})
Emit an error with the op name prefixed, like "'dim' op " which is convenient for verifiers.
This class represents success/failure for parsing-like operations that find it important to chain tog...
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Type getType() const
Return the type of this value.
Operation * getDefiningOp() const
If this value is the result of an operation, return the operation that defines it.
QueryRef parse(llvm::StringRef line, const QuerySession &qs)
constexpr char kExecutionScopeAttrName[]
constexpr char kGroupOperationAttrName[]
constexpr char kClusterSize[]
static void printGroupNonUniformArithmeticOp(Operation *groupOp, OpAsmPrinter &printer)
static ParseResult parseGroupNonUniformArithmeticOp(OpAsmParser &parser, OperationState &state)
static LogicalResult verifyGroupNonUniformArithmeticOp(Operation *groupOp)
TargetEnvAttr lookupTargetEnvOrDefault(Operation *op)
Queries the target environment recursively from enclosing symbol table ops containing the given op or...
static LogicalResult verifyGroupNonUniformShuffleOp(OpTy op)
static LogicalResult verifyGroupOp(Op op)
LogicalResult extractValueFromConstOp(Operation *op, int32_t &value)
TargetEnvAttr getDefaultTargetEnv(MLIRContext *context)
Returns the default target environment: SPIR-V 1.0 with Shader capability and no extra extensions.
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
bool succeeded(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a success value.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
LogicalResult verify(Operation *op, bool verifyRecursively=true)
Perform (potentially expensive) checks of invariants, used to detect compiler bugs,...
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value.
This class represents an efficient way to signal success or failure.
This is the representation of an operand reference.
This represents an operation in an abstracted form, suitable for use with the builder APIs.