blob: d880913446dfaa488930317d4d19aedf604efa21 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#include <willow/IR/ConstantPool.h>
#include <cassert>
namespace willow {
ConstantInt *ConstantPool::getInt(Type ty, uint64_t val) {
assert(ty.isInt() && "Expected integer type");
ConstantInt::Key &&k{ty.getImpl(), ty.getNumBits()};
std::lock_guard<std::mutex> lock(int_mutex);
auto [it, _] = icache.try_emplace(k, std::make_unique<ConstantInt>(ty, val));
return it->second.get();
}
PoisonVal *ConstantPool::getPoisonVal(Type ty) {
std::lock_guard<std::mutex> lock(poison_mutex);
auto [it, _] =
pcache.try_emplace(ty.getImpl(), std::make_unique<PoisonVal>(ty));
return it->second.get();
}
}
|