[llvm] r346391 - [MSP430] Fix encodeInstruction() for big endian hosts

Anton Korobeynikov via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 8 02:17:52 PST 2018


Author: asl
Date: Thu Nov  8 02:17:52 2018
New Revision: 346391

URL: http://llvm.org/viewvc/llvm-project?rev=346391&view=rev
Log:
[MSP430] Fix encodeInstruction() for big endian hosts

Reviewers: asl

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D54251

Modified:
    llvm/trunk/lib/Target/MSP430/MCTargetDesc/MSP430MCCodeEmitter.cpp

Modified: llvm/trunk/lib/Target/MSP430/MCTargetDesc/MSP430MCCodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MCTargetDesc/MSP430MCCodeEmitter.cpp?rev=346391&r1=346390&r2=346391&view=diff
==============================================================================
--- llvm/trunk/lib/Target/MSP430/MCTargetDesc/MSP430MCCodeEmitter.cpp (original)
+++ llvm/trunk/lib/Target/MSP430/MCTargetDesc/MSP430MCCodeEmitter.cpp Thu Nov  8 02:17:52 2018
@@ -91,12 +91,11 @@ void MSP430MCCodeEmitter::encodeInstruct
   Offset = 2;
 
   uint64_t BinaryOpCode = getBinaryCodeForInstr(MI, Fixups, STI);
-  const uint16_t *Words = reinterpret_cast<uint16_t const *>(&BinaryOpCode);
   size_t WordCount = Size / 2;
 
-  for (size_t i = 0; i < WordCount; ++i) {
-    uint16_t Word = Words[i];
-    support::endian::write(OS, Word, support::little);
+  while (WordCount--) {
+    support::endian::write(OS, (uint16_t)BinaryOpCode, support::little);
+    BinaryOpCode >>= 16;
   }
 }
 




More information about the llvm-commits mailing list