mini-llvm
0.1.0
Toggle main menu visibility
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
10
#include "
mini-llvm/common/ExtensionMode.h
"
11
#include "
mini-llvm/mir/ImmediateOperand.h
"
12
#include "
mini-llvm/mir/Instruction.h
"
13
#include "
mini-llvm/mir/InstructionVisitor.h
"
14
#include "
mini-llvm/mir/MemoryOperand.h
"
15
#include "
mini-llvm/mir/Register.h
"
16
#include "
mini-llvm/mir/RegisterClass.h
"
17
#include "
mini-llvm/mir/RegisterOperand.h
"
18
#include "
mini-llvm/utils/Compiler.h
"
19
#include "
mini-llvm/utils/Memory.h
"
20
21
namespace
mini_llvm::mir
{
22
23
class
MINI_LLVM_EXPORT
Load
:
public
Instruction
{
24
public
:
25
Load
(
int
width
,
26
std::shared_ptr<Register>
dst
,
27
MemoryOperand
src
,
28
ExtensionMode
extMode
=
ExtensionMode::kNo
)
29
: width_(
width
),
30
dst_(
RegisterClass
::
kGPR
, std::move(
dst
)),
31
src_(std::move(
src
)),
32
extMode_(
extMode
) {}
33
34
int
width
()
const
{
35
return
width_;
36
}
37
38
template
<
typename
Self>
39
auto
&
dst
(
this
Self &&self) {
40
return
self.dst_;
41
}
42
43
template
<
typename
Self>
44
auto
&
src
(
this
Self &&self) {
45
return
self.src_;
46
}
47
48
ExtensionMode
extMode
()
const
{
49
return
extMode_;
50
}
51
52
std::unordered_set<const RegisterOperand *>
regOps
()
const override
{
53
return
{&
dst
(), &
src
().baseReg()};
54
}
55
56
std::unordered_set<const RegisterOperand *>
dsts
()
const override
{
57
return
{&
dst
()};
58
}
59
60
std::unordered_set<const RegisterOperand *>
srcs
()
const override
{
61
return
{&
src
().baseReg()};
62
}
63
64
std::unordered_set<const ImmediateOperand *>
immOps
()
const override
{
65
return
{&
src
().offset()};
66
}
67
68
std::unordered_set<const MemoryOperand *>
memOps
()
const override
{
69
return
{&
src
()};
70
}
71
72
bool
hasSideEffects
()
const override
{
73
return
true
;
74
}
75
76
std::string
format
()
const override
;
77
78
std::unique_ptr<Instruction>
clone
()
const override
{
79
return
std::make_unique<Load>(
width
(),
share
(*
dst
()),
src
().
clone
(),
extMode
());
80
}
81
82
void
accept
(
InstructionVisitor
&visitor)
override
{
83
visitor.
visitLoad
(*
this
);
84
}
85
86
void
accept
(
InstructionVisitor
&visitor)
const override
{
87
visitor.
visitLoad
(*
this
);
88
}
89
90
private
:
91
int
width_;
92
RegisterOperand
dst_;
93
MemoryOperand
src_;
94
ExtensionMode
extMode_;
95
};
96
97
}
// namespace mini_llvm::mir
Compiler.h
MINI_LLVM_EXPORT
#define MINI_LLVM_EXPORT
Definition
Compiler.h:17
ExtensionMode.h
ImmediateOperand.h
MemoryOperand.h
Memory.h
RegisterClass.h
RegisterOperand.h
Register.h
mini_llvm::mir::InstructionVisitor
Definition
InstructionVisitor.h:70
mini_llvm::mir::InstructionVisitor::visitLoad
virtual void visitLoad(Load &I)
Definition
InstructionVisitor.h:115
mini_llvm::mir::Instruction::Instruction
Instruction()=default
mini_llvm::mir::Load::Load
Load(int width, std::shared_ptr< Register > dst, MemoryOperand src, ExtensionMode extMode=ExtensionMode::kNo)
Definition
Load.h:25
mini_llvm::mir::Load::width
int width() const
Definition
Load.h:34
mini_llvm::mir::Load::accept
void accept(InstructionVisitor &visitor) const override
Definition
Load.h:86
mini_llvm::mir::Load::dsts
std::unordered_set< const RegisterOperand * > dsts() const override
Definition
Load.h:56
mini_llvm::mir::Load::dst
auto & dst(this Self &&self)
Definition
Load.h:39
mini_llvm::mir::Load::regOps
std::unordered_set< const RegisterOperand * > regOps() const override
Definition
Load.h:52
mini_llvm::mir::Load::clone
std::unique_ptr< Instruction > clone() const override
Definition
Load.h:78
mini_llvm::mir::Load::immOps
std::unordered_set< const ImmediateOperand * > immOps() const override
Definition
Load.h:64
mini_llvm::mir::Load::srcs
std::unordered_set< const RegisterOperand * > srcs() const override
Definition
Load.h:60
mini_llvm::mir::Load::format
std::string format() const override
mini_llvm::mir::Load::src
auto & src(this Self &&self)
Definition
Load.h:44
mini_llvm::mir::Load::accept
void accept(InstructionVisitor &visitor) override
Definition
Load.h:82
mini_llvm::mir::Load::memOps
std::unordered_set< const MemoryOperand * > memOps() const override
Definition
Load.h:68
mini_llvm::mir::Load::hasSideEffects
bool hasSideEffects() const override
Definition
Load.h:72
mini_llvm::mir::Load::extMode
ExtensionMode extMode() const
Definition
Load.h:48
mini_llvm::mir::MemoryOperand
Definition
MemoryOperand.h:20
mini_llvm::mir::RegisterOperand
Definition
RegisterOperand.h:13
InstructionVisitor.h
Instruction.h
mini_llvm::mir
Definition
BasicBlock.h:22
mini_llvm::mir::RegisterClass
RegisterClass
Definition
RegisterClass.h:7
mini_llvm::mir::RegisterClass::kGPR
@ kGPR
Definition
RegisterClass.h:8
mini_llvm::ExtensionMode
ExtensionMode
Definition
ExtensionMode.h:7
mini_llvm::ExtensionMode::kNo
@ kNo
Definition
ExtensionMode.h:8
mini_llvm::share
std::shared_ptr< T > share(T &value)
Definition
Memory.h:25
include
mini-llvm
mir
Instruction
Load.h
Generated by
1.17.0