mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Pass MonoItemData to MonoItem::define
This commit is contained in:
parent
a73eba99f7
commit
e2e96fa14e
@ -223,8 +223,8 @@ pub fn compile_codegen_unit(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ... and now that we have everything pre-defined, fill out those definitions.
|
// ... and now that we have everything pre-defined, fill out those definitions.
|
||||||
for &(mono_item, _) in &mono_items {
|
for &(mono_item, item_data) in &mono_items {
|
||||||
mono_item.define::<Builder<'_, '_, '_>>(&cx);
|
mono_item.define::<Builder<'_, '_, '_>>(&cx, item_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this codegen unit contains the main function, also create the
|
// If this codegen unit contains the main function, also create the
|
||||||
|
@ -90,8 +90,8 @@ pub(crate) fn compile_codegen_unit(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ... and now that we have everything pre-defined, fill out those definitions.
|
// ... and now that we have everything pre-defined, fill out those definitions.
|
||||||
for &(mono_item, _) in &mono_items {
|
for &(mono_item, item_data) in &mono_items {
|
||||||
mono_item.define::<Builder<'_, '_, '_>>(&cx);
|
mono_item.define::<Builder<'_, '_, '_>>(&cx, item_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this codegen unit contains the main function, also create the
|
// If this codegen unit contains the main function, also create the
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use rustc_abi::{BackendRepr, Float, Integer, Primitive, RegKind};
|
use rustc_abi::{BackendRepr, Float, Integer, Primitive, RegKind};
|
||||||
use rustc_attr_parsing::InstructionSetAttr;
|
use rustc_attr_parsing::InstructionSetAttr;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_middle::mir::mono::{Linkage, MonoItem, MonoItemData, Visibility};
|
use rustc_middle::mir::mono::{Linkage, MonoItemData, Visibility};
|
||||||
use rustc_middle::mir::{InlineAsmOperand, START_BLOCK};
|
use rustc_middle::mir::{InlineAsmOperand, START_BLOCK};
|
||||||
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout};
|
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout};
|
||||||
use rustc_middle::ty::{Instance, Ty, TyCtxt, TypeVisitableExt};
|
use rustc_middle::ty::{Instance, Ty, TyCtxt, TypeVisitableExt};
|
||||||
@ -12,18 +12,18 @@ use rustc_target::spec::{BinaryFormat, WasmCAbi};
|
|||||||
|
|
||||||
use crate::common;
|
use crate::common;
|
||||||
use crate::mir::AsmCodegenMethods;
|
use crate::mir::AsmCodegenMethods;
|
||||||
use crate::traits::{GlobalAsmOperandRef, MiscCodegenMethods};
|
use crate::traits::GlobalAsmOperandRef;
|
||||||
|
|
||||||
pub(crate) fn codegen_naked_asm<
|
pub(crate) fn codegen_naked_asm<
|
||||||
'a,
|
'a,
|
||||||
'tcx,
|
'tcx,
|
||||||
Cx: LayoutOf<'tcx, LayoutOfResult = TyAndLayout<'tcx>>
|
Cx: LayoutOf<'tcx, LayoutOfResult = TyAndLayout<'tcx>>
|
||||||
+ FnAbiOf<'tcx, FnAbiOfResult = &'tcx FnAbi<'tcx, Ty<'tcx>>>
|
+ FnAbiOf<'tcx, FnAbiOfResult = &'tcx FnAbi<'tcx, Ty<'tcx>>>
|
||||||
+ AsmCodegenMethods<'tcx>
|
+ AsmCodegenMethods<'tcx>,
|
||||||
+ MiscCodegenMethods<'tcx>,
|
|
||||||
>(
|
>(
|
||||||
cx: &'a Cx,
|
cx: &'a Cx,
|
||||||
instance: Instance<'tcx>,
|
instance: Instance<'tcx>,
|
||||||
|
item_data: MonoItemData,
|
||||||
) {
|
) {
|
||||||
assert!(!instance.args.has_infer());
|
assert!(!instance.args.has_infer());
|
||||||
let mir = cx.tcx().instance_mir(instance.def);
|
let mir = cx.tcx().instance_mir(instance.def);
|
||||||
@ -44,7 +44,6 @@ pub(crate) fn codegen_naked_asm<
|
|||||||
let operands: Vec<_> =
|
let operands: Vec<_> =
|
||||||
operands.iter().map(|op| inline_to_global_operand::<Cx>(cx, instance, op)).collect();
|
operands.iter().map(|op| inline_to_global_operand::<Cx>(cx, instance, op)).collect();
|
||||||
|
|
||||||
let item_data = cx.codegen_unit().items().get(&MonoItem::Fn(instance)).unwrap();
|
|
||||||
let name = cx.mangled_name(instance);
|
let name = cx.mangled_name(instance);
|
||||||
let fn_abi = cx.fn_abi_of_instance(instance, ty::List::empty());
|
let fn_abi = cx.fn_abi_of_instance(instance, ty::List::empty());
|
||||||
let (begin, end) = prefix_and_suffix(cx.tcx(), instance, &name, item_data, fn_abi);
|
let (begin, end) = prefix_and_suffix(cx.tcx(), instance, &name, item_data, fn_abi);
|
||||||
@ -118,7 +117,7 @@ fn prefix_and_suffix<'tcx>(
|
|||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
instance: Instance<'tcx>,
|
instance: Instance<'tcx>,
|
||||||
asm_name: &str,
|
asm_name: &str,
|
||||||
item_data: &MonoItemData,
|
item_data: MonoItemData,
|
||||||
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
|
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
|
||||||
) -> (String, String) {
|
) -> (String, String) {
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||||
use rustc_middle::mir::interpret::ErrorHandled;
|
use rustc_middle::mir::interpret::ErrorHandled;
|
||||||
use rustc_middle::mir::mono::{Linkage, MonoItem, Visibility};
|
use rustc_middle::mir::mono::{Linkage, MonoItem, MonoItemData, Visibility};
|
||||||
use rustc_middle::ty::Instance;
|
use rustc_middle::ty::Instance;
|
||||||
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf};
|
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf};
|
||||||
use rustc_middle::{span_bug, ty};
|
use rustc_middle::{span_bug, ty};
|
||||||
@ -12,7 +12,7 @@ use crate::traits::*;
|
|||||||
use crate::{base, common};
|
use crate::{base, common};
|
||||||
|
|
||||||
pub trait MonoItemExt<'a, 'tcx> {
|
pub trait MonoItemExt<'a, 'tcx> {
|
||||||
fn define<Bx: BuilderMethods<'a, 'tcx>>(&self, cx: &'a Bx::CodegenCx);
|
fn define<Bx: BuilderMethods<'a, 'tcx>>(&self, cx: &'a Bx::CodegenCx, item_data: MonoItemData);
|
||||||
fn predefine<Bx: BuilderMethods<'a, 'tcx>>(
|
fn predefine<Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
&self,
|
&self,
|
||||||
cx: &'a Bx::CodegenCx,
|
cx: &'a Bx::CodegenCx,
|
||||||
@ -23,7 +23,7 @@ pub trait MonoItemExt<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
|
impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
|
||||||
fn define<Bx: BuilderMethods<'a, 'tcx>>(&self, cx: &'a Bx::CodegenCx) {
|
fn define<Bx: BuilderMethods<'a, 'tcx>>(&self, cx: &'a Bx::CodegenCx, item_data: MonoItemData) {
|
||||||
debug!(
|
debug!(
|
||||||
"BEGIN IMPLEMENTING '{} ({})' in cgu {}",
|
"BEGIN IMPLEMENTING '{} ({})' in cgu {}",
|
||||||
self,
|
self,
|
||||||
@ -106,7 +106,7 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
|
|||||||
.flags
|
.flags
|
||||||
.contains(CodegenFnAttrFlags::NAKED)
|
.contains(CodegenFnAttrFlags::NAKED)
|
||||||
{
|
{
|
||||||
naked_asm::codegen_naked_asm::<Bx::CodegenCx>(cx, instance);
|
naked_asm::codegen_naked_asm::<Bx::CodegenCx>(cx, instance, item_data);
|
||||||
} else {
|
} else {
|
||||||
base::codegen_instance::<Bx>(cx, instance);
|
base::codegen_instance::<Bx>(cx, instance);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user