mini-llvm
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
RISCVAddress.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
3
#pragma once
4
5
#include <cstddef>
6
#include <cstdint>
7
#include <format>
8
#include <functional>
9
#include <string>
10
#include <utility>
11
12
#include "
mini-llvm/mc/Symbol.h
"
13
#include "
mini-llvm/utils/Compiler.h
"
14
#include "
mini-llvm/utils/HashCombine.h
"
15
16
namespace
mini_llvm::mc
{
17
18
class
MINI_LLVM_EXPORT
RISCVAddress
{
19
public
:
20
explicit
RISCVAddress
(
Symbol
baseSymbol
)
21
: baseSymbol_(std::move(
baseSymbol
)), offset_(0) {}
22
23
RISCVAddress
(
Symbol
baseSymbol
, int64_t
offset
)
24
: baseSymbol_(std::move(
baseSymbol
)), offset_(
offset
) {}
25
26
const
Symbol
&
baseSymbol
() const & {
27
return
baseSymbol_;
28
}
29
30
Symbol
&&
baseSymbol
() && {
31
return
std::move(baseSymbol_);
32
}
33
34
int64_t
offset
()
const
{
35
return
offset_;
36
}
37
38
void
setBaseSymbol
(
Symbol
baseSymbol
) {
39
baseSymbol_ = std::move(
baseSymbol
);
40
}
41
42
void
setOffset
(int64_t
offset
) {
43
offset_ =
offset
;
44
}
45
46
std::string
format
()
const
;
47
48
private
:
49
Symbol
baseSymbol_;
50
int64_t offset_;
51
};
52
53
}
// namespace mini_llvm::mc
54
55
template
<>
56
struct
std::hash<
mini_llvm
::mc::RISCVAddress> {
57
size_t
operator()
(
const
mini_llvm::mc::RISCVAddress
&addr)
const
noexcept
{
58
size_t
seed = 0;
59
60
mini_llvm::hash_combine
(seed, addr.baseSymbol());
61
mini_llvm::hash_combine
(seed, addr.offset());
62
63
return
seed;
64
}
65
};
66
67
template
<>
68
struct
std::formatter<
mini_llvm
::mc::RISCVAddress> {
69
constexpr
auto
parse
(std::format_parse_context &ctx) {
70
return
ctx.begin();
71
}
72
73
template
<
typename
FormatContext>
74
auto
format
(
const
mini_llvm::mc::RISCVAddress
&addr, FormatContext &ctx)
const
{
75
return
std::format_to(ctx.out(),
"{}"
, addr.
format
());
76
}
77
};
Compiler.h
MINI_LLVM_EXPORT
#define MINI_LLVM_EXPORT
Definition
Compiler.h:17
HashCombine.h
mini_llvm::mc::RISCVAddress
Definition
RISCVAddress.h:18
mini_llvm::mc::RISCVAddress::baseSymbol
const Symbol & baseSymbol() const &
Definition
RISCVAddress.h:26
mini_llvm::mc::RISCVAddress::format
std::string format() const
mini_llvm::mc::RISCVAddress::setBaseSymbol
void setBaseSymbol(Symbol baseSymbol)
Definition
RISCVAddress.h:38
mini_llvm::mc::RISCVAddress::offset
int64_t offset() const
Definition
RISCVAddress.h:34
mini_llvm::mc::RISCVAddress::RISCVAddress
RISCVAddress(Symbol baseSymbol, int64_t offset)
Definition
RISCVAddress.h:23
mini_llvm::mc::RISCVAddress::RISCVAddress
RISCVAddress(Symbol baseSymbol)
Definition
RISCVAddress.h:20
mini_llvm::mc::RISCVAddress::baseSymbol
Symbol && baseSymbol() &&
Definition
RISCVAddress.h:30
mini_llvm::mc::RISCVAddress::setOffset
void setOffset(int64_t offset)
Definition
RISCVAddress.h:42
mini_llvm::mc::Symbol
Definition
Symbol.h:16
Symbol.h
mini_llvm::mc
Definition
Directive.h:8
mini_llvm
Definition
GraphColoringAllocator.h:13
mini_llvm::hash_combine
constexpr void hash_combine(size_t &seed, const T &v) noexcept
Definition
HashCombine.h:63
std::formatter< mini_llvm::mc::RISCVAddress >::parse
constexpr auto parse(std::format_parse_context &ctx)
Definition
RISCVAddress.h:69
std::formatter< mini_llvm::mc::RISCVAddress >::format
auto format(const mini_llvm::mc::RISCVAddress &addr, FormatContext &ctx) const
Definition
RISCVAddress.h:74
std::hash< mini_llvm::mc::RISCVAddress >::operator()
size_t operator()(const mini_llvm::mc::RISCVAddress &addr) const noexcept
Definition
RISCVAddress.h:57
include
mini-llvm
targets
riscv
mc
RISCVAddress.h
Generated by
1.17.0