mini-llvm
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
LA.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/GlobalValue.h
"
12
#include "
mini-llvm/mir/GlobalValueOperand.h
"
13
#include "
mini-llvm/mir/ImmediateOperand.h
"
14
#include "
mini-llvm/mir/Instruction.h
"
15
#include "
mini-llvm/mir/InstructionVisitor.h
"
16
#include "
mini-llvm/mir/MemoryOperand.h
"
17
#include "
mini-llvm/mir/Register.h
"
18
#include "
mini-llvm/mir/RegisterClass.h
"
19
#include "
mini-llvm/mir/RegisterOperand.h
"
20
#include "
mini-llvm/utils/Compiler.h
"
21
#include "
mini-llvm/utils/Memory.h
"
22
23
namespace
mini_llvm::mir
{
24
25
class
MINI_LLVM_EXPORT
LA
:
public
Instruction
{
26
public
:
27
LA
(
int
width
, std::shared_ptr<Register>
dst
,
GlobalValue
*
src
)
28
: width_(
width
), dst_(
RegisterClass
::
kGPR
, std::move(
dst
)), src_(
src
) {}
29
30
int
width
()
const
{
31
return
width_;
32
}
33
34
template
<
typename
Self>
35
auto
&
dst
(
this
Self &&self) {
36
return
self.dst_;
37
}
38
39
template
<
typename
Self>
40
auto
&
src
(
this
Self &&self) {
41
return
self.src_;
42
}
43
44
std::unordered_set<const RegisterOperand *>
regOps
()
const override
{
45
return
{&
dst
()};
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
{};
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
bool
hasSideEffects
()
const override
{
65
return
false
;
66
}
67
68
std::string
format
()
const override
{
69
return
std::format(
"LA i{} {}, {:o}"
,
width
() * 8, *
dst
(), *
src
());
70
}
71
72
std::unique_ptr<Instruction>
clone
()
const override
{
73
return
std::make_unique<LA>(
width
(),
share
(*
dst
()), &*
src
());
74
}
75
76
void
accept
(
InstructionVisitor
&visitor)
override
{
77
visitor.
visitLA
(*
this
);
78
}
79
80
void
accept
(
InstructionVisitor
&visitor)
const override
{
81
visitor.
visitLA
(*
this
);
82
}
83
84
private
:
85
int
width_;
86
RegisterOperand
dst_;
87
GlobalValueOperand
src_;
88
};
89
90
}
// namespace mini_llvm::mir
Compiler.h
MINI_LLVM_EXPORT
#define MINI_LLVM_EXPORT
Definition
Compiler.h:17
GlobalValueOperand.h
ImmediateOperand.h
MemoryOperand.h
Memory.h
RegisterClass.h
RegisterOperand.h
Register.h
mini_llvm::mir::GlobalValueOperand
Definition
GlobalValueOperand.h:9
mini_llvm::mir::GlobalValue
Definition
GlobalValue.h:15
mini_llvm::mir::InstructionVisitor
Definition
InstructionVisitor.h:70
mini_llvm::mir::InstructionVisitor::visitLA
virtual void visitLA(LA &I)
Definition
InstructionVisitor.h:112
mini_llvm::mir::Instruction::Instruction
Instruction()=default
mini_llvm::mir::LA::memOps
std::unordered_set< const MemoryOperand * > memOps() const override
Definition
LA.h:60
mini_llvm::mir::LA::hasSideEffects
bool hasSideEffects() const override
Definition
LA.h:64
mini_llvm::mir::LA::format
std::string format() const override
Definition
LA.h:68
mini_llvm::mir::LA::srcs
std::unordered_set< const RegisterOperand * > srcs() const override
Definition
LA.h:52
mini_llvm::mir::LA::accept
void accept(InstructionVisitor &visitor) const override
Definition
LA.h:80
mini_llvm::mir::LA::LA
LA(int width, std::shared_ptr< Register > dst, GlobalValue *src)
Definition
LA.h:27
mini_llvm::mir::LA::dst
auto & dst(this Self &&self)
Definition
LA.h:35
mini_llvm::mir::LA::width
int width() const
Definition
LA.h:30
mini_llvm::mir::LA::src
auto & src(this Self &&self)
Definition
LA.h:40
mini_llvm::mir::LA::clone
std::unique_ptr< Instruction > clone() const override
Definition
LA.h:72
mini_llvm::mir::LA::accept
void accept(InstructionVisitor &visitor) override
Definition
LA.h:76
mini_llvm::mir::LA::regOps
std::unordered_set< const RegisterOperand * > regOps() const override
Definition
LA.h:44
mini_llvm::mir::LA::immOps
std::unordered_set< const ImmediateOperand * > immOps() const override
Definition
LA.h:56
mini_llvm::mir::LA::dsts
std::unordered_set< const RegisterOperand * > dsts() const override
Definition
LA.h:48
mini_llvm::mir::RegisterOperand
Definition
RegisterOperand.h:13
GlobalValue.h
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
LA.h
Generated by
1.17.0