Bug 13413 - need "o" inline asm constraint
Summary: need "o" inline asm constraint
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.3.2
: P2 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: inline-asm
Depends on:
Blocks:
 
Reported: 2003-12-16 17:13 UTC by Alexander Melkov
Modified: 2021-09-13 21:33 UTC (History)
1 user (show)

See Also:
Host: i686-freebsd-gnu
Target: i686-freebsd-gnu
Build: i686-freebsd-gnu
Known to work:
Known to fail:
Last reconfirmed: 2005-05-15 01:02:48


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Melkov 2003-12-16 17:13:50 UTC
I think that having no "o" constraint is asm for i386 target is unfair, because 
in effect all the "m" values are actually offsetable.
For example, when I write:
movl 4+%5, %2
- I always get correct code.
The only problem here is that I get gas warning each time %5 happens to be a 
base register without an offset, i.e. something like (%ebx) turns the above 
line into
movl 4+(%ebx), %eax

If there was "o" constraing that behaves like "m" in most cases but prints zero 
in case of zero offset, some people like me would be happy.

What I want, once again:
%5 == (%ebx)
"m" prints (%ebx)
"o" prints 0(%ebx)
-> quite correct movl 4+0(%ebx), %eax in "o" case.

%5 == 12(%ebx)
both "m" and "o" print (%ebx)
-> still correct movl 4+12(%ebx), %eax code.

I hope that's easy to do. Thanks in advance :)
Comment 1 Andrew Pinski 2003-12-19 07:36:29 UTC
So this is what you want:
int f(int *i){int t; asm("a %1":"=r"(t):"o"(*i)); return t;}
0(%eax) and not (%eax) which it currently is now, right?
Comment 2 Alexander Melkov 2003-12-19 21:35:55 UTC
(In reply to comment #1)
> So this is what you want:
> int f(int *i){int t; asm("a %1":"=r"(t):"o"(*i)); return t;}
> 0(%eax) and not (%eax) which it currently is now, right?
Yes, that's right.

But that's not enough. Nowadays gcc doesn't like "o" at all, it says: "error: 
impossible constraint in `asm'".

/usr/local/egcs-3/bin/c++ -O -Wall mo.cpp
mo.cpp: In function `int main(int, char**)':
mo.cpp:3: error: impossible constraint in `asm'

==> mo.cpp <==
int main(int argc, char *[]) {
    long long A = argc;
    asm volatile(
        ""
        : "=o" (A)
        :
        : "cc"
    );
    return A;
}

With "m", it compiles fine. (note -O switch)