diff options
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/thir.rs | 12 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/util.rs | 4 |
2 files changed, 15 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index 7c8b0ec671a..c97af68c29e 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -1047,6 +1047,12 @@ impl<'tcx> PatRangeBoundary<'tcx> { let b = other.eval_bits(ty, tcx, param_env); match ty.kind() { + ty::Float(ty::FloatTy::F16) => { + use rustc_apfloat::Float; + let a = rustc_apfloat::ieee::Half::from_bits(a); + let b = rustc_apfloat::ieee::Half::from_bits(b); + a.partial_cmp(&b) + } ty::Float(ty::FloatTy::F32) => { use rustc_apfloat::Float; let a = rustc_apfloat::ieee::Single::from_bits(a); @@ -1059,6 +1065,12 @@ impl<'tcx> PatRangeBoundary<'tcx> { let b = rustc_apfloat::ieee::Double::from_bits(b); a.partial_cmp(&b) } + ty::Float(ty::FloatTy::F128) => { + use rustc_apfloat::Float; + let a = rustc_apfloat::ieee::Quad::from_bits(a); + let b = rustc_apfloat::ieee::Quad::from_bits(b); + a.partial_cmp(&b) + } ty::Int(ity) => { let size = rustc_target::abi::Integer::from_int_ty(&tcx, *ity).size(); let a = size.sign_extend(a) as i128; diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index 1b5efcee903..9307e380681 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -1196,7 +1196,7 @@ impl<'tcx> Ty<'tcx> { /// Returns the minimum and maximum values for the given numeric type (including `char`s) or /// returns `None` if the type is not numeric. pub fn numeric_min_and_max_as_bits(self, tcx: TyCtxt<'tcx>) -> Option<(u128, u128)> { - use rustc_apfloat::ieee::{Double, Single}; + use rustc_apfloat::ieee::{Double, Half, Quad, Single}; Some(match self.kind() { ty::Int(_) | ty::Uint(_) => { let (size, signed) = self.int_size_and_signed(tcx); @@ -1206,12 +1206,14 @@ impl<'tcx> Ty<'tcx> { (min, max) } ty::Char => (0, std::char::MAX as u128), + ty::Float(ty::FloatTy::F16) => ((-Half::INFINITY).to_bits(), Half::INFINITY.to_bits()), ty::Float(ty::FloatTy::F32) => { ((-Single::INFINITY).to_bits(), Single::INFINITY.to_bits()) } ty::Float(ty::FloatTy::F64) => { ((-Double::INFINITY).to_bits(), Double::INFINITY.to_bits()) } + ty::Float(ty::FloatTy::F128) => ((-Quad::INFINITY).to_bits(), Quad::INFINITY.to_bits()), _ => return None, }) } |
