Skip to content

Commit 70cdc47

Browse files
committed
Add f16 and f128 to rustc_middle, rustc_span, and rustc_type_ir
Compilation of `rustc_middle` is successful at this stage
1 parent 03181e0 commit 70cdc47

File tree

5 files changed

+67
-3
lines changed

5 files changed

+67
-3
lines changed

compiler/rustc_middle/src/ty/context.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,10 @@ pub struct CommonTypes<'tcx> {
282282
pub u32: Ty<'tcx>,
283283
pub u64: Ty<'tcx>,
284284
pub u128: Ty<'tcx>,
285+
pub f16: Ty<'tcx>,
285286
pub f32: Ty<'tcx>,
286287
pub f64: Ty<'tcx>,
288+
pub f128: Ty<'tcx>,
287289
pub str_: Ty<'tcx>,
288290
pub never: Ty<'tcx>,
289291
pub self_param: Ty<'tcx>,
@@ -363,8 +365,10 @@ impl<'tcx> CommonTypes<'tcx> {
363365
u32: mk(Uint(ty::UintTy::U32)),
364366
u64: mk(Uint(ty::UintTy::U64)),
365367
u128: mk(Uint(ty::UintTy::U128)),
368+
f16: mk(Float(ty::FloatTy::F16)),
366369
f32: mk(Float(ty::FloatTy::F32)),
367370
f64: mk(Float(ty::FloatTy::F64)),
371+
f128: mk(Float(ty::FloatTy::F128)),
368372
str_: mk(Str),
369373
self_param: mk(ty::Param(ty::ParamTy { index: 0, name: kw::SelfUpper })),
370374

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,8 +2008,10 @@ impl<'tcx> Ty<'tcx> {
20082008
pub fn new_float(tcx: TyCtxt<'tcx>, f: ty::FloatTy) -> Ty<'tcx> {
20092009
use ty::FloatTy::*;
20102010
match f {
2011+
F16 => tcx.types.f16,
20112012
F32 => tcx.types.f32,
20122013
F64 => tcx.types.f64,
2014+
F128 => tcx.types.f128,
20132015
}
20142016
}
20152017

@@ -2900,8 +2902,10 @@ impl<'tcx> Ty<'tcx> {
29002902
ty::Bool => Some(sym::bool),
29012903
ty::Char => Some(sym::char),
29022904
ty::Float(f) => match f {
2905+
ty::FloatTy::F16 => Some(sym::f16),
29032906
ty::FloatTy::F32 => Some(sym::f32),
29042907
ty::FloatTy::F64 => Some(sym::f64),
2908+
ty::FloatTy::F128 => Some(sym::f128),
29052909
},
29062910
ty::Int(f) => match f {
29072911
ty::IntTy::Isize => Some(sym::isize),

compiler/rustc_middle/src/ty/util.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,8 +938,10 @@ impl<'tcx> Ty<'tcx> {
938938
}
939939
ty::Char => Some(std::char::MAX as u128),
940940
ty::Float(fty) => Some(match fty {
941+
ty::FloatTy::F16 => rustc_apfloat::ieee::Half::INFINITY.to_bits(),
941942
ty::FloatTy::F32 => rustc_apfloat::ieee::Single::INFINITY.to_bits(),
942943
ty::FloatTy::F64 => rustc_apfloat::ieee::Double::INFINITY.to_bits(),
944+
ty::FloatTy::F128 => rustc_apfloat::ieee::Quad::INFINITY.to_bits(),
943945
}),
944946
_ => None,
945947
};
@@ -958,8 +960,10 @@ impl<'tcx> Ty<'tcx> {
958960
}
959961
ty::Char => Some(0),
960962
ty::Float(fty) => Some(match fty {
961-
ty::FloatTy::F32 => (-::rustc_apfloat::ieee::Single::INFINITY).to_bits(),
962-
ty::FloatTy::F64 => (-::rustc_apfloat::ieee::Double::INFINITY).to_bits(),
963+
ty::FloatTy::F16 => (-rustc_apfloat::ieee::Half::INFINITY).to_bits(),
964+
ty::FloatTy::F32 => (-rustc_apfloat::ieee::Single::INFINITY).to_bits(),
965+
ty::FloatTy::F64 => (-rustc_apfloat::ieee::Double::INFINITY).to_bits(),
966+
ty::FloatTy::F128 => (-rustc_apfloat::ieee::Quad::INFINITY).to_bits(),
963967
}),
964968
_ => None,
965969
};

compiler/rustc_span/src/symbol.rs

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,8 @@ symbols! {
455455
capture_disjoint_fields,
456456
cause,
457457
cdylib,
458+
ceilf128,
459+
ceilf16,
458460
ceilf32,
459461
ceilf64,
460462
cfg,
@@ -553,13 +555,17 @@ symbols! {
553555
copy,
554556
copy_closures,
555557
copy_nonoverlapping,
558+
copysignf128,
559+
copysignf16,
556560
copysignf32,
557561
copysignf64,
558562
core,
559563
core_panic,
560564
core_panic_2015_macro,
561565
core_panic_2021_macro,
562566
core_panic_macro,
567+
cosf128,
568+
cosf16,
563569
cosf32,
564570
cosf64,
565571
count,
@@ -682,10 +688,14 @@ symbols! {
682688
exhaustive_integer_patterns,
683689
exhaustive_patterns,
684690
existential_type,
691+
exp2f128,
692+
exp2f16,
685693
exp2f32,
686694
exp2f64,
687695
expect,
688696
expected,
697+
expf128,
698+
expf16,
689699
expf32,
690700
expf64,
691701
explicit_generic_args_with_impl_trait,
@@ -702,11 +712,17 @@ symbols! {
702712
extern_types,
703713
external_doc,
704714
f,
705-
f16c_target_feature,
715+
f128,
716+
f128_nan,
717+
f16,
718+
f16_nan,
719+
f16c_target_feature, // TODO: how should this interact?
706720
f32,
707721
f32_nan,
708722
f64,
709723
f64_nan,
724+
fabsf128,
725+
fabsf16,
710726
fabsf32,
711727
fabsf64,
712728
fadd_fast,
@@ -727,6 +743,8 @@ symbols! {
727743
flags,
728744
float,
729745
float_to_int_unchecked,
746+
floorf128,
747+
floorf16,
730748
floorf32,
731749
floorf64,
732750
fmaf32,
@@ -903,11 +921,17 @@ symbols! {
903921
loaded_from_disk,
904922
local,
905923
local_inner_macros,
924+
log10f128,
925+
log10f16,
906926
log10f32,
907927
log10f64,
928+
log2f128,
929+
log2f16,
908930
log2f32,
909931
log2f64,
910932
log_syntax,
933+
logf128,
934+
logf16,
911935
logf32,
912936
logf64,
913937
loop_break_value,
@@ -933,6 +957,8 @@ symbols! {
933957
match_beginning_vert,
934958
match_default_bindings,
935959
matches_macro,
960+
maxnumf128,
961+
maxnumf16,
936962
maxnumf32,
937963
maxnumf64,
938964
may_dangle,
@@ -962,6 +988,8 @@ symbols! {
962988
min_const_unsafe_fn,
963989
min_specialization,
964990
min_type_alias_impl_trait,
991+
minnumf128,
992+
minnumf16,
965993
minnumf32,
966994
minnumf64,
967995
mips_target_feature,
@@ -993,6 +1021,8 @@ symbols! {
9931021
native_link_modifiers_whole_archive,
9941022
natvis_file,
9951023
ne,
1024+
nearbyintf128,
1025+
nearbyintf16,
9961026
nearbyintf32,
9971027
nearbyintf64,
9981028
needs_allocator,
@@ -1122,8 +1152,12 @@ symbols! {
11221152
position,
11231153
post_dash_lto: "post-lto",
11241154
powerpc_target_feature,
1155+
powf128,
1156+
powf16,
11251157
powf32,
11261158
powf64,
1159+
powif128,
1160+
powif16,
11271161
powif32,
11281162
powif64,
11291163
pre_dash_lto: "pre-lto",
@@ -1233,14 +1267,20 @@ symbols! {
12331267
return_position_impl_trait_in_trait,
12341268
return_type_notation,
12351269
rhs,
1270+
rintf128,
1271+
rintf16,
12361272
rintf32,
12371273
rintf64,
12381274
riscv_target_feature,
12391275
rlib,
12401276
rotate_left,
12411277
rotate_right,
1278+
roundevenf128,
1279+
roundevenf16,
12421280
roundevenf32,
12431281
roundevenf64,
1282+
roundf128,
1283+
roundf16,
12441284
roundf32,
12451285
roundf64,
12461286
rt,
@@ -1438,6 +1478,8 @@ symbols! {
14381478
simd_trunc,
14391479
simd_xor,
14401480
since,
1481+
sinf128,
1482+
sinf16,
14411483
sinf32,
14421484
sinf64,
14431485
size,
@@ -1453,6 +1495,8 @@ symbols! {
14531495
specialization,
14541496
speed,
14551497
spotlight,
1498+
sqrtf128,
1499+
sqrtf16,
14561500
sqrtf32,
14571501
sqrtf64,
14581502
sreg,
@@ -1551,6 +1595,8 @@ symbols! {
15511595
transparent_enums,
15521596
transparent_unions,
15531597
trivial_bounds,
1598+
truncf128,
1599+
truncf16,
15541600
truncf32,
15551601
truncf64,
15561602
try_blocks,

compiler/rustc_type_ir/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,22 +539,28 @@ impl UintTy {
539539
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
540540
#[derive(Encodable, Decodable, HashStable_Generic)]
541541
pub enum FloatTy {
542+
F16,
542543
F32,
543544
F64,
545+
F128,
544546
}
545547

546548
impl FloatTy {
547549
pub fn name_str(self) -> &'static str {
548550
match self {
551+
FloatTy::F16 => "f16",
549552
FloatTy::F32 => "f32",
550553
FloatTy::F64 => "f64",
554+
FloatTy::F128 => "f128",
551555
}
552556
}
553557

554558
pub fn bit_width(self) -> u64 {
555559
match self {
560+
FloatTy::F16 => 16,
556561
FloatTy::F32 => 32,
557562
FloatTy::F64 => 64,
563+
FloatTy::F128 => 128,
558564
}
559565
}
560566
}

0 commit comments

Comments
 (0)