LLVM 22.0.0git
UniqueBBID.h
Go to the documentation of this file.
1//===- llvm/Support/UniqueBBID.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//===----------------------------------------------------------------------===//
8//
9// Unique fixed ID assigned to basic blocks upon their creation.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_SUPPORT_UNIQUEBBID_H
14#define LLVM_SUPPORT_UNIQUEBBID_H
15
17
18namespace llvm {
19
20// This structure represents the information for a basic block pertaining to
21// the basic block sections profile.
22struct UniqueBBID {
23 unsigned BaseID;
24 unsigned CloneID;
25};
26
27// Provides DenseMapInfo for UniqueBBID.
28template <> struct DenseMapInfo<UniqueBBID> {
29 static inline UniqueBBID getEmptyKey() {
30 unsigned EmptyKey = DenseMapInfo<unsigned>::getEmptyKey();
31 return UniqueBBID{EmptyKey, EmptyKey};
32 }
33 static inline UniqueBBID getTombstoneKey() {
34 unsigned TombstoneKey = DenseMapInfo<unsigned>::getTombstoneKey();
35 return UniqueBBID{TombstoneKey, TombstoneKey};
36 }
37 static unsigned getHashValue(const UniqueBBID &Val) {
38 std::pair<unsigned, unsigned> PairVal =
39 std::make_pair(Val.BaseID, Val.CloneID);
40 return DenseMapInfo<std::pair<unsigned, unsigned>>::getHashValue(PairVal);
41 }
42 static bool isEqual(const UniqueBBID &LHS, const UniqueBBID &RHS) {
43 return DenseMapInfo<unsigned>::isEqual(LHS.BaseID, RHS.BaseID) &&
44 DenseMapInfo<unsigned>::isEqual(LHS.CloneID, RHS.CloneID);
45 }
46};
47
48} // end namespace llvm
49
50#endif // LLVM_SUPPORT_UNIQUEBBID_H
This file defines DenseMapInfo traits for DenseMap.
Value * RHS
Value * LHS
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
static bool isEqual(const UniqueBBID &LHS, const UniqueBBID &RHS)
Definition: UniqueBBID.h:42
static UniqueBBID getEmptyKey()
Definition: UniqueBBID.h:29
static unsigned getHashValue(const UniqueBBID &Val)
Definition: UniqueBBID.h:37
static UniqueBBID getTombstoneKey()
Definition: UniqueBBID.h:33
An information struct used to provide DenseMap with the various necessary components for a given valu...
Definition: DenseMapInfo.h:54
unsigned BaseID
Definition: UniqueBBID.h:23
unsigned CloneID
Definition: UniqueBBID.h:24