mini-llvm 0.1.0
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
17
18namespace mini_llvm::mir {
19
21public:
22 explicit FakeUse(PhysicalRegister *physReg) : physReg_(physReg) {}
23
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
72private:
73 PhysicalRegister *physReg_;
74};
75
76} // namespace mini_llvm::mir
#define MINI_LLVM_EXPORT
Definition Compiler.h:17
std::unordered_set< const MemoryOperand * > memOps() const override
Definition FakeUse.h:48
std::unordered_set< const ImmediateOperand * > immOps() const override
Definition FakeUse.h:44
std::unique_ptr< Instruction > clone() const override
Definition FakeUse.h:60
void accept(InstructionVisitor &visitor) override
Definition FakeUse.h:64
FakeUse(PhysicalRegister *physReg)
Definition FakeUse.h:22
bool hasSideEffects() const override
Definition FakeUse.h:52
void accept(InstructionVisitor &visitor) const override
Definition FakeUse.h:68
std::unordered_set< const RegisterOperand * > dsts() const override
Definition FakeUse.h:32
std::unordered_set< PhysicalRegister * > implicitSrcs() const override
Definition FakeUse.h:40
std::unordered_set< const RegisterOperand * > srcs() const override
Definition FakeUse.h:36
std::unordered_set< const RegisterOperand * > regOps() const override
Definition FakeUse.h:28
std::string format() const override
Definition FakeUse.h:56
PhysicalRegister * physReg() const
Definition FakeUse.h:24
Definition InstructionVisitor.h:70
virtual void visitLive(FakeUse &I)
Definition InstructionVisitor.h:114
Definition PhysicalRegister.h:13
Definition BasicBlock.h:22