From: Weddington, E. <Eri...@at...> - 2012-01-12 19:56:58
|
> -----Original Message----- > From: Borja Ferrer [mailto:bor...@gm...] > Sent: Thursday, January 12, 2012 10:14 AM > To: Weddington, Eric > Cc: Sherard Dames; avr...@li... > Subject: Re: [avr-llvm-devel] Current Status? > > Eric I have one question, when passing function parameters through the > stack, why does gcc allocate stack space doing the typical copy from SP to > a reg, decrement it for the needed amount and then copy it back to SP and > then use std instructions, instead of directly pushing the registers > saving all the SP manipulation? > Is there particular reason for not doing this? > I can only speculate on why GCC does that, and that would be to probably save on code space. It depends (or, at least, it *should* depend) on how much data is being passed as parameters. It might be smaller to do: 1. copy SP to reg 2. decrement reg by needed amount 3. copy reg back to SP than it would be to do multiple pushes. But, again, I stress that I'm just speculating as to why it would be the case. For llvm, I would suggest that you do as you see fit, as long as it's *correct* code, and then let's go back later to optimize it. If you think it is easier to deal with doing all pushes, then go ahead and implement it. Then we'll look at the code output. Eric Weddington |