llvm ist wirklich verblüffend, hier ein Beispiel mit einer Schlaufe:
Code: Alles auswählen
program while1;
var
i1,i2: int32;
begin
i1:= 0;
i2:= 0;
while i1 < 5 do begin
inc(i1);
i2:= i1+i2;
end;
exitcode:= i2;
end.
MSElang-llvm -O3:
Code: Alles auswählen
.file "test-opt.ll"
.text
.globl main
.align 16, 0x90
.type main,@function
main: # @main
# BB#0:
movl $15, %eax
ret
.Ltmp0:
.size main, .Ltmp0-main
.section ".note.GNU-stack","",@progbits
FPC fixes_2_6 -O3:
Code: Alles auswählen
main:
# Temps allocated between esp+0 and esp+0
# Var i1 located in register ecx
# Var i2 located in register edx
# [test1.pas]
# [4] begin
call FPC_INITIALIZEUNITS
movl $0,%eax
movl $0,%eax
# [5] i1:= 0;
movl $0,%ecx
# [6] i2:= 0;
movl $0,%edx
# [7] while i1 < 5 do begin
jmp .Lj8
.balign 4,0x90
.Lj7:
# [8] inc(i1);
incl %ecx
# [9] i2:= i1+i2;
movl %edx,%eax
addl %ecx,%eax
movl %eax,%edx
.Lj8:
cmpl $5,%ecx
jl .Lj7
.Lj9:
# [11] exitcode:= i2;
movl %edx,operatingsystem_result
# [12] end.
call FPC_DO_EXIT
ret
.Le0:
.size main, .Le0 - main