}
let cx = bx.cx;
if self.is_sized_indirect() {
- OperandValue::Ref(val, self.layout.align).store(bx, dst)
+ OperandValue::Ref(val, None, self.layout.align).store(bx, dst)
} else if self.is_unsized_indirect() {
bug!("unsized ArgType must be handled through store_fn_arg");
} else if let PassMode::Cast(cast) = self.mode {
OperandValue::Pair(next(), next()).store(bx, dst);
}
PassMode::Indirect(_, Some(_)) => {
- OperandValue::UnsizedRef(next(), next()).store(bx, dst);
+ OperandValue::Ref(next(), Some(next()), self.layout.align).store(bx, dst);
}
PassMode::Direct(_) | PassMode::Indirect(_, None) | PassMode::Cast(_) => {
self.store(bx, next(), dst);
OperandValue::Immediate(base) => {
unsize_thin_ptr(bx, base, src_ty, dst_ty)
}
- OperandValue::Ref(..) | OperandValue::UnsizedRef(..) => bug!()
+ OperandValue::Ref(..) => bug!()
};
OperandValue::Pair(base, info).store(bx, dst);
};
// etc.
assert!(!bx.cx.type_needs_drop(arg.layout.ty));
let (ptr, align) = match arg.val {
- OperandValue::Ref(ptr, align) => (ptr, align),
+ OperandValue::Ref(ptr, None, align) => (ptr, align),
_ => bug!()
};
let arg = PlaceRef::new_sized(ptr, arg.layout, align);
use super::{FunctionCx, LocalRef};
use super::place::PlaceRef;
use super::operand::OperandRef;
-use super::operand::OperandValue::{Pair, Ref, UnsizedRef, Immediate};
+use super::operand::OperandValue::{Pair, Ref, Immediate};
impl FunctionCx<'a, 'll, 'tcx> {
pub fn codegen_block(&mut self, bb: mir::BasicBlock) {
PassMode::Direct(_) | PassMode::Pair(..) => {
let op = self.codegen_consume(&bx, &mir::Place::Local(mir::RETURN_PLACE));
- if let Ref(llval, align) = op.val {
+ if let Ref(llval, _, align) = op.val {
bx.load(llval, align)
- } else if let UnsizedRef(..) = op.val {
- bug!("return type must be sized");
} else {
op.immediate_or_packed_pair(&bx)
}
LocalRef::Operand(None) => bug!("use of return before def"),
LocalRef::Place(cg_place) => {
OperandRef {
- val: Ref(cg_place.llval, cg_place.align),
+ val: Ref(cg_place.llval, None, cg_place.align),
layout: cg_place.layout
}
}
op.val.store(&bx, scratch);
scratch.llval
}
- Ref(llval, align) => {
+ Ref(llval, _, align) => {
assert_eq!(align.abi(), op.layout.align.abi(),
"return place is unaligned!");
llval
}
- UnsizedRef(..) => bug!("return type must be sized"),
};
bx.load(
bx.pointercast(llslot, cast_ty.llvm_type(bx.cx).ptr_to()),
// The callee needs to own the argument memory if we pass it
// by-ref, so make a local copy of non-immediate constants.
match (arg, op.val) {
- (&mir::Operand::Copy(_), Ref(..)) |
- (&mir::Operand::Constant(_), Ref(..)) => {
+ (&mir::Operand::Copy(_), Ref(_, None, _)) |
+ (&mir::Operand::Constant(_), Ref(_, None, _)) => {
let tmp = PlaceRef::alloca(&bx, op.layout, "const");
op.val.store(&bx, tmp);
- op.val = Ref(tmp.llval, tmp.align);
- }
- (&mir::Operand::Copy(_), UnsizedRef(..)) |
- (&mir::Operand::Constant(_), UnsizedRef(..)) => {
- bug!("tried to pass an unsized argument by copy or constant")
+ op.val = Ref(tmp.llval, None, tmp.align);
}
_ => {}
}
}
} else if arg.is_unsized_indirect() {
match op.val {
- UnsizedRef(a, b) => {
+ Ref(a, Some(b), _) => {
llargs.push(a);
llargs.push(b);
return;
}
}
}
- Ref(llval, align) => {
+ Ref(llval, _, align) => {
if arg.is_indirect() && align.abi() < arg.layout.align.abi() {
// `foo(packed.large_field)`. We can't pass the (unaligned) field directly. I
// think that ATM (Rust 1.16) we only pass temporaries, but we shouldn't
(llval, align, true)
}
}
- UnsizedRef(..) =>
- bug!("codegen_argument: tried to pass unsized operand to sized argument"),
};
if by_ref && !arg.is_indirect() {
let tuple = self.codegen_operand(bx, operand);
// Handle both by-ref and immediate tuples.
- if let Ref(llval, align) = tuple.val {
+ if let Ref(llval, None, align) = tuple.val {
let tuple_ptr = PlaceRef::new_sized(llval, tuple.layout, align);
for i in 0..tuple.layout.fields.count() {
let field_ptr = tuple_ptr.project_field(bx, i);
self.codegen_argument(bx, field_ptr.load(bx), llargs, &args[i]);
}
- } else if let UnsizedRef(..) = tuple.val {
+ } else if let Ref(_, Some(_), _) = tuple.val {
bug!("closure arguments must be sized")
} else {
// If the tuple is immediate, the elements are as well.
pub enum OperandValue<'ll> {
/// A reference to the actual operand. The data is guaranteed
/// to be valid for the operand's lifetime.
- Ref(&'ll Value, Align),
- /// A reference to the unsized operand. The data is guaranteed
- /// to be valid for the operand's lifetime.
- /// The second field is the extra.
- UnsizedRef(&'ll Value, &'ll Value),
+ /// The second value, if any, is the extra data (vtable or length)
+ /// which indicates that it refers to an unsized rvalue.
+ Ref(&'ll Value, Option<&'ll Value>, Align),
/// A single LLVM value.
Immediate(&'ll Value),
/// A pair of immediate LLVM values. Used by fat pointers too.
let (llptr, llextra) = match self.val {
OperandValue::Immediate(llptr) => (llptr, None),
OperandValue::Pair(llptr, llextra) => (llptr, Some(llextra)),
- OperandValue::Ref(..) |
- OperandValue::UnsizedRef(..) => bug!("Deref of by-Ref operand {:?}", self)
+ OperandValue::Ref(..) => bug!("Deref of by-Ref operand {:?}", self)
};
let layout = cx.layout_of(projected_ty);
PlaceRef {
*a = bx.bitcast(*a, field.scalar_pair_element_llvm_type(bx.cx, 0, true));
*b = bx.bitcast(*b, field.scalar_pair_element_llvm_type(bx.cx, 1, true));
}
- OperandValue::Ref(..) |
- OperandValue::UnsizedRef(..) => bug!()
+ OperandValue::Ref(..) => bug!()
}
OperandRef {
return;
}
match self {
- OperandValue::Ref(r, source_align) => {
+ OperandValue::Ref(r, None, source_align) => {
base::memcpy_ty(bx, dest.llval, r, dest.layout,
source_align.min(dest.align), flags)
}
- OperandValue::UnsizedRef(..) => {
+ OperandValue::Ref(_, Some(_), _) => {
bug!("cannot directly store unsized values");
}
OperandValue::Immediate(s) => {
.unwrap_or_else(|| bug!("indirect_dest has non-pointer type: {:?}", indirect_dest)).ty;
let (llptr, llextra) =
- if let OperandValue::UnsizedRef(llptr, llextra) = self {
+ if let OperandValue::Ref(llptr, Some(llextra), _) = self {
(llptr, llextra)
} else {
bug!("store_unsized called with a sized value")
};
let val = if let Some(llextra) = self.llextra {
- OperandValue::UnsizedRef(self.llval, llextra)
+ OperandValue::Ref(self.llval, Some(llextra), self.align)
} else if self.layout.is_llvm_immediate() {
let mut const_llval = None;
unsafe {
};
OperandValue::Pair(load(0, a), load(1, b))
} else {
- OperandValue::Ref(self.llval, self.align)
+ OperandValue::Ref(self.llval, None, self.align)
};
OperandRef { val, layout: self.layout }
base::coerce_unsized_into(&bx, scratch, dest);
scratch.storage_dead(&bx);
}
- OperandValue::Ref(llref, align) => {
+ OperandValue::Ref(llref, None, align) => {
let source = PlaceRef::new_sized(llref, operand.layout, align);
base::coerce_unsized_into(&bx, source, dest);
}
- OperandValue::UnsizedRef(..) => {
+ OperandValue::Ref(_, Some(_), _) => {
bug!("unsized coercion on an unsized rvalue")
}
}
bug!("by-ref operand {:?} in codegen_rvalue_operand",
operand);
}
- OperandValue::UnsizedRef(..) => {
- bug!("unsized coercion on an unsized rvalue")
- }
}
}
mir::CastKind::Misc if operand.layout.is_llvm_scalar_pair() => {