From: Jan Hubicka <jh@suse.cz>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: jh@suse.cz, linux-kernel@vger.kernel.org
Subject: Re: i386 flags register clober in inline assembly
Date: Sat, 17 Nov 2001 21:40:41 +0100 [thread overview]
Message-ID: <20011117214041.D3789@atrey.karlin.mff.cuni.cz> (raw)
In-Reply-To: <87y9l58pb5.fsf@fadata.bg> <200111171920.fAHJKjJ01550@penguin.transmeta.com>
In-Reply-To: <200111171920.fAHJKjJ01550@penguin.transmeta.com>
> unsigned long result;
> asm volatile(
> LOCK "decl %m"
> :"+m" (v->counter),
> "=cc" (result)
> : :"memory");
> if (result > 0) /* "jnb" */
> ...
>
> which would be wonderful, and would expand to
>
> (set (cc0) ..asm..)
> (set (pc)
> (if_then_else (gtu (cc0) (const_int 0))
> (label_ref (match_operand ..
> (pc))
>
> Which _should_ just automatically give us
>
> lock ; decl ..
> ja ..
>
> which is exactly what we want.
>
> I know this used to be impossible in gcc, because the x86 didn't
> actually track the flags values, and conditional jumps were really a
> _combination_ of the conditional and the jump, and splitting it up so
> that the conditional would be in an asm was thus not possible.
>
> But I think gcc makes cc0 explicit on x86 these days, and that the above
> kind of setup might be possible today, no?
Actually the main dificulty I see is storing cc0 to variable. CC0 is hard
register and pretty strange one - you can't move it, you can't spill. Using
the syntax above you can easilly make cc0 from asm statement to span another
cc0 set resulting in incorrect code or compiler crash.
(the code generator may insert any code in between statements as it don't
know he can't clobber cc0. In fact this is happening in from of if
construct as deffered stack deallocators are flushed).
If i386 were IA-64 this would be possible as their flags behave more regularry,
but in i386 way I don't see easy trick how to get this (or something
equivalent) working. Maybe someone do have idea how to get around, but I was
thinking about this some time ago too and failed to find feasible sollution.
Honza
>
> Linus
next prev parent reply other threads:[~2001-11-17 20:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-11-17 14:06 Momchil Velikov
2001-11-17 15:14 ` Jan Hubicka
2001-11-17 19:20 ` Linus Torvalds
2001-11-17 19:58 ` H. Peter Anvin
2001-11-17 20:24 ` Momchil Velikov
2001-11-17 20:30 ` Linus Torvalds
2001-11-17 20:40 ` Jan Hubicka [this message]
2001-11-17 20:42 ` Linus Torvalds
2001-11-18 1:09 ` Jan Hubicka
2001-11-18 2:48 ` Linus Torvalds
2001-11-20 8:33 ` Richard Henderson
2001-11-20 13:00 ` Jan Hubicka
2001-11-20 23:14 ` Richard Henderson
2001-11-20 17:12 ` Linus Torvalds
2001-11-17 21:00 ` H. Peter Anvin
2001-11-20 14:39 ` PATCH 2.4.15-pre6 idt compilation and proc_misc cleanup Martin Dalecki
2001-11-23 22:24 ` Roman Zippel
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=20011117214041.D3789@atrey.karlin.mff.cuni.cz \
--to=jh@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/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
all inboxes | Powered by JetHome®