codegen_llvm: whitespace & formatting improvements
This commit is contained in:
parent
ef5c00d0ca
commit
61f47737b5
13 changed files with 69 additions and 80 deletions
|
@ -259,8 +259,7 @@ impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait FnTypeExt<'tcx> {
|
pub trait FnTypeExt<'tcx> {
|
||||||
fn of_instance(cx: &CodegenCx<'ll, 'tcx>, instance: &ty::Instance<'tcx>)
|
fn of_instance(cx: &CodegenCx<'ll, 'tcx>, instance: &ty::Instance<'tcx>) -> Self;
|
||||||
-> Self;
|
|
||||||
fn new(cx: &CodegenCx<'ll, 'tcx>,
|
fn new(cx: &CodegenCx<'ll, 'tcx>,
|
||||||
sig: ty::FnSig<'tcx>,
|
sig: ty::FnSig<'tcx>,
|
||||||
extra_args: &[Ty<'tcx>]) -> Self;
|
extra_args: &[Ty<'tcx>]) -> Self;
|
||||||
|
@ -283,8 +282,7 @@ pub trait FnTypeExt<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
|
impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
|
||||||
fn of_instance(cx: &CodegenCx<'ll, 'tcx>, instance: &ty::Instance<'tcx>)
|
fn of_instance(cx: &CodegenCx<'ll, 'tcx>, instance: &ty::Instance<'tcx>) -> Self {
|
||||||
-> Self {
|
|
||||||
let fn_ty = instance.ty(cx.tcx);
|
let fn_ty = instance.ty(cx.tcx);
|
||||||
let sig = ty_fn_sig(cx, fn_ty);
|
let sig = ty_fn_sig(cx, fn_ty);
|
||||||
let sig = cx.tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig);
|
let sig = cx.tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig);
|
||||||
|
|
|
@ -737,8 +737,8 @@ fn determine_cgu_reuse<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
|
||||||
pub fn codegen_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
pub fn codegen_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
rx: mpsc::Receiver<Box<dyn Any + Send>>)
|
rx: mpsc::Receiver<Box<dyn Any + Send>>)
|
||||||
-> OngoingCodegen {
|
-> OngoingCodegen
|
||||||
|
{
|
||||||
check_for_rustc_errors_attr(tcx);
|
check_for_rustc_errors_attr(tcx);
|
||||||
|
|
||||||
if let Some(true) = tcx.sess.opts.debugging_opts.thinlto {
|
if let Some(true) = tcx.sess.opts.debugging_opts.thinlto {
|
||||||
|
@ -803,8 +803,7 @@ pub fn codegen_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
|
||||||
// Run the monomorphization collector and partition the collected items into
|
// Run the monomorphization collector and partition the collected items into
|
||||||
// codegen units.
|
// codegen units.
|
||||||
let codegen_units =
|
let codegen_units = tcx.collect_and_partition_mono_items(LOCAL_CRATE).1;
|
||||||
tcx.collect_and_partition_mono_items(LOCAL_CRATE).1;
|
|
||||||
let codegen_units = (*codegen_units).clone();
|
let codegen_units = (*codegen_units).clone();
|
||||||
|
|
||||||
// Force all codegen_unit queries so they are already either red or green
|
// Force all codegen_unit queries so they are already either red or green
|
||||||
|
|
|
@ -59,8 +59,8 @@ pub struct CodegenCx<'a, 'tcx: 'a> {
|
||||||
/// Cache instances of monomorphic and polymorphic items
|
/// Cache instances of monomorphic and polymorphic items
|
||||||
pub instances: RefCell<FxHashMap<Instance<'tcx>, &'a Value>>,
|
pub instances: RefCell<FxHashMap<Instance<'tcx>, &'a Value>>,
|
||||||
/// Cache generated vtables
|
/// Cache generated vtables
|
||||||
pub vtables: RefCell<FxHashMap<(Ty<'tcx>,
|
pub vtables: RefCell<FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>),
|
||||||
Option<ty::PolyExistentialTraitRef<'tcx>>), &'a Value>>,
|
&'a Value>>,
|
||||||
/// Cache of constant strings,
|
/// Cache of constant strings,
|
||||||
pub const_cstr_cache: RefCell<FxHashMap<LocalInternedString, &'a Value>>,
|
pub const_cstr_cache: RefCell<FxHashMap<LocalInternedString, &'a Value>>,
|
||||||
|
|
||||||
|
|
|
@ -373,7 +373,6 @@ pub fn codegen_intrinsic_call(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
"fadd_fast" | "fsub_fast" | "fmul_fast" | "fdiv_fast" | "frem_fast" => {
|
"fadd_fast" | "fsub_fast" | "fmul_fast" | "fdiv_fast" | "frem_fast" => {
|
||||||
let sty = &arg_tys[0].sty;
|
let sty = &arg_tys[0].sty;
|
||||||
|
@ -822,8 +821,7 @@ fn codegen_msvc_try(
|
||||||
let i64p = Type::i64(cx).ptr_to();
|
let i64p = Type::i64(cx).ptr_to();
|
||||||
let ptr_align = bx.tcx().data_layout.pointer_align;
|
let ptr_align = bx.tcx().data_layout.pointer_align;
|
||||||
let slot = bx.alloca(i64p, "slot", ptr_align);
|
let slot = bx.alloca(i64p, "slot", ptr_align);
|
||||||
bx.invoke(func, &[data], normal.llbb(), catchswitch.llbb(),
|
bx.invoke(func, &[data], normal.llbb(), catchswitch.llbb(), None);
|
||||||
None);
|
|
||||||
|
|
||||||
normal.ret(C_i32(cx, 0));
|
normal.ret(C_i32(cx, 0));
|
||||||
|
|
||||||
|
@ -911,8 +909,7 @@ fn codegen_gnu_try(
|
||||||
// being thrown. The second value is a "selector" indicating which of
|
// being thrown. The second value is a "selector" indicating which of
|
||||||
// the landing pad clauses the exception's type had been matched to.
|
// the landing pad clauses the exception's type had been matched to.
|
||||||
// rust_try ignores the selector.
|
// rust_try ignores the selector.
|
||||||
let lpad_ty = Type::struct_(cx, &[Type::i8p(cx), Type::i32(cx)],
|
let lpad_ty = Type::struct_(cx, &[Type::i8p(cx), Type::i32(cx)], false);
|
||||||
false);
|
|
||||||
let vals = catch.landing_pad(lpad_ty, bx.cx.eh_personality(), 1);
|
let vals = catch.landing_pad(lpad_ty, bx.cx.eh_personality(), 1);
|
||||||
catch.add_clause(vals, C_null(Type::i8p(cx)));
|
catch.add_clause(vals, C_null(Type::i8p(cx)));
|
||||||
let ptr = catch.extract_value(vals, 0);
|
let ptr = catch.extract_value(vals, 0);
|
||||||
|
@ -1000,11 +997,11 @@ fn generic_simd_intrinsic(
|
||||||
($msg: tt, $($fmt: tt)*) => {
|
($msg: tt, $($fmt: tt)*) => {
|
||||||
span_invalid_monomorphization_error(
|
span_invalid_monomorphization_error(
|
||||||
bx.sess(), span,
|
bx.sess(), span,
|
||||||
&format!(concat!("invalid monomorphization of `{}` intrinsic: ",
|
&format!(concat!("invalid monomorphization of `{}` intrinsic: ", $msg),
|
||||||
$msg),
|
|
||||||
name, $($fmt)*));
|
name, $($fmt)*));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! return_error {
|
macro_rules! return_error {
|
||||||
($($fmt: tt)*) => {
|
($($fmt: tt)*) => {
|
||||||
{
|
{
|
||||||
|
@ -1021,14 +1018,13 @@ fn generic_simd_intrinsic(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! require_simd {
|
macro_rules! require_simd {
|
||||||
($ty: expr, $position: expr) => {
|
($ty: expr, $position: expr) => {
|
||||||
require!($ty.is_simd(), "expected SIMD {} type, found non-SIMD `{}`", $position, $ty)
|
require!($ty.is_simd(), "expected SIMD {} type, found non-SIMD `{}`", $position, $ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let tcx = bx.tcx();
|
let tcx = bx.tcx();
|
||||||
let sig = tcx.normalize_erasing_late_bound_regions(
|
let sig = tcx.normalize_erasing_late_bound_regions(
|
||||||
ty::ParamEnv::reveal_all(),
|
ty::ParamEnv::reveal_all(),
|
||||||
|
@ -1150,9 +1146,7 @@ fn generic_simd_intrinsic(
|
||||||
);
|
);
|
||||||
match m_elem_ty.sty {
|
match m_elem_ty.sty {
|
||||||
ty::Int(_) => {},
|
ty::Int(_) => {},
|
||||||
_ => {
|
_ => return_error!("mask element type is `{}`, expected `i_`", m_elem_ty)
|
||||||
return_error!("mask element type is `{}`, expected `i_`", m_elem_ty);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// truncate the mask to a vector of i1s
|
// truncate the mask to a vector of i1s
|
||||||
let i1 = Type::i1(bx.cx);
|
let i1 = Type::i1(bx.cx);
|
||||||
|
@ -1177,8 +1171,7 @@ fn generic_simd_intrinsic(
|
||||||
($msg: tt, $($fmt: tt)*) => {
|
($msg: tt, $($fmt: tt)*) => {
|
||||||
span_invalid_monomorphization_error(
|
span_invalid_monomorphization_error(
|
||||||
bx.sess(), span,
|
bx.sess(), span,
|
||||||
&format!(concat!("invalid monomorphization of `{}` intrinsic: ",
|
&format!(concat!("invalid monomorphization of `{}` intrinsic: ", $msg),
|
||||||
$msg),
|
|
||||||
name, $($fmt)*));
|
name, $($fmt)*));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1570,7 +1563,6 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
Ok(bx.$float_reduce(acc, args[0].immediate()))
|
Ok(bx.$float_reduce(acc, args[0].immediate()))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue