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