forked from NUDT-compiler/nudt-compiler-cpp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.2 KiB
46 lines
1.2 KiB
// 当前仅支持 void、i32 和 i32*。
|
|
#include "ir/IR.h"
|
|
|
|
namespace ir {
|
|
|
|
Type::Type(Kind k) : kind_(k) {}
|
|
|
|
const std::shared_ptr<Type>& Type::GetVoidType() {
|
|
static const std::shared_ptr<Type> type = std::make_shared<Type>(Kind::Void);
|
|
return type;
|
|
}
|
|
|
|
const std::shared_ptr<Type>& Type::GetInt32Type() {
|
|
static const std::shared_ptr<Type> type = std::make_shared<Type>(Kind::Int32);
|
|
return type;
|
|
}
|
|
|
|
const std::shared_ptr<Type>& Type::GetPtrInt32Type() {
|
|
static const std::shared_ptr<Type> type = std::make_shared<Type>(Kind::PtrInt32);
|
|
return type;
|
|
}
|
|
|
|
const std::shared_ptr<Type>& Type::GetFloat32Type() {
|
|
static const std::shared_ptr<Type> type = std::make_shared<Type>(Kind::Float32);
|
|
return type;
|
|
}
|
|
|
|
const std::shared_ptr<Type>& Type::GetPtrFloat32Type() {
|
|
static const std::shared_ptr<Type> type = std::make_shared<Type>(Kind::PtrFloat32);
|
|
return type;
|
|
}
|
|
|
|
Type::Kind Type::GetKind() const { return kind_; }
|
|
|
|
bool Type::IsVoid() const { return kind_ == Kind::Void; }
|
|
|
|
bool Type::IsInt32() const { return kind_ == Kind::Int32; }
|
|
|
|
bool Type::IsPtrInt32() const { return kind_ == Kind::PtrInt32; }
|
|
|
|
bool Type::IsFloat32() const { return kind_ == Kind::Float32; }
|
|
|
|
bool Type::IsPtrFloat32() const { return kind_ == Kind::PtrFloat32; }
|
|
|
|
} // namespace ir
|