aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/AsmPrinter/ByteStreamer.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/AsmPrinter/ByteStreamer.h')
-rw-r--r--lib/CodeGen/AsmPrinter/ByteStreamer.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/CodeGen/AsmPrinter/ByteStreamer.h b/lib/CodeGen/AsmPrinter/ByteStreamer.h
index 42be114..179a4d4 100644
--- a/lib/CodeGen/AsmPrinter/ByteStreamer.h
+++ b/lib/CodeGen/AsmPrinter/ByteStreamer.h
@@ -19,6 +19,8 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/MC/MCStreamer.h"
+#include "llvm/Support/LEB128.h"
+#include <string>
namespace llvm {
class ByteStreamer {
@@ -66,6 +68,33 @@ class HashingByteStreamer : public ByteStreamer {
Hash.addULEB128(DWord);
}
};
+
+class BufferByteStreamer : public ByteStreamer {
+private:
+ SmallVectorImpl<char> &Buffer;
+ // FIXME: This is actually only needed for textual asm output.
+ SmallVectorImpl<std::string> &Comments;
+
+public:
+ BufferByteStreamer(SmallVectorImpl<char> &Buffer,
+ SmallVectorImpl<std::string> &Comments)
+ : Buffer(Buffer), Comments(Comments) {}
+ void EmitInt8(uint8_t Byte, const Twine &Comment) override {
+ Buffer.push_back(Byte);
+ Comments.push_back(Comment.str());
+ }
+ void EmitSLEB128(uint64_t DWord, const Twine &Comment) override {
+ raw_svector_ostream OSE(Buffer);
+ encodeSLEB128(DWord, OSE);
+ Comments.push_back(Comment.str());
+ }
+ void EmitULEB128(uint64_t DWord, const Twine &Comment) override {
+ raw_svector_ostream OSE(Buffer);
+ encodeULEB128(DWord, OSE);
+ Comments.push_back(Comment.str());
+ }
+};
+
}
#endif