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