-
Notifications
You must be signed in to change notification settings - Fork 3
/
group.hpp
46 lines (38 loc) · 948 Bytes
/
group.hpp
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* Copyright (c) 2020 Romain Dolbeau <[email protected]>
* MIT License
* See the LICENSE file at the top level of this software distribution for details.
*/
#ifndef __GROUP_HPP__
#define __GROUP_HPP__
#include <set>
#include "inst.hpp"
class group {
public:
const std::string name;
std::set<const instruction*> instructions;
std::set<std::string> opnames;
group(std::string n) : name(n) {
}
void add(const instruction *inst) {
instructions.insert(inst);
opnames.insert(inst->opname);
}
bool match(const instruction *inst) {
return inst->group.compare(name) == 0;
}
bool contains(const instruction *inst) {
for (const instruction* check : instructions) {
if (*check == *inst)
return true;
}
return false;
}
bool operator ==(const group &b) const {
return name.compare(b.name) == 0;
}
std::string ctrlName() const {
return "CTRL_" + name;
}
};
#endif // __GROUP_HPP__