use llvm::{self, AttributePlace};
use base;
use builder::{Builder, MemFlags};
-use common::C_usize;
use context::CodegenCx;
use mir::place::PlaceRef;
use mir::operand::OperandValue;
use type_of::{LayoutLlvmExt, PointerKind};
use value::Value;
-use rustc_target::abi::{LayoutOf, Size, TyLayout, Abi as LayoutAbi};
+use interfaces::{BuilderMethods, CommonMethods};
+
+use rustc_target::abi::{HasDataLayout, LayoutOf, Size, TyLayout, Abi as LayoutAbi};
use rustc::ty::{self, Ty};
use rustc::ty::layout;
pub trait ArgTypeExt<'ll, 'tcx> {
fn memory_ty(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
- fn store(&self, bx: &Builder<'_, 'll, 'tcx>, val: &'ll Value, dst: PlaceRef<'ll, 'tcx>);
- fn store_fn_arg(&self, bx: &Builder<'_, 'll, 'tcx>, idx: &mut usize, dst: PlaceRef<'ll, 'tcx>);
+ fn store(
+ &self,
+ bx: &Builder<'_, 'll, 'tcx>,
+ val: &'ll Value,
+ dst: PlaceRef<'tcx, &'ll Value>,
+ );
+ fn store_fn_arg(
+ &self,
+ bx: &Builder<'_, 'll, 'tcx>,
+ idx: &mut usize,
+ dst: PlaceRef<'tcx, &'ll Value>,
+ );
}
impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
/// place for the original Rust type of this argument/return.
/// Can be used for both storing formal arguments into Rust variables
/// or results of call/invoke instructions into their destinations.
- fn store(&self, bx: &Builder<'_, 'll, 'tcx>, val: &'ll Value, dst: PlaceRef<'ll, 'tcx>) {
+ fn store(
+ &self,
+ bx: &Builder<'_, 'll, 'tcx>,
+ val: &'ll Value,
+ dst: PlaceRef<'tcx, &'ll Value>,
+ ) {
if self.is_ignore() {
return;
}
- let cx = bx.cx;
+ let cx = bx.cx();
if self.is_sized_indirect() {
OperandValue::Ref(val, None, self.layout.align).store(bx, dst)
} else if self.is_unsized_indirect() {
self.layout.align,
bx.pointercast(llscratch, Type::i8p(cx)),
scratch_align,
- C_usize(cx, self.layout.size.bytes()),
+ cx.c_usize(self.layout.size.bytes()),
MemFlags::empty());
bx.lifetime_end(llscratch, scratch_size);
}
}
- fn store_fn_arg(&self, bx: &Builder<'a, 'll, 'tcx>, idx: &mut usize, dst: PlaceRef<'ll, 'tcx>) {
+ fn store_fn_arg(
+ &self,
+ bx: &Builder<'a, 'll, 'tcx>,
+ idx: &mut usize,
+ dst: PlaceRef<'tcx, &'ll Value>,
+ ) {
let mut next = || {
let val = llvm::get_param(bx.llfn(), *idx as c_uint);
*idx += 1;
cx: &CodegenCx<'ll, 'tcx>,
abi: Abi);
fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
+ fn ptr_to_llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
fn llvm_cconv(&self) -> llvm::CallConv;
fn apply_attrs_llfn(&self, llfn: &'ll Value);
fn apply_attrs_callsite(&self, bx: &Builder<'a, 'll, 'tcx>, callsite: &'ll Value);
}
}
+ fn ptr_to_llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type {
+ unsafe {
+ llvm::LLVMPointerType(self.llvm_type(cx),
+ cx.data_layout().instruction_address_space as c_uint)
+ }
+ }
+
fn llvm_cconv(&self) -> llvm::CallConv {
match self.conv {
Conv::C => llvm::CCallConv,
// by the LLVM verifier.
if let layout::Int(..) = scalar.value {
if !scalar.is_bool() {
- let range = scalar.valid_range_exclusive(bx.cx);
+ let range = scalar.valid_range_exclusive(bx.cx());
if range.start != range.end {
bx.range_metadata(callsite, range);
}