summaryrefslogtreecommitdiff
path: root/lib/MC/MCContext.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-03-13 18:09:26 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-03-13 18:09:26 +0000
commit7e9df19d5f935c52ed4f550997f944930874146d (patch)
tree4ab114134209b45f53116b8c760bae6e4f2ba591 /lib/MC/MCContext.cpp
parent1fa9a14308df8bb7c5abba7d814b79116341aefa (diff)
downloadllvm-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 'lib/MC/MCContext.cpp')
-rw-r--r--lib/MC/MCContext.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp
index 7f211255c6..27f66d8393 100644
--- a/lib/MC/MCContext.cpp
+++ b/lib/MC/MCContext.cpp
@@ -162,32 +162,39 @@ MCSymbol *MCContext::CreateTempSymbol() {
return CreateSymbol(NameSV);
}
-unsigned MCContext::NextInstance(int64_t LocalLabelVal) {
+unsigned MCContext::NextInstance(unsigned LocalLabelVal) {
MCLabel *&Label = Instances[LocalLabelVal];
if (!Label)
Label = new (*this) MCLabel(0);
return Label->incInstance();
}
-unsigned MCContext::GetInstance(int64_t LocalLabelVal) {
+unsigned MCContext::GetInstance(unsigned LocalLabelVal) {
MCLabel *&Label = Instances[LocalLabelVal];
if (!Label)
Label = new (*this) MCLabel(0);
return Label->getInstance();
}
-MCSymbol *MCContext::CreateDirectionalLocalSymbol(int64_t LocalLabelVal) {
- return GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) +
- Twine(LocalLabelVal) +
- "\2" +
- Twine(NextInstance(LocalLabelVal)));
+MCSymbol *MCContext::getOrCreateDirectionalLocalSymbol(unsigned LocalLabelVal,
+ unsigned Instance) {
+ MCSymbol *&Sym = LocalSymbols[std::make_pair(LocalLabelVal, Instance)];
+ if (!Sym)
+ Sym = CreateTempSymbol();
+ return Sym;
+}
+
+MCSymbol *MCContext::CreateDirectionalLocalSymbol(unsigned LocalLabelVal) {
+ unsigned Instance = NextInstance(LocalLabelVal);
+ return getOrCreateDirectionalLocalSymbol(LocalLabelVal, Instance);
}
-MCSymbol *MCContext::GetDirectionalLocalSymbol(int64_t LocalLabelVal,
- int bORf) {
- return GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) +
- Twine(LocalLabelVal) +
- "\2" +
- Twine(GetInstance(LocalLabelVal) + bORf));
+
+MCSymbol *MCContext::GetDirectionalLocalSymbol(unsigned LocalLabelVal,
+ bool Before) {
+ unsigned Instance = GetInstance(LocalLabelVal);
+ if (!Before)
+ ++Instance;
+ return getOrCreateDirectionalLocalSymbol(LocalLabelVal, Instance);
}
MCSymbol *MCContext::LookupSymbol(StringRef Name) const {