}
pub fn cast_shift_expr_rhs(
- cx: &Builder<'_, 'll, '_>, op: hir::BinOpKind, lhs: &'ll Value, rhs: &'ll Value
+ bx: &Builder<'_, 'll, '_>, op: hir::BinOpKind, lhs: &'ll Value, rhs: &'ll Value
) -> &'ll Value {
- cast_shift_rhs(op, lhs, rhs, |a, b| cx.trunc(a, b), |a, b| cx.zext(a, b))
+ cast_shift_rhs(bx, op, lhs, rhs, |a, b| bx.trunc(a, b), |a, b| bx.zext(a, b))
}
-fn cast_shift_rhs<'ll, F, G>(op: hir::BinOpKind,
+fn cast_shift_rhs<'ll, F, G>(bx: &Builder<'_, 'll, '_>,
+ op: hir::BinOpKind,
lhs: &'ll Value,
rhs: &'ll Value,
trunc: F,
{
// Shifts may have any size int on the rhs
if op.is_shift() {
- let mut rhs_llty = CodegenCx::val_ty(rhs);
- let mut lhs_llty = CodegenCx::val_ty(lhs);
+ let mut rhs_llty = bx.cx().val_ty(rhs);
+ let mut lhs_llty = bx.cx().val_ty(lhs);
if rhs_llty.kind() == TypeKind::Vector {
rhs_llty = rhs_llty.element_type()
}
bx: &Builder<'_ ,'ll, '_, &'ll Value>,
val: &'ll Value
) -> &'ll Value {
- if CodegenCx::val_ty(val) == Type::i1(bx.cx()) {
+ if bx.cx().val_ty(val) == Type::i1(bx.cx()) {
bx.zext(val, Type::i8(bx.cx()))
} else {
val
if flags.contains(MemFlags::NONTEMPORAL) {
// HACK(nox): This is inefficient but there is no nontemporal memcpy.
let val = bx.load(src, src_align);
- let ptr = bx.pointercast(dst, CodegenCx::val_ty(val).ptr_to());
+ let ptr = bx.pointercast(dst, bx.cx().val_ty(val).ptr_to());
bx.store_with_flags(val, ptr, dst_align, flags);
return;
}
DeflateEncoder::new(&mut compressed, Compression::fast())
.write_all(&metadata.raw_data).unwrap();
- let llmeta = CodegenCx::c_bytes_in_context(metadata_llcx, &compressed);
- let llconst = CodegenCx::c_struct_in_context(metadata_llcx, &[llmeta], false);
+ let llmeta = llvm_module.c_bytes_in_context(metadata_llcx, &compressed);
+ let llconst = llvm_module.c_struct_in_context(metadata_llcx, &[llmeta], false);
let name = exported_symbols::metadata_symbol_name(tcx);
let buf = CString::new(name).unwrap();
let llglobal = unsafe {
- llvm::LLVMAddGlobal(metadata_llmod, CodegenCx::val_ty(llconst), buf.as_ptr())
+ llvm::LLVMAddGlobal(metadata_llmod, llvm_module.val_ty(llconst), buf.as_ptr())
};
unsafe {
llvm::LLVMSetInitializer(llglobal, llconst);
// Run replace-all-uses-with for statics that need it
for &(old_g, new_g) in cx.statics_to_rauw.borrow().iter() {
unsafe {
- let bitcast = llvm::LLVMConstPointerCast(new_g, CodegenCx::val_ty(old_g));
+ let bitcast = llvm::LLVMConstPointerCast(new_g, cx.val_ty(old_g));
llvm::LLVMReplaceAllUsesWith(old_g, bitcast);
llvm::LLVMDeleteGlobal(old_g);
}
if !cx.used_statics.borrow().is_empty() {
let name = const_cstr!("llvm.used");
let section = const_cstr!("llvm.metadata");
- let array = CodegenCx::c_array(Type::i8(&cx).ptr_to(), &*cx.used_statics.borrow());
+ let array = cx.c_array(Type::i8(&cx).ptr_to(), &*cx.used_statics.borrow());
unsafe {
let g = llvm::LLVMAddGlobal(cx.llmod,
- CodegenCx::val_ty(array),
+ cx.val_ty(array),
name.as_ptr());
llvm::LLVMSetInitializer(g, array);
llvm::LLVMRustSetLinkage(g, llvm::Linkage::AppendingLinkage);