[llvm] 29b4d8f - [AVR] Fix endianness handling in AVR MC
via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 25 02:41:26 PST 2019
Author: serge_sans_paille
Date: 2019-11-25T11:41:05+01:00
New Revision: 29b4d8f19e30910c099c5453da258843d6b7869a
URL: https://github.com/llvm/llvm-project/commit/29b4d8f19e30910c099c5453da258843d6b7869a
DIFF: https://github.com/llvm/llvm-project/commit/29b4d8f19e30910c099c5453da258843d6b7869a.diff
LOG: [AVR] Fix endianness handling in AVR MC
Differential Revision: https://reviews.llvm.org/D67926
Added:
Modified:
llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp
index bc0488778685..db995e247562 100644
--- a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp
+++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp
@@ -25,6 +25,7 @@
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/Support/Casting.h"
+#include "llvm/Support/EndianStream.h"
#include "llvm/Support/raw_ostream.h"
#define DEBUG_TYPE "mccodeemitter"
@@ -268,14 +269,11 @@ unsigned AVRMCCodeEmitter::getMachineOpValue(const MCInst &MI,
void AVRMCCodeEmitter::emitInstruction(uint64_t Val, unsigned Size,
const MCSubtargetInfo &STI,
raw_ostream &OS) const {
- const uint16_t *Words = reinterpret_cast<uint16_t const *>(&Val);
size_t WordCount = Size / 2;
for (int64_t i = WordCount - 1; i >= 0; --i) {
- uint16_t Word = Words[i];
-
- OS << (uint8_t) ((Word & 0x00ff) >> 0);
- OS << (uint8_t) ((Word & 0xff00) >> 8);
+ uint16_t Word = (Val >> (i * 16)) & 0xFFFF;
+ support::endian::write(OS, Word, support::endianness::little);
}
}
More information about the llvm-commits
mailing list