On 14 Dec 2012, at 13:46, michael.vancann...@wisa.be wrote:
On Fri, 14 Dec 2012, Jonas Maebe wrote:
Indeed, adding inline assembler to a routine disables many
optimizations.
Doesn't adding the list of modified registers to the 'ASM' block
help in this case ? I thought this was why we supported this ?
That's required to guarantee the correctness of the generated code
under all circumstances. It doesn't help with register variables though:
{$asmmode intel}
procedure test;
var
l: longint;
begin
// compiler decides to put l into register eax
l:=1;
asm
push eax
push edx
rdtsc
mov l,eax
pop edx
pop eax
end; // no register changed -> no list required
// always writes 1
writeln(l);
end;
It would be possible to prevent registers accessed from assembler code
to be put into registers, but currently the compiler does not perform
any kind of analysis of assembler code, and I think it should stay
that way. There are too many ways in which assembler code can be
written that defeats automatic analyses. If you use assembler, you get
full freedom and that freedom gets taken away from the compiler.
Jonas
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal