50LogicalResult checkForNameConflict(SymbolTableCollection &tables, SymbolOpInterface op) {
55 return op.emitOpError()
56 .append(
"name conflicts with an existing symbol")
57 .attachNote(res->get()->getLoc())
58 .append(
"symbol already defined here");
66 return checkForNameConflict(tables, *
this);
74 if (failed(checkForNameConflict(tables, *
this))) {
80 Operation *thisOp = this->getOperation();
82 assert(parentTemplate &&
"per ODS");
83 LogicalResult errorState = success();
84 auto checkUses = [
this, &parentTemplate, &errorState](Operation *symTableOp, bool) {
86 for (SymbolTable::SymbolUse
use : uses.value()) {
88 auto usedSym = llvm::dyn_cast<FlatSymbolRefAttr>(
use.getSymbolRef());
90 InFlightDiagnostic diag = this->emitOpError().append(
91 "initialization cannot use a symbol defined by another `",
94 diag.attachNote(
use.getUser()->getLoc()).append(
"symbol ", usedSym,
" used here");
96 diag.attachNote(def.getLoc()).append(
"defined here");
103 checkUses(thisOp,
true);
104 if (succeeded(errorState)) {
105 SymbolTable::walkSymbolTables(thisOp,
true, checkUses);
112 if (!region.hasOneBlock()) {
113 return emitOpError(
"expected initializer region with a single block");
115 Block &block = region.back();
116 if (!llvm::isa<YieldOp>(block.getTerminator())) {
117 return emitOpError(
"expected initializer region to end with a '")
121 Operation *illegalOp =
nullptr;
122 auto walkRes = block.walk([&illegalOp](Operation *p) {
125 if (llvm::isa<global::GlobalRefOpInterface, function::CallOp>(p)) {
127 return WalkResult::interrupt();
129 return WalkResult::advance();
131 if (walkRes.wasInterrupted()) {
133 return illegalOp->emitOpError().append(
142 assert(region.hasOneBlock() &&
"per `verifyRegions()`");
143 YieldOp yieldOp = llvm::dyn_cast<YieldOp>(region.back().getTerminator());
144 assert(yieldOp &&
"per `verifyRegions()`");
145 return yieldOp.
getVal().getType();
156 if (failed(getParentRes)) {
159 if (!*getParentRes) {
162 <<
"' that targets an operation with a '"
169 return this->emitOpError()
170 .append(
"references unknown symbol \"", name,
'"')
171 .attachNote(getParentRes->getLoc())
172 .append(
"must reference a param or expr of this template");
175 if (std::optional<Type> paramType = constParam.getTypeOpt()) {
176 if (this->getType() != *paramType) {
177 return this->emitOpError().append(
178 "type ", this->getType(),
" does not match constant param type ", *paramType
196 if (map.getNumResults() != 1) {
197 return emitOpError(
"must produce exactly one value");
201 unsigned mapDims = map.getNumDims();
202 if (getNumOperands() != mapDims + map.getNumSymbols()) {
203 return emitOpError(
"operand count must equal affine map dimension+symbol count");
205 return emitOpError(
"dimension operand count must equal affine map dimension count");
217 return emitOpError() <<
"input type " <<
getInput().getType() <<
" and output type "
218 <<
getResult().getType() <<
" are not unifiable";
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
::mlir::IntegerAttr getNumDimsAttr()
::llvm::LogicalResult verify()
::mlir::AffineMap getMap()
::mlir::FlatSymbolRefAttr getConstNameAttr()
::llvm::LogicalResult verifySymbolUses(::mlir::SymbolTableCollection &symbolTable)
::llvm::LogicalResult verifyRegions()
::mlir::Region & getInitializerRegion()
::llvm::LogicalResult verifySymbolUses(::mlir::SymbolTableCollection &symbolTable)
::mlir::Type getType()
Returns the type of the poly.yield op in the initializer region.
::std::optional<::mlir::Type > getTypeOpt()
static constexpr ::llvm::StringLiteral getOperationName()
OpT getConstNamed(::mlir::StringRef find)
Return the op of type OpT with the given name within the body region if it exists,...
bool hasConstNamed(::mlir::StringRef find)
Return true if there is an op of type OpT with the given name within the body region.
static constexpr ::llvm::StringLiteral getOperationName()
::llvm::LogicalResult verifySymbolUses(::mlir::SymbolTableCollection &symbolTable)
::llvm::LogicalResult verify()
::mlir::TypedValue<::mlir::Type > getInput()
::mlir::TypedValue<::mlir::Type > getResult()
static constexpr ::llvm::StringLiteral getOperationName()
::mlir::TypedValue<::mlir::Type > getVal()
static constexpr ::llvm::StringLiteral getOperationName()
bool isInTemplate(Operation *op)
FailureOr< TemplateOp > verifyInTemplate(Operation *op)
mlir::FailureOr< SymbolLookupResultUntyped > lookupTopLevelSymbol(mlir::SymbolTableCollection &tables, mlir::SymbolRefAttr symbol, mlir::Operation *origin, bool reportMissing=true)
std::optional< mlir::SymbolTable::UseRange > getSymbolUses(mlir::Operation *from)
Get an iterator range for all of the uses, for any symbol, that are nested within the given operation...
FailureOr< TemplateOp > getConstResolutionTemplate(SymbolTableCollection &tables, Operation *origin)
OpClass getParentOfType(mlir::Operation *op)
Return the closest surrounding parent/ancestor operation that is of type 'OpClass'.
LogicalResult verifyTypeResolution(SymbolTableCollection &tables, Operation *origin, Type ty)
bool typesUnify(Type lhs, Type rhs, ArrayRef< StringRef > rhsReversePrefix, UnificationMap *unifications)