Skip to content

Use more Datums in trans. #13004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 8 additions & 18 deletions src/librustc/middle/trans/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ use driver::session::FullDebugInfo;
use lib::llvm::{llvm, ValueRef, BasicBlockRef};
use middle::const_eval;
use middle::borrowck::root_map_key;
use middle::lang_items::{UniqStrEqFnLangItem, StrEqFnLangItem};
use middle::lang_items::StrEqFnLangItem;
use middle::pat_util::*;
use middle::resolve::DefMap;
use middle::trans::adt;
Expand Down Expand Up @@ -1278,30 +1278,20 @@ fn compare_values<'a>(
-> Result<'a> {
let _icx = push_ctxt("compare_values");
if ty::type_is_scalar(rhs_t) {
let rs = compare_scalar_types(cx, lhs, rhs, rhs_t, ast::BiEq);
return rslt(rs.bcx, rs.val);
return compare_scalar_types(cx, lhs, rhs, rhs_t, ast::BiEq);
}

match ty::get(rhs_t).sty {
ty::ty_str(ty::vstore_uniq) => {
let scratch_lhs = alloca(cx, val_ty(lhs), "__lhs");
Store(cx, lhs, scratch_lhs);
let scratch_rhs = alloca(cx, val_ty(rhs), "__rhs");
Store(cx, rhs, scratch_rhs);
let did = langcall(cx, None,
format!("comparison of `{}`", cx.ty_to_str(rhs_t)),
UniqStrEqFnLangItem);
let result = callee::trans_lang_call(cx, did, [scratch_lhs, scratch_rhs], None);
Result {
bcx: result.bcx,
val: bool_to_i1(result.bcx, result.val)
}
}
ty::ty_str(_) => {
let did = langcall(cx, None,
format!("comparison of `{}`", cx.ty_to_str(rhs_t)),
StrEqFnLangItem);
let result = callee::trans_lang_call(cx, did, [lhs, rhs], None);
let result = callee::trans_call(cx, None,
callee::Fn(callee::trans_fn_ref_with_vtables(cx, did, ExprId(0), [], None)),
[lhs, rhs].iter(), |bcx, &val| {
DatumBlock(bcx, Datum(val, rhs_t, RvalueExpr(Rvalue(ByRef))))
},
None);
Result {
bcx: result.bcx,
val: bool_to_i1(result.bcx, result.val)
Expand Down
16 changes: 7 additions & 9 deletions src/librustc/middle/trans/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,13 @@ pub fn trans_inline_asm<'a>(bcx: &'a Block<'a>, ia: &ast::InlineAsm)
// Now the input operands
let inputs = ia.inputs.map(|&(ref c, input)| {
constraints.push((*c).clone());

let in_datum = unpack_datum!(bcx, expr::trans(bcx, input));
unpack_result!(bcx, {
callee::trans_arg_datum(bcx,
expr_ty(bcx, input),
in_datum,
cleanup::CustomScope(temp_scope),
callee::DontAutorefArg)
})
let input = expr::trans(bcx, input);
let input_ty = input.datum.ty;
let input = unpack_datum!(bcx, {
callee::trans_arg_datum(input, input_ty,
cleanup::CustomScope(temp_scope))
});
input.val
});

// no failure occurred preparing operands, no need to cleanup
Expand Down
Loading