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.
24 lines
722 B
24 lines
722 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::type() const { return type_; }
|
|
|
|
const std::string& Value::name() const { return name_; }
|
|
|
|
void Value::set_name(std::string n) { name_ = std::move(n); }
|
|
|
|
void Value::AddUser(Instruction* user) { users_.push_back(user); }
|
|
|
|
const std::vector<Instruction*>& Value::users() const { return users_; }
|
|
|
|
ConstantInt::ConstantInt(int v) : Value(Type::Int32(), ""), value_(v) {}
|
|
|
|
} // namespace ir
|