-
Hallo Sprinter,
das mit dem I-ASM ist eine gute Idee für zeitkritische Funktionen.
Der Gcc Bug Report:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32871
Wo Du gerade das Attribute always_inline ansprichst. Angenommen, man hat eie Funktion, die immer geinlined wird. Dann ist aber immer noch die Funktion im Listing an sich da, wieso löscht der Avr-Gcc die dann nicht?
Grüße
-
Die Funktion muss ja da bleiben, weil es vielleicht eine externe Referenz auf die Funktion gibt. Hier hilft's, die Funktion als static zu geklarieren. Aber selbst dann kann die Funktion noch gebraucht werden, zB wenn ihre Adresse genommen wird.
Dann gibt's noch die hilfreichen Schalter -Winline -fno-keep-inline-functions (für -fxxx gibt's immer auch -fno-xxx)
Weitere Rädchen zum Feinjustieren siehst du mit
Code:
avr-gcc -v --help | grep inline
Aber aufpassen: grep filtert nur nach "inline". Evtl sind die Options nur für C++. Dann das komplette avr-gcc -v --help lesen...
-
Zum bugreport bei gcc.gnu.org:
Häng da noch die Precompilierte Quelle (also wo alle #includes etc aufgelöst sind) dran, und wie du die Datei erhalten hast!
Sonst kann man das niemals nachvollziehen!
Code:
long foo (long a, long b, long c, unsigned char d){
if(d){
return a+b;
}else{
return a-c;
}
}
Code:
d:\avr\test>avr-gcc blah.c -Os -S -v -fverbose-asm
Reading specs from E:/WinAVR_20060421/lib/gcc/avr/3.4.6/specs
Configured with: ../gcc-3.4.6/configure --prefix=/c/WinAVR --target=avr --enable
=c,c++ --with-dwarf2 --enable-win32-registry=WinAVR --disable-nls
Thread model: single
gcc version 3.4.6
E:/WinAVR_20060421/libexec/gcc/avr/3.4.6/cc1.exe -quiet -v -iprefix e:\WinAVR_2
n/../lib/gcc/avr/3.4.6/ blah.c -quiet -dumpbase blah.c -auxbase blah -Os -versio
e-asm -o blah.s
ignoring nonexistent directory "E:/WinAVR_20060421/avr/sys-include"
#include "..." search starts here:
#include <...> search starts here:
e:\WinAVR_20060421\bin/../lib/gcc/avr/3.4.6/include
E:/WinAVR_20060421/lib/gcc/avr/3.4.6/include
E:/WinAVR_20060421/avr/include
End of search list.
GNU C version 3.4.6 (avr)
compiled by GNU C version 3.4.2 (mingw-special).
GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=32702
blah.s:
Code:
.file "blah.c"
.arch avr2
__SREG__ = 0x3f
__SP_H__ = 0x3e
__SP_L__ = 0x3d
__tmp_reg__ = 0
__zero_reg__ = 1
.global __do_copy_data
.global __do_clear_bss
; GNU C version 3.4.6 (avr)
; compiled by GNU C version 3.4.2 (mingw-special).
; GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=32702
; options passed: -v -iprefix -auxbase -Os -fverbose-asm
; options enabled: -feliminate-unused-debug-types -fdefer-pop
; -fomit-frame-pointer -foptimize-sibling-calls -funit-at-a-time
; -fcse-follow-jumps -fcse-skip-blocks -fexpensive-optimizations
; -fthread-jumps -fstrength-reduce -fpeephole -fforce-mem -ffunction-cse
; -fkeep-static-consts -fcaller-saves -freg-struct-return -fgcse
; -fgcse-lm -fgcse-sm -fgcse-las -floop-optimize -fcrossjumping
; -fif-conversion -fif-conversion2 -frerun-cse-after-loop
; -frerun-loop-opt -fdelete-null-pointer-checks -fsched-interblock
; -fsched-spec -fsched-stalled-insns -fsched-stalled-insns-dep
; -fbranch-count-reg -freorder-functions -fcprop-registers -fcommon
; -fverbose-asm -fregmove -foptimize-register-move -fargument-alias
; -fstrict-aliasing -fmerge-constants -fzero-initialized-in-bss -fident
; -fpeephole2 -fguess-branch-probability -fmath-errno -ftrapping-math
; -minit-stack=__stack -mmcu=avr2
.text
.global foo
.type foo, @function
foo:
/* prologue: frame size=0 */
push r12
push r14
push r15
push r16
push r17
push r28
push r29
/* prologue end (size=7) */
mov r29,r25 ; a, a
mov r28,r24 ; a, a
mov r27,r23 ; a, a
mov r26,r22 ; a, a
tst r12 ; d
breq .L2 ; ,
mov r22,r26 ; <result>, a
mov r23,r27 ; <result>, a
mov r24,r28 ; <result>, a
mov r25,r29 ; <result>, a
add r22,r18 ; <result>, b
adc r23,r19 ; <result>, b
adc r24,r20 ; <result>, b
adc r25,r21 ; <result>, b
rjmp .L1 ;
.L2:
mov r22,r26 ; <result>, a
mov r23,r27 ; <result>, a
mov r24,r28 ; <result>, a
mov r25,r29 ; <result>, a
sub r22,r14 ; <result>, c
sbc r23,r15 ; <result>, c
sbc r24,r16 ; <result>, c
sbc r25,r17 ; <result>, c
.L1:
/* epilogue: frame size=0 */
pop r29
pop r28
pop r17
pop r16
pop r15
pop r14
pop r12
ret
/* epilogue end (size=8) */
/* function foo size 38 (23) */
.size foo, .-foo
/* File "blah.c": code 38 = 0x0026 ( 23), prologues 7, epilogues 8 */
-
Hallo Sprinter,
ich habe den Bugreport erweitert. Vielen Dank für Deinen Hinweis!
Michael