mini-llvm
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
CmpZ.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/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
CmpZ
:
public
Instruction
{
24
public
:
25
CmpZ
(
int
width
, std::shared_ptr<Register>
src
)
26
: width_(
width
), src_(
RegisterClass
::
kGPR
, std::move(
src
)) {}
27
28
int
width
()
const
{
29
return
width_;
30
}
31
32
template
<
typename
Self>
33
auto
&
src
(
this
Self &&self) {
34
return
self.src_;
35
}
36
37
std::unordered_set<const RegisterOperand *>
regOps
()
const override
{
38
return
{&
src
()};
39
}
40
41
std::unordered_set<const RegisterOperand *>
dsts
()
const override
{
42
return
{};
43
}
44
45
std::unordered_set<const RegisterOperand *>
srcs
()
const override
{
46
return
{&
src
()};
47
}
48
49
std::unordered_set<const ImmediateOperand *>
immOps
()
const override
{
50
return
{};
51
}
52
53
std::unordered_set<const MemoryOperand *>
memOps
()
const override
{
54
return
{};
55
}
56
57
bool
hasSideEffects
()
const override
{
58
return
false
;
59
}
60
61
std::string
format
()
const override
{
62
return
std::format(
"CMPZ i{} {}"
,
width
() * 8, *
src
());
63
}
64
65
std::unique_ptr<Instruction>
clone
()
const override
{
66
return
std::make_unique<CmpZ>(
width
(),
share
(*
src
()));
67
}
68
69
void
accept
(
InstructionVisitor
&visitor)
override
{
70
visitor.
visitCmpZ
(*
this
);
71
}
72
73
void
accept
(
InstructionVisitor
&visitor)
const override
{
74
visitor.
visitCmpZ
(*
this
);
75
}
76
77
78
private
:
79
int
width_;
80
RegisterOperand
src_;
81
};
82
83
}
// namespace mini_llvm::mir
Compiler.h
MINI_LLVM_EXPORT
#define MINI_LLVM_EXPORT
Definition
Compiler.h:17
ImmediateOperand.h
MemoryOperand.h
Memory.h
RegisterClass.h
RegisterOperand.h
Register.h
mini_llvm::mir::CmpZ::accept
void accept(InstructionVisitor &visitor) const override
Definition
CmpZ.h:73
mini_llvm::mir::CmpZ::hasSideEffects
bool hasSideEffects() const override
Definition
CmpZ.h:57
mini_llvm::mir::CmpZ::dsts
std::unordered_set< const RegisterOperand * > dsts() const override
Definition
CmpZ.h:41
mini_llvm::mir::CmpZ::immOps
std::unordered_set< const ImmediateOperand * > immOps() const override
Definition
CmpZ.h:49
mini_llvm::mir::CmpZ::accept
void accept(InstructionVisitor &visitor) override
Definition
CmpZ.h:69
mini_llvm::mir::CmpZ::srcs
std::unordered_set< const RegisterOperand * > srcs() const override
Definition
CmpZ.h:45
mini_llvm::mir::CmpZ::src
auto & src(this Self &&self)
Definition
CmpZ.h:33
mini_llvm::mir::CmpZ::CmpZ
CmpZ(int width, std::shared_ptr< Register > src)
Definition
CmpZ.h:25
mini_llvm::mir::CmpZ::format
std::string format() const override
Definition
CmpZ.h:61
mini_llvm::mir::CmpZ::memOps
std::unordered_set< const MemoryOperand * > memOps() const override
Definition
CmpZ.h:53
mini_llvm::mir::CmpZ::regOps
std::unordered_set< const RegisterOperand * > regOps() const override
Definition
CmpZ.h:37
mini_llvm::mir::CmpZ::width
int width() const
Definition
CmpZ.h:28
mini_llvm::mir::CmpZ::clone
std::unique_ptr< Instruction > clone() const override
Definition
CmpZ.h:65
mini_llvm::mir::InstructionVisitor
Definition
InstructionVisitor.h:70
mini_llvm::mir::InstructionVisitor::visitCmpZ
virtual void visitCmpZ(CmpZ &I)
Definition
InstructionVisitor.h:91
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::RegisterClass
RegisterClass
Definition
RegisterClass.h:7
mini_llvm::mir::RegisterClass::kGPR
@ kGPR
Definition
RegisterClass.h:8
mini_llvm::share
std::shared_ptr< T > share(T &value)
Definition
Memory.h:25
include
mini-llvm
mir
Instruction
CmpZ.h
Generated by
1.17.0