From: Cody Rigney <codyrigney92@gmail.com>
To: Andrew Haley <aph@redhat.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: Compiler optimizing variables in inline assembly
Date: Thu, 27 Feb 2014 18:34:00 -0000 [thread overview]
Message-ID: <CA+1=iYbA0=9j6vErhCbZxjHmpzQDPD--oMW2H8NYo61ZTfsbvQ@mail.gmail.com> (raw)
In-Reply-To: <530F45B3.3010402@redhat.com>
On Thu, Feb 27, 2014 at 9:03 AM, Andrew Haley <aph@redhat.com> wrote:
>
> I have been informed that this is wrong, sorry.
>
> The correct way to do it is like so:
>
> ---------------------------------------
> If you know how large the accessed memory is, you can add it as input or
> output but if this is not known, you should add `memory'. As an example,
> if you access ten bytes of a string, you can use a memory input like:
>
> {"m"( ({ struct { char x[10]; } *p = (void *)ptr ; *p; }) )}.
>
> ---------------------------------------
>
> If you use a zero-length array in the struct (i.e. char x[0]) that will
> effectively do the job if you don't know how large the array is, but there
> seems to be some doubt whether this is guaranteed. A memory clobber really
> is guaranteed, but seems a bit like overkill.
>
> Andrew.
>
I gave that a shot but it didn't work for me. I tried making small
modifications and it would either not work right(maybe optimizations)
or the instruction wouldn't allow offsets like [r0, #16].
I did this instead:
typedef struct { char x[16]; } MemContainer128;
....
output param is "=m" ( *((MemContainer128*)ptr))
Cody
next prev parent reply other threads:[~2014-02-27 18:34 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-19 19:05 Cody Rigney
2014-02-20 9:14 ` Andrew Haley
2014-02-20 19:30 ` Cody Rigney
2014-02-21 9:53 ` Andrew Haley
2014-02-21 14:06 ` Cody Rigney
2014-02-21 15:02 ` Andrew Haley
2014-02-21 15:20 ` Cody Rigney
2014-02-27 13:18 ` Cody Rigney
2014-02-27 14:03 ` Andrew Haley
2014-02-27 18:34 ` Cody Rigney [this message]
2014-02-21 9:54 ` David Brown
2014-02-21 9:55 ` David Brown
2014-02-20 9:54 ` David Brown
2014-02-20 19:39 ` Cody Rigney
2014-02-21 10:15 ` David Brown
2014-02-21 14:11 ` Cody Rigney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CA+1=iYbA0=9j6vErhCbZxjHmpzQDPD--oMW2H8NYo61ZTfsbvQ@mail.gmail.com' \
--to=codyrigney92@gmail.com \
--cc=aph@redhat.com \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).