mini-llvm 0.1.0
Loading...
Searching...
No Matches
Store.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2
3#pragma once
4
5#include <memory>
6#include <string>
7#include <unordered_set>
8#include <utility>
9
12#include "mini-llvm/ir/Type.h"
14#include "mini-llvm/ir/Use.h"
15#include "mini-llvm/ir/Value.h"
17
18namespace mini_llvm::ir {
19
20class MINI_LLVM_EXPORT Store final : public Instruction {
21public:
22 Store(std::shared_ptr<Value> value, std::shared_ptr<Value> addr)
23 : value_(this, std::move(value)), ptr_(this, std::move(addr)) {}
24
25 template <typename Self>
26 auto &value(this Self &&self) {
27 return self.value_;
28 }
29
30 template <typename Self>
31 auto &ptr(this Self &&self) {
32 return self.ptr_;
33 }
34
35 std::unordered_set<const UseBase *> operands() const override {
36 return {&value(), &ptr()};
37 }
38
39 void accept(InstructionVisitor &visitor) override {
40 visitor.visitStore(*this);
41 }
42
43 void accept(InstructionVisitor &visitor) const override {
44 visitor.visitStore(*this);
45 }
46
47 bool isWellFormed() const override;
48
49 std::unique_ptr<Type> type() const override {
50 return std::make_unique<Void>();
51 }
52
53 std::string format() const override;
54 std::unique_ptr<Value> clone() const override;
55
56private:
57 Use<Value> value_;
58 Use<Value> ptr_;
59};
60
61} // namespace mini_llvm::ir
#define MINI_LLVM_EXPORT
Definition Compiler.h:17
Definition InstructionVisitor.h:58
virtual void visitStore(Store &I)
Definition InstructionVisitor.h:106
Definition Instruction.h:22
std::string format() const override
std::unique_ptr< Type > type() const override
Definition Store.h:49
auto & value(this Self &&self)
Definition Store.h:26
std::unique_ptr< Value > clone() const override
auto & ptr(this Self &&self)
Definition Store.h:31
std::unordered_set< const UseBase * > operands() const override
Definition Store.h:35
void accept(InstructionVisitor &visitor) const override
Definition Store.h:43
void accept(InstructionVisitor &visitor) override
Definition Store.h:39
bool isWellFormed() const override
Store(std::shared_ptr< Value > value, std::shared_ptr< Value > addr)
Definition Store.h:22
Definition Use.h:44
Definition Argument.h:13