mini-llvm
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
Symbol.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
3
#pragma once
4
5
#include <compare>
6
#include <cstddef>
7
#include <format>
8
#include <functional>
9
#include <string>
10
#include <utility>
11
12
#include "
mini-llvm/utils/Compiler.h
"
13
14
namespace
mini_llvm::mc
{
15
16
class
MINI_LLVM_EXPORT
Symbol
final {
17
public
:
18
explicit
Symbol
(std::string
name
) : name_(std::move(
name
)) {}
19
20
const
std::string &
name
() const & {
21
return
name_;
22
}
23
24
std::string &&
name
() && {
25
return
std::move(name_);
26
}
27
28
std::string
format
()
const
;
29
30
private
:
31
std::string name_;
32
};
33
34
inline
bool
operator==
(
const
Symbol
&lhs,
const
Symbol
&rhs) {
35
return
lhs.
name
() == rhs.
name
();
36
}
37
38
inline
std::strong_ordering
operator<=>
(
const
Symbol
&lhs,
const
Symbol
&rhs) {
39
return
lhs.
name
() <=> rhs.
name
();
40
}
41
42
}
// namespace mini_llvm::mc
43
44
template
<>
45
struct
std::hash<
mini_llvm
::mc::Symbol> {
46
size_t
operator()
(
const
mini_llvm::mc::Symbol
&symbol)
const
{
47
return
std::hash<std::string>()(symbol.
name
());
48
}
49
};
50
51
template
<>
52
struct
std::formatter<
mini_llvm
::mc::Symbol> {
53
constexpr
auto
parse
(std::format_parse_context &ctx) {
54
return
ctx.begin();
55
}
56
57
template
<
typename
FormatContext>
58
auto
format
(
const
mini_llvm::mc::Symbol
&symbol, FormatContext &ctx)
const
{
59
return
std::format_to(ctx.out(),
"{}"
, symbol.
format
());
60
}
61
};
Compiler.h
MINI_LLVM_EXPORT
#define MINI_LLVM_EXPORT
Definition
Compiler.h:17
mini_llvm::mc::Symbol
Definition
Symbol.h:16
mini_llvm::mc::Symbol::name
const std::string & name() const &
Definition
Symbol.h:20
mini_llvm::mc::Symbol::Symbol
Symbol(std::string name)
Definition
Symbol.h:18
mini_llvm::mc::Symbol::name
std::string && name() &&
Definition
Symbol.h:24
mini_llvm::mc::Symbol::format
std::string format() const
mini_llvm::mc
Definition
Directive.h:8
mini_llvm::mc::operator==
bool operator==(const Symbol &lhs, const Symbol &rhs)
Definition
Symbol.h:34
mini_llvm::mc::operator<=>
std::strong_ordering operator<=>(const Symbol &lhs, const Symbol &rhs)
Definition
Symbol.h:38
mini_llvm
Definition
GraphColoringAllocator.h:13
std::formatter< mini_llvm::mc::Symbol >::format
auto format(const mini_llvm::mc::Symbol &symbol, FormatContext &ctx) const
Definition
Symbol.h:58
std::formatter< mini_llvm::mc::Symbol >::parse
constexpr auto parse(std::format_parse_context &ctx)
Definition
Symbol.h:53
std::hash< mini_llvm::mc::Symbol >::operator()
size_t operator()(const mini_llvm::mc::Symbol &symbol) const
Definition
Symbol.h:46
include
mini-llvm
mc
Symbol.h
Generated by
1.17.0