Use clearer name for integer bit width helper function
This commit is contained in:
parent
eb18d39a04
commit
6cfda078bf
@ -381,7 +381,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
|
||||
// Helper to get a `-1` value of the appropriate type
|
||||
fn neg_1_literal(&mut self, span: Span, ty: Ty<'tcx>) -> Operand<'tcx> {
|
||||
let bits = self.hir.type_bit_size(ty);
|
||||
let bits = self.hir.integer_bit_width(ty);
|
||||
let n = (!0u128) >> (128 - bits);
|
||||
let literal = Literal::Value {
|
||||
value: self.hir.tcx().mk_const(ty::Const {
|
||||
@ -396,7 +396,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
// Helper to get the minimum value of the appropriate type
|
||||
fn minval_literal(&mut self, span: Span, ty: Ty<'tcx>) -> Operand<'tcx> {
|
||||
assert!(ty.is_signed());
|
||||
let bits = self.hir.type_bit_size(ty);
|
||||
let bits = self.hir.integer_bit_width(ty);
|
||||
let n = 1 << (bits - 1);
|
||||
let literal = Literal::Value {
|
||||
value: self.hir.tcx().mk_const(ty::Const {
|
||||
|
@ -149,7 +149,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn type_bit_size(
|
||||
pub fn integer_bit_width(
|
||||
&self,
|
||||
ty: Ty,
|
||||
) -> u64 {
|
||||
@ -179,7 +179,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
|
||||
};
|
||||
|
||||
let clamp = |n| {
|
||||
let size = self.type_bit_size(ty);
|
||||
let size = self.integer_bit_width(ty);
|
||||
trace!("clamp {} with size {} and amt {}", n, size, 128 - size);
|
||||
let amt = 128 - size;
|
||||
let result = (n << amt) >> amt;
|
||||
|
Loading…
Reference in New Issue
Block a user