Skip to content

Commit

Permalink
compiler: remove rustc_target::abi entirely
Browse files Browse the repository at this point in the history
  • Loading branch information
workingjubilee committed Feb 7, 2025
1 parent 3948be6 commit 1f37b9a
Show file tree
Hide file tree
Showing 80 changed files with 129 additions and 87 deletions.
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4015,6 +4015,7 @@ version = "0.0.0"
dependencies = [
"rustc-rayon",
"rustc-rayon-core",
"rustc_abi",
"rustc_ast",
"rustc_ast_lowering",
"rustc_ast_passes",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/traits/consts.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rustc_abi as abi;
use rustc_middle::mir::interpret::{ConstAllocation, Scalar};
use rustc_target::abi;

use super::BackendTypes;

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"
# tidy-alphabetical-start
rustc-rayon = { version = "0.5.0" }
rustc-rayon-core = { version = "0.5.0" }
rustc_abi = { path = "../rustc_abi" }
rustc_ast = { path = "../rustc_ast" }
rustc_ast_lowering = { path = "../rustc_ast_lowering" }
rustc_ast_passes = { path = "../rustc_ast_passes" }
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::num::NonZero;
use std::path::{Path, PathBuf};
use std::sync::atomic::AtomicBool;

use rustc_abi::Align;
use rustc_data_structures::profiling::TimePassesFormat;
use rustc_errors::emitter::HumanReadableErrorType;
use rustc_errors::{ColorConfig, registry};
Expand All @@ -24,7 +25,6 @@ use rustc_session::{CompilerIO, EarlyDiagCtxt, Session, build_session, filesearc
use rustc_span::edition::{DEFAULT_EDITION, Edition};
use rustc_span::source_map::{RealFileLoader, SourceMapInputs};
use rustc_span::{FileName, SourceFileHashAlgorithm, sym};
use rustc_target::abi::Align;
use rustc_target::spec::{
CodeModel, FramePointer, LinkerFlavorCli, MergeFunctions, OnBrokenPipe, PanicStrategy,
RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TlsModel, WasmCAbi,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_monomorphize/src/mono_checks/abi_check.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//! This module ensures that if a function's ABI requires a particular target feature,
//! that target feature is enabled both on the callee and all callers.
use rustc_abi::{BackendRepr, RegKind};
use rustc_hir::CRATE_HIR_ID;
use rustc_middle::mir::{self, traversal};
use rustc_middle::ty::inherent::*;
use rustc_middle::ty::{self, Instance, InstanceKind, Ty, TyCtxt};
use rustc_session::lint::builtin::ABI_UNSUPPORTED_VECTOR_TYPES;
use rustc_span::def_id::DefId;
use rustc_span::{DUMMY_SP, Span, Symbol};
use rustc_target::abi::call::{FnAbi, PassMode};
use rustc_target::abi::{BackendRepr, RegKind};
use rustc_target::callconv::{FnAbi, PassMode};

use crate::errors::{
AbiErrorDisabledVectorTypeCall, AbiErrorDisabledVectorTypeDef,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/abi_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_middle::ty::layout::{FnAbiError, LayoutError};
use rustc_middle::ty::{self, GenericArgs, Instance, Ty, TyCtxt};
use rustc_span::source_map::Spanned;
use rustc_span::sym;
use rustc_target::abi::call::FnAbi;
use rustc_target::callconv::FnAbi;

use super::layout_test::ensure_wf;
use crate::errors::{AbiInvalidAttribute, AbiNe, AbiOf, UnrecognizedField};
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use std::cell::Cell;
use std::collections::hash_map::Entry;

use rustc_abi::{ExternAbi, Size};
use rustc_ast::{AttrStyle, LitKind, MetaItemInner, MetaItemKind, MetaItemLit, ast};
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{Applicability, DiagCtxtHandle, IntoDiagArg, MultiSpan, StashKey};
Expand All @@ -32,8 +33,6 @@ use rustc_session::lint::builtin::{
};
use rustc_session::parse::feature_err;
use rustc_span::{BytePos, DUMMY_SP, Span, Symbol, kw, sym};
use rustc_target::abi::Size;
use rustc_target::spec::abi::Abi;
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::infer::{TyCtxtInferExt, ValuePairs};
use rustc_trait_selection::traits::ObligationCtxt;
Expand Down Expand Up @@ -1519,7 +1518,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
if target == Target::ForeignMod
&& let hir::Node::Item(item) = self.tcx.hir_node(hir_id)
&& let Item { kind: ItemKind::ForeignMod { abi, .. }, .. } = item
&& !matches!(abi, Abi::Rust | Abi::RustIntrinsic)
&& !matches!(abi, ExternAbi::Rust | ExternAbi::RustIntrinsic)
{
return;
}
Expand Down Expand Up @@ -2445,7 +2444,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
token_stream,
false,
Safety::Safe,
Abi::Rust,
ExternAbi::Rust,
);

if let Err(terr) = ocx.eq(&cause, param_env, expected_sig, sig) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::iter;

use rustc_abi::{BackendRepr, HasDataLayout, Primitive, TyAbiInterface};

use crate::abi::call::{ArgAbi, FnAbi, Reg, RegKind, Uniform};
use crate::callconv::{ArgAbi, FnAbi, Reg, RegKind, Uniform};
use crate::spec::{HasTargetSpec, Target};

/// Indicates the variant of the AArch64 ABI we are compiling for.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/amdgpu.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rustc_abi::{HasDataLayout, TyAbiInterface};

use crate::abi::call::{ArgAbi, FnAbi};
use crate::callconv::{ArgAbi, FnAbi};

fn classify_ret<'a, Ty, C>(_cx: &C, ret: &mut ArgAbi<'a, Ty>)
where
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/arm.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rustc_abi::{HasDataLayout, TyAbiInterface};

use crate::abi::call::{ArgAbi, Conv, FnAbi, Reg, RegKind, Uniform};
use crate::callconv::{ArgAbi, Conv, FnAbi, Reg, RegKind, Uniform};
use crate::spec::HasTargetSpec;

fn is_homogeneous_aggregate<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>) -> Option<Uniform>
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/avr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
//! compatible with AVR-GCC - Rust and AVR-GCC only differ in the small amount
//! of compiler frontend specific calling convention logic implemented here.
use crate::abi::call::{ArgAbi, FnAbi};
use crate::callconv::{ArgAbi, FnAbi};

fn classify_ret_ty<Ty>(ret: &mut ArgAbi<'_, Ty>) {
if ret.layout.is_aggregate() {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/bpf.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// see https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/BPF/BPFCallingConv.td
use crate::abi::call::{ArgAbi, FnAbi};
use crate::callconv::{ArgAbi, FnAbi};

fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) {
if ret.layout.is_aggregate() || ret.layout.size.bits() > 64 {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/csky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Reference: Clang CSKY lowering code
// https://github.com/llvm/llvm-project/blob/4a074f32a6914f2a8d7215d78758c24942dddc3d/clang/lib/CodeGen/Targets/CSKY.cpp#L76-L162

use crate::abi::call::{ArgAbi, FnAbi, Reg, Uniform};
use crate::callconv::{ArgAbi, FnAbi, Reg, Uniform};

fn classify_ret<Ty>(arg: &mut ArgAbi<'_, Ty>) {
if !arg.layout.is_sized() {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/hexagon.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::abi::call::{ArgAbi, FnAbi};
use crate::callconv::{ArgAbi, FnAbi};

fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) {
if ret.layout.is_aggregate() && ret.layout.size.bits() > 64 {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/m68k.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::abi::call::{ArgAbi, FnAbi};
use crate::callconv::{ArgAbi, FnAbi};

fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) {
if ret.layout.is_aggregate() {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/mips.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rustc_abi::{HasDataLayout, Size};

use crate::abi::call::{ArgAbi, FnAbi, Reg, Uniform};
use crate::callconv::{ArgAbi, FnAbi, Reg, Uniform};

fn classify_ret<Ty, C>(cx: &C, ret: &mut ArgAbi<'_, Ty>, offset: &mut Size)
where
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/msp430.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Reference: MSP430 Embedded Application Binary Interface
// https://www.ti.com/lit/an/slaa534a/slaa534a.pdf

use crate::abi::call::{ArgAbi, FnAbi};
use crate::callconv::{ArgAbi, FnAbi};

// 3.5 Structures or Unions Passed and Returned by Reference
//
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/nvptx64.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rustc_abi::{HasDataLayout, Reg, Size, TyAbiInterface};

use super::{ArgAttribute, ArgAttributes, ArgExtension, CastTarget};
use crate::abi::call::{ArgAbi, FnAbi, Uniform};
use crate::callconv::{ArgAbi, FnAbi, Uniform};

fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) {
if ret.layout.is_aggregate() && ret.layout.is_sized() {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/powerpc.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::abi::call::{ArgAbi, FnAbi};
use crate::callconv::{ArgAbi, FnAbi};
use crate::spec::HasTargetSpec;

fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/powerpc64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use rustc_abi::{Endian, HasDataLayout, TyAbiInterface};

use crate::abi::call::{Align, ArgAbi, FnAbi, Reg, RegKind, Uniform};
use crate::callconv::{Align, ArgAbi, FnAbi, Reg, RegKind, Uniform};
use crate::spec::HasTargetSpec;

#[derive(Debug, Clone, Copy, PartialEq)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/riscv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_abi::{
TyAbiInterface, TyAndLayout, Variants,
};

use crate::abi::call::{ArgAbi, ArgExtension, CastTarget, FnAbi, PassMode, Uniform};
use crate::callconv::{ArgAbi, ArgExtension, CastTarget, FnAbi, PassMode, Uniform};
use crate::spec::HasTargetSpec;

#[derive(Copy, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/s390x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use rustc_abi::{BackendRepr, HasDataLayout, TyAbiInterface};

use crate::abi::call::{ArgAbi, FnAbi, Reg, RegKind};
use crate::callconv::{ArgAbi, FnAbi, Reg, RegKind};
use crate::spec::HasTargetSpec;

fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/sparc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rustc_abi::{HasDataLayout, Size};

use crate::abi::call::{ArgAbi, FnAbi, Reg, Uniform};
use crate::callconv::{ArgAbi, FnAbi, Reg, Uniform};

fn classify_ret<Ty, C>(cx: &C, ret: &mut ArgAbi<'_, Ty>, offset: &mut Size)
where
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/sparc64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rustc_abi::{
TyAndLayout,
};

use crate::abi::call::{
use crate::callconv::{
ArgAbi, ArgAttribute, ArgAttributes, ArgExtension, CastTarget, FnAbi, Uniform,
};
use crate::spec::HasTargetSpec;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/wasm.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rustc_abi::{BackendRepr, Float, HasDataLayout, Integer, Primitive, TyAbiInterface};

use crate::abi::call::{ArgAbi, FnAbi};
use crate::callconv::{ArgAbi, FnAbi};

fn unwrap_trivial_aggregate<'a, Ty, C>(cx: &C, val: &mut ArgAbi<'a, Ty>) -> bool
where
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use rustc_abi::{
TyAbiInterface, TyAndLayout,
};

use crate::abi::call::{ArgAttribute, FnAbi, PassMode};
use crate::callconv::{ArgAttribute, FnAbi, PassMode};
use crate::spec::HasTargetSpec;

#[derive(PartialEq)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_abi::{
Variants,
};

use crate::abi::call::{ArgAbi, CastTarget, FnAbi};
use crate::callconv::{ArgAbi, CastTarget, FnAbi};

/// Classification of "eightbyte" components.
// N.B., the order of the variants is from general to specific,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/x86_win64.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rustc_abi::{BackendRepr, Float, Integer, Primitive, RegKind, Size};

use crate::abi::call::{ArgAbi, FnAbi, Reg};
use crate::callconv::{ArgAbi, FnAbi, Reg};
use crate::spec::HasTargetSpec;

// Win64 ABI: https://docs.microsoft.com/en-us/cpp/build/parameter-passing
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/callconv/xtensa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use rustc_abi::{BackendRepr, HasDataLayout, Size, TyAbiInterface};

use crate::abi::call::{ArgAbi, FnAbi, Reg, Uniform};
use crate::callconv::{ArgAbi, FnAbi, Reg, Uniform};
use crate::spec::HasTargetSpec;

const NUM_ARG_GPRS: u64 = 6;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl<A: ToJson> ToJson for Option<A> {
}
}

impl ToJson for crate::abi::call::Conv {
impl ToJson for crate::callconv::Conv {
fn to_json(&self) -> Json {
let buf: String;
let s = match self {
Expand Down
6 changes: 0 additions & 6 deletions compiler/rustc_target/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ pub mod target_features;
#[cfg(test)]
mod tests;

pub mod abi {
pub use rustc_abi::*;

pub use crate::callconv as call;
}

pub use rustc_abi::HashStableContext;

/// The name of rustc's own place to organize libraries.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use rustc_span::{Symbol, kw, sym};
use serde_json::Value;
use tracing::debug;

use crate::abi::call::Conv;
use crate::callconv::Conv;
use crate::json::{Json, ToJson};
use crate::spec::crt_objects::CrtObjects;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::abi::Endian;
use rustc_abi::Endian;

use crate::spec::{StackProbeType, Target, TargetOptions, base};

pub(crate) fn target() -> Target {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::abi::Endian;
use rustc_abi::Endian;

use crate::spec::{StackProbeType, Target, TargetOptions, base};

pub(crate) fn target() -> Target {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::abi::Endian;
use rustc_abi::Endian;

use crate::spec::{StackProbeType, Target, TargetOptions, base};

pub(crate) fn target() -> Target {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::abi::Endian;
use rustc_abi::Endian;

use crate::spec::{FloatAbi, Target, TargetOptions, base};

pub(crate) fn target() -> Target {
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_target/src/spec/targets/armebv7r_none_eabi.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Targets the Big endian Cortex-R4/R5 processor (ARMv7-R)

use crate::abi::Endian;
use rustc_abi::Endian;

use crate::spec::{
Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Targets the Cortex-R4F/R5F processor (ARMv7-R)

use crate::abi::Endian;
use rustc_abi::Endian;

use crate::spec::{
Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::abi::Endian;
use rustc_abi::Endian;

use crate::spec::{Cc, FloatAbi, LinkerFlavor, Lld, RelocModel, Target, TargetOptions, cvs};

/// A base target for PlayStation Vita devices using the VITASDK toolchain (using newlib).
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_target/src/spec/targets/bpfeb_unknown_none.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::abi::Endian;
use rustc_abi::Endian;

use crate::spec::{Target, base};

pub(crate) fn target() -> Target {
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_target/src/spec/targets/bpfel_unknown_none.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::abi::Endian;
use rustc_abi::Endian;

use crate::spec::{Target, base};

pub(crate) fn target() -> Target {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::abi::Endian;
use rustc_abi::Endian;

use crate::spec::{LinkSelfContainedDefault, Target, TargetOptions, base};

pub(crate) fn target() -> Target {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::abi::Endian;
use rustc_abi::Endian;

use crate::spec::{CodeModel, PanicStrategy, RelocModel, Target, TargetOptions};

pub(crate) fn target() -> Target {
Expand Down
Loading

0 comments on commit 1f37b9a

Please sign in to comment.