Changeset View
Changeset View
Standalone View
Standalone View
mlir/include/mlir/IR/StorageUniquerSupport.h
Show First 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | static ConcreteT getChecked(function_ref<InFlightDiagnostic()> emitErrorFn, | ||||
// If the construction invariants fail then we return a null attribute. | // If the construction invariants fail then we return a null attribute. | ||||
if (failed(ConcreteT::verify(emitErrorFn, args...))) | if (failed(ConcreteT::verify(emitErrorFn, args...))) | ||||
return ConcreteT(); | return ConcreteT(); | ||||
return UniquerT::template get<ConcreteT>(ctx, args...); | return UniquerT::template get<ConcreteT>(ctx, args...); | ||||
} | } | ||||
/// Get an instance of the concrete type from a void pointer. | /// Get an instance of the concrete type from a void pointer. | ||||
static ConcreteT getFromOpaquePointer(const void *ptr) { | static ConcreteT getFromOpaquePointer(const void *ptr) { | ||||
return ptr ? BaseT::getFromOpaquePointer(ptr).template cast<ConcreteT>() | return ConcreteT((const typename BaseT::ImplType *)ptr); | ||||
: nullptr; | |||||
} | } | ||||
protected: | protected: | ||||
/// Mutate the current storage instance. This will not change the unique key. | /// Mutate the current storage instance. This will not change the unique key. | ||||
/// The arguments are forwarded to 'ConcreteT::mutate'. | /// The arguments are forwarded to 'ConcreteT::mutate'. | ||||
template <typename... Args> LogicalResult mutate(Args &&...args) { | template <typename... Args> LogicalResult mutate(Args &&...args) { | ||||
return UniquerT::template mutate<ConcreteT>(this->getContext(), getImpl(), | return UniquerT::template mutate<ConcreteT>(this->getContext(), getImpl(), | ||||
std::forward<Args>(args)...); | std::forward<Args>(args)...); | ||||
Show All 14 Lines |