LLVM  15.0.0git
TableManager.h
Go to the documentation of this file.
1 //===---------------------- TableManager.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 // Fix edge for edge that needs an entry to reference the target symbol
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_EXECUTIONENGINE_JITLINK_TABLEMANAGER_H
14 #define LLVM_EXECUTIONENGINE_JITLINK_TABLEMANAGER_H
15 
17 #include "llvm/Support/Debug.h"
18 
19 namespace llvm {
20 namespace jitlink {
21 
22 /// A CRTP base for tables that are built on demand, e.g. Global Offset Tables
23 /// and Procedure Linkage Tables.
24 /// The getEntyrForTarget function returns the table entry corresponding to the
25 /// given target, calling down to the implementation class to build an entry if
26 /// one does not already exist.
27 template <typename TableManagerImplT> class TableManager {
28 public:
29  /// Return the constructed entry
30  ///
31  /// Use parameter G to construct the entry for target symbol
33  assert(Target.hasName() && "Edge cannot point to anonymous target");
34 
35  auto EntryI = Entries.find(Target.getName());
36 
37  // Build the entry if it doesn't exist.
38  if (EntryI == Entries.end()) {
39  auto &Entry = impl().createEntry(G, Target);
40  DEBUG_WITH_TYPE("jitlink", {
41  dbgs() << " Created" << impl().getSectionName() << "entry for "
42  << Target.getName() << ": " << Entry << "\n";
43  });
44  EntryI = Entries.insert(std::make_pair(Target.getName(), &Entry)).first;
45  }
46 
47  assert(EntryI != Entries.end() && "Could not get entry symbol");
48  DEBUG_WITH_TYPE("jitlink", {
49  dbgs() << " Using " << impl().getSectionName() << " entry "
50  << *EntryI->second << "\n";
51  });
52  return *EntryI->second;
53  }
54 
55 private:
56  TableManagerImplT &impl() { return static_cast<TableManagerImplT &>(*this); }
58 };
59 
60 } // namespace jitlink
61 } // namespace llvm
62 
63 #endif
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:145
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
DEBUG_WITH_TYPE
#define DEBUG_WITH_TYPE(TYPE, X)
DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug information.
Definition: Debug.h:64
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:200
llvm::DenseMap
Definition: DenseMap.h:716
llvm::Target::getName
const char * getName() const
getName - Get the target name.
Definition: TargetRegistry.h:367
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Debug.h