mini-llvm
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
PtrConstant.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
3
#pragma once
4
5
#include <cstdint>
6
#include <string>
7
#include <utility>
8
9
#include "
mini-llvm/mir/Constant.h
"
10
#include "
mini-llvm/mir/ConstantVisitor.h
"
11
#include "
mini-llvm/mir/GlobalValue.h
"
12
#include "
mini-llvm/utils/Compiler.h
"
13
14
namespace
mini_llvm::mir
{
15
16
class
MINI_LLVM_EXPORT
PtrConstant
final :
public
Constant
{
17
public
:
18
PtrConstant
(
int
ptrSize
, std::pair<GlobalValue *, int64_t>
value
)
19
: ptrSize_(
ptrSize
), value_(
value
) {}
20
21
PtrConstant
(
int
ptrSize
,
GlobalValue
*basePtr, int64_t offset)
22
: ptrSize_(
ptrSize
), value_(basePtr, offset) {}
23
24
int
ptrSize
()
const
{
25
return
ptrSize_;
26
}
27
28
std::pair<GlobalValue *, int64_t>
value
()
const
{
29
return
value_;
30
}
31
32
void
setValue
(std::pair<GlobalValue *, int64_t>
value
) {
33
value_ =
value
;
34
}
35
36
void
setValue
(
GlobalValue
*basePtr, int64_t offset) {
37
value_ = {basePtr, offset};
38
}
39
40
int
size
()
const override
{
41
return
ptrSize_;
42
}
43
44
std::string
format
()
const override
;
45
46
void
accept
(
ConstantVisitor
&visitor)
override
{
47
visitor.
visitPtrConstant
(*
this
);
48
}
49
50
void
accept
(
ConstantVisitor
&visitor)
const override
{
51
visitor.
visitPtrConstant
(*
this
);
52
}
53
54
private
:
55
int
ptrSize_;
56
std::pair<GlobalValue *, int64_t> value_;
57
};
58
59
}
// namespace mini_llvm::mir
Compiler.h
MINI_LLVM_EXPORT
#define MINI_LLVM_EXPORT
Definition
Compiler.h:17
mini_llvm::mir::ConstantVisitor
Definition
ConstantVisitor.h:24
mini_llvm::mir::ConstantVisitor::visitPtrConstant
virtual void visitPtrConstant(PtrConstant &C)
Definition
ConstantVisitor.h:45
mini_llvm::mir::Constant::Constant
Constant()=default
mini_llvm::mir::GlobalValue
Definition
GlobalValue.h:15
mini_llvm::mir::PtrConstant::format
std::string format() const override
mini_llvm::mir::PtrConstant::setValue
void setValue(std::pair< GlobalValue *, int64_t > value)
Definition
PtrConstant.h:32
mini_llvm::mir::PtrConstant::setValue
void setValue(GlobalValue *basePtr, int64_t offset)
Definition
PtrConstant.h:36
mini_llvm::mir::PtrConstant::accept
void accept(ConstantVisitor &visitor) override
Definition
PtrConstant.h:46
mini_llvm::mir::PtrConstant::accept
void accept(ConstantVisitor &visitor) const override
Definition
PtrConstant.h:50
mini_llvm::mir::PtrConstant::size
int size() const override
Definition
PtrConstant.h:40
mini_llvm::mir::PtrConstant::value
std::pair< GlobalValue *, int64_t > value() const
Definition
PtrConstant.h:28
mini_llvm::mir::PtrConstant::PtrConstant
PtrConstant(int ptrSize, std::pair< GlobalValue *, int64_t > value)
Definition
PtrConstant.h:18
mini_llvm::mir::PtrConstant::ptrSize
int ptrSize() const
Definition
PtrConstant.h:24
mini_llvm::mir::PtrConstant::PtrConstant
PtrConstant(int ptrSize, GlobalValue *basePtr, int64_t offset)
Definition
PtrConstant.h:21
ConstantVisitor.h
Constant.h
GlobalValue.h
mini_llvm::mir
Definition
BasicBlock.h:22
include
mini-llvm
mir
Constant
PtrConstant.h
Generated by
1.17.0