Skip to content

Commit 47c33f7

Browse files
committed
rustc_trans: adjust mips64 abi to use new CastTarget
1 parent 05d66dc commit 47c33f7

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/librustc_trans/cabi_mips64.rs

+15-9
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn classify_ret_ty<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, ret: &mut ArgType<'tcx>)
7373
} else if ret.layout.fields.count() == 2 {
7474
if let Some(reg0) = float_reg(cx, ret, 0) {
7575
if let Some(reg1) = float_reg(cx, ret, 1) {
76-
ret.cast_to(CastTarget::Pair(reg0, reg1));
76+
ret.cast_to(CastTarget::pair(reg0, reg1));
7777
return;
7878
}
7979
}
@@ -98,7 +98,7 @@ fn classify_arg_ty<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, arg: &mut ArgType<'tcx>)
9898

9999
let dl = &cx.tcx.data_layout;
100100
let size = arg.layout.size;
101-
let mut prefix = [RegKind::Integer; 8];
101+
let mut prefix = [None; 8];
102102
let mut prefix_index = 0;
103103

104104
match arg.layout.fields {
@@ -123,15 +123,20 @@ fn classify_arg_ty<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, arg: &mut ArgType<'tcx>)
123123
if let layout::Abi::Scalar(ref scalar) = field.abi {
124124
if let layout::F64 = scalar.value {
125125
if offset.is_abi_aligned(dl.f64_align) {
126-
// Skip over enough integers to cover [last_offset, offset)
126+
// Insert enough integers to cover [last_offset, offset)
127127
assert!(last_offset.is_abi_aligned(dl.f64_align));
128-
prefix_index += ((offset - last_offset).bits() / 64) as usize;
128+
for _ in 0..((offset - last_offset).bits() / 64)
129+
.min((prefix.len() - prefix_index) as u64) {
129130

130-
if prefix_index >= prefix.len() {
131+
prefix[prefix_index] = Some(RegKind::Integer);
132+
prefix_index += 1;
133+
}
134+
135+
if prefix_index == prefix.len() {
131136
break;
132137
}
133138

134-
prefix[prefix_index] = RegKind::Float;
139+
prefix[prefix_index] = Some(RegKind::Float);
135140
prefix_index += 1;
136141
last_offset = offset + Reg::f64().size;
137142
}
@@ -142,10 +147,11 @@ fn classify_arg_ty<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, arg: &mut ArgType<'tcx>)
142147
};
143148

144149
// Extract first 8 chunks as the prefix
145-
arg.cast_to(CastTarget::ChunkedPrefix {
150+
let rest_size = size - Size::from_bytes(8) * prefix_index as u64;
151+
arg.cast_to(CastTarget {
146152
prefix: prefix,
147-
chunk: Size::from_bytes(8),
148-
total: size
153+
prefix_chunk: Size::from_bytes(8),
154+
rest: Uniform { unit: Reg::i64(), total: rest_size }
149155
});
150156
}
151157

0 commit comments

Comments
 (0)