File indexing completed on 2026-05-10 08:44:07
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef LLVM_IR_MANGLER_H
0014 #define LLVM_IR_MANGLER_H
0015
0016 #include "llvm/ADT/DenseMap.h"
0017 #include "llvm/ADT/StringRef.h"
0018
0019 namespace llvm {
0020
0021 class DataLayout;
0022 class GlobalValue;
0023 template <typename T> class SmallVectorImpl;
0024 class Triple;
0025 class Twine;
0026 class raw_ostream;
0027
0028 class Mangler {
0029
0030
0031 mutable DenseMap<const GlobalValue*, unsigned> AnonGlobalIDs;
0032
0033 public:
0034
0035
0036
0037 void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV,
0038 bool CannotUsePrivateLabel) const;
0039 void getNameWithPrefix(SmallVectorImpl<char> &OutName, const GlobalValue *GV,
0040 bool CannotUsePrivateLabel) const;
0041
0042
0043
0044 static void getNameWithPrefix(raw_ostream &OS, const Twine &GVName,
0045 const DataLayout &DL);
0046 static void getNameWithPrefix(SmallVectorImpl<char> &OutName,
0047 const Twine &GVName, const DataLayout &DL);
0048 };
0049
0050 void emitLinkerFlagsForGlobalCOFF(raw_ostream &OS, const GlobalValue *GV,
0051 const Triple &TT, Mangler &Mangler);
0052
0053 void emitLinkerFlagsForUsedCOFF(raw_ostream &OS, const GlobalValue *GV,
0054 const Triple &T, Mangler &M);
0055
0056
0057
0058 std::optional<std::string> getArm64ECMangledFunctionName(StringRef Name);
0059
0060
0061
0062 std::optional<std::string> getArm64ECDemangledFunctionName(StringRef Name);
0063
0064
0065 bool inline isArm64ECMangledFunctionName(StringRef Name) {
0066 return Name[0] == '#' ||
0067 (Name[0] == '?' && Name.find("@$$h") != StringRef::npos);
0068 }
0069
0070 }
0071
0072 #endif