mini-llvm
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
FCvt.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
FCvt
:
public
Instruction
{
26
public
:
27
FCvt
(
Precision
dstPrecision
,
28
Precision
srcPrecision
,
29
std::shared_ptr<Register>
dst
,
30
std::shared_ptr<Register>
src
)
31
: dstPrecision_(
dstPrecision
),
32
srcPrecision_(
srcPrecision
),
33
dst_(
RegisterClass
::
kFPR
, std::move(
dst
)),
34
src_(
RegisterClass
::
kFPR
, std::move(
src
)) {}
35
36
Precision
dstPrecision
()
const
{
37
return
dstPrecision_;
38
}
39
40
Precision
srcPrecision
()
const
{
41
return
srcPrecision_;
42
}
43
44
template
<
typename
Self>
45
auto
&
dst
(
this
Self &&self) {
46
return
self.dst_;
47
}
48
49
template
<
typename
Self>
50
auto
&
src
(
this
Self &&self) {
51
return
self.src_;
52
}
53
54
std::unordered_set<const RegisterOperand *>
regOps
()
const override
{
55
return
{&
dst
(), &
src
()};
56
}
57
58
std::unordered_set<const RegisterOperand *>
dsts
()
const override
{
59
return
{&
dst
()};
60
}
61
62
std::unordered_set<const RegisterOperand *>
srcs
()
const override
{
63
return
{&
src
()};
64
}
65
66
std::unordered_set<const ImmediateOperand *>
immOps
()
const override
{
67
return
{};
68
}
69
70
std::unordered_set<const MemoryOperand *>
memOps
()
const override
{
71
return
{};
72
}
73
74
bool
hasSideEffects
()
const override
{
75
return
true
;
76
}
77
78
std::string
format
()
const override
{
79
return
std::format(
80
"FCVT {} {} {}, {}"
,
81
specifier
(
dstPrecision
()),
specifier
(
srcPrecision
()), *
dst
(), *
src
());
82
}
83
84
std::unique_ptr<Instruction>
clone
()
const override
{
85
return
std::make_unique<FCvt>(
86
dstPrecision
(),
srcPrecision
(),
share
(*
dst
()),
share
(*
src
()));
87
}
88
89
void
accept
(
InstructionVisitor
&visitor)
override
{
90
visitor.
visitFCvt
(*
this
);
91
}
92
93
void
accept
(
InstructionVisitor
&visitor)
const override
{
94
visitor.
visitFCvt
(*
this
);
95
}
96
97
private
:
98
Precision
dstPrecision_, srcPrecision_;
99
RegisterOperand
dst_, src_;
100
};
101
102
}
// 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::FCvt::srcPrecision
Precision srcPrecision() const
Definition
FCvt.h:40
mini_llvm::mir::FCvt::format
std::string format() const override
Definition
FCvt.h:78
mini_llvm::mir::FCvt::src
auto & src(this Self &&self)
Definition
FCvt.h:50
mini_llvm::mir::FCvt::accept
void accept(InstructionVisitor &visitor) const override
Definition
FCvt.h:93
mini_llvm::mir::FCvt::clone
std::unique_ptr< Instruction > clone() const override
Definition
FCvt.h:84
mini_llvm::mir::FCvt::dst
auto & dst(this Self &&self)
Definition
FCvt.h:45
mini_llvm::mir::FCvt::memOps
std::unordered_set< const MemoryOperand * > memOps() const override
Definition
FCvt.h:70
mini_llvm::mir::FCvt::immOps
std::unordered_set< const ImmediateOperand * > immOps() const override
Definition
FCvt.h:66
mini_llvm::mir::FCvt::hasSideEffects
bool hasSideEffects() const override
Definition
FCvt.h:74
mini_llvm::mir::FCvt::FCvt
FCvt(Precision dstPrecision, Precision srcPrecision, std::shared_ptr< Register > dst, std::shared_ptr< Register > src)
Definition
FCvt.h:27
mini_llvm::mir::FCvt::dstPrecision
Precision dstPrecision() const
Definition
FCvt.h:36
mini_llvm::mir::FCvt::dsts
std::unordered_set< const RegisterOperand * > dsts() const override
Definition
FCvt.h:58
mini_llvm::mir::FCvt::regOps
std::unordered_set< const RegisterOperand * > regOps() const override
Definition
FCvt.h:54
mini_llvm::mir::FCvt::srcs
std::unordered_set< const RegisterOperand * > srcs() const override
Definition
FCvt.h:62
mini_llvm::mir::FCvt::accept
void accept(InstructionVisitor &visitor) override
Definition
FCvt.h:89
mini_llvm::mir::InstructionVisitor
Definition
InstructionVisitor.h:70
mini_llvm::mir::InstructionVisitor::visitFCvt
virtual void visitFCvt(FCvt &I)
Definition
InstructionVisitor.h:98
mini_llvm::mir::Instruction::Instruction
Instruction()=default
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
FCvt.h
Generated by
1.17.0