forked from OSchip/llvm-project
[AVR] Fix endianness handling in AVR MC
Differential Revision: https://reviews.llvm.org/D67926
This commit is contained in:
parent
9659464d7e
commit
29b4d8f19e
|
@ -25,6 +25,7 @@
|
||||||
#include "llvm/MC/MCRegisterInfo.h"
|
#include "llvm/MC/MCRegisterInfo.h"
|
||||||
#include "llvm/MC/MCSubtargetInfo.h"
|
#include "llvm/MC/MCSubtargetInfo.h"
|
||||||
#include "llvm/Support/Casting.h"
|
#include "llvm/Support/Casting.h"
|
||||||
|
#include "llvm/Support/EndianStream.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
|
||||||
#define DEBUG_TYPE "mccodeemitter"
|
#define DEBUG_TYPE "mccodeemitter"
|
||||||
|
@ -268,14 +269,11 @@ unsigned AVRMCCodeEmitter::getMachineOpValue(const MCInst &MI,
|
||||||
void AVRMCCodeEmitter::emitInstruction(uint64_t Val, unsigned Size,
|
void AVRMCCodeEmitter::emitInstruction(uint64_t Val, unsigned Size,
|
||||||
const MCSubtargetInfo &STI,
|
const MCSubtargetInfo &STI,
|
||||||
raw_ostream &OS) const {
|
raw_ostream &OS) const {
|
||||||
const uint16_t *Words = reinterpret_cast<uint16_t const *>(&Val);
|
|
||||||
size_t WordCount = Size / 2;
|
size_t WordCount = Size / 2;
|
||||||
|
|
||||||
for (int64_t i = WordCount - 1; i >= 0; --i) {
|
for (int64_t i = WordCount - 1; i >= 0; --i) {
|
||||||
uint16_t Word = Words[i];
|
uint16_t Word = (Val >> (i * 16)) & 0xFFFF;
|
||||||
|
support::endian::write(OS, Word, support::endianness::little);
|
||||||
OS << (uint8_t) ((Word & 0x00ff) >> 0);
|
|
||||||
OS << (uint8_t) ((Word & 0xff00) >> 8);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue