Rollup merge of #132422 - maurer:sparc-layout, r=durin42

llvm: Match new LLVM 128-bit integer alignment on sparc

LLVM continues to align more 128-bit integers to 128-bits in the data layout rather than relying on the high level language to do it. Update SPARC target files to match and add a backcompat replacement for current LLVMs.

See llvm/llvm-project#106951 for details

`@rustbot` label: +llvm-main

r? `@durin42`

(Please wait for the LLVM CI to come back before approving), creating this PR to get it tested there.
This commit is contained in:
Jubilee 2024-10-31 17:50:44 -07:00 committed by GitHub
commit acd839d992
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 11 additions and 6 deletions

View File

@ -148,6 +148,11 @@ pub(crate) unsafe fn create_module<'ll>(
target_data_layout = target_data_layout =
target_data_layout.replace("-p270:32:32-p271:32:32-p272:64:64", ""); target_data_layout.replace("-p270:32:32-p271:32:32-p272:64:64", "");
} }
if sess.target.arch.starts_with("sparc") {
// LLVM 20 updates the sparc layout to correctly align 128 bit integers to 128 bit.
// See https://github.com/llvm/llvm-project/pull/106951
target_data_layout = target_data_layout.replace("-i128:128", "");
}
} }
// Ensure the data-layout values hardcoded remain the defaults. // Ensure the data-layout values hardcoded remain the defaults.

View File

@ -16,7 +16,7 @@ pub(crate) fn target() -> Target {
std: Some(true), std: Some(true),
}, },
pointer_width: 64, pointer_width: 64,
data_layout: "E-m:e-i64:64-n32:64-S128".into(), data_layout: "E-m:e-i64:64-i128:128-n32:64-S128".into(),
arch: "sparc64".into(), arch: "sparc64".into(),
options: base, options: base,
} }

View File

@ -16,7 +16,7 @@ pub(crate) fn target() -> Target {
std: Some(true), std: Some(true),
}, },
pointer_width: 64, pointer_width: 64,
data_layout: "E-m:e-i64:64-n32:64-S128".into(), data_layout: "E-m:e-i64:64-i128:128-n32:64-S128".into(),
arch: "sparc64".into(), arch: "sparc64".into(),
options: TargetOptions { endian: Endian::Big, mcount: "__mcount".into(), ..base }, options: TargetOptions { endian: Endian::Big, mcount: "__mcount".into(), ..base },
} }

View File

@ -17,7 +17,7 @@ pub(crate) fn target() -> Target {
std: Some(true), std: Some(true),
}, },
pointer_width: 64, pointer_width: 64,
data_layout: "E-m:e-i64:64-n32:64-S128".into(), data_layout: "E-m:e-i64:64-i128:128-n32:64-S128".into(),
arch: "sparc64".into(), arch: "sparc64".into(),
options: base, options: base,
} }

View File

@ -11,7 +11,7 @@ pub(crate) fn target() -> Target {
std: Some(true), std: Some(true),
}, },
pointer_width: 32, pointer_width: 32,
data_layout: "E-m:e-p:32:32-i64:64-f128:64-n32-S64".into(), data_layout: "E-m:e-p:32:32-i64:64-i128:128-f128:64-n32-S64".into(),
arch: "sparc".into(), arch: "sparc".into(),
options: TargetOptions { options: TargetOptions {
cpu: "v9".into(), cpu: "v9".into(),

View File

@ -17,7 +17,7 @@ pub(crate) fn target() -> Target {
..Default::default() ..Default::default()
}; };
Target { Target {
data_layout: "E-m:e-p:32:32-i64:64-f128:64-n32-S64".into(), data_layout: "E-m:e-p:32:32-i64:64-i128:128-f128:64-n32-S64".into(),
llvm_target: "sparc-unknown-none-elf".into(), llvm_target: "sparc-unknown-none-elf".into(),
metadata: crate::spec::TargetMetadata { metadata: crate::spec::TargetMetadata {
description: Some("Bare 32-bit SPARC V7+".into()), description: Some("Bare 32-bit SPARC V7+".into()),

View File

@ -19,7 +19,7 @@ pub(crate) fn target() -> Target {
std: Some(true), std: Some(true),
}, },
pointer_width: 64, pointer_width: 64,
data_layout: "E-m:e-i64:64-n32:64-S128".into(), data_layout: "E-m:e-i64:64-i128:128-n32:64-S128".into(),
// Use "sparc64" instead of "sparcv9" here, since the former is already // Use "sparc64" instead of "sparcv9" here, since the former is already
// used widely in the source base. If we ever needed ABI // used widely in the source base. If we ever needed ABI
// differentiation from the sparc64, we could, but that would probably // differentiation from the sparc64, we could, but that would probably