Mangler.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- llvm/IR/Mangler.h - Self-contained name mangler ---------*- 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. // Unified name mangler for various backends.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_IR_MANGLER_H
  18. #define LLVM_IR_MANGLER_H
  19. #include "llvm/ADT/DenseMap.h"
  20. namespace llvm {
  21. class DataLayout;
  22. class GlobalValue;
  23. template <typename T> class SmallVectorImpl;
  24. class Triple;
  25. class Twine;
  26. class raw_ostream;
  27. class Mangler {
  28. /// We need to give global values the same name every time they are mangled.
  29. /// This keeps track of the number we give to anonymous ones.
  30. mutable DenseMap<const GlobalValue*, unsigned> AnonGlobalIDs;
  31. public:
  32. /// Print the appropriate prefix and the specified global variable's name.
  33. /// If the global variable doesn't have a name, this fills in a unique name
  34. /// for the global.
  35. void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV,
  36. bool CannotUsePrivateLabel) const;
  37. void getNameWithPrefix(SmallVectorImpl<char> &OutName, const GlobalValue *GV,
  38. bool CannotUsePrivateLabel) const;
  39. /// Print the appropriate prefix and the specified name as the global variable
  40. /// name. GVName must not be empty.
  41. static void getNameWithPrefix(raw_ostream &OS, const Twine &GVName,
  42. const DataLayout &DL);
  43. static void getNameWithPrefix(SmallVectorImpl<char> &OutName,
  44. const Twine &GVName, const DataLayout &DL);
  45. };
  46. void emitLinkerFlagsForGlobalCOFF(raw_ostream &OS, const GlobalValue *GV,
  47. const Triple &TT, Mangler &Mangler);
  48. void emitLinkerFlagsForUsedCOFF(raw_ostream &OS, const GlobalValue *GV,
  49. const Triple &T, Mangler &M);
  50. } // End llvm namespace
  51. #endif
  52. #ifdef __GNUC__
  53. #pragma GCC diagnostic pop
  54. #endif