compiler: rustc_abi::Abi => BackendRepr
The initial naming of "Abi" was an awful mistake, conveying wrong ideas about how psABIs worked and even more about what the enum meant. It was only meant to represent the way the value would be described to a codegen backend as it was lowered to that intermediate representation. It was never meant to mean anything about the actual psABI handling! The conflation is because LLVM typically will associate a certain form with a certain ABI, but even that does not hold when the special cases that actually exist arise, plus the IR annotations that modify the ABI. Reframe `rustc_abi::Abi` as the `BackendRepr` of the type, and rename `BackendRepr::Aggregate` as `BackendRepr::Memory`. Unfortunately, due to the persistent misunderstandings, this too is now incorrect: - Scattered ABI-relevant code is entangled with BackendRepr - We do not always pre-compute a correct BackendRepr that reflects how we "actually" want this value to be handled, so we leave the backend interface to also inject various special-cases here - In some cases `BackendRepr::Memory` is a "real" aggregate, but in others it is in fact using memory, and in some cases it is a scalar! Our rustc-to-backend lowering code handles this sort of thing right now. That will eventually be addressed by lifting duplicated lowering code to either rustc_codegen_ssa or rustc_target as appropriate.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use std::sync::atomic::Ordering::Relaxed;
|
||||
|
||||
use either::{Left, Right};
|
||||
use rustc_abi::{self as abi, BackendRepr};
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::mir::interpret::{AllocId, ErrorHandled, InterpErrorInfo};
|
||||
@@ -12,7 +13,6 @@ use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_span::def_id::LocalDefId;
|
||||
use rustc_span::{DUMMY_SP, Span};
|
||||
use rustc_target::abi::{self, Abi};
|
||||
use tracing::{debug, instrument, trace};
|
||||
|
||||
use super::{CanAccessMutGlobal, CompileTimeInterpCx, CompileTimeMachine};
|
||||
@@ -174,8 +174,8 @@ pub(super) fn op_to_const<'tcx>(
|
||||
// type (it's used throughout the compiler and having it work just on literals is not enough)
|
||||
// and we want it to be fast (i.e., don't go to an `Allocation` and reconstruct the `Scalar`
|
||||
// from its byte-serialized form).
|
||||
let force_as_immediate = match op.layout.abi {
|
||||
Abi::Scalar(abi::Scalar::Initialized { .. }) => true,
|
||||
let force_as_immediate = match op.layout.backend_repr {
|
||||
BackendRepr::Scalar(abi::Scalar::Initialized { .. }) => true,
|
||||
// We don't *force* `ConstValue::Slice` for `ScalarPair`. This has the advantage that if the
|
||||
// input `op` is a place, then turning it into a `ConstValue` and back into a `OpTy` will
|
||||
// not have to generate any duplicate allocations (we preserve the original `AllocId` in
|
||||
|
||||
Reference in New Issue
Block a user