[MPlayer-dev-eng] Asm parameter constraints (was: Improved remove-logo filter)

Trent Piepho xyzzy at speakeasy.org
Sun Nov 5 21:00:32 CET 2006


On Sun, 5 Nov 2006, Loren Merritt wrote:
> On Sat, 4 Nov 2006, Trent Piepho wrote:
> > On Fri, 3 Nov 2006, Uoti Urpala wrote:
> >
> >> Michael's original comment which you disagreed with said that if you do
> >> use [out]"=m"(a):[in]"m"(a) then [out] and [in] could be the same memory
> >> location or different ones, and [out] might overlap some other input
> >> parameter. I don't see anything in your latest reply which would show
> >> that gcc guarantees the opposite will always be true.
> >
> > You are saying that if you write [out]"=m"(a):[in]"m"(b) then out and in
> > could overlap?  This is what you mean when you say, "[out] might overlap
> > some other input parameter?"
> >
> > If that is the case, what would you write so that out and in can't overlap?
> > Or do you think there is no way to keep [out]"=m"(a) from overlapping some
> > other input paramters, and it is thus impossible to have a "=m" parameter
> > that is used before all inputs are consumed?
>
> [out]"=&m"(a)
>
> earlyclobber ("&") is specifally for that situation.

void foo(void) { int a, b; asm("# %0":"=&m"(a):"g"(b)); }

test.c: In function 'foo':
test.c:1: error: '&' constraint used with no register class
test.c:1: error: '&' constraint used with no register class

My question was mearly rhetorical, as I already knew (unlike those trying
to "correct" me) that '&' only applies to registers and can not be used
with a constraint that does not allow a register, such as 'm'.

So either I have been right all along, and a memory operand to an asm can't
overlap another unrelated memory operand, or it is impossible to write to a
memory operand before all the inputs are consumed.  I wonder when mplayer and
lavc will be audited to remove all the asm code that writes to memory and
then expects an input to still exist.



More information about the MPlayer-dev-eng mailing list