about summary refs log tree commit diff
path: root/compiler/rustc_target/src
diff options
context:
space:
mode:
authorTrevor Gross <t.gross35@gmail.com>2024-07-22 11:40:19 -0500
committerGitHub <noreply@github.com>2024-07-22 11:40:19 -0500
commit5e8e46cbd2f60693bd9b1f01a279faf62341a887 (patch)
treec263e2f11190fd54b58b361ab2d516565cbd595d /compiler/rustc_target/src
parent81135a015fe157206dbbda278e67a2a033561ff0 (diff)
parent01e6e60bf363e5ac056717f7bec8703a7b941c8b (diff)
downloadrust-5e8e46cbd2f60693bd9b1f01a279faf62341a887.tar.gz
rust-5e8e46cbd2f60693bd9b1f01a279faf62341a887.zip
Rollup merge of #127506 - liushuyu:s390x-target-features, r=davidtwco
rustc_target: add known safe s390x target features

This pull request adds known safe target features for s390x (aka IBM Z systems).
Currently, these features are unstable since stabilizing the target features requires submitting proposals.

The `vector` feature was added in IBM Z13 (`arch11`), and this is a SIMD feature for the newer IBM Z systems.
The `backchain` attribute is the IBM Z way of adding frame pointers like unwinding capabilities (the "frame-pointer" switch on IBM Z and IBM POWER platforms will add _emulated_ frame pointers to the binary, which profilers can't use for unwinding the stack).

Both attributes can be applied at the LLVM module or function levels. However, the `backchain` attribute has to be enabled for all the functions in the call stack to get a successful unwind process.
Diffstat (limited to 'compiler/rustc_target/src')
-rw-r--r--compiler/rustc_target/src/target_features.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs
index 6667efb14e2..4fb0323b6cf 100644
--- a/compiler/rustc_target/src/target_features.rs
+++ b/compiler/rustc_target/src/target_features.rs
@@ -4,6 +4,9 @@ use rustc_span::symbol::Symbol;
 /// Features that control behaviour of rustc, rather than the codegen.
 pub const RUSTC_SPECIFIC_FEATURES: &[&str] = &["crt-static"];
 
+/// Features that require special handling when passing to LLVM.
+pub const RUSTC_SPECIAL_FEATURES: &[&str] = &["backchain"];
+
 /// Stability information for target features.
 #[derive(Debug, Clone, Copy)]
 pub enum Stability {
@@ -397,6 +400,13 @@ const LOONGARCH_ALLOWED_FEATURES: &[(&str, Stability)] = &[
     // tidy-alphabetical-end
 ];
 
+const IBMZ_ALLOWED_FEATURES: &[(&str, Stability)] = &[
+    // tidy-alphabetical-start
+    ("backchain", Unstable(sym::s390x_target_feature)),
+    ("vector", Unstable(sym::s390x_target_feature)),
+    // tidy-alphabetical-end
+];
+
 /// When rustdoc is running, provide a list of all known features so that all their respective
 /// primitives may be documented.
 ///
@@ -414,6 +424,7 @@ pub fn all_known_features() -> impl Iterator<Item = (&'static str, Stability)> {
         .chain(BPF_ALLOWED_FEATURES.iter())
         .chain(CSKY_ALLOWED_FEATURES)
         .chain(LOONGARCH_ALLOWED_FEATURES)
+        .chain(IBMZ_ALLOWED_FEATURES)
         .cloned()
 }
 
@@ -431,6 +442,7 @@ impl super::spec::Target {
             "bpf" => BPF_ALLOWED_FEATURES,
             "csky" => CSKY_ALLOWED_FEATURES,
             "loongarch64" => LOONGARCH_ALLOWED_FEATURES,
+            "s390x" => IBMZ_ALLOWED_FEATURES,
             _ => &[],
         }
     }