Weddington, Eric schrieb: >> -----Original Message----- >> From: Georg-Johann Lay >> Sent: Thursday, October 27, 2011 11:26 AM >> To: gcc-patches@gcc.gnu.org >> Cc: Richard Henderson; Weddington, Eric; Denis Chertykov >> Subject: [Patch,AVR]: Support -maccumulate-args option >> >> This is support of a new option -maccumulate-args that implements >> ACCUMULATE_OUTGOING_ARGS as proposed by Richard. > > Hi Johann, > > Sorry I don't recall the earlier conversation. What is the benefit to > the end user of this patch and adding this switch? > > Thanks, > Eric
Suppose the attaches aoa.c source file that passes arguments on the stack. Pushing the arguments is inevitable but popping/adjusting SP is expensive and done several times, whereas with ACCUMULATE_OUTGOING_ARGS the overall stack usage might increase but the stack adjustment has just to be done in the prologue and in the epilogue, not multiple times. For the source attached and with the patch applied: $ avr-gcc aoa.c -c -save-temps -Os -mmcu=avr4 -dp -maccumulate-args \ && avr-size aoa.o text data bss dec hex filename 206 0 0 206 ce aoa.o $ avr-gcc aoa.c -c -save-temps -Os -mmcu=avr4 -dp -mno-accumulate-args \ && avr-size aoa.o text data bss dec hex filename 224 0 0 224 e0 aoa.o Johann
extern int sprintf (char*, const char*, ...); extern unsigned int strnlen (const char*, unsigned int); typedef unsigned char uint8_t; void long_to_dec_str (long value, char *decs, uint8_t prec) { uint8_t pos, i; if (prec == 0) sprintf (decs, "%ld", value); else if (prec == 1) sprintf (decs, "%02ld", value); else if (prec == 2) sprintf (decs, "%03ld", value); if (prec == 0) return; pos = strnlen (decs, 16) + 1; for (i = 0; i <= prec; i++) { decs[pos] = decs[pos-1]; pos--; } decs[pos] = '.'; }