mini-llvm
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
UnaryOperator.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/ImmediateOperand.h
"
12
#include "
mini-llvm/mir/Instruction.h
"
13
#include "
mini-llvm/mir/MemoryOperand.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
UnaryOperator
:
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
&
src
(
this
Self &&self) {
34
return
self.src_;
35
}
36
37
ExtensionMode
extMode
()
const
{
38
return
extMode_;
39
}
40
41
std::unordered_set<const RegisterOperand *>
regOps
()
const override
{
42
return
{&
dst
(), &
src
()};
43
}
44
45
std::unordered_set<const RegisterOperand *>
dsts
()
const override
{
46
return
{&
dst
()};
47
}
48
49
std::unordered_set<const RegisterOperand *>
srcs
()
const override
{
50
return
{&
src
()};
51
}
52
53
std::unordered_set<const ImmediateOperand *>
immOps
()
const override
{
54
return
{};
55
}
56
57
std::unordered_set<const MemoryOperand *>
memOps
()
const override
{
58
return
{};
59
}
60
61
std::string
format
()
const override
;
62
63
protected
:
64
UnaryOperator
(
int
width
,
65
std::shared_ptr<Register>
dst
,
66
std::shared_ptr<Register>
src
,
67
ExtensionMode
extMode
)
68
: width_(
width
),
69
dst_(
RegisterClass
::
kGPR
, std::move(
dst
)),
70
src_(
RegisterClass
::
kGPR
, std::move(
src
)),
71
extMode_(
extMode
) {}
72
73
virtual
const
char
*
mnemonic
()
const
= 0;
74
75
private
:
76
int
width_;
77
RegisterOperand
dst_, src_;
78
ExtensionMode
extMode_;
79
};
80
81
}
// namespace mini_llvm::mir
Compiler.h
MINI_LLVM_EXPORT
#define MINI_LLVM_EXPORT
Definition
Compiler.h:17
ExtensionMode.h
ImmediateOperand.h
MemoryOperand.h
RegisterClass.h
RegisterOperand.h
Register.h
mini_llvm::mir::Instruction::Instruction
Instruction()=default
mini_llvm::mir::RegisterOperand
Definition
RegisterOperand.h:13
mini_llvm::mir::UnaryOperator::memOps
std::unordered_set< const MemoryOperand * > memOps() const override
Definition
UnaryOperator.h:57
mini_llvm::mir::UnaryOperator::extMode
ExtensionMode extMode() const
Definition
UnaryOperator.h:37
mini_llvm::mir::UnaryOperator::src
auto & src(this Self &&self)
Definition
UnaryOperator.h:33
mini_llvm::mir::UnaryOperator::mnemonic
virtual const char * mnemonic() const =0
mini_llvm::mir::UnaryOperator::UnaryOperator
UnaryOperator(int width, std::shared_ptr< Register > dst, std::shared_ptr< Register > src, ExtensionMode extMode)
Definition
UnaryOperator.h:64
mini_llvm::mir::UnaryOperator::format
std::string format() const override
mini_llvm::mir::UnaryOperator::immOps
std::unordered_set< const ImmediateOperand * > immOps() const override
Definition
UnaryOperator.h:53
mini_llvm::mir::UnaryOperator::srcs
std::unordered_set< const RegisterOperand * > srcs() const override
Definition
UnaryOperator.h:49
mini_llvm::mir::UnaryOperator::width
int width() const
Definition
UnaryOperator.h:23
mini_llvm::mir::UnaryOperator::dsts
std::unordered_set< const RegisterOperand * > dsts() const override
Definition
UnaryOperator.h:45
mini_llvm::mir::UnaryOperator::dst
auto & dst(this Self &&self)
Definition
UnaryOperator.h:28
mini_llvm::mir::UnaryOperator::regOps
std::unordered_set< const RegisterOperand * > regOps() const override
Definition
UnaryOperator.h:41
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
UnaryOperator.h
Generated by
1.17.0