27 spirv::MemorySemantics memoryScope;
32 if (parseEnumStrAttr<spirv::ScopeAttr>(scope, parser, state,
34 parseEnumStrAttr<spirv::MemorySemanticsAttr>(memoryScope, parser, state,
40 auto ptrType = llvm::dyn_cast<spirv::PointerType>(type);
42 return parser.
emitError(loc,
"expected pointer type");
45 operandTypes.push_back(ptrType);
47 operandTypes.push_back(ptrType.getPointeeType());
51 return parser.
addTypeToList(ptrType.getPointeeType(), state.types);
58 printer << spirv::stringifyScope(scopeAttr.getValue()) <<
"\" \"";
59 auto memorySemanticsAttr =
61 printer << spirv::stringifyMemorySemantics(memorySemanticsAttr.getValue())
62 <<
"\" " << op->getOperands() <<
" : " << op->getOperand(0).getType();
79 template <
typename ExpectedElementType>
81 auto ptrType = llvm::cast<spirv::PointerType>(op->getOperand(0).getType());
82 auto elementType = ptrType.getPointeeType();
83 if (!llvm::isa<ExpectedElementType>(elementType))
84 return op->emitOpError() <<
"pointer operand must point to an "
85 << stringifyTypeName<ExpectedElementType>()
86 <<
" value, found " << elementType;
88 if (op->getNumOperands() > 1) {
89 auto valueType = op->getOperand(1).getType();
90 if (valueType != elementType)
91 return op->emitOpError(
"expected value to have the same type as the "
92 "pointer operand's pointee type ")
93 << elementType <<
", but found " << valueType;
95 auto memorySemantics =
104 template <
typename T>
106 printer <<
" \"" << stringifyScope(atomOp.getMemoryScope()) <<
"\" \""
107 << stringifyMemorySemantics(atomOp.getEqualSemantics()) <<
"\" \""
108 << stringifyMemorySemantics(atomOp.getUnequalSemantics()) <<
"\" "
109 << atomOp.getOperands() <<
" : " << atomOp.getPointer().getType();
114 spirv::Scope memoryScope;
115 spirv::MemorySemantics equalSemantics, unequalSemantics;
118 if (parseEnumStrAttr<spirv::ScopeAttr>(memoryScope, parser, state,
120 parseEnumStrAttr<spirv::MemorySemanticsAttr>(
122 parseEnumStrAttr<spirv::MemorySemanticsAttr>(
131 auto ptrType = llvm::dyn_cast<spirv::PointerType>(type);
133 return parser.
emitError(loc,
"expected pointer type");
137 {ptrType, ptrType.getPointeeType(), ptrType.getPointeeType()},
141 return parser.
addTypeToList(ptrType.getPointeeType(), state.types);
144 template <
typename T>
150 if (atomOp.getType() != atomOp.getValue().getType())
151 return atomOp.emitOpError(
"value operand must have the same type as the op "
152 "result, but found ")
153 << atomOp.getValue().getType() <<
" vs " << atomOp.getType();
155 if (atomOp.getType() != atomOp.getComparator().getType())
156 return atomOp.emitOpError(
157 "comparator operand must have the same type as the op "
158 "result, but found ")
159 << atomOp.getComparator().getType() <<
" vs " << atomOp.getType();
162 llvm::cast<spirv::PointerType>(atomOp.getPointer().getType())
164 if (atomOp.getType() != pointeeType)
165 return atomOp.emitOpError(
166 "pointer operand's pointee type must have the same "
167 "as the op result type, but found ")
168 << pointeeType <<
" vs " << atomOp.getType();
181 return verifyAtomicUpdateOp<IntegerType>(getOperation());
199 OperationState &result) {
216 OperationState &result) {
229 printer <<
" \"" << stringifyScope(getMemoryScope()) <<
"\" \""
230 << stringifyMemorySemantics(getSemantics()) <<
"\" " << getOperands()
231 <<
" : " << getPointer().getType();
235 OperationState &result) {
236 spirv::Scope memoryScope;
237 spirv::MemorySemantics semantics;
238 SmallVector<OpAsmParser::UnresolvedOperand, 2> operandInfo;
240 if (parseEnumStrAttr<spirv::ScopeAttr>(memoryScope, parser, result,
242 parseEnumStrAttr<spirv::MemorySemanticsAttr>(semantics, parser, result,
244 parser.parseOperandList(operandInfo, 2))
247 auto loc = parser.getCurrentLocation();
248 if (parser.parseColonType(type))
251 auto ptrType = llvm::dyn_cast<spirv::PointerType>(type);
253 return parser.emitError(loc,
"expected pointer type");
255 if (parser.resolveOperands(operandInfo, {ptrType, ptrType.getPointeeType()},
256 parser.getNameLoc(), result.operands))
259 return parser.addTypeToList(ptrType.getPointeeType(), result.types);
263 if (getType() != getValue().getType())
264 return emitOpError(
"value operand must have the same type as the op "
265 "result, but found ")
266 << getValue().getType() <<
" vs " << getType();
269 llvm::cast<spirv::PointerType>(getPointer().getType()).getPointeeType();
270 if (getType() != pointeeType)
271 return emitOpError(
"pointer operand's pointee type must have the same "
272 "as the op result type, but found ")
273 << pointeeType <<
" vs " << getType();
283 return verifyAtomicUpdateOp<IntegerType>(getOperation());
297 return verifyAtomicUpdateOp<FloatType>(getOperation());
301 OperationState &result) {
314 return verifyAtomicUpdateOp<IntegerType>(getOperation());
318 OperationState &result) {
331 return verifyAtomicUpdateOp<IntegerType>(getOperation());
335 OperationState &result) {
348 return verifyAtomicUpdateOp<IntegerType>(getOperation());
362 return verifyAtomicUpdateOp<IntegerType>(getOperation());
376 return verifyAtomicUpdateOp<IntegerType>(getOperation());
390 return verifyAtomicUpdateOp<IntegerType>(getOperation());
404 return verifyAtomicUpdateOp<IntegerType>(getOperation());
418 return verifyAtomicUpdateOp<IntegerType>(getOperation());
432 return verifyAtomicUpdateOp<IntegerType>(getOperation());
static void print(spirv::VerCapExtAttr triple, DialectAsmPrinter &printer)
virtual InFlightDiagnostic emitError(SMLoc loc, const Twine &message={})=0
Emit a diagnostic at the specified location and return failure.
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 SMLoc getCurrentLocation()=0
Get the location of the next token and store it into the argument.
virtual SMLoc getNameLoc() const =0
Return the location of the original name token.
The OpAsmParser has methods for interacting with the asm parser: parsing things from it,...
ParseResult resolveOperands(Operands &&operands, Type type, SmallVectorImpl< Value > &result)
Resolve a list of operands to SSA values, emitting an error on failure, or appending the results to t...
virtual ParseResult parseOperandList(SmallVectorImpl< UnresolvedOperand > &result, Delimiter delimiter=Delimiter::None, bool allowResultNumber=true, int requiredOperandCount=-1)=0
Parse zero or more SSA comma-separated operand references with a specified surrounding delimiter,...
This is a pure-virtual base class that exposes the asmprinter hooks necessary to implement a custom p...
Operation is the basic unit of execution within MLIR.
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
An inlay hint that for a type annotation.
QueryRef parse(llvm::StringRef line, const QuerySession &qs)
constexpr char kEqualSemanticsAttrName[]
constexpr char kMemoryScopeAttrName[]
constexpr char kSemanticsAttrName[]
constexpr char kUnequalSemanticsAttrName[]
static StringRef stringifyTypeName()
LogicalResult verifyMemorySemantics(Operation *op, spirv::MemorySemantics memorySemantics)
static LogicalResult verifyAtomicCompareExchangeImpl(T atomOp)
static LogicalResult verifyAtomicUpdateOp(Operation *op)
StringRef stringifyTypeName< FloatType >()
static ParseResult parseAtomicUpdateOp(OpAsmParser &parser, OperationState &state, bool hasValue)
StringRef stringifyTypeName< IntegerType >()
static void printAtomicCompareExchangeImpl(T atomOp, OpAsmPrinter &printer)
static ParseResult parseAtomicCompareExchangeImpl(OpAsmParser &parser, OperationState &state)
static void printAtomicUpdateOp(Operation *op, OpAsmPrinter &printer)
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
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.