14#ifndef MLIR_IR_LOCATION_H
15#define MLIR_IR_LOCATION_H
18#include "llvm/Support/PointerLikeTypeTraits.h"
48 if (
auto typedLoc = llvm::dyn_cast<T>(loc)) {
59 template <
typename T,
typename UnknownT = UnknownLoc>
79 assert(loc &&
"location should never be null.");
82 assert(
impl &&
"location should never be null.");
137#define GET_ATTRDEF_CLASSES
138#include "mlir/IR/BuiltinLocationAttributes.h.inc"
148template <
typename MetadataT>
151 using FusedLoc::FusedLoc;
155 return llvm::cast<MetadataT>(FusedLoc::getMetadata());
160 auto fusedLoc = llvm::dyn_cast<FusedLoc>(attr);
161 return fusedLoc && mlir::isa_and_nonnull<MetadataT>(fusedLoc.getMetadata());
176 using FileLineColRange::FileLineColRange;
181 unsigned line,
unsigned column);
199inline OpaqueLoc OpaqueLoc::get(T underlyingLocation,
MLIRContext *context) {
201 UnknownLoc::get(context));
216 return cast<LocationAttr>(attrRepls.
take_front(1)[0]);
249struct PointerLikeTypeTraits<
mlir::Location> {
258 PointerLikeTypeTraits<mlir::Attribute>::NumLowBitsAvailable;
265struct ValueIsPresent<
mlir::Location> {
272template <
typename To,
typename From>
275 std::is_same_v<mlir::Location, std::remove_const_t<From>> ||
276 std::is_base_of_v<mlir::Location, From>>>
283 return std::is_same_v<To, std::remove_const_t<From>> ||
290 return To(location->
getImpl());
ArrayRef< T > take_front(unsigned n)
Take the first N replacements as an ArrayRef, dropping them from this replacement list.
Base storage class appearing in an attribute.
Attributes are known-constant values of operations.
constexpr Attribute()=default
ImplType * getImpl() const
Return the internal Attribute implementation.
MLIRContext * getContext() const
Return the context this attribute belongs to.
AttributeStorage ImplType
An instance of this location represents a tuple of file, line number, and column number.
StringAttr getFilename() const
static FileLineColLoc get(StringAttr filename, unsigned line, unsigned column)
unsigned getColumn() const
This class represents a fused location whose metadata is known to be an instance of the given type.
MetadataT getMetadata() const
Return the metadata associated with this fused location.
static bool classof(Attribute attr)
Support llvm style casting.
Location objects represent source locations information in MLIR.
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.
T findInstanceOf()
Return an instance of the given location type if one is nested under the current location.
LocationAttr findInstanceOfOrUnknown()
Return an instance of the given location type if one is nested under the current location else return...
constexpr Attribute()=default
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
MLIRContext * getContext() const
Return the context this location is uniqued in.
Location(LocationAttr loc)
static bool classof(Attribute attr)
Support llvm style casting.
friend::llvm::hash_code hash_value(Location arg)
Location(const LocationAttr::ImplType *impl)
LocationAttr impl
The internal backing location attribute.
static Location getFromOpaquePointer(const void *pointer)
bool operator!=(Location rhs) const
LocationAttr * operator->() const
const void * getAsOpaquePointer() const
Methods for supporting PointerLikeTypeTraits.
bool operator==(Location rhs) const
Comparison operators.
void print(raw_ostream &os) const
Print the location.
MLIRContext is the top-level object for a collection of MLIR operations.
static TypeID get()
Construct a type info object for the given type T.
A utility result that is used to signal how to proceed with an ongoing walk:
static WalkResult advance()
static WalkResult interrupt()
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Include the generated interface declarations.
raw_ostream & operator<<(raw_ostream &os, const AliasResult &result)
AttrTypeSubElementReplacements< Attribute > AttrSubElementReplacements
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...
inline ::llvm::hash_code hash_value(AffineExpr arg)
Make AffineExpr hashable.
llvm::function_ref< Fn > function_ref
AttrTypeSubElementReplacements< Type > TypeSubElementReplacements
bool isStrictFileLineColLoc(Location loc)
Returns true iff the given location is a FileLineColRange with exactly one line and column.
static bool isPossible(mlir::Location location)
static To doCast(mlir::Location location)
static bool isEqual(mlir::Location LHS, mlir::Location RHS)
static unsigned getHashValue(mlir::Location val)
static mlir::Location getEmptyKey()
static mlir::Location getTombstoneKey()
static constexpr int NumLowBitsAvailable
static void * getAsVoidPointer(mlir::Location I)
static mlir::Location getFromVoidPointer(void *P)
mlir::Location UnwrappedType
static bool isPresent(const mlir::Location &location)
static Location replace(Location param, AttrSubElementReplacements &attrRepls, TypeSubElementReplacements &typeRepls)
static void walk(Location param, AttrTypeImmediateSubElementWalker &walker)
This class provides support for interacting with the SubElementInterfaces for different types of para...