mini-llvm 0.1.0
Loading...
Searching...
No Matches
RISCVMemoryOperand.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2
3#pragma once
4
5#include <cstdint>
6#include <format>
7#include <string>
8
11
12namespace mini_llvm::mc {
13
14class RISCVMemoryOperand final : public Operand {
15public:
16 RISCVMemoryOperand(int idx, int64_t offset) : idx_(idx), offset_(offset) {}
17
18 int idx() const {
19 return idx_;
20 }
21
22 void setIdx(int idx) {
23 idx_ = idx;
24 }
25
26 int64_t offset() const {
27 return offset_;
28 }
29
30 void setOffset(int64_t offset) {
31 offset_ = offset;
32 }
33
34 std::string format() const override {
35 return std::format("{}({})", offset(), name(static_cast<RISCVRegister>(idx())));
36 }
37
38private:
39 int idx_;
40 int64_t offset_;
41};
42
43} // namespace mini_llvm::mc
void setIdx(int idx)
Definition RISCVMemoryOperand.h:22
int idx() const
Definition RISCVMemoryOperand.h:18
void setOffset(int64_t offset)
Definition RISCVMemoryOperand.h:30
RISCVMemoryOperand(int idx, int64_t offset)
Definition RISCVMemoryOperand.h:16
int64_t offset() const
Definition RISCVMemoryOperand.h:26
std::string format() const override
Definition RISCVMemoryOperand.h:34
Definition Directive.h:8
RISCVRegister
Definition RISCVRegister.h:9
constexpr const char * name(RISCVRegister reg)
Definition RISCVRegister.h:17