Skip to content

Commit bdebe92

Browse files
crabtwbrson
authored andcommitted
add forgotten index and fix array type
1 parent d0d7183 commit bdebe92

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/rustc/middle/trans/native.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ fn classify_ty(ty: TypeRef) -> [x86_64_reg_class] {
163163
}
164164

165165
fn classify(ty: TypeRef,
166-
cls: [mut x86_64_reg_class], i: uint,
166+
cls: [mut x86_64_reg_class], ix: uint,
167167
off: uint) {
168168
let t_align = ty_align(ty);
169169
let t_size = ty_size(ty);
@@ -173,7 +173,7 @@ fn classify_ty(ty: TypeRef) -> [x86_64_reg_class] {
173173
let mut i = off / 8u;
174174
let e = (off + t_size + 7u) / 8u;
175175
while i < e {
176-
unify(cls, i, memory_class);
176+
unify(cls, ix + i, memory_class);
177177
i += 1u;
178178
}
179179
ret;
@@ -182,30 +182,30 @@ fn classify_ty(ty: TypeRef) -> [x86_64_reg_class] {
182182
alt llvm::LLVMGetTypeKind(ty) as int {
183183
8 /* integer */ |
184184
12 /* pointer */ {
185-
unify(cls, off / 8u, integer_class);
185+
unify(cls, ix + off / 8u, integer_class);
186186
}
187187
2 /* float */ {
188188
if off % 8u == 4u {
189-
unify(cls, off / 8u, sse_fv_class);
189+
unify(cls, ix + off / 8u, sse_fv_class);
190190
} else {
191-
unify(cls, off / 8u, sse_fs_class);
191+
unify(cls, ix + off / 8u, sse_fs_class);
192192
}
193193
}
194194
3 /* double */ {
195-
unify(cls, off / 8u, sse_ds_class);
195+
unify(cls, ix + off / 8u, sse_ds_class);
196196
}
197197
10 /* struct */ {
198-
classify_struct(struct_tys(ty), cls, i, off);
198+
classify_struct(struct_tys(ty), cls, ix, off);
199199
}
200200
11 /* array */ {
201-
// FIXME: I HAVE NO IDEA WHAT I AM DOING THIS MUST BE WRONG
202-
let len = llvm::LLVMGetArrayLength(ty) as uint;
203-
if len == 0u {
204-
} else {
205-
let elt = llvm::LLVMGetElementType(ty);
206-
let tys = vec::from_elem(len, elt);
207-
classify_struct(tys, cls, i, off);
208-
}
201+
let elt = llvm::LLVMGetElementType(ty);
202+
let eltsz = ty_size(elt);
203+
let len = llvm::LLVMGetArrayLength(ty) as uint;
204+
let mut i = 0u;
205+
while i < len {
206+
classify(elt, cls, ix, off + i * eltsz);
207+
i += 1u;
208+
}
209209
}
210210
_ {
211211
fail "classify: unhandled type";
@@ -215,9 +215,11 @@ fn classify_ty(ty: TypeRef) -> [x86_64_reg_class] {
215215

216216
fn fixup(ty: TypeRef, cls: [mut x86_64_reg_class]) {
217217
let mut i = 0u;
218+
let llty = llvm::LLVMGetTypeKind(ty) as int;
218219
let e = vec::len(cls);
219220
if vec::len(cls) > 2u &&
220-
llvm::LLVMGetTypeKind(ty) as int == 10 /* struct */ {
221+
(llty == 10 /* struct */ ||
222+
llty == 11 /* array */) {
221223
if is_sse(cls[i]) {
222224
i += 1u;
223225
while i < e {

0 commit comments

Comments
 (0)