未验证 提交 c71198f8 编写于 作者: A Aurelius84 提交者: GitHub

[IR]Polish code in builtin type declaration (#54275)

* [IR]Polish code in builtin type declaration

* fix typo
上级 5b4d786b
...@@ -34,6 +34,9 @@ namespace ir { ...@@ -34,6 +34,9 @@ namespace ir {
/// Type fp32 = Float32Type::get(ctx); /// Type fp32 = Float32Type::get(ctx);
/// \endcode /// \endcode
/// ///
// NOTE(dev): Currently BF16 and Int8 are not considered as a cached member
// in IrContextImpl because they are not widely used.
class BFloat16Type : public Type { class BFloat16Type : public Type {
public: public:
using Type::Type; using Type::Type;
...@@ -41,33 +44,6 @@ class BFloat16Type : public Type { ...@@ -41,33 +44,6 @@ class BFloat16Type : public Type {
DECLARE_TYPE_UTILITY_FUNCTOR(BFloat16Type, TypeStorage); DECLARE_TYPE_UTILITY_FUNCTOR(BFloat16Type, TypeStorage);
}; };
class Float16Type : public Type {
public:
using Type::Type;
DECLARE_TYPE_UTILITY_FUNCTOR(Float16Type, TypeStorage);
static Float16Type get(IrContext *context);
};
class Float32Type : public Type {
public:
using Type::Type;
DECLARE_TYPE_UTILITY_FUNCTOR(Float32Type, TypeStorage);
static Float32Type get(IrContext *context);
};
class Float64Type : public Type {
public:
using Type::Type;
DECLARE_TYPE_UTILITY_FUNCTOR(Float64Type, TypeStorage);
static Float64Type get(IrContext *context);
};
class Int8Type : public Type { class Int8Type : public Type {
public: public:
using Type::Type; using Type::Type;
...@@ -75,42 +51,6 @@ class Int8Type : public Type { ...@@ -75,42 +51,6 @@ class Int8Type : public Type {
DECLARE_TYPE_UTILITY_FUNCTOR(Int8Type, TypeStorage); DECLARE_TYPE_UTILITY_FUNCTOR(Int8Type, TypeStorage);
}; };
class Int16Type : public Type {
public:
using Type::Type;
DECLARE_TYPE_UTILITY_FUNCTOR(Int16Type, TypeStorage);
static Int16Type get(IrContext *context);
};
class Int32Type : public Type {
public:
using Type::Type;
DECLARE_TYPE_UTILITY_FUNCTOR(Int32Type, TypeStorage);
static Int32Type get(IrContext *context);
};
class Int64Type : public Type {
public:
using Type::Type;
DECLARE_TYPE_UTILITY_FUNCTOR(Int64Type, TypeStorage);
static Int64Type get(IrContext *context);
};
class BoolType : public Type {
public:
using Type::Type;
DECLARE_TYPE_UTILITY_FUNCTOR(BoolType, TypeStorage);
static BoolType get(IrContext *context);
};
class VectorType : public Type { class VectorType : public Type {
public: public:
using Type::Type; using Type::Type;
...@@ -126,4 +66,28 @@ class VectorType : public Type { ...@@ -126,4 +66,28 @@ class VectorType : public Type {
Type operator[](size_t index) const { return data()[index]; } Type operator[](size_t index) const { return data()[index]; }
}; };
#define DECLARE_BUILTIN_TYPE(__name) \
class __name##Type : public Type { \
public: \
using Type::Type; \
\
DECLARE_TYPE_UTILITY_FUNCTOR(__name##Type, TypeStorage); \
\
static __name##Type get(IrContext *context); \
};
#define FOREACH_BUILTIN_TYPE(__macro) \
__macro(Float16); \
__macro(Float32); \
__macro(Float64); \
__macro(Int16); \
__macro(Int32); \
__macro(Int64); \
__macro(Bool);
FOREACH_BUILTIN_TYPE(DECLARE_BUILTIN_TYPE)
#undef FOREACH_BUILTIN_TYPE
#undef DECLARE_BUILTIN_TYPE
} // namespace ir } // namespace ir
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册