about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_smir/src/rustc_smir/convert/abi.rs11
-rw-r--r--compiler/stable_mir/src/abi.rs28
2 files changed, 31 insertions, 8 deletions
diff --git a/compiler/rustc_smir/src/rustc_smir/convert/abi.rs b/compiler/rustc_smir/src/rustc_smir/convert/abi.rs
index 071c02e0381..6fb1560ac6c 100644
--- a/compiler/rustc_smir/src/rustc_smir/convert/abi.rs
+++ b/compiler/rustc_smir/src/rustc_smir/convert/abi.rs
@@ -6,8 +6,9 @@ use crate::rustc_smir::{Stable, Tables};
 use rustc_middle::ty;
 use rustc_target::abi::call::Conv;
 use stable_mir::abi::{
-    AddressSpace, ArgAbi, CallConvention, FieldsShape, FnAbi, IntegerLength, Layout, LayoutShape,
-    PassMode, Primitive, Scalar, TagEncoding, TyAndLayout, ValueAbi, VariantsShape, WrappingRange,
+    AddressSpace, ArgAbi, CallConvention, FieldsShape, FloatLength, FnAbi, IntegerLength, Layout,
+    LayoutShape, PassMode, Primitive, Scalar, TagEncoding, TyAndLayout, ValueAbi, VariantsShape,
+    WrappingRange,
 };
 use stable_mir::opaque;
 use stable_mir::target::MachineSize as Size;
@@ -255,8 +256,10 @@ impl<'tcx> Stable<'tcx> for rustc_abi::Primitive {
             rustc_abi::Primitive::Int(length, signed) => {
                 Primitive::Int { length: length.stable(tables), signed: *signed }
             }
-            rustc_abi::Primitive::F32 => Primitive::F32,
-            rustc_abi::Primitive::F64 => Primitive::F64,
+            rustc_abi::Primitive::F16 => Primitive::Float { length: FloatLength::F16 },
+            rustc_abi::Primitive::F32 => Primitive::Float { length: FloatLength::F32 },
+            rustc_abi::Primitive::F64 => Primitive::Float { length: FloatLength::F64 },
+            rustc_abi::Primitive::F128 => Primitive::Float { length: FloatLength::F128 },
             rustc_abi::Primitive::Pointer(space) => Primitive::Pointer(space.stable(tables)),
         }
     }
diff --git a/compiler/stable_mir/src/abi.rs b/compiler/stable_mir/src/abi.rs
index 1c5e3275673..7fda9ceb79a 100644
--- a/compiler/stable_mir/src/abi.rs
+++ b/compiler/stable_mir/src/abi.rs
@@ -293,8 +293,9 @@ pub enum Primitive {
         length: IntegerLength,
         signed: bool,
     },
-    F32,
-    F64,
+    Float {
+        length: FloatLength,
+    },
     Pointer(AddressSpace),
 }
 
@@ -302,8 +303,7 @@ impl Primitive {
     pub fn size(self, target: &MachineInfo) -> Size {
         match self {
             Primitive::Int { length, .. } => Size::from_bits(length.bits()),
-            Primitive::F32 => Size::from_bits(32),
-            Primitive::F64 => Size::from_bits(64),
+            Primitive::Float { length } => Size::from_bits(length.bits()),
             Primitive::Pointer(_) => target.pointer_width,
         }
     }
@@ -319,6 +319,15 @@ pub enum IntegerLength {
     I128,
 }
 
+/// Enum representing the existing float lengths.
+#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
+pub enum FloatLength {
+    F16,
+    F32,
+    F64,
+    F128,
+}
+
 impl IntegerLength {
     pub fn bits(self) -> usize {
         match self {
@@ -331,6 +340,17 @@ impl IntegerLength {
     }
 }
 
+impl FloatLength {
+    pub fn bits(self) -> usize {
+        match self {
+            FloatLength::F16 => 16,
+            FloatLength::F32 => 32,
+            FloatLength::F64 => 64,
+            FloatLength::F128 => 128,
+        }
+    }
+}
+
 /// An identifier that specifies the address space that some operation
 /// should operate on. Special address spaces have an effect on code generation,
 /// depending on the target and the address spaces it implements.