mini-llvm 0.1.0
Loading...
Searching...
No Matches
UnaryOperator.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
18
19namespace mini_llvm::mir {
20
22public:
23 int width() const {
24 return width_;
25 }
26
27 template <typename Self>
28 auto &dst(this Self &&self) {
29 return self.dst_;
30 }
31
32 template <typename Self>
33 auto &src(this Self &&self) {
34 return self.src_;
35 }
36
38 return extMode_;
39 }
40
41 std::unordered_set<const RegisterOperand *> regOps() const override {
42 return {&dst(), &src()};
43 }
44
45 std::unordered_set<const RegisterOperand *> dsts() const override {
46 return {&dst()};
47 }
48
49 std::unordered_set<const RegisterOperand *> srcs() const override {
50 return {&src()};
51 }
52
53 std::unordered_set<const ImmediateOperand *> immOps() const override {
54 return {};
55 }
56
57 std::unordered_set<const MemoryOperand *> memOps() const override {
58 return {};
59 }
60
61 std::string format() const override;
62
63protected:
65 std::shared_ptr<Register> dst,
66 std::shared_ptr<Register> src,
68 : width_(width),
69 dst_(RegisterClass::kGPR, std::move(dst)),
70 src_(RegisterClass::kGPR, std::move(src)),
71 extMode_(extMode) {}
72
73 virtual const char *mnemonic() const = 0;
74
75private:
76 int width_;
77 RegisterOperand dst_, src_;
78 ExtensionMode extMode_;
79};
80
81} // namespace mini_llvm::mir
#define MINI_LLVM_EXPORT
Definition Compiler.h:17
Definition RegisterOperand.h:13
std::unordered_set< const MemoryOperand * > memOps() const override
Definition UnaryOperator.h:57
ExtensionMode extMode() const
Definition UnaryOperator.h:37
auto & src(this Self &&self)
Definition UnaryOperator.h:33
virtual const char * mnemonic() const =0
UnaryOperator(int width, std::shared_ptr< Register > dst, std::shared_ptr< Register > src, ExtensionMode extMode)
Definition UnaryOperator.h:64
std::string format() const override
std::unordered_set< const ImmediateOperand * > immOps() const override
Definition UnaryOperator.h:53
std::unordered_set< const RegisterOperand * > srcs() const override
Definition UnaryOperator.h:49
int width() const
Definition UnaryOperator.h:23
std::unordered_set< const RegisterOperand * > dsts() const override
Definition UnaryOperator.h:45
auto & dst(this Self &&self)
Definition UnaryOperator.h:28
std::unordered_set< const RegisterOperand * > regOps() const override
Definition UnaryOperator.h:41
Definition BasicBlock.h:22
RegisterClass
Definition RegisterClass.h:7
@ kGPR
Definition RegisterClass.h:8
ExtensionMode
Definition ExtensionMode.h:7