about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-03-17 22:49:07 +0100
committerGitHub <noreply@github.com>2025-03-17 22:49:07 +0100
commitaa53a72dff95f6d9a8593b6901262804748f53c8 (patch)
tree83b589e8f770b961715061c90c2497037f37ac96
parentcd4dfd77fa7ac0689a595f479c61a9dc6bc8ce8c (diff)
parent0ee99cf240053bc6a73a70922a3c156343555f4b (diff)
downloadrust-aa53a72dff95f6d9a8593b6901262804748f53c8.tar.gz
rust-aa53a72dff95f6d9a8593b6901262804748f53c8.zip
Rollup merge of #138608 - heiher:issue-116344, r=RalfJung
rustc_target: Add target feature constraints for LoongArch

Part of https://github.com/rust-lang/rust/issues/116344

r? `@RalfJung`
-rw-r--r--compiler/rustc_target/src/target_features.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs
index a32b42a6fe3..a96caf227f7 100644
--- a/compiler/rustc_target/src/target_features.rs
+++ b/compiler/rustc_target/src/target_features.rs
@@ -923,6 +923,28 @@ impl Target {
                     _ => unreachable!(),
                 }
             }
+            "loongarch64" => {
+                // LoongArch handles ABI in a very sane way, being fully explicit via `llvm_abiname`
+                // about what the intended ABI is.
+                match &*self.llvm_abiname {
+                    "ilp32d" | "lp64d" => {
+                        // Requires d (which implies f), incompatible with nothing.
+                        FeatureConstraints { required: &["d"], incompatible: &[] }
+                    }
+                    "ilp32f" | "lp64f" => {
+                        // Requires f, incompatible with nothing.
+                        FeatureConstraints { required: &["f"], incompatible: &[] }
+                    }
+                    "ilp32s" | "lp64s" => {
+                        // The soft-float ABI does not require any features and is also not
+                        // incompatible with any features. Rust targets explicitly specify the
+                        // LLVM ABI names, which allows for enabling hard-float support even on
+                        // soft-float targets, and ensures that the ABI behavior is as expected.
+                        NOTHING
+                    }
+                    _ => unreachable!(),
+                }
+            }
             _ => NOTHING,
         }
     }