fn trans_eager_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                 binop_expr: &ast::Expr,
                                 binop_ty: Ty<'tcx>,
                                 op: ast::BinOp,
                                 lhs_t: Ty<'tcx>,
                                 lhs: ValueRef,
                                 rhs_t: Ty<'tcx>,
                                 rhs: ValueRef)
                                 -> DatumBlock<'blk, 'tcx, Expr> {
    let _icx = push_ctxt("trans_eager_binop");

    let tcx = bcx.tcx();
    let is_simd = lhs_t.is_simd(tcx);
    let intype = if is_simd {
        lhs_t.simd_type(tcx)
    } else {
        lhs_t
    };
    let is_float = intype.is_fp();
    let is_signed = intype.is_signed();
    let info = expr_info(binop_expr);

    let binop_debug_loc = binop_expr.debug_loc();

    let mut bcx = bcx;
    let val = match op.node {
      ast::BiAdd => {
        if is_float {
            FAdd(bcx, lhs, rhs, binop_debug_loc)
        } else if is_simd {
            Add(bcx, lhs, rhs, binop_debug_loc)
        } else {
            let (newbcx, res) = with_overflow_check(
                bcx, OverflowOp::Add, info, lhs_t, lhs, rhs, binop_debug_loc);
            bcx = newbcx;
            res
        }
      }
      ast::BiSub => {
        if is_float {
            FSub(bcx, lhs, rhs, binop_debug_loc)
        } else if is_simd {
            Sub(bcx, lhs, rhs, binop_debug_loc)
        } else {
            let (newbcx, res) = with_overflow_check(
                bcx, OverflowOp::Sub, info, lhs_t, lhs, rhs, binop_debug_loc);
            bcx = newbcx;
            res
        }
      }
      ast::BiMul => {
        if is_float {
            FMul(bcx, lhs, rhs, binop_debug_loc)
        } else if is_simd {
            Mul(bcx, lhs, rhs, binop_debug_loc)
        } else {
            let (newbcx, res) = with_overflow_check(
                bcx, OverflowOp::Mul, info, lhs_t, lhs, rhs, binop_debug_loc);
            bcx = newbcx;
            res
        }
      }
      ast::BiDiv => {
        if is_float {
            FDiv(bcx, lhs, rhs, binop_debug_loc)
        } else {
            // Only zero-check integers; fp /0 is NaN
            bcx = base::fail_if_zero_or_overflows(bcx,
                                                  expr_info(binop_expr),
                                                  op,
                                                  lhs,
                                                  rhs,
                                                  rhs_t);
            if is_signed {
                SDiv(bcx, lhs, rhs, binop_debug_loc)
            } else {
                UDiv(bcx, lhs, rhs, binop_debug_loc)
            }
        }
      }
      ast::BiRem => {
        if is_float {
            FRem(bcx, lhs, rhs, binop_debug_loc)
        } else {
            // Only zero-check integers; fp %0 is NaN
            bcx = base::fail_if_zero_or_overflows(bcx,
                                                  expr_info(binop_expr),
                                                  op, lhs, rhs, rhs_t);
            if is_signed {
                SRem(bcx, lhs, rhs, binop_debug_loc)
            } else {
                URem(bcx, lhs, rhs, binop_debug_loc)
            }
        }
      }
      ast::BiBitOr => Or(bcx, lhs, rhs, binop_debug_loc),
      ast::BiBitAnd => And(bcx, lhs, rhs, binop_debug_loc),
      ast::BiBitXor => Xor(bcx, lhs, rhs, binop_debug_loc),
      ast::BiShl => {
          let (newbcx, res) = with_overflow_check(
              bcx, OverflowOp::Shl, info, lhs_t, lhs, rhs, binop_debug_loc);
          bcx = newbcx;
          res
      }
      ast::BiShr => {
          let (newbcx, res) = with_overflow_check(
              bcx, OverflowOp::Shr, info, lhs_t, lhs, rhs, binop_debug_loc);
          bcx = newbcx;
          res
      }
      ast::BiEq | ast::BiNe | ast::BiLt | ast::BiGe | ast::BiLe | ast::BiGt => {
        if is_simd {
            base::compare_simd_types(bcx, lhs, rhs, intype, op.node, binop_debug_loc)
        } else {
            base::compare_scalar_types(bcx, lhs, rhs, intype, op.node, binop_debug_loc)
        }
      }
      _ => {
        bcx.tcx().sess.span_bug(binop_expr.span, "unexpected binop");
      }
    };

    immediate_rvalue_bcx(bcx, val, binop_ty).to_expr_datumblock()
}
// Important to get types for both lhs and rhs, because one might be _|_
// and the other not.
Important to get types for both lhs and rhs, because one might be _|_
and the other not.
Important to get types for both lhs and rhs because one might be _|_ and the other not .
fn trans_eager_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                 binop_expr: &ast::Expr,
                                 binop_ty: Ty<'tcx>,
                                 op: ast::BinOp,
                                 lhs_t: Ty<'tcx>,
                                 lhs: ValueRef,
                                 rhs_t: Ty<'tcx>,
                                 rhs: ValueRef)
                                 -> DatumBlock<'blk, 'tcx, Expr> {
    let _icx = push_ctxt("trans_eager_binop");
    let tcx = bcx.tcx();
    let is_simd = lhs_t.is_simd(tcx);
    let intype = if is_simd {
        lhs_t.simd_type(tcx)
    } else {
        lhs_t
    };
    let is_float = intype.is_fp();
    let is_signed = intype.is_signed();
    let info = expr_info(binop_expr);
    let binop_debug_loc = binop_expr.debug_loc();
    let mut bcx = bcx;
    let val = match op.node {
      ast::BiAdd => {
        if is_float {
            FAdd(bcx, lhs, rhs, binop_debug_loc)
        } else if is_simd {
            Add(bcx, lhs, rhs, binop_debug_loc)
        } else {
            let (newbcx, res) = with_overflow_check(
                bcx, OverflowOp::Add, info, lhs_t, lhs, rhs, binop_debug_loc);
            bcx = newbcx;
            res
        }
      }
      ast::BiSub => {
        if is_float {
            FSub(bcx, lhs, rhs, binop_debug_loc)
        } else if is_simd {
            Sub(bcx, lhs, rhs, binop_debug_loc)
        } else {
            let (newbcx, res) = with_overflow_check(
                bcx, OverflowOp::Sub, info, lhs_t, lhs, rhs, binop_debug_loc);
            bcx = newbcx;
            res
        }
      }
      ast::BiMul => {
        if is_float {
            FMul(bcx, lhs, rhs, binop_debug_loc)
        } else if is_simd {
            Mul(bcx, lhs, rhs, binop_debug_loc)
        } else {
            let (newbcx, res) = with_overflow_check(
                bcx, OverflowOp::Mul, info, lhs_t, lhs, rhs, binop_debug_loc);
            bcx = newbcx;
            res
        }
      }
      ast::BiDiv => {
        if is_float {
            FDiv(bcx, lhs, rhs, binop_debug_loc)
        } else {
            // Only zero-check integers; fp /0 is NaN
            bcx = base::fail_if_zero_or_overflows(bcx,
                                                  expr_info(binop_expr),
                                                  op,
                                                  lhs,
                                                  rhs,
                                                  rhs_t);
            if is_signed {
                SDiv(bcx, lhs, rhs, binop_debug_loc)
            } else {
                UDiv(bcx, lhs, rhs, binop_debug_loc)
            }
        }
      }
      ast::BiRem => {
        if is_float {
            FRem(bcx, lhs, rhs, binop_debug_loc)
        } else {
            // Only zero-check integers; fp %0 is NaN
            bcx = base::fail_if_zero_or_overflows(bcx,
                                                  expr_info(binop_expr),
                                                  op, lhs, rhs, rhs_t);
            if is_signed {
                SRem(bcx, lhs, rhs, binop_debug_loc)
            } else {
                URem(bcx, lhs, rhs, binop_debug_loc)
            }
        }
      }
      ast::BiBitOr => Or(bcx, lhs, rhs, binop_debug_loc),
      ast::BiBitAnd => And(bcx, lhs, rhs, binop_debug_loc),
      ast::BiBitXor => Xor(bcx, lhs, rhs, binop_debug_loc),
      ast::BiShl => {
          let (newbcx, res) = with_overflow_check(
              bcx, OverflowOp::Shl, info, lhs_t, lhs, rhs, binop_debug_loc);
          bcx = newbcx;
          res
      }
      ast::BiShr => {
          let (newbcx, res) = with_overflow_check(
              bcx, OverflowOp::Shr, info, lhs_t, lhs, rhs, binop_debug_loc);
          bcx = newbcx;
          res
      }
      ast::BiEq | ast::BiNe | ast::BiLt | ast::BiGe | ast::BiLe | ast::BiGt => {
        if is_simd {
            base::compare_simd_types(bcx, lhs, rhs, intype, op.node, binop_debug_loc)
        } else {
            base::compare_scalar_types(bcx, lhs, rhs, intype, op.node, binop_debug_loc)
        }
      }
      _ => {
        bcx.tcx().sess.span_bug(binop_expr.span, "unexpected binop");
      }
    };
    immediate_rvalue_bcx(bcx, val, binop_ty).to_expr_datumblock()
}
fn trans_eager_binop < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > , binop_expr : & ast :: Expr , binop_ty : Ty < ' tcx > , op : ast :: BinOp , lhs_t : Ty < ' tcx > , lhs : ValueRef , rhs_t : Ty < ' tcx > , rhs : ValueRef ) -> DatumBlock < ' blk , ' tcx , Expr > { let _icx = push_ctxt ( " " ) ; let tcx = bcx . tcx ( ) ; let is_simd = lhs_t . is_simd ( tcx ) ; let intype = if is_simd { lhs_t . simd_type ( tcx ) } else { lhs_t } ; let is_float = intype . is_fp ( ) ; let is_signed = intype . is_signed ( ) ; let info = expr_info ( binop_expr ) ; let binop_debug_loc = binop_expr . debug_loc ( ) ; let mut bcx = bcx ; let val = match op . node { ast :: BiAdd => { if is_float { FAdd ( bcx , lhs , rhs , binop_debug_loc ) } else if is_simd { Add ( bcx , lhs , rhs , binop_debug_loc ) } else { let ( newbcx , res ) = with_overflow_check ( bcx , OverflowOp :: Add , info , lhs_t , lhs , rhs , binop_debug_loc ) ; bcx = newbcx ; res } } ast :: BiSub => { if is_float { FSub ( bcx , lhs , rhs , binop_debug_loc ) } else if is_simd { Sub ( bcx , lhs , rhs , binop_debug_loc ) } else { let ( newbcx , res ) = with_overflow_check ( bcx , OverflowOp :: Sub , info , lhs_t , lhs , rhs , binop_debug_loc ) ; bcx = newbcx ; res } } ast :: BiMul => { if is_float { FMul ( bcx , lhs , rhs , binop_debug_loc ) } else if is_simd { Mul ( bcx , lhs , rhs , binop_debug_loc ) } else { let ( newbcx , res ) = with_overflow_check ( bcx , OverflowOp :: Mul , info , lhs_t , lhs , rhs , binop_debug_loc ) ; bcx = newbcx ; res } } ast :: BiDiv => { if is_float { FDiv ( bcx , lhs , rhs , binop_debug_loc ) } else { // Only zero-check integers; fp /0 is NaN bcx = base :: fail_if_zero_or_overflows ( bcx , expr_info ( binop_expr ) , op , lhs , rhs , rhs_t ) ; if is_signed { SDiv ( bcx , lhs , rhs , binop_debug_loc ) } else { UDiv ( bcx , lhs , rhs , binop_debug_loc ) } } } ast :: BiRem => { if is_float { FRem ( bcx , lhs , rhs , binop_debug_loc ) } else { // Only zero-check integers; fp %0 is NaN bcx = base :: fail_if_zero_or_overflows ( bcx , expr_info ( binop_expr ) , op , lhs , rhs , rhs_t ) ; if is_signed { SRem ( bcx , lhs , rhs , binop_debug_loc ) } else { URem ( bcx , lhs , rhs , binop_debug_loc ) } } } ast :: BiBitOr => Or ( bcx , lhs , rhs , binop_debug_loc ) , ast :: BiBitAnd => And ( bcx , lhs , rhs , binop_debug_loc ) , ast :: BiBitXor => Xor ( bcx , lhs , rhs , binop_debug_loc ) , ast :: BiShl => { let ( newbcx , res ) = with_overflow_check ( bcx , OverflowOp :: Shl , info , lhs_t , lhs , rhs , binop_debug_loc ) ; bcx = newbcx ; res } ast :: BiShr => { let ( newbcx , res ) = with_overflow_check ( bcx , OverflowOp :: Shr , info , lhs_t , lhs , rhs , binop_debug_loc ) ; bcx = newbcx ; res } ast :: BiEq | ast :: BiNe | ast :: BiLt | ast :: BiGe | ast :: BiLe | ast :: BiGt => { if is_simd { base :: compare_simd_types ( bcx , lhs , rhs , intype , op . node , binop_debug_loc ) } else { base :: compare_scalar_types ( bcx , lhs , rhs , intype , op . node , binop_debug_loc ) } } _ => { bcx . tcx ( ) . sess . span_bug ( binop_expr . span , " " ) ; } } ; immediate_rvalue_bcx ( bcx , val , binop_ty ) . to_expr_datumblock ( ) }
Important to get types for both lhs and rhs, because one might be _|_
and the other not.
Important to get types for both lhs and rhs because one might be _|_ and the other not .
bcx
Block<'blk, 'tcx>
binop_expr
&ast::Expr
binop_ty
Ty<'tcx>
op
ast::BinOp
lhs_t
Ty<'tcx>
lhs
ValueRef
rhs_t
Ty<'tcx>
rhs
ValueRef
bcx
Block<'blk, 'tcx>
binop_expr
&ast::Expr
binop_ty
Ty<'tcx>
op
ast::BinOp
lhs_t
Ty<'tcx>
lhs
ValueRef
rhs_t
Ty<'tcx>
rhs
ValueRef