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.
25 lines
760 B
25 lines
760 B
// SSA 值体系抽象:
|
|
// - 常量、参数、指令结果等统一为 Value
|
|
// - 提供类型信息与使用/被使用关系(按需要实现)
|
|
#include "ir/IR.h"
|
|
|
|
namespace ir {
|
|
|
|
Value::Value(std::shared_ptr<Type> ty, std::string name)
|
|
: type_(std::move(ty)), name_(std::move(name)) {}
|
|
|
|
const std::shared_ptr<Type>& Value::GetType() const { return type_; }
|
|
|
|
const std::string& Value::GetName() const { return name_; }
|
|
|
|
void Value::SetName(std::string n) { name_ = std::move(n); }
|
|
|
|
void Value::AddUser(Instruction* user) { users_.push_back(user); }
|
|
|
|
const std::vector<Instruction*>& Value::GetUsers() const { return users_; }
|
|
|
|
ConstantInt::ConstantInt(std::shared_ptr<Type> ty, int v)
|
|
: Value(std::move(ty), ""), value_(v) {}
|
|
|
|
} // namespace ir
|