summaryrefslogtreecommitdiff
path: root/willow/include/willow/IR/Instruction.h
blob: c7756bb1d26c538626c2e363e05c5cdb62e9fe39 (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
51
52
53
54
55
56
57
58
59
60
61
#ifndef WILLOW_IR_INSTRUCTION_HPP
#define WILLOW_IR_INSTRUCTION_HPP

#include <willow/IR/Value.h>

namespace willow {

class Value;

/// Defines an SSA value or control-flow effect.
class Instruction : Value {
public:
  enum class Op {
    Const,

    Add,
    Mul,
    Sub,
    Div,
    Mod,
    Shl,
    Shr,

    Eq,
    Lt,
    Gt,
    Le,
    Ge,

    Not,
    And,
    Or,

    Jmp,
    Br,
    Call,
    Ret,

    Phi,
    Alloca
  };

private:
  class BasicBlock *parent = nullptr;
  Op op;

public:
  /// \param op Opcode for this instruction.
  /// \param val SSA value defined by this instruction (may be nullptr).
  Instruction(Op op, Value *val);

  Op getOp() const { return op; }

  const Value *getValue() const { return value; }
  Value *getValue() { return value; }
  bool hasValue() const { return value; }
};

} // namespace willow

#endif // WILLOW_IR_INST_HPP