Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:19

0001 //===- ModuleSymbolTable.h - symbol table for in-memory IR ------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This class represents a symbol table built from in-memory IR. It provides
0010 // access to GlobalValues and should only be used if such access is required
0011 // (e.g. in the LTO implementation).
0012 //
0013 //===----------------------------------------------------------------------===//
0014 
0015 #ifndef LLVM_OBJECT_MODULESYMBOLTABLE_H
0016 #define LLVM_OBJECT_MODULESYMBOLTABLE_H
0017 
0018 #include "llvm/ADT/ArrayRef.h"
0019 #include "llvm/ADT/PointerUnion.h"
0020 #include "llvm/IR/Mangler.h"
0021 #include "llvm/Object/SymbolicFile.h"
0022 #include "llvm/Support/Allocator.h"
0023 #include <cstdint>
0024 #include <string>
0025 #include <utility>
0026 #include <vector>
0027 
0028 namespace llvm {
0029 
0030 class GlobalValue;
0031 class Module;
0032 
0033 class ModuleSymbolTable {
0034 public:
0035   using AsmSymbol = std::pair<std::string, uint32_t>;
0036   using Symbol = PointerUnion<GlobalValue *, AsmSymbol *>;
0037 
0038 private:
0039   Module *FirstMod = nullptr;
0040 
0041   SpecificBumpPtrAllocator<AsmSymbol> AsmSymbols;
0042   std::vector<Symbol> SymTab;
0043   Mangler Mang;
0044 
0045 public:
0046   ArrayRef<Symbol> symbols() const { return SymTab; }
0047   void addModule(Module *M);
0048 
0049   void printSymbolName(raw_ostream &OS, Symbol S) const;
0050   uint32_t getSymbolFlags(Symbol S) const;
0051 
0052   /// Parse inline ASM and collect the symbols that are defined or referenced in
0053   /// the current module.
0054   ///
0055   /// For each found symbol, call \p AsmSymbol with the name of the symbol found
0056   /// and the associated flags.
0057   static void CollectAsmSymbols(
0058       const Module &M,
0059       function_ref<void(StringRef, object::BasicSymbolRef::Flags)> AsmSymbol);
0060 
0061   /// Parse inline ASM and collect the symvers directives that are defined in
0062   /// the current module.
0063   ///
0064   /// For each found symbol, call \p AsmSymver with the name of the symbol and
0065   /// its alias.
0066   static void
0067   CollectAsmSymvers(const Module &M,
0068                     function_ref<void(StringRef, StringRef)> AsmSymver);
0069 };
0070 
0071 } // end namespace llvm
0072 
0073 #endif // LLVM_OBJECT_MODULESYMBOLTABLE_H