Complete Lab2 IR generation and document process
This commit is contained in:
@@ -15,10 +15,18 @@ ConstantInt* Context::GetConstInt(int v) {
|
||||
return inserted->second.get();
|
||||
}
|
||||
|
||||
ConstantFloat* Context::GetConstFloat(float v) {
|
||||
auto it = const_floats_.find(v);
|
||||
if (it != const_floats_.end()) return it->second.get();
|
||||
auto inserted =
|
||||
const_floats_
|
||||
.emplace(v, std::make_unique<ConstantFloat>(Type::GetFloatType(), v))
|
||||
.first;
|
||||
return inserted->second.get();
|
||||
}
|
||||
|
||||
std::string Context::NextTemp() {
|
||||
std::ostringstream oss;
|
||||
oss << "%" << ++temp_index_;
|
||||
return oss.str();
|
||||
return "t" + std::to_string(++temp_index_);
|
||||
}
|
||||
|
||||
} // namespace ir
|
||||
|
||||
Reference in New Issue
Block a user