Mangling.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===------ Mangling.h -- Name Mangling Utilities for ORC -------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // Name mangling utilities for ORC.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_EXECUTIONENGINE_ORC_MANGLING_H
  18. #define LLVM_EXECUTIONENGINE_ORC_MANGLING_H
  19. #include "llvm/ExecutionEngine/Orc/Core.h"
  20. #include "llvm/ExecutionEngine/Orc/ThreadSafeModule.h"
  21. #include "llvm/IR/Module.h"
  22. #include "llvm/Support/MemoryBuffer.h"
  23. namespace llvm {
  24. namespace orc {
  25. /// Mangles symbol names then uniques them in the context of an
  26. /// ExecutionSession.
  27. class MangleAndInterner {
  28. public:
  29. MangleAndInterner(ExecutionSession &ES, const DataLayout &DL);
  30. SymbolStringPtr operator()(StringRef Name);
  31. private:
  32. ExecutionSession &ES;
  33. const DataLayout &DL;
  34. };
  35. /// Maps IR global values to their linker symbol names / flags.
  36. ///
  37. /// This utility can be used when adding new IR globals in the JIT.
  38. class IRSymbolMapper {
  39. public:
  40. struct ManglingOptions {
  41. bool EmulatedTLS = false;
  42. };
  43. using SymbolNameToDefinitionMap = std::map<SymbolStringPtr, GlobalValue *>;
  44. /// Add mangled symbols for the given GlobalValues to SymbolFlags.
  45. /// If a SymbolToDefinitionMap pointer is supplied then it will be populated
  46. /// with Name-to-GlobalValue* mappings. Note that this mapping is not
  47. /// necessarily one-to-one: thread-local GlobalValues, for example, may
  48. /// produce more than one symbol, in which case the map will contain duplicate
  49. /// values.
  50. static void add(ExecutionSession &ES, const ManglingOptions &MO,
  51. ArrayRef<GlobalValue *> GVs, SymbolFlagsMap &SymbolFlags,
  52. SymbolNameToDefinitionMap *SymbolToDefinition = nullptr);
  53. };
  54. } // End namespace orc
  55. } // End namespace llvm
  56. #endif // LLVM_EXECUTIONENGINE_ORC_MANGLING_H
  57. #ifdef __GNUC__
  58. #pragma GCC diagnostic pop
  59. #endif