Rustfmt
This commit is contained in:
parent
bc84888830
commit
16e936b93f
5 changed files with 43 additions and 22 deletions
23
src/abi.rs
23
src/abi.rs
|
@ -49,7 +49,11 @@ fn get_pass_mode<'a, 'tcx: 'a>(
|
|||
PassMode::ByVal(ret_ty)
|
||||
} else {
|
||||
if abi == Abi::C {
|
||||
unimpl!("Non scalars are not yet supported for \"C\" abi ({:?}) is_return: {:?}", ty, is_return);
|
||||
unimpl!(
|
||||
"Non scalars are not yet supported for \"C\" abi ({:?}) is_return: {:?}",
|
||||
ty,
|
||||
is_return
|
||||
);
|
||||
}
|
||||
PassMode::ByRef
|
||||
}
|
||||
|
@ -667,9 +671,10 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>(
|
|||
assert_eq!(args.len(), 1);
|
||||
let layout = fx.layout_of(substs.type_at(0));
|
||||
let size = match &layout.ty.sty {
|
||||
_ if !layout.is_unsized() => {
|
||||
fx.bcx.ins().iconst(fx.module.pointer_type(), layout.size.bytes() as i64)
|
||||
}
|
||||
_ if !layout.is_unsized() => fx
|
||||
.bcx
|
||||
.ins()
|
||||
.iconst(fx.module.pointer_type(), layout.size.bytes() as i64),
|
||||
ty::Slice(elem) => {
|
||||
let len = args[0].load_value_pair(fx).1;
|
||||
let elem_size = fx.layout_of(elem).size.bytes();
|
||||
|
@ -690,9 +695,10 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>(
|
|||
assert_eq!(args.len(), 1);
|
||||
let layout = fx.layout_of(substs.type_at(0));
|
||||
let align = match &layout.ty.sty {
|
||||
_ if !layout.is_unsized() => {
|
||||
fx.bcx.ins().iconst(fx.module.pointer_type(), layout.align.abi() as i64)
|
||||
}
|
||||
_ if !layout.is_unsized() => fx
|
||||
.bcx
|
||||
.ins()
|
||||
.iconst(fx.module.pointer_type(), layout.align.abi() as i64),
|
||||
ty::Slice(elem) => {
|
||||
let align = fx.layout_of(elem).align.abi() as i64;
|
||||
fx.bcx.ins().iconst(fx.module.pointer_type(), align)
|
||||
|
@ -860,7 +866,8 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>(
|
|||
_ if intrinsic.starts_with("atomic_fence") => {}
|
||||
_ if intrinsic.starts_with("atomic_load") => {
|
||||
assert_eq!(args.len(), 1);
|
||||
let inner_layout = fx.layout_of(args[0].layout().ty.builtin_deref(true).unwrap().ty);
|
||||
let inner_layout =
|
||||
fx.layout_of(args[0].layout().ty.builtin_deref(true).unwrap().ty);
|
||||
let val = CValue::ByRef(args[0].load_value(fx), inner_layout);
|
||||
ret.write_cvalue(fx, val);
|
||||
}
|
||||
|
|
18
src/base.rs
18
src/base.rs
|
@ -27,8 +27,11 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(
|
|||
if inst.def_id().krate == LOCAL_CRATE =>
|
||||
{
|
||||
let mut mir = ::std::io::Cursor::new(Vec::new());
|
||||
crate::rustc_mir::util::write_mir_pretty(tcx, Some(inst.def_id()), &mut mir)
|
||||
.unwrap();
|
||||
crate::rustc_mir::util::write_mir_pretty(
|
||||
tcx,
|
||||
Some(inst.def_id()),
|
||||
&mut mir,
|
||||
).unwrap();
|
||||
String::from_utf8(mir.into_inner()).unwrap()
|
||||
}
|
||||
InstanceDef::Item(_)
|
||||
|
@ -436,12 +439,10 @@ fn trans_stmt<'a, 'tcx: 'a>(
|
|||
let res = fx.bcx.ins().icmp_imm(IntCC::Equal, val, 0);
|
||||
fx.bcx.ins().bint(types::I8, res)
|
||||
}
|
||||
ty::Uint(_) | ty::Int(_) => {
|
||||
fx.bcx.ins().bnot(val)
|
||||
}
|
||||
ty::Uint(_) | ty::Int(_) => fx.bcx.ins().bnot(val),
|
||||
_ => unimplemented!("un op Not for {:?}", layout.ty),
|
||||
}
|
||||
},
|
||||
}
|
||||
UnOp::Neg => match layout.ty.sty {
|
||||
ty::Int(_) => {
|
||||
let clif_ty = fx.cton_type(layout.ty).unwrap();
|
||||
|
@ -1001,7 +1002,10 @@ fn trans_ptr_binop<'a, 'tcx: 'a>(
|
|||
let res = match bin_op {
|
||||
BinOp::Eq => fx.bcx.ins().icmp(IntCC::Equal, lhs, rhs),
|
||||
BinOp::Ne => fx.bcx.ins().icmp(IntCC::NotEqual, lhs, rhs),
|
||||
_ => unimplemented!("trans_ptr_binop({:?}, <fat ptr>, <fat ptr>) not implemented", bin_op),
|
||||
_ => unimplemented!(
|
||||
"trans_ptr_binop({:?}, <fat ptr>, <fat ptr>) not implemented",
|
||||
bin_op
|
||||
),
|
||||
};
|
||||
|
||||
assert_eq!(fx.tcx.types.bool, ret_ty);
|
||||
|
|
|
@ -372,7 +372,9 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> {
|
|||
pub fn write_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, from: CValue<'tcx>) {
|
||||
match (&self.layout().ty.sty, &from.layout().ty.sty) {
|
||||
(ty::Ref(_, t, dest_mut), ty::Ref(_, u, src_mut))
|
||||
if (if *dest_mut != crate::rustc::hir::Mutability::MutImmutable && src_mut != dest_mut {
|
||||
if (if *dest_mut != crate::rustc::hir::Mutability::MutImmutable
|
||||
&& src_mut != dest_mut
|
||||
{
|
||||
false
|
||||
} else if t != u {
|
||||
false
|
||||
|
@ -449,7 +451,11 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> {
|
|||
) -> CPlace<'tcx> {
|
||||
match self {
|
||||
CPlace::Var(var, layout) => {
|
||||
bug!("Tried to project {:?}, which is put in SSA var {:?}", layout.ty, var);
|
||||
bug!(
|
||||
"Tried to project {:?}, which is put in SSA var {:?}",
|
||||
layout.ty,
|
||||
var
|
||||
);
|
||||
}
|
||||
CPlace::Addr(base, extra, layout) => {
|
||||
let (field_ptr, field_layout) = codegen_field(fx, base, layout, field);
|
||||
|
|
|
@ -154,7 +154,8 @@ fn data_id_for_static<'a, 'tcx: 'a, B: Backend>(
|
|||
def_id: DefId,
|
||||
) -> DataId {
|
||||
let symbol_name = tcx.symbol_name(Instance::mono(tcx, def_id)).as_str();
|
||||
let is_mutable = if let crate::rustc::hir::Mutability::MutMutable = tcx.is_static(def_id).unwrap() {
|
||||
let is_mutable =
|
||||
if let crate::rustc::hir::Mutability::MutMutable = tcx.is_static(def_id).unwrap() {
|
||||
true
|
||||
} else {
|
||||
!tcx.type_of(def_id)
|
||||
|
@ -235,11 +236,13 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>(
|
|||
let data_id = match tcx.alloc_map.lock().get(reloc).unwrap() {
|
||||
AllocType::Function(instance) => {
|
||||
let (func_name, sig) = crate::abi::get_function_name_and_sig(tcx, instance);
|
||||
let func_id = module.declare_function(&func_name, Linkage::Import, &sig).unwrap();
|
||||
let func_id = module
|
||||
.declare_function(&func_name, Linkage::Import, &sig)
|
||||
.unwrap();
|
||||
let local_func_id = module.declare_func_in_data(func_id, &mut data_ctx);
|
||||
data_ctx.write_function_addr(reloc_offset as u32, local_func_id);
|
||||
continue;
|
||||
},
|
||||
}
|
||||
AllocType::Memory(_) => {
|
||||
cx.todo.insert(TodoItem::Alloc(reloc));
|
||||
data_id_for_alloc_id(module, reloc)
|
||||
|
|
|
@ -81,8 +81,9 @@ fn build_vtable<'a, 'tcx: 'a>(
|
|||
.layout_of(ParamEnv::reveal_all().and(ty))
|
||||
.unwrap()
|
||||
.size_and_align();
|
||||
let drop_in_place_fn =
|
||||
fx.get_function_id(crate::rustc_mir::monomorphize::resolve_drop_in_place(tcx, ty));
|
||||
let drop_in_place_fn = fx.get_function_id(
|
||||
crate::rustc_mir::monomorphize::resolve_drop_in_place(tcx, ty),
|
||||
);
|
||||
|
||||
let mut components: Vec<_> = vec![Some(drop_in_place_fn), None, None];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue