Skip to content

Commit fc90f6e

Browse files
rustc_abi::Abi to IrForm in cg_ssa
1 parent 11d84b0 commit fc90f6e

File tree

6 files changed

+30
-30
lines changed

6 files changed

+30
-30
lines changed

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
15321532
// the load would just produce `OperandValue::Ref` instead
15331533
// of the `OperandValue::Immediate` we need for the call.
15341534
llval = bx.load(bx.backend_type(arg.layout), llval, align);
1535-
if let abi::Abi::Scalar(scalar) = arg.layout.abi {
1535+
if let abi::IrForm::Scalar(scalar) = arg.layout.ir_form {
15361536
if scalar.is_bool() {
15371537
bx.range_metadata(llval, WrappingRange { start: 0, end: 1 });
15381538
}

compiler/rustc_codegen_ssa/src/mir/constant.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
use rustc_abi::IrForm;
12
use rustc_middle::mir::interpret::ErrorHandled;
23
use rustc_middle::ty::layout::HasTyCtxt;
34
use rustc_middle::ty::{self, Ty};
45
use rustc_middle::{bug, mir, span_bug};
5-
use rustc_target::abi::Abi;
66

77
use super::FunctionCx;
88
use crate::errors;
@@ -86,7 +86,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
8686
.map(|field| {
8787
if let Some(prim) = field.try_to_scalar() {
8888
let layout = bx.layout_of(field_ty);
89-
let Abi::Scalar(scalar) = layout.abi else {
89+
let IrForm::Scalar(scalar) = layout.ir_form else {
9090
bug!("from_const: invalid ByVal layout: {:#?}", layout);
9191
};
9292
bx.scalar_to_backend(prim, scalar, bx.immediate_backend_type(layout))

compiler/rustc_codegen_ssa/src/mir/debuginfo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::collections::hash_map::Entry;
22
use std::marker::PhantomData;
33
use std::ops::Range;
44

5+
use rustc_abi::{FieldIdx, FieldsShape, IrForm, Size, VariantIdx};
56
use rustc_data_structures::fx::FxHashMap;
67
use rustc_index::IndexVec;
78
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
@@ -11,7 +12,6 @@ use rustc_middle::{bug, mir, ty};
1112
use rustc_session::config::DebugInfo;
1213
use rustc_span::symbol::{Symbol, kw};
1314
use rustc_span::{BytePos, Span, hygiene};
14-
use rustc_target::abi::{Abi, FieldIdx, FieldsShape, Size, VariantIdx};
1515

1616
use super::operand::{OperandRef, OperandValue};
1717
use super::place::{PlaceRef, PlaceValue};
@@ -510,7 +510,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
510510
// be marked as a `LocalVariable` for MSVC debuggers to visualize
511511
// their data correctly. (See #81894 & #88625)
512512
let var_ty_layout = self.cx.layout_of(var_ty);
513-
if let Abi::ScalarPair(_, _) = var_ty_layout.abi {
513+
if let IrForm::ScalarPair(_, _) = var_ty_layout.ir_form {
514514
VariableKind::LocalVariable
515515
} else {
516516
VariableKind::ArgumentVariable(arg_index)

compiler/rustc_codegen_ssa/src/mir/operand.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::fmt;
44
use arrayvec::ArrayVec;
55
use either::Either;
66
use rustc_abi as abi;
7-
use rustc_abi::{Abi, Align, Size};
7+
use rustc_abi::{Align, IrForm, Size};
88
use rustc_middle::bug;
99
use rustc_middle::mir::interpret::{Pointer, Scalar, alloc_range};
1010
use rustc_middle::mir::{self, ConstValue};
@@ -163,15 +163,15 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
163163

164164
let val = match val {
165165
ConstValue::Scalar(x) => {
166-
let Abi::Scalar(scalar) = layout.abi else {
166+
let IrForm::Scalar(scalar) = layout.ir_form else {
167167
bug!("from_const: invalid ByVal layout: {:#?}", layout);
168168
};
169169
let llval = bx.scalar_to_backend(x, scalar, bx.immediate_backend_type(layout));
170170
OperandValue::Immediate(llval)
171171
}
172172
ConstValue::ZeroSized => return OperandRef::zero_sized(layout),
173173
ConstValue::Slice { data, meta } => {
174-
let Abi::ScalarPair(a_scalar, _) = layout.abi else {
174+
let IrForm::ScalarPair(a_scalar, _) = layout.ir_form else {
175175
bug!("from_const: invalid ScalarPair layout: {:#?}", layout);
176176
};
177177
let a = Scalar::from_pointer(
@@ -221,14 +221,14 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
221221
// case where some of the bytes are initialized and others are not. So, we need an extra
222222
// check that walks over the type of `mplace` to make sure it is truly correct to treat this
223223
// like a `Scalar` (or `ScalarPair`).
224-
match layout.abi {
225-
Abi::Scalar(s @ abi::Scalar::Initialized { .. }) => {
224+
match layout.ir_form {
225+
IrForm::Scalar(s @ abi::Scalar::Initialized { .. }) => {
226226
let size = s.size(bx);
227227
assert_eq!(size, layout.size, "abi::Scalar size does not match layout size");
228228
let val = read_scalar(offset, size, s, bx.immediate_backend_type(layout));
229229
OperandRef { val: OperandValue::Immediate(val), layout }
230230
}
231-
Abi::ScalarPair(
231+
IrForm::ScalarPair(
232232
a @ abi::Scalar::Initialized { .. },
233233
b @ abi::Scalar::Initialized { .. },
234234
) => {
@@ -322,7 +322,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
322322
llval: V,
323323
layout: TyAndLayout<'tcx>,
324324
) -> Self {
325-
let val = if let Abi::ScalarPair(..) = layout.abi {
325+
let val = if let IrForm::ScalarPair(..) = layout.ir_form {
326326
debug!("Operand::from_immediate_or_packed_pair: unpacking {:?} @ {:?}", llval, layout);
327327

328328
// Deconstruct the immediate aggregate.
@@ -343,7 +343,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
343343
let field = self.layout.field(bx.cx(), i);
344344
let offset = self.layout.fields.offset(i);
345345

346-
let mut val = match (self.val, self.layout.abi) {
346+
let mut val = match (self.val, self.layout.ir_form) {
347347
// If the field is ZST, it has no data.
348348
_ if field.is_zst() => OperandValue::ZeroSized,
349349

@@ -356,7 +356,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
356356
}
357357

358358
// Extract a scalar component from a pair.
359-
(OperandValue::Pair(a_llval, b_llval), Abi::ScalarPair(a, b)) => {
359+
(OperandValue::Pair(a_llval, b_llval), IrForm::ScalarPair(a, b)) => {
360360
if offset.bytes() == 0 {
361361
assert_eq!(field.size, a.size(bx.cx()));
362362
OperandValue::Immediate(a_llval)
@@ -368,30 +368,30 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
368368
}
369369

370370
// `#[repr(simd)]` types are also immediate.
371-
(OperandValue::Immediate(llval), Abi::Vector { .. }) => {
371+
(OperandValue::Immediate(llval), IrForm::Vector { .. }) => {
372372
OperandValue::Immediate(bx.extract_element(llval, bx.cx().const_usize(i as u64)))
373373
}
374374

375375
_ => bug!("OperandRef::extract_field({:?}): not applicable", self),
376376
};
377377

378-
match (&mut val, field.abi) {
378+
match (&mut val, field.ir_form) {
379379
(OperandValue::ZeroSized, _) => {}
380380
(
381381
OperandValue::Immediate(llval),
382-
Abi::Scalar(_) | Abi::ScalarPair(..) | Abi::Vector { .. },
382+
IrForm::Scalar(_) | IrForm::ScalarPair(..) | IrForm::Vector { .. },
383383
) => {
384384
// Bools in union fields needs to be truncated.
385385
*llval = bx.to_immediate(*llval, field);
386386
}
387-
(OperandValue::Pair(a, b), Abi::ScalarPair(a_abi, b_abi)) => {
387+
(OperandValue::Pair(a, b), IrForm::ScalarPair(a_abi, b_abi)) => {
388388
// Bools in union fields needs to be truncated.
389389
*a = bx.to_immediate_scalar(*a, a_abi);
390390
*b = bx.to_immediate_scalar(*b, b_abi);
391391
}
392392
// Newtype vector of array, e.g. #[repr(simd)] struct S([i32; 4]);
393-
(OperandValue::Immediate(llval), Abi::Aggregate { sized: true }) => {
394-
assert_matches!(self.layout.abi, Abi::Vector { .. });
393+
(OperandValue::Immediate(llval), IrForm::Memory { sized: true }) => {
394+
assert_matches!(self.layout.ir_form, IrForm::Vector { .. });
395395

396396
let llfield_ty = bx.cx().backend_type(field);
397397

@@ -400,7 +400,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
400400
bx.store(*llval, llptr, field.align.abi);
401401
*llval = bx.load(llfield_ty, llptr, field.align.abi);
402402
}
403-
(OperandValue::Immediate(_), Abi::Uninhabited | Abi::Aggregate { sized: false }) => {
403+
(OperandValue::Immediate(_), IrForm::Uninhabited | IrForm::Memory { sized: false }) => {
404404
bug!()
405405
}
406406
(OperandValue::Pair(..), _) => bug!(),
@@ -494,7 +494,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandValue<V> {
494494
bx.store_with_flags(val, dest.val.llval, dest.val.align, flags);
495495
}
496496
OperandValue::Pair(a, b) => {
497-
let Abi::ScalarPair(a_scalar, b_scalar) = dest.layout.abi else {
497+
let IrForm::ScalarPair(a_scalar, b_scalar) = dest.layout.ir_form else {
498498
bug!("store_with_flags: invalid ScalarPair layout: {:#?}", dest.layout);
499499
};
500500
let b_offset = a_scalar.size(bx).align_to(b_scalar.align(bx).abi);
@@ -645,7 +645,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
645645
// However, some SIMD types do not actually use the vector ABI
646646
// (in particular, packed SIMD types do not). Ensure we exclude those.
647647
let layout = bx.layout_of(constant_ty);
648-
if let Abi::Vector { .. } = layout.abi {
648+
if let IrForm::Vector { .. } = layout.ir_form {
649649
let (llval, ty) = self.immediate_const_vector(bx, constant);
650650
return OperandRef {
651651
val: OperandValue::Immediate(llval),

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,17 +1136,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
11361136
OperandValueKind::ZeroSized
11371137
} else if self.cx.is_backend_immediate(layout) {
11381138
assert!(!self.cx.is_backend_scalar_pair(layout));
1139-
OperandValueKind::Immediate(match layout.abi {
1140-
abi::Abi::Scalar(s) => s,
1141-
abi::Abi::Vector { element, .. } => element,
1139+
OperandValueKind::Immediate(match layout.ir_form {
1140+
abi::IrForm::Scalar(s) => s,
1141+
abi::IrForm::Vector { element, .. } => element,
11421142
x => span_bug!(self.mir.span, "Couldn't translate {x:?} as backend immediate"),
11431143
})
11441144
} else if self.cx.is_backend_scalar_pair(layout) {
1145-
let abi::Abi::ScalarPair(s1, s2) = layout.abi else {
1145+
let abi::IrForm::ScalarPair(s1, s2) = layout.ir_form else {
11461146
span_bug!(
11471147
self.mir.span,
11481148
"Couldn't translate {:?} as backend scalar pair",
1149-
layout.abi,
1149+
layout.ir_form,
11501150
);
11511151
};
11521152
OperandValueKind::Pair(s1, s2)

compiler/rustc_codegen_ssa/src/traits/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use std::assert_matches::assert_matches;
22
use std::ops::Deref;
33

4+
use rustc_abi::{Align, IrForm, Scalar, Size, WrappingRange};
45
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
56
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout};
67
use rustc_middle::ty::{Instance, Ty};
78
use rustc_session::config::OptLevel;
89
use rustc_span::Span;
910
use rustc_target::abi::call::FnAbi;
10-
use rustc_target::abi::{Abi, Align, Scalar, Size, WrappingRange};
1111

1212
use super::abi::AbiBuilderMethods;
1313
use super::asm::AsmBuilderMethods;
@@ -162,7 +162,7 @@ pub trait BuilderMethods<'a, 'tcx>:
162162

163163
fn from_immediate(&mut self, val: Self::Value) -> Self::Value;
164164
fn to_immediate(&mut self, val: Self::Value, layout: TyAndLayout<'_>) -> Self::Value {
165-
if let Abi::Scalar(scalar) = layout.abi {
165+
if let IrForm::Scalar(scalar) = layout.ir_form {
166166
self.to_immediate_scalar(val, scalar)
167167
} else {
168168
val

0 commit comments

Comments
 (0)