blob: a819b532ae471eb6e91e9d25ab37b8074b829f3c (
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#ifndef _WILLOW_IR_VALUE_HPP
#define _WILLOW_IR_VALUE_HPP
// #include <willow/IR/Instruction.h>
#include <willow/IR/Types.h>
#include <string>
#include <string_view>
#include <vector>
namespace willow {
class Instruction;
enum class ValueType {
Result, ///< the identified result of an instruction
Parameter, ///< the named parameter to a function
Literal, ///< an anonymous typed literal
};
/// An SSA value that may be used.
class Value {
std::string name;
ValueType value_type;
Type type;
// Instructions that use this value
std::vector<Instruction *> uses;
public:
Value(std::string name, Type type) : name(std::move(name)), type(type) {}
explicit Value(Type type) : type(type) {}
bool hasName() const { return !name.empty(); }
std::string_view getName() const { return name; }
void setName(std::string name) { this->name = std::move(name); }
Type getType() const { return type; }
ValueType getValueType() const { return value_type; }
bool isVoid() const { return type->is }
const std::vector<Instruction *> &getUses() const { return uses; }
std::vector<Instruction *> &getUses() { return uses; }
};
} // namespace willow
#endif // _WILLOW_IR_VALUE_HPP
|