Can someone tell me why all functions declared as "static" do not seem to have any register optimization done on them? At least this is implied since they are not listed in the map file where register usage is specified but become listed if the "static" declaration is removed. Does this imply that I should remove the "static" declaration from any function to which I have set a global pointer in order to ensure optimization is done on that function?
Ok, I now understand that there is no option for iterative register optimization on static functions as there is for global functions. This is unfortunate for it would seem to provide a great efficiency gain if it were done. To have to organize a module by increasing function complexity to gain that efficiency means that I am working for the compiler rather than it working for me. Besides it would remove the logical organization of the file. Back to my original question though: Does this imply that I should remove the "static" declaration from any function to which I have set a global pointer in order to ensure optimization is done on that function? In other words, does the compiler have enough awareness of global pointers to static functions so that global register optimizations are performed on those static functions or must I change the static functions to global functions to achieve this?
You'll have to remove the static declaration. However, if you're using function pointers, you're going to need to use the OVERLAY directive to manually update the call tree the linker generates. HAve you taken a look at the function pointer application note? http://www.keil.com/appnotes/docs/apnt_129.asp Jon
Jon, I am not sure how much of this article applies to my situation since I am using the C166 toolset and it does not seem to have a linker OVERLAY definition (at least not in my manual) although the article is an interesting review of the issues of non-reentrantcy. Also, the C167 toolset defines REENTRANT by default, one would need to define STATIC for the issues brought up in this article to be valid, wouldn't it? I was referring to the C "static" function declaration modifier that I believe only restricts the scope of the function name. I was not aware of the limit of three parameters for function pointers though. After looking through my code I found I just got lucky in that I never needed more than three and they were always structures or USHORTs.
Oops - I get so used to C51 issued I just didn't notice the C166. Sorry for that. Jon
The compiler generates the functions in the order they appear in the source module. Even on global functions that are in the same module you must keep the structure described in: http://www.keil.com/support/docs/2809.htm. We are working on an enhanced strategy for the ARM Compiler where this structure is no longer required. But it involves that the Compiler make s a call tree analysis before generating the code (you need to know how many registers a function uses to generate optimum code for other functions). I think for the moment, you should consider to re-organize your code.