summaryrefslogtreecommitdiff
path: root/user/llvm18/m68k-endianness.patch
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2024-07-06 20:37:32 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2024-08-07 10:08:22 -0500
commite2ec142d7bfd9f2465c62900a03e3accf4adf572 (patch)
treee1f4499d59088adf1da20797fb9f260c2e87bf05 /user/llvm18/m68k-endianness.patch
parentc5c08854322efc2aea8f8bcf51a544976fd86a12 (diff)
downloadpackages-e2ec142d7bfd9f2465c62900a03e3accf4adf572.tar.gz
packages-e2ec142d7bfd9f2465c62900a03e3accf4adf572.tar.bz2
packages-e2ec142d7bfd9f2465c62900a03e3accf4adf572.tar.xz
packages-e2ec142d7bfd9f2465c62900a03e3accf4adf572.zip
user/llvm18: New package
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;
+ }