mini-llvm
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
BinaryOperatorI.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
3
#pragma once
4
5
#include <memory>
6
#include <string>
7
#include <unordered_set>
8
#include <utility>
9
10
#include "
mini-llvm/common/ExtensionMode.h
"
11
#include "
mini-llvm/mir/Immediate.h
"
12
#include "
mini-llvm/mir/ImmediateOperand.h
"
13
#include "
mini-llvm/mir/Instruction.h
"
14
#include "
mini-llvm/mir/Register.h
"
15
#include "
mini-llvm/mir/RegisterClass.h
"
16
#include "
mini-llvm/mir/RegisterOperand.h
"
17
#include "
mini-llvm/utils/Compiler.h
"
18
19
namespace
mini_llvm::mir
{
20
21
class
MINI_LLVM_EXPORT
BinaryOperatorI
:
public
Instruction
{
22
public
:
23
int
width
()
const
{
24
return
width_;
25
}
26
27
template
<
typename
Self>
28
auto
&
dst
(
this
Self &&self) {
29
return
self.dst_;
30
}
31
32
template
<
typename
Self>
33
auto
&
src1
(
this
Self &&self) {
34
return
self.src1_;
35
}
36
37
template
<
typename
Self>
38
auto
&
src2
(
this
Self &&self) {
39
return
self.src2_;
40
}
41
42
ExtensionMode
extMode
()
const
{
43
return
extMode_;
44
}
45
46
std::unordered_set<const RegisterOperand *>
regOps
()
const override
{
47
return
{&
dst
(), &
src1
()};
48
}
49
50
std::unordered_set<const RegisterOperand *>
dsts
()
const override
{
51
return
{&
dst
()};
52
}
53
54
std::unordered_set<const RegisterOperand *>
srcs
()
const override
{
55
return
{&
src1
()};
56
}
57
58
std::unordered_set<const ImmediateOperand *>
immOps
()
const override
{
59
return
{&
src2
()};
60
}
61
62
std::unordered_set<const MemoryOperand *>
memOps
()
const override
{
63
return
{};
64
}
65
66
std::string
format
()
const override
;
67
68
protected
:
69
BinaryOperatorI
(
int
width
,
70
std::shared_ptr<Register>
dst
,
71
std::shared_ptr<Register>
src1
,
72
std::unique_ptr<Immediate>
src2
,
73
ExtensionMode
extMode
)
74
: width_(
width
),
75
dst_(
RegisterClass
::
kGPR
, std::move(
dst
)),
76
src1_(
RegisterClass
::
kGPR
, std::move(
src1
)),
77
src2_(std::move(
src2
)),
78
extMode_(
extMode
) {}
79
80
virtual
const
char
*
mnemonic
()
const
= 0;
81
82
private
:
83
int
width_;
84
RegisterOperand
dst_, src1_;
85
ImmediateOperand
src2_;
86
ExtensionMode
extMode_;
87
};
88
89
}
// namespace mini_llvm::mir
Compiler.h
MINI_LLVM_EXPORT
#define MINI_LLVM_EXPORT
Definition
Compiler.h:17
ExtensionMode.h
ImmediateOperand.h
Immediate.h
RegisterClass.h
RegisterOperand.h
Register.h
mini_llvm::mir::BinaryOperatorI::format
std::string format() const override
mini_llvm::mir::BinaryOperatorI::dsts
std::unordered_set< const RegisterOperand * > dsts() const override
Definition
BinaryOperatorI.h:50
mini_llvm::mir::BinaryOperatorI::src2
auto & src2(this Self &&self)
Definition
BinaryOperatorI.h:38
mini_llvm::mir::BinaryOperatorI::BinaryOperatorI
BinaryOperatorI(int width, std::shared_ptr< Register > dst, std::shared_ptr< Register > src1, std::unique_ptr< Immediate > src2, ExtensionMode extMode)
Definition
BinaryOperatorI.h:69
mini_llvm::mir::BinaryOperatorI::memOps
std::unordered_set< const MemoryOperand * > memOps() const override
Definition
BinaryOperatorI.h:62
mini_llvm::mir::BinaryOperatorI::extMode
ExtensionMode extMode() const
Definition
BinaryOperatorI.h:42
mini_llvm::mir::BinaryOperatorI::srcs
std::unordered_set< const RegisterOperand * > srcs() const override
Definition
BinaryOperatorI.h:54
mini_llvm::mir::BinaryOperatorI::immOps
std::unordered_set< const ImmediateOperand * > immOps() const override
Definition
BinaryOperatorI.h:58
mini_llvm::mir::BinaryOperatorI::regOps
std::unordered_set< const RegisterOperand * > regOps() const override
Definition
BinaryOperatorI.h:46
mini_llvm::mir::BinaryOperatorI::width
int width() const
Definition
BinaryOperatorI.h:23
mini_llvm::mir::BinaryOperatorI::src1
auto & src1(this Self &&self)
Definition
BinaryOperatorI.h:33
mini_llvm::mir::BinaryOperatorI::dst
auto & dst(this Self &&self)
Definition
BinaryOperatorI.h:28
mini_llvm::mir::BinaryOperatorI::mnemonic
virtual const char * mnemonic() const =0
mini_llvm::mir::ImmediateOperand
Definition
ImmediateOperand.h:12
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::RegisterClass
RegisterClass
Definition
RegisterClass.h:7
mini_llvm::mir::RegisterClass::kGPR
@ kGPR
Definition
RegisterClass.h:8
mini_llvm::ExtensionMode
ExtensionMode
Definition
ExtensionMode.h:7
include
mini-llvm
mir
Instruction
BinaryOperatorI.h
Generated by
1.17.0