public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "simon.willcocks at gmx dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug inline-asm/101422] register variable uninitialised before passing to asm
Date: Thu, 15 Jul 2021 11:41:20 +0000 [thread overview]
Message-ID: <bug-101422-4-USP51S2HPI@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101422-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101422
--- Comment #8 from Simon Willcocks <simon.willcocks at gmx dot de> ---
(In reply to Andrew Pinski from comment #4)
> (In reply to Simon Willcocks from comment #2)
> > That's not an accurate description of the problem; the value of the variable
> > is being passed, not its address. As a register variable, it doesn't have an
> > address.
>
> It is the address of the array that is being passed (I was copying and
> pasting from another bug).
> register uint32_t *cap_and_join asm( "r5" ) = cap_and_join_style;
> Is the same as:
> register uint32_t *cap_and_join asm( "r5" ) = &cap_and_join_style[0];
>
> Because array decays to pointers :).
And, of course, I later came up against this precise problem, at least I knew
what I was looking for, and thanks to you, how to fix it. The final solution is
as follows. I really think that passing a pointer type into an asm should
indicate that the object pointed to is used, though.
void Draw_Stroke( uint32_t *path )
{
// Keep this declaration before the first register variable declaration, or
// -Os will cause the compiler to forget the preceding registers.
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101422
uint32_t cap_and_join_style[5] = { 0x00000001 }; // Round joints
register uint32_t *draw_path asm( "r0" ) = path;
register uint32_t fill_style asm( "r1" ) = 0x3f;
register uint32_t *matrix asm( "r2" ) = 0;
register uint32_t flatness asm( "r3" ) = 0;
register uint32_t thickness asm( "r4" ) = 8;
register uint32_t *cap_and_join asm( "r5" ) = cap_and_join_style;
register uint32_t dashes asm( "r6" ) = 0;
asm ( "swi 0x60704" :
: "r" (draw_path)
, "r" (fill_style)
, "r" (matrix)
, "r" (flatness)
, "r" (thickness)
, "r" (cap_and_join)
, "r" (dashes)
, "m" (cap_and_join_style) ); // Without this, array is not initialised
}
I wanted to correct the record and thank you (both). I'll shut up, now.
prev parent reply other threads:[~2021-07-15 11:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-11 18:23 [Bug c/101422] New: " simon.willcocks at gmx dot de
2021-07-11 18:30 ` [Bug inline-asm/101422] " pinskia at gcc dot gnu.org
2021-07-11 18:51 ` simon.willcocks at gmx dot de
2021-07-11 18:52 ` simon.willcocks at gmx dot de
2021-07-11 18:59 ` pinskia at gcc dot gnu.org
2021-07-11 19:13 ` simon.willcocks at gmx dot de
2021-07-12 8:14 ` jakub at gcc dot gnu.org
2021-07-12 13:02 ` simon.willcocks at gmx dot de
2021-07-15 11:41 ` simon.willcocks at gmx dot de [this message]
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=bug-101422-4-USP51S2HPI@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@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).