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 <cstddef>
6
#include <functional>
7
#include <string>
8
9
#include "
mini-llvm/utils/HashCombine.h
"
10
11
namespace
mini_llvm::ir
{
12
13
struct
Symbol
{
14
enum class
Scope
{
15
kGlobal
,
16
kLocal
,
17
};
18
19
Scope
scope
;
20
std::string
name
;
21
};
22
23
inline
bool
operator==
(
const
Symbol
&lhs,
const
Symbol
&rhs) {
24
return
lhs.
scope
== rhs.
scope
&& lhs.
name
== rhs.
name
;
25
}
26
27
}
// namespace mini_llvm::ir
28
29
template
<>
30
struct
std::hash<
mini_llvm
::ir::Symbol> {
31
constexpr
size_t
operator()
(
const
mini_llvm::ir::Symbol
&symbol)
const
noexcept
{
32
size_t
seed = 0;
33
34
mini_llvm::hash_combine
(seed, symbol.scope);
35
mini_llvm::hash_combine
(seed, symbol.name);
36
37
return
seed;
38
}
39
};
HashCombine.h
mini_llvm::ir
Definition
Argument.h:13
mini_llvm::ir::operator==
bool operator==(const Constant &lhs, const Constant &rhs)
Definition
Constant.h:28
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
mini_llvm::ir::Symbol
Definition
Symbol.h:13
mini_llvm::ir::Symbol::Scope
Scope
Definition
Symbol.h:14
mini_llvm::ir::Symbol::Scope::kGlobal
@ kGlobal
Definition
Symbol.h:15
mini_llvm::ir::Symbol::Scope::kLocal
@ kLocal
Definition
Symbol.h:16
mini_llvm::ir::Symbol::scope
Scope scope
Definition
Symbol.h:19
mini_llvm::ir::Symbol::name
std::string name
Definition
Symbol.h:20
std::hash< mini_llvm::ir::Symbol >::operator()
constexpr size_t operator()(const mini_llvm::ir::Symbol &symbol) const noexcept
Definition
Symbol.h:31
include
mini-llvm
ir_reader
Symbol.h
Generated by
1.17.0