Skip to content

Commit

Permalink
debuginfo: Represent SIMD types as tuple structs instead of as fixed-…
Browse files Browse the repository at this point in the history
…sized arrays
  • Loading branch information
michaelwoerister committed May 15, 2014
1 parent 73a68cd commit 3fabb11
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions src/librustc/middle/trans/debuginfo.rs
Expand Up @@ -1224,25 +1224,42 @@ impl MemberDescriptionFactory {
}

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()
}
Expand Down Expand Up @@ -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,
}),
}
Expand Down Expand Up @@ -1690,7 +1708,7 @@ fn prepare_enum_metadata(cx: &CrateContext,
}

enum MemberOffset {
FixedMemberOffset { bytes: uint },
FixedMemberOffset { bytes: u64 },
// For ComputedMemberOffset, the offset is read from the llvm type definition
ComputedMemberOffset
}
Expand Down Expand Up @@ -2225,13 +2243,7 @@ fn type_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,
Expand Down

13 comments on commit 3fabb11

@bors
Copy link
Contributor

@bors bors commented on 3fabb11 May 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at michaelwoerister@3fabb11

@bors
Copy link
Contributor

@bors bors commented on 3fabb11 May 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging michaelwoerister/rust/simd-update = 3fabb11 into auto

@bors
Copy link
Contributor

@bors bors commented on 3fabb11 May 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

michaelwoerister/rust/simd-update = 3fabb11 merged ok, testing candidate = e7181a9e

@bors
Copy link
Contributor

@bors bors commented on 3fabb11 May 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 3fabb11 May 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at michaelwoerister@3fabb11

@bors
Copy link
Contributor

@bors bors commented on 3fabb11 May 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging michaelwoerister/rust/simd-update = 3fabb11 into auto

@bors
Copy link
Contributor

@bors bors commented on 3fabb11 May 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

michaelwoerister/rust/simd-update = 3fabb11 merged ok, testing candidate = 0e91c226

@bors
Copy link
Contributor

@bors bors commented on 3fabb11 May 17, 2014

@bors
Copy link
Contributor

@bors bors commented on 3fabb11 May 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at michaelwoerister@3fabb11

@bors
Copy link
Contributor

@bors bors commented on 3fabb11 May 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging michaelwoerister/rust/simd-update = 3fabb11 into auto

@bors
Copy link
Contributor

@bors bors commented on 3fabb11 May 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

michaelwoerister/rust/simd-update = 3fabb11 merged ok, testing candidate = 1e0379f

@bors
Copy link
Contributor

@bors bors commented on 3fabb11 May 17, 2014

@bors
Copy link
Contributor

@bors bors commented on 3fabb11 May 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 1e0379f

Please sign in to comment.