mini-llvm 0.1.0
Loading...
Searching...
No Matches
RISCVCall.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
19
20namespace mini_llvm::mir {
21
23public:
25 : callee_(callee), numIntegerArgs_(numIntegerArgs), numFloatingArgs_(numFloatingArgs) {}
26
27 template <typename Self>
28 auto &callee(this Self &&self) {
29 return self.callee_;
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 {};
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 {};
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).visitRISCVCall(*this);
77 }
78
79 void accept(InstructionVisitor &visitor) const override {
80 static_cast<RISCVInstructionVisitor &>(visitor).visitRISCVCall(*this);
81 }
82
83 std::string format() const override;
84
85 std::unique_ptr<Instruction> clone() const override {
86 return std::make_unique<RISCVCall>(&*callee(), numIntegerArgs(), numFloatingArgs());
87 }
88
89private:
90 FunctionOperand callee_;
91 int numIntegerArgs_, numFloatingArgs_;
92};
93
94} // namespace mini_llvm::mir
#define MINI_LLVM_EXPORT
Definition Compiler.h:17
Definition FunctionOperand.h:9
Definition Function.h:21
Definition InstructionVisitor.h:70
int numFloatingArgs() const
Definition RISCVCall.h:40
void accept(InstructionVisitor &visitor) override
Definition RISCVCall.h:75
std::unordered_set< PhysicalRegister * > implicitSrcs() const override
auto & callee(this Self &&self)
Definition RISCVCall.h:28
std::unordered_set< const RegisterOperand * > regOps() const override
Definition RISCVCall.h:48
std::string format() const override
std::unique_ptr< Instruction > clone() const override
Definition RISCVCall.h:85
void accept(InstructionVisitor &visitor) const override
Definition RISCVCall.h:79
bool hasSideEffects() const override
Definition RISCVCall.h:71
int numIntegerArgs() const
Definition RISCVCall.h:32
void setNumIntegerArgs(int numIntegerArgs)
Definition RISCVCall.h:36
std::unordered_set< const RegisterOperand * > srcs() const override
Definition RISCVCall.h:56
void setNumFloatingArgs(int numFloatingArgs)
Definition RISCVCall.h:44
std::unordered_set< const ImmediateOperand * > immOps() const override
Definition RISCVCall.h:67
std::unordered_set< PhysicalRegister * > implicitDsts() const override
std::unordered_set< const RegisterOperand * > dsts() const override
Definition RISCVCall.h:52
std::unordered_set< const MemoryOperand * > memOps() const override
Definition RISCVCall.h:60
RISCVCall(Function *callee, int numIntegerArgs, int numFloatingArgs)
Definition RISCVCall.h:24
Definition RISCVInstructionVisitor.h:17
Definition BasicBlock.h:22