Merge pull request #2427 from msullivan/shifts

Get rid of the >>> operator and make >> logical or arithmetic depending ...
This commit is contained in:
Brian Anderson 2012-05-22 17:50:04 -07:00
commit a32392d032
14 changed files with 49 additions and 79 deletions

View file

@ -44,8 +44,7 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val {
mul { const_int(a * b) } div { const_int(a / b) }
rem { const_int(a % b) } and | bitand { const_int(a & b) }
or | bitor { const_int(a | b) } bitxor { const_int(a ^ b) }
lsl { const_int(a << b) } lsr { const_int(a >> b) }
asr { const_int(a >>> b) }
shl { const_int(a << b) } shr { const_int(a >> b) }
eq { fromb(a == b) } lt { fromb(a < b) }
le { fromb(a <= b) } ne { fromb(a != b) }
ge { fromb(a >= b) } gt { fromb(a > b) }
@ -58,9 +57,7 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val {
mul { const_uint(a * b) } div { const_uint(a / b) }
rem { const_uint(a % b) } and | bitand { const_uint(a & b) }
or | bitor { const_uint(a | b) } bitxor { const_uint(a ^ b) }
lsl { const_int((a << b) as i64) }
lsr { const_int((a >> b) as i64) }
asr { const_int((a >>> b) as i64) }
shl { const_uint(a << b) } shr { const_uint(a >> b) }
eq { fromb(a == b) } lt { fromb(a < b) }
le { fromb(a <= b) } ne { fromb(a != b) }
ge { fromb(a >= b) } gt { fromb(a > b) }

View file

@ -1617,9 +1617,12 @@ fn trans_eager_binop(cx: block, op: ast::binop, lhs: ValueRef,
ast::bitor { Or(cx, lhs, rhs) }
ast::bitand { And(cx, lhs, rhs) }
ast::bitxor { Xor(cx, lhs, rhs) }
ast::lsl { Shl(cx, lhs, rhs) }
ast::lsr { LShr(cx, lhs, rhs) }
ast::asr { AShr(cx, lhs, rhs) }
ast::shl { Shl(cx, lhs, rhs) }
ast::shr {
if ty::type_is_signed(intype) {
AShr(cx, lhs, rhs)
} else { LShr(cx, lhs, rhs) }
}
_ {
let cmpr = trans_compare(cx, op, lhs, lhs_t, rhs, rhs_t);
cx = cmpr.bcx;
@ -4565,9 +4568,11 @@ fn trans_const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
ast::bitxor { llvm::LLVMConstXor(te1, te2) }
ast::bitand { llvm::LLVMConstAnd(te1, te2) }
ast::bitor { llvm::LLVMConstOr(te1, te2) }
ast::lsl { llvm::LLVMConstShl(te1, te2) }
ast::lsr { llvm::LLVMConstLShr(te1, te2) }
ast::asr { llvm::LLVMConstAShr(te1, te2) }
ast::shl { llvm::LLVMConstShl(te1, te2) }
ast::shr {
if signed { llvm::LLVMConstAShr(te1, te2) }
else { llvm::LLVMConstLShr(te1, te2) }
}
ast::eq |
ast::lt |
ast::le |

View file

@ -2711,9 +2711,8 @@ fn is_binopable(_cx: ctxt, ty: t, op: ast::binop) -> bool {
ast::bitxor { opcat_bit }
ast::bitand { opcat_bit }
ast::bitor { opcat_bit }
ast::lsl { opcat_shift }
ast::lsr { opcat_shift }
ast::asr { opcat_shift }
ast::shl { opcat_shift }
ast::shr { opcat_shift }
ast::eq { opcat_eq }
ast::ne { opcat_eq }
ast::lt { opcat_rel }

View file

@ -867,8 +867,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
fn binop_method(op: ast::binop) -> option<str> {
alt op {
ast::add | ast::subtract | ast::mul | ast::div | ast::rem |
ast::bitxor | ast::bitand | ast::bitor | ast::lsl | ast::lsr |
ast::asr { some(ast_util::binop_to_str(op)) }
ast::bitxor | ast::bitand | ast::bitor | ast::shl | ast::shr
{ some(ast_util::binop_to_str(op)) }
_ { none }
}
}