1
Fork 0

Generalized mir::codegen_mir (and all subsequent functions)

This commit is contained in:
Denis Merigoux 2018-09-20 15:47:22 +02:00 committed by Eduard-Mihai Burtescu
parent cbe31a4229
commit 6a993fe353
41 changed files with 1778 additions and 1390 deletions

View file

@ -57,7 +57,6 @@ use rustc_mir::monomorphize::item::DefPathBasedNames;
use common::{self, IntPredicate, RealPredicate, TypeKind};
use context::CodegenCx;
use debuginfo;
use declare;
use meth;
use mir;
use monomorphize::Instance;
@ -392,15 +391,18 @@ pub fn wants_msvc_seh(sess: &Session) -> bool {
sess.target.target.options.is_like_msvc
}
pub fn call_assume(bx: &Builder<'_, 'll, '_>, val: &'ll Value) {
pub fn call_assume<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
bx: &Bx,
val: Bx::Value
) {
let assume_intrinsic = bx.cx().get_intrinsic("llvm.assume");
bx.call(assume_intrinsic, &[val], None);
}
pub fn from_immediate<'a, 'tcx: 'a, Builder: BuilderMethods<'a, 'tcx>>(
bx: &Builder,
val: Builder::Value
) -> Builder::Value {
pub fn from_immediate<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
bx: &Bx,
val: Bx::Value
) -> Bx::Value {
if bx.cx().val_ty(val) == bx.cx().type_i1() {
bx.zext(val, bx.cx().type_i8())
} else {
@ -447,7 +449,7 @@ pub fn memcpy_ty<'a, 'tcx: 'a, Builder: BuilderMethods<'a, 'tcx>>(
bx.memcpy(dst, dst_align, src, src_align, bx.cx().const_usize(size), flags);
}
pub fn codegen_instance<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, instance: Instance<'tcx>) {
pub fn codegen_instance(cx: &CodegenCx<'_, 'tcx>, instance: Instance<'tcx>) {
let _s = if cx.sess().codegen_stats() {
let mut instance_name = String::new();
DefPathBasedNames::new(cx.tcx, true, true)
@ -471,7 +473,7 @@ pub fn codegen_instance<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, instance: Instance<'
cx.stats.borrow_mut().n_closures += 1;
let mir = cx.tcx.instance_mir(instance.def);
mir::codegen_mir(cx, lldecl, &mir, instance, sig);
mir::codegen_mir::<Builder>(cx, lldecl, &mir, instance, sig);
}
pub fn set_link_section(llval: &Value, attrs: &CodegenFnAttrs) {
@ -532,7 +534,7 @@ fn maybe_create_entry_wrapper(cx: &CodegenCx) {
&main_ret_ty.no_bound_vars().unwrap(),
);
if declare::get_defined_value(cx, "main").is_some() {
if cx.get_defined_value("main").is_some() {
// FIXME: We should be smart and show a better diagnostic here.
cx.sess().struct_span_err(sp, "entry symbol `main` defined multiple times")
.help("did you use #[no_mangle] on `fn main`? Use #[start] instead")
@ -540,7 +542,7 @@ fn maybe_create_entry_wrapper(cx: &CodegenCx) {
cx.sess().abort_if_errors();
bug!();
}
let llfn = declare::declare_cfn(cx, "main", llfty);
let llfn = cx.declare_cfn("main", llfty);
// `main` should respect same config for frame pointer elimination as rest of code
attributes::set_frame_pointer_elimination(cx, llfn);