Skip to content

Commit d71f633

Browse files
committed
Mark scalar layout unions so that backends that do not support partially initialized scalars can special case them.
1 parent 6ce5ce8 commit d71f633

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/builder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -694,11 +694,11 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
694694
}
695695

696696
fn scalar_load_metadata<'a, 'gcc, 'tcx>(bx: &mut Builder<'a, 'gcc, 'tcx>, load: RValue<'gcc>, scalar: &abi::Scalar) {
697-
let vr = scalar.valid_range.clone();
698-
match scalar.value {
697+
let vr = scalar.valid_range(bx);
698+
match scalar.primitive() {
699699
abi::Int(..) => {
700700
if !scalar.is_always_valid(bx) {
701-
bx.range_metadata(load, scalar.valid_range);
701+
bx.range_metadata(load, vr);
702702
}
703703
}
704704
abi::Pointer if vr.start < vr.end && !vr.contains(0) => {
@@ -720,7 +720,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
720720
OperandValue::Immediate(self.to_immediate(load, place.layout))
721721
}
722722
else if let abi::Abi::ScalarPair(ref a, ref b) = place.layout.abi {
723-
let b_offset = a.value.size(self).align_to(b.value.align(self).abi);
723+
let b_offset = a.size(self).align_to(b.align(self).abi);
724724
let pair_type = place.layout.gcc_type(self, false);
725725

726726
let mut load = |i, scalar: &abi::Scalar, align| {

src/common.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,14 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
158158
}
159159

160160
fn scalar_to_backend(&self, cv: Scalar, layout: abi::Scalar, ty: Type<'gcc>) -> RValue<'gcc> {
161-
let bitsize = if layout.is_bool() { 1 } else { layout.value.size(self).bits() };
161+
let bitsize = if layout.is_bool() { 1 } else { layout.size(self).bits() };
162162
match cv {
163163
Scalar::Int(ScalarInt::ZST) => {
164-
assert_eq!(0, layout.value.size(self).bytes());
164+
assert_eq!(0, layout.size(self).bytes());
165165
self.const_undef(self.type_ix(0))
166166
}
167167
Scalar::Int(int) => {
168-
let data = int.assert_bits(layout.value.size(self));
168+
let data = int.assert_bits(layout.size(self));
169169

170170
// FIXME(antoyo): there's some issues with using the u128 code that follows, so hard-code
171171
// the paths for floating-point values.
@@ -209,7 +209,7 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
209209
let base_addr = self.const_bitcast(base_addr, self.usize_type);
210210
let offset = self.context.new_rvalue_from_long(self.usize_type, offset.bytes() as i64);
211211
let ptr = self.const_bitcast(base_addr + offset, ptr_type);
212-
if layout.value != Pointer {
212+
if layout.primitive() != Pointer {
213213
self.const_bitcast(ptr.dereference(None).to_rvalue(), ty)
214214
}
215215
else {

src/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ pub fn const_alloc_to_gcc<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, alloc: ConstAl
328328
interpret::Pointer::new(alloc_id, Size::from_bytes(ptr_offset)),
329329
&cx.tcx,
330330
),
331-
abi::Scalar { value: Primitive::Pointer, valid_range: WrappingRange { start: 0, end: !0 } },
331+
abi::Scalar::Initialized { value: Primitive::Pointer, valid_range: WrappingRange { start: 0, end: !0 } },
332332
cx.type_i8p(),
333333
));
334334
next_offset = offset + pointer_size;

src/type_of.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
224224
}
225225

226226
fn scalar_gcc_type_at<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>, scalar: &abi::Scalar, offset: Size) -> Type<'gcc> {
227-
match scalar.value {
227+
match scalar.primitive() {
228228
Int(i, true) => cx.type_from_integer(i),
229229
Int(i, false) => cx.type_from_unsigned_integer(i),
230230
F32 => cx.type_f32(),
@@ -282,7 +282,7 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
282282
Size::ZERO
283283
}
284284
else {
285-
a.value.size(cx).align_to(b.value.align(cx).abi)
285+
a.size(cx).align_to(b.align(cx).abi)
286286
};
287287
self.scalar_gcc_type_at(cx, scalar, offset)
288288
}

0 commit comments

Comments
 (0)