[mlir] Rework the implementation of TypeID

This commit restructures how TypeID is implemented to ideally avoid
the current problems related to shared libraries. This is done by changing
the "implicit" fallback path to use the name of the type, instead of using
a static template variable (which breaks shared libraries). The major downside to this
is that it adds some additional initialization costs for the implicit path. Given the
use of type names for uniqueness in the fallback, we also no longer allow types
defined in anonymous namespaces to have an implicit TypeID. To simplify defining
an ID for these classes, a new `MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID` macro
was added to allow for explicitly defining a TypeID directly on an internal class.

To help identify when types are using the fallback, `-debug-only=typeid` can be
used to log which types are using implicit ids.

This change generally only requires changes to the test passes, which are all defined
in anonymous namespaces, and thus can't use the fallback any longer.

Differential Revision: https://reviews.llvm.org/D122775
This commit is contained in:
River Riddle 2022-03-30 17:00:37 -07:00
parent dba90d74be
commit 5e50dd048e
106 changed files with 706 additions and 126 deletions

View File

@ -3391,6 +3391,8 @@ private:
struct LLVMIRLoweringPass
: public mlir::PassWrapper<LLVMIRLoweringPass,
mlir::OperationPass<mlir::ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(LLVMIRLoweringPass)
using Printer = fir::LLVMIRLoweringPrinter;
LLVMIRLoweringPass(raw_ostream &output, Printer p)
: output{output}, printer{p} {}

View File

