Skip to content

Commit 6d122ab

Browse files
committed
Rename AddressSpace::DATA to AddressSpace::ZERO
1 parent dddd7ab commit 6d122ab

File tree

8 files changed

+15
-15
lines changed

8 files changed

+15
-15
lines changed

compiler/rustc_abi/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ impl Default for TargetDataLayout {
274274
(Size::from_bits(64), AbiAlign::new(align(64))),
275275
(Size::from_bits(128), AbiAlign::new(align(128))),
276276
],
277-
instruction_address_space: AddressSpace::DATA,
277+
instruction_address_space: AddressSpace::ZERO,
278278
c_enum_min_size: Integer::I32,
279279
}
280280
}
@@ -1422,8 +1422,8 @@ impl<FieldIdx: Idx> FieldsShape<FieldIdx> {
14221422
pub struct AddressSpace(pub u32);
14231423

14241424
impl AddressSpace {
1425-
/// The default address space, corresponding to data space.
1426-
pub const DATA: Self = AddressSpace(0);
1425+
/// LLVM's `0` address space.
1426+
pub const ZERO: Self = AddressSpace(0);
14271427
}
14281428

14291429
/// The way we represent values to the backend

compiler/rustc_codegen_llvm/src/type_.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ impl<'ll, CX: Borrow<SCx<'ll>>> BaseTypeCodegenMethods for GenericCx<'ll, CX> {
208208
}
209209

210210
fn type_ptr(&self) -> &'ll Type {
211-
self.type_ptr_ext(AddressSpace::DATA)
211+
self.type_ptr_ext(AddressSpace::ZERO)
212212
}
213213

214214
fn type_ptr_ext(&self, address_space: AddressSpace) -> &'ll Type {
@@ -258,7 +258,7 @@ impl Type {
258258
}
259259

260260
pub(crate) fn ptr_llcx(llcx: &llvm::Context) -> &Type {
261-
unsafe { llvm::LLVMPointerTypeInContext(llcx, AddressSpace::DATA.0) }
261+
unsafe { llvm::LLVMPointerTypeInContext(llcx, AddressSpace::ZERO.0) }
262262
}
263263
}
264264

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@ fn assume_scalar_range<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
11921192
let range = scalar.valid_range(bx.cx());
11931193
bx.assume_integer_range(imm, backend_ty, range);
11941194
}
1195-
abi::Primitive::Pointer(abi::AddressSpace::DATA)
1195+
abi::Primitive::Pointer(abi::AddressSpace::ZERO)
11961196
if !scalar.valid_range(bx.cx()).contains(0) =>
11971197
{
11981198
bx.assume_nonnull(imm);

compiler/rustc_middle/src/mir/interpret/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ impl<'tcx> GlobalAlloc<'tcx> {
297297
match self {
298298
GlobalAlloc::Function { .. } => cx.data_layout().instruction_address_space,
299299
GlobalAlloc::Static(..) | GlobalAlloc::Memory(..) | GlobalAlloc::VTable(..) => {
300-
AddressSpace::DATA
300+
AddressSpace::ZERO
301301
}
302302
}
303303
}

compiler/rustc_middle/src/ty/layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ where
10821082
if let Some(variant) = data_variant {
10831083
// FIXME(erikdesjardins): handle non-default addrspace ptr sizes
10841084
// (requires passing in the expected address space from the caller)
1085-
let ptr_end = offset + Primitive::Pointer(AddressSpace::DATA).size(cx);
1085+
let ptr_end = offset + Primitive::Pointer(AddressSpace::ZERO).size(cx);
10861086
for i in 0..variant.fields.count() {
10871087
let field_start = variant.fields.offset(i);
10881088
if field_start <= offset {

compiler/rustc_target/src/callconv/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
733733
}
734734

735735
if arg_idx.is_none()
736-
&& arg.layout.size > Primitive::Pointer(AddressSpace::DATA).size(cx) * 2
736+
&& arg.layout.size > Primitive::Pointer(AddressSpace::ZERO).size(cx) * 2
737737
&& !matches!(arg.layout.backend_repr, BackendRepr::SimdVector { .. })
738738
{
739739
// Return values larger than 2 registers using a return area
@@ -792,7 +792,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
792792

793793
let size = arg.layout.size;
794794
if arg.layout.is_sized()
795-
&& size <= Primitive::Pointer(AddressSpace::DATA).size(cx)
795+
&& size <= Primitive::Pointer(AddressSpace::ZERO).size(cx)
796796
{
797797
// We want to pass small aggregates as immediates, but using
798798
// an LLVM aggregate type for this leads to bad optimizations,

compiler/rustc_target/src/callconv/x86.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ where
219219
// SSE ABI. We prefer this over integer registers as float scalars need to be in SSE
220220
// registers for float operations, so that's the best place to pass them around.
221221
fn_abi.ret.cast_to(Reg { kind: RegKind::Vector, size: fn_abi.ret.layout.size });
222-
} else if fn_abi.ret.layout.size <= Primitive::Pointer(AddressSpace::DATA).size(cx) {
222+
} else if fn_abi.ret.layout.size <= Primitive::Pointer(AddressSpace::ZERO).size(cx) {
223223
// Same size or smaller than pointer, return in an integer register.
224224
fn_abi.ret.cast_to(Reg { kind: RegKind::Integer, size: fn_abi.ret.layout.size });
225225
} else {

compiler/rustc_ty_utils/src/layout.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ fn layout_of_uncached<'tcx>(
379379

380380
// Potentially-wide pointers.
381381
ty::Ref(_, pointee, _) | ty::RawPtr(pointee, _) => {
382-
let mut data_ptr = scalar_unit(Pointer(AddressSpace::DATA));
382+
let mut data_ptr = scalar_unit(Pointer(AddressSpace::ZERO));
383383
if !ty.is_raw_ptr() {
384384
data_ptr.valid_range_mut().start = 1;
385385
}
@@ -435,7 +435,7 @@ fn layout_of_uncached<'tcx>(
435435
}
436436
ty::Slice(_) | ty::Str => scalar_unit(Int(dl.ptr_sized_integer(), false)),
437437
ty::Dynamic(..) => {
438-
let mut vtable = scalar_unit(Pointer(AddressSpace::DATA));
438+
let mut vtable = scalar_unit(Pointer(AddressSpace::ZERO));
439439
vtable.valid_range_mut().start = 1;
440440
vtable
441441
}
@@ -450,9 +450,9 @@ fn layout_of_uncached<'tcx>(
450450
}
451451

452452
ty::Dynamic(_, _, ty::DynStar) => {
453-
let mut data = scalar_unit(Pointer(AddressSpace::DATA));
453+
let mut data = scalar_unit(Pointer(AddressSpace::ZERO));
454454
data.valid_range_mut().start = 0;
455-
let mut vtable = scalar_unit(Pointer(AddressSpace::DATA));
455+
let mut vtable = scalar_unit(Pointer(AddressSpace::ZERO));
456456
vtable.valid_range_mut().start = 1;
457457
tcx.mk_layout(LayoutData::scalar_pair(cx, data, vtable))
458458
}

0 commit comments

Comments
 (0)