about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRobert Zakrzewski <robert.zakrzewski1@stellantis.com>2024-06-21 22:10:52 +0200
committerRobert Zakrzewski <robert.zakrzewski1@stellantis.com>2024-06-21 22:10:52 +0200
commitdabf5faff0bb0154d702561266826cc0cd53eec4 (patch)
tree3e697a36098b99fd4b9742d119935fbbf359fb0b
parent2eaac2388d6172922d0b8ac62979ff4fa6a2355c (diff)
downloadrust-dabf5faff0bb0154d702561266826cc0cd53eec4.tar.gz
rust-dabf5faff0bb0154d702561266826cc0cd53eec4.zip
Add support for Float64
-rw-r--r--src/base.rs2
-rw-r--r--src/context.rs3
-rw-r--r--src/type_.rs4
3 files changed, 9 insertions, 0 deletions
diff --git a/src/base.rs b/src/base.rs
index ea2b0b791b7..e88fde8ebef 100644
--- a/src/base.rs
+++ b/src/base.rs
@@ -186,6 +186,7 @@ pub fn compile_codegen_unit(
             // context.
             let f16_type_supported = target_info.supports_target_dependent_type(CType::Float16);
             let f32_type_supported = target_info.supports_target_dependent_type(CType::Float32);
+            let f64_type_supported = target_info.supports_target_dependent_type(CType::Float64);
             let f128_type_supported = target_info.supports_target_dependent_type(CType::Float128);
             // TODO: improve this to avoid passing that many arguments.
             let cx = CodegenCx::new(
@@ -195,6 +196,7 @@ pub fn compile_codegen_unit(
                 target_info.supports_128bit_int(),
                 f16_type_supported,
                 f32_type_supported,
+                f64_type_supported,
                 f128_type_supported,
             );
 
diff --git a/src/context.rs b/src/context.rs
index 53a2b09217a..6beed91270b 100644
--- a/src/context.rs
+++ b/src/context.rs
@@ -70,6 +70,7 @@ pub struct CodegenCx<'gcc, 'tcx> {
     pub supports_128bit_integers: bool,
     pub supports_f16_type: bool,
     pub supports_f32_type: bool,
+    pub supports_f64_type: bool,
     pub supports_f128_type: bool,
 
     pub float_type: Type<'gcc>,
@@ -135,6 +136,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
         supports_128bit_integers: bool,
         supports_f16_type: bool,
         supports_f32_type: bool,
+        supports_f64_type: bool,
         supports_f128_type: bool,
     ) -> Self {
         let check_overflow = tcx.sess.overflow_checks();
@@ -313,6 +315,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
             supports_128bit_integers,
             supports_f16_type,
             supports_f32_type,
+            supports_f64_type,
             supports_f128_type,
 
             float_type,
diff --git a/src/type_.rs b/src/type_.rs
index eaa16c44897..093ddbf8137 100644
--- a/src/type_.rs
+++ b/src/type_.rs
@@ -142,6 +142,10 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
     }
 
     fn type_f64(&self) -> Type<'gcc> {
+        #[cfg(feature = "master")]
+        if self.supports_f64_type {
+            return self.context.new_c_type(CType::Float64);
+        }
         self.double_type
     }