summaryrefslogtreecommitdiff
path: root/user/llvm18/m68k-endianness.patch
diff options
context:
space:
mode:
Diffstat (limited to 'user/llvm18/m68k-endianness.patch')
-rw-r--r--user/llvm18/m68k-endianness.patch26
1 files changed, 26 insertions, 0 deletions
diff --git a/user/llvm18/m68k-endianness.patch b/user/llvm18/m68k-endianness.patch
new file mode 100644
index 000000000..49e96a995
--- /dev/null
+++ b/user/llvm18/m68k-endianness.patch
@@ -0,0 +1,26 @@
+Upstream: https://github.com/llvm/llvm-project/issues/94726
+
+diff --git a/lib/Target/M68k/MCTargetDesc/M68kBaseInfo.h b/lib/Target/M68k/MCTargetDesc/M68kBaseInfo.h
+index 1376b06bef6f..62ea03cc9760 100644
+--- a/lib/Target/M68k/MCTargetDesc/M68kBaseInfo.h
++++ b/lib/Target/M68k/MCTargetDesc/M68kBaseInfo.h
+@@ -85,9 +85,16 @@ template <typename value_t> value_t swapWord(value_t Val) {
+ Val = support::endian::byte_swap(Val, llvm::endianness::big);
+ value_t NewVal = 0;
+ for (unsigned i = 0U; i != NumWords; ++i) {
+- uint16_t Part = (Val >> (i * 16)) & 0xFFFF;
+- Part = support::endian::byte_swap(Part, llvm::endianness::big);
+- NewVal |= (Part << (i * 16));
++ if (llvm::endianness::native == llvm::endianness::big) {
++ uint16_t Lo = (Val >> (i * 16)) & 0xFFFF;
++ NewVal |= (Lo << (++i * 16));
++ uint16_t Hi = (Val >> (++i * 16)) & 0xFFFF;
++ NewVal |= (Hi << ((i - 1) * 16));
++ } else {
++ uint16_t Part = (Val >> (i * 16)) & 0xFFFF;
++ Part = support::endian::byte_swap(Part, llvm::endianness::big);
++ NewVal |= (Part << (i * 16));
++ }
+ }
+ return NewVal;
+ }