mini-llvm
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
FLoad.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
3
#pragma once
4
5
#include <format>
6
#include <memory>
7
#include <string>
8
#include <unordered_set>
9
#include <utility>
10
11
#include "
mini-llvm/common/Precision.h
"
12
#include "
mini-llvm/mir/FormatPrecision.h
"
13
#include "
mini-llvm/mir/ImmediateOperand.h
"
14
#include "
mini-llvm/mir/Instruction.h
"
15
#include "
mini-llvm/mir/InstructionVisitor.h
"
16
#include "
mini-llvm/mir/MemoryOperand.h
"
17
#include "
mini-llvm/mir/Register.h
"
18
#include "
mini-llvm/mir/RegisterClass.h
"
19
#include "
mini-llvm/mir/RegisterOperand.h
"
20
#include "
mini-llvm/utils/Compiler.h
"
21
#include "
mini-llvm/utils/Memory.h
"
22
23
namespace
mini_llvm::mir
{
24
25
class
MINI_LLVM_EXPORT
FLoad
:
public
Instruction
{
26
public
:
27
FLoad
(
Precision
precision
, std::shared_ptr<Register>
dst
,
MemoryOperand
src
)
28
: precision_(
precision
),
29
dst_(
RegisterClass
::
kFPR
, std::move(
dst
)),
30
src_(std::move(
src
)) {}
31
32
Precision
precision
()
const
{
33
return
precision_;
34
}
35
36
template
<
typename
Self>
37
auto
&
dst
(
this
Self &&self) {
38
return
self.dst_;
39
}
40
41
template
<
typename
Self>
42
auto
&
src
(
this
Self &&self) {
43
return
self.src_;
44
}
45
46
std::unordered_set<const RegisterOperand *>
regOps
()
const override
{
47
return
{&
dst
(), &
src
().baseReg()};
48
}
49
50
std::unordered_set<const RegisterOperand *>
dsts
()
const override
{
51
return
{&
dst
()};
52
}
53
54
std::unordered_set<const RegisterOperand *>
srcs
()
const override
{
55
return
{&
src
().baseReg()};
56
}
57
58
std::unordered_set<const ImmediateOperand *>
immOps
()
const override
{
59
return
{&
src
().offset()};
60
}
61
62
std::unordered_set<const MemoryOperand *>
memOps
()
const override
{
63
return
{&
src
()};
64
}
65
66
bool
hasSideEffects
()
const override
{
67
return
true
;
68
}
69
70
std::string
format
()
const override
{
71
return
std::format(
"FLOAD {} {}, {}"
,
specifier
(
precision
()), *
dst
(),
src
());
72
}
73
74
std::unique_ptr<Instruction>
clone
()
const override
{
75
return
std::make_unique<FLoad>(
precision
(),
share
(*
dst
()),
src
().
clone
());
76
}
77
78
void
accept
(
InstructionVisitor
&visitor)
override
{
79
visitor.
visitFLoad
(*
this
);
80
}
81
82
void
accept
(
InstructionVisitor
&visitor)
const override
{
83
visitor.
visitFLoad
(*
this
);
84
}
85
86
private
:
87
Precision
precision_;
88
RegisterOperand
dst_;
89
MemoryOperand
src_;
90
};
91
92
}
// namespace mini_llvm::mir
Compiler.h
MINI_LLVM_EXPORT
#define MINI_LLVM_EXPORT
Definition
Compiler.h:17
FormatPrecision.h
ImmediateOperand.h
MemoryOperand.h
Memory.h
Precision.h
RegisterClass.h
RegisterOperand.h
Register.h
mini_llvm::mir::FLoad::src
auto & src(this Self &&self)
Definition
FLoad.h:42
mini_llvm::mir::FLoad::clone
std::unique_ptr< Instruction > clone() const override
Definition
FLoad.h:74
mini_llvm::mir::FLoad::dst
auto & dst(this Self &&self)
Definition
FLoad.h:37
mini_llvm::mir::FLoad::accept
void accept(InstructionVisitor &visitor) const override
Definition
FLoad.h:82
mini_llvm::mir::FLoad::immOps
std::unordered_set< const ImmediateOperand * > immOps() const override
Definition
FLoad.h:58
mini_llvm::mir::FLoad::precision
Precision precision() const
Definition
FLoad.h:32
mini_llvm::mir::FLoad::format
std::string format() const override
Definition
FLoad.h:70
mini_llvm::mir::FLoad::memOps
std::unordered_set< const MemoryOperand * > memOps() const override
Definition
FLoad.h:62
mini_llvm::mir::FLoad::srcs
std::unordered_set< const RegisterOperand * > srcs() const override
Definition
FLoad.h:54
mini_llvm::mir::FLoad::dsts
std::unordered_set< const RegisterOperand * > dsts() const override
Definition
FLoad.h:50
mini_llvm::mir::FLoad::FLoad
FLoad(Precision precision, std::shared_ptr< Register > dst, MemoryOperand src)
Definition
FLoad.h:27
mini_llvm::mir::FLoad::accept
void accept(InstructionVisitor &visitor) override
Definition
FLoad.h:78
mini_llvm::mir::FLoad::regOps
std::unordered_set< const RegisterOperand * > regOps() const override
Definition
FLoad.h:46
mini_llvm::mir::FLoad::hasSideEffects
bool hasSideEffects() const override
Definition
FLoad.h:66
mini_llvm::mir::InstructionVisitor
Definition
InstructionVisitor.h:70
mini_llvm::mir::InstructionVisitor::visitFLoad
virtual void visitFLoad(FLoad &I)
Definition
InstructionVisitor.h:104
mini_llvm::mir::Instruction::Instruction
Instruction()=default
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::specifier
constexpr const char * specifier(Condition cond)
Definition
Condition.h:15
mini_llvm::mir::RegisterClass
RegisterClass
Definition
RegisterClass.h:7
mini_llvm::mir::RegisterClass::kFPR
@ kFPR
Definition
RegisterClass.h:9
mini_llvm::share
std::shared_ptr< T > share(T &value)
Definition
Memory.h:25
mini_llvm::Precision
Precision
Definition
Precision.h:7
include
mini-llvm
mir
Instruction
FLoad.h
Generated by
1.17.0