Simplify cast_shift_expr_rhs
.
It's only ever used with shift operators.
This commit is contained in:
parent
8c02f4d05d
commit
6cd35ac203
2 changed files with 18 additions and 24 deletions
|
@ -337,12 +337,10 @@ pub fn coerce_unsized_into<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
|
|
||||||
pub fn cast_shift_expr_rhs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
pub fn cast_shift_expr_rhs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
bx: &mut Bx,
|
bx: &mut Bx,
|
||||||
op: hir::BinOpKind,
|
|
||||||
lhs: Bx::Value,
|
lhs: Bx::Value,
|
||||||
rhs: Bx::Value,
|
rhs: Bx::Value,
|
||||||
) -> Bx::Value {
|
) -> Bx::Value {
|
||||||
// Shifts may have any size int on the rhs
|
// Shifts may have any size int on the rhs
|
||||||
if op.is_shift() {
|
|
||||||
let mut rhs_llty = bx.cx().val_ty(rhs);
|
let mut rhs_llty = bx.cx().val_ty(rhs);
|
||||||
let mut lhs_llty = bx.cx().val_ty(lhs);
|
let mut lhs_llty = bx.cx().val_ty(lhs);
|
||||||
if bx.cx().type_kind(rhs_llty) == TypeKind::Vector {
|
if bx.cx().type_kind(rhs_llty) == TypeKind::Vector {
|
||||||
|
@ -362,9 +360,6 @@ pub fn cast_shift_expr_rhs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
} else {
|
} else {
|
||||||
rhs
|
rhs
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
rhs
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if this session's target will use SEH-based unwinding.
|
/// Returns `true` if this session's target will use SEH-based unwinding.
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#![allow(non_camel_case_types)]
|
#![allow(non_camel_case_types)]
|
||||||
|
|
||||||
use rustc_errors::struct_span_err;
|
use rustc_errors::struct_span_err;
|
||||||
use rustc_hir as hir;
|
|
||||||
use rustc_hir::LangItem;
|
use rustc_hir::LangItem;
|
||||||
use rustc_middle::mir::interpret::ConstValue;
|
use rustc_middle::mir::interpret::ConstValue;
|
||||||
use rustc_middle::ty::{self, layout::TyAndLayout, Ty, TyCtxt};
|
use rustc_middle::ty::{self, layout::TyAndLayout, Ty, TyCtxt};
|
||||||
|
@ -140,7 +139,7 @@ pub fn build_unchecked_lshift<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
lhs: Bx::Value,
|
lhs: Bx::Value,
|
||||||
rhs: Bx::Value,
|
rhs: Bx::Value,
|
||||||
) -> Bx::Value {
|
) -> Bx::Value {
|
||||||
let rhs = base::cast_shift_expr_rhs(bx, hir::BinOpKind::Shl, lhs, rhs);
|
let rhs = base::cast_shift_expr_rhs(bx, lhs, rhs);
|
||||||
// #1877, #10183: Ensure that input is always valid
|
// #1877, #10183: Ensure that input is always valid
|
||||||
let rhs = shift_mask_rhs(bx, rhs);
|
let rhs = shift_mask_rhs(bx, rhs);
|
||||||
bx.shl(lhs, rhs)
|
bx.shl(lhs, rhs)
|
||||||
|
@ -152,7 +151,7 @@ pub fn build_unchecked_rshift<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
lhs: Bx::Value,
|
lhs: Bx::Value,
|
||||||
rhs: Bx::Value,
|
rhs: Bx::Value,
|
||||||
) -> Bx::Value {
|
) -> Bx::Value {
|
||||||
let rhs = base::cast_shift_expr_rhs(bx, hir::BinOpKind::Shr, lhs, rhs);
|
let rhs = base::cast_shift_expr_rhs(bx, lhs, rhs);
|
||||||
// #1877, #10183: Ensure that input is always valid
|
// #1877, #10183: Ensure that input is always valid
|
||||||
let rhs = shift_mask_rhs(bx, rhs);
|
let rhs = shift_mask_rhs(bx, rhs);
|
||||||
let is_signed = lhs_t.is_signed();
|
let is_signed = lhs_t.is_signed();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue