mini-llvm
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
FakeUse.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
10
#include "
mini-llvm/mir/ImmediateOperand.h
"
11
#include "
mini-llvm/mir/Instruction.h
"
12
#include "
mini-llvm/mir/InstructionVisitor.h
"
13
#include "
mini-llvm/mir/MemoryOperand.h
"
14
#include "
mini-llvm/mir/PhysicalRegister.h
"
15
#include "
mini-llvm/mir/RegisterOperand.h
"
16
#include "
mini-llvm/utils/Compiler.h
"
17
18
namespace
mini_llvm::mir
{
19
20
class
MINI_LLVM_EXPORT
FakeUse
:
public
Instruction
{
21
public
:
22
explicit
FakeUse
(
PhysicalRegister
*
physReg
) : physReg_(
physReg
) {}
23
24
PhysicalRegister
*
physReg
()
const
{
25
return
physReg_;
26
}
27
28
std::unordered_set<const RegisterOperand *>
regOps
()
const override
{
29
return
{};
30
}
31
32
std::unordered_set<const RegisterOperand *>
dsts
()
const override
{
33
return
{};
34
}
35
36
std::unordered_set<const RegisterOperand *>
srcs
()
const override
{
37
return
{};
38
}
39
40
std::unordered_set<PhysicalRegister *>
implicitSrcs
()
const override
{
41
return
{
physReg
()};
42
}
43
44
std::unordered_set<const ImmediateOperand *>
immOps
()
const override
{
45
return
{};
46
}
47
48
std::unordered_set<const MemoryOperand *>
memOps
()
const override
{
49
return
{};
50
}
51
52
bool
hasSideEffects
()
const override
{
53
return
true
;
54
}
55
56
std::string
format
()
const override
{
57
return
std::format(
"FAKEUSE {}"
, *
physReg
());
58
}
59
60
std::unique_ptr<Instruction>
clone
()
const override
{
61
return
std::make_unique<FakeUse>(
physReg
());
62
}
63
64
void
accept
(
InstructionVisitor
&visitor)
override
{
65
visitor.
visitLive
(*
this
);
66
}
67
68
void
accept
(
InstructionVisitor
&visitor)
const override
{
69
visitor.
visitLive
(*
this
);
70
}
71
72
private
:
73
PhysicalRegister
*physReg_;
74
};
75
76
}
// namespace mini_llvm::mir
Compiler.h
MINI_LLVM_EXPORT
#define MINI_LLVM_EXPORT
Definition
Compiler.h:17
ImmediateOperand.h
MemoryOperand.h
PhysicalRegister.h
RegisterOperand.h
mini_llvm::mir::FakeUse::memOps
std::unordered_set< const MemoryOperand * > memOps() const override
Definition
FakeUse.h:48
mini_llvm::mir::FakeUse::immOps
std::unordered_set< const ImmediateOperand * > immOps() const override
Definition
FakeUse.h:44
mini_llvm::mir::FakeUse::clone
std::unique_ptr< Instruction > clone() const override
Definition
FakeUse.h:60
mini_llvm::mir::FakeUse::accept
void accept(InstructionVisitor &visitor) override
Definition
FakeUse.h:64
mini_llvm::mir::FakeUse::FakeUse
FakeUse(PhysicalRegister *physReg)
Definition
FakeUse.h:22
mini_llvm::mir::FakeUse::hasSideEffects
bool hasSideEffects() const override
Definition
FakeUse.h:52
mini_llvm::mir::FakeUse::accept
void accept(InstructionVisitor &visitor) const override
Definition
FakeUse.h:68
mini_llvm::mir::FakeUse::dsts
std::unordered_set< const RegisterOperand * > dsts() const override
Definition
FakeUse.h:32
mini_llvm::mir::FakeUse::implicitSrcs
std::unordered_set< PhysicalRegister * > implicitSrcs() const override
Definition
FakeUse.h:40
mini_llvm::mir::FakeUse::srcs
std::unordered_set< const RegisterOperand * > srcs() const override
Definition
FakeUse.h:36
mini_llvm::mir::FakeUse::regOps
std::unordered_set< const RegisterOperand * > regOps() const override
Definition
FakeUse.h:28
mini_llvm::mir::FakeUse::format
std::string format() const override
Definition
FakeUse.h:56
mini_llvm::mir::FakeUse::physReg
PhysicalRegister * physReg() const
Definition
FakeUse.h:24
mini_llvm::mir::InstructionVisitor
Definition
InstructionVisitor.h:70
mini_llvm::mir::InstructionVisitor::visitLive
virtual void visitLive(FakeUse &I)
Definition
InstructionVisitor.h:114
mini_llvm::mir::Instruction::Instruction
Instruction()=default
mini_llvm::mir::PhysicalRegister
Definition
PhysicalRegister.h:13
InstructionVisitor.h
Instruction.h
mini_llvm::mir
Definition
BasicBlock.h:22
include
mini-llvm
mir
Instruction
FakeUse.h
Generated by
1.17.0