Revert r111230, we have to find a better place for the host-specific code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111232 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer 2010-08-17 15:50:23 +00:00
parent 6ccd0da0fe
commit 73c32f60c4

View File

@ -10,10 +10,8 @@
#ifndef LLVM_MC_MCOBJECTWRITER_H
#define LLVM_MC_MCOBJECTWRITER_H
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/System/DataTypes.h"
#include "llvm/System/Host.h"
#include <cassert>
namespace llvm {
@ -94,57 +92,54 @@ public:
}
void WriteLE16(uint16_t Value) {
if (sys::isBigEndianHost())
Value = ByteSwap_16(Value);
OS << StringRef((const char*)&Value, sizeof(Value));
Write8(uint8_t(Value >> 0));
Write8(uint8_t(Value >> 8));
}
void WriteLE32(uint32_t Value) {
if (sys::isBigEndianHost())
Value = ByteSwap_32(Value);
OS << StringRef((const char*)&Value, sizeof(Value));
WriteLE16(uint16_t(Value >> 0));
WriteLE16(uint16_t(Value >> 16));
}
void WriteLE64(uint64_t Value) {
if (sys::isBigEndianHost())
Value = ByteSwap_64(Value);
OS << StringRef((const char*)&Value, sizeof(Value));
WriteLE32(uint32_t(Value >> 0));
WriteLE32(uint32_t(Value >> 32));
}
void WriteBE16(uint16_t Value) {
if (sys::isLittleEndianHost())
Value = ByteSwap_16(Value);
OS << StringRef((const char*)&Value, sizeof(Value));
Write8(uint8_t(Value >> 8));
Write8(uint8_t(Value >> 0));
}
void WriteBE32(uint32_t Value) {
if (sys::isLittleEndianHost())
Value = ByteSwap_32(Value);
OS << StringRef((const char*)&Value, sizeof(Value));
WriteBE16(uint16_t(Value >> 16));
WriteBE16(uint16_t(Value >> 0));
}
void WriteBE64(uint64_t Value) {
if (sys::isLittleEndianHost())
Value = ByteSwap_64(Value);
OS << StringRef((const char*)&Value, sizeof(Value));
WriteBE32(uint32_t(Value >> 32));
WriteBE32(uint32_t(Value >> 0));
}
void Write16(uint16_t Value) {
if (IsLittleEndian != sys::isLittleEndianHost())
Value = ByteSwap_16(Value);
OS << StringRef((const char*)&Value, sizeof(Value));
if (IsLittleEndian)
WriteLE16(Value);
else
WriteBE16(Value);
}
void Write32(uint32_t Value) {
if (IsLittleEndian != sys::isLittleEndianHost())
Value = ByteSwap_32(Value);
OS << StringRef((const char*)&Value, sizeof(Value));
if (IsLittleEndian)
WriteLE32(Value);
else
WriteBE32(Value);
}
void Write64(uint64_t Value) {
if (IsLittleEndian != sys::isLittleEndianHost())
Value = ByteSwap_64(Value);
OS << StringRef((const char*)&Value, sizeof(Value));
if (IsLittleEndian)
WriteLE64(Value);
else
WriteBE64(Value);
}
void WriteZeros(unsigned N) {