Aligning data in memory
Peter Alexander
peter.alexander.au at gmail.com
Wed Sep 21 11:29:22 PDT 2011
I could be wrong, but I think so.
As I understand, align(N) only aligns it *within the structure*.
If you are at 0 offset, you are aligned on all N already, so I don't see
why it would add padding before the first member of a struct.
On 21/09/11 11:22 AM, Rory McGuire wrote:
> Would that even be true in the case where you specify a alignment (
> keeping in mind that the alignment is for that specific variable)?
>
>
>
> On Tue, Sep 20, 2011 at 7:25 PM, Peter Alexander
> <peter.alexander.au at gmail.com <mailto:peter.alexander.au at gmail.com>> wrote:
>
> On 19/09/11 9:17 AM, Rory McGuire wrote:
>
> surely you would have to use
> movaps XMM0, v.v;
>
> because the alignment would only happen inside the struct?
>
>
> On Sat, Sep 17, 2011 at 8:11 PM, Adam D. Ruppe
> <destructionator at gmail.com <mailto:destructionator at gmail.com>
> <mailto:destructionator at gmail.__com
> <mailto:destructionator at gmail.com>>> wrote:
>
> Perhaps:
>
> void foo() {
> struct V { align(16) float[4] v = [1.0f, 2.0f, 3.0f,
> 4.0f]; }
> V v;
> asm {
> movaps XMM0, v;
> }
> }
>
>
> It compiles, but I'm not sure if it's actually correct.
>
>
>
> v has offset 0 in the struct, so &v.v == &v, which is all the inline
> asm cares about.
>
>
More information about the Digitalmars-d
mailing list