BinOpKind

This commit is contained in:
csmoe 2018-07-11 18:44:53 +08:00 committed by Oliver Schneider
parent 3d5753fda1
commit fe8955bd58
14 changed files with 292 additions and 288 deletions

View file

@ -124,16 +124,16 @@ impl<'a, 'tcx> Drop for StatRecorder<'a, 'tcx> {
}
}
pub fn bin_op_to_icmp_predicate(op: hir::BinOp_,
pub fn bin_op_to_icmp_predicate(op: hir::BinOpKind,
signed: bool)
-> llvm::IntPredicate {
match op {
hir::BiEq => llvm::IntEQ,
hir::BiNe => llvm::IntNE,
hir::BiLt => if signed { llvm::IntSLT } else { llvm::IntULT },
hir::BiLe => if signed { llvm::IntSLE } else { llvm::IntULE },
hir::BiGt => if signed { llvm::IntSGT } else { llvm::IntUGT },
hir::BiGe => if signed { llvm::IntSGE } else { llvm::IntUGE },
hir::BinOpKind::Eq => llvm::IntEQ,
hir::BinOpKind::Ne => llvm::IntNE,
hir::BinOpKind::Lt => if signed { llvm::IntSLT } else { llvm::IntULT },
hir::BinOpKind::Le => if signed { llvm::IntSLE } else { llvm::IntULE },
hir::BinOpKind::Gt => if signed { llvm::IntSGT } else { llvm::IntUGT },
hir::BinOpKind::Ge => if signed { llvm::IntSGE } else { llvm::IntUGE },
op => {
bug!("comparison_op_to_icmp_predicate: expected comparison operator, \
found {:?}",
@ -142,14 +142,14 @@ pub fn bin_op_to_icmp_predicate(op: hir::BinOp_,
}
}
pub fn bin_op_to_fcmp_predicate(op: hir::BinOp_) -> llvm::RealPredicate {
pub fn bin_op_to_fcmp_predicate(op: hir::BinOpKind) -> llvm::RealPredicate {
match op {
hir::BiEq => llvm::RealOEQ,
hir::BiNe => llvm::RealUNE,
hir::BiLt => llvm::RealOLT,
hir::BiLe => llvm::RealOLE,
hir::BiGt => llvm::RealOGT,
hir::BiGe => llvm::RealOGE,
hir::BinOpKind::Eq => llvm::RealOEQ,
hir::BinOpKind::Ne => llvm::RealUNE,
hir::BinOpKind::Lt => llvm::RealOLT,
hir::BinOpKind::Le => llvm::RealOLE,
hir::BinOpKind::Gt => llvm::RealOGT,
hir::BinOpKind::Ge => llvm::RealOGE,
op => {
bug!("comparison_op_to_fcmp_predicate: expected comparison operator, \
found {:?}",
@ -164,7 +164,7 @@ pub fn compare_simd_types<'a, 'tcx>(
rhs: ValueRef,
t: Ty<'tcx>,
ret_ty: Type,
op: hir::BinOp_
op: hir::BinOpKind
) -> ValueRef {
let signed = match t.sty {
ty::TyFloat(_) => {
@ -332,12 +332,12 @@ pub fn coerce_unsized_into<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
}
pub fn cast_shift_expr_rhs(
cx: &Builder, op: hir::BinOp_, lhs: ValueRef, rhs: ValueRef
cx: &Builder, op: hir::BinOpKind, lhs: ValueRef, rhs: ValueRef
) -> ValueRef {
cast_shift_rhs(op, lhs, rhs, |a, b| cx.trunc(a, b), |a, b| cx.zext(a, b))
}
fn cast_shift_rhs<F, G>(op: hir::BinOp_,
fn cast_shift_rhs<F, G>(op: hir::BinOpKind,
lhs: ValueRef,
rhs: ValueRef,
trunc: F,

View file

@ -350,7 +350,7 @@ pub fn build_unchecked_lshift<'a, 'tcx>(
lhs: ValueRef,
rhs: ValueRef
) -> ValueRef {
let rhs = base::cast_shift_expr_rhs(bx, hir::BinOp_::BiShl, lhs, rhs);
let rhs = base::cast_shift_expr_rhs(bx, hir::BinOpKind::Shl, lhs, rhs);
// #1877, #10183: Ensure that input is always valid
let rhs = shift_mask_rhs(bx, rhs);
bx.shl(lhs, rhs)
@ -359,7 +359,7 @@ pub fn build_unchecked_lshift<'a, 'tcx>(
pub fn build_unchecked_rshift<'a, 'tcx>(
bx: &Builder<'a, 'tcx>, lhs_t: Ty<'tcx>, lhs: ValueRef, rhs: ValueRef
) -> ValueRef {
let rhs = base::cast_shift_expr_rhs(bx, hir::BinOp_::BiShr, lhs, rhs);
let rhs = base::cast_shift_expr_rhs(bx, hir::BinOpKind::Shr, lhs, rhs);
// #1877, #10183: Ensure that input is always valid
let rhs = shift_mask_rhs(bx, rhs);
let is_signed = lhs_t.is_signed();

View file

@ -1022,12 +1022,12 @@ fn generic_simd_intrinsic<'a, 'tcx>(
let in_len = arg_tys[0].simd_size(tcx);
let comparison = match name {
"simd_eq" => Some(hir::BiEq),
"simd_ne" => Some(hir::BiNe),
"simd_lt" => Some(hir::BiLt),
"simd_le" => Some(hir::BiLe),
"simd_gt" => Some(hir::BiGt),
"simd_ge" => Some(hir::BiGe),
"simd_eq" => Some(hir::BinOpKind::Eq),
"simd_ne" => Some(hir::BinOpKind::Ne),
"simd_lt" => Some(hir::BinOpKind::Lt),
"simd_le" => Some(hir::BinOpKind::Le),
"simd_gt" => Some(hir::BinOpKind::Gt),
"simd_ge" => Some(hir::BinOpKind::Ge),
_ => None
};