@ -63,6 +63,8 @@ namespace {
/// loop-carried, then the arrays are conflict-free and no copies are required.
class ArrayCopyAnalysis {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ArrayCopyAnalysis)
using ConflictSetT = llvm::SmallPtrSet<mlir::Operation *, 16>;
using UseSetT = llvm::SmallPtrSet<mlir::OpOperand *, 8>;
using LoadMapSetsT = llvm::DenseMap<mlir::Operation *, UseSetT>;

View File

@ -37,6 +37,8 @@ struct MemoryAllocationOptions {
class ReturnAnalysis {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ReturnAnalysis)
ReturnAnalysis(mlir::Operation *op) {
if (auto func = mlir::dyn_cast<mlir::FuncOp>(op))
for (mlir::Block &block : func)

View File

@ -44,9 +44,10 @@ namespace {
/// d) infer the shape of its output from the argument types.
/// 3) If the worklist is empty, the algorithm succeeded.
///
class ShapeInferencePass
struct ShapeInferencePass
: public mlir::PassWrapper<ShapeInferencePass, OperationPass<toy::FuncOp>> {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ShapeInferencePass)
void runOnOperation() override {
auto f = getOperation();

View File

@ -310,6 +310,8 @@ struct TransposeOpLowering : public ConversionPattern {
namespace {
struct ToyToAffineLoweringPass
: public PassWrapper<ToyToAffineLoweringPass, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ToyToAffineLoweringPass)
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<AffineDialect, func::FuncDialect, memref::MemRefDialect>();
}

View File

@ -44,9 +44,10 @@ namespace {
/// d) infer the shape of its output from the argument types.
/// 3) If the worklist is empty, the algorithm succeeded.
///
class ShapeInferencePass
struct ShapeInferencePass
: public mlir::PassWrapper<ShapeInferencePass, OperationPass<toy::FuncOp>> {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ShapeInferencePass)
void runOnOperation() override {
auto f = getOperation();

View File

@ -310,6 +310,8 @@ struct TransposeOpLowering : public ConversionPattern {
namespace {
struct ToyToAffineLoweringPass
: public PassWrapper<ToyToAffineLoweringPass, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ToyToAffineLoweringPass)
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<AffineDialect, func::FuncDialect, memref::MemRefDialect>();
}

View File

@ -172,6 +172,8 @@ private:
namespace {
struct ToyToLLVMLoweringPass
: public PassWrapper<ToyToLLVMLoweringPass, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ToyToLLVMLoweringPass)
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<LLVM::LLVMDialect, scf::SCFDialect>();
}

View File

@ -44,9 +44,10 @@ namespace {
/// d) infer the shape of its output from the argument types.
/// 3) If the worklist is empty, the algorithm succeeded.
///
class ShapeInferencePass
struct ShapeInferencePass
: public mlir::PassWrapper<ShapeInferencePass, OperationPass<toy::FuncOp>> {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ShapeInferencePass)
void runOnOperation() override {
auto f = getOperation();

View File

@ -310,6 +310,8 @@ struct TransposeOpLowering : public ConversionPattern {
namespace {
struct ToyToAffineLoweringPass
: public PassWrapper<ToyToAffineLoweringPass, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ToyToAffineLoweringPass)
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<AffineDialect, func::FuncDialect, memref::MemRefDialect>();
}

View File

@ -172,6 +172,8 @@ private:
namespace {
struct ToyToLLVMLoweringPass
: public PassWrapper<ToyToLLVMLoweringPass, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ToyToLLVMLoweringPass)
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<LLVM::LLVMDialect, scf::SCFDialect>();
}

View File

@ -44,9 +44,10 @@ namespace {
/// d) infer the shape of its output from the argument types.
/// 3) If the worklist is empty, the algorithm succeeded.
///
class ShapeInferencePass
struct ShapeInferencePass
: public mlir::PassWrapper<ShapeInferencePass, OperationPass<toy::FuncOp>> {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ShapeInferencePass)
void runOnOperation() override {
auto f = getOperation();

View File

@ -8,12 +8,12 @@
#ifndef MLIR_CONVERSION_SCFTOGPU_SCFTOGPUPASS_H_
#define MLIR_CONVERSION_SCFTOGPU_SCFTOGPUPASS_H_
#include "mlir/IR/FunctionInterfaces.h"
#include "mlir/Support/LLVM.h"
#include <memory>
namespace mlir {
class FunctionOpInterface;
template <typename T>
class InterfacePass;
class Pass;

View File

@ -28,7 +28,7 @@ namespace detail {
/// A utility class to represent the analyses that are known to be preserved.
class PreservedAnalyses {
/// A type used to represent all potential analyses.
struct AllAnalysesType;
struct AllAnalysesType {};
public:
/// Mark all analyses as preserved.

View File

@ -17,14 +17,15 @@
#include "mlir/Support/LLVM.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/PointerLikeTypeTraits.h"
#include "llvm/Support/TypeName.h"
namespace mlir {
namespace detail {
struct TypeIDExported;
} // namespace detail
//===----------------------------------------------------------------------===//
// TypeID
//===----------------------------------------------------------------------===//
/// This class provides an efficient unique identifier for a specific C++ type.
/// This allows for a C++ type to be compared, hashed, and stored in an opaque
@ -50,6 +51,56 @@ struct TypeIDExported;
/// ...
/// }
///
/// C++ RTTI is a notoriously difficult topic; given the nature of shared
/// libraries many different approaches fundamentally break down in either the
/// area of support (i.e. only certain types of classes are supported), or in
/// terms of performance (e.g. by using string comparison). This class intends
/// to strike a balance between performance and the setup required to enable its
/// use.
///
/// Assume we are adding support for some class Foo, below are the set of ways
/// in which a given c++ type may be supported:
///
/// * Explicitly via `MLIR_DECLARE_EXPLICIT_TYPE_ID` and
/// `MLIR_DEFINE_EXPLICIT_TYPE_ID`
///
/// - This method explicitly defines the type ID for a given type using the
/// given macros. These should be placed at the top-level of the file (i.e.
/// not within any namespace or class). This is the most effective and
/// efficient method, but requires explicit annotations for each type.
///
/// Example:
///
/// // Foo.h
/// MLIR_DECLARE_EXPLICIT_TYPE_ID(Foo);
///
/// // Foo.cpp
/// MLIR_DEFINE_EXPLICIT_TYPE_ID(Foo);
///
/// * Explicitly via `MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID`
/// - This method explicitly defines the type ID for a given type by
/// annotating the class directly. This has similar effectiveness and
/// efficiency to the above method, but should only be used on internal
/// classes; i.e. those with definitions constrained to a specific library
/// (generally classes in anonymous namespaces).
///
/// Example:
///
/// namespace {
/// class Foo {
/// public:
/// MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(Foo)
/// };
/// } // namespace
///
/// * Implicitly via a fallback using the type name
/// - This method implicitly defines a type ID for a given type by using the
/// type name. This method requires nothing explicitly from the user, but
/// pays additional access and initialization cost. Given that this method
/// uses the name of the type, it may not be used for types defined in
/// anonymous namespaces (which is asserted when it can be detected). String
/// names do not provide any guarantees on uniqueness in these contexts.
///
class TypeID {
/// This class represents the storage of a type info object.
/// Note: We specify an explicit alignment here to allow use with
@ -91,9 +142,6 @@ private:
/// The storage of this type info object.
const Storage *storage;
// See TypeIDExported below for an explanation of the trampoline behavior.
friend struct detail::TypeIDExported;
friend class TypeIDAllocator;
};
@ -102,45 +150,142 @@ inline ::llvm::hash_code hash_value(TypeID id) {
return DenseMapInfo<const TypeID::Storage *>::getHashValue(id.storage);
}
namespace detail {
//===----------------------------------------------------------------------===//
// TypeIDResolver
//===----------------------------------------------------------------------===//
/// The static local instance of each get method must be emitted with
/// "default" (public) visibility across all shared libraries, regardless of
/// whether they are compiled with hidden visibility or not. The only reliable
/// way to make this happen is to set the visibility attribute at the
/// containing namespace/struct scope. We don't do this on the TypeID (internal
/// API) class in order to reduce the scope of what gets exported with
/// public visibility. Instead, the get() methods on TypeID trampoline
/// through those on this detail class with specific visibility controls
/// applied, making visibility declarations on the internal TypeID class not
/// required (all visibility relevant pieces are here).
/// TODO: This currently won't work when using DLLs as it requires properly
/// attaching dllimport and dllexport. Fix this when that information is
/// available within LLVM.
struct LLVM_EXTERNAL_VISIBILITY TypeIDExported {
template <typename T>
static TypeID get() {
static TypeID::Storage instance;
return TypeID(&instance);
}
template <template <typename> class Trait>
static TypeID get() {
static TypeID::Storage instance;
return TypeID(&instance);
namespace detail {
/// This class provides a fallback for resolving TypeIDs. It uses the string
/// name of the type to perform the resolution, and as such does not allow the
/// use of classes defined in "anonymous" contexts.
class FallbackTypeIDResolver {
protected:
/// Register an implicit type ID for the given type name.
static TypeID registerImplicitTypeID(StringRef name);
};
/// This class provides a resolver for getting the ID for a given class T. This
/// allows for the derived type to specialize its resolution behavior. The
/// default implementation uses the string name of the type to resolve the ID.
/// This provides a strong definition, but at the cost of performance (we need
/// to do an initial lookup) and is not usable by classes defined in anonymous
/// contexts.
///
/// TODO: The use of the type name is only necessary when building in the
/// presence of shared libraries. We could add a build flag that guarantees
/// "static"-like environments and switch this to a more optimal implementation
/// when that is enabled.
template <typename T, typename Enable = void>
class TypeIDResolver : public FallbackTypeIDResolver {
public:
/// Trait to check if `U` is fully resolved. We use this to verify that `T` is
/// fully resolved when trying to resolve a TypeID. We don't technically need
/// to have the full definition of `T` for the fallback, but it does help
/// prevent situations where a forward declared type uses this fallback even
/// though there is a strong definition for the TypeID in the location where
/// `T` is defined.
template <typename U>
using is_fully_resolved_trait = decltype(sizeof(U));
template <typename U>
using is_fully_resolved = llvm::is_detected<is_fully_resolved_trait, U>;
static TypeID resolveTypeID() {
static_assert(is_fully_resolved<T>::value,
"TypeID::get<> requires the complete definition of `T`");
static TypeID id = registerImplicitTypeID(llvm::getTypeName<T>());
return id;
}
};
/// This class provides utilities for resolving the TypeID of a class that
/// provides a `static TypeID resolveTypeID()` method. This allows for
/// simplifying situations when the class can resolve the ID itself. This
/// functionality is separated from the corresponding `TypeIDResolver`
/// specialization below to enable referencing it more easily in different
/// contexts.
struct InlineTypeIDResolver {
/// Trait to check if `T` provides a static `resolveTypeID` method.
template <typename T>
using has_resolve_typeid_trait = decltype(T::resolveTypeID());
template <typename T>
using has_resolve_typeid = llvm::is_detected<has_resolve_typeid_trait, T>;
template <typename T>
static TypeID resolveTypeID() {
return T::resolveTypeID();
}
};
/// This class provides a resolver for getting the ID for a given class T, when
/// the class provides a `static TypeID resolveTypeID()` method. This allows for
/// simplifying situations when the class can resolve the ID itself.
template <typename T>
class TypeIDResolver<
T, std::enable_if_t<InlineTypeIDResolver::has_resolve_typeid<T>::value>> {
public:
static TypeID resolveTypeID() {
return InlineTypeIDResolver::resolveTypeID<T>();
}
};
} // namespace detail
template <typename T>
TypeID TypeID::get() {
return detail::TypeIDExported::get<T>();
return detail::TypeIDResolver<T>::resolveTypeID();
}
template <template <typename> class Trait>
TypeID TypeID::get() {
return detail::TypeIDExported::get<Trait>();
// An empty class used to simplify the use of Trait types.
struct Empty {};
return TypeID::get<Trait<Empty>>();
}
// Declare/define an explicit specialization for TypeID: this forces the
// compiler to emit a strong definition for a class and controls which
// translation unit and shared object will actually have it.
// This can be useful to turn to a link-time failure what would be in other
// circumstances a hard-to-catch runtime bug when a TypeID is hidden in two
// different shared libraries and instances of the same class only gets the same
// TypeID inside a given DSO.
#define MLIR_DECLARE_EXPLICIT_TYPE_ID(CLASS_NAME) \
namespace mlir { \
namespace detail { \
template <> \
class TypeIDResolver<CLASS_NAME> { \
public: \
static TypeID resolveTypeID() { return id; } \
\
private: \
static SelfOwningTypeID id; \
}; \
} /* namespace detail */ \
} /* namespace mlir */
#define MLIR_DEFINE_EXPLICIT_TYPE_ID(CLASS_NAME) \
namespace mlir { \
namespace detail { \
SelfOwningTypeID TypeIDResolver<CLASS_NAME>::id = {}; \
} /* namespace detail */ \
} /* namespace mlir */
// Declare/define an explicit, **internal**, specialization of TypeID for the
// given class. This is useful for providing an explicit specialization of
// TypeID for a class that is known to be internal to a specific library. It
// should be placed within a public section of the declaration of the class.
#define MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CLASS_NAME) \
static ::mlir::TypeID resolveTypeID() { \
static ::mlir::SelfOwningTypeID id; \
return id; \
} \
static_assert( \
::mlir::detail::InlineTypeIDResolver::has_resolve_typeid< \
CLASS_NAME>::value, \
"`MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID` must be placed in a " \
"public section of `" #CLASS_NAME "`");
//===----------------------------------------------------------------------===//
// TypeIDAllocator
//===----------------------------------------------------------------------===//
/// This class provides a way to define new TypeIDs at runtime.
/// When the allocator is destructed, all allocated TypeIDs become invalid and
/// therefore should not be used.
@ -156,9 +301,15 @@ private:
llvm::SpecificBumpPtrAllocator<TypeID::Storage> ids;
};
//===----------------------------------------------------------------------===//
// SelfOwningTypeID
//===----------------------------------------------------------------------===//
/// Defines a TypeID for each instance of this class by using a pointer to the
/// instance. Thus, the copy and move constructor are deleted.
class SelfOwningTypeID {
/// Note: We align by 8 to match the alignment of TypeID::Storage, as we treat
/// an instance of this class similarly to TypeID::Storage.
class alignas(8) SelfOwningTypeID {
public:
SelfOwningTypeID() = default;
SelfOwningTypeID(const SelfOwningTypeID &) = delete;
@ -166,36 +317,21 @@ public:
SelfOwningTypeID(SelfOwningTypeID &&) = delete;
SelfOwningTypeID &operator=(SelfOwningTypeID &&) = delete;
/// Implicitly converts to the owned TypeID.
operator TypeID() const { return getTypeID(); }
/// Return the TypeID owned by this object.
TypeID getTypeID() const { return TypeID::getFromOpaquePointer(this); }
};
} // namespace mlir
// Declare/define an explicit specialization for TypeID: this forces the
// compiler to emit a strong definition for a class and controls which
// translation unit and shared object will actually have it.
// This can be useful to turn to a link-time failure what would be in other
// circumstances a hard-to-catch runtime bug when a TypeID is hidden in two
// different shared libraries and instances of the same class only gets the same
// TypeID inside a given DSO.
#define DECLARE_EXPLICIT_TYPE_ID(CLASS_NAME) \
namespace mlir { \
namespace detail { \
template <> \
LLVM_EXTERNAL_VISIBILITY TypeID TypeIDExported::get<CLASS_NAME>(); \
} \
}
//===----------------------------------------------------------------------===//
// Builtin TypeIDs
//===----------------------------------------------------------------------===//
#define DEFINE_EXPLICIT_TYPE_ID(CLASS_NAME) \
namespace mlir { \
namespace detail { \
template <> \
LLVM_EXTERNAL_VISIBILITY TypeID TypeIDExported::get<CLASS_NAME>() { \
static TypeID::Storage instance; \
return TypeID(&instance); \
} \
} \
}
/// Explicitly register a set of "builtin" types.
MLIR_DECLARE_EXPLICIT_TYPE_ID(void)
namespace llvm {
template <> struct DenseMapInfo<mlir::TypeID> {

View File

@ -277,6 +277,15 @@ public:
} // namespace pdll
} // namespace mlir
MLIR_DECLARE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::AttributeTypeStorage)
MLIR_DECLARE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::ConstraintTypeStorage)
MLIR_DECLARE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::OperationTypeStorage)
MLIR_DECLARE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::RangeTypeStorage)
MLIR_DECLARE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::RewriteTypeStorage)
MLIR_DECLARE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::TupleTypeStorage)
MLIR_DECLARE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::TypeTypeStorage)
MLIR_DECLARE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::ValueTypeStorage)
namespace llvm {
template <> struct DenseMapInfo<mlir::pdll::ast::Type> {
static mlir::pdll::ast::Type getEmptyKey() {

View File

@ -12,10 +12,10 @@
#include "mlir/Pass/Pass.h"
#include "mlir/Conversion/GPUToROCDL/Runtimes.h"
#include "mlir/IR/FunctionInterfaces.h"
namespace mlir {
class AffineDialect;
class FunctionOpInterface;
// Forward declaration from Dialect.h
template <typename ConcreteDialect>

View File

@ -61,6 +61,8 @@ namespace {
class SerializeToHsacoPass
: public PassWrapper<SerializeToHsacoPass, gpu::SerializeToBlobPass> {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SerializeToHsacoPass)
SerializeToHsacoPass(StringRef triple, StringRef arch, StringRef features,
int optLevel);
SerializeToHsacoPass(const SerializeToHsacoPass &other);

View File

@ -103,6 +103,8 @@ namespace {
/// inside the struct.
class ResourceAliasAnalysis {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ResourceAliasAnalysis)
explicit ResourceAliasAnalysis(Operation *);
/// Returns true if the given `op` can be rewritten to use a canonical

View File

@ -257,6 +257,10 @@ public:
unsigned number; // Number, specified with #12
SMLoc loc; // Location of first definition or use.
};
struct DeferredLocInfo {
SMLoc loc;
StringRef identifier;
};
/// Push a new SSA name scope to the parser.
void pushSSANameScope(bool isIsolated);
@ -481,10 +485,6 @@ private:
/// Deffered locations: when parsing `loc(#loc42)` we add an entry to this
/// map. After parsing the definition `#loc42 = ...` we'll patch back users
/// of this location.
struct DeferredLocInfo {
SMLoc loc;
StringRef identifier;
};
std::vector<DeferredLocInfo> deferredLocsReferences;
/// The builder used when creating parsed operation instances.
@ -495,6 +495,9 @@ private:
};
} // namespace
MLIR_DECLARE_EXPLICIT_TYPE_ID(OperationParser::DeferredLocInfo *)
MLIR_DEFINE_EXPLICIT_TYPE_ID(OperationParser::DeferredLocInfo *)
OperationParser::OperationParser(ParserState &state, ModuleOp topLevelOp)
: Parser(state), opBuilder(topLevelOp.getRegion()), topLevelOp(topLevelOp) {
// The top level operation starts a new name scope.

View File

@ -6,6 +6,7 @@ set(LLVM_OPTIONAL_SOURCES
StorageUniquer.cpp
Timing.cpp
ToolUtilities.cpp
TypeID.cpp
)
add_mlir_library(MLIRSupport
@ -16,6 +17,7 @@ add_mlir_library(MLIRSupport
StorageUniquer.cpp
Timing.cpp
ToolUtilities.cpp
TypeID.cpp
ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Support

View File

@ -0,0 +1,92 @@
//===- TypeID.cpp - MLIR TypeID -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "mlir/Support/TypeID.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/RWMutex.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/raw_ostream.h"
using namespace mlir;
#define DEBUG_TYPE "typeid"
//===----------------------------------------------------------------------===//
// TypeID Registry
//===----------------------------------------------------------------------===//
namespace {
struct ImplicitTypeIDRegistry {
/// Lookup or insert a TypeID for the given type name.
TypeID lookupOrInsert(StringRef typeName) {
LLVM_DEBUG(llvm::dbgs() << "ImplicitTypeIDRegistry::lookupOrInsert("
<< typeName << ")\n");
// Perform a heuristic check to see if this type is in an anonymous
// namespace. String equality is not valid for anonymous types, so we try to
// abort whenever we see them.
#ifndef NDEBUG
#if defined(_MSC_VER)
if (typeName.contains("anonymous-namespace")) {
#else
if (typeName.contains("anonymous namespace")) {
#endif
std::string errorStr;
{
llvm::raw_string_ostream errorOS(errorStr);
errorOS << "TypeID::get<" << typeName
<< ">(): Using TypeID on a class with an anonymous "
"namespace requires an explicit TypeID definition. The "
"implicit fallback uses string name, which does not "
"guarantee uniqueness in anonymous contexts. Define an "
"explicit TypeID instantiation for this type using "
"`MLIR_DECLARE_EXPLICIT_TYPE_ID`/"
"`MLIR_DEFINE_EXPLICIT_TYPE_ID` or "
"`DEFINE_EXPLICIT_PRIVATE_INLINE_TYPE_ID`.\n";
}
llvm::report_fatal_error(errorStr);
}
#endif
{ // Try a read-only lookup first.
llvm::sys::SmartScopedReader<true> guard(mutex);
auto it = typeNameToID.find(typeName);
if (it != typeNameToID.end())
return it->second;
}
llvm::sys::SmartScopedWriter<true> guard(mutex);
auto it = typeNameToID.try_emplace(typeName, TypeID());
if (it.second)
it.first->second = typeIDAllocator.allocate();
return it.first->second;
}
/// A mutex that guards access to the registry.
llvm::sys::SmartRWMutex<true> mutex;
/// An allocator used for TypeID objects.
TypeIDAllocator typeIDAllocator;
/// A map type name to TypeID.
DenseMap<StringRef, TypeID> typeNameToID;
};
} // end namespace
TypeID detail::FallbackTypeIDResolver::registerImplicitTypeID(StringRef name) {
static ImplicitTypeIDRegistry registry;
return registry.lookupOrInsert(name);
}
//===----------------------------------------------------------------------===//
// Builtin TypeIDs
//===----------------------------------------------------------------------===//
MLIR_DEFINE_EXPLICIT_TYPE_ID(void)

View File

@ -31,6 +31,8 @@ namespace {
class OpenMPAllocaStackFrame
: public LLVM::ModuleTranslation::StackFrameBase<OpenMPAllocaStackFrame> {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(OpenMPAllocaStackFrame)
explicit OpenMPAllocaStackFrame(llvm::OpenMPIRBuilder::InsertPointTy allocaIP)
: allocaInsertPoint(allocaIP) {}
llvm::OpenMPIRBuilder::InsertPointTy allocaInsertPoint;
@ -42,6 +44,8 @@ class OpenMPVarMappingStackFrame
: public LLVM::ModuleTranslation::StackFrameBase<
OpenMPVarMappingStackFrame> {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(OpenMPVarMappingStackFrame)
explicit OpenMPVarMappingStackFrame(
const DenseMap<Value, llvm::Value *> &mapping)
: mapping(mapping) {}

View File

@ -13,6 +13,15 @@
using namespace mlir;
using namespace mlir::pdll::ast;
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::AttributeTypeStorage)
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::ConstraintTypeStorage)
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::OperationTypeStorage)
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::RangeTypeStorage)
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::RewriteTypeStorage)
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::TupleTypeStorage)
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::TypeTypeStorage)
MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::pdll::ast::detail::ValueTypeStorage)
//===----------------------------------------------------------------------===//
// Type
//===----------------------------------------------------------------------===//

View File

@ -1753,15 +1753,13 @@ int testTypeID(MlirContext ctx) {
return 2;
}
if (mlirTypeIDEqual(i32ID, f32ID) ||
mlirTypeIDHashValue(i32ID) == mlirTypeIDHashValue(f32ID)) {
if (mlirTypeIDEqual(i32ID, f32ID)) {
fprintf(stderr,
"ERROR: Expected integer type id to not equal float type id\n");
return 3;
}
if (mlirTypeIDEqual(i32ID, i32AttrID) ||
mlirTypeIDHashValue(i32ID) == mlirTypeIDHashValue(i32AttrID)) {
if (mlirTypeIDEqual(i32ID, i32AttrID)) {
fprintf(stderr, "ERROR: Expected integer type id to not equal integer "
"attribute type id\n");
return 4;

View File

@ -46,6 +46,8 @@ static void printAliasOperand(Value value) {
namespace {
struct TestAliasAnalysisPass
: public PassWrapper<TestAliasAnalysisPass, OperationPass<>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestAliasAnalysisPass)
StringRef getArgument() const final { return "test-alias-analysis"; }
StringRef getDescription() const final {
return "Test alias analysis results.";
@ -88,6 +90,8 @@ struct TestAliasAnalysisPass
namespace {
struct TestAliasAnalysisModRefPass
: public PassWrapper<TestAliasAnalysisModRefPass, OperationPass<>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestAliasAnalysisModRefPass)
StringRef getArgument() const final { return "test-alias-analysis-modref"; }
StringRef getDescription() const final {
return "Test alias analysis ModRef results.";

View File

@ -19,6 +19,8 @@ using namespace mlir;
namespace {
struct TestCallGraphPass
: public PassWrapper<TestCallGraphPass, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestCallGraphPass)
StringRef getArgument() const final { return "test-print-callgraph"; }
StringRef getDescription() const final {
return "Print the contents of a constructed callgraph.";

View File

@ -20,6 +20,8 @@ namespace {
struct TestLivenessPass
: public PassWrapper<TestLivenessPass, InterfacePass<SymbolOpInterface>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestLivenessPass)
StringRef getArgument() const final { return "test-print-liveness"; }
StringRef getDescription() const final {
return "Print the contents of a constructed liveness information.";

View File

@ -37,6 +37,8 @@ void printReductionResult(Operation *redRegionOp, unsigned numOutput,
struct TestMatchReductionPass
: public PassWrapper<TestMatchReductionPass,
InterfacePass<FunctionOpInterface>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestMatchReductionPass)
StringRef getArgument() const final { return "test-match-reduction"; }
StringRef getDescription() const final {
return "Test the match reduction utility.";

View File

@ -29,6 +29,8 @@ namespace {
/// Checks for out of bound memref access subscripts..
struct TestMemRefBoundCheck
: public PassWrapper<TestMemRefBoundCheck, OperationPass<>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestMemRefBoundCheck)
StringRef getArgument() const final { return "test-memref-bound-check"; }
StringRef getDescription() const final {
return "Check memref access bounds";

View File

@ -28,6 +28,8 @@ namespace {
/// Checks dependences between all pairs of memref accesses in a Function.
struct TestMemRefDependenceCheck
: public PassWrapper<TestMemRefDependenceCheck, OperationPass<>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestMemRefDependenceCheck)
StringRef getArgument() const final { return "test-memref-dependence-check"; }
StringRef getDescription() const final {
return "Checks dependences between all pairs of memref accesses.";

View File

@ -16,6 +16,8 @@ namespace {
struct TestMemRefStrideCalculation
: public PassWrapper<TestMemRefStrideCalculation,
InterfacePass<SymbolOpInterface>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestMemRefStrideCalculation)
StringRef getArgument() const final {
return "test-memref-stride-calculation";
}

View File

@ -18,6 +18,8 @@ namespace {
struct TestTopologicalSortPass
: public PassWrapper<TestTopologicalSortPass,
InterfacePass<SymbolOpInterface>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestTopologicalSortPass)
StringRef getArgument() const final { return "test-print-topological-sort"; }
StringRef getDescription() const final {
return "Print operations in topological order";

View File

@ -32,9 +32,10 @@ public:
}
};
class TestConvertCallOp
struct TestConvertCallOp
: public PassWrapper<TestConvertCallOp, OperationPass<ModuleOp>> {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestConvertCallOp)
void getDependentDialects(DialectRegistry &registry) const final {
registry.insert<LLVM::LLVMDialect>();
}

View File

@ -28,6 +28,8 @@ namespace {
struct TestAffineDataCopy
: public PassWrapper<TestAffineDataCopy, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestAffineDataCopy)
StringRef getArgument() const final { return PASS_NAME; }
StringRef getDescription() const final {
return "Tests affine data copy utility functions.";

View File

@ -24,6 +24,8 @@ namespace {
struct TestAffineLoopParametricTiling
: public PassWrapper<TestAffineLoopParametricTiling,
OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestAffineLoopParametricTiling)
StringRef getArgument() const final { return "test-affine-parametric-tile"; }
StringRef getDescription() const final {
return "Tile affine loops using SSA values as tile sizes";

View File

@ -25,6 +25,8 @@ namespace {
/// This pass applies the permutation on the first maximal perfect nest.
struct TestAffineLoopUnswitching
: public PassWrapper<TestAffineLoopUnswitching, OperationPass<>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestAffineLoopUnswitching)
StringRef getArgument() const final { return PASS_NAME; }
StringRef getDescription() const final {
return "Tests affine loop unswitching / if/else hoisting";

View File

@ -42,6 +42,8 @@ namespace {
struct TestLoopFusion
: public PassWrapper<TestLoopFusion, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestLoopFusion)
StringRef getArgument() const final { return "test-loop-fusion"; }
StringRef getDescription() const final {
return "Tests loop fusion utility functions.";

View File

@ -22,9 +22,10 @@
using namespace mlir;
namespace {
class TestLoopMappingPass
struct TestLoopMappingPass
: public PassWrapper<TestLoopMappingPass, OperationPass<>> {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestLoopMappingPass)
StringRef getArgument() const final {
return "test-mapping-to-processing-elements";
}

View File

@ -24,6 +24,8 @@ namespace {
/// This pass applies the permutation on the first maximal perfect nest.
struct TestLoopPermutation
: public PassWrapper<TestLoopPermutation, OperationPass<>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestLoopPermutation)
StringRef getArgument() const final { return PASS_NAME; }
StringRef getDescription() const final {
return "Tests affine loop permutation utility";

View File

@ -71,6 +71,8 @@ static llvm::cl::opt<bool> clTestVecAffineLoopNest(
namespace {
struct VectorizerTestPass
: public PassWrapper<VectorizerTestPass, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(VectorizerTestPass)
static constexpr auto kTestAffineMapOpName = "test_affine_map";
static constexpr auto kTestAffineMapAttrName = "affine_map";
void getDependentDialects(DialectRegistry &registry) const override {

View File

@ -21,6 +21,8 @@ namespace {
/// result types.
struct TestDataLayoutQuery
: public PassWrapper<TestDataLayoutQuery, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestDataLayoutQuery)
StringRef getArgument() const final { return "test-data-layout-query"; }
StringRef getDescription() const final { return "Test data layout queries"; }
void runOnOperation() override {

View File

@ -23,6 +23,7 @@ namespace {
/// For example, `tuple<T1, T2, T3> --> T1, T2, T3`.
struct TestDecomposeCallGraphTypes
: public PassWrapper<TestDecomposeCallGraphTypes, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestDecomposeCallGraphTypes)
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<test::TestDialect>();

View File

@ -20,6 +20,8 @@ namespace {
class TestSerializeToCubinPass
: public PassWrapper<TestSerializeToCubinPass, gpu::SerializeToBlobPass> {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestSerializeToCubinPass)
StringRef getArgument() const final { return "test-gpu-to-cubin"; }
StringRef getDescription() const final {
return "Lower GPU kernel function to CUBIN binary annotations";

View File

@ -20,6 +20,8 @@ namespace {
class TestSerializeToHsacoPass
: public PassWrapper<TestSerializeToHsacoPass, gpu::SerializeToBlobPass> {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestSerializeToHsacoPass)
StringRef getArgument() const final { return "test-gpu-to-hsaco"; }
StringRef getDescription() const final {
return "Lower GPU kernel function to HSAco binary annotations";

View File

@ -27,9 +27,11 @@ namespace {
/// Promotes all arguments with "gpu.test_promote_workgroup" attribute. This
/// does not check whether the promotion is legal (e.g., amount of memory used)
/// or beneficial (e.g., makes previously uncoalesced loads coalesced).
class TestGpuMemoryPromotionPass
struct TestGpuMemoryPromotionPass
: public PassWrapper<TestGpuMemoryPromotionPass,
OperationPass<gpu::GPUFuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestGpuMemoryPromotionPass)
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<AffineDialect, memref::MemRefDialect, scf::SCFDialect>();
}

View File

@ -19,9 +19,12 @@ using namespace mlir;
namespace {
/// Simple pass for testing the mapping of parallel loops to hardware ids using
/// a greedy mapping strategy.
class TestGpuGreedyParallelLoopMappingPass
struct TestGpuGreedyParallelLoopMappingPass
: public PassWrapper<TestGpuGreedyParallelLoopMappingPass,
OperationPass<>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(
TestGpuGreedyParallelLoopMappingPass)
StringRef getArgument() const final {
return "test-gpu-greedy-parallel-loop-mapping";
}

View File

@ -22,6 +22,8 @@ using namespace mlir;
namespace {
struct TestGpuRewritePass
: public PassWrapper<TestGpuRewritePass, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestGpuRewritePass)
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<arith::ArithmeticDialect, func::FuncDialect,
memref::MemRefDialect>();

View File

@ -31,6 +31,8 @@ using namespace mlir::linalg;
namespace {
struct TestLinalgCodegenStrategy
: public PassWrapper<TestLinalgCodegenStrategy, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestLinalgCodegenStrategy)
StringRef getArgument() const final { return "test-linalg-codegen-strategy"; }
StringRef getDescription() const final {
return "Test Linalg Codegen Strategy.";

View File

@ -18,7 +18,7 @@
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include "llvm/ADT/TypeSwitch.h"
namespace mlir {
using namespace mlir;
static void addOperands(Operation *op, SetVector<Value> &operandSet) {
if (!op)
@ -48,6 +48,8 @@ static bool setFusedOpOperandLimit(const OpResult &producer,
namespace {
struct TestLinalgElementwiseFusion
: public PassWrapper<TestLinalgElementwiseFusion, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestLinalgElementwiseFusion)
TestLinalgElementwiseFusion() = default;
TestLinalgElementwiseFusion(const TestLinalgElementwiseFusion &pass)
: PassWrapper(pass) {}
@ -168,10 +170,10 @@ struct TestLinalgElementwiseFusion
} // namespace
namespace mlir {
namespace test {
void registerTestLinalgElementwiseFusion() {
PassRegistration<TestLinalgElementwiseFusion>();
}
} // namespace test
} // namespace mlir

View File

@ -114,6 +114,8 @@ template <LinalgTilingLoopType LoopType>
struct TestLinalgFusionTransforms
: public PassWrapper<TestLinalgFusionTransforms<LoopType>,
OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestLinalgFusionTransforms)
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<AffineDialect, linalg::LinalgDialect, memref::MemRefDialect,
scf::SCFDialect>();
@ -135,6 +137,9 @@ struct TestLinalgFusionTransforms
struct TestLinalgFusionTransformsParallelLoops
: public TestLinalgFusionTransforms<LinalgTilingLoopType::ParallelLoops> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(
TestLinalgFusionTransformsParallelLoops)
StringRef getArgument() const final {
return "test-linalg-fusion-transform-patterns";
}
@ -146,6 +151,8 @@ struct TestLinalgFusionTransformsParallelLoops
struct TestLinalgFusionTransformsLoops
: public TestLinalgFusionTransforms<LinalgTilingLoopType::Loops> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestLinalgFusionTransformsLoops)
StringRef getArgument() const final {
return "test-linalg-tensor-fusion-transform-patterns";
}
@ -157,6 +164,9 @@ struct TestLinalgFusionTransformsLoops
struct TestLinalgFusionTransformsTiledLoops
: public TestLinalgFusionTransforms<LinalgTilingLoopType::TiledLoops> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(
TestLinalgFusionTransformsTiledLoops)
StringRef getArgument() const final {
return "test-linalg-tiled-loop-fusion-transform-patterns";
}
@ -228,6 +238,8 @@ static LogicalResult fuseLinalgOpsGreedily(FuncOp f) {
namespace {
struct TestLinalgGreedyFusion
: public PassWrapper<TestLinalgGreedyFusion, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestLinalgGreedyFusion)
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<AffineDialect, linalg::LinalgDialect, memref::MemRefDialect,
scf::SCFDialect>();
@ -261,6 +273,9 @@ struct TestLinalgGreedyFusion
struct TestLinalgTileAndFuseSequencePass
: public PassWrapper<TestLinalgTileAndFuseSequencePass,
OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(
TestLinalgTileAndFuseSequencePass)
StringRef getArgument() const final { return "test-linalg-tile-and-fuse"; }
StringRef getDescription() const final {
return "Test Linalg tiling and fusion of a sequence of Linalg operations.";

View File

@ -22,6 +22,8 @@ using namespace mlir::linalg;
namespace {
struct TestLinalgHoisting
: public PassWrapper<TestLinalgHoisting, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestLinalgHoisting)
TestLinalgHoisting() = default;
TestLinalgHoisting(const TestLinalgHoisting &pass) : PassWrapper(pass) {}
void getDependentDialects(DialectRegistry &registry) const override {

View File

@ -33,6 +33,8 @@ using namespace mlir::linalg;
namespace {
struct TestLinalgTransforms
: public PassWrapper<TestLinalgTransforms, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestLinalgTransforms)
TestLinalgTransforms() = default;
TestLinalgTransforms(const TestLinalgTransforms &pass) : PassWrapper(pass) {}

View File

@ -16,11 +16,12 @@
#include "mlir/Pass/PassManager.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
namespace mlir {
using namespace mlir;
namespace {
struct TestPadFusionPass
: public PassWrapper<TestPadFusionPass, OperationPass<>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestPadFusionPass)
void getDependentDialects(DialectRegistry &registry) const override {
registry
@ -41,8 +42,8 @@ struct TestPadFusionPass
};
} // namespace
namespace mlir {
namespace test {
void registerTestPadFusion() { PassRegistration<TestPadFusionPass>(); }
} // namespace test
} // namespace mlir

View File

@ -21,6 +21,9 @@ using namespace mlir;
namespace {
struct TestMathAlgebraicSimplificationPass
: public PassWrapper<TestMathAlgebraicSimplificationPass, OperationPass<>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(
TestMathAlgebraicSimplificationPass)
void runOnOperation() override;
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<vector::VectorDialect, math::MathDialect>();

View File

@ -19,6 +19,8 @@ using namespace mlir;
namespace {
struct TestExpandTanhPass
: public PassWrapper<TestExpandTanhPass, OperationPass<>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestExpandTanhPass)
void runOnOperation() override;
StringRef getArgument() const final { return "test-expand-tanh"; }
StringRef getDescription() const final { return "Test expanding tanh"; }

View File

@ -24,6 +24,9 @@ using namespace mlir;
namespace {
struct TestMathPolynomialApproximationPass
: public PassWrapper<TestMathPolynomialApproximationPass, OperationPass<>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(
TestMathPolynomialApproximationPass)
TestMathPolynomialApproximationPass() = default;
TestMathPolynomialApproximationPass(
const TestMathPolynomialApproximationPass &pass)

View File

@ -20,6 +20,8 @@ using namespace mlir;
namespace {
struct TestComposeSubViewPass
: public PassWrapper<TestComposeSubViewPass, OperationPass<>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestComposeSubViewPass)
StringRef getArgument() const final { return "test-compose-subview"; }
StringRef getDescription() const final {
return "Test combining composed subviews";

View File

@ -17,6 +17,8 @@ using namespace mlir;
namespace {
struct TestMultiBufferingPass
: public PassWrapper<TestMultiBufferingPass, OperationPass<>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestMultiBufferingPass)
TestMultiBufferingPass() = default;
TestMultiBufferingPass(const TestMultiBufferingPass &pass)
: PassWrapper(pass) {}

View File

@ -24,6 +24,8 @@ namespace {
class SimpleParametricLoopTilingPass
: public PassWrapper<SimpleParametricLoopTilingPass, OperationPass<>> {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SimpleParametricLoopTilingPass)
StringRef getArgument() const final {
return "test-extract-fixed-outer-loops";
}

View File

@ -30,9 +30,10 @@ static unsigned getNestingDepth(Operation *op) {
return depth;
}
class TestLoopUnrollingPass
struct TestLoopUnrollingPass
: public PassWrapper<TestLoopUnrollingPass, OperationPass<>> {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestLoopUnrollingPass)
StringRef getArgument() const final { return "test-loop-unrolling"; }
StringRef getDescription() const final {
return "Tests loop unrolling transformation";

View File

@ -25,9 +25,10 @@
using namespace mlir;
namespace {
class TestSCFForUtilsPass
struct TestSCFForUtilsPass
: public PassWrapper<TestSCFForUtilsPass, OperationPass<FuncOp>> {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestSCFForUtilsPass)
StringRef getArgument() const final { return "test-scf-for-utils"; }
StringRef getDescription() const final { return "test scf.for utils"; }
explicit TestSCFForUtilsPass() = default;
@ -57,9 +58,10 @@ public:
}
};
class TestSCFIfUtilsPass
struct TestSCFIfUtilsPass
: public PassWrapper<TestSCFIfUtilsPass, OperationPass<ModuleOp>> {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestSCFIfUtilsPass)
StringRef getArgument() const final { return "test-scf-if-utils"; }
StringRef getDescription() const final { return "test scf.if utils"; }
explicit TestSCFIfUtilsPass() = default;
@ -95,9 +97,10 @@ static const StringLiteral kTestPipeliningAnnotationPart =
static const StringLiteral kTestPipeliningAnnotationIteration =
"__test_pipelining_iteration";
class TestSCFPipeliningPass
struct TestSCFPipeliningPass
: public PassWrapper<TestSCFPipeliningPass, OperationPass<FuncOp>> {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestSCFPipeliningPass)
TestSCFPipeliningPass() = default;
TestSCFPipeliningPass(const TestSCFPipeliningPass &) {}
StringRef getArgument() const final { return "test-scf-pipelining"; }

View File

@ -23,6 +23,8 @@ namespace {
/// A pass for testing SPIR-V op availability.
struct PrintOpAvailability
: public PassWrapper<PrintOpAvailability, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(PrintOpAvailability)
void runOnOperation() override;
StringRef getArgument() const final { return "test-spirv-op-availability"; }
StringRef getDescription() const final {
@ -105,6 +107,8 @@ namespace {
/// A pass for testing SPIR-V op availability.
struct ConvertToTargetEnv
: public PassWrapper<ConvertToTargetEnv, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ConvertToTargetEnv)
StringRef getArgument() const override { return "test-spirv-target-env"; }
StringRef getDescription() const override {
return "Test SPIR-V target environment";

View File

@ -20,10 +20,11 @@ using namespace mlir;
namespace {
/// Pass to set the spv.entry_point_abi
class TestSpirvEntryPointABIPass
struct TestSpirvEntryPointABIPass
: public PassWrapper<TestSpirvEntryPointABIPass,
OperationPass<gpu::GPUModuleOp>> {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestSpirvEntryPointABIPass)
StringRef getArgument() const final { return "test-spirv-entry-point-abi"; }
StringRef getDescription() const final {
return "Set the spv.entry_point_abi attribute on GPU kernel function "

View File

@ -20,6 +20,8 @@ class TestModuleCombinerPass
: public PassWrapper<TestModuleCombinerPass,
OperationPass<mlir::ModuleOp>> {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestModuleCombinerPass)
StringRef getArgument() const final { return "test-spirv-module-combiner"; }
StringRef getDescription() const final {
return "Tests SPIR-V module combiner library";

View File

@ -19,6 +19,8 @@ namespace {
/// This is a pass that reports shape functions associated with ops.
struct ReportShapeFnPass
: public PassWrapper<ReportShapeFnPass, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ReportShapeFnPass)
void runOnOperation() override;
StringRef getArgument() const final { return "test-shape-function-report"; }
StringRef getDescription() const final {

View File

@ -22,6 +22,8 @@ using namespace mlir;
namespace {
struct TestTensorTransforms
: public PassWrapper<TestTensorTransforms, OperationPass<>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestTensorTransforms)
TestTensorTransforms() = default;
TestTensorTransforms(const TestTensorTransforms &pass) : PassWrapper(pass) {}

View File

@ -1021,6 +1021,8 @@ LogicalResult OpWithResultShapePerDimInterfaceOp::reifyResultShapes(
namespace {
/// A test resource for side effects.
struct TestResource : public SideEffects::Resource::Base<TestResource> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestResource)
StringRef getName() final { return "<Test>"; }
};
} // namespace

View File

@ -149,6 +149,8 @@ public:
struct TestPatternDriver
: public PassWrapper<TestPatternDriver, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestPatternDriver)
StringRef getArgument() const final { return "test-patterns"; }
StringRef getDescription() const final { return "Run test dialect patterns"; }
void runOnOperation() override {
@ -214,6 +216,8 @@ static void reifyReturnShape(Operation *op) {
struct TestReturnTypeDriver
: public PassWrapper<TestReturnTypeDriver, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestReturnTypeDriver)
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<tensor::TensorDialect>();
}
@ -254,6 +258,8 @@ struct TestReturnTypeDriver
namespace {
struct TestDerivedAttributeDriver
: public PassWrapper<TestDerivedAttributeDriver, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestDerivedAttributeDriver)
StringRef getArgument() const final { return "test-derived-attr"; }
StringRef getDescription() const final {
return "Run test derived attributes";
@ -655,6 +661,8 @@ struct TestTypeConverter : public TypeConverter {
struct TestLegalizePatternDriver
: public PassWrapper<TestLegalizePatternDriver, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestLegalizePatternDriver)
StringRef getArgument() const final { return "test-legalize-patterns"; }
StringRef getDescription() const final {
return "Run test dialect legalization patterns";
@ -864,6 +872,8 @@ struct TestRemapValueInRegion
struct TestRemappedValue
: public mlir::PassWrapper<TestRemappedValue, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestRemappedValue)
StringRef getArgument() const final { return "test-remapped-value"; }
StringRef getDescription() const final {
return "Test public remapped value mechanism in ConversionPatternRewriter";
@ -922,6 +932,8 @@ struct RemoveTestDialectOps : public RewritePattern {
struct TestUnknownRootOpDriver
: public mlir::PassWrapper<TestUnknownRootOpDriver, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestUnknownRootOpDriver)
StringRef getArgument() const final {
return "test-legalize-unknown-root-patterns";
}
@ -1041,6 +1053,8 @@ struct TestTypeConversionAnotherProducer
struct TestTypeConversionDriver
: public PassWrapper<TestTypeConversionDriver, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestTypeConversionDriver)
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<TestDialect>();
}
@ -1177,6 +1191,9 @@ struct ForwardOperandPattern : public OpConversionPattern<TestTypeChangerOp> {
struct TestTargetMaterializationWithNoUses
: public PassWrapper<TestTargetMaterializationWithNoUses,
OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(
TestTargetMaterializationWithNoUses)
StringRef getArgument() const final {
return "test-target-materialization-with-no-uses";
}
@ -1283,6 +1300,8 @@ struct TestMergeSingleBlockOps
struct TestMergeBlocksPatternDriver
: public PassWrapper<TestMergeBlocksPatternDriver,
OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestMergeBlocksPatternDriver)
StringRef getArgument() const final { return "test-merge-blocks"; }
StringRef getDescription() const final {
return "Test Merging operation in ConversionPatternRewriter";
@ -1354,6 +1373,9 @@ struct TestSelectiveOpReplacementPattern : public OpRewritePattern<TestCastOp> {
struct TestSelectiveReplacementPatternDriver
: public PassWrapper<TestSelectiveReplacementPatternDriver,
OperationPass<>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(
TestSelectiveReplacementPatternDriver)
StringRef getArgument() const final {
return "test-pattern-selective-replacement";
}

View File

@ -33,6 +33,8 @@ OpFoldResult TestInvolutionTraitSuccesfulOperationFolderOp::fold(
namespace {
struct TestTraitFolder
: public PassWrapper<TestTraitFolder, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestTraitFolder)
StringRef getArgument() const final { return "test-trait-folder"; }
StringRef getDescription() const final { return "Run trait folding"; }
void runOnOperation() override {

View File

@ -179,6 +179,8 @@ namespace {
struct TosaTestQuantUtilAPI
: public PassWrapper<TosaTestQuantUtilAPI, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TosaTestQuantUtilAPI)
StringRef getArgument() const final { return PASS_NAME; }
StringRef getDescription() const final {
return "TOSA Test: Exercise the APIs in QuantUtils.cpp.";

View File

@ -30,6 +30,8 @@ namespace {
struct TestVectorToVectorLowering
: public PassWrapper<TestVectorToVectorLowering, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestVectorToVectorLowering)
TestVectorToVectorLowering() = default;
TestVectorToVectorLowering(const TestVectorToVectorLowering &pass)
: PassWrapper(pass) {}
@ -103,6 +105,8 @@ private:
struct TestVectorContractionLowering
: public PassWrapper<TestVectorContractionLowering, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestVectorContractionLowering)
StringRef getArgument() const final {
return "test-vector-contraction-lowering";
}
@ -176,6 +180,8 @@ struct TestVectorContractionLowering
struct TestVectorTransposeLowering
: public PassWrapper<TestVectorTransposeLowering, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestVectorTransposeLowering)
StringRef getArgument() const final {
return "test-vector-transpose-lowering";
}
@ -248,6 +254,8 @@ struct TestVectorTransposeLowering
struct TestVectorUnrollingPatterns
: public PassWrapper<TestVectorUnrollingPatterns, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestVectorUnrollingPatterns)
StringRef getArgument() const final {
return "test-vector-unrolling-patterns";
}
@ -315,6 +323,8 @@ struct TestVectorUnrollingPatterns
struct TestVectorDistributePatterns
: public PassWrapper<TestVectorDistributePatterns, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestVectorDistributePatterns)
StringRef getArgument() const final {
return "test-vector-distribute-patterns";
}
@ -372,6 +382,8 @@ struct TestVectorDistributePatterns
struct TestVectorToLoopPatterns
: public PassWrapper<TestVectorToLoopPatterns, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestVectorToLoopPatterns)
StringRef getArgument() const final { return "test-vector-to-forloop"; }
StringRef getDescription() const final {
return "Test lowering patterns to break up a vector op into a for loop";
@ -430,6 +442,9 @@ struct TestVectorToLoopPatterns
struct TestVectorTransferUnrollingPatterns
: public PassWrapper<TestVectorTransferUnrollingPatterns,
OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(
TestVectorTransferUnrollingPatterns)
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<AffineDialect>();
}
@ -459,6 +474,9 @@ struct TestVectorTransferUnrollingPatterns
struct TestVectorTransferFullPartialSplitPatterns
: public PassWrapper<TestVectorTransferFullPartialSplitPatterns,
OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(
TestVectorTransferFullPartialSplitPatterns)
StringRef getArgument() const final {
return "test-vector-transfer-full-partial-split";
}
@ -496,6 +514,8 @@ struct TestVectorTransferFullPartialSplitPatterns
struct TestVectorTransferOpt
: public PassWrapper<TestVectorTransferOpt, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestVectorTransferOpt)
StringRef getArgument() const final { return "test-vector-transferop-opt"; }
StringRef getDescription() const final {
return "Test optimization transformations for transfer ops";
@ -506,6 +526,9 @@ struct TestVectorTransferOpt
struct TestVectorTransferLoweringPatterns
: public PassWrapper<TestVectorTransferLoweringPatterns,
OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(
TestVectorTransferLoweringPatterns)
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<tensor::TensorDialect, memref::MemRefDialect>();
}
@ -526,6 +549,9 @@ struct TestVectorTransferLoweringPatterns
struct TestVectorMultiReductionLoweringPatterns
: public PassWrapper<TestVectorMultiReductionLoweringPatterns,
OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(
TestVectorMultiReductionLoweringPatterns)
TestVectorMultiReductionLoweringPatterns() = default;
TestVectorMultiReductionLoweringPatterns(
const TestVectorMultiReductionLoweringPatterns &pass)
@ -557,6 +583,9 @@ struct TestVectorMultiReductionLoweringPatterns
struct TestVectorTransferCollapseInnerMostContiguousDims
: public PassWrapper<TestVectorTransferCollapseInnerMostContiguousDims,
OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(
TestVectorTransferCollapseInnerMostContiguousDims)
TestVectorTransferCollapseInnerMostContiguousDims() = default;
TestVectorTransferCollapseInnerMostContiguousDims(
const TestVectorTransferCollapseInnerMostContiguousDims &pass) = default;
@ -584,6 +613,9 @@ struct TestVectorTransferCollapseInnerMostContiguousDims
struct TestVectorReduceToContractPatternsPatterns
: public PassWrapper<TestVectorReduceToContractPatternsPatterns,
OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(
TestVectorReduceToContractPatternsPatterns)
StringRef getArgument() const final {
return "test-vector-reduction-to-contract-patterns";
}
@ -601,6 +633,9 @@ struct TestVectorReduceToContractPatternsPatterns
struct TestVectorTransferDropUnitDimsPatterns
: public PassWrapper<TestVectorTransferDropUnitDimsPatterns,
OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(
TestVectorTransferDropUnitDimsPatterns)
StringRef getArgument() const final {
return "test-vector-transfer-drop-unit-dims-patterns";
}
@ -617,6 +652,9 @@ struct TestVectorTransferDropUnitDimsPatterns
struct TestFlattenVectorTransferPatterns
: public PassWrapper<TestFlattenVectorTransferPatterns,
OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(
TestFlattenVectorTransferPatterns)
StringRef getArgument() const final {
return "test-vector-transfer-flatten-patterns";
}
@ -636,6 +674,8 @@ struct TestFlattenVectorTransferPatterns
struct TestVectorScanLowering
: public PassWrapper<TestVectorScanLowering, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestVectorScanLowering)
StringRef getArgument() const final { return "test-vector-scan-lowering"; }
StringRef getDescription() const final {
return "Test lowering patterns that lower the scan op in the vector "

View File

@ -16,6 +16,8 @@ using namespace test;
namespace {
struct TestElementsAttrInterface
: public PassWrapper<TestElementsAttrInterface, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestElementsAttrInterface)
StringRef getArgument() const final { return "test-elements-attr-interface"; }
StringRef getDescription() const final {
return "Test ElementsAttr interface support.";

View File

@ -20,6 +20,8 @@ namespace {
struct TestDiagnosticFilterPass
: public PassWrapper<TestDiagnosticFilterPass,
InterfacePass<SymbolOpInterface>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestDiagnosticFilterPass)
StringRef getArgument() const final { return "test-diagnostic-filter"; }
StringRef getDescription() const final {
return "Test diagnostic filtering support.";

View File

@ -92,6 +92,8 @@ private:
struct TestDominancePass
: public PassWrapper<TestDominancePass, InterfacePass<SymbolOpInterface>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestDominancePass)
StringRef getArgument() const final { return "test-print-dominance"; }
StringRef getDescription() const final {
return "Print the dominance information for multiple regions.";

View File

@ -17,6 +17,8 @@ namespace {
/// method.
struct TestFuncInsertArg
: public PassWrapper<TestFuncInsertArg, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestFuncInsertArg)
StringRef getArgument() const final { return "test-func-insert-arg"; }
StringRef getDescription() const final { return "Test inserting func args."; }
void runOnOperation() override {
@ -52,6 +54,8 @@ struct TestFuncInsertArg
/// This is a test pass for verifying FunctionOpInterface's insertResult method.
struct TestFuncInsertResult
: public PassWrapper<TestFuncInsertResult, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestFuncInsertResult)
StringRef getArgument() const final { return "test-func-insert-result"; }
StringRef getDescription() const final {
return "Test inserting func results.";
@ -84,6 +88,8 @@ struct TestFuncInsertResult
/// method.
struct TestFuncEraseArg
: public PassWrapper<TestFuncEraseArg, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestFuncEraseArg)
StringRef getArgument() const final { return "test-func-erase-arg"; }
StringRef getDescription() const final { return "Test erasing func args."; }
void runOnOperation() override {
@ -102,6 +108,8 @@ struct TestFuncEraseArg
/// This is a test pass for verifying FunctionOpInterface's eraseResult method.
struct TestFuncEraseResult
: public PassWrapper<TestFuncEraseResult, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestFuncEraseResult)
StringRef getArgument() const final { return "test-func-erase-result"; }
StringRef getDescription() const final {
return "Test erasing func results.";
@ -122,6 +130,8 @@ struct TestFuncEraseResult
/// This is a test pass for verifying FunctionOpInterface's setType method.
struct TestFuncSetType
: public PassWrapper<TestFuncSetType, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestFuncSetType)
StringRef getArgument() const final { return "test-func-set-type"; }
StringRef getDescription() const final {
return "Test FunctionOpInterface::setType.";

View File

@ -17,6 +17,8 @@ namespace {
/// application.
struct TestTypeInterfaces
: public PassWrapper<TestTypeInterfaces, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestTypeInterfaces)
StringRef getArgument() const final { return "test-type-interfaces"; }
StringRef getDescription() const final {
return "Test type interface support.";

View File

@ -18,6 +18,8 @@ namespace {
/// This is a test pass for verifying matchers.
struct TestMatchers
: public PassWrapper<TestMatchers, InterfacePass<FunctionOpInterface>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestMatchers)
void runOnOperation() override;
StringRef getArgument() const final { return "test-matchers"; }
StringRef getDescription() const final {

View File

@ -11,6 +11,21 @@
using namespace mlir;
namespace {
/// A simple structure which is used for testing as an underlying location in
/// OpaqueLoc.
struct MyLocation {
MyLocation() = default;
MyLocation(int id) : id(id) {}
int getId() { return id; }
int id{42};
};
} // namespace
MLIR_DECLARE_EXPLICIT_TYPE_ID(MyLocation *)
MLIR_DEFINE_EXPLICIT_TYPE_ID(MyLocation *)
namespace {
/// Pass that changes locations to opaque locations for each operation.
/// It also takes all operations that are not function operations or
@ -18,21 +33,13 @@ namespace {
/// locations.
struct TestOpaqueLoc
: public PassWrapper<TestOpaqueLoc, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestOpaqueLoc)
StringRef getArgument() const final { return "test-opaque-loc"; }
StringRef getDescription() const final {
return "Changes all leaf locations to opaque locations";
}
/// A simple structure which is used for testing as an underlying location in
/// OpaqueLoc.
struct MyLocation {
MyLocation() = default;
MyLocation(int id) : id(id) {}
int getId() { return id; }
int id{42};
};
void runOnOperation() override {
std::vector<std::unique_ptr<MyLocation>> myLocs;
int lastIt = 0;

View File

@ -15,6 +15,8 @@ namespace {
/// This pass illustrates the IR def-use chains through printing.
struct TestOperationEqualPass
: public PassWrapper<TestOperationEqualPass, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestOperationEqualPass)
StringRef getArgument() const final { return "test-operations-equality"; }
StringRef getDescription() const final { return "Test operations equality."; }
void runOnOperation() override {

View File

@ -15,6 +15,8 @@ namespace {
/// This pass illustrates the IR def-use chains through printing.
struct TestPrintDefUsePass
: public PassWrapper<TestPrintDefUsePass, OperationPass<>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestPrintDefUsePass)
StringRef getArgument() const final { return "test-print-defuse"; }
StringRef getDescription() const final { return "Test various printing."; }
void runOnOperation() override {

View File

@ -20,6 +20,8 @@ using namespace mlir;
namespace {
struct TestPrintInvalidPass
: public PassWrapper<TestPrintInvalidPass, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestPrintInvalidPass)
StringRef getArgument() const final { return "test-print-invalid"; }
StringRef getDescription() const final {
return "Test printing invalid ops.";

View File

@ -15,6 +15,8 @@ namespace {
/// This pass illustrates the IR nesting through printing.
struct TestPrintNestingPass
: public PassWrapper<TestPrintNestingPass, OperationPass<>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestPrintNestingPass)
StringRef getArgument() const final { return "test-print-nesting"; }
StringRef getDescription() const final { return "Test various printing."; }
// Entry point for the pass.

View File

@ -14,6 +14,8 @@ using namespace mlir;
namespace {
struct SideEffectsPass
: public PassWrapper<SideEffectsPass, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SideEffectsPass)
StringRef getArgument() const final { return "test-side-effects"; }
StringRef getDescription() const final {
return "Test side effects interfaces";

View File

@ -47,6 +47,8 @@ namespace {
/// Pass to test slice generated from slice analysis.
struct SliceAnalysisTestPass
: public PassWrapper<SliceAnalysisTestPass, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SliceAnalysisTestPass)
StringRef getArgument() const final { return "slice-analysis-test"; }
StringRef getDescription() const final {
return "Test Slice analysis functionality.";

View File

@ -17,6 +17,8 @@ namespace {
/// provided by the symbol table along with erasing from the symbol table.
struct SymbolUsesPass
: public PassWrapper<SymbolUsesPass, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SymbolUsesPass)
StringRef getArgument() const final { return "test-symbol-uses"; }
StringRef getDescription() const final {
return "Test detection of symbol uses";
@ -93,6 +95,8 @@ struct SymbolUsesPass
/// functionality provided by the symbol table.
struct SymbolReplacementPass
: public PassWrapper<SymbolReplacementPass, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(SymbolReplacementPass)
StringRef getArgument() const final { return "test-symbol-rauw"; }
StringRef getDescription() const final {
return "Test replacement of symbol uses";

View File

@ -16,6 +16,8 @@ using namespace test;
namespace {
struct TestRecursiveTypesPass
: public PassWrapper<TestRecursiveTypesPass, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestRecursiveTypesPass)
LogicalResult createIRWithTypes();
StringRef getArgument() const final { return "test-recursive-types"; }

View File

@ -152,6 +152,8 @@ namespace {
/// This pass exercises the different configurations of the IR visitors.
struct TestIRVisitorsPass
: public PassWrapper<TestIRVisitorsPass, OperationPass<>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestIRVisitorsPass)
StringRef getArgument() const final { return "test-ir-visitors"; }
StringRef getDescription() const final { return "Test various visitors."; }
void runOnOperation() override {

View File

@ -22,9 +22,10 @@ static std::string getStageDescription(const WalkStage &stage) {
namespace {
/// This pass exercises generic visitor with void callbacks and prints the order
/// and stage in which operations are visited.
class TestGenericIRVisitorPass
struct TestGenericIRVisitorPass
: public PassWrapper<TestGenericIRVisitorPass, OperationPass<>> {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestGenericIRVisitorPass)
StringRef getArgument() const final { return "test-generic-ir-visitors"; }
StringRef getDescription() const final { return "Test generic IR visitors."; }
void runOnOperation() override {
@ -46,9 +47,11 @@ public:
/// This pass exercises the generic visitor with non-void callbacks and prints
/// the order and stage in which operations are visited. It will interrupt the
/// walk based on attributes peesent in the IR.
class TestGenericIRVisitorInterruptPass
struct TestGenericIRVisitorInterruptPass
: public PassWrapper<TestGenericIRVisitorInterruptPass, OperationPass<>> {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(
TestGenericIRVisitorInterruptPass)
StringRef getArgument() const final {
return "test-generic-ir-visitors-interrupt";
}

View File

@ -20,6 +20,8 @@ namespace {
class TestDynamicPipelinePass
: public PassWrapper<TestDynamicPipelinePass, OperationPass<>> {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestDynamicPipelinePass)
StringRef getArgument() const final { return "test-dynamic-pipeline"; }
StringRef getDescription() const final {
return "Tests the dynamic pipeline feature by applying "

View File

@ -17,6 +17,8 @@ using namespace mlir;
namespace {
struct TestModulePass
: public PassWrapper<TestModulePass, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestModulePass)
void runOnOperation() final {}
StringRef getArgument() const final { return "test-module-pass"; }
StringRef getDescription() const final {
@ -25,15 +27,19 @@ struct TestModulePass
};
struct TestFunctionPass
: public PassWrapper<TestFunctionPass, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestFunctionPass)
void runOnOperation() final {}
StringRef getArgument() const final { return "test-function-pass"; }
StringRef getDescription() const final {
return "Test a function pass in the pass manager";
}
};
class TestInterfacePass
struct TestInterfacePass
: public PassWrapper<TestInterfacePass,
InterfacePass<FunctionOpInterface>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestInterfacePass)
void runOnOperation() final {
getOperation()->emitRemark() << "Executing interface pass on operation";
}
@ -43,9 +49,10 @@ class TestInterfacePass
"pass manager";
}
};
class TestOptionsPass
struct TestOptionsPass
: public PassWrapper<TestOptionsPass, OperationPass<FuncOp>> {
public:
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestOptionsPass)
struct Options : public PassPipelineOptions<Options> {
ListOption<int> listOption{*this, "list",
llvm::cl::desc("Example list option")};
@ -78,8 +85,10 @@ public:
/// A test pass that always aborts to enable testing the crash recovery
/// mechanism of the pass manager.
class TestCrashRecoveryPass
struct TestCrashRecoveryPass
: public PassWrapper<TestCrashRecoveryPass, OperationPass<>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestCrashRecoveryPass)
void runOnOperation() final { abort(); }
StringRef getArgument() const final { return "test-pass-crash"; }
StringRef getDescription() const final {
@ -89,7 +98,9 @@ class TestCrashRecoveryPass
/// A test pass that always fails to enable testing the failure recovery
/// mechanisms of the pass manager.
class TestFailurePass : public PassWrapper<TestFailurePass, OperationPass<>> {
struct TestFailurePass : public PassWrapper<TestFailurePass, OperationPass<>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestFailurePass)
void runOnOperation() final { signalPassFailure(); }
StringRef getArgument() const final { return "test-pass-failure"; }
StringRef getDescription() const final {
@ -99,9 +110,11 @@ class TestFailurePass : public PassWrapper<TestFailurePass, OperationPass<>> {
/// A test pass that always fails to enable testing the failure recovery
/// mechanisms of the pass manager.
class TestInvalidParentPass
struct TestInvalidParentPass
: public PassWrapper<TestInvalidParentPass,
InterfacePass<FunctionOpInterface>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestInvalidParentPass)
StringRef getArgument() const final { return "test-pass-invalid-parent"; }
StringRef getDescription() const final {
return "Test a pass in the pass manager that makes the parent operation "
@ -121,6 +134,8 @@ class TestInvalidParentPass
/// A test pass that contains a statistic.
struct TestStatisticPass
: public PassWrapper<TestStatisticPass, OperationPass<>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestStatisticPass)
TestStatisticPass() = default;
TestStatisticPass(const TestStatisticPass &) {}
StringRef getArgument() const final { return "test-stats-pass"; }

View File

@ -22,6 +22,8 @@ namespace {
/// "crashOp" in the input MLIR file and crashes the mlir-opt tool if the
/// operation is found.
struct TestReducer : public PassWrapper<TestReducer, OperationPass<>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestReducer)
StringRef getArgument() const final { return "test-mlir-reducer"; }
StringRef getDescription() const final {
return "Tests MLIR Reduce tool by generating failures";

View File

@ -67,6 +67,8 @@ static void customRewriter(ArrayRef<PDLValue> args, PatternRewriter &rewriter,
namespace {
struct TestPDLByteCodePass
: public PassWrapper<TestPDLByteCodePass, OperationPass<ModuleOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestPDLByteCodePass)
StringRef getArgument() const final { return "test-pdl-bytecode-pass"; }
StringRef getDescription() const final {
return "Test PDL ByteCode functionality";

View File

@ -15,6 +15,8 @@ namespace {
/// Simple constant folding pass.
struct TestConstantFold
: public PassWrapper<TestConstantFold, OperationPass<>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestConstantFold)
StringRef getArgument() const final { return "test-constant-fold"; }
StringRef getDescription() const final {
return "Test operation constant folding";

View File

@ -24,6 +24,8 @@ namespace {
/// `was_sunk` into the first region of `test.sink_target` ops.
struct TestControlFlowSinkPass
: public PassWrapper<TestControlFlowSinkPass, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestControlFlowSinkPass)
/// Get the command-line argument of the test pass.
StringRef getArgument() const final { return "test-control-flow-sink"; }
/// Get the description of the test pass.

View File

@ -25,6 +25,8 @@ using namespace test;
namespace {
struct Inliner : public PassWrapper<Inliner, OperationPass<FuncOp>> {
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(Inliner)
StringRef getArgument() const final { return "test-inline"; }
StringRef getDescription() const final {
return "Test inlining region calls";

View File

@ -663,8 +663,9 @@ bool DefGenerator::emitDecls(StringRef selectedDialect) {
// each of these.
for (const AttrOrTypeDef &def : defs)
if (!def.getDialect().getCppNamespace().empty())
os << "DECLARE_EXPLICIT_TYPE_ID(" << def.getDialect().getCppNamespace()
<< "::" << def.getCppClassName() << ")\n";
os << "MLIR_DECLARE_EXPLICIT_TYPE_ID("
<< def.getDialect().getCppNamespace() << "::" << def.getCppClassName()
<< ")\n";
return false;
}
@ -827,8 +828,9 @@ bool DefGenerator::emitDefs(StringRef selectedDialect) {
}
// Emit the TypeID explicit specializations to have a single symbol def.
if (!def.getDialect().getCppNamespace().empty())
os << "DEFINE_EXPLICIT_TYPE_ID(" << def.getDialect().getCppNamespace()
<< "::" << def.getCppClassName() << ")\n";
os << "MLIR_DEFINE_EXPLICIT_TYPE_ID("
<< def.getDialect().getCppNamespace() << "::" << def.getCppClassName()
<< ")\n";
}
Dialect firstDialect = defs.front().getDialect();

View File

@ -236,7 +236,7 @@ emitDialectDecl(Dialect &dialect,
os << "};\n";
}
if (!dialect.getCppNamespace().empty())
os << "DECLARE_EXPLICIT_TYPE_ID(" << dialect.getCppNamespace()
os << "MLIR_DECLARE_EXPLICIT_TYPE_ID(" << dialect.getCppNamespace()
<< "::" << dialect.getCppClassName() << ")\n";
}
@ -273,7 +273,7 @@ static const char *const dialectDestructorStr = R"(
static void emitDialectDef(Dialect &dialect, raw_ostream &os) {
// Emit the TypeID explicit specializations to have a single symbol def.
if (!dialect.getCppNamespace().empty())
os << "DEFINE_EXPLICIT_TYPE_ID(" << dialect.getCppNamespace()
os << "MLIR_DEFINE_EXPLICIT_TYPE_ID(" << dialect.getCppNamespace()
<< "::" << dialect.getCppClassName() << ")\n";
// Emit all nested namespaces.

View File

@ -2778,7 +2778,7 @@ static void emitOpClasses(const RecordKeeper &recordKeeper,
}
// Emit the TypeID explicit specialization to have a single definition.
if (!op.getCppNamespace().empty())
os << "DECLARE_EXPLICIT_TYPE_ID(" << op.getCppNamespace()
os << "MLIR_DECLARE_EXPLICIT_TYPE_ID(" << op.getCppNamespace()
<< "::" << op.getCppClassName() << ")\n\n";
} else {
{
@ -2789,7 +2789,7 @@ static void emitOpClasses(const RecordKeeper &recordKeeper,
}
// Emit the TypeID explicit specialization to have a single definition.
if (!op.getCppNamespace().empty())
os << "DEFINE_EXPLICIT_TYPE_ID(" << op.getCppNamespace()
os << "MLIR_DEFINE_EXPLICIT_TYPE_ID(" << op.getCppNamespace()
<< "::" << op.getCppClassName() << ")\n\n";
}
}

View File

@ -79,6 +79,11 @@ public:
{4}
}
/// Explicitly declare the TypeID for this class. We declare an explicit private
/// instantiation because Pass classes should only be visible by the current
/// library.
MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID({0}Base<DerivedT>)
protected:
)";

Some files were not shown because too many files have changed in this diff Show More