use base;
use callee::Callee;
use common::{self, val_ty, C_bool, C_null, C_uint, BlockAndBuilder, Result};
-use datum::{Datum, Lvalue};
use debuginfo::DebugLoc;
use adt;
use machine;
let size = C_uint(bcx.ccx(), size);
let base = get_dataptr(&bcx, dest.llval);
let bcx = bcx.map_block(|block| {
- tvec::iter_vec_raw(block, base, tr_elem.ty, size, |block, llslot, _| {
+ tvec::slice_for_each(block, base, tr_elem.ty, size, |block, llslot| {
self.store_operand_direct(block, llslot, tr_elem);
block
})
mir::Rvalue::InlineAsm { ref asm, ref outputs, ref inputs } => {
let outputs = outputs.iter().map(|output| {
let lvalue = self.trans_lvalue(&bcx, output);
- Datum::new(lvalue.llval, lvalue.ty.to_ty(bcx.tcx()),
- Lvalue::new("out"))
+ (lvalue.llval, lvalue.ty.to_ty(bcx.tcx()))
}).collect();
let input_vals = inputs.iter().map(|input| {
ty::TyFnDef(def_id, substs, _) => {
OperandValue::Immediate(
Callee::def(bcx.ccx(), def_id, substs)
- .reify(bcx.ccx()).val)
+ .reify(bcx.ccx()))
}
_ => {
bug!("{} cannot be reified to a fn ptr", operand.ty)
}
}
}
- mir::CastKind::Misc if common::type_is_immediate(bcx.ccx(), operand.ty) => {
+ mir::CastKind::Misc if common::type_is_fat_ptr(bcx.tcx(), operand.ty) => {
+ let ll_cast_ty = type_of::immediate_type_of(bcx.ccx(), cast_ty);
+ let ll_from_ty = type_of::immediate_type_of(bcx.ccx(), operand.ty);
+ if let OperandValue::Pair(data_ptr, meta_ptr) = operand.val {
+ if common::type_is_fat_ptr(bcx.tcx(), cast_ty) {
+ let ll_cft = ll_cast_ty.field_types();
+ let ll_fft = ll_from_ty.field_types();
+ let data_cast = bcx.pointercast(data_ptr, ll_cft[0]);
+ assert_eq!(ll_cft[1].kind(), ll_fft[1].kind());
+ OperandValue::Pair(data_cast, meta_ptr)
+ } else { // cast to thin-ptr
+ // Cast of fat-ptr to thin-ptr is an extraction of data-ptr and
+ // pointer-cast of that pointer to desired pointer type.
+ let llval = bcx.pointercast(data_ptr, ll_cast_ty);
+ OperandValue::Immediate(llval)
+ }
+ } else {
+ bug!("Unexpected non-Pair operand")
+ }
+ }
+ mir::CastKind::Misc => {
debug_assert!(common::type_is_immediate(bcx.ccx(), cast_ty));
let r_t_in = CastTy::from_ty(operand.ty).expect("bad input type for cast");
let r_t_out = CastTy::from_ty(cast_ty).expect("bad output type for cast");
let ll_t_in = type_of::immediate_type_of(bcx.ccx(), operand.ty);
let ll_t_out = type_of::immediate_type_of(bcx.ccx(), cast_ty);
- let llval = operand.immediate();
- let signed = if let CastTy::Int(IntTy::CEnum) = r_t_in {
+ let (llval, signed) = if let CastTy::Int(IntTy::CEnum) = r_t_in {
let repr = adt::represent_type(bcx.ccx(), operand.ty);
- adt::is_discr_signed(&repr)
+ let discr = match operand.val {
+ OperandValue::Immediate(llval) => llval,
+ OperandValue::Ref(llptr) => {
+ bcx.with_block(|bcx| {
+ adt::trans_get_discr(bcx, &repr, llptr, None, true)
+ })
+ }
+ OperandValue::Pair(..) => bug!("Unexpected Pair operand")
+ };
+ (discr, adt::is_discr_signed(&repr))
} else {
- operand.ty.is_signed()
+ (operand.immediate(), operand.ty.is_signed())
};
let newval = match (r_t_in, r_t_out) {
};
OperandValue::Immediate(newval)
}
- mir::CastKind::Misc => { // Casts from a fat-ptr.
- let ll_cast_ty = type_of::immediate_type_of(bcx.ccx(), cast_ty);
- let ll_from_ty = type_of::immediate_type_of(bcx.ccx(), operand.ty);
- if let OperandValue::Pair(data_ptr, meta_ptr) = operand.val {
- if common::type_is_fat_ptr(bcx.tcx(), cast_ty) {
- let ll_cft = ll_cast_ty.field_types();
- let ll_fft = ll_from_ty.field_types();
- let data_cast = bcx.pointercast(data_ptr, ll_cft[0]);
- assert_eq!(ll_cft[1].kind(), ll_fft[1].kind());
- OperandValue::Pair(data_cast, meta_ptr)
- } else { // cast to thin-ptr
- // Cast of fat-ptr to thin-ptr is an extraction of data-ptr and
- // pointer-cast of that pointer to desired pointer type.
- let llval = bcx.pointercast(data_ptr, ll_cast_ty);
- OperandValue::Immediate(llval)
- }
- } else {
- bug!("Unexpected non-Pair operand")
- }
- }
};
let operand = OperandRef {
val: val,
};
let operand = OperandRef {
val: OperandValue::Immediate(llresult),
- ty: self.mir.binop_ty(bcx.tcx(), op, lhs.ty, rhs.ty),
+ ty: op.ty(bcx.tcx(), lhs.ty, rhs.ty),
};
(bcx, operand)
}
let result = self.trans_scalar_checked_binop(&bcx, op,
lhs.immediate(), rhs.immediate(),
lhs.ty);
- let val_ty = self.mir.binop_ty(bcx.tcx(), op, lhs.ty, rhs.ty);
+ let val_ty = op.ty(bcx.tcx(), lhs.ty, rhs.ty);
let operand_ty = bcx.tcx().mk_tup(vec![val_ty, bcx.tcx().types.bool]);
let operand = OperandRef {
val: result,