-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Fix handling of x18 in AArch64 inline assembly on ohos/trusty or with -Zfixed-x18 #133463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,6 +228,12 @@ const AARCH64_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ | |
("rcpc3", Unstable(sym::aarch64_unstable_target_feature), &["rcpc2"]), | ||
// FEAT_RDM | ||
("rdm", Stable, &["neon"]), | ||
// This is needed for inline assembly, but shouldn't be stabilized as-is | ||
// since it should be enabled globally using -Zfixed-x18, not | ||
// #[target_feature]. | ||
// Note that cfg(target_feature = "reserve-x18") is currently not set for | ||
// targets that reserve x18 by default. | ||
("reserve-x18", Unstable(sym::aarch64_unstable_target_feature), &[]), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any cleaner way this could be done? This really should be listed as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like it just needs things to be listed in |
||
// FEAT_SB | ||
("sb", Stable, &[]), | ||
// FEAT_SHA1 & FEAT_SHA256 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
//@ revisions: aarch64 aarch64_fixed_x18 aarch64_no_x18 aarch64_reserve_x18 arm64ec | ||
//@[aarch64] compile-flags: --target aarch64-unknown-linux-gnu | ||
//@[aarch64] needs-llvm-components: aarch64 | ||
//@[aarch64_fixed_x18] compile-flags: --target aarch64-unknown-linux-gnu -Zfixed-x18 | ||
//@[aarch64_fixed_x18] needs-llvm-components: aarch64 | ||
//@[aarch64_no_x18] compile-flags: --target aarch64-pc-windows-msvc | ||
//@[aarch64_no_x18] needs-llvm-components: aarch64 | ||
// aarch64-unknown-trusty uses aarch64-unknown-unknown-musl which doesn't | ||
// reserve x18 by default as llvm_target, and pass +reserve-x18 in target-spec. | ||
//@[aarch64_reserve_x18] compile-flags: --target aarch64-unknown-trusty | ||
//@[aarch64_reserve_x18] needs-llvm-components: aarch64 | ||
//@[arm64ec] compile-flags: --target arm64ec-pc-windows-msvc | ||
//@[arm64ec] needs-llvm-components: aarch64 | ||
// ignore-tidy-linelength | ||
|
||
#![crate_type = "rlib"] | ||
#![feature(no_core, rustc_attrs, lang_items)] | ||
#![no_core] | ||
|
||
#[lang = "sized"] | ||
trait Sized {} | ||
|
||
#[rustc_builtin_macro] | ||
macro_rules! asm { | ||
() => {}; | ||
} | ||
|
||
// CHECK-LABEL: @cc_clobber | ||
// CHECK: call void asm sideeffect "", "~{cc}"() | ||
#[no_mangle] | ||
pub unsafe fn cc_clobber() { | ||
asm!("", options(nostack, nomem)); | ||
} | ||
|
||
// CHECK-LABEL: @no_clobber | ||
// CHECK: call void asm sideeffect "", ""() | ||
#[no_mangle] | ||
pub unsafe fn no_clobber() { | ||
asm!("", options(nostack, nomem, preserves_flags)); | ||
} | ||
|
||
// CHECK-LABEL: @clobber_abi | ||
// aarch64: asm sideeffect "", "={w0},={w1},={w2},={w3},={w4},={w5},={w6},={w7},={w8},={w9},={w10},={w11},={w12},={w13},={w14},={w15},={w16},={w17},={w18},={w30},={q0},={q1},={q2},={q3},={q4},={q5},={q6},={q7},={q8},={q9},={q10},={q11},={q12},={q13},={q14},={q15},={q16},={q17},={q18},={q19},={q20},={q21},={q22},={q23},={q24},={q25},={q26},={q27},={q28},={q29},={q30},={q31},~{p0},~{p1},~{p2},~{p3},~{p4},~{p5},~{p6},~{p7},~{p8},~{p9},~{p10},~{p11},~{p12},~{p13},~{p14},~{p15},~{ffr}"() | ||
// aarch64_fixed_x18: asm sideeffect "", "={w0},={w1},={w2},={w3},={w4},={w5},={w6},={w7},={w8},={w9},={w10},={w11},={w12},={w13},={w14},={w15},={w16},={w17},={w30},={q0},={q1},={q2},={q3},={q4},={q5},={q6},={q7},={q8},={q9},={q10},={q11},={q12},={q13},={q14},={q15},={q16},={q17},={q18},={q19},={q20},={q21},={q22},={q23},={q24},={q25},={q26},={q27},={q28},={q29},={q30},={q31},~{p0},~{p1},~{p2},~{p3},~{p4},~{p5},~{p6},~{p7},~{p8},~{p9},~{p10},~{p11},~{p12},~{p13},~{p14},~{p15},~{ffr}"() | ||
// aarch64_no_x18: asm sideeffect "", "={w0},={w1},={w2},={w3},={w4},={w5},={w6},={w7},={w8},={w9},={w10},={w11},={w12},={w13},={w14},={w15},={w16},={w17},={w30},={q0},={q1},={q2},={q3},={q4},={q5},={q6},={q7},={q8},={q9},={q10},={q11},={q12},={q13},={q14},={q15},={q16},={q17},={q18},={q19},={q20},={q21},={q22},={q23},={q24},={q25},={q26},={q27},={q28},={q29},={q30},={q31},~{p0},~{p1},~{p2},~{p3},~{p4},~{p5},~{p6},~{p7},~{p8},~{p9},~{p10},~{p11},~{p12},~{p13},~{p14},~{p15},~{ffr}"() | ||
// aarch64_reserve_x18: asm sideeffect "", "={w0},={w1},={w2},={w3},={w4},={w5},={w6},={w7},={w8},={w9},={w10},={w11},={w12},={w13},={w14},={w15},={w16},={w17},={w30},={q0},={q1},={q2},={q3},={q4},={q5},={q6},={q7},={q8},={q9},={q10},={q11},={q12},={q13},={q14},={q15},={q16},={q17},={q18},={q19},={q20},={q21},={q22},={q23},={q24},={q25},={q26},={q27},={q28},={q29},={q30},={q31},~{p0},~{p1},~{p2},~{p3},~{p4},~{p5},~{p6},~{p7},~{p8},~{p9},~{p10},~{p11},~{p12},~{p13},~{p14},~{p15},~{ffr}"() | ||
// arm64ec: asm sideeffect "", "={w0},={w1},={w2},={w3},={w4},={w5},={w6},={w7},={w8},={w9},={w10},={w11},={w12},={w15},={w16},={w17},={w30},={q0},={q1},={q2},={q3},={q4},={q5},={q6},={q7},={q8},={q9},={q10},={q11},={q12},={q13},={q14},={q15}"() | ||
#[no_mangle] | ||
pub unsafe fn clobber_abi() { | ||
asm!("", clobber_abi("C"), options(nostack, nomem, preserves_flags)); | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to avoid duplicating this logic? It seems prone to getting out of sync with llvm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't think of a good way to avoid the duplication unfortunately.