mini-llvm
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
FBinaryOperator.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
FBinaryOperator
:
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
&
src1
(
this
Self &&self) {
36
return
self.src1_;
37
}
38
39
template
<
typename
Self>
40
auto
&
src2
(
this
Self &&self) {
41
return
self.src2_;
42
}
43
44
std::unordered_set<const RegisterOperand *>
regOps
()
const override
{
45
return
{&
dst
(), &
src1
(), &
src2
()};
46
}
47
48
std::unordered_set<const RegisterOperand *>
dsts
()
const override
{
49
return
{&
dst
()};
50
}
51
52
std::unordered_set<const RegisterOperand *>
srcs
()
const override
{
53
return
{&
src1
(), &
src2
()};
54
}
55
56
std::unordered_set<const ImmediateOperand *>
immOps
()
const override
{
57
return
{};
58
}
59
60
std::unordered_set<const MemoryOperand *>
memOps
()
const override
{
61
return
{};
62
}
63
64
std::string
format
()
const override
{
65
return
std::format(
"{} {} {}, {}, {}"
,
mnemonic
(),
specifier
(
precision
()), *
dst
(), *
src1
(), *
src2
());
66
}
67
68
protected
:
69
FBinaryOperator
(
Precision
precision
,
70
std::shared_ptr<Register>
dst
,
71
std::shared_ptr<Register>
src1
,
72
std::shared_ptr<Register>
src2
)
73
: precision_(
precision
),
74
dst_(
RegisterClass
::
kFPR
, std::move(
dst
)),
75
src1_(
RegisterClass
::
kFPR
, std::move(
src1
)),
76
src2_(
RegisterClass
::
kFPR
, std::move(
src2
)) {}
77
78
virtual
const
char
*
mnemonic
()
const
= 0;
79
80
private
:
81
Precision
precision_;
82
RegisterOperand
dst_, src1_, src2_;
83
};
84
85
}
// 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::FBinaryOperator::dst
auto & dst(this Self &&self)
Definition
FBinaryOperator.h:30
mini_llvm::mir::FBinaryOperator::src1
auto & src1(this Self &&self)
Definition
FBinaryOperator.h:35
mini_llvm::mir::FBinaryOperator::memOps
std::unordered_set< const MemoryOperand * > memOps() const override
Definition
FBinaryOperator.h:60
mini_llvm::mir::FBinaryOperator::regOps
std::unordered_set< const RegisterOperand * > regOps() const override
Definition
FBinaryOperator.h:44
mini_llvm::mir::FBinaryOperator::immOps
std::unordered_set< const ImmediateOperand * > immOps() const override
Definition
FBinaryOperator.h:56
mini_llvm::mir::FBinaryOperator::format
std::string format() const override
Definition
FBinaryOperator.h:64
mini_llvm::mir::FBinaryOperator::srcs
std::unordered_set< const RegisterOperand * > srcs() const override
Definition
FBinaryOperator.h:52
mini_llvm::mir::FBinaryOperator::src2
auto & src2(this Self &&self)
Definition
FBinaryOperator.h:40
mini_llvm::mir::FBinaryOperator::precision
Precision precision() const
Definition
FBinaryOperator.h:25
mini_llvm::mir::FBinaryOperator::mnemonic
virtual const char * mnemonic() const =0
mini_llvm::mir::FBinaryOperator::dsts
std::unordered_set< const RegisterOperand * > dsts() const override
Definition
FBinaryOperator.h:48
mini_llvm::mir::FBinaryOperator::FBinaryOperator
FBinaryOperator(Precision precision, std::shared_ptr< Register > dst, std::shared_ptr< Register > src1, std::shared_ptr< Register > src2)
Definition
FBinaryOperator.h:69
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
FBinaryOperator.h
Generated by
1.17.0