Skip to content

Commit 8cb4195

Browse files
committed
Add f16 and f128 to rustc_abi and rustc_target
1 parent 1606f27 commit 8cb4195

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

compiler/rustc_abi/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,10 @@ pub struct TargetDataLayout {
162162
pub i32_align: AbiAndPrefAlign,
163163
pub i64_align: AbiAndPrefAlign,
164164
pub i128_align: AbiAndPrefAlign,
165+
pub f16_align: AbiAndPrefAlign,
165166
pub f32_align: AbiAndPrefAlign,
166167
pub f64_align: AbiAndPrefAlign,
168+
pub f128_align: AbiAndPrefAlign,
167169
pub pointer_size: Size,
168170
pub pointer_align: AbiAndPrefAlign,
169171
pub aggregate_align: AbiAndPrefAlign,
@@ -191,8 +193,10 @@ impl Default for TargetDataLayout {
191193
i32_align: AbiAndPrefAlign::new(align(32)),
192194
i64_align: AbiAndPrefAlign { abi: align(32), pref: align(64) },
193195
i128_align: AbiAndPrefAlign { abi: align(32), pref: align(64) },
196+
f16_align: AbiAndPrefAlign::new(align(16)),
194197
f32_align: AbiAndPrefAlign::new(align(32)),
195198
f64_align: AbiAndPrefAlign::new(align(64)),
199+
f128_align: AbiAndPrefAlign::new(align(128)),
196200
pointer_size: Size::from_bits(64),
197201
pointer_align: AbiAndPrefAlign::new(align(64)),
198202
aggregate_align: AbiAndPrefAlign { abi: align(0), pref: align(64) },
@@ -270,8 +274,10 @@ impl TargetDataLayout {
270274
dl.instruction_address_space = parse_address_space(&p[1..], "P")?
271275
}
272276
["a", ref a @ ..] => dl.aggregate_align = align(a, "a")?,
277+
["f16", ref a @ ..] => dl.f32_align = align(a, "f16")?,
273278
["f32", ref a @ ..] => dl.f32_align = align(a, "f32")?,
274279
["f64", ref a @ ..] => dl.f64_align = align(a, "f64")?,
280+
["f128", ref a @ ..] => dl.f32_align = align(a, "f128")?,
275281
// FIXME(erikdesjardins): we should be parsing nonzero address spaces
276282
// this will require replacing TargetDataLayout::{pointer_size,pointer_align}
277283
// with e.g. `fn pointer_size_in(AddressSpace)`
@@ -901,8 +907,10 @@ pub enum Primitive {
901907
/// a negative integer passed by zero-extension will appear positive in
902908
/// the callee, and most operations on it will produce the wrong values.
903909
Int(Integer, bool),
910+
F16,
904911
F32,
905912
F64,
913+
F128,
906914
Pointer(AddressSpace),
907915
}
908916

@@ -912,8 +920,10 @@ impl Primitive {
912920

913921
match self {
914922
Int(i, _) => i.size(),
923+
F16 => Size::from_bits(16),
915924
F32 => Size::from_bits(32),
916925
F64 => Size::from_bits(64),
926+
F128 => Size::from_bits(128),
917927
// FIXME(erikdesjardins): ignoring address space is technically wrong, pointers in
918928
// different address spaces can have different sizes
919929
// (but TargetDataLayout doesn't currently parse that part of the DL string)
@@ -926,8 +936,10 @@ impl Primitive {
926936

927937
match self {
928938
Int(i, _) => i.align(dl),
939+
F16 => dl.f16_align,
929940
F32 => dl.f32_align,
930941
F64 => dl.f64_align,
942+
F128 => dl.f128_align,
931943
// FIXME(erikdesjardins): ignoring address space is technically wrong, pointers in
932944
// different address spaces can have different alignments
933945
// (but TargetDataLayout doesn't currently parse that part of the DL string)

compiler/rustc_target/src/abi/call/loongarch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ where
5959
_ => return Err(CannotUseFpConv),
6060
}
6161
}
62-
abi::F32 | abi::F64 => {
62+
abi::F16 | abi::F32 | abi::F64 | abi::F128 => {
6363
if arg_layout.size.bits() > flen {
6464
return Err(CannotUseFpConv);
6565
}

compiler/rustc_target/src/abi/call/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
346346
Abi::Scalar(scalar) => {
347347
let kind = match scalar.primitive() {
348348
abi::Int(..) | abi::Pointer(_) => RegKind::Integer,
349-
abi::F32 | abi::F64 => RegKind::Float,
349+
abi::F16 | abi::F32 | abi::F64 | abi::F128 => RegKind::Float,
350350
};
351351
Ok(HomogeneousAggregate::Homogeneous(Reg { kind, size: self.size }))
352352
}

compiler/rustc_target/src/abi/call/riscv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ where
6565
_ => return Err(CannotUseFpConv),
6666
}
6767
}
68-
abi::F32 | abi::F64 => {
68+
abi::F16 | abi::F32 | abi::F64 | abi::F128 => {
6969
if arg_layout.size.bits() > flen {
7070
return Err(CannotUseFpConv);
7171
}

compiler/rustc_target/src/abi/call/x86_64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ where
5151

5252
Abi::Scalar(scalar) => match scalar.primitive() {
5353
abi::Int(..) | abi::Pointer(_) => Class::Int,
54-
abi::F32 | abi::F64 => Class::Sse,
54+
abi::F16 | abi::F32 | abi::F64 | abi::F128 => Class::Sse,
5555
},
5656

5757
Abi::Vector { .. } => Class::Sse,

0 commit comments

Comments
 (0)