mini-llvm
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
FUnaryOperator.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/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
21
namespace
mini_llvm::mir
{
22
23
class
MINI_LLVM_EXPORT
FUnaryOperator
:
public
Instruction
{
24
public
:
25
Precision
precision
()
const
{
26
return
precision_;
27
}
28
29
template
<
typename
Self>
30
auto
&
dst
(
this
Self &&self) {
31
return
self.dst_;
32
}
33
34
template
<
typename
Self>
35
auto
&
src
(
this
Self &&self) {
36
return
self.src_;
37
}
38
39
std::unordered_set<const RegisterOperand *>
regOps
()
const override
{
40
return
{&
dst
(), &
src
()};
41
}
42
43
std::unordered_set<const RegisterOperand *>
dsts
()
const override
{
44
return
{&
dst
()};
45
}
46
47
std::unordered_set<const RegisterOperand *>
srcs
()
const override
{
48
return
{&
src
()};
49
}
50
51
std::unordered_set<const ImmediateOperand *>
immOps
()
const override
{
52
return
{};
53
}
54
55
std::unordered_set<const MemoryOperand *>
memOps
()
const override
{
56
return
{};
57
}
58
59
std::string
format
()
const override
{
60
return
std::format(
"{} {} {}, {}"
,
mnemonic
(),
specifier
(
precision
()), *
dst
(), *
src
());
61
}
62
63
protected
:
64
FUnaryOperator
(
Precision
precision
, std::shared_ptr<Register>
dst
, std::shared_ptr<Register>
src
)
65
: precision_(
precision
),
66
dst_(
RegisterClass
::
kFPR
, std::move(
dst
)),
67
src_(
RegisterClass
::
kFPR
, std::move(
src
)) {}
68
69
virtual
const
char
*
mnemonic
()
const
= 0;
70
71
private
:
72
Precision
precision_;
73
RegisterOperand
dst_, src_;
74
};
75
76
}
// namespace mini_llvm::mir
Compiler.h
MINI_LLVM_EXPORT
#define MINI_LLVM_EXPORT
Definition
Compiler.h:17
FormatPrecision.h
ImmediateOperand.h
MemoryOperand.h
Precision.h
RegisterClass.h
RegisterOperand.h
Register.h
mini_llvm::mir::FUnaryOperator::dsts
std::unordered_set< const RegisterOperand * > dsts() const override
Definition
FUnaryOperator.h:43
mini_llvm::mir::FUnaryOperator::memOps
std::unordered_set< const MemoryOperand * > memOps() const override
Definition
FUnaryOperator.h:55
mini_llvm::mir::FUnaryOperator::mnemonic
virtual const char * mnemonic() const =0
mini_llvm::mir::FUnaryOperator::precision
Precision precision() const
Definition
FUnaryOperator.h:25
mini_llvm::mir::FUnaryOperator::src
auto & src(this Self &&self)
Definition
FUnaryOperator.h:35
mini_llvm::mir::FUnaryOperator::dst
auto & dst(this Self &&self)
Definition
FUnaryOperator.h:30
mini_llvm::mir::FUnaryOperator::regOps
std::unordered_set< const RegisterOperand * > regOps() const override
Definition
FUnaryOperator.h:39
mini_llvm::mir::FUnaryOperator::srcs
std::unordered_set< const RegisterOperand * > srcs() const override
Definition
FUnaryOperator.h:47
mini_llvm::mir::FUnaryOperator::immOps
std::unordered_set< const ImmediateOperand * > immOps() const override
Definition
FUnaryOperator.h:51
mini_llvm::mir::FUnaryOperator::format
std::string format() const override
Definition
FUnaryOperator.h:59
mini_llvm::mir::FUnaryOperator::FUnaryOperator
FUnaryOperator(Precision precision, std::shared_ptr< Register > dst, std::shared_ptr< Register > src)
Definition
FUnaryOperator.h:64
mini_llvm::mir::Instruction::Instruction
Instruction()=default
mini_llvm::mir::RegisterOperand
Definition
RegisterOperand.h:13
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::Precision
Precision
Definition
Precision.h:7
include
mini-llvm
mir
Instruction
FUnaryOperator.h
Generated by
1.17.0