mini-llvm 0.1.0
Loading...
Searching...
No Matches
RISCVJALR.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
17
18namespace mini_llvm::mir {
19
21public:
22 RISCVJALR(std::shared_ptr<Register> src, int numIntegerArgs, int numFloatingArgs)
23 : src_(RegisterClass::kGPR, std::move(src)),
24 numIntegerArgs_(numIntegerArgs),
25 numFloatingArgs_(numFloatingArgs) {}
26
27 template <typename Self>
28 auto &src(this Self &&self) {
29 return self.src_;
30 }
31
32 int numIntegerArgs() const {
33 return numIntegerArgs_;
34 }
35
37 numIntegerArgs_ = numIntegerArgs;
38 }
39
40 int numFloatingArgs() const {
41 return numFloatingArgs_;
42 }
43
45 numFloatingArgs_ = numFloatingArgs;
46 }
47
48 std::unordered_set<const RegisterOperand *> regOps() const override {
49 return {&src()};
50 }
51
52 std::unordered_set<const RegisterOperand *> dsts() const override {
53 return {};
54 }
55
56 std::unordered_set<const RegisterOperand *> srcs() const override {
57 return {&src()};
58 }
59
60 std::unordered_set<const MemoryOperand *> memOps() const override {
61 return {};
62 }
63
64 std::unordered_set<PhysicalRegister *> implicitDsts() const override;
65 std::unordered_set<PhysicalRegister *> implicitSrcs() const override;
66
67 std::unordered_set<const ImmediateOperand *> immOps() const override {
68 return {};
69 }
70
71 bool hasSideEffects() const override {
72 return true;
73 }
74
75 void accept(InstructionVisitor &visitor) override {
76 static_cast<RISCVInstructionVisitor &>(visitor).visitRISCVJALR(*this);
77 }
78
79 void accept(InstructionVisitor &visitor) const override {
80 static_cast<RISCVInstructionVisitor &>(visitor).visitRISCVJALR(*this);
81 }
82
83 std::string format() const override;
84
85 std::unique_ptr<Instruction> clone() const override {
86 return std::make_unique<RISCVJALR>(share(*src()), numIntegerArgs(), numFloatingArgs());
87 }
88
89private:
90 RegisterOperand src_;
91 int numIntegerArgs_, numFloatingArgs_;
92};
93
94} // namespace mini_llvm::mir
#define MINI_LLVM_EXPORT
Definition Compiler.h:17
Definition InstructionVisitor.h:70
Definition RISCVInstructionVisitor.h:17
std::unique_ptr< Instruction > clone() const override
Definition RISCVJALR.h:85
auto & src(this Self &&self)
Definition RISCVJALR.h:28
std::unordered_set< PhysicalRegister * > implicitSrcs() const override
int numFloatingArgs() const
Definition RISCVJALR.h:40
std::unordered_set< const MemoryOperand * > memOps() const override
Definition RISCVJALR.h:60
std::string format() const override
std::unordered_set< const ImmediateOperand * > immOps() const override
Definition RISCVJALR.h:67
void accept(InstructionVisitor &visitor) const override
Definition RISCVJALR.h:79
std::unordered_set< PhysicalRegister * > implicitDsts() const override
std::unordered_set< const RegisterOperand * > regOps() const override
Definition RISCVJALR.h:48
void setNumIntegerArgs(int numIntegerArgs)
Definition RISCVJALR.h:36
std::unordered_set< const RegisterOperand * > srcs() const override
Definition RISCVJALR.h:56
int numIntegerArgs() const
Definition RISCVJALR.h:32
std::unordered_set< const RegisterOperand * > dsts() const override
Definition RISCVJALR.h:52
bool hasSideEffects() const override
Definition RISCVJALR.h:71
void setNumFloatingArgs(int numFloatingArgs)
Definition RISCVJALR.h:44
RISCVJALR(std::shared_ptr< Register > src, int numIntegerArgs, int numFloatingArgs)
Definition RISCVJALR.h:22
void accept(InstructionVisitor &visitor) override
Definition RISCVJALR.h:75
Definition RegisterOperand.h:13
Definition BasicBlock.h:22
RegisterClass
Definition RegisterClass.h:7
@ kGPR
Definition RegisterClass.h:8
std::shared_ptr< T > share(T &value)
Definition Memory.h:25