aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm
diff options
context:
space:
mode:
authorEli Bendersky <eliben@google.com>2012-12-07 22:06:56 +0000
committerEli Bendersky <eliben@google.com>2012-12-07 22:06:56 +0000
commit550f0ade457c3b042fa099ecff2c022c7ab58b1e (patch)
treed4862ee34165b0a87d78b69cce1254a8da09c6a9 /include/llvm
parentaf59e9adbd4c972d480d58260b03768c85eb2067 (diff)
downloadexternal_llvm-550f0ade457c3b042fa099ecff2c022c7ab58b1e.tar.gz
external_llvm-550f0ade457c3b042fa099ecff2c022c7ab58b1e.tar.bz2
external_llvm-550f0ade457c3b042fa099ecff2c022c7ab58b1e.zip
Make the contents of encoded sections SmallVector<char, N> instead of
SmallString. This makes it possible to use the length-erased SmallVectorImpl in the interface without imposing buffer size. Thus, the size of MCInstFragment is back down since a preallocated 8-byte contents buffer is enough. It would be generally a good idea to rid all the fragments of SmallString as contents, because a vector just makes more sense. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169644 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/MC/MCAssembler.h16
-rw-r--r--include/llvm/MC/MCObjectWriter.h6
2 files changed, 14 insertions, 8 deletions
diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h
index a308030ff6..e2ba91de2a 100644
--- a/include/llvm/MC/MCAssembler.h
+++ b/include/llvm/MC/MCAssembler.h
@@ -113,8 +113,8 @@ public:
typedef SmallVectorImpl<MCFixup>::const_iterator const_fixup_iterator;
typedef SmallVectorImpl<MCFixup>::iterator fixup_iterator;
- virtual SmallString<32> &getContents() = 0;
- virtual const SmallString<32> &getContents() const = 0;
+ virtual SmallVectorImpl<char> &getContents() = 0;
+ virtual const SmallVectorImpl<char> &getContents() const = 0;
virtual SmallVectorImpl<MCFixup> &getFixups() = 0;
virtual const SmallVectorImpl<MCFixup> &getFixups() const = 0;
@@ -132,7 +132,7 @@ public:
class MCDataFragment : public MCEncodedFragment {
virtual void anchor();
- SmallString<32> Contents;
+ SmallVector<char, 32> Contents;
/// Fixups - The list of fixups in this fragment.
SmallVector<MCFixup, 4> Fixups;
@@ -142,8 +142,8 @@ public:
: MCEncodedFragment(FT_Data, SD) {
}
- SmallString<32> &getContents() { return Contents; }
- const SmallString<32> &getContents() const { return Contents; }
+ virtual SmallVectorImpl<char> &getContents() { return Contents; }
+ virtual const SmallVectorImpl<char> &getContents() const { return Contents; }
SmallVectorImpl<MCFixup> &getFixups() {
return Fixups;
@@ -171,7 +171,7 @@ class MCInstFragment : public MCEncodedFragment {
MCInst Inst;
/// Contents - Binary data for the currently encoded instruction.
- SmallString<32> Contents;
+ SmallVector<char, 8> Contents;
/// Fixups - The list of fixups in this fragment.
SmallVector<MCFixup, 1> Fixups;
@@ -181,8 +181,8 @@ public:
: MCEncodedFragment(FT_Inst, SD), Inst(_Inst) {
}
- SmallString<32> &getContents() { return Contents; }
- const SmallString<32> &getContents() const { return Contents; }
+ virtual SmallVectorImpl<char> &getContents() { return Contents; }
+ virtual const SmallVectorImpl<char> &getContents() const { return Contents; }
unsigned getInstSize() const { return Contents.size(); }
const MCInst &getInst() const { return Inst; }
diff --git a/include/llvm/MC/MCObjectWriter.h b/include/llvm/MC/MCObjectWriter.h
index 22f10ffa27..f77b7d853d 100644
--- a/include/llvm/MC/MCObjectWriter.h
+++ b/include/llvm/MC/MCObjectWriter.h
@@ -173,7 +173,13 @@ public:
OS << StringRef(Zeros, N % 16);
}
+ void WriteBytes(SmallVectorImpl<char> &ByteVec, unsigned ZeroFillSize = 0) {
+ WriteBytes(StringRef(ByteVec.data(), ByteVec.size()), ZeroFillSize);
+ }
+
void WriteBytes(StringRef Str, unsigned ZeroFillSize = 0) {
+ // TODO: this version may need to go away once all fragment contents are
+ // converted to SmallVector<char, N>
assert((ZeroFillSize == 0 || Str.size () <= ZeroFillSize) &&
"data size greater than fill size, unexpected large write will occur");
OS << Str;