[PATCH] D54251: [MSP430] Fix encodeInstruction() for big endian hosts

Anton Korobeynikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 8 02:20:18 PST 2018


This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL346391: [MSP430] Fix encodeInstruction() for big endian hosts (authored by asl, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D54251

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


Index: llvm/trunk/lib/Target/MSP430/MCTargetDesc/MSP430MCCodeEmitter.cpp
===================================================================
--- llvm/trunk/lib/Target/MSP430/MCTargetDesc/MSP430MCCodeEmitter.cpp
+++ llvm/trunk/lib/Target/MSP430/MCTargetDesc/MSP430MCCodeEmitter.cpp
@@ -91,12 +91,11 @@
   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;
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54251.173133.patch
Type: text/x-patch
Size: 763 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181108/e084c848/attachment.bin>


More information about the llvm-commits mailing list