mini-llvm
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
FCmpSet.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/Condition.h
"
13
#include "
mini-llvm/mir/FormatPrecision.h
"
14
#include "
mini-llvm/mir/ImmediateOperand.h
"
15
#include "
mini-llvm/mir/Instruction.h
"
16
#include "
mini-llvm/mir/InstructionVisitor.h
"
17
#include "
mini-llvm/mir/MemoryOperand.h
"
18
#include "
mini-llvm/mir/Register.h
"
19
#include "
mini-llvm/mir/RegisterClass.h
"
20
#include "
mini-llvm/mir/RegisterOperand.h
"
21
#include "
mini-llvm/utils/Compiler.h
"
22
#include "
mini-llvm/utils/Memory.h
"
23
24
namespace
mini_llvm::mir
{
25
26
class
MINI_LLVM_EXPORT
FCmpSet
:
public
Instruction
{
27
public
:
28
FCmpSet
(
int
dstWidth
,
29
Precision
srcPrecision
,
30
Condition
cond
,
31
std::shared_ptr<Register>
dst
,
32
std::shared_ptr<Register>
src1
,
33
std::shared_ptr<Register>
src2
)
34
: dstWidth_(
dstWidth
),
35
srcPrecision_(
srcPrecision
),
36
cond_(
cond
),
37
dst_(
RegisterClass
::
kGPR
, std::move(
dst
)),
38
src1_(
RegisterClass
::
kFPR
, std::move(
src1
)),
39
src2_(
RegisterClass
::
kFPR
, std::move(
src2
)) {}
40
41
int
dstWidth
()
const
{
42
return
dstWidth_;
43
}
44
45
Precision
srcPrecision
()
const
{
46
return
srcPrecision_;
47
}
48
49
Condition
cond
()
const
{
50
return
cond_;
51
}
52
53
void
setCond
(
Condition
cond
) {
54
cond_ =
cond
;
55
}
56
57
template
<
typename
Self>
58
auto
&
dst
(
this
Self &&self) {
59
return
self.dst_;
60
}
61
62
template
<
typename
Self>
63
auto
&
src1
(
this
Self &&self) {
64
return
self.src1_;
65
}
66
67
template
<
typename
Self>
68
auto
&
src2
(
this
Self &&self) {
69
return
self.src2_;
70
}
71
72
std::unordered_set<const RegisterOperand *>
regOps
()
const override
{
73
return
{&
dst
(), &
src1
(), &
src2
()};
74
}
75
76
std::unordered_set<const RegisterOperand *>
dsts
()
const override
{
77
return
{&
dst
()};
78
}
79
80
std::unordered_set<const RegisterOperand *>
srcs
()
const override
{
81
return
{&
src1
(), &
src2
()};
82
}
83
84
std::unordered_set<const ImmediateOperand *>
immOps
()
const override
{
85
return
{};
86
}
87
88
std::unordered_set<const MemoryOperand *>
memOps
()
const override
{
89
return
{};
90
}
91
92
bool
hasSideEffects
()
const override
{
93
return
true
;
94
}
95
96
std::string
format
()
const override
{
97
return
std::format(
98
"FCMPSET i{}, {} {} {}, {}, {}"
,
99
dstWidth
() * 8,
specifier
(
srcPrecision
()),
specifier
(
cond
()), *
dst
(), *
src1
(), *
src2
());
100
}
101
102
std::unique_ptr<Instruction>
clone
()
const override
{
103
return
std::make_unique<FCmpSet>(
104
dstWidth
(),
srcPrecision
(),
cond
(),
share
(*
dst
()),
share
(*
src1
()),
share
(*
src2
()));
105
}
106
107
void
accept
(
InstructionVisitor
&visitor)
override
{
108
visitor.
visitFCmpSet
(*
this
);
109
}
110
111
void
accept
(
InstructionVisitor
&visitor)
const override
{
112
visitor.
visitFCmpSet
(*
this
);
113
}
114
115
private
:
116
int
dstWidth_;
117
Precision
srcPrecision_;
118
Condition
cond_;
119
RegisterOperand
dst_, src1_, src2_;
120
};
121
122
}
// namespace mini_llvm::mir
Compiler.h
MINI_LLVM_EXPORT
#define MINI_LLVM_EXPORT
Definition
Compiler.h:17
Condition.h
FormatPrecision.h
ImmediateOperand.h
MemoryOperand.h
Memory.h
Precision.h
RegisterClass.h
RegisterOperand.h
Register.h
mini_llvm::mir::FCmpSet::format
std::string format() const override
Definition
FCmpSet.h:96
mini_llvm::mir::FCmpSet::accept
void accept(InstructionVisitor &visitor) override
Definition
FCmpSet.h:107
mini_llvm::mir::FCmpSet::srcPrecision
Precision srcPrecision() const
Definition
FCmpSet.h:45
mini_llvm::mir::FCmpSet::src2
auto & src2(this Self &&self)
Definition
FCmpSet.h:68
mini_llvm::mir::FCmpSet::clone
std::unique_ptr< Instruction > clone() const override
Definition
FCmpSet.h:102
mini_llvm::mir::FCmpSet::immOps
std::unordered_set< const ImmediateOperand * > immOps() const override
Definition
FCmpSet.h:84
mini_llvm::mir::FCmpSet::src1
auto & src1(this Self &&self)
Definition
FCmpSet.h:63
mini_llvm::mir::FCmpSet::memOps
std::unordered_set< const MemoryOperand * > memOps() const override
Definition
FCmpSet.h:88
mini_llvm::mir::FCmpSet::dsts
std::unordered_set< const RegisterOperand * > dsts() const override
Definition
FCmpSet.h:76
mini_llvm::mir::FCmpSet::setCond
void setCond(Condition cond)
Definition
FCmpSet.h:53
mini_llvm::mir::FCmpSet::dst
auto & dst(this Self &&self)
Definition
FCmpSet.h:58
mini_llvm::mir::FCmpSet::FCmpSet
FCmpSet(int dstWidth, Precision srcPrecision, Condition cond, std::shared_ptr< Register > dst, std::shared_ptr< Register > src1, std::shared_ptr< Register > src2)
Definition
FCmpSet.h:28
mini_llvm::mir::FCmpSet::regOps
std::unordered_set< const RegisterOperand * > regOps() const override
Definition
FCmpSet.h:72
mini_llvm::mir::FCmpSet::srcs
std::unordered_set< const RegisterOperand * > srcs() const override
Definition
FCmpSet.h:80
mini_llvm::mir::FCmpSet::dstWidth
int dstWidth() const
Definition
FCmpSet.h:41
mini_llvm::mir::FCmpSet::accept
void accept(InstructionVisitor &visitor) const override
Definition
FCmpSet.h:111
mini_llvm::mir::FCmpSet::cond
Condition cond() const
Definition
FCmpSet.h:49
mini_llvm::mir::FCmpSet::hasSideEffects
bool hasSideEffects() const override
Definition
FCmpSet.h:92
mini_llvm::mir::InstructionVisitor
Definition
InstructionVisitor.h:70
mini_llvm::mir::InstructionVisitor::visitFCmpSet
virtual void visitFCmpSet(FCmpSet &I)
Definition
InstructionVisitor.h:97
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::mir::RegisterClass::kGPR
@ kGPR
Definition
RegisterClass.h:8
mini_llvm::mir::Condition
Condition
Definition
Condition.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
FCmpSet.h
Generated by
1.17.0