diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp --- a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp +++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp @@ -26,6 +26,7 @@ #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/Support/Casting.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/EndianStream.h" #define DEBUG_TYPE "mccodeemitter" @@ -273,9 +274,7 @@ 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); + support::endian::write(OS, Word, support::endianness::native); } }