From: Borja F. <bor...@gm...> - 2012-01-12 23:01:38
|
Ahh I see, well any function call that needs 8 bytes passed through the stack will do. 2012/1/12 Weddington, Eric <Eri...@at...> > > Well, then, I'm not sure what to tell you. I agree it seems stupid, if > the compiler generates it that way. > > Another reason why I suggested a real test case is that way I can check > what different gcc versions are doing, and specifically what gcc trunk > is doing now. There's been a lot of new work going on with the avr port > in gcc. I'd like to be able to do some comparisons. > > Eric > > > -----Original Message----- > > From: Borja Ferrer [mailto:bor...@gm...] > > Sent: Thursday, January 12, 2012 2:16 PM > > To: Weddington, Eric > > Cc: Sherard Dames; avr...@li... > > Subject: Re: [avr-llvm-devel] Current Status? > > > > Haha, well in avr asm it would be something like: > > > > in r30, 0x3d > > in r31, 0x3e > > sbiw r30, 0x08 > > in r0, 0x3f > > cli > > out 0x3e, r30 > > out 0x3f, r0 > > out 0x3d, r31 <--- 8 instructions to allocate 8 bytes of stack > space! > > std Z+1, reg1 <-- move 8 regs into the stack > > std Z+2, reg2 > > .... > > std Z+8, reg8 > > call foo > > > > instead of: > > > > push reg1 > > push reg2 > > ... > > push reg8 > > call foo > > > > You still have 8 instructions to copy the data into the stack for both > > cases, but in the 2nd you've saved 8 instructions that manipulate SP. > > Does it make more sense now? > > > > > > 2012/1/12 Weddington, Eric <Eri...@at...> > > > > > > > > > > > -----Original Message----- > > > From: Borja Ferrer [mailto:bor...@gm...] > > > > > Sent: Thursday, January 12, 2012 1:25 PM > > > To: Weddington, Eric > > > Cc: Sherard Dames; avr...@li... > > > Subject: Re: [avr-llvm-devel] Current Status? > > > > > > > > For now I've implemented it the same way as gcc, but it's > > something > > that > > > popped to me when i was coding it. > > > I don't see how it saves space :) what I think is that you get > the > > same > > > amount of pushes and std's when moving data into the stack no > > matter > > what > > > method is used. The difference I see is that when using std, > you > > have > > to > > > adjust the SP pointer which creates an additional overhead. > Just > > to > > > clarify I'm talking about the case when you want to pass > function > > > arguments before a function call, not in a function prologue > which > > is > > a > > > different story. > > > > > > In x86 it would be something like: > > > > > > sub esp, 8 > > > mov DWORD PTR [esp], reg1 > > > mov DWORD PTR [esp+4], reg 2 > > > call foo > > > ... > > > > > > instead of > > > > > > push reg1 > > > push reg2 > > > call foo > > > ... > > > > > > which saves 1 instruction, but in our case doing "sub esp, 8" > > means > > adding > > > 5 or 6 more instructions. > > > > > > > > > My x86 assembly is extremely rusty. ;-) > > > > Maybe we should work with a real test case... Do you have > something > > that > > shows the issue? > > > > Eric > > > > > > > > > > |