32 Type &produceTokenType) {
51 if (failed(parser.
parseType(produceTokenType)))
62 Type produceTokenType) {
63 if (consumeTokens.empty() && !produceTokenType)
67 if (consumeTokens.empty())
71 if (produceTokenType) {
96 typeAttr = TypeAttr::get(type);
117 StringAttr &symVisibilityAttr) {
118 StringRef symVisibility;
120 {
"public",
"private",
"nested"});
121 if (symVisibility.empty())
123 <<
"expected 'public', 'private', or 'nested'";
124 if (!symVisibility.empty())
130 StringAttr symVisibilityAttr) {
131 if (!symVisibilityAttr)
134 p << symVisibilityAttr.getValue();
141#define GET_OP_CLASSES
142#include "mlir/Dialect/MLProgram/IR/MLProgramOps.cpp.inc"
156 getFunctionTypeAttrName(
result.name), buildFuncType,
157 getArgAttrsAttrName(
result.name), getResAttrsAttrName(
result.name));
162 p, *
this,
false, getFunctionTypeAttrName(),
163 getArgAttrsAttrName(), getResAttrsAttrName());
170LogicalResult GlobalOp::verify() {
171 if (!getIsMutable() && !getValue())
172 return emitOpError() <<
"immutable global must have an initial value";
181 for (
auto *parent = getOperation()->getParentOp(); parent;
182 parent = parent->getParentOp()) {
184 parent, getGlobalAttr())) {
193 GlobalOp referrent = getGlobalOp(symbolTable);
195 return emitOpError() <<
"undefined global: " << getGlobal();
197 if (referrent.getType() != getResult().
getType()) {
198 return emitOpError() <<
"cannot load from global typed "
199 << referrent.getType() <<
" as "
200 << getResult().getType();
212 getOperation()->getParentOp(), getGlobalAttr());
217 GlobalOp referrent = getGlobalOp(symbolTable);
219 return emitOpError() <<
"undefined global: " << getGlobal();
221 if (referrent.getIsMutable())
222 return emitOpError() <<
"cannot load as const from mutable global "
225 if (referrent.getType() != getResult().
getType())
226 return emitOpError() <<
"cannot load from global typed "
227 << referrent.getType() <<
" as "
228 << getResult().getType();
239 getOperation()->getParentOp(), getGlobalAttr());
244 GlobalOp referrent = getGlobalOp(symbolTable);
246 return emitOpError() <<
"undefined global: " << getGlobal();
248 if (referrent.getType() != getResult().
getType()) {
249 return emitOpError() <<
"cannot load from global typed "
250 << referrent.getType() <<
" as "
251 << getResult().getType();
262 for (
auto *parent = getOperation()->getParentOp(); parent;) {
264 parent, getGlobalAttr())) {
267 parent = parent->getParentOp();
274 GlobalOp referrent = getGlobalOp(symbolTable);
276 return emitOpError() <<
"undefined global: " << getGlobal();
278 if (!referrent.getIsMutable()) {
279 return emitOpError() <<
"cannot store to an immutable global "
283 if (referrent.getType() != getValue().
getType()) {
284 return emitOpError() <<
"cannot store to a global typed "
285 << referrent.getType() <<
" from "
286 << getValue().getType();
298 getOperation()->getParentOp(), getGlobalAttr());
303 GlobalOp referrent = getGlobalOp(symbolTable);
305 return emitOpError() <<
"undefined global: " << getGlobal();
307 if (!referrent.getIsMutable()) {
308 return emitOpError() <<
"cannot store to an immutable global "
312 if (referrent.getType() != getValue().
getType()) {
313 return emitOpError() <<
"cannot store to a global typed "
314 << referrent.getType() <<
" from "
315 << getValue().getType();
333 getFunctionTypeAttrName(
result.name), buildFuncType,
334 getArgAttrsAttrName(
result.name), getResAttrsAttrName(
result.name));
339 p, *
this,
false, getFunctionTypeAttrName(),
340 getArgAttrsAttrName(), getResAttrsAttrName());
347LogicalResult OutputOp::verify() {
348 auto function = cast<SubgraphOp>((*this)->getParentOp());
351 const auto &results = function.getFunctionType().getResults();
352 if (getNumOperands() != results.size())
354 << getNumOperands() <<
" operands, but enclosing function (@"
355 << function.getName() <<
") outputs " << results.size();
357 for (
unsigned i = 0, e = results.size(); i != e; ++i)
358 if (getOperand(i).
getType() != results[i])
359 return emitError() <<
"type of output operand " << i <<
" ("
360 << getOperand(i).getType()
361 <<
") doesn't match function result type ("
363 <<
" in function @" << function.getName();
372LogicalResult ReturnOp::verify() {
373 auto function = cast<FuncOp>((*this)->getParentOp());
376 const auto &results = function.getFunctionType().getResults();
377 if (getNumOperands() != results.size())
379 << getNumOperands() <<
" operands, but enclosing function (@"
380 << function.getName() <<
") returns " << results.size();
382 for (
unsigned i = 0, e = results.size(); i != e; ++i)
383 if (getOperand(i).
getType() != results[i])
384 return emitError() <<
"type of return operand " << i <<
" ("
385 << getOperand(i).getType()
386 <<
") doesn't match function result type ("
388 <<
" in function @" << function.getName();
p<< " : "<< getMemRefType()<< ", "<< getType();}static LogicalResult verifyVectorMemoryOp(Operation *op, MemRefType memrefType, VectorType vectorType) { if(memrefType.getElementType() !=vectorType.getElementType()) return op-> emitOpError("requires memref and vector types of the same elemental type")
Given a list of lists of parsed operands, populates uniqueOperands with unique operands.
static void printTypedInitialValue(OpAsmPrinter &p, Operation *op, TypeAttr type, Attribute attr)
static void printTokenOrdering(OpAsmPrinter &p, Operation *op, OperandRange consumeTokens, Type produceTokenType)
static void printSymbolVisibility(OpAsmPrinter &p, Operation *op, StringAttr symVisibilityAttr)
static ParseResult parseTypedInitialValue(OpAsmParser &parser, TypeAttr &typeAttr, Attribute &attr)
some.op custom<TypeOrAttr>($type, $attr)
static ParseResult parseTokenOrdering(OpAsmParser &parser, SmallVectorImpl< OpAsmParser::UnresolvedOperand > &consumeTokens, Type &produceTokenType)
Parse and print an ordering clause for a variadic of consuming tokens and an producing token.
static ParseResult parseSymbolVisibility(OpAsmParser &parser, StringAttr &symVisibilityAttr)
some.op custom<SymbolVisibility>($sym_visibility) $sym_name -> some.op public @foo some....
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.
virtual InFlightDiagnostic emitError(SMLoc loc, const Twine &message={})=0
Emit a diagnostic at the specified location and return failure.
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 ParseResult parseArrow()=0
Parse a '->' token.
virtual ParseResult parseLParen()=0
Parse a ( token.
virtual ParseResult parseType(Type &result)=0
Parse a type.
virtual ParseResult parseOptionalLParen()=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 void printType(Type type)
virtual void printAttribute(Attribute attr)
Attributes are known-constant values of operations.
This class is a general helper class for creating context-global objects like types,...
FunctionType getFunctionType(TypeRange inputs, TypeRange results)
StringAttr getStringAttr(const Twine &bytes)
The OpAsmParser has methods for interacting with the asm parser: parsing things from it,...
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...
void printOperands(const ContainerType &container)
Print a comma separated list of operands.
This class implements the operand iterators for the Operation class.
Operation is the basic unit of execution within MLIR.
This class represents a collection of SymbolTables.
virtual Operation * lookupNearestSymbolFrom(Operation *from, StringAttr symbol)
Returns the operation registered with the given symbol name within the closest parent operation of,...
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
A named class for passing around the variadic flag.
void printFunctionOp(OpAsmPrinter &p, FunctionOpInterface op, bool isVariadic, StringRef typeAttrName, StringAttr argAttrsName, StringAttr resAttrsName)
Printer implementation for function-like operations.
ParseResult parseFunctionOp(OpAsmParser &parser, OperationState &result, bool allowVariadic, StringAttr typeAttrName, FuncTypeBuilder funcTypeBuilder, StringAttr argAttrsName, StringAttr resAttrsName)
Parser implementation for function-like operations.
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.
This represents an operation in an abstracted form, suitable for use with the builder APIs.