mini-llvm 0.1.0
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
10
11namespace mini_llvm::ir {
12
13struct Symbol {
14 enum class Scope {
17 };
18
20 std::string name;
21};
22
23inline 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
29template <>
30struct 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};
Definition Argument.h:13
bool operator==(const Constant &lhs, const Constant &rhs)
Definition Constant.h:28
Definition GraphColoringAllocator.h:13
constexpr void hash_combine(size_t &seed, const T &v) noexcept
Definition HashCombine.h:63
Definition Symbol.h:13
Scope
Definition Symbol.h:14
@ kGlobal
Definition Symbol.h:15
@ kLocal
Definition Symbol.h:16
Scope scope
Definition Symbol.h:19
std::string name
Definition Symbol.h:20
constexpr size_t operator()(const mini_llvm::ir::Symbol &symbol) const noexcept
Definition Symbol.h:31