summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCContext.cpp
diff options
context:
space:
mode:
authorKevin Enderby <enderby@apple.com>2010-05-17 23:08:19 +0000
committerKevin Enderby <enderby@apple.com>2010-05-17 23:08:19 +0000
commit0510b48fd97cd37fe6297117d82bacb683c3aa39 (patch)
treed235dbaa55c275573afa801ef39477e0b861a11e /llvm/lib/MC/MCContext.cpp
parent990783e345ee0ddd1f0372c20da0d0c9d884fef6 (diff)
downloadbcm5719-llvm-0510b48fd97cd37fe6297117d82bacb683c3aa39.tar.gz
bcm5719-llvm-0510b48fd97cd37fe6297117d82bacb683c3aa39.zip
Added support in MC for Directional Local Labels.
llvm-svn: 103989
Diffstat (limited to 'llvm/lib/MC/MCContext.cpp')
-rw-r--r--llvm/lib/MC/MCContext.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 5a65b8ae380..5cc72e8e9f5 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -13,6 +13,7 @@
#include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCSectionCOFF.h"
#include "llvm/MC/MCSymbol.h"
+#include "llvm/MC/MCLabel.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/Twine.h"
using namespace llvm;
@@ -71,6 +72,50 @@ MCSymbol *MCContext::CreateTempSymbol() {
"tmp" + Twine(NextUniqueID++));
}
+unsigned MCContext::NextInstance(int64_t LocalLabelVal) {
+ unsigned Instance;
+ MCLabel *Label;
+ Label = Instances[LocalLabelVal];
+ if (Label) {
+ Instance = Label->incInstance();
+ }
+ else {
+ Instance = 1;
+ Label = new MCLabel(Instance);
+ Instances[LocalLabelVal] = Label;
+ }
+ return Instance;
+}
+
+unsigned MCContext::GetInstance(int64_t LocalLabelVal) {
+ int Instance;
+ MCLabel *Label;
+ Label = Instances[LocalLabelVal];
+ if (Label) {
+ Instance = Label->getInstance();
+ }
+ else {
+ Instance = 0;
+ Label = new MCLabel(Instance);
+ Instances[LocalLabelVal] = Label;
+ }
+ return Instance;
+}
+
+MCSymbol *MCContext::CreateDirectionalLocalSymbol(int64_t LocalLabelVal) {
+ return GetOrCreateSymbol(Twine(MAI.getPrivateGlobalPrefix()) +
+ Twine(LocalLabelVal) +
+ "\2" +
+ Twine(NextInstance(LocalLabelVal)));
+}
+MCSymbol *MCContext::GetDirectionalLocalSymbol(int64_t LocalLabelVal,
+ int bORf) {
+ return GetOrCreateSymbol(Twine(MAI.getPrivateGlobalPrefix()) +
+ Twine(LocalLabelVal) +
+ "\2" +
+ Twine(GetInstance(LocalLabelVal) + bORf));
+}
+
MCSymbol *MCContext::LookupSymbol(StringRef Name) const {
return Symbols.lookup(Name);
}
OpenPOWER on IntegriCloud