summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/BinaryStreamWriter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Support/BinaryStreamWriter.cpp')
-rw-r--r--llvm/lib/Support/BinaryStreamWriter.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/Support/BinaryStreamWriter.cpp b/llvm/lib/Support/BinaryStreamWriter.cpp
index 929968bf2e4..986e18da281 100644
--- a/llvm/lib/Support/BinaryStreamWriter.cpp
+++ b/llvm/lib/Support/BinaryStreamWriter.cpp
@@ -11,6 +11,7 @@
#include "llvm/Support/BinaryStreamError.h"
#include "llvm/Support/BinaryStreamReader.h"
#include "llvm/Support/BinaryStreamRef.h"
+#include "llvm/Support/LEB128.h"
using namespace llvm;
@@ -31,6 +32,18 @@ Error BinaryStreamWriter::writeBytes(ArrayRef<uint8_t> Buffer) {
return Error::success();
}
+Error BinaryStreamWriter::writeULEB128(uint64_t Value) {
+ uint8_t EncodedBytes[10] = {0};
+ unsigned Size = encodeULEB128(Value, &EncodedBytes[0]);
+ return writeBytes({EncodedBytes, Size});
+}
+
+Error BinaryStreamWriter::writeSLEB128(int64_t Value) {
+ uint8_t EncodedBytes[10] = {0};
+ unsigned Size = encodeSLEB128(Value, &EncodedBytes[0]);
+ return writeBytes({EncodedBytes, Size});
+}
+
Error BinaryStreamWriter::writeCString(StringRef Str) {
if (auto EC = writeFixedString(Str))
return EC;
OpenPOWER on IntegriCloud