refactor(irgen): IR改成alloca和store形式

This commit is contained in:
jing
2026-03-01 15:36:50 +08:00
parent 29bf99727f
commit 730280abb8
10 changed files with 180 additions and 10 deletions

View File

@@ -28,6 +28,13 @@ const std::shared_ptr<Type>& Context::Int32() {
return int32_;
}
const std::shared_ptr<Type>& Context::PtrInt32() {
if (!ptr_i32_) {
ptr_i32_ = std::make_shared<Type>(Type::Kind::PtrInt32);
}
return ptr_i32_;
}
ConstantInt* Context::GetConstInt(int v) {
auto it = const_ints_.find(v);
if (it != const_ints_.end()) return it->second.get();
@@ -38,7 +45,7 @@ ConstantInt* Context::GetConstInt(int v) {
std::string Context::NextTemp() {
std::ostringstream oss;
oss << "%t" << temp_index_++;
oss << "%" << ++temp_index_;
return oss.str();
}