aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Target')
-rw-r--r--lib/Target/ELFTargetAsmInfo.cpp60
-rw-r--r--lib/Target/Sparc/SparcTargetAsmInfo.cpp31
-rw-r--r--lib/Target/Sparc/SparcTargetAsmInfo.h4
-rw-r--r--lib/Target/TargetAsmInfo.cpp13
-rw-r--r--lib/Target/X86/X86TargetAsmInfo.cpp21
-rw-r--r--lib/Target/X86/X86TargetAsmInfo.h4
6 files changed, 67 insertions, 66 deletions
diff --git a/lib/Target/ELFTargetAsmInfo.cpp b/lib/Target/ELFTargetAsmInfo.cpp
index 258542c..b64c0b6 100644
--- a/lib/Target/ELFTargetAsmInfo.cpp
+++ b/lib/Target/ELFTargetAsmInfo.cpp
@@ -168,38 +168,44 @@ ELFTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const {
return getReadOnlySection();
}
-std::string ELFTargetAsmInfo::printSectionFlags(unsigned flags) const {
- std::string Flags = ",\"";
-
- if (!(flags & SectionFlags::Debug))
- Flags += 'a';
- if (flags & SectionFlags::Code)
- Flags += 'x';
- if (flags & SectionFlags::Writable)
- Flags += 'w';
- if (flags & SectionFlags::Mergeable)
- Flags += 'M';
- if (flags & SectionFlags::Strings)
- Flags += 'S';
- if (flags & SectionFlags::TLS)
- Flags += 'T';
-
- Flags += "\",";
+void ELFTargetAsmInfo::getSectionFlags(unsigned Flags,
+ SmallVectorImpl<char> &Str) const {
+ Str.push_back(',');
+ Str.push_back('"');
+
+ if (!(Flags & SectionFlags::Debug))
+ Str.push_back('a');
+ if (Flags & SectionFlags::Code)
+ Str.push_back('x');
+ if (Flags & SectionFlags::Writable)
+ Str.push_back('w');
+ if (Flags & SectionFlags::Mergeable)
+ Str.push_back('M');
+ if (Flags & SectionFlags::Strings)
+ Str.push_back('S');
+ if (Flags & SectionFlags::TLS)
+ Str.push_back('T');
+
+ Str.push_back('"');
+ Str.push_back(',');
// If comment string is '@', e.g. as on ARM - use '%' instead
if (strcmp(CommentString, "@") == 0)
- Flags += '%';
+ Str.push_back('%');
else
- Flags += '@';
+ Str.push_back('@');
- // FIXME: There can be exceptions here
- if (flags & SectionFlags::BSS)
- Flags += "nobits";
+ const char *KindStr;
+ if (Flags & SectionFlags::BSS)
+ KindStr = "nobits";
else
- Flags += "progbits";
-
- if (unsigned entitySize = SectionFlags::getEntitySize(flags))
- Flags += "," + utostr(entitySize);
+ KindStr = "progbits";
+
+ Str.append(KindStr, KindStr+strlen(KindStr));
- return Flags;
+ if (unsigned entitySize = SectionFlags::getEntitySize(Flags)) {
+ Str.push_back(',');
+ std::string Size = utostr(entitySize);
+ Str.append(Size.begin(), Size.end());
+ }
}
diff --git a/lib/Target/Sparc/SparcTargetAsmInfo.cpp b/lib/Target/Sparc/SparcTargetAsmInfo.cpp
index 0087c26..7b9f449 100644
--- a/lib/Target/Sparc/SparcTargetAsmInfo.cpp
+++ b/lib/Target/Sparc/SparcTargetAsmInfo.cpp
@@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#include "SparcTargetAsmInfo.h"
-
+#include "llvm/ADT/SmallVector.h"
using namespace llvm;
SparcELFTargetAsmInfo::SparcELFTargetAsmInfo(const TargetMachine &TM):
@@ -32,19 +32,22 @@ SparcELFTargetAsmInfo::SparcELFTargetAsmInfo(const TargetMachine &TM):
/* Override */ true);
}
-std::string SparcELFTargetAsmInfo::printSectionFlags(unsigned flags) const {
- if (flags & SectionFlags::Mergeable)
- return ELFTargetAsmInfo::printSectionFlags(flags);
- std::string Flags;
- if (!(flags & SectionFlags::Debug))
- Flags += ",#alloc";
- if (flags & SectionFlags::Code)
- Flags += ",#execinstr";
- if (flags & SectionFlags::Writable)
- Flags += ",#write";
- if (flags & SectionFlags::TLS)
- Flags += ",#tls";
+void SparcELFTargetAsmInfo::getSectionFlags(unsigned Flags,
+ SmallVectorImpl<char> &Str) const {
+ if (Flags & SectionFlags::Mergeable)
+ return ELFTargetAsmInfo::getSectionFlags(Flags, Str);
+
+ // FIXME: Inefficient.
+ std::string Res;
+ if (!(Flags & SectionFlags::Debug))
+ Res += ",#alloc";
+ if (Flags & SectionFlags::Code)
+ Res += ",#execinstr";
+ if (Flags & SectionFlags::Writable)
+ Res += ",#write";
+ if (Flags & SectionFlags::TLS)
+ Res += ",#tls";
- return Flags;
+ Str.append(Res.begin(), Res.end());
}
diff --git a/lib/Target/Sparc/SparcTargetAsmInfo.h b/lib/Target/Sparc/SparcTargetAsmInfo.h
index 1af5d80..77cf4e9 100644
--- a/lib/Target/Sparc/SparcTargetAsmInfo.h
+++ b/lib/Target/Sparc/SparcTargetAsmInfo.h
@@ -25,7 +25,9 @@ namespace llvm {
struct SparcELFTargetAsmInfo : public ELFTargetAsmInfo {
explicit SparcELFTargetAsmInfo(const TargetMachine &TM);
- std::string printSectionFlags(unsigned flags) const;
+ virtual void getSectionFlags(unsigned Flags,
+ SmallVectorImpl<char> &Str) const;
+
};
} // namespace llvm
diff --git a/lib/Target/TargetAsmInfo.cpp b/lib/Target/TargetAsmInfo.cpp
index b0aeff6..0052075 100644
--- a/lib/Target/TargetAsmInfo.cpp
+++ b/lib/Target/TargetAsmInfo.cpp
@@ -416,19 +416,6 @@ TargetAsmInfo::getUnnamedSection(const char *Directive, unsigned Flags,
return &S;
}
-const std::string&
-TargetAsmInfo::getSectionFlags(unsigned Flags) const {
- SectionFlags::FlagsStringsMapType::iterator I = FlagsStrings.find(Flags);
-
- // We didn't print these flags yet, print and save them to map. This reduces
- // amount of heap trashing due to std::string construction / concatenation.
- if (I == FlagsStrings.end())
- I = FlagsStrings.insert(std::make_pair(Flags,
- printSectionFlags(Flags))).first;
-
- return I->second;
-}
-
unsigned TargetAsmInfo::getULEB128Size(unsigned Value) {
unsigned Size = 0;
do {
diff --git a/lib/Target/X86/X86TargetAsmInfo.cpp b/lib/Target/X86/X86TargetAsmInfo.cpp
index 5de9d69..b584cb4 100644
--- a/lib/Target/X86/X86TargetAsmInfo.cpp
+++ b/lib/Target/X86/X86TargetAsmInfo.cpp
@@ -274,17 +274,18 @@ getSectionPrefixForUniqueGlobal(SectionKind Kind) const {
return ".rdata$linkonce";
}
-std::string X86COFFTargetAsmInfo::printSectionFlags(unsigned flags) const {
- std::string Flags = ",\"";
- if (flags & SectionFlags::Code)
- Flags += 'x';
- if (flags & SectionFlags::Writable)
- Flags += 'w';
-
- Flags += "\"";
-
- return Flags;
+void X86COFFTargetAsmInfo::getSectionFlags(unsigned Flags,
+ SmallVectorImpl<char> &Str) const {
+ // FIXME: Inefficient.
+ std::string Res = ",\"";
+ if (Flags & SectionFlags::Code)
+ Res += 'x';
+ if (Flags & SectionFlags::Writable)
+ Res += 'w';
+ Res += "\"";
+
+ Str.append(Res.begin(), Res.end());
}
X86WinTargetAsmInfo::X86WinTargetAsmInfo(const X86TargetMachine &TM):
diff --git a/lib/Target/X86/X86TargetAsmInfo.h b/lib/Target/X86/X86TargetAsmInfo.h
index af1ee2d..75cd04c 100644
--- a/lib/Target/X86/X86TargetAsmInfo.h
+++ b/lib/Target/X86/X86TargetAsmInfo.h
@@ -55,7 +55,9 @@ namespace llvm {
bool Global) const;
virtual const char *
getSectionPrefixForUniqueGlobal(SectionKind kind) const;
- virtual std::string printSectionFlags(unsigned flags) const;
+
+ virtual void getSectionFlags(unsigned Flags,
+ SmallVectorImpl<char> &Str) const;
};
struct X86WinTargetAsmInfo : public X86GenericTargetAsmInfo {