diff options
author | Brian Gaeke <gaeke@uiuc.edu> | 2003-07-24 20:20:58 +0000 |
---|---|---|
committer | Brian Gaeke <gaeke@uiuc.edu> | 2003-07-24 20:20:58 +0000 |
commit | b198ca304b1abb2784291315f19c89d04e5968fd (patch) | |
tree | 3646eaf8b54e13887bb83f8af4408f6afb5bcb32 /include | |
parent | d9fb37ac98d2bafdee8170f3c4ecca4627ca83aa (diff) | |
download | llvm-b198ca304b1abb2784291315f19c89d04e5968fd.tar.gz llvm-b198ca304b1abb2784291315f19c89d04e5968fd.tar.bz2 llvm-b198ca304b1abb2784291315f19c89d04e5968fd.tar.xz |
Factor out name-mangling from X86/Printer, which is derived from CWriter,
into this new support class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7300 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Support/Mangler.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/include/llvm/Support/Mangler.h b/include/llvm/Support/Mangler.h new file mode 100644 index 0000000000..3e01ac0bee --- /dev/null +++ b/include/llvm/Support/Mangler.h @@ -0,0 +1,45 @@ +//===-- Mangler.h - Self-contained c/asm llvm name mangler ----------------===// +// +// Unified name mangler for CWriter and assembly backends. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_MANGLER_H +#define LLVM_SUPPORT_MANGLER_H + +class Value; +#include <map> + +class Mangler { +public: + /// getValueName - Returns the mangled name of V, an LLVM Value, + /// in the current module. + /// + std::string getValueName(const Value *V); + + Mangler(Module &_M); + + /// makeNameProper - We don't want identifier names with ., space, or + /// - in them, so we mangle these characters into the strings "d_", + /// "s_", and "D_", respectively. This is a very simple mangling that + /// doesn't guarantee unique names for values. getValueName already + /// does this for you, so there's no point calling it on the result + /// from getValueName. + /// + static std::string makeNameProper(std::string x); + +private: + /// This keeps track of which global values have had their names + /// mangled in the current module. + /// + std::set<const Value *> MangledGlobals; + + Module &M; + + typedef std::map<const Value *, std::string> ValueMap; + ValueMap Memo; + + long long Count; +}; + +#endif // LLVM_SUPPORT_MANGLER_H |