Remove vestigal bits of MC from the mangler. It no longer uses this, and
[oota-llvm.git] / include / llvm / IR / Mangler.h
1 //===-- llvm/IR/Mangler.h - Self-contained name mangler ---------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Unified name mangler for various backends.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_TARGET_MANGLER_H
15 #define LLVM_TARGET_MANGLER_H
16
17 #include "llvm/ADT/DenseMap.h"
18
19 namespace llvm {
20
21 class DataLayout;
22 class GlobalValue;
23 template <typename T> class SmallVectorImpl;
24 class Twine;
25
26 class Mangler {
27 public:
28   enum ManglerPrefixTy {
29     Default,               ///< Emit default string before each symbol.
30     Private,               ///< Emit "private" prefix before each symbol.
31     LinkerPrivate          ///< Emit "linker private" prefix before each symbol.
32   };
33
34 private:
35   const DataLayout *DL;
36
37   /// AnonGlobalIDs - We need to give global values the same name every time
38   /// they are mangled.  This keeps track of the number we give to anonymous
39   /// ones.
40   ///
41   DenseMap<const GlobalValue*, unsigned> AnonGlobalIDs;
42
43   /// NextAnonGlobalID - This simple counter is used to unique value names.
44   ///
45   unsigned NextAnonGlobalID;
46
47 public:
48   Mangler(const DataLayout *DL) : DL(DL), NextAnonGlobalID(1) {}
49
50   /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix
51   /// and the specified global variable's name.  If the global variable doesn't
52   /// have a name, this fills in a unique name for the global.
53   void getNameWithPrefix(SmallVectorImpl<char> &OutName, const GlobalValue *GV);
54
55   /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix
56   /// and the specified name as the global variable name.  GVName must not be
57   /// empty.
58   void getNameWithPrefix(SmallVectorImpl<char> &OutName, const Twine &GVName,
59                          ManglerPrefixTy PrefixTy = Mangler::Default);
60 };
61
62 } // End llvm namespace
63
64 #endif // LLVM_TARGET_MANGLER_H