This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: GCC can't count operands.


Tony Mantler <eek@escape.ca> said:
> At 8:07 PM -0600 3/24/2000, Alexandre Oliva wrote:
> >On Mar 24, 2000, Tony Mantler <eek@escape.ca> wrote:

> >> Parsing "%[0-9]+" doesn't strike me as being a terribly difficult.

> >But it would change the meaning of already existing code.  Just think
> >of `%[0-9]' immediately followed by numbers.

> Please tell me you're kidding, is that syntax actually allowable? That
> rather strikes me as a parsing and readability nightmare.

What gcc does when confronted with an asm() is to scan the string inside
for %[0-9]'s, and replaces them blindly with the corresponding arguments.

As for readability, if I write "%110" in an asm(), I'm saying "second
operand, followed by '10'". Crystal clear. ;-)

> I certainly wouldn't be as quick to defend any syntax that would allow a
> fixed-length numeric identifier to be followed immediatley by a bare number
> without any separator. That's just broken.

Suggest a reasonable alternative. Note that assembly languages vary widely,
and spaces are usually very significant around operands. Remember to keep
backward compatibility with all legal previous uses. Carefully consider
that this has to be handled by machine-independent code in the compiler.
Then come back.

> Besides, legacy asm code was already broken when you guys (rightly) dropped
> support for short branches to global symbols. It's not the end of the world
> if you break legacy stuff in the name of sanity.

If you check the above outline of how asm() works, you see you can write
any garbage you want into the string, gcc won't care. If, after compiling,
the complete resulting assembly file makes sense, you got lucky.

Please, take a peek at how asm() used to work on K&R C compilers. The gcc
way is broken, but an inmense step forward. And it is _not_ important, even
stuff like the linux kernel contains just a tiny fraction of assembly.
-- 
Horst von Brand                             vonbrand@sleipnir.valparaiso.cl
Casilla 9G, Viņa del Mar, Chile                               +56 32 672616

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]