[InstCombine] Signed saturation tests. NFC
[llvm-complete.git] / include / llvm / DebugInfo / GSYM / FileEntry.h
blob49e7fc9c429184a3be03c7b0ad2424fb241dae8c
1 //===- FileEntry.h ----------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_DEBUGINFO_GSYM_FILEENTRY_H
10 #define LLVM_DEBUGINFO_GSYM_FILEENTRY_H
12 #include "llvm/ADT/DenseMapInfo.h"
13 #include "llvm/ADT/Hashing.h"
14 #include <functional>
15 #include <stdint.h>
16 #include <utility>
18 namespace llvm {
19 namespace gsym {
21 /// Files in GSYM are contained in FileEntry structs where we split the
22 /// directory and basename into two different strings in the string
23 /// table. This allows paths to shared commont directory and filename
24 /// strings and saves space.
25 struct FileEntry {
27 /// Offsets in the string table.
28 /// @{
29 uint32_t Dir = 0;
30 uint32_t Base = 0;
31 /// @}
33 FileEntry() = default;
34 FileEntry(uint32_t D, uint32_t B) : Dir(D), Base(B) {}
36 // Implement operator== so that FileEntry can be used as key in
37 // unordered containers.
38 bool operator==(const FileEntry &RHS) const {
39 return Base == RHS.Base && Dir == RHS.Dir;
41 bool operator!=(const FileEntry &RHS) const {
42 return Base != RHS.Base || Dir != RHS.Dir;
46 } // namespace gsym
48 template <> struct DenseMapInfo<gsym::FileEntry> {
49 static inline gsym::FileEntry getEmptyKey() {
50 uint32_t key = DenseMapInfo<uint32_t>::getEmptyKey();
51 return gsym::FileEntry(key, key);
53 static inline gsym::FileEntry getTombstoneKey() {
54 uint32_t key = DenseMapInfo<uint32_t>::getTombstoneKey();
55 return gsym::FileEntry(key, key);
57 static unsigned getHashValue(const gsym::FileEntry &Val) {
58 return llvm::hash_combine(DenseMapInfo<uint32_t>::getHashValue(Val.Dir),
59 DenseMapInfo<uint32_t>::getHashValue(Val.Base));
61 static bool isEqual(const gsym::FileEntry &LHS, const gsym::FileEntry &RHS) {
62 return LHS == RHS;
66 } // namespace llvm
67 #endif // #ifndef LLVM_DEBUGINFO_GSYM_FILEENTRY_H