use mir::place::PlaceRef;
use mir::operand::{OperandRef, OperandValue};
use base::*;
-use common::*;
use context::CodegenCx;
-use declare;
use glue;
use type_::Type;
use type_of::LayoutLlvmExt;
use rustc::ty::{self, Ty};
use rustc::ty::layout::{LayoutOf, HasTyCtxt};
+use rustc_codegen_ssa::common::TypeKind;
use rustc::hir;
use syntax::ast;
use syntax::symbol::Symbol;
Some(cx.get_intrinsic(&llvm_name))
}
-impl IntrinsicCallMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
- /// Remember to add all intrinsics here, in librustc_typeck/check/mod.rs,
- /// and in libcore/intrinsics.rs; if you need access to any llvm intrinsics,
- /// add them to librustc_codegen_llvm/context.rs
+impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
fn codegen_intrinsic_call(
&self,
callee_ty: Ty<'tcx>,
let tp_ty = substs.type_at(0);
if let OperandValue::Pair(_, meta) = args[0].val {
let (llsize, _) =
- glue::size_and_align_of_dst(&self, tp_ty, Some(meta));
+ glue::size_and_align_of_dst(self, tp_ty, Some(meta));
llsize
} else {
cx.const_usize(cx.size_of(tp_ty).bytes())
let tp_ty = substs.type_at(0);
if let OperandValue::Pair(_, meta) = args[0].val {
let (_, llalign) =
- glue::size_and_align_of_dst(&self, tp_ty, Some(meta));
+ glue::size_and_align_of_dst(self, tp_ty, Some(meta));
llalign
} else {
cx.const_usize(cx.align_of(tp_ty).abi())
},
"volatile_store" => {
let dst = args[0].deref(cx);
- args[1].val.volatile_store(&self, dst);
+ args[1].val.volatile_store(self, dst);
return;
},
"unaligned_volatile_store" => {
let dst = args[0].deref(cx);
- args[1].val.unaligned_volatile_store(&self, dst);
+ args[1].val.unaligned_volatile_store(self, dst);
return;
},
"prefetch_read_data" | "prefetch_write_data" |
cx.type_bool()
);
- let dest = result.project_field(&self, 0);
+ let dest = result.project_field(self, 0);
self.store(val, dest.llval, dest.align);
- let dest = result.project_field(&self, 1);
+ let dest = result.project_field(self, 1);
self.store(overflow, dest.llval, dest.align);
return;
},
"discriminant_value" => {
- args[0].deref(cx).codegen_get_discr(&self, ret_ty)
+ args[0].deref(cx).codegen_get_discr(self, ret_ty)
}
name if name.starts_with("simd_") => {
// This requires that atomic intrinsics follow a specific naming pattern:
// "atomic_<operation>[_<ordering>]", and no ordering means SeqCst
name if name.starts_with("atomic_") => {
- use self::AtomicOrdering::*;
+ use rustc_codegen_ssa::common::AtomicOrdering::*;
+ use rustc_codegen_ssa::common::
+ {SynchronizationScope, AtomicRmwBinOp};
let split: Vec<&str> = name.split('_').collect();
cx.type_bool()
);
- let dest = result.project_field(&self, 0);
+ let dest = result.project_field(self, 0);
self.store(val, dest.llval, dest.align);
- let dest = result.project_field(&self, 1);
+ let dest = result.project_field(self, 1);
self.store(success, dest.llval, dest.align);
return;
} else {
"nontemporal_store" => {
let dst = args[0].deref(cx);
- args[1].val.nontemporal_store(&self, dst);
+ args[1].val.nontemporal_store(self, dst);
return;
}
};
let arg = PlaceRef::new_sized(ptr, arg.layout, align);
(0..contents.len()).map(|i| {
- arg.project_field(bx, i).load(bx).immediate()
+ bx.load_operand(arg.project_field(bx, i)).immediate()
}).collect()
}
intrinsics::Type::Pointer(_, Some(ref llvm_elem), _) => {
let val = match intr.definition {
intrinsics::IntrinsicDef::Named(name) => {
- let f = declare::declare_cfn(cx,
- name,
- cx.type_func(&inputs, outputs));
+ let f = cx.declare_cfn(
+ name,
+ cx.type_func(&inputs, outputs),
+ );
self.call(f, &llargs, None)
}
};
assert!(!flatten);
for i in 0..elems.len() {
- let dest = result.project_field(&self, i);
+ let dest = result.project_field(self, i);
let val = self.extract_value(val, i as u64);
self.store(val, dest.llval, dest.align);
}
let ptr = self.pointercast(result.llval, cx.type_ptr_to(ty.llvm_type(cx)));
self.store(llval, ptr, result.align);
} else {
- OperandRef::from_immediate_or_packed_pair(&self, llval, result.layout)
- .val.store(&self, result);
+ OperandRef::from_immediate_or_packed_pair(self, llval, result.layout)
+ .val.store(self, result);
}
}
}
local_ptr: &'ll Value,
dest: &'ll Value,
) {
- if bx.sess().no_landing_pads() {
+ if bx.cx().sess().no_landing_pads() {
bx.call(func, &[data], None);
let ptr_align = bx.tcx().data_layout.pointer_align;
bx.store(cx.const_null(cx.type_i8p()), dest, ptr_align);
- } else if wants_msvc_seh(bx.sess()) {
+ } else if wants_msvc_seh(bx.cx().sess()) {
codegen_msvc_try(bx, cx, func, data, local_ptr, dest);
} else {
codegen_gnu_try(bx, cx, func, data, local_ptr, dest);
Some(did) => cx.get_static(did),
None => bug!("msvc_try_filter not defined"),
};
- let tok = catchpad.catch_pad(cs, &[tydesc, cx.const_i32(0), slot]);
+ let funclet = catchpad.catch_pad(cs, &[tydesc, cx.const_i32(0), slot]);
let addr = catchpad.load(slot, ptr_align);
let i64_align = bx.tcx().data_layout.i64_align;
let local_ptr = catchpad.bitcast(local_ptr, i64p);
catchpad.store(arg1, local_ptr, i64_align);
catchpad.store(arg2, catchpad.inbounds_gep(local_ptr, &[val1]), i64_align);
- catchpad.catch_ret(tok, caught.llbb());
+ catchpad.catch_ret(&funclet, caught.llbb());
caught.ret(cx.const_i32(1));
});
hir::Unsafety::Unsafe,
Abi::Rust
));
- let llfn = declare::define_internal_fn(cx, name, rust_fn_sig);
+ let llfn = cx.define_internal_fn(name, rust_fn_sig);
attributes::from_fn_attrs(cx, llfn, None);
let bx = Builder::new_block(cx, llfn, "entry-block");
codegen(bx);
};
($msg: tt, $($fmt: tt)*) => {
span_invalid_monomorphization_error(
- bx.sess(), span,
+ bx.cx().sess(), span,
&format!(concat!("invalid monomorphization of `{}` intrinsic: ", $msg),
name, $($fmt)*));
}
};
($msg: tt, $($fmt: tt)*) => {
span_invalid_monomorphization_error(
- bx.sess(), span,
+ bx.cx().sess(), span,
&format!(concat!("invalid monomorphization of `{}` intrinsic: ", $msg),
name, $($fmt)*));
}
let llvm_intrinsic = format!("llvm.masked.gather.{}.{}",
llvm_elem_vec_str, llvm_pointer_vec_str);
- let f = declare::declare_cfn(bx.cx(), &llvm_intrinsic,
+ let f = bx.cx().declare_cfn(&llvm_intrinsic,
bx.cx().type_func(&[
llvm_pointer_vec_ty,
alignment_ty,
let llvm_intrinsic = format!("llvm.masked.scatter.{}.{}",
llvm_elem_vec_str, llvm_pointer_vec_str);
- let f = declare::declare_cfn(bx.cx(), &llvm_intrinsic,
+ let f = bx.cx().declare_cfn(&llvm_intrinsic,
bx.cx().type_func(&[llvm_elem_vec_ty,
llvm_pointer_vec_ty,
alignment_ty,