mini-llvm 0.1.0
Loading...
Searching...
No Matches
Load.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"
13#include "mini-llvm/ir/Use.h"
14#include "mini-llvm/ir/Value.h"
16
17namespace mini_llvm::ir {
18
19class MINI_LLVM_EXPORT Load final : public Instruction {
20public:
21 Load(std::unique_ptr<Type> type, std::shared_ptr<Value> addr)
22 : type_(std::move(type)), ptr_(this, std::move(addr)) {}
23
24 template <typename Self>
25 auto &ptr(this Self &&self) {
26 return self.ptr_;
27 }
28
29 std::unordered_set<const UseBase *> operands() const override {
30 return {&ptr()};
31 }
32
33 void accept(InstructionVisitor &visitor) override {
34 visitor.visitLoad(*this);
35 }
36
37 void accept(InstructionVisitor &visitor) const override {
38 visitor.visitLoad(*this);
39 }
40
41 bool isWellFormed() const override;
42
43 std::unique_ptr<Type> type() const override {
44 return type_->clone();
45 }
46
47 std::string format() const override;
48 std::unique_ptr<Value> clone() const override;
49
50private:
51 std::unique_ptr<Type> type_;
52 Use<Value> ptr_;
53};
54
55} // namespace mini_llvm::ir
#define MINI_LLVM_EXPORT
Definition Compiler.h:17
Definition InstructionVisitor.h:58
virtual void visitLoad(Load &I)
Definition InstructionVisitor.h:93
Definition Instruction.h:22
bool isWellFormed() const override
std::unique_ptr< Value > clone() const override
std::unordered_set< const UseBase * > operands() const override
Definition Load.h:29
void accept(InstructionVisitor &visitor) const override
Definition Load.h:37
void accept(InstructionVisitor &visitor) override
Definition Load.h:33
auto & ptr(this Self &&self)
Definition Load.h:25
std::unique_ptr< Type > type() const override
Definition Load.h:43
std::string format() const override
Load(std::unique_ptr< Type > type, std::shared_ptr< Value > addr)
Definition Load.h:21
Definition Use.h:44
Definition Argument.h:13