1 //===- lib/MC/MCObjectWriter.cpp - MCObjectWriter implementation ----------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/MC/MCObjectWriter.h"
14 MCObjectWriter::~MCObjectWriter() {
17 /// Utility function to encode a SLEB128 value.
18 void MCObjectWriter::EncodeSLEB128(int64_t Value, raw_ostream &OS) {
21 uint8_t Byte = Value & 0x7f;
22 // NOTE: this assumes that this signed shift is an arithmetic right shift.
24 More = !((((Value == 0 ) && ((Byte & 0x40) == 0)) ||
25 ((Value == -1) && ((Byte & 0x40) != 0))));
27 Byte |= 0x80; // Mark this byte that that more bytes will follow.
32 /// Utility function to encode a ULEB128 value.
33 void MCObjectWriter::EncodeULEB128(uint64_t Value, raw_ostream &OS) {
35 uint8_t Byte = Value & 0x7f;
38 Byte |= 0x80; // Mark this byte that that more bytes will follow.