mini-llvm 0.1.0
Loading...
Searching...
No Matches
Ptr.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2
3#pragma once
4
5#include <cstdint>
6#include <cstdlib>
7#include <memory>
8#include <string>
9#include <typeinfo>
10
11#include "mini-llvm/ir/Type.h"
15
16namespace mini_llvm::ir {
17
18class Constant;
19
21public:
22 int size() const override {
23 abort();
24 }
25
26 int alignment() const override {
27 abort();
28 }
29
30 int size(int pointerSize) const override {
31 return pointerSize;
32 }
33
34 int alignment(int pointerAlignment) const override {
35 return pointerAlignment;
36 }
37
38 std::unique_ptr<Constant> zeroValue() const override;
39
40 std::unique_ptr<Constant> constant(int64_t) const override {
41 abort();
42 }
43
44 std::unique_ptr<Type> promoted() const override {
45 abort();
46 }
47
48 std::unique_ptr<Type> demoted() const override {
49 abort();
50 }
51
52 std::string format() const override {
53 return "ptr";
54 }
55
56 std::unique_ptr<Type> clone() const override {
57 return std::make_unique<Ptr>();
58 }
59
60 void accept(TypeVisitor &visitor) override {
61 visitor.visitPtr(*this);
62 }
63
64 void accept(TypeVisitor &visitor) const override {
65 visitor.visitPtr(*this);
66 }
67
68protected:
69 bool equals(const Type &other) const override {
70 return typeid(*this) == typeid(other);
71 }
72};
73
74} // namespace mini_llvm::ir
#define MINI_LLVM_EXPORT
Definition Compiler.h:17
Definition Constant.h:13
Definition IntegerOrPointerType.h:10
Definition Ptr.h:20
std::unique_ptr< Type > demoted() const override
Definition Ptr.h:48
std::unique_ptr< Constant > zeroValue() const override
std::string format() const override
Definition Ptr.h:52
int alignment(int pointerAlignment) const override
Definition Ptr.h:34
bool equals(const Type &other) const override
Definition Ptr.h:69
int alignment() const override
Definition Ptr.h:26
int size(int pointerSize) const override
Definition Ptr.h:30
std::unique_ptr< Type > promoted() const override
Definition Ptr.h:44
void accept(TypeVisitor &visitor) const override
Definition Ptr.h:64
std::unique_ptr< Type > clone() const override
Definition Ptr.h:56
void accept(TypeVisitor &visitor) override
Definition Ptr.h:60
std::unique_ptr< Constant > constant(int64_t) const override
Definition Ptr.h:40
int size() const override
Definition Ptr.h:22
Definition TypeVisitor.h:25
virtual void visitPtr(Ptr &type)
Definition TypeVisitor.h:47
Definition Type.h:18
Definition Argument.h:13