Skip to content

Commit 906cd32

Browse files
Rollup merge of #132246 - workingjubilee:campaign-on-irform, r=compiler-errors
Rename `rustc_abi::Abi` to `BackendRepr` Remove the confabulation of `rustc_abi::Abi` with what "ABI" actually means by renaming it to `BackendRepr`, and rename `Abi::Aggregate` to `BackendRepr::Memory`. The type never actually represented how things are passed, as that has to have `PassMode` considered, at minimum, but rather it just is how we represented some things to the backend. This conflation arose because LLVM, the primary backend at the time, would lower certain IR forms using certain ABIs. Even that only somewhat was true, as it broke down when one ventured significantly afield of what is described by the System V AMD64 ABI either by using different architectures, ABI-modifying IR annotations, the same architecture **with different ISA extensions enabled**, or other... unexpected delights. Unfortunately both names are still somewhat of a misnomer right now, as people have written code for years based on this misunderstanding. Still, their original names are even moreso, and for better or worse, this backend code hasn't received as much maintenance as the rest of the compiler, lately. Actually arriving at a correct end-state will simply require us to disentangle a lot of code in order to fix, much of it pointlessly repeated in several places. Thus this is not an "actual fix", just a way to deflect further misunderstandings.
2 parents 885954c + 92faf55 commit 906cd32

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

crates/hir-ty/src/layout.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use base_db::ra_salsa::Cycle;
66
use chalk_ir::{AdtId, FloatTy, IntTy, TyKind, UintTy};
77
use hir_def::{
88
layout::{
9-
Abi, FieldsShape, Float, Integer, LayoutCalculator, LayoutCalculatorError, LayoutData,
9+
BackendRepr, FieldsShape, Float, Integer, LayoutCalculator, LayoutCalculatorError, LayoutData,
1010
Primitive, ReprOptions, Scalar, Size, StructKind, TargetDataLayout, WrappingRange,
1111
},
1212
LocalFieldId, StructId,
@@ -168,7 +168,7 @@ fn layout_of_simd_ty(
168168

169169
// Compute the ABI of the element type:
170170
let e_ly = db.layout_of_ty(e_ty, env)?;
171-
let Abi::Scalar(e_abi) = e_ly.abi else {
171+
let BackendRepr::Scalar(e_abi) = e_ly.backend_repr else {
172172
return Err(LayoutError::Unknown);
173173
};
174174

@@ -190,7 +190,7 @@ fn layout_of_simd_ty(
190190
Ok(Arc::new(Layout {
191191
variants: Variants::Single { index: struct_variant_idx() },
192192
fields,
193-
abi: Abi::Vector { element: e_abi, count: e_len },
193+
backend_repr: BackendRepr::Vector { element: e_abi, count: e_len },
194194
largest_niche: e_ly.largest_niche,
195195
size,
196196
align,
@@ -294,18 +294,18 @@ pub fn layout_of_ty_query(
294294
.checked_mul(count, dl)
295295
.ok_or(LayoutError::BadCalc(LayoutCalculatorError::SizeOverflow))?;
296296

297-
let abi = if count != 0 && matches!(element.abi, Abi::Uninhabited) {
298-
Abi::Uninhabited
297+
let backend_repr = if count != 0 && matches!(element.backend_repr, BackendRepr::Uninhabited) {
298+
BackendRepr::Uninhabited
299299
} else {
300-
Abi::Aggregate { sized: true }
300+
BackendRepr::Memory { sized: true }
301301
};
302302

303303
let largest_niche = if count != 0 { element.largest_niche } else { None };
304304

305305
Layout {
306306
variants: Variants::Single { index: struct_variant_idx() },
307307
fields: FieldsShape::Array { stride: element.size, count },
308-
abi,
308+
backend_repr,
309309
largest_niche,
310310
align: element.align,
311311
size,
@@ -318,7 +318,7 @@ pub fn layout_of_ty_query(
318318
Layout {
319319
variants: Variants::Single { index: struct_variant_idx() },
320320
fields: FieldsShape::Array { stride: element.size, count: 0 },
321-
abi: Abi::Aggregate { sized: false },
321+
backend_repr: BackendRepr::Memory { sized: false },
322322
largest_niche: None,
323323
align: element.align,
324324
size: Size::ZERO,
@@ -329,7 +329,7 @@ pub fn layout_of_ty_query(
329329
TyKind::Str => Layout {
330330
variants: Variants::Single { index: struct_variant_idx() },
331331
fields: FieldsShape::Array { stride: Size::from_bytes(1), count: 0 },
332-
abi: Abi::Aggregate { sized: false },
332+
backend_repr: BackendRepr::Memory { sized: false },
333333
largest_niche: None,
334334
align: dl.i8_align,
335335
size: Size::ZERO,
@@ -379,8 +379,8 @@ pub fn layout_of_ty_query(
379379
TyKind::Never => cx.calc.layout_of_never_type(),
380380
TyKind::Dyn(_) | TyKind::Foreign(_) => {
381381
let mut unit = layout_of_unit(&cx)?;
382-
match &mut unit.abi {
383-
Abi::Aggregate { sized } => *sized = false,
382+
match &mut unit.backend_repr {
383+
BackendRepr::Memory { sized } => *sized = false,
384384
_ => return Err(LayoutError::Unknown),
385385
}
386386
unit

0 commit comments

Comments
 (0)