12 #include "llvm/ADT/SetVector.h"
13 #include "llvm/ADT/TypeSwitch.h"
22 #define GET_ATTRDEF_CLASSES
23 #include "mlir/IR/BuiltinLocationAttributes.cpp.inc"
29 void BuiltinDialect::registerLocationAttributes() {
31 #define GET_ATTRDEF_LIST
32 #include "mlir/IR/BuiltinLocationAttributes.cpp.inc"
41 if (walkFn(*this).wasInterrupted())
46 if (callLoc.getCallee()->walk(walkFn).wasInterrupted())
48 return callLoc.getCaller()->walk(walkFn);
51 for (
Location subLoc : fusedLoc.getLocations())
52 if (subLoc->walk(walkFn).wasInterrupted())
57 return nameLoc.getChildLoc()->
walk(walkFn);
60 return opaqueLoc.getFallbackLocation()->
walk(walkFn);
67 return llvm::isa<CallSiteLoc, FileLineColLoc,
FusedLoc, NameLoc, OpaqueLoc,
76 assert(!frames.empty() &&
"required at least 1 call frame");
78 for (
auto frame : llvm::reverse(frames.drop_back()))
90 llvm::SmallSetVector<Location, 4> decomposedLocs;
91 for (
auto loc : locs) {
94 if (
auto fusedLoc = llvm::dyn_cast<FusedLoc>(loc)) {
95 if (fusedLoc.getMetadata() == metadata) {
98 decomposedLocs.insert(fusedLoc.getLocations().begin(),
99 fusedLoc.getLocations().end());
104 if (!llvm::isa<UnknownLoc>(loc))
105 decomposedLocs.insert(loc);
107 locs = decomposedLocs.getArrayRef();
119 if (locs.size() == 1 && !metadata)
122 return Base::get(context, locs, metadata);
Attributes are known-constant values of operations.
WalkResult walk(function_ref< WalkResult(Location)> walkFn)
Walk all of the locations nested under, and including, the current.
static bool classof(Attribute attr)
Methods for support type inquiry through isa, cast, and dyn_cast.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
MLIRContext is the top-level object for a collection of MLIR operations.
A utility result that is used to signal how to proceed with an ongoing walk:
static WalkResult advance()
static WalkResult interrupt()
Detect if any of the given parameter types has a sub-element handler.
void walk(Operation *op, function_ref< void(Region *)> callback, WalkOrder order)
Walk all of the regions, blocks, or operations nested under (and including) the given operation.
Include the generated interface declarations.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...