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"
44 if (
auto loc = llvm::dyn_cast<LocationAttr>(attr))
62 assert(!frames.empty() &&
"required at least 1 call frame");
64 for (
auto frame : llvm::reverse(frames.drop_back()))
76 llvm::SmallSetVector<Location, 4> decomposedLocs;
77 for (
auto loc : locs) {
80 if (
auto fusedLoc = llvm::dyn_cast<FusedLoc>(loc)) {
81 if (fusedLoc.getMetadata() == metadata) {
84 decomposedLocs.insert(fusedLoc.getLocations().begin(),
85 fusedLoc.getLocations().end());
90 if (!llvm::isa<UnknownLoc>(loc))
91 decomposedLocs.insert(loc);
93 locs = decomposedLocs.getArrayRef();
105 if (locs.size() == 1 && !metadata)
108 return Base::get(context, locs, metadata);
void addWalk(WalkFn< Attribute > &&fn)
Register a walk function for a given attribute or type.
WalkResult walk(T element)
Walk the given attribute/type, and recursively walk any sub elements.
Attributes are known-constant values of operations.
bool hasTrait()
Returns true if the type was registered with a particular trait.
WalkResult walk(function_ref< WalkResult(Location)> walkFn)
Walk all of the locations nested directly 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:
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...
This trait is used to determine if an attribute is a location or not.