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