auto merge of #14224 : michaelwoerister/rust/simd-update, r=alexcrichton

This is a small change that improves the DWARF description of SIMD types by exposing their type name to debuginfo.
This commit is contained in:
bors 2014-05-16 23:16:22 -07:00
commit 1e0379f05b

View File

@ -1224,25 +1224,42 @@ fn create_member_descriptions(&self, cx: &CrateContext)
}
struct StructMemberDescriptionFactory {
fields: Vec<ty::field> ,
fields: Vec<ty::field>,
is_simd: bool,
span: Span,
}
impl StructMemberDescriptionFactory {
fn create_member_descriptions(&self, cx: &CrateContext)
-> Vec<MemberDescription> {
self.fields.iter().map(|field| {
fn create_member_descriptions(&self, cx: &CrateContext) -> Vec<MemberDescription> {
if self.fields.len() == 0 {
return Vec::new();
}
let field_size = if self.is_simd {
machine::llsize_of_alloc(cx, type_of::type_of(cx, self.fields.get(0).mt.ty))
} else {
0xdeadbeef
};
self.fields.iter().enumerate().map(|(i, field)| {
let name = if field.ident.name == special_idents::unnamed_field.name {
"".to_strbuf()
} else {
token::get_ident(field.ident).get().to_strbuf()
};
let offset = if self.is_simd {
assert!(field_size != 0xdeadbeef);
FixedMemberOffset { bytes: i as u64 * field_size }
} else {
ComputedMemberOffset
};
MemberDescription {
name: name,
llvm_type: type_of::type_of(cx, field.mt.ty),
type_metadata: type_metadata(cx, field.mt.ty, self.span),
offset: ComputedMemberOffset,
offset: offset,
}
}).collect()
}
@ -1278,6 +1295,7 @@ fn prepare_struct_metadata(cx: &CrateContext,
file_metadata: file_metadata,
member_description_factory: StructMD(StructMemberDescriptionFactory {
fields: fields,
is_simd: ty::type_is_simd(cx.tcx(), struct_type),
span: span,
}),
}
@ -1690,7 +1708,7 @@ fn get_enum_discriminant_name(cx: &CrateContext, def_id: ast::DefId) -> token::I
}
enum MemberOffset {
FixedMemberOffset { bytes: uint },
FixedMemberOffset { bytes: u64 },
// For ComputedMemberOffset, the offset is read from the llvm type definition
ComputedMemberOffset
}
@ -2225,13 +2243,7 @@ fn create_pointer_to_box_metadata(cx: &CrateContext,
trait_metadata(cx, def_id, t, substs, store, bounds)
}
ty::ty_struct(def_id, ref substs) => {
if ty::type_is_simd(cx.tcx(), t) {
let element_type = ty::simd_type(cx.tcx(), t);
let len = ty::simd_size(cx.tcx(), t);
fixed_vec_metadata(cx, element_type, len, usage_site_span)
} else {
prepare_struct_metadata(cx, t, def_id, substs, usage_site_span).finalize(cx)
}
prepare_struct_metadata(cx, t, def_id, substs, usage_site_span).finalize(cx)
}
ty::ty_tup(ref elements) => {
prepare_tuple_metadata(cx,