48LogicalResult checkForNameConflict(SymbolTableCollection &tables, SymbolOpInterface op) {
53 return op.emitOpError()
54 .append(
"name conflicts with an existing symbol")
55 .attachNote(res->get()->getLoc())
56 .append(
"symbol already defined here");
64 return checkForNameConflict(tables, *
this);
72 if (failed(checkForNameConflict(tables, *
this))) {
78 Operation *thisOp = this->getOperation();
80 assert(parentTemplate &&
"per ODS");
81 LogicalResult errorState = success();
82 auto checkUses = [
this, &parentTemplate, &errorState](Operation *symTableOp, bool) {
84 for (SymbolTable::SymbolUse
use : uses.value()) {
86 auto usedSym = llvm::dyn_cast<FlatSymbolRefAttr>(
use.getSymbolRef());
88 InFlightDiagnostic diag = this->emitOpError().append(
89 "initialization cannot use a symbol defined by another `",
92 diag.attachNote(
use.getUser()->getLoc()).append(
"symbol ", usedSym,
" used here");
94 diag.attachNote(def.getLoc()).append(
"defined here");
101 checkUses(thisOp,
true);
102 if (succeeded(errorState)) {
103 SymbolTable::walkSymbolTables(thisOp,
true, checkUses);
110 if (!region.hasOneBlock()) {
111 return emitOpError(
"expected initializer region with a single block");
113 Block &block = region.back();
114 if (!llvm::isa<YieldOp>(block.getTerminator())) {
115 return emitOpError(
"expected initializer region to end with a '")
119 Operation *illegalOp =
nullptr;
120 auto walkRes = block.walk([&illegalOp](Operation *p) {
123 if (llvm::isa<global::GlobalRefOpInterface, function::CallOp>(p)) {
125 return WalkResult::interrupt();
127 return WalkResult::advance();
129 if (walkRes.wasInterrupted()) {
131 return illegalOp->emitOpError().append(
140 assert(region.hasOneBlock() &&
"per `verifyRegions()`");
141 YieldOp yieldOp = llvm::dyn_cast<YieldOp>(region.back().getTerminator());
142 assert(yieldOp &&
"per `verifyRegions()`");
143 return yieldOp.
getVal().getType();
154 if (failed(getParentRes)) {
161 return this->emitOpError()
162 .append(
"references unknown symbol \"", name,
'"')
163 .attachNote(getParentRes->getLoc())
164 .append(
"must reference a param or expr of this template");
167 if (std::optional<Type> paramType = constParam.getTypeOpt()) {
168 if (this->getType() != *paramType) {
169 return this->emitOpError().append(
170 "type ", this->getType(),
" does not match constant param type ", *paramType
188 if (map.getNumResults() != 1) {
189 return emitOpError(
"must produce exactly one value");
193 unsigned mapDims = map.getNumDims();
194 if (getNumOperands() != mapDims + map.getNumSymbols()) {
195 return emitOpError(
"operand count must equal affine map dimension+symbol count");
197 return emitOpError(
"dimension operand count must equal affine map dimension count");
209 return emitOpError() <<
"input type " <<
getInput().getType() <<
" and output type "
210 <<
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()
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...
OpClass getParentOfType(mlir::Operation *op)
Return the closest surrounding parent 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)