about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/back/write.rs
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2024-12-30 19:08:03 +0100
committerRalf Jung <post@ralfj.de>2024-12-30 21:59:05 +0100
commita0dbb37ebd7919df4b698deb356e024a741283ec (patch)
tree44f86eee8f6ccca604db1afc1541c1a39f3eacfc /compiler/rustc_codegen_llvm/src/back/write.rs
parentfff026c8e572809cfce7202ec1ad63897b72c5b0 (diff)
downloadrust-a0dbb37ebd7919df4b698deb356e024a741283ec.tar.gz
rust-a0dbb37ebd7919df4b698deb356e024a741283ec.zip
add llvm_floatabi field to target spec that controls FloatABIType
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/back/write.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/back/write.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs
index ba4492b4936..806f810627d 100644
--- a/compiler/rustc_codegen_llvm/src/back/write.rs
+++ b/compiler/rustc_codegen_llvm/src/back/write.rs
@@ -26,7 +26,7 @@ use rustc_session::config::{
     self, Lto, OutputType, Passes, RemapPathScopeComponents, SplitDwarfKind, SwitchWithOptPath,
 };
 use rustc_span::{BytePos, InnerSpan, Pos, SpanData, SyntaxContext, sym};
-use rustc_target::spec::{CodeModel, RelocModel, SanitizerSet, SplitDebuginfo, TlsModel};
+use rustc_target::spec::{CodeModel, FloatAbi, RelocModel, SanitizerSet, SplitDebuginfo, TlsModel};
 use tracing::debug;
 
 use crate::back::lto::ThinBuffer;
@@ -40,7 +40,7 @@ use crate::errors::{
     WithLlvmError, WriteBytecode,
 };
 use crate::llvm::diagnostic::OptimizationDiagnosticKind::*;
-use crate::llvm::{self, DiagnosticInfo, FloatAbi, PassManager};
+use crate::llvm::{self, DiagnosticInfo, PassManager};
 use crate::type_::Type;
 use crate::{LlvmCodegenBackend, ModuleLlvm, base, common, llvm_util};
 
@@ -181,6 +181,14 @@ pub(crate) fn to_llvm_code_model(code_model: Option<CodeModel>) -> llvm::CodeMod
     }
 }
 
+fn to_llvm_float_abi(float_abi: Option<FloatAbi>) -> llvm::FloatAbi {
+    match float_abi {
+        None => llvm::FloatAbi::Default,
+        Some(FloatAbi::Soft) => llvm::FloatAbi::Soft,
+        Some(FloatAbi::Hard) => llvm::FloatAbi::Hard,
+    }
+}
+
 pub(crate) fn target_machine_factory(
     sess: &Session,
     optlvl: config::OptLevel,
@@ -190,11 +198,11 @@ pub(crate) fn target_machine_factory(
 
     let (opt_level, _) = to_llvm_opt_settings(optlvl);
     let float_abi = if sess.target.arch == "arm" && sess.opts.cg.soft_float {
-        FloatAbi::Soft
+        llvm::FloatAbi::Soft
     } else {
         // `validate_commandline_args_with_session_available` has already warned about this being
         // ignored. Let's make sure LLVM doesn't suddenly start using this flag on more targets.
-        FloatAbi::Default
+        to_llvm_float_abi(sess.target.llvm_floatabi)
     };
 
     let ffunction_sections =