Rename (un)signed to (un)signed_int

This commit is contained in:
Andreas Liljeqvist 2021-09-07 20:44:33 +02:00
parent 9129f4306f
commit dd34e0c966
6 changed files with 17 additions and 16 deletions

View File

@ -260,7 +260,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
// unsigned
if is_add {
// max unsigned
Scalar::from_uint(size.unsigned_max(), Size::from_bits(num_bits))
Scalar::from_uint(size.unsigned_int_max(), Size::from_bits(num_bits))
} else {
// underflow to 0
Scalar::from_uint(0u128, Size::from_bits(num_bits))

View File

@ -627,7 +627,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
// At least one value is excluded.
let valid_range = scalar_layout.valid_range;
let WrappingRange { start, end } = valid_range;
let max_value = op.layout.size.unsigned_max();
let max_value = op.layout.size.unsigned_int_max();
assert!(end <= max_value);
// Determine the allowed range
let value = self.read_scalar(op)?;

View File

@ -514,7 +514,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
let scalar_unit = |value: Primitive| {
let size = value.size(dl);
assert!(size.bits() <= 128);
Scalar { value, valid_range: WrappingRange { start: 0, end: size.unsigned_max() } }
Scalar { value, valid_range: WrappingRange { start: 0, end: size.unsigned_int_max() } }
};
let scalar = |value: Primitive| tcx.intern_layout(Layout::scalar(self, scalar_unit(value)));
@ -1266,7 +1266,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
}
}
let tag_mask = ity.size().unsigned_max();
let tag_mask = ity.size().unsigned_int_max();
let tag = Scalar {
value: Int(ity, signed),
valid_range: WrappingRange {

View File

@ -62,8 +62,8 @@ impl<'tcx> Discr<'tcx> {
pub fn checked_add(self, tcx: TyCtxt<'tcx>, n: u128) -> (Self, bool) {
let (size, signed) = int_size_and_signed(tcx, self.ty);
let (val, oflo) = if signed {
let min = size.signed_min();
let max = size.signed_max();
let min = size.signed_int_min();
let max = size.signed_int_max();
let val = size.sign_extend(self.val) as i128;
assert!(n < (i128::MAX as u128));
let n = n as i128;
@ -74,7 +74,7 @@ impl<'tcx> Discr<'tcx> {
let val = size.truncate(val);
(val, oflo)
} else {
let max = size.unsigned_max();
let max = size.unsigned_int_max();
let val = self.val;
let oflo = val > max - n;
let val = if oflo { n - (max - val) - 1 } else { val + n };
@ -609,7 +609,8 @@ impl<'tcx> ty::TyS<'tcx> {
let val = match self.kind() {
ty::Int(_) | ty::Uint(_) => {
let (size, signed) = int_size_and_signed(tcx, self);
let val = if signed { size.signed_max() as u128 } else { size.unsigned_max() };
let val =
if signed { size.signed_int_max() as u128 } else { size.unsigned_int_max() };
Some(val)
}
ty::Char => Some(std::char::MAX as u128),
@ -628,7 +629,7 @@ impl<'tcx> ty::TyS<'tcx> {
let val = match self.kind() {
ty::Int(_) | ty::Uint(_) => {
let (size, signed) = int_size_and_signed(tcx, self);
let val = if signed { size.truncate(size.signed_min() as u128) } else { 0 };
let val = if signed { size.truncate(size.signed_int_min() as u128) } else { 0 };
Some(val)
}
ty::Char => Some(0),

View File

@ -495,7 +495,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
fn neg_1_literal(&mut self, span: Span, ty: Ty<'tcx>) -> Operand<'tcx> {
let param_ty = ty::ParamEnv::empty().and(ty);
let size = self.tcx.layout_of(param_ty).unwrap().size;
let literal = ty::Const::from_bits(self.tcx, size.unsigned_max(), param_ty);
let literal = ty::Const::from_bits(self.tcx, size.unsigned_int_max(), param_ty);
self.literal_operand(span, literal)
}

View File

@ -394,17 +394,17 @@ impl Size {
}
#[inline]
pub fn signed_min(&self) -> i128 {
pub fn signed_int_min(&self) -> i128 {
self.sign_extend(1_u128 << (self.bits() - 1)) as i128
}
#[inline]
pub fn signed_max(&self) -> i128 {
pub fn signed_int_max(&self) -> i128 {
i128::MAX >> (128 - self.bits())
}
#[inline]
pub fn unsigned_max(&self) -> u128 {
pub fn unsigned_int_max(&self) -> u128 {
u128::MAX >> (128 - self.bits())
}
}
@ -790,7 +790,7 @@ impl WrappingRange {
/// Returns `true` if `size` completely fills the range.
#[inline]
pub fn is_full_for(&self, size: Size) -> bool {
let max_value = size.unsigned_max();
let max_value = size.unsigned_int_max();
debug_assert!(self.start <= max_value && self.end <= max_value);
(self.start == 0 && self.end == max_value) || (self.end + 1 == self.start)
}
@ -1084,7 +1084,7 @@ impl Niche {
let Scalar { value, valid_range: v } = self.scalar;
let size = value.size(cx);
assert!(size.bits() <= 128);
let max_value = size.unsigned_max();
let max_value = size.unsigned_int_max();
// Find out how many values are outside the valid range.
let niche = v.end.wrapping_add(1)..v.start;
@ -1097,7 +1097,7 @@ impl Niche {
let Scalar { value, valid_range: v } = self.scalar;
let size = value.size(cx);
assert!(size.bits() <= 128);
let max_value = size.unsigned_max();
let max_value = size.unsigned_int_max();
if count > max_value {
return None;