[DAGCombiner] Add target hook function to decide folding (mul (add x, c1), c2)
[llvm-project.git] / lld / COFF / TypeMerger.h
blob72fd5fc72b0118a2aa78ae6927dc23f836a5a420
1 //===- TypeMerger.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 LLD_COFF_TYPEMERGER_H
10 #define LLD_COFF_TYPEMERGER_H
12 #include "Config.h"
13 #include "llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h"
14 #include "llvm/DebugInfo/CodeView/TypeHashing.h"
15 #include "llvm/Support/Allocator.h"
16 #include <atomic>
18 namespace lld {
19 namespace coff {
21 using llvm::codeview::GloballyHashedType;
22 using llvm::codeview::TypeIndex;
24 struct GHashState;
26 class TypeMerger {
27 public:
28 TypeMerger(llvm::BumpPtrAllocator &alloc);
30 ~TypeMerger();
32 /// Get the type table or the global type table if /DEBUG:GHASH is enabled.
33 inline llvm::codeview::TypeCollection &getTypeTable() {
34 assert(!config->debugGHashes);
35 return typeTable;
38 /// Get the ID table or the global ID table if /DEBUG:GHASH is enabled.
39 inline llvm::codeview::TypeCollection &getIDTable() {
40 assert(!config->debugGHashes);
41 return idTable;
44 /// Use global hashes to eliminate duplicate types and identify unique type
45 /// indices in each TpiSource.
46 void mergeTypesWithGHash();
48 /// Map from PDB function id type indexes to PDB function type indexes.
49 /// Populated after mergeTypesWithGHash.
50 llvm::DenseMap<TypeIndex, TypeIndex> funcIdToType;
52 /// Type records that will go into the PDB TPI stream.
53 llvm::codeview::MergingTypeTableBuilder typeTable;
55 /// Item records that will go into the PDB IPI stream.
56 llvm::codeview::MergingTypeTableBuilder idTable;
58 // When showSummary is enabled, these are histograms of TPI and IPI records
59 // keyed by type index.
60 SmallVector<uint32_t, 0> tpiCounts;
61 SmallVector<uint32_t, 0> ipiCounts;
64 } // namespace coff
65 } // namespace lld
67 #endif