#[lang = "exchange_malloc"]
unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
- &mut MY_TINY_HEAP as *mut [u8; 16] as *mut u8
+ &mut MY_TINY_HEAP as *mut [u8; 16] as *mut u8
}
pub mod intrinsics {
),
PassMode::ByRef => {
(
- Some(pointer_ty(tcx)).into_iter() // First param is place to put return val
+ Some(pointer_ty(tcx)) // First param is place to put return val
+ .into_iter()
.chain(inputs)
.map(AbiParam::new)
.collect(),
) -> Option<Value> {
let sig = Signature {
params: input_tys.iter().cloned().map(AbiParam::new).collect(),
- returns: output_ty.map(|output_ty| vec![AbiParam::new(output_ty)]).unwrap_or(Vec::new()),
+ returns: output_ty
+ .map(|output_ty| vec![AbiParam::new(output_ty)])
+ .unwrap_or(Vec::new()),
call_conv: CallConv::SystemV,
};
let func_id = self
let len = args[0].load_value_pair(fx).1;
let elem_size = fx.layout_of(elem).size.bytes();
fx.bcx.ins().imul_imm(len, elem_size as i64)
- },
+ }
ty => unimplemented!("size_of_val for {:?}", ty),
};
ret.write_cvalue(fx, CValue::ByVal(size, usize_layout));
match inst.def {
InstanceDef::Item(_)
| InstanceDef::DropGlue(_, _)
- | InstanceDef::Virtual(_, _) if inst.def_id().krate == LOCAL_CRATE => {
+ | InstanceDef::Virtual(_, _)
+ if inst.def_id().krate == LOCAL_CRATE =>
+ {
let mut mir = ::std::io::Cursor::new(Vec::new());
::rustc_mir::util::write_mir_pretty(tcx, Some(inst.def_id()), &mut mir)
.unwrap();
| InstanceDef::FnPtrShim(_, _)
| InstanceDef::ClosureOnceShim { .. }
| InstanceDef::CloneShim(_, _) => {
- // FIXME fix write_mir_pretty for these instances
- format!("{:#?}", tcx.instance_mir(inst.def))
+ // FIXME fix write_mir_pretty for these instances
+ format!("{:#?}", tcx.instance_mir(inst.def))
}
InstanceDef::Intrinsic(_) => bug!("tried to codegen intrinsic"),
}
let def_id = match fx.tcx.lang_items().require(ExchangeMallocFnLangItem) {
Ok(id) => id,
Err(s) => {
- fx.tcx.sess.fatal(&format!("allocation of `{}` {}", box_layout.ty, s));
+ fx.tcx
+ .sess
+ .fatal(&format!("allocation of `{}` {}", box_layout.ty, s));
}
};
let instance = ty::Instance::mono(fx.tcx, def_id);
let call = fx.bcx.ins().call(func_ref, &[llsize, llalign]);
let ptr = fx.bcx.inst_results(call)[0];
lval.write_cvalue(fx, CValue::ByVal(ptr, box_layout));
- },
+ }
Rvalue::NullaryOp(NullOp::SizeOf, ty) => {
assert!(
lval.layout()
{
match self {
CValue::ByRef(addr, layout) => {
- let cton_ty = fx
- .cton_type(layout.ty)
- .unwrap_or_else(|| {
- if layout.ty.is_box() && !fx.layout_of(layout.ty.builtin_deref(true).unwrap().ty).is_unsized() {
- // Consider sized box to be a ptr
- pointer_ty(fx.tcx)
- } else {
- panic!("load_value of type {:?}", layout.ty);
- }
- });
+ let cton_ty = fx.cton_type(layout.ty).unwrap_or_else(|| {
+ if layout.ty.is_box() && !fx
+ .layout_of(layout.ty.builtin_deref(true).unwrap().ty)
+ .is_unsized()
+ {
+ // Consider sized box to be a ptr
+ pointer_ty(fx.tcx)
+ } else {
+ panic!("load_value of type {:?}", layout.ty);
+ }
+ });
fx.bcx.ins().load(cton_ty, MemFlags::new(), addr, 0)
}
CValue::ByVal(value, _layout) => value,
};
pub use cranelift::codegen::Context;
pub use cranelift::prelude::*;
- pub use cranelift_module::{
- Backend, DataContext, DataId, FuncId, Linkage, Module,
- };
+ pub use cranelift_module::{Backend, DataContext, DataId, FuncId, Linkage, Module};
pub use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder};
pub use crate::abi::*;