1 //===-- Mangler.h - Self-contained llvm name mangler ------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Unified name mangler for various backends.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_SUPPORT_MANGLER_H
15 #define LLVM_SUPPORT_MANGLER_H
27 /// This keeps track of which global values have had their names
28 /// mangled in the current module.
30 std::set<const Value *> MangledGlobals;
33 bool AddUnderscorePrefix;
35 typedef std::map<const Value *, std::string> ValueMap;
40 void InsertName(GlobalValue *GV, std::map<std::string, GlobalValue*> &Names);
43 // Mangler ctor - if AddUnderscorePrefix is true, then all public global
44 // symbols will be prefixed with an underscore.
45 Mangler(Module &M, bool AddUnderscorePrefix = false);
47 /// getValueName - Returns the mangled name of V, an LLVM Value,
48 /// in the current module.
50 std::string getValueName(const Value *V);
52 /// makeNameProper - We don't want identifier names with ., space, or
53 /// - in them, so we mangle these characters into the strings "d_",
54 /// "s_", and "D_", respectively. This is a very simple mangling that
55 /// doesn't guarantee unique names for values. getValueName already
56 /// does this for you, so there's no point calling it on the result
57 /// from getValueName.
59 static std::string makeNameProper(const std::string &x);
62 } // End llvm namespace
64 #endif // LLVM_SUPPORT_MANGLER_H