mini-llvm 0.1.0
Loading...
Searching...
No Matches
FStore.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
22
23namespace mini_llvm::mir {
24
26public:
27 FStore(Precision precision, MemoryOperand dst, std::shared_ptr<Register> src)
28 : precision_(precision), dst_(std::move(dst)), src_(RegisterClass::kFPR, std::move(src)) {}
29
31 return precision_;
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().baseReg(), &src()};
46 }
47
48 std::unordered_set<const RegisterOperand *> dsts() const override {
49 return {};
50 }
51
52 std::unordered_set<const RegisterOperand *> srcs() const override {
53 return {&dst().baseReg(), &src()};
54 }
55
56 std::unordered_set<const ImmediateOperand *> immOps() const override {
57 return {&dst().offset()};
58 }
59
60 std::unordered_set<const MemoryOperand *> memOps() const override {
61 return {&dst()};
62 }
63
64 bool hasSideEffects() const override {
65 return true;
66 }
67
68 std::string format() const override {
69 return std::format("FSTORE {} {}, {}", specifier(precision()), dst(), *src());
70 }
71
72 std::unique_ptr<Instruction> clone() const override {
73 return std::make_unique<FStore>(precision(), dst().clone(), share(*src()));
74 }
75
76 void accept(InstructionVisitor &visitor) override {
77 visitor.visitFStore(*this);
78 }
79
80 void accept(InstructionVisitor &visitor) const override {
81 visitor.visitFStore(*this);
82 }
83
84private:
85 Precision precision_;
86 MemoryOperand dst_;
87 RegisterOperand src_;
88};
89
90} // namespace mini_llvm::mir
#define MINI_LLVM_EXPORT
Definition Compiler.h:17
std::unordered_set< const RegisterOperand * > dsts() const override
Definition FStore.h:48
std::string format() const override
Definition FStore.h:68
bool hasSideEffects() const override
Definition FStore.h:64
Precision precision() const
Definition FStore.h:30
std::unordered_set< const RegisterOperand * > regOps() const override
Definition FStore.h:44
auto & dst(this Self &&self)
Definition FStore.h:35
std::unordered_set< const MemoryOperand * > memOps() const override
Definition FStore.h:60
FStore(Precision precision, MemoryOperand dst, std::shared_ptr< Register > src)
Definition FStore.h:27
std::unordered_set< const ImmediateOperand * > immOps() const override
Definition FStore.h:56
auto & src(this Self &&self)
Definition FStore.h:40
void accept(InstructionVisitor &visitor) const override
Definition FStore.h:80
void accept(InstructionVisitor &visitor) override
Definition FStore.h:76
std::unique_ptr< Instruction > clone() const override
Definition FStore.h:72
std::unordered_set< const RegisterOperand * > srcs() const override
Definition FStore.h:52
Definition InstructionVisitor.h:70
virtual void visitFStore(FStore &I)
Definition InstructionVisitor.h:110
Definition MemoryOperand.h:20
Definition RegisterOperand.h:13
Definition BasicBlock.h:22
constexpr const char * specifier(Condition cond)
Definition Condition.h:15
RegisterClass
Definition RegisterClass.h:7
@ kFPR
Definition RegisterClass.h:9
std::shared_ptr< T > share(T &value)
Definition Memory.h:25
Precision
Definition Precision.h:7