Add f16
and f128
to rustc_type_ir::FloatTy
and rustc_abi::Primitive
Make changes necessary to support these types in the compiler.
This commit is contained in:
parent
ef324565d0
commit
e3f63d9375
31 changed files with 107 additions and 14 deletions
|
@ -337,8 +337,10 @@ pub struct CommonTypes<'tcx> {
|
|||
pub u32: Ty<'tcx>,
|
||||
pub u64: Ty<'tcx>,
|
||||
pub u128: Ty<'tcx>,
|
||||
pub f16: Ty<'tcx>,
|
||||
pub f32: Ty<'tcx>,
|
||||
pub f64: Ty<'tcx>,
|
||||
pub f128: Ty<'tcx>,
|
||||
pub str_: Ty<'tcx>,
|
||||
pub never: Ty<'tcx>,
|
||||
pub self_param: Ty<'tcx>,
|
||||
|
@ -418,8 +420,10 @@ impl<'tcx> CommonTypes<'tcx> {
|
|||
u32: mk(Uint(ty::UintTy::U32)),
|
||||
u64: mk(Uint(ty::UintTy::U64)),
|
||||
u128: mk(Uint(ty::UintTy::U128)),
|
||||
f16: mk(Float(ty::FloatTy::F16)),
|
||||
f32: mk(Float(ty::FloatTy::F32)),
|
||||
f64: mk(Float(ty::FloatTy::F64)),
|
||||
f128: mk(Float(ty::FloatTy::F128)),
|
||||
str_: mk(Str),
|
||||
self_param: mk(ty::Param(ty::ParamTy { index: 0, name: kw::SelfUpper })),
|
||||
|
||||
|
|
|
@ -117,8 +117,10 @@ impl Primitive {
|
|||
fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
|
||||
match *self {
|
||||
Int(i, signed) => i.to_ty(tcx, signed),
|
||||
F16 => tcx.types.f16,
|
||||
F32 => tcx.types.f32,
|
||||
F64 => tcx.types.f64,
|
||||
F128 => tcx.types.f128,
|
||||
// FIXME(erikdesjardins): handle non-default addrspace ptr sizes
|
||||
Pointer(_) => Ty::new_mut_ptr(tcx, Ty::new_unit(tcx)),
|
||||
}
|
||||
|
@ -135,7 +137,7 @@ impl Primitive {
|
|||
let signed = false;
|
||||
tcx.data_layout().ptr_sized_integer().to_ty(tcx, signed)
|
||||
}
|
||||
F32 | F64 => bug!("floats do not have an int type"),
|
||||
F16 | F32 | F64 | F128 => bug!("floats do not have an int type"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1580,8 +1580,10 @@ impl<'tcx> Ty<'tcx> {
|
|||
pub fn new_float(tcx: TyCtxt<'tcx>, f: ty::FloatTy) -> Ty<'tcx> {
|
||||
use ty::FloatTy::*;
|
||||
match f {
|
||||
F16 => tcx.types.f16,
|
||||
F32 => tcx.types.f32,
|
||||
F64 => tcx.types.f64,
|
||||
F128 => tcx.types.f128,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2539,8 +2541,10 @@ impl<'tcx> Ty<'tcx> {
|
|||
ty::Bool => Some(sym::bool),
|
||||
ty::Char => Some(sym::char),
|
||||
ty::Float(f) => match f {
|
||||
ty::FloatTy::F16 => Some(sym::f16),
|
||||
ty::FloatTy::F32 => Some(sym::f32),
|
||||
ty::FloatTy::F64 => Some(sym::f64),
|
||||
ty::FloatTy::F128 => Some(sym::f128),
|
||||
},
|
||||
ty::Int(f) => match f {
|
||||
ty::IntTy::Isize => Some(sym::isize),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue