Skip to content

Commit a04279d

Browse files
ricky26nikic
authored andcommitted
[M68k] Update pointer data layout
Fixes PR51626. The M68k requires that all instruction, word and long word reads are aligned to word boundaries. From the 68020 onwards, there is a performance benefit from aligning long words to long word boundaries. The M68k uses the same data layout for pointers and integers. In line with this, this commit updates the pointer data layout to match the layout already set for 32-bit integers: 32:16:32. Differential Revision: https://reviews.llvm.org/D108792
1 parent 411cf42 commit a04279d

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

clang/lib/Basic/Targets/M68k.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ M68kTargetInfo::M68kTargetInfo(const llvm::Triple &Triple,
3737
// FIXME how to wire it with the used object format?
3838
Layout += "-m:e";
3939

40-
// M68k pointers are always 32 bit wide even for 16 bit cpus
41-
Layout += "-p:32:32";
40+
// M68k pointers are always 32 bit wide even for 16-bit CPUs
41+
Layout += "-p:32:16:32";
4242

4343
// M68k integer data types
4444
Layout += "-i8:8:8-i16:16:16-i32:16:32";

llvm/lib/Target/M68k/M68kTargetMachine.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,14 @@ std::string computeDataLayout(const Triple &TT, StringRef CPU,
4949
// FIXME how to wire it with the used object format?
5050
Ret += "-m:e";
5151

52-
// M68k pointers are always 32 bit wide even for 16 bit cpus
53-
Ret += "-p:32:32";
54-
55-
// M68k requires i8 to align on 2 byte boundry
52+
// M68k pointers are always 32 bit wide even for 16-bit CPUs.
53+
// The ABI only specifies 16-bit alignment.
54+
// On at least the 68020+ with a 32-bit bus, there is a performance benefit
55+
// to having 32-bit alignment.
56+
Ret += "-p:32:16:32";
57+
58+
// Bytes do not require special alignment, words are word aligned and
59+
// long words are word aligned at minimum.
5660
Ret += "-i8:8:8-i16:16:16-i32:16:32";
5761

5862
// FIXME no floats at the moment

0 commit comments

Comments
 (0)