trans: Use fmt::Debug for debugging instead of ad-hoc methods.
This commit is contained in:
parent
abb1515c53
commit
b47fcb8375
@ -133,6 +133,7 @@ pub enum DLLStorageClassTypes {
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
#[derive(Debug)]
|
||||
flags Attribute : u64 {
|
||||
const ZExt = 1 << 0,
|
||||
const SExt = 1 << 1,
|
||||
|
@ -216,6 +216,7 @@ use trans::monomorphize;
|
||||
use trans::tvec;
|
||||
use trans::type_of;
|
||||
use trans::Disr;
|
||||
use trans::value::Value;
|
||||
use middle::ty::{self, Ty, TyCtxt};
|
||||
use middle::traits::ProjectionMode;
|
||||
use session::config::NoDebugInfo;
|
||||
@ -448,6 +449,12 @@ impl<'tcx> Datum<'tcx, Lvalue> {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for MatchInput {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt::Debug::fmt(&Value(self.val), f)
|
||||
}
|
||||
}
|
||||
|
||||
impl MatchInput {
|
||||
fn from_val(val: ValueRef) -> MatchInput {
|
||||
MatchInput {
|
||||
@ -466,11 +473,8 @@ fn expand_nested_bindings<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
col: usize,
|
||||
val: MatchInput)
|
||||
-> Vec<Match<'a, 'p, 'blk, 'tcx>> {
|
||||
debug!("expand_nested_bindings(bcx={}, m={:?}, col={}, val={})",
|
||||
bcx.to_str(),
|
||||
m,
|
||||
col,
|
||||
bcx.val_to_string(val.val));
|
||||
debug!("expand_nested_bindings(bcx={}, m={:?}, col={}, val={:?})",
|
||||
bcx.to_str(), m, col, val);
|
||||
let _indenter = indenter();
|
||||
|
||||
m.iter().map(|br| {
|
||||
@ -506,11 +510,8 @@ fn enter_match<'a, 'b, 'p, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
|
||||
-> Vec<Match<'a, 'p, 'blk, 'tcx>> where
|
||||
F: FnMut(&[&'p hir::Pat]) -> Option<Vec<&'p hir::Pat>>,
|
||||
{
|
||||
debug!("enter_match(bcx={}, m={:?}, col={}, val={})",
|
||||
bcx.to_str(),
|
||||
m,
|
||||
col,
|
||||
bcx.val_to_string(val.val));
|
||||
debug!("enter_match(bcx={}, m={:?}, col={}, val={:?})",
|
||||
bcx.to_str(), m, col, val);
|
||||
let _indenter = indenter();
|
||||
|
||||
m.iter().filter_map(|br| {
|
||||
@ -549,11 +550,8 @@ fn enter_default<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
col: usize,
|
||||
val: MatchInput)
|
||||
-> Vec<Match<'a, 'p, 'blk, 'tcx>> {
|
||||
debug!("enter_default(bcx={}, m={:?}, col={}, val={})",
|
||||
bcx.to_str(),
|
||||
m,
|
||||
col,
|
||||
bcx.val_to_string(val.val));
|
||||
debug!("enter_default(bcx={}, m={:?}, col={}, val={:?})",
|
||||
bcx.to_str(), m, col, val);
|
||||
let _indenter = indenter();
|
||||
|
||||
// Collect all of the matches that can match against anything.
|
||||
@ -606,12 +604,8 @@ fn enter_opt<'a, 'p, 'blk, 'tcx>(
|
||||
variant_size: usize,
|
||||
val: MatchInput)
|
||||
-> Vec<Match<'a, 'p, 'blk, 'tcx>> {
|
||||
debug!("enter_opt(bcx={}, m={:?}, opt={:?}, col={}, val={})",
|
||||
bcx.to_str(),
|
||||
m,
|
||||
*opt,
|
||||
col,
|
||||
bcx.val_to_string(val.val));
|
||||
debug!("enter_opt(bcx={}, m={:?}, opt={:?}, col={}, val={:?})",
|
||||
bcx.to_str(), m, *opt, col, val);
|
||||
let _indenter = indenter();
|
||||
|
||||
let ctor = match opt {
|
||||
@ -1032,7 +1026,7 @@ fn insert_lllocals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
bcx.fcx.schedule_drop_and_fill_mem(cs, llval, binding_info.ty, opt_datum);
|
||||
}
|
||||
|
||||
debug!("binding {} to {}", binding_info.id, bcx.val_to_string(llval));
|
||||
debug!("binding {} to {:?}", binding_info.id, Value(llval));
|
||||
bcx.fcx.lllocals.borrow_mut().insert(binding_info.id, datum);
|
||||
debuginfo::create_match_binding_metadata(bcx, name, binding_info);
|
||||
}
|
||||
@ -1047,11 +1041,8 @@ fn compile_guard<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
chk: &FailureHandler,
|
||||
has_genuine_default: bool)
|
||||
-> Block<'blk, 'tcx> {
|
||||
debug!("compile_guard(bcx={}, guard_expr={:?}, m={:?}, vals=[{}])",
|
||||
bcx.to_str(),
|
||||
guard_expr,
|
||||
m,
|
||||
vals.iter().map(|v| bcx.val_to_string(v.val)).collect::<Vec<_>>().join(", "));
|
||||
debug!("compile_guard(bcx={}, guard_expr={:?}, m={:?}, vals={:?})",
|
||||
bcx.to_str(), guard_expr, m, vals);
|
||||
let _indenter = indenter();
|
||||
|
||||
let mut bcx = insert_lllocals(bcx, &data.bindings_map, None);
|
||||
@ -1093,10 +1084,8 @@ fn compile_submatch<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
vals: &[MatchInput],
|
||||
chk: &FailureHandler,
|
||||
has_genuine_default: bool) {
|
||||
debug!("compile_submatch(bcx={}, m={:?}, vals=[{}])",
|
||||
bcx.to_str(),
|
||||
m,
|
||||
vals.iter().map(|v| bcx.val_to_string(v.val)).collect::<Vec<_>>().join(", "));
|
||||
debug!("compile_submatch(bcx={}, m={:?}, vals=[{:?}])",
|
||||
bcx.to_str(), m, vals);
|
||||
let _indenter = indenter();
|
||||
let _icx = push_ctxt("match::compile_submatch");
|
||||
let mut bcx = bcx;
|
||||
@ -1256,7 +1245,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
debug!("options={:?}", opts);
|
||||
let mut kind = NoBranch;
|
||||
let mut test_val = val.val;
|
||||
debug!("test_val={}", bcx.val_to_string(test_val));
|
||||
debug!("test_val={:?}", Value(test_val));
|
||||
if !opts.is_empty() {
|
||||
match opts[0] {
|
||||
ConstantValue(..) | ConstantRange(..) => {
|
||||
@ -1761,8 +1750,8 @@ fn mk_binding_alloca<'blk, 'tcx, A, F>(bcx: Block<'blk, 'tcx>,
|
||||
let lvalue = Lvalue::new_with_hint(caller_name, bcx, p_id, HintKind::DontZeroJustUse);
|
||||
let datum = Datum::new(llval, var_ty, lvalue);
|
||||
|
||||
debug!("mk_binding_alloca cleanup_scope={:?} llval={} var_ty={:?}",
|
||||
cleanup_scope, bcx.ccx().tn().val_to_string(llval), var_ty);
|
||||
debug!("mk_binding_alloca cleanup_scope={:?} llval={:?} var_ty={:?}",
|
||||
cleanup_scope, Value(llval), var_ty);
|
||||
|
||||
// Subtle: be sure that we *populate* the memory *before*
|
||||
// we schedule the cleanup.
|
||||
@ -1794,10 +1783,8 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
val: MatchInput,
|
||||
cleanup_scope: cleanup::ScopeId)
|
||||
-> Block<'blk, 'tcx> {
|
||||
debug!("bind_irrefutable_pat(bcx={}, pat={:?}, val={})",
|
||||
bcx.to_str(),
|
||||
pat,
|
||||
bcx.val_to_string(val.val));
|
||||
debug!("bind_irrefutable_pat(bcx={}, pat={:?}, val={:?})",
|
||||
bcx.to_str(), pat, val);
|
||||
|
||||
if bcx.sess().asm_comments() {
|
||||
add_comment(bcx, &format!("bind_irrefutable_pat(pat={:?})",
|
||||
@ -1923,7 +1910,7 @@ pub fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
// a regular one
|
||||
if !type_is_sized(tcx, fty) {
|
||||
let scratch = alloc_ty(bcx, fty, "__struct_field_fat_ptr");
|
||||
debug!("Creating fat pointer {}", bcx.val_to_string(scratch));
|
||||
debug!("Creating fat pointer {:?}", Value(scratch));
|
||||
Store(bcx, fldptr, expr::get_dataptr(bcx, scratch));
|
||||
Store(bcx, val.meta, expr::get_meta(bcx, scratch));
|
||||
fldptr = scratch;
|
||||
|
@ -67,6 +67,7 @@ use trans::machine;
|
||||
use trans::monomorphize;
|
||||
use trans::type_::Type;
|
||||
use trans::type_of;
|
||||
use trans::value::Value;
|
||||
|
||||
type Hint = attr::ReprAttr;
|
||||
|
||||
@ -88,11 +89,6 @@ impl TypeContext {
|
||||
fn may_need_drop_flag(t: Type, needs_drop_flag: bool) -> TypeContext {
|
||||
TypeContext { prefix: t, needs_drop_flag: needs_drop_flag }
|
||||
}
|
||||
pub fn to_string(self) -> String {
|
||||
let TypeContext { prefix, needs_drop_flag } = self;
|
||||
format!("TypeContext {{ prefix: {}, needs_drop_flag: {} }}",
|
||||
prefix.to_string(), needs_drop_flag)
|
||||
}
|
||||
}
|
||||
|
||||
/// Representations.
|
||||
@ -1139,9 +1135,8 @@ pub fn struct_field_ptr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, st: &Struct<'tcx>, v
|
||||
|
||||
// There's no metadata available, log the case and just do the GEP.
|
||||
if !val.has_meta() {
|
||||
debug!("Unsized field `{}`, of `{}` has no metadata for adjustment",
|
||||
ix,
|
||||
bcx.val_to_string(ptr_val));
|
||||
debug!("Unsized field `{}`, of `{:?}` has no metadata for adjustment",
|
||||
ix, Value(ptr_val));
|
||||
return StructGEP(bcx, ptr_val, ix);
|
||||
}
|
||||
|
||||
@ -1189,8 +1184,7 @@ pub fn struct_field_ptr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, st: &Struct<'tcx>, v
|
||||
Neg(bcx, align, dbloc),
|
||||
dbloc);
|
||||
|
||||
debug!("struct_field_ptr: DST field offset: {}",
|
||||
bcx.val_to_string(offset));
|
||||
debug!("struct_field_ptr: DST field offset: {:?}", Value(offset));
|
||||
|
||||
// Cast and adjust pointer
|
||||
let byte_ptr = PointerCast(bcx, ptr_val, Type::i8p(bcx.ccx()));
|
||||
@ -1198,7 +1192,7 @@ pub fn struct_field_ptr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, st: &Struct<'tcx>, v
|
||||
|
||||
// Finally, cast back to the type expected
|
||||
let ll_fty = type_of::in_memory_type_of(bcx.ccx(), fty);
|
||||
debug!("struct_field_ptr: Field type is {}", ll_fty.to_string());
|
||||
debug!("struct_field_ptr: Field type is {:?}", ll_fty);
|
||||
PointerCast(bcx, byte_ptr, ll_fty.ptr_to())
|
||||
}
|
||||
|
||||
@ -1442,7 +1436,7 @@ fn padding(ccx: &CrateContext, size: u64) -> ValueRef {
|
||||
fn roundup(x: u64, a: u32) -> u64 { let a = a as u64; ((x + (a - 1)) / a) * a }
|
||||
|
||||
/// Get the discriminant of a constant value.
|
||||
pub fn const_get_discrim(ccx: &CrateContext, r: &Repr, val: ValueRef) -> Disr {
|
||||
pub fn const_get_discrim(r: &Repr, val: ValueRef) -> Disr {
|
||||
match *r {
|
||||
CEnum(ity, _, _) => {
|
||||
match ity {
|
||||
@ -1452,13 +1446,13 @@ pub fn const_get_discrim(ccx: &CrateContext, r: &Repr, val: ValueRef) -> Disr {
|
||||
}
|
||||
General(ity, _, _) => {
|
||||
match ity {
|
||||
attr::SignedInt(..) => Disr(const_to_int(const_get_elt(ccx, val, &[0])) as u64),
|
||||
attr::UnsignedInt(..) => Disr(const_to_uint(const_get_elt(ccx, val, &[0])))
|
||||
attr::SignedInt(..) => Disr(const_to_int(const_get_elt(val, &[0])) as u64),
|
||||
attr::UnsignedInt(..) => Disr(const_to_uint(const_get_elt(val, &[0])))
|
||||
}
|
||||
}
|
||||
Univariant(..) => Disr(0),
|
||||
RawNullablePointer { .. } | StructWrappedNullablePointer { .. } => {
|
||||
ccx.sess().bug("const discrim access of non c-like enum")
|
||||
unreachable!("const discrim access of non c-like enum")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1472,25 +1466,25 @@ pub fn const_get_field(ccx: &CrateContext, r: &Repr, val: ValueRef,
|
||||
_discr: Disr, ix: usize) -> ValueRef {
|
||||
match *r {
|
||||
CEnum(..) => ccx.sess().bug("element access in C-like enum const"),
|
||||
Univariant(..) => const_struct_field(ccx, val, ix),
|
||||
General(..) => const_struct_field(ccx, val, ix + 1),
|
||||
Univariant(..) => const_struct_field(val, ix),
|
||||
General(..) => const_struct_field(val, ix + 1),
|
||||
RawNullablePointer { .. } => {
|
||||
assert_eq!(ix, 0);
|
||||
val
|
||||
},
|
||||
StructWrappedNullablePointer{ .. } => const_struct_field(ccx, val, ix)
|
||||
StructWrappedNullablePointer{ .. } => const_struct_field(val, ix)
|
||||
}
|
||||
}
|
||||
|
||||
/// Extract field of struct-like const, skipping our alignment padding.
|
||||
fn const_struct_field(ccx: &CrateContext, val: ValueRef, ix: usize) -> ValueRef {
|
||||
fn const_struct_field(val: ValueRef, ix: usize) -> ValueRef {
|
||||
// Get the ix-th non-undef element of the struct.
|
||||
let mut real_ix = 0; // actual position in the struct
|
||||
let mut ix = ix; // logical index relative to real_ix
|
||||
let mut field;
|
||||
loop {
|
||||
loop {
|
||||
field = const_get_elt(ccx, val, &[real_ix]);
|
||||
field = const_get_elt(val, &[real_ix]);
|
||||
if !is_undef(field) {
|
||||
break;
|
||||
}
|
||||
|
@ -948,9 +948,9 @@ pub fn invoke<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
}
|
||||
|
||||
if need_invoke(bcx) {
|
||||
debug!("invoking {} at {:?}", bcx.val_to_string(llfn), bcx.llbb);
|
||||
debug!("invoking {:?} at {:?}", Value(llfn), bcx.llbb);
|
||||
for &llarg in llargs {
|
||||
debug!("arg: {}", bcx.val_to_string(llarg));
|
||||
debug!("arg: {:?}", Value(llarg));
|
||||
}
|
||||
let normal_bcx = bcx.fcx.new_temp_block("normal-return");
|
||||
let landing_pad = bcx.fcx.get_landing_pad();
|
||||
@ -964,9 +964,9 @@ pub fn invoke<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
debug_loc);
|
||||
return (llresult, normal_bcx);
|
||||
} else {
|
||||
debug!("calling {} at {:?}", bcx.val_to_string(llfn), bcx.llbb);
|
||||
debug!("calling {:?} at {:?}", Value(llfn), bcx.llbb);
|
||||
for &llarg in llargs {
|
||||
debug!("arg: {}", bcx.val_to_string(llarg));
|
||||
debug!("arg: {:?}", Value(llarg));
|
||||
}
|
||||
|
||||
let llresult = Call(bcx, llfn, &llargs[..], Some(attributes), debug_loc);
|
||||
@ -1058,10 +1058,7 @@ pub fn store_ty<'blk, 'tcx>(cx: Block<'blk, 'tcx>, v: ValueRef, dst: ValueRef, t
|
||||
return;
|
||||
}
|
||||
|
||||
debug!("store_ty: {} : {:?} <- {}",
|
||||
cx.val_to_string(dst),
|
||||
t,
|
||||
cx.val_to_string(v));
|
||||
debug!("store_ty: {:?} : {:?} <- {:?}", Value(dst), t, Value(v));
|
||||
|
||||
if common::type_is_fat_ptr(cx.tcx(), t) {
|
||||
Store(cx,
|
||||
@ -2030,8 +2027,7 @@ pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
debug!("trans_closure: monomorphized_arg_type: {:?}",
|
||||
monomorphized_arg_type);
|
||||
}
|
||||
debug!("trans_closure: function lltype: {}",
|
||||
bcx.fcx.ccx.tn().val_to_string(bcx.fcx.llfn));
|
||||
debug!("trans_closure: function lltype: {:?}", Value(bcx.fcx.llfn));
|
||||
|
||||
let has_tupled_arg = match closure_env {
|
||||
closure::ClosureEnv::NotClosure => abi == Abi::RustCall,
|
||||
|
@ -20,6 +20,7 @@ use syntax::codemap::Span;
|
||||
|
||||
use trans::builder::Builder;
|
||||
use trans::type_::Type;
|
||||
use trans::value::Value;
|
||||
use trans::debuginfo::DebugLoc;
|
||||
|
||||
use libc::{c_uint, c_char};
|
||||
@ -146,9 +147,11 @@ pub fn Invoke(cx: Block,
|
||||
}
|
||||
check_not_terminated(cx);
|
||||
terminate(cx, "Invoke");
|
||||
debug!("Invoke({} with arguments ({}))",
|
||||
cx.val_to_string(fn_),
|
||||
args.iter().map(|a| cx.val_to_string(*a)).collect::<Vec<String>>().join(", "));
|
||||
debug!("Invoke({:?} with arguments ({}))",
|
||||
Value(fn_),
|
||||
args.iter().map(|a| {
|
||||
format!("{:?}", Value(*a))
|
||||
}).collect::<Vec<String>>().join(", "));
|
||||
debug_loc.apply(cx.fcx);
|
||||
let bundle = cx.lpad().and_then(|b| b.bundle());
|
||||
B(cx).invoke(fn_, args, then, catch, bundle, attributes)
|
||||
|
@ -18,6 +18,7 @@ use trans::base;
|
||||
use trans::common::*;
|
||||
use trans::machine::llalign_of_pref;
|
||||
use trans::type_::Type;
|
||||
use trans::value::Value;
|
||||
use util::nodemap::FnvHashMap;
|
||||
use libc::{c_uint, c_char};
|
||||
|
||||
@ -169,10 +170,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
-> ValueRef {
|
||||
self.count_insn("invoke");
|
||||
|
||||
debug!("Invoke {} with args ({})",
|
||||
self.ccx.tn().val_to_string(llfn),
|
||||
debug!("Invoke {:?} with args ({})",
|
||||
Value(llfn),
|
||||
args.iter()
|
||||
.map(|&v| self.ccx.tn().val_to_string(v))
|
||||
.map(|&v| format!("{:?}", Value(v)))
|
||||
.collect::<Vec<String>>()
|
||||
.join(", "));
|
||||
|
||||
@ -497,9 +498,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
}
|
||||
|
||||
pub fn store(&self, val: ValueRef, ptr: ValueRef) -> ValueRef {
|
||||
debug!("Store {} -> {}",
|
||||
self.ccx.tn().val_to_string(val),
|
||||
self.ccx.tn().val_to_string(ptr));
|
||||
debug!("Store {:?} -> {:?}", Value(val), Value(ptr));
|
||||
assert!(!self.llbuilder.is_null());
|
||||
self.count_insn("store");
|
||||
unsafe {
|
||||
@ -508,9 +507,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
}
|
||||
|
||||
pub fn volatile_store(&self, val: ValueRef, ptr: ValueRef) -> ValueRef {
|
||||
debug!("Store {} -> {}",
|
||||
self.ccx.tn().val_to_string(val),
|
||||
self.ccx.tn().val_to_string(ptr));
|
||||
debug!("Store {:?} -> {:?}", Value(val), Value(ptr));
|
||||
assert!(!self.llbuilder.is_null());
|
||||
self.count_insn("store.volatile");
|
||||
unsafe {
|
||||
@ -521,9 +518,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
}
|
||||
|
||||
pub fn atomic_store(&self, val: ValueRef, ptr: ValueRef, order: AtomicOrdering) {
|
||||
debug!("Store {} -> {}",
|
||||
self.ccx.tn().val_to_string(val),
|
||||
self.ccx.tn().val_to_string(ptr));
|
||||
debug!("Store {:?} -> {:?}", Value(val), Value(ptr));
|
||||
self.count_insn("store.atomic");
|
||||
unsafe {
|
||||
let ty = Type::from_ref(llvm::LLVMTypeOf(ptr));
|
||||
@ -796,11 +791,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
else { llvm::False };
|
||||
|
||||
let argtys = inputs.iter().map(|v| {
|
||||
debug!("Asm Input Type: {}", self.ccx.tn().val_to_string(*v));
|
||||
debug!("Asm Input Type: {:?}", Value(*v));
|
||||
val_ty(*v)
|
||||
}).collect::<Vec<_>>();
|
||||
|
||||
debug!("Asm Output Type: {}", self.ccx.tn().type_to_string(output));
|
||||
debug!("Asm Output Type: {:?}", output);
|
||||
let fty = Type::func(&argtys[..], &output);
|
||||
unsafe {
|
||||
let v = llvm::LLVMInlineAsm(
|
||||
@ -814,10 +809,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
attributes: Option<AttrBuilder>) -> ValueRef {
|
||||
self.count_insn("call");
|
||||
|
||||
debug!("Call {} with args ({})",
|
||||
self.ccx.tn().val_to_string(llfn),
|
||||
debug!("Call {:?} with args ({})",
|
||||
Value(llfn),
|
||||
args.iter()
|
||||
.map(|&v| self.ccx.tn().val_to_string(v))
|
||||
.map(|&v| format!("{:?}", Value(v)))
|
||||
.collect::<Vec<String>>()
|
||||
.join(", "));
|
||||
|
||||
@ -838,11 +833,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
if expected_ty != actual_ty {
|
||||
self.ccx.sess().bug(
|
||||
&format!(
|
||||
"Type mismatch in function call of {}. Expected {} for param {}, got {}",
|
||||
self.ccx.tn().val_to_string(llfn),
|
||||
self.ccx.tn().type_to_string(expected_ty),
|
||||
i,
|
||||
self.ccx.tn().type_to_string(actual_ty)));
|
||||
"Type mismatch in function call of {:?}. \
|
||||
Expected {:?} for param {}, got {:?}",
|
||||
Value(llfn),
|
||||
expected_ty, i, actual_ty));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ use trans::cabi_mips;
|
||||
use trans::cabi_asmjs;
|
||||
use trans::type_::Type;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||
pub enum ArgKind {
|
||||
/// Pass the argument directly using the normal converted
|
||||
/// LLVM type or by coercing to another specified type
|
||||
@ -39,7 +39,7 @@ pub enum ArgKind {
|
||||
/// should be passed to or returned from a function
|
||||
///
|
||||
/// This is borrowed from clang's ABIInfo.h
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct ArgType {
|
||||
pub kind: ArgKind,
|
||||
/// Original LLVM type
|
||||
|
@ -47,6 +47,7 @@ use trans::meth;
|
||||
use trans::monomorphize;
|
||||
use trans::type_::Type;
|
||||
use trans::type_of;
|
||||
use trans::value::Value;
|
||||
use trans::Disr;
|
||||
use middle::ty::{self, Ty, TyCtxt, TypeFoldable};
|
||||
use rustc_front::hir;
|
||||
@ -615,8 +616,8 @@ fn trans_call_inner<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
||||
let llret_ty = common::val_ty(llretslot);
|
||||
if llformal_ret_ty != llret_ty {
|
||||
// this could happen due to e.g. subtyping
|
||||
debug!("casting actual return type ({}) to match formal ({})",
|
||||
bcx.llty_str(llret_ty), bcx.llty_str(llformal_ret_ty));
|
||||
debug!("casting actual return type ({:?}) to match formal ({:?})",
|
||||
llret_ty, llformal_ret_ty);
|
||||
llretslot = PointerCast(bcx, llretslot, llformal_ret_ty);
|
||||
}
|
||||
llargs.push(llretslot);
|
||||
@ -926,12 +927,11 @@ pub fn trans_arg_datum<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
let mut bcx = bcx;
|
||||
let ccx = bcx.ccx();
|
||||
|
||||
debug!("trans_arg_datum({:?})",
|
||||
formal_arg_ty);
|
||||
debug!("trans_arg_datum({:?})", formal_arg_ty);
|
||||
|
||||
let arg_datum_ty = arg_datum.ty;
|
||||
|
||||
debug!(" arg datum: {}", arg_datum.to_string(bcx.ccx()));
|
||||
debug!(" arg datum: {:?}", arg_datum);
|
||||
|
||||
let mut val = if common::type_is_fat_ptr(bcx.tcx(), arg_datum_ty) &&
|
||||
!bcx.fcx.type_needs_drop(arg_datum_ty) {
|
||||
@ -956,14 +956,14 @@ pub fn trans_arg_datum<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
if type_of::arg_is_indirect(ccx, formal_arg_ty) && formal_arg_ty != arg_datum_ty {
|
||||
// this could happen due to e.g. subtyping
|
||||
let llformal_arg_ty = type_of::type_of_explicit_arg(ccx, formal_arg_ty);
|
||||
debug!("casting actual type ({}) to match formal ({})",
|
||||
bcx.val_to_string(val), bcx.llty_str(llformal_arg_ty));
|
||||
debug!("casting actual type ({:?}) to match formal ({:?})",
|
||||
Value(val), llformal_arg_ty);
|
||||
debug!("Rust types: {:?}; {:?}", arg_datum_ty,
|
||||
formal_arg_ty);
|
||||
val = PointerCast(bcx, val, llformal_arg_ty);
|
||||
}
|
||||
|
||||
debug!("--- trans_arg_datum passing {}", bcx.val_to_string(val));
|
||||
debug!("--- trans_arg_datum passing {:?}", Value(val));
|
||||
|
||||
if common::type_is_fat_ptr(bcx.tcx(), formal_arg_ty) {
|
||||
llargs.push(Load(bcx, expr::get_dataptr(bcx, val)));
|
||||
|
@ -129,7 +129,9 @@ use trans::debuginfo::{DebugLoc, ToDebugLoc};
|
||||
use trans::glue;
|
||||
use middle::region;
|
||||
use trans::type_::Type;
|
||||
use trans::value::Value;
|
||||
use middle::ty::{Ty, TyCtxt};
|
||||
|
||||
use std::fmt;
|
||||
use syntax::ast;
|
||||
|
||||
@ -401,9 +403,8 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> {
|
||||
ptr: val,
|
||||
};
|
||||
|
||||
debug!("schedule_lifetime_end({:?}, val={})",
|
||||
cleanup_scope,
|
||||
self.ccx.tn().val_to_string(val));
|
||||
debug!("schedule_lifetime_end({:?}, val={:?})",
|
||||
cleanup_scope, Value(val));
|
||||
|
||||
self.schedule_clean(cleanup_scope, drop as CleanupObj);
|
||||
}
|
||||
@ -426,9 +427,9 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> {
|
||||
drop_hint: drop_hint,
|
||||
};
|
||||
|
||||
debug!("schedule_drop_mem({:?}, val={}, ty={:?}) fill_on_drop={} skip_dtor={}",
|
||||
debug!("schedule_drop_mem({:?}, val={:?}, ty={:?}) fill_on_drop={} skip_dtor={}",
|
||||
cleanup_scope,
|
||||
self.ccx.tn().val_to_string(val),
|
||||
Value(val),
|
||||
ty,
|
||||
drop.fill_on_drop,
|
||||
drop.skip_dtor);
|
||||
@ -454,10 +455,10 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> {
|
||||
drop_hint: drop_hint,
|
||||
};
|
||||
|
||||
debug!("schedule_drop_and_fill_mem({:?}, val={}, ty={:?},
|
||||
debug!("schedule_drop_and_fill_mem({:?}, val={:?}, ty={:?},
|
||||
fill_on_drop={}, skip_dtor={}, has_drop_hint={})",
|
||||
cleanup_scope,
|
||||
self.ccx.tn().val_to_string(val),
|
||||
Value(val),
|
||||
ty,
|
||||
drop.fill_on_drop,
|
||||
drop.skip_dtor,
|
||||
@ -488,9 +489,9 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> {
|
||||
drop_hint: None,
|
||||
};
|
||||
|
||||
debug!("schedule_drop_adt_contents({:?}, val={}, ty={:?}) fill_on_drop={} skip_dtor={}",
|
||||
debug!("schedule_drop_adt_contents({:?}, val={:?}, ty={:?}) fill_on_drop={} skip_dtor={}",
|
||||
cleanup_scope,
|
||||
self.ccx.tn().val_to_string(val),
|
||||
Value(val),
|
||||
ty,
|
||||
drop.fill_on_drop,
|
||||
drop.skip_dtor);
|
||||
@ -514,9 +515,9 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> {
|
||||
drop_hint: None,
|
||||
});
|
||||
|
||||
debug!("schedule_drop_immediate({:?}, val={}, ty={:?}) fill_on_drop={} skip_dtor={}",
|
||||
debug!("schedule_drop_immediate({:?}, val={:?}, ty={:?}) fill_on_drop={} skip_dtor={}",
|
||||
cleanup_scope,
|
||||
self.ccx.tn().val_to_string(val),
|
||||
Value(val),
|
||||
ty,
|
||||
drop.fill_on_drop,
|
||||
drop.skip_dtor);
|
||||
@ -532,10 +533,8 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> {
|
||||
content_ty: Ty<'tcx>) {
|
||||
let drop = box FreeValue { ptr: val, heap: heap, content_ty: content_ty };
|
||||
|
||||
debug!("schedule_free_value({:?}, val={}, heap={:?})",
|
||||
cleanup_scope,
|
||||
self.ccx.tn().val_to_string(val),
|
||||
heap);
|
||||
debug!("schedule_free_value({:?}, val={:?}, heap={:?})",
|
||||
cleanup_scope, Value(val), heap);
|
||||
|
||||
self.schedule_clean(cleanup_scope, drop as CleanupObj);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ use trans::declare;
|
||||
use trans::expr;
|
||||
use trans::monomorphize::{MonoId};
|
||||
use trans::type_of::*;
|
||||
use trans::value::Value;
|
||||
use trans::Disr;
|
||||
use middle::ty;
|
||||
use session::config::FullDebugInfo;
|
||||
@ -146,7 +147,7 @@ pub fn get_or_create_closure_declaration<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
|
||||
if let Some(&llfn) = ccx.closure_vals().borrow().get(&mono_id) {
|
||||
debug!("get_or_create_closure_declaration(): found closure {:?}: {:?}",
|
||||
mono_id, ccx.tn().val_to_string(llfn));
|
||||
mono_id, Value(llfn));
|
||||
return llfn;
|
||||
}
|
||||
|
||||
@ -160,10 +161,8 @@ pub fn get_or_create_closure_declaration<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
attributes::inline(llfn, attributes::InlineAttr::Hint);
|
||||
|
||||
debug!("get_or_create_declaration_if_closure(): inserting new \
|
||||
closure {:?} (type {}): {:?}",
|
||||
mono_id,
|
||||
ccx.tn().type_to_string(val_ty(llfn)),
|
||||
ccx.tn().val_to_string(llfn));
|
||||
closure {:?}: {:?}",
|
||||
mono_id, Value(llfn));
|
||||
ccx.closure_vals().borrow_mut().insert(mono_id, llfn);
|
||||
|
||||
llfn
|
||||
@ -278,11 +277,8 @@ pub fn trans_closure_method<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>,
|
||||
let tcx = ccx.tcx();
|
||||
|
||||
debug!("trans_closure_adapter_shim(llfn_closure_kind={:?}, \
|
||||
trait_closure_kind={:?}, \
|
||||
llfn={})",
|
||||
llfn_closure_kind,
|
||||
trait_closure_kind,
|
||||
ccx.tn().val_to_string(llfn));
|
||||
trait_closure_kind={:?}, llfn={:?})",
|
||||
llfn_closure_kind, trait_closure_kind, Value(llfn));
|
||||
|
||||
match (llfn_closure_kind, trait_closure_kind) {
|
||||
(ty::ClosureKind::Fn, ty::ClosureKind::Fn) |
|
||||
@ -324,10 +320,8 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
|
||||
llreffn: ValueRef)
|
||||
-> ValueRef
|
||||
{
|
||||
debug!("trans_fn_once_adapter_shim(closure_def_id={:?}, substs={:?}, llreffn={})",
|
||||
closure_def_id,
|
||||
substs,
|
||||
ccx.tn().val_to_string(llreffn));
|
||||
debug!("trans_fn_once_adapter_shim(closure_def_id={:?}, substs={:?}, llreffn={:?})",
|
||||
closure_def_id, substs, Value(llreffn));
|
||||
|
||||
let tcx = ccx.tcx();
|
||||
let infcx = infer::normalizing_infer_ctxt(ccx.tcx(), &ccx.tcx().tables, ProjectionMode::Any);
|
||||
@ -391,8 +385,8 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
|
||||
env_datum.to_lvalue_datum_in_scope(bcx, "self",
|
||||
self_scope_id));
|
||||
|
||||
debug!("trans_fn_once_adapter_shim: env_datum={}",
|
||||
bcx.val_to_string(env_datum.val));
|
||||
debug!("trans_fn_once_adapter_shim: env_datum={:?}",
|
||||
Value(env_datum.val));
|
||||
llargs[self_idx] = env_datum.val;
|
||||
|
||||
let dest =
|
||||
|
@ -37,6 +37,7 @@ use trans::machine;
|
||||
use trans::monomorphize;
|
||||
use trans::type_::Type;
|
||||
use trans::type_of;
|
||||
use trans::value::Value;
|
||||
use middle::ty::{self, Ty, TyCtxt};
|
||||
use middle::traits::{self, SelectionContext, ProjectionMode};
|
||||
use middle::ty::fold::{TypeFolder, TypeFoldable};
|
||||
@ -652,14 +653,6 @@ impl<'blk, 'tcx> BlockS<'blk, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn val_to_string(&self, val: ValueRef) -> String {
|
||||
self.ccx().tn().val_to_string(val)
|
||||
}
|
||||
|
||||
pub fn llty_str(&self, ty: Type) -> String {
|
||||
self.ccx().tn().type_to_string(ty)
|
||||
}
|
||||
|
||||
pub fn to_str(&self) -> String {
|
||||
format!("[block {:p}]", self)
|
||||
}
|
||||
@ -767,10 +760,6 @@ impl<'blk, 'tcx> BlockAndBuilder<'blk, 'tcx> {
|
||||
self.bcx.mir()
|
||||
}
|
||||
|
||||
pub fn val_to_string(&self, val: ValueRef) -> String {
|
||||
self.bcx.val_to_string(val)
|
||||
}
|
||||
|
||||
pub fn monomorphize<T>(&self, value: &T) -> T
|
||||
where T: TypeFoldable<'tcx>
|
||||
{
|
||||
@ -1028,15 +1017,15 @@ pub fn C_bytes_in_context(llcx: ContextRef, bytes: &[u8]) -> ValueRef {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn const_get_elt(cx: &CrateContext, v: ValueRef, us: &[c_uint])
|
||||
pub fn const_get_elt(v: ValueRef, us: &[c_uint])
|
||||
-> ValueRef {
|
||||
unsafe {
|
||||
let r = llvm::LLVMConstExtractValue(v, us.as_ptr(), us.len() as c_uint);
|
||||
|
||||
debug!("const_get_elt(v={}, us={:?}, r={})",
|
||||
cx.tn().val_to_string(v), us, cx.tn().val_to_string(r));
|
||||
debug!("const_get_elt(v={:?}, us={:?}, r={:?})",
|
||||
Value(v), us, Value(r));
|
||||
|
||||
return r;
|
||||
r
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ use trans::declare;
|
||||
use trans::monomorphize;
|
||||
use trans::type_::Type;
|
||||
use trans::type_of;
|
||||
use trans::value::Value;
|
||||
use trans::Disr;
|
||||
use middle::subst::Substs;
|
||||
use middle::ty::adjustment::{AdjustDerefRef, AdjustReifyFnPointer};
|
||||
@ -405,8 +406,8 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
// to use a different vtable. In that case, we want to
|
||||
// load out the original data pointer so we can repackage
|
||||
// it.
|
||||
(const_get_elt(cx, llconst, &[abi::FAT_PTR_ADDR as u32]),
|
||||
Some(const_get_elt(cx, llconst, &[abi::FAT_PTR_EXTRA as u32])))
|
||||
(const_get_elt(llconst, &[abi::FAT_PTR_ADDR as u32]),
|
||||
Some(const_get_elt(llconst, &[abi::FAT_PTR_EXTRA as u32])))
|
||||
} else {
|
||||
(llconst, None)
|
||||
};
|
||||
@ -595,17 +596,15 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
/* Neither type is bottom, and we expect them to be unified
|
||||
* already, so the following is safe. */
|
||||
let (te1, ty) = try!(const_expr(cx, &e1, param_substs, fn_args, trueconst));
|
||||
debug!("const_expr_unadjusted: te1={}, ty={:?}",
|
||||
cx.tn().val_to_string(te1),
|
||||
ty);
|
||||
debug!("const_expr_unadjusted: te1={:?}, ty={:?}",
|
||||
Value(te1), ty);
|
||||
assert!(!ty.is_simd());
|
||||
let is_float = ty.is_fp();
|
||||
let signed = ty.is_signed();
|
||||
|
||||
let (te2, ty2) = try!(const_expr(cx, &e2, param_substs, fn_args, trueconst));
|
||||
debug!("const_expr_unadjusted: te2={}, ty={:?}",
|
||||
cx.tn().val_to_string(te2),
|
||||
ty2);
|
||||
debug!("const_expr_unadjusted: te2={:?}, ty={:?}",
|
||||
Value(te2), ty2);
|
||||
|
||||
try!(check_binary_expr_validity(cx, e, ty, te1, te2, trueconst));
|
||||
|
||||
@ -689,8 +688,8 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
let (arr, len) = match bt.sty {
|
||||
ty::TyArray(_, u) => (bv, C_uint(cx, u)),
|
||||
ty::TySlice(..) | ty::TyStr => {
|
||||
let e1 = const_get_elt(cx, bv, &[0]);
|
||||
(load_const(cx, e1, bt), const_get_elt(cx, bv, &[1]))
|
||||
let e1 = const_get_elt(bv, &[0]);
|
||||
(load_const(cx, e1, bt), const_get_elt(bv, &[1]))
|
||||
},
|
||||
ty::TyRef(_, mt) => match mt.ty.sty {
|
||||
ty::TyArray(_, u) => {
|
||||
@ -725,7 +724,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
"const index-expr is out of bounds");
|
||||
C_undef(val_ty(arr).element_type())
|
||||
} else {
|
||||
const_get_elt(cx, arr, &[iv as c_uint])
|
||||
const_get_elt(arr, &[iv as c_uint])
|
||||
}
|
||||
},
|
||||
hir::ExprCast(ref base, _) => {
|
||||
@ -741,10 +740,10 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
let t_cast_inner =
|
||||
t_cast.builtin_deref(true, ty::NoPreference).expect("cast to non-pointer").ty;
|
||||
let ptr_ty = type_of::in_memory_type_of(cx, t_cast_inner).ptr_to();
|
||||
let addr = ptrcast(const_get_elt(cx, v, &[abi::FAT_PTR_ADDR as u32]),
|
||||
let addr = ptrcast(const_get_elt(v, &[abi::FAT_PTR_ADDR as u32]),
|
||||
ptr_ty);
|
||||
if type_is_fat_ptr(cx.tcx(), t_cast) {
|
||||
let info = const_get_elt(cx, v, &[abi::FAT_PTR_EXTRA as u32]);
|
||||
let info = const_get_elt(v, &[abi::FAT_PTR_EXTRA as u32]);
|
||||
return Ok(C_struct(cx, &[addr, info], false))
|
||||
} else {
|
||||
return Ok(addr);
|
||||
@ -756,7 +755,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
) {
|
||||
(CastTy::Int(IntTy::CEnum), CastTy::Int(_)) => {
|
||||
let repr = adt::represent_type(cx, t_expr);
|
||||
let discr = adt::const_get_discrim(cx, &repr, v);
|
||||
let discr = adt::const_get_discrim(&repr, v);
|
||||
let iv = C_integral(cx.int_type(), discr.0, false);
|
||||
let s = adt::is_discr_signed(&repr) as Bool;
|
||||
llvm::LLVMConstIntCast(iv, llty.to_ref(), s)
|
||||
|
@ -152,9 +152,8 @@ pub fn trans_if<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
els: Option<&hir::Expr>,
|
||||
dest: expr::Dest)
|
||||
-> Block<'blk, 'tcx> {
|
||||
debug!("trans_if(bcx={}, if_id={}, cond={:?}, thn={}, dest={})",
|
||||
bcx.to_str(), if_id, cond, thn.id,
|
||||
dest.to_string(bcx.ccx()));
|
||||
debug!("trans_if(bcx={}, if_id={}, cond={:?}, thn={}, dest={:?})",
|
||||
bcx.to_str(), if_id, cond, thn.id, dest);
|
||||
let _icx = push_ctxt("trans_if");
|
||||
|
||||
if bcx.unreachable.get() {
|
||||
|
@ -101,6 +101,7 @@ use trans::cleanup;
|
||||
use trans::cleanup::{CleanupMethods, DropHintDatum, DropHintMethods};
|
||||
use trans::expr;
|
||||
use trans::tvec;
|
||||
use trans::value::Value;
|
||||
use middle::ty::Ty;
|
||||
|
||||
use std::fmt;
|
||||
@ -111,7 +112,7 @@ use syntax::codemap::DUMMY_SP;
|
||||
/// describes where the value is stored, what Rust type the value has,
|
||||
/// whether it is addressed by reference, and so forth. Please refer
|
||||
/// the section on datums in `README.md` for more details.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct Datum<'tcx, K> {
|
||||
/// The llvm value. This is either a pointer to the Rust value or
|
||||
/// the value itself, depending on `kind` below.
|
||||
@ -124,6 +125,13 @@ pub struct Datum<'tcx, K> {
|
||||
pub kind: K,
|
||||
}
|
||||
|
||||
impl<'tcx, K: fmt::Debug> fmt::Debug for Datum<'tcx, K> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "Datum({:?}, {:?}, {:?})",
|
||||
Value(self.val), self.ty, self.kind)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DatumBlock<'blk, 'tcx: 'blk, K> {
|
||||
pub bcx: Block<'blk, 'tcx>,
|
||||
pub datum: Datum<'tcx, K>,
|
||||
@ -311,8 +319,8 @@ pub fn lvalue_scratch_datum<'blk, 'tcx, A, F>(bcx: Block<'blk, 'tcx>,
|
||||
// Very subtle: potentially initialize the scratch memory at point where it is alloca'ed.
|
||||
// (See discussion at Issue 30530.)
|
||||
let scratch = alloc_ty_init(bcx, ty, zero, name);
|
||||
debug!("lvalue_scratch_datum scope={:?} scratch={} ty={:?}",
|
||||
scope, bcx.ccx().tn().val_to_string(scratch), ty);
|
||||
debug!("lvalue_scratch_datum scope={:?} scratch={:?} ty={:?}",
|
||||
scope, Value(scratch), ty);
|
||||
|
||||
// Subtle. Populate the scratch memory *before* scheduling cleanup.
|
||||
let bcx = populate(arg, bcx, scratch);
|
||||
@ -351,8 +359,8 @@ fn add_rvalue_clean<'a, 'tcx>(mode: RvalueMode,
|
||||
scope: cleanup::ScopeId,
|
||||
val: ValueRef,
|
||||
ty: Ty<'tcx>) {
|
||||
debug!("add_rvalue_clean scope={:?} val={} ty={:?}",
|
||||
scope, fcx.ccx.tn().val_to_string(val), ty);
|
||||
debug!("add_rvalue_clean scope={:?} val={:?} ty={:?}",
|
||||
scope, Value(val), ty);
|
||||
match mode {
|
||||
ByValue => { fcx.schedule_drop_immediate(scope, val, ty); }
|
||||
ByRef => {
|
||||
@ -617,7 +625,7 @@ impl<'tcx> Datum<'tcx, Expr> {
|
||||
name: &str,
|
||||
expr_id: ast::NodeId)
|
||||
-> DatumBlock<'blk, 'tcx, Lvalue> {
|
||||
debug!("to_lvalue_datum self: {}", self.to_string(bcx.ccx()));
|
||||
debug!("to_lvalue_datum self: {:?}", self);
|
||||
|
||||
self.match_kind(
|
||||
|l| DatumBlock::new(bcx, l),
|
||||
@ -767,14 +775,6 @@ impl<'tcx, K: KindOps + fmt::Debug> Datum<'tcx, K> {
|
||||
self.shallow_copy_raw(bcx, dst)
|
||||
}
|
||||
|
||||
#[allow(dead_code)] // useful for debugging
|
||||
pub fn to_string<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> String {
|
||||
format!("Datum({}, {:?}, {:?})",
|
||||
ccx.tn().val_to_string(self.val),
|
||||
self.ty,
|
||||
self.kind)
|
||||
}
|
||||
|
||||
/// See the `appropriate_rvalue_mode()` function
|
||||
pub fn appropriate_rvalue_mode<'a>(&self, ccx: &CrateContext<'a, 'tcx>)
|
||||
-> RvalueMode {
|
||||
|
@ -129,7 +129,7 @@ pub fn declare_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str,
|
||||
let sig = infer::normalize_associated_type(ccx.tcx(), &sig);
|
||||
debug!("declare_rust_fn (after region erasure) sig={:?}", sig);
|
||||
let llfty = type_of::type_of_rust_fn(ccx, env, &sig, abi);
|
||||
debug!("declare_rust_fn llfty={}", ccx.tn().type_to_string(llfty));
|
||||
debug!("declare_rust_fn llfty={:?}", llfty);
|
||||
|
||||
// it is ok to directly access sig.0.output because we erased all
|
||||
// late-bound-regions above
|
||||
|
@ -69,6 +69,7 @@ use trans::glue;
|
||||
use trans::machine;
|
||||
use trans::tvec;
|
||||
use trans::type_of;
|
||||
use trans::value::Value;
|
||||
use trans::Disr;
|
||||
use middle::ty::adjustment::{AdjustDerefRef, AdjustReifyFnPointer};
|
||||
use middle::ty::adjustment::{AdjustUnsafeFnPointer, AdjustMutToConstPointer};
|
||||
@ -85,6 +86,7 @@ use rustc_front::hir;
|
||||
|
||||
use syntax::{ast, codemap};
|
||||
use syntax::parse::token::InternedString;
|
||||
use std::fmt;
|
||||
use std::mem;
|
||||
|
||||
// Destinations
|
||||
@ -98,11 +100,11 @@ pub enum Dest {
|
||||
Ignore,
|
||||
}
|
||||
|
||||
impl Dest {
|
||||
pub fn to_string(&self, ccx: &CrateContext) -> String {
|
||||
impl fmt::Debug for Dest {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
SaveIn(v) => format!("SaveIn({})", ccx.tn().val_to_string(v)),
|
||||
Ignore => "Ignore".to_string()
|
||||
SaveIn(v) => write!(f, "SaveIn({:?})", Value(v)),
|
||||
Ignore => f.write_str("Ignore")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -377,10 +379,8 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
}
|
||||
Some(adj) => { adj }
|
||||
};
|
||||
debug!("unadjusted datum for expr {:?}: {} adjustment={:?}",
|
||||
expr,
|
||||
datum.to_string(bcx.ccx()),
|
||||
adjustment);
|
||||
debug!("unadjusted datum for expr {:?}: {:?} adjustment={:?}",
|
||||
expr, datum, adjustment);
|
||||
match adjustment {
|
||||
AdjustReifyFnPointer => {
|
||||
match datum.ty.sty {
|
||||
@ -452,7 +452,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
}
|
||||
}
|
||||
}
|
||||
debug!("after adjustments, datum={}", datum.to_string(bcx.ccx()));
|
||||
debug!("after adjustments, datum={:?}", datum);
|
||||
DatumBlock::new(bcx, datum)
|
||||
}
|
||||
|
||||
@ -462,9 +462,7 @@ fn coerce_unsized<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
target: Datum<'tcx, Rvalue>)
|
||||
-> Block<'blk, 'tcx> {
|
||||
let mut bcx = bcx;
|
||||
debug!("coerce_unsized({} -> {})",
|
||||
source.to_string(bcx.ccx()),
|
||||
target.to_string(bcx.ccx()));
|
||||
debug!("coerce_unsized({:?} -> {:?})", source, target);
|
||||
|
||||
match (&source.ty.sty, &target.ty.sty) {
|
||||
(&ty::TyBox(a), &ty::TyBox(b)) |
|
||||
@ -854,8 +852,8 @@ fn trans_index<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
|
||||
let (base, len) = base_datum.get_vec_base_and_len(bcx);
|
||||
|
||||
debug!("trans_index: base {}", bcx.val_to_string(base));
|
||||
debug!("trans_index: len {}", bcx.val_to_string(len));
|
||||
debug!("trans_index: base {:?}", Value(base));
|
||||
debug!("trans_index: len {:?}", Value(len));
|
||||
|
||||
let bounds_check = ICmp(bcx,
|
||||
llvm::IntUGE,
|
||||
@ -1279,8 +1277,8 @@ pub fn trans_local_var<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
nid));
|
||||
}
|
||||
};
|
||||
debug!("take_local(nid={}, v={}, ty={})",
|
||||
nid, bcx.val_to_string(datum.val), datum.ty);
|
||||
debug!("take_local(nid={}, v={:?}, ty={})",
|
||||
nid, Value(datum.val), datum.ty);
|
||||
datum
|
||||
}
|
||||
_ => {
|
||||
@ -1829,12 +1827,10 @@ fn trans_binary<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
|
||||
let lhs = unpack_datum!(bcx, trans(bcx, lhs));
|
||||
let lhs = unpack_datum!(bcx, lhs.to_rvalue_datum(bcx, "binop_lhs"));
|
||||
debug!("trans_binary (expr {}): lhs={}",
|
||||
expr.id, lhs.to_string(ccx));
|
||||
debug!("trans_binary (expr {}): lhs={:?}", expr.id, lhs);
|
||||
let rhs = unpack_datum!(bcx, trans(bcx, rhs));
|
||||
let rhs = unpack_datum!(bcx, rhs.to_rvalue_datum(bcx, "binop_rhs"));
|
||||
debug!("trans_binary (expr {}): rhs={}",
|
||||
expr.id, rhs.to_string(ccx));
|
||||
debug!("trans_binary (expr {}): rhs={:?}", expr.id, rhs);
|
||||
|
||||
if type_is_fat_ptr(ccx.tcx(), lhs.ty) {
|
||||
assert!(type_is_fat_ptr(ccx.tcx(), rhs.ty),
|
||||
@ -2085,10 +2081,8 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
-> DatumBlock<'blk, 'tcx, Expr> {
|
||||
let ccx = bcx.ccx();
|
||||
|
||||
debug!("deref_once(expr={:?}, datum={}, method_call={:?})",
|
||||
expr,
|
||||
datum.to_string(ccx),
|
||||
method_call);
|
||||
debug!("deref_once(expr={:?}, datum={:?}, method_call={:?})",
|
||||
expr, datum, method_call);
|
||||
|
||||
let mut bcx = bcx;
|
||||
|
||||
@ -2175,8 +2169,8 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
}
|
||||
};
|
||||
|
||||
debug!("deref_once(expr={}, method_call={:?}, result={})",
|
||||
expr.id, method_call, r.datum.to_string(ccx));
|
||||
debug!("deref_once(expr={}, method_call={:?}, result={:?})",
|
||||
expr.id, method_call, r.datum);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ use trans::monomorphize;
|
||||
use trans::type_::Type;
|
||||
use trans::type_of::*;
|
||||
use trans::type_of;
|
||||
use trans::value::Value;
|
||||
use middle::infer;
|
||||
use middle::ty::{self, Ty, TyCtxt};
|
||||
use middle::subst::Substs;
|
||||
@ -254,12 +255,8 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
{
|
||||
let ccx = bcx.ccx();
|
||||
|
||||
debug!("trans_native_call(callee_ty={:?}, \
|
||||
llfn={}, \
|
||||
llretptr={})",
|
||||
callee_ty,
|
||||
ccx.tn().val_to_string(llfn),
|
||||
ccx.tn().val_to_string(llretptr));
|
||||
debug!("trans_native_call(callee_ty={:?}, llfn={:?}, llretptr={:?})",
|
||||
callee_ty, Value(llfn), Value(llretptr));
|
||||
|
||||
let (fn_abi, fn_sig) = match callee_ty.sty {
|
||||
ty::TyFnDef(_, _, ref fn_ty) |
|
||||
@ -306,11 +303,11 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
// Does Rust pass this argument by pointer?
|
||||
let rust_indirect = type_of::arg_is_indirect(ccx, passed_arg_tys[i]);
|
||||
|
||||
debug!("argument {}, llarg_rust={}, rust_indirect={}, arg_ty={}",
|
||||
debug!("argument {}, llarg_rust={:?}, rust_indirect={}, arg_ty={:?}",
|
||||
i,
|
||||
ccx.tn().val_to_string(llarg_rust),
|
||||
Value(llarg_rust),
|
||||
rust_indirect,
|
||||
ccx.tn().type_to_string(arg_ty.ty));
|
||||
arg_ty.ty);
|
||||
|
||||
// Ensure that we always have the Rust value indirectly,
|
||||
// because it makes bitcasting easier.
|
||||
@ -326,8 +323,8 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
llarg_rust = scratch;
|
||||
}
|
||||
|
||||
debug!("llarg_rust={} (after indirection)",
|
||||
ccx.tn().val_to_string(llarg_rust));
|
||||
debug!("llarg_rust={:?} (after indirection)",
|
||||
Value(llarg_rust));
|
||||
|
||||
// Check whether we need to do any casting
|
||||
match arg_ty.cast {
|
||||
@ -335,8 +332,8 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
None => ()
|
||||
}
|
||||
|
||||
debug!("llarg_rust={} (after casting)",
|
||||
ccx.tn().val_to_string(llarg_rust));
|
||||
debug!("llarg_rust={:?} (after casting)",
|
||||
Value(llarg_rust));
|
||||
|
||||
// Finally, load the value if needed for the foreign ABI
|
||||
let foreign_indirect = arg_ty.is_indirect();
|
||||
@ -351,8 +348,8 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
}
|
||||
};
|
||||
|
||||
debug!("argument {}, llarg_foreign={}",
|
||||
i, ccx.tn().val_to_string(llarg_foreign));
|
||||
debug!("argument {}, llarg_foreign={:?}",
|
||||
i, Value(llarg_foreign));
|
||||
|
||||
// fill padding with undef value
|
||||
match arg_ty.pad {
|
||||
@ -421,10 +418,10 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
None => fn_type.ret_ty.ty
|
||||
};
|
||||
|
||||
debug!("llretptr={}", ccx.tn().val_to_string(llretptr));
|
||||
debug!("llforeign_retval={}", ccx.tn().val_to_string(llforeign_retval));
|
||||
debug!("llrust_ret_ty={}", ccx.tn().type_to_string(llrust_ret_ty));
|
||||
debug!("llforeign_ret_ty={}", ccx.tn().type_to_string(llforeign_ret_ty));
|
||||
debug!("llretptr={:?}", Value(llretptr));
|
||||
debug!("llforeign_retval={:?}", Value(llforeign_retval));
|
||||
debug!("llrust_ret_ty={:?}", llrust_ret_ty);
|
||||
debug!("llforeign_ret_ty={:?}", llforeign_ret_ty);
|
||||
|
||||
if llrust_ret_ty == llforeign_ret_ty {
|
||||
match fn_sig.output {
|
||||
@ -562,8 +559,8 @@ pub fn decl_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
let llfn = declare::declare_fn(ccx, name, cconv, llfn_ty,
|
||||
ty::FnConverging(ccx.tcx().mk_nil()));
|
||||
add_argument_attributes(&tys, llfn);
|
||||
debug!("decl_rust_fn_with_foreign_abi(llfn_ty={}, llfn={})",
|
||||
ccx.tn().type_to_string(llfn_ty), ccx.tn().val_to_string(llfn));
|
||||
debug!("decl_rust_fn_with_foreign_abi(llfn_ty={:?}, llfn={:?})",
|
||||
llfn_ty, Value(llfn));
|
||||
llfn
|
||||
}
|
||||
|
||||
@ -585,8 +582,8 @@ pub fn register_rust_fn_with_foreign_abi(ccx: &CrateContext,
|
||||
let llfn_ty = lltype_for_fn_from_foreign_types(ccx, &tys);
|
||||
let llfn = base::register_fn_llvmty(ccx, sp, sym, node_id, cconv, llfn_ty);
|
||||
add_argument_attributes(&tys, llfn);
|
||||
debug!("register_rust_fn_with_foreign_abi(node_id={}, llfn_ty={}, llfn={})",
|
||||
node_id, ccx.tn().type_to_string(llfn_ty), ccx.tn().val_to_string(llfn));
|
||||
debug!("register_rust_fn_with_foreign_abi(node_id={}, llfn_ty={:?}, llfn={:?})",
|
||||
node_id, llfn_ty, Value(llfn));
|
||||
llfn
|
||||
}
|
||||
|
||||
@ -667,9 +664,9 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
let _icx = push_ctxt(
|
||||
"foreign::trans_rust_fn_with_foreign_abi::build_wrap_fn");
|
||||
|
||||
debug!("build_wrap_fn(llrustfn={}, llwrapfn={}, t={:?})",
|
||||
ccx.tn().val_to_string(llrustfn),
|
||||
ccx.tn().val_to_string(llwrapfn),
|
||||
debug!("build_wrap_fn(llrustfn={:?}, llwrapfn={:?}, t={:?})",
|
||||
Value(llrustfn),
|
||||
Value(llwrapfn),
|
||||
t);
|
||||
|
||||
// Avoid all the Rust generation stuff and just generate raw
|
||||
@ -737,12 +734,12 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
// alloca some scratch space on the stack.
|
||||
match foreign_outptr {
|
||||
Some(llforeign_outptr) => {
|
||||
debug!("out pointer, foreign={}",
|
||||
ccx.tn().val_to_string(llforeign_outptr));
|
||||
debug!("out pointer, foreign={:?}",
|
||||
Value(llforeign_outptr));
|
||||
let llrust_retptr =
|
||||
builder.bitcast(llforeign_outptr, llrust_ret_ty.ptr_to());
|
||||
debug!("out pointer, foreign={} (casted)",
|
||||
ccx.tn().val_to_string(llrust_retptr));
|
||||
debug!("out pointer, foreign={:?} (casted)",
|
||||
Value(llrust_retptr));
|
||||
llrust_args.push(llrust_retptr);
|
||||
return_alloca = None;
|
||||
}
|
||||
@ -750,11 +747,11 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
None => {
|
||||
let slot = builder.alloca(llrust_ret_ty, "return_alloca");
|
||||
debug!("out pointer, \
|
||||
allocad={}, \
|
||||
llrust_ret_ty={}, \
|
||||
allocad={:?}, \
|
||||
llrust_ret_ty={:?}, \
|
||||
return_ty={:?}",
|
||||
ccx.tn().val_to_string(slot),
|
||||
ccx.tn().type_to_string(llrust_ret_ty),
|
||||
Value(slot),
|
||||
llrust_ret_ty,
|
||||
tys.fn_sig.output);
|
||||
llrust_args.push(slot);
|
||||
return_alloca = Some(slot);
|
||||
@ -792,8 +789,8 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
let foreign_index = next_foreign_arg(llforeign_arg_ty.pad.is_some());
|
||||
let mut llforeign_arg = get_param(llwrapfn, foreign_index);
|
||||
|
||||
debug!("llforeign_arg {}{}: {}", "#",
|
||||
i, ccx.tn().val_to_string(llforeign_arg));
|
||||
debug!("llforeign_arg {}{}: {:?}", "#",
|
||||
i, Value(llforeign_arg));
|
||||
debug!("rust_indirect = {}, foreign_indirect = {}",
|
||||
rust_indirect, foreign_indirect);
|
||||
|
||||
@ -840,8 +837,8 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
}
|
||||
};
|
||||
|
||||
debug!("llrust_arg {}{}: {}", "#",
|
||||
i, ccx.tn().val_to_string(llrust_arg));
|
||||
debug!("llrust_arg {}{}: {:?}", "#",
|
||||
i, Value(llrust_arg));
|
||||
if type_is_fat_ptr(ccx.tcx(), rust_ty) {
|
||||
let next_llrust_ty = rust_param_tys.next().expect("Not enough parameter types!");
|
||||
llrust_args.push(builder.load(builder.bitcast(builder.struct_gep(
|
||||
@ -854,8 +851,8 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
}
|
||||
|
||||
// Perform the call itself
|
||||
debug!("calling llrustfn = {}, t = {:?}",
|
||||
ccx.tn().val_to_string(llrustfn), t);
|
||||
debug!("calling llrustfn = {:?}, t = {:?}",
|
||||
Value(llrustfn), t);
|
||||
let attributes = attributes::from_fn_type(ccx, t);
|
||||
let llrust_ret_val = builder.call(llrustfn, &llrust_args,
|
||||
None, Some(attributes));
|
||||
@ -971,14 +968,14 @@ fn foreign_types_for_fn_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
llsig.ret_def);
|
||||
debug!("foreign_types_for_fn_ty(\
|
||||
ty={:?}, \
|
||||
llsig={} -> {}, \
|
||||
fn_ty={} -> {}, \
|
||||
llsig={:?} -> {:?}, \
|
||||
fn_ty={:?} -> {:?}, \
|
||||
ret_def={}",
|
||||
ty,
|
||||
ccx.tn().types_to_str(&llsig.llarg_tys),
|
||||
ccx.tn().type_to_string(llsig.llret_ty),
|
||||
ccx.tn().types_to_str(&fn_ty.arg_tys.iter().map(|t| t.ty).collect::<Vec<_>>()),
|
||||
ccx.tn().type_to_string(fn_ty.ret_ty.ty),
|
||||
llsig.llarg_tys,
|
||||
llsig.llret_ty,
|
||||
fn_ty.arg_tys,
|
||||
fn_ty.ret_ty,
|
||||
llsig.ret_def);
|
||||
|
||||
ForeignTypes {
|
||||
|
@ -37,6 +37,7 @@ use trans::machine::*;
|
||||
use trans::monomorphize;
|
||||
use trans::type_of::{type_of, sizing_type_of, align_of};
|
||||
use trans::type_::Type;
|
||||
use trans::value::Value;
|
||||
|
||||
use arena::TypedArena;
|
||||
use libc::c_uint;
|
||||
@ -374,14 +375,14 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
|
||||
pub fn size_and_align_of_dst<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>, info: ValueRef)
|
||||
-> (ValueRef, ValueRef) {
|
||||
debug!("calculate size of DST: {}; with lost info: {}",
|
||||
t, bcx.val_to_string(info));
|
||||
debug!("calculate size of DST: {}; with lost info: {:?}",
|
||||
t, Value(info));
|
||||
if type_is_sized(bcx.tcx(), t) {
|
||||
let sizing_type = sizing_type_of(bcx.ccx(), t);
|
||||
let size = llsize_of_alloc(bcx.ccx(), sizing_type);
|
||||
let align = align_of(bcx.ccx(), t);
|
||||
debug!("size_and_align_of_dst t={} info={} size: {} align: {}",
|
||||
t, bcx.val_to_string(info), size, align);
|
||||
debug!("size_and_align_of_dst t={} info={:?} size: {} align: {}",
|
||||
t, Value(info), size, align);
|
||||
let size = C_uint(bcx.ccx(), size);
|
||||
let align = C_uint(bcx.ccx(), align);
|
||||
return (size, align);
|
||||
@ -394,7 +395,7 @@ pub fn size_and_align_of_dst<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>, in
|
||||
assert!(!t.is_simd());
|
||||
let repr = adt::represent_type(ccx, t);
|
||||
let sizing_type = adt::sizing_type_context_of(ccx, &repr, true);
|
||||
debug!("DST {} sizing_type: {}", t, sizing_type.to_string());
|
||||
debug!("DST {} sizing_type: {:?}", t, sizing_type);
|
||||
let sized_size = llsize_of_alloc(ccx, sizing_type.prefix());
|
||||
let sized_align = llalign_of_min(ccx, sizing_type.prefix());
|
||||
debug!("DST {} statically sized prefix size: {} align: {}",
|
||||
|
@ -1552,7 +1552,7 @@ fn generic_simd_intrinsic<'blk, 'tcx, 'a>
|
||||
let indices: Option<Vec<_>> = (0..n)
|
||||
.map(|i| {
|
||||
let arg_idx = i;
|
||||
let val = const_get_elt(bcx.ccx(), vector, &[i as libc::c_uint]);
|
||||
let val = const_get_elt(vector, &[i as libc::c_uint]);
|
||||
let c = const_to_opt_uint(val);
|
||||
match c {
|
||||
None => {
|
||||
|
@ -1,36 +0,0 @@
|
||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use trans::context::CrateContext;
|
||||
use trans::type_::Type;
|
||||
use llvm::ValueRef;
|
||||
|
||||
pub trait LlvmRepr {
|
||||
fn llrepr(&self, ccx: &CrateContext) -> String;
|
||||
}
|
||||
|
||||
impl<T:LlvmRepr> LlvmRepr for [T] {
|
||||
fn llrepr(&self, ccx: &CrateContext) -> String {
|
||||
let reprs: Vec<String> = self.iter().map(|t| t.llrepr(ccx)).collect();
|
||||
format!("[{}]", reprs.join(","))
|
||||
}
|
||||
}
|
||||
|
||||
impl LlvmRepr for Type {
|
||||
fn llrepr(&self, ccx: &CrateContext) -> String {
|
||||
ccx.tn().type_to_string(*self)
|
||||
}
|
||||
}
|
||||
|
||||
impl LlvmRepr for ValueRef {
|
||||
fn llrepr(&self, ccx: &CrateContext) -> String {
|
||||
ccx.tn().val_to_string(*self)
|
||||
}
|
||||
}
|
@ -33,6 +33,7 @@ use trans::glue;
|
||||
use trans::machine;
|
||||
use trans::type_::Type;
|
||||
use trans::type_of::*;
|
||||
use trans::value::Value;
|
||||
use middle::ty::{self, Ty, TyCtxt, TypeFoldable};
|
||||
|
||||
use syntax::ast::{self, Name};
|
||||
@ -171,10 +172,8 @@ pub fn get_virtual_method<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
let ccx = bcx.ccx();
|
||||
|
||||
// Load the data pointer from the object.
|
||||
debug!("get_virtual_method(callee_ty={}, vtable_index={}, llvtable={})",
|
||||
method_ty,
|
||||
vtable_index,
|
||||
bcx.val_to_string(llvtable));
|
||||
debug!("get_virtual_method(callee_ty={}, vtable_index={}, llvtable={:?})",
|
||||
method_ty, vtable_index, Value(llvtable));
|
||||
|
||||
let mptr = Load(bcx, GEPi(bcx, llvtable, &[vtable_index + VTABLE_OFFSET]));
|
||||
|
||||
@ -250,8 +249,8 @@ pub fn trans_object_shim<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>,
|
||||
let llself = llargs[self_idx];
|
||||
let llvtable = llargs[self_idx + 1];
|
||||
|
||||
debug!("trans_object_shim: llself={}, llvtable={}",
|
||||
bcx.val_to_string(llself), bcx.val_to_string(llvtable));
|
||||
debug!("trans_object_shim: llself={:?}, llvtable={:?}",
|
||||
Value(llself), Value(llvtable));
|
||||
|
||||
assert!(!fcx.needs_ret_allocas);
|
||||
|
||||
|
@ -38,8 +38,8 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
let val = if common::type_is_immediate(ccx, ty) {
|
||||
OperandValue::Immediate(val)
|
||||
} else if common::type_is_fat_ptr(bcx.tcx(), ty) {
|
||||
let data = common::const_get_elt(ccx, val, &[abi::FAT_PTR_ADDR as u32]);
|
||||
let extra = common::const_get_elt(ccx, val, &[abi::FAT_PTR_EXTRA as u32]);
|
||||
let data = common::const_get_elt(val, &[abi::FAT_PTR_ADDR as u32]);
|
||||
let extra = common::const_get_elt(val, &[abi::FAT_PTR_EXTRA as u32]);
|
||||
OperandValue::FatPtr(data, extra)
|
||||
} else {
|
||||
OperandValue::Ref(val)
|
||||
|
@ -15,9 +15,12 @@ use trans::adt;
|
||||
use trans::base;
|
||||
use trans::common::{self, Block, BlockAndBuilder};
|
||||
use trans::datum;
|
||||
use trans::value::Value;
|
||||
use trans::Disr;
|
||||
use trans::glue;
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use super::{MirContext, TempRef, drop};
|
||||
use super::lvalue::LvalueRef;
|
||||
|
||||
@ -53,6 +56,25 @@ pub struct OperandRef<'tcx> {
|
||||
pub ty: Ty<'tcx>
|
||||
}
|
||||
|
||||
impl<'tcx> fmt::Debug for OperandRef<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self.val {
|
||||
OperandValue::Ref(r) => {
|
||||
write!(f, "OperandRef(Ref({:?}) @ {:?})",
|
||||
Value(r), self.ty)
|
||||
}
|
||||
OperandValue::Immediate(i) => {
|
||||
write!(f, "OperandRef(Immediate({:?}) @ {:?})",
|
||||
Value(i), self.ty)
|
||||
}
|
||||
OperandValue::FatPtr(a, d) => {
|
||||
write!(f, "OperandRef(FatPtr({:?}, {:?}) @ {:?})",
|
||||
Value(a), Value(d), self.ty)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> OperandRef<'tcx> {
|
||||
/// Asserts that this operand refers to a scalar and returns
|
||||
/// a reference to its value.
|
||||
@ -63,25 +85,6 @@ impl<'tcx> OperandRef<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn repr<'bcx>(self, bcx: &BlockAndBuilder<'bcx, 'tcx>) -> String {
|
||||
match self.val {
|
||||
OperandValue::Ref(r) => {
|
||||
format!("OperandRef(Ref({}) @ {:?})",
|
||||
bcx.val_to_string(r), self.ty)
|
||||
}
|
||||
OperandValue::Immediate(i) => {
|
||||
format!("OperandRef(Immediate({}) @ {:?})",
|
||||
bcx.val_to_string(i), self.ty)
|
||||
}
|
||||
OperandValue::FatPtr(a, d) => {
|
||||
format!("OperandRef(FatPtr({}, {}) @ {:?})",
|
||||
bcx.val_to_string(a),
|
||||
bcx.val_to_string(d),
|
||||
self.ty)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_rvalue_datum(datum: datum::Datum<'tcx, datum::Rvalue>) -> OperandRef {
|
||||
OperandRef {
|
||||
ty: datum.ty,
|
||||
@ -100,7 +103,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
ty: Ty<'tcx>)
|
||||
-> OperandRef<'tcx>
|
||||
{
|
||||
debug!("trans_load: {} @ {:?}", bcx.val_to_string(llval), ty);
|
||||
debug!("trans_load: {:?} @ {:?}", Value(llval), ty);
|
||||
|
||||
let val = match datum::appropriate_rvalue_mode(bcx.ccx(), ty) {
|
||||
datum::ByValue => {
|
||||
@ -164,7 +167,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
lldest: ValueRef,
|
||||
operand: OperandRef<'tcx>)
|
||||
{
|
||||
debug!("store_operand: operand={}", operand.repr(bcx));
|
||||
debug!("store_operand: operand={:?}", operand);
|
||||
bcx.with_block(|bcx| self.store_operand_direct(bcx, lldest, operand))
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ use trans::machine;
|
||||
use trans::type_::Type;
|
||||
use trans::type_of;
|
||||
use trans::tvec;
|
||||
use trans::value::Value;
|
||||
use trans::Disr;
|
||||
|
||||
use super::MirContext;
|
||||
@ -40,9 +41,8 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
rvalue: &mir::Rvalue<'tcx>)
|
||||
-> BlockAndBuilder<'bcx, 'tcx>
|
||||
{
|
||||
debug!("trans_rvalue(dest.llval={}, rvalue={:?})",
|
||||
bcx.val_to_string(dest.llval),
|
||||
rvalue);
|
||||
debug!("trans_rvalue(dest.llval={:?}, rvalue={:?})",
|
||||
Value(dest.llval), rvalue);
|
||||
|
||||
match *rvalue {
|
||||
mir::Rvalue::Use(ref operand) => {
|
||||
@ -193,7 +193,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
match *rvalue {
|
||||
mir::Rvalue::Cast(ref kind, ref operand, cast_ty) => {
|
||||
let operand = self.trans_operand(&bcx, operand);
|
||||
debug!("cast operand is {}", operand.repr(&bcx));
|
||||
debug!("cast operand is {:?}", operand);
|
||||
let cast_ty = bcx.monomorphize(&cast_ty);
|
||||
|
||||
let val = match *kind {
|
||||
@ -237,8 +237,8 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
}
|
||||
OperandValue::Ref(_) => {
|
||||
bcx.sess().bug(
|
||||
&format!("by-ref operand {} in trans_rvalue_operand",
|
||||
operand.repr(&bcx)));
|
||||
&format!("by-ref operand {:?} in trans_rvalue_operand",
|
||||
operand));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,6 @@ mod foreign;
|
||||
mod glue;
|
||||
mod inline;
|
||||
mod intrinsic;
|
||||
mod llrepr;
|
||||
mod machine;
|
||||
mod _match;
|
||||
mod meth;
|
||||
|
@ -26,6 +26,7 @@ use trans::expr;
|
||||
use trans::machine::llsize_of_alloc;
|
||||
use trans::type_::Type;
|
||||
use trans::type_of;
|
||||
use trans::value::Value;
|
||||
use middle::ty::{self, Ty};
|
||||
|
||||
use rustc_front::hir;
|
||||
@ -33,20 +34,12 @@ use rustc_front::hir;
|
||||
use syntax::ast;
|
||||
use syntax::parse::token::InternedString;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
struct VecTypes<'tcx> {
|
||||
unit_ty: Ty<'tcx>,
|
||||
llunit_ty: Type
|
||||
}
|
||||
|
||||
impl<'tcx> VecTypes<'tcx> {
|
||||
pub fn to_string<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> String {
|
||||
format!("VecTypes {{unit_ty={}, llunit_ty={}}}",
|
||||
self.unit_ty,
|
||||
ccx.tn().type_to_string(self.llunit_ty))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn trans_fixed_vstore<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
expr: &hir::Expr,
|
||||
dest: expr::Dest)
|
||||
@ -58,8 +51,7 @@ pub fn trans_fixed_vstore<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
// to store the array of the suitable size, so all we have to do is
|
||||
// generate the content.
|
||||
|
||||
debug!("trans_fixed_vstore(expr={:?}, dest={})",
|
||||
expr, dest.to_string(bcx.ccx()));
|
||||
debug!("trans_fixed_vstore(expr={:?}, dest={:?})", expr, dest);
|
||||
|
||||
let vt = vec_types_from_expr(bcx, expr);
|
||||
|
||||
@ -82,7 +74,6 @@ pub fn trans_slice_vec<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
content_expr: &hir::Expr)
|
||||
-> DatumBlock<'blk, 'tcx, Expr> {
|
||||
let fcx = bcx.fcx;
|
||||
let ccx = fcx.ccx;
|
||||
let mut bcx = bcx;
|
||||
|
||||
debug!("trans_slice_vec(slice_expr={:?})",
|
||||
@ -105,7 +96,7 @@ pub fn trans_slice_vec<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
// Handle the &[...] case:
|
||||
let vt = vec_types_from_expr(bcx, content_expr);
|
||||
let count = elements_required(bcx, content_expr);
|
||||
debug!(" vt={}, count={}", vt.to_string(ccx), count);
|
||||
debug!(" vt={:?}, count={}", vt, count);
|
||||
|
||||
let fixed_ty = bcx.tcx().mk_array(vt.unit_ty, count);
|
||||
|
||||
@ -144,9 +135,7 @@ pub fn trans_lit_str<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
str_lit: InternedString,
|
||||
dest: Dest)
|
||||
-> Block<'blk, 'tcx> {
|
||||
debug!("trans_lit_str(lit_expr={:?}, dest={})",
|
||||
lit_expr,
|
||||
dest.to_string(bcx.ccx()));
|
||||
debug!("trans_lit_str(lit_expr={:?}, dest={:?})", lit_expr, dest);
|
||||
|
||||
match dest {
|
||||
Ignore => bcx,
|
||||
@ -172,10 +161,8 @@ fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
let fcx = bcx.fcx;
|
||||
let mut bcx = bcx;
|
||||
|
||||
debug!("write_content(vt={}, dest={}, vstore_expr={:?})",
|
||||
vt.to_string(bcx.ccx()),
|
||||
dest.to_string(bcx.ccx()),
|
||||
vstore_expr);
|
||||
debug!("write_content(vt={:?}, dest={:?}, vstore_expr={:?})",
|
||||
vt, dest, vstore_expr);
|
||||
|
||||
match content_expr.node {
|
||||
hir::ExprLit(ref lit) => {
|
||||
@ -214,8 +201,8 @@ fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
let temp_scope = fcx.push_custom_cleanup_scope();
|
||||
for (i, element) in elements.iter().enumerate() {
|
||||
let lleltptr = GEPi(bcx, lldest, &[i]);
|
||||
debug!("writing index {} with lleltptr={}",
|
||||
i, bcx.val_to_string(lleltptr));
|
||||
debug!("writing index {} with lleltptr={:?}",
|
||||
i, Value(lleltptr));
|
||||
bcx = expr::trans_into(bcx, &element,
|
||||
SaveIn(lleltptr));
|
||||
let scope = cleanup::CustomScope(temp_scope);
|
||||
|
@ -11,7 +11,7 @@
|
||||
#![allow(non_upper_case_globals)]
|
||||
|
||||
use llvm;
|
||||
use llvm::{TypeRef, Bool, False, True, TypeKind, ValueRef};
|
||||
use llvm::{TypeRef, Bool, False, True, TypeKind};
|
||||
use llvm::{Float, Double, X86_FP80, PPC_FP128, FP128};
|
||||
|
||||
use trans::context::CrateContext;
|
||||
@ -20,18 +20,27 @@ use util::nodemap::FnvHashMap;
|
||||
use syntax::ast;
|
||||
|
||||
use std::ffi::CString;
|
||||
use std::fmt;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
use std::cell::RefCell;
|
||||
|
||||
use libc::c_uint;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
#[repr(C)]
|
||||
pub struct Type {
|
||||
rf: TypeRef
|
||||
}
|
||||
|
||||
impl fmt::Debug for Type {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.write_str(&llvm::build_string(|s| unsafe {
|
||||
llvm::LLVMWriteTypeToString(self.to_ref(), s);
|
||||
}).expect("non-UTF8 type description from LLVM"))
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! ty {
|
||||
($e:expr) => ( Type::from_ref(unsafe { $e }))
|
||||
}
|
||||
@ -50,12 +59,6 @@ impl Type {
|
||||
self.rf
|
||||
}
|
||||
|
||||
pub fn to_string(self: Type) -> String {
|
||||
llvm::build_string(|s| unsafe {
|
||||
llvm::LLVMWriteTypeToString(self.to_ref(), s);
|
||||
}).expect("non-UTF8 type description from LLVM")
|
||||
}
|
||||
|
||||
pub fn to_ref_slice(slice: &[Type]) -> &[TypeRef] {
|
||||
unsafe { mem::transmute(slice) }
|
||||
}
|
||||
@ -301,7 +304,6 @@ impl Type {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Memory-managed object interface to type handles. */
|
||||
|
||||
pub struct TypeNames {
|
||||
@ -323,19 +325,4 @@ impl TypeNames {
|
||||
pub fn find_type(&self, s: &str) -> Option<Type> {
|
||||
self.named_types.borrow().get(s).map(|x| Type::from_ref(*x))
|
||||
}
|
||||
|
||||
pub fn type_to_string(&self, ty: Type) -> String {
|
||||
ty.to_string()
|
||||
}
|
||||
|
||||
pub fn types_to_str(&self, tys: &[Type]) -> String {
|
||||
let strs: Vec<String> = tys.iter().map(|t| self.type_to_string(*t)).collect();
|
||||
format!("[{}]", strs.join(","))
|
||||
}
|
||||
|
||||
pub fn val_to_string(&self, val: ValueRef) -> String {
|
||||
llvm::build_string(|s| unsafe {
|
||||
llvm::LLVMWriteValueToString(val, s);
|
||||
}).expect("nun-UTF8 value description from LLVM")
|
||||
}
|
||||
}
|
||||
|
@ -234,9 +234,7 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
|
||||
ty::TySlice(_) | ty::TyTrait(..) | ty::TyStr => unreachable!()
|
||||
};
|
||||
|
||||
debug!("--> mapped t={:?} to llsizingty={}",
|
||||
t,
|
||||
cx.tn().type_to_string(llsizingty));
|
||||
debug!("--> mapped t={:?} to llsizingty={:?}", t, llsizingty);
|
||||
|
||||
cx.llsizingtypes().borrow_mut().insert(t, llsizingty);
|
||||
llsizingty
|
||||
@ -314,12 +312,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
|
||||
|
||||
if t != t_norm {
|
||||
let llty = in_memory_type_of(cx, t_norm);
|
||||
debug!("--> normalized {:?} {:?} to {:?} {:?} llty={}",
|
||||
t,
|
||||
t,
|
||||
t_norm,
|
||||
t_norm,
|
||||
cx.tn().type_to_string(llty));
|
||||
debug!("--> normalized {:?} to {:?} llty={:?}", t, t_norm, llty);
|
||||
cx.lltypes().borrow_mut().insert(t, llty);
|
||||
return llty;
|
||||
}
|
||||
@ -440,9 +433,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
|
||||
ty::TyError => cx.sess().bug("type_of with TyError"),
|
||||
};
|
||||
|
||||
debug!("--> mapped t={:?} to llty={}",
|
||||
t,
|
||||
cx.tn().type_to_string(llty));
|
||||
debug!("--> mapped t={:?} to llty={:?}", t, llty);
|
||||
|
||||
cx.lltypes().borrow_mut().insert(t, llty);
|
||||
|
||||
|
@ -12,11 +12,22 @@ use llvm;
|
||||
use llvm::{UseRef, ValueRef};
|
||||
use trans::basic_block::BasicBlock;
|
||||
use trans::common::Block;
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use libc::c_uint;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
pub struct Value(pub ValueRef);
|
||||
|
||||
impl fmt::Debug for Value {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.write_str(&llvm::build_string(|s| unsafe {
|
||||
llvm::LLVMWriteValueToString(self.0, s);
|
||||
}).expect("nun-UTF8 value description from LLVM"))
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! opt_val { ($e:expr) => (
|
||||
unsafe {
|
||||
match $e {
|
||||
|
Loading…
x
Reference in New Issue
Block a user