diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-03-13 18:09:26 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-03-13 18:09:26 +0000 |
commit | 7e9df19d5f935c52ed4f550997f944930874146d (patch) | |
tree | 4ab114134209b45f53116b8c760bae6e4f2ba591 /include | |
parent | 1fa9a14308df8bb7c5abba7d814b79116341aefa (diff) | |
download | llvm-7e9df19d5f935c52ed4f550997f944930874146d.tar.gz llvm-7e9df19d5f935c52ed4f550997f944930874146d.tar.bz2 llvm-7e9df19d5f935c52ed4f550997f944930874146d.tar.xz |
Use printable names to implement directional labels.
This changes the implementation of local directional labels to use a dedicated
map. With that it can then just use CreateTempSymbol, which is what the rest
of MC uses.
CreateTempSymbol doesn't do a great job at making sure the names are unique
(or being efficient when the names are not needed), but that should probably
be fixed in a followup patch.
This fixes pr18928.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203826 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/MC/MCContext.h | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/include/llvm/MC/MCContext.h b/include/llvm/MC/MCContext.h index f0e8f0729b..51e2d89ed1 100644 --- a/include/llvm/MC/MCContext.h +++ b/include/llvm/MC/MCContext.h @@ -70,6 +70,14 @@ namespace llvm { /// Symbols - Bindings of names to symbols. SymbolTable Symbols; + /// A maping from a local label number and an instance count to a symbol. + /// For example, in the assembly + /// 1: + /// 2: + /// 1: + /// We have three labels represented by the pairs (1, 0), (2, 0) and (1, 1) + DenseMap<std::pair<unsigned, unsigned>, MCSymbol*> LocalSymbols; + /// UsedNames - Keeps tracks of names that were used both for used declared /// and artificial symbols. StringMap<bool, BumpPtrAllocator&> UsedNames; @@ -82,10 +90,10 @@ namespace llvm { DenseMap<unsigned, MCLabel *> Instances; /// NextInstance() creates the next instance of the directional local label /// for the LocalLabelVal and adds it to the map if needed. - unsigned NextInstance(int64_t LocalLabelVal); + unsigned NextInstance(unsigned LocalLabelVal); /// GetInstance() gets the current instance of the directional local label /// for the LocalLabelVal and adds it to the map if needed. - unsigned GetInstance(int64_t LocalLabelVal); + unsigned GetInstance(unsigned LocalLabelVal); /// The file name of the log file from the environment variable /// AS_SECURE_LOG_FILE. Which must be set before the .secure_log_unique @@ -154,6 +162,9 @@ namespace llvm { MCSymbol *CreateSymbol(StringRef Name); + MCSymbol *getOrCreateDirectionalLocalSymbol(unsigned LocalLabelVal, + unsigned Instance); + public: explicit MCContext(const MCAsmInfo *MAI, const MCRegisterInfo *MRI, const MCObjectFileInfo *MOFI, const SourceMgr *Mgr = 0, @@ -190,13 +201,13 @@ namespace llvm { /// symbol names. unsigned getUniqueSymbolID() { return NextUniqueID++; } - /// CreateDirectionalLocalSymbol - Create the definition of a directional - /// local symbol for numbered label (used for "1:" definitions). - MCSymbol *CreateDirectionalLocalSymbol(int64_t LocalLabelVal); + /// Create the definition of a directional local symbol for numbered label + /// (used for "1:" definitions). + MCSymbol *CreateDirectionalLocalSymbol(unsigned LocalLabelVal); - /// GetDirectionalLocalSymbol - Create and return a directional local - /// symbol for numbered label (used for "1b" or 1f" references). - MCSymbol *GetDirectionalLocalSymbol(int64_t LocalLabelVal, int bORf); + /// Create and return a directional local symbol for numbered label (used + /// for "1b" or 1f" references). + MCSymbol *GetDirectionalLocalSymbol(unsigned LocalLabelVal, bool Before); /// GetOrCreateSymbol - Lookup the symbol inside with the specified /// @p Name. If it exists, return it. If not, create a forward |