blob: 703e8076ca6a7a54a9ba534b0785009717bce301 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#include <willow/IR/Constant.h>
#include <willow/IR/Value.h>
#include <cassert>
namespace willow {
void Value::addUse(Instruction *instruction) {
auto [it, inserted] = uses.try_emplace(instruction, 1);
if (!inserted)
it->second += 1;
}
void Value::delUse(Instruction *instruction) {
assert(uses.contains(instruction) && "No uses to remove");
auto it = uses.find(instruction);
it->second -= 1;
if (it->second == 0)
uses.erase(it);
}
} // namespace willow
|