* [Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
[not found] <bug-16331-1331@http.gcc.gnu.org/bugzilla/>
@ 2009-02-09 20:46 ` hjl dot tools at gmail dot com
2009-02-09 20:47 ` hjl dot tools at gmail dot com
` (6 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-02-09 20:46 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from hjl dot tools at gmail dot com 2009-02-09 20:46 -------
Reopened.
--
hjl dot tools at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16331
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
[not found] <bug-16331-1331@http.gcc.gnu.org/bugzilla/>
2009-02-09 20:46 ` [Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI hjl dot tools at gmail dot com
@ 2009-02-09 20:47 ` hjl dot tools at gmail dot com
2009-02-09 20:47 ` hjl dot tools at gmail dot com
` (5 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-02-09 20:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from hjl dot tools at gmail dot com 2009-02-09 20:46 -------
*** Bug 39139 has been marked as a duplicate of this bug. ***
--
hjl dot tools at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16331
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
[not found] <bug-16331-1331@http.gcc.gnu.org/bugzilla/>
2009-02-09 20:46 ` [Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI hjl dot tools at gmail dot com
2009-02-09 20:47 ` hjl dot tools at gmail dot com
@ 2009-02-09 20:47 ` hjl dot tools at gmail dot com
2009-02-09 20:50 ` hjl dot tools at gmail dot com
` (4 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-02-09 20:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from hjl dot tools at gmail dot com 2009-02-09 20:47 -------
The rational for this request is at
http://gcc.gnu.org/bugzilla/attachment.cgi?id=17274
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16331
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
[not found] <bug-16331-1331@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2009-02-09 20:47 ` hjl dot tools at gmail dot com
@ 2009-02-09 20:50 ` hjl dot tools at gmail dot com
2009-02-09 22:43 ` ubizjak at gmail dot com
` (3 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-02-09 20:50 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from hjl dot tools at gmail dot com 2009-02-09 20:49 -------
Uros, how hard to support this in x86 backend?
--
hjl dot tools at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ubizjak at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16331
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
[not found] <bug-16331-1331@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2009-02-09 20:50 ` hjl dot tools at gmail dot com
@ 2009-02-09 22:43 ` ubizjak at gmail dot com
2009-02-10 14:35 ` thutt at vmware dot com
` (2 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: ubizjak at gmail dot com @ 2009-02-09 22:43 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from ubizjak at gmail dot com 2009-02-09 22:43 -------
(In reply to comment #11)
> Uros, how hard to support this in x86 backend?
I remember there were concerns when xmm0 single-register constraint was
introduced... We need new constraint letter and new regclass entry. I don't
have relevant mail at hand, but IIRC adding new register class is O(n*n).
OTOH, constraints should be used to support correct register allocation for
machine instructions, not to emulate ABI in order to support calls from inside
asm statements.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16331
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
[not found] <bug-16331-1331@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2009-02-09 22:43 ` ubizjak at gmail dot com
@ 2009-02-10 14:35 ` thutt at vmware dot com
2009-02-10 15:20 ` ubizjak at gmail dot com
2009-02-10 15:35 ` thutt at vmware dot com
7 siblings, 0 replies; 14+ messages in thread
From: thutt at vmware dot com @ 2009-02-10 14:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #13 from thutt at vmware dot com 2009-02-10 14:34 -------
(In reply to comment #12)
> (In reply to comment #11)
> > Uros, how hard to support this in x86 backend?
>
<snip>
> OTOH, constraints should be used to support correct register
> allocation for machine instructions, not to emulate ABI in order to
> support calls from inside asm statements.
Please indulge me for a moment.
What exactly is a call?
Are you considering the only method of transferring control to be the
standard 'near call' & 'near ret' instructions on the x86?
What about the following modes of transferring control to another
address?
int
iret
ret
sysenter
sysexit
syscall
sysret
ud2
int3
jmp
Then, what of these?
lcall
lret
ljmp
Every one of these is a method to transfer control to another address
with a programmer-defined set of input register. More importantly,
none of these are directly supported by gcc to invoke functions
without resorting to inline assembly.
If you're working on an operating system, a virtualization engine or
some other embedded device you might need to transfer control using
one of these methods.
As a really simple example, consider a handler for a timer interrupt.
Let's say that the prologue for the interrupt (written in assembly)
handler storing all the machine registers into a data structure
accessible from C. Then, the prologue transfers to the handler which is
conveniently written in C. Wouldn't it be really nice if one could
restore all the saved registers in C code using only inline assembly
instruction?
__asm__("iret"
:
: force restoring registers saved in data structure);
I'm confident you can see the advantage of doing this in C and letting
the compiler deal with the bookkeeping details, rather than resorting
to another assembly language function which does such a simple feat.
I think I pretty clearly demonstrate here that calling other functions
using the x86 architecture isn't as simple as assuming it's going only
to be done with 'call', 'jmp' and 'ret', and many of those methods are
not possible with straight C, even with gcc's helpful extensions.
Should gcc prevent the developer from using the ABI just because the
inline assembly wasn't meant to 'support calls from inside assembly
statements'?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16331
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
[not found] <bug-16331-1331@http.gcc.gnu.org/bugzilla/>
` (5 preceding siblings ...)
2009-02-10 14:35 ` thutt at vmware dot com
@ 2009-02-10 15:20 ` ubizjak at gmail dot com
2009-02-10 15:35 ` thutt at vmware dot com
7 siblings, 0 replies; 14+ messages in thread
From: ubizjak at gmail dot com @ 2009-02-10 15:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #14 from ubizjak at gmail dot com 2009-02-10 15:20 -------
> > OTOH, constraints should be used to support correct register
> > allocation for machine instructions, not to emulate ABI in order to
> > support calls from inside asm statements.
>
> Please indulge me for a moment.
>
> What exactly is a call?
>
> Are you considering the only method of transferring control to be the
> standard 'near call' & 'near ret' instructions on the x86?
I was referring at the procedure call, where you need to setup outgoing
arguments on the calling point and setup incoming arguments on caller point.
gcc will magically match these two no matter what ABI-changing compile flag
(i.e. -mregparm) you use. When you call procedure from inside asm, gcc does not
know about that, and there is no way that gcc will know where arguments are to
be found.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16331
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
[not found] <bug-16331-1331@http.gcc.gnu.org/bugzilla/>
` (6 preceding siblings ...)
2009-02-10 15:20 ` ubizjak at gmail dot com
@ 2009-02-10 15:35 ` thutt at vmware dot com
7 siblings, 0 replies; 14+ messages in thread
From: thutt at vmware dot com @ 2009-02-10 15:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #15 from thutt at vmware dot com 2009-02-10 15:35 -------
(In reply to comment #14)
> > > OTOH, constraints should be used to support correct register
> > > allocation for machine instructions, not to emulate ABI in order to
> > > support calls from inside asm statements.
> >
> > Please indulge me for a moment.
> >
> > What exactly is a call?
> >
> > Are you considering the only method of transferring control to be the
> > standard 'near call' & 'near ret' instructions on the x86?
>
> I was referring at the procedure call, where you need to setup outgoing
> arguments on the calling point and setup incoming arguments on caller point.
> gcc will magically match these two no matter what ABI-changing compile flag
> (i.e. -mregparm) you use. When you call procedure from inside asm, gcc does not
> know about that, and there is no way that gcc will know where arguments are to
> be found.
I understand.
I'm not expecting gcc to handle those aspects of the inline assembly.
My request is just to be able to specify any GP hardware register in a
constraint. Both input & output.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16331
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
2004-07-02 16:51 [Bug c/16331] New: " thutt at vmware dot com
@ 2004-08-03 7:06 ` pinskia at gcc dot gnu dot org
2005-07-02 1:27 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
3 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-03 7:06 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Component|c |target
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16331
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
2004-07-02 16:51 [Bug c/16331] New: " thutt at vmware dot com
2004-08-03 7:06 ` [Bug target/16331] " pinskia at gcc dot gnu dot org
@ 2005-07-02 1:27 ` pinskia at gcc dot gnu dot org
2005-07-02 10:17 ` falk at debian dot org
2005-09-04 19:05 ` pinskia at gcc dot gnu dot org
3 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-02 1:27 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-07-02 01:27 -------
(In reply to comment #4)
> __asm__ __volatile__("call pokus"
This is wrong, you don't want to use call in an asm at all.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16331
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
2004-07-02 16:51 [Bug c/16331] New: " thutt at vmware dot com
2004-08-03 7:06 ` [Bug target/16331] " pinskia at gcc dot gnu dot org
2005-07-02 1:27 ` pinskia at gcc dot gnu dot org
@ 2005-07-02 10:17 ` falk at debian dot org
2005-09-04 19:05 ` pinskia at gcc dot gnu dot org
3 siblings, 0 replies; 14+ messages in thread
From: falk at debian dot org @ 2005-07-02 10:17 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From falk at debian dot org 2005-07-02 10:17 -------
(In reply to comment #4)
> The first call of pokus() completely ignores the assigned value of the variable
> r8 -- instead the value '6' into it for the call. The second call assumes the
> the register r8 should be used for the call, but by now the wrong value has bee
> placed into it.
I cannot reproduce this with gcc 3.3.6, the generated assembly looks just
fine for me:
0000000000000000 <test>:
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: e8 00 00 00 00 callq 9 <test+0x9>
5: R_X86_64_PC32 hokus+0xfffffffffffffffc
9: 41 89 c0 mov %eax,%r8d
c: 41 b9 06 00 00 00 mov $0x6,%r9d
12: be 02 00 00 00 mov $0x2,%esi
17: ba 03 00 00 00 mov $0x3,%edx
1c: b9 04 00 00 00 mov $0x4,%ecx
21: 44 89 c7 mov %r8d,%edi
24: e8 00 00 00 00 callq 29 <test+0x29>
25: R_X86_64_PC32 pokus+0xfffffffffffffffc
29: e8 00 00 00 00 callq 2e <test+0x2e>
2a: R_X86_64_PC32 hokus+0xfffffffffffffffc
2e: 41 b9 06 00 00 00 mov $0x6,%r9d
34: 41 b8 05 00 00 00 mov $0x5,%r8d
3a: b9 04 00 00 00 mov $0x4,%ecx
3f: ba 03 00 00 00 mov $0x3,%edx
44: be 02 00 00 00 mov $0x2,%esi
49: 44 89 c7 mov %r8d,%edi
4c: b8 00 00 00 00 mov $0x0,%eax
51: e8 00 00 00 00 callq 56 <test+0x56>
52: R_X86_64_PC32 pokus+0xfffffffffffffffc
56: c9 leaveq
Please retry and give the exact version and flags you used.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16331
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
2004-07-02 16:51 [Bug c/16331] New: " thutt at vmware dot com
` (2 preceding siblings ...)
2005-07-02 10:17 ` falk at debian dot org
@ 2005-09-04 19:05 ` pinskia at gcc dot gnu dot org
3 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-04 19:05 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-09-04 19:05 -------
No feedbacck in 3 months.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16331
^ permalink raw reply [flat|nested] 14+ messages in thread