www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/15/11:45:22

From: buers AT gmx DOT de (Dieter Buerssner)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: THE -O2 PROBLEM
Date: 15 Apr 2000 10:49:15 GMT
Lines: 69
Message-ID: <8d9okd.3vs7iub.0@buerssner-17104.user.cis.dfn.de>
References: <38F20E7A DOT 3330E9A4 AT mtu-net DOT ru> <38F6C64E DOT C7753C6C AT mtu-net DOT ru> <8d7l3g$j3i$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> <38F76B94 DOT 5E968BA7 AT mtu-net DOT ru>
NNTP-Posting-Host: pec-144-126.tnt10.s2.uunet.de (149.225.144.126)
Mime-Version: 1.0
X-Trace: fu-berlin.de 955795755 7711224 149.225.144.126 (16 [17104])
X-Posting-Agent: Hamster/1.3.13.0
User-Agent: Xnews/03.02.04
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Alexei A. Frounze wrote:

>I'm going to change that stupid "g" constraint. I'll replace it with 
>others ("r" and "m" or even with particular registers, if needed).

I hope you are aware, that you cannot just change "g" to "m", that
wouldn't work. You have to get rid of all those stupid references
as well.

>Btw, I have a suggestion. Why not to add this story to the FAQ? Just 
>mention there that usage of the "g" constarint may cause problems during 
>compilation such as error messages about wrong syntax, although syntax 
>seems to be correct.

I think, the syntax doesn't seem correct at all. The gcc manual
is quite clear. Under Simple Constraints: 

|`g'
|     Any register, memory or immediate integer operand is allowed,
|     except for registers that are not general registers.

You got, what you asked for. 

IHMO, who ever has not read this, shouldn't use inline assembler.
The FAQ, question 18.12, shows how to find the description of
inline assembler in the gcc manual. In that chapter, there is
a cross reference to the constraints description. Seems obvious
to me.

Also, in Brennan Underwood's tutorial, that is mentioned in
the same FAQ

|g        eax, ebx, ecx, edx or variable in memory

While not totally correct, it is clear that this cannot
be used for referencing, because "opcode (variable in memory)"
is not possible with x86.

Unfortunately, that tutorial seems a bit outdated, and some
code will suffer from the "spilled register" problem. (I am
trying to contact the author.)

\begin{rant}
I still think, it is stupid, that gcc made this non back compatible
change with the clobbered input registers. I can fix those occurences
with an algorithm (manually), so why can't gcc do it. Almost all
code, that I have seen, and that uses inline assembly extensively,
broke because of this. If you look at GRX sources, you can see,
that the author(s) do know inline assembly very well and that they
most probably have read and understood the available documentation.
(They do know the preprocessor a bit too well though ;)

In the FAQ I read:

|GCC 2.95 became more picky about some invalid use of clobber specifiers

This is a bit of an euphism. Code, that was written according to
the documentation, just stopped to work. What is invalid now, was
not invalid with earlier versions of gcc. 
\end{rant}

Sorry about that, but feeling better now ;)

Probably I shouldn't tell you Alexei, but if you wouldn't have
used all those unnecessary references, "g" would even have worked 
with floating point variables.

-- 
Dieter

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019