Rustfmt
This commit is contained in:
parent
38585b3f01
commit
a0cdbd1aa6
5 changed files with 26 additions and 28 deletions
|
@ -6,8 +6,8 @@ extern crate rustc_interface;
|
||||||
extern crate rustc_session;
|
extern crate rustc_session;
|
||||||
extern crate rustc_target;
|
extern crate rustc_target;
|
||||||
|
|
||||||
use std::panic;
|
|
||||||
use std::lazy::SyncLazy;
|
use std::lazy::SyncLazy;
|
||||||
|
use std::panic;
|
||||||
|
|
||||||
use rustc_data_structures::profiling::{get_resident_set_size, print_time_passes_entry};
|
use rustc_data_structures::profiling::{get_resident_set_size, print_time_passes_entry};
|
||||||
use rustc_interface::interface;
|
use rustc_interface::interface;
|
||||||
|
|
|
@ -291,7 +291,8 @@ pub(crate) fn run_aot(
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME handle `-Ctarget-cpu=native`
|
// FIXME handle `-Ctarget-cpu=native`
|
||||||
let target_cpu = tcx.sess.opts.cg.target_cpu.as_ref().unwrap_or(&tcx.sess.target.cpu).to_owned();
|
let target_cpu =
|
||||||
|
tcx.sess.opts.cg.target_cpu.as_ref().unwrap_or(&tcx.sess.target.cpu).to_owned();
|
||||||
Box::new((
|
Box::new((
|
||||||
CodegenResults {
|
CodegenResults {
|
||||||
modules,
|
modules,
|
||||||
|
|
|
@ -26,7 +26,8 @@ thread_local! {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The Sender owned by the rustc thread
|
/// The Sender owned by the rustc thread
|
||||||
static GLOBAL_MESSAGE_SENDER: SyncOnceCell<Mutex<mpsc::Sender<UnsafeMessage>>> = SyncOnceCell::new();
|
static GLOBAL_MESSAGE_SENDER: SyncOnceCell<Mutex<mpsc::Sender<UnsafeMessage>>> =
|
||||||
|
SyncOnceCell::new();
|
||||||
|
|
||||||
/// A message that is sent from the jitted runtime to the rustc thread.
|
/// A message that is sent from the jitted runtime to the rustc thread.
|
||||||
/// Senders are responsible for upholding `Send` semantics.
|
/// Senders are responsible for upholding `Send` semantics.
|
||||||
|
@ -195,14 +196,17 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, backend_config: BackendConfig) -> ! {
|
||||||
// lazy JIT compilation request - compile requested instance and return pointer to result
|
// lazy JIT compilation request - compile requested instance and return pointer to result
|
||||||
UnsafeMessage::JitFn { instance_ptr, trampoline_ptr, tx } => {
|
UnsafeMessage::JitFn { instance_ptr, trampoline_ptr, tx } => {
|
||||||
tx.send(jit_fn(instance_ptr, trampoline_ptr))
|
tx.send(jit_fn(instance_ptr, trampoline_ptr))
|
||||||
.expect("jitted runtime hung up before response to lazy JIT request was sent");
|
.expect("jitted runtime hung up before response to lazy JIT request was sent");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
extern "C" fn __clif_jit_fn(instance_ptr: *const Instance<'static>, trampoline_ptr: *const u8) -> *const u8 {
|
extern "C" fn __clif_jit_fn(
|
||||||
|
instance_ptr: *const Instance<'static>,
|
||||||
|
trampoline_ptr: *const u8,
|
||||||
|
) -> *const u8 {
|
||||||
// send the JIT request to the rustc thread, with a channel for the response
|
// send the JIT request to the rustc thread, with a channel for the response
|
||||||
let (tx, rx) = mpsc::channel();
|
let (tx, rx) = mpsc::channel();
|
||||||
UnsafeMessage::JitFn { instance_ptr, trampoline_ptr, tx }
|
UnsafeMessage::JitFn { instance_ptr, trampoline_ptr, tx }
|
||||||
|
@ -210,8 +214,7 @@ extern "C" fn __clif_jit_fn(instance_ptr: *const Instance<'static>, trampoline_p
|
||||||
.expect("rustc thread hung up before lazy JIT request was sent");
|
.expect("rustc thread hung up before lazy JIT request was sent");
|
||||||
|
|
||||||
// block on JIT compilation result
|
// block on JIT compilation result
|
||||||
rx.recv()
|
rx.recv().expect("rustc thread hung up before responding to sent lazy JIT request")
|
||||||
.expect("rustc thread hung up before responding to sent lazy JIT request")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn jit_fn(instance_ptr: *const Instance<'static>, trampoline_ptr: *const u8) -> *const u8 {
|
fn jit_fn(instance_ptr: *const Instance<'static>, trampoline_ptr: *const u8) -> *const u8 {
|
||||||
|
|
|
@ -148,30 +148,28 @@ fn llvm_add_sub<'tcx>(
|
||||||
ret: CPlace<'tcx>,
|
ret: CPlace<'tcx>,
|
||||||
cb_in: Value,
|
cb_in: Value,
|
||||||
a: CValue<'tcx>,
|
a: CValue<'tcx>,
|
||||||
b: CValue<'tcx>
|
b: CValue<'tcx>,
|
||||||
) {
|
) {
|
||||||
assert_eq!(a.layout().ty, fx.tcx.types.u64, "llvm.x86.addcarry.64/llvm.x86.subborrow.64 second operand must be u64");
|
assert_eq!(
|
||||||
assert_eq!(b.layout().ty, fx.tcx.types.u64, "llvm.x86.addcarry.64/llvm.x86.subborrow.64 third operand must be u64");
|
a.layout().ty,
|
||||||
|
fx.tcx.types.u64,
|
||||||
|
"llvm.x86.addcarry.64/llvm.x86.subborrow.64 second operand must be u64"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
b.layout().ty,
|
||||||
|
fx.tcx.types.u64,
|
||||||
|
"llvm.x86.addcarry.64/llvm.x86.subborrow.64 third operand must be u64"
|
||||||
|
);
|
||||||
|
|
||||||
// c + carry -> c + first intermediate carry or borrow respectively
|
// c + carry -> c + first intermediate carry or borrow respectively
|
||||||
let int0 = crate::num::codegen_checked_int_binop(
|
let int0 = crate::num::codegen_checked_int_binop(fx, bin_op, a, b);
|
||||||
fx,
|
|
||||||
bin_op,
|
|
||||||
a,
|
|
||||||
b,
|
|
||||||
);
|
|
||||||
let c = int0.value_field(fx, mir::Field::new(0));
|
let c = int0.value_field(fx, mir::Field::new(0));
|
||||||
let cb0 = int0.value_field(fx, mir::Field::new(1)).load_scalar(fx);
|
let cb0 = int0.value_field(fx, mir::Field::new(1)).load_scalar(fx);
|
||||||
|
|
||||||
// c + carry -> c + second intermediate carry or borrow respectively
|
// c + carry -> c + second intermediate carry or borrow respectively
|
||||||
let cb_in_as_u64 = fx.bcx.ins().uextend(types::I64, cb_in);
|
let cb_in_as_u64 = fx.bcx.ins().uextend(types::I64, cb_in);
|
||||||
let cb_in_as_u64 = CValue::by_val(cb_in_as_u64, fx.layout_of(fx.tcx.types.u64));
|
let cb_in_as_u64 = CValue::by_val(cb_in_as_u64, fx.layout_of(fx.tcx.types.u64));
|
||||||
let int1 = crate::num::codegen_checked_int_binop(
|
let int1 = crate::num::codegen_checked_int_binop(fx, bin_op, c, cb_in_as_u64);
|
||||||
fx,
|
|
||||||
bin_op,
|
|
||||||
c,
|
|
||||||
cb_in_as_u64,
|
|
||||||
);
|
|
||||||
let (c, cb1) = int1.load_scalar_pair(fx);
|
let (c, cb1) = int1.load_scalar_pair(fx);
|
||||||
|
|
||||||
// carry0 | carry1 -> carry or borrow respectively
|
// carry0 | carry1 -> carry or borrow respectively
|
||||||
|
|
|
@ -69,12 +69,8 @@ pub(crate) fn get_vtable<'tcx>(
|
||||||
trait_ref: Option<ty::PolyExistentialTraitRef<'tcx>>,
|
trait_ref: Option<ty::PolyExistentialTraitRef<'tcx>>,
|
||||||
) -> Value {
|
) -> Value {
|
||||||
let alloc_id = fx.tcx.vtable_allocation(ty, trait_ref);
|
let alloc_id = fx.tcx.vtable_allocation(ty, trait_ref);
|
||||||
let data_id = data_id_for_alloc_id(
|
let data_id =
|
||||||
&mut fx.constants_cx,
|
data_id_for_alloc_id(&mut fx.constants_cx, &mut *fx.module, alloc_id, Mutability::Not);
|
||||||
&mut *fx.module,
|
|
||||||
alloc_id,
|
|
||||||
Mutability::Not,
|
|
||||||
);
|
|
||||||
let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func);
|
let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func);
|
||||||
if fx.clif_comments.enabled() {
|
if fx.clif_comments.enabled() {
|
||||||
fx.add_comment(local_data_id, format!("vtable: {:?}", alloc_id));
|
fx.add_comment(local_data_id, format!("vtable: {:?}", alloc_id));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue