Coldfire: fastcall or equivalent declspec to pass parms by register

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Coldfire: fastcall or equivalent declspec to pass parms by register

2,270 Views
toddL
Contributor I
I'm using the CodeWarrior for Coldfire (6.3 build 14) for my C code and would like to know if there's a fastcall keyword available or some other equivalent __declspec parameter that I can use to indicate certain functions should pass their parameters by register rather than pushing them on the stack.
 
I know there's a global optimization flag to enable passing by register, but I don't want to use that. I only want to optimize certain functions this way by specifying them explicitly in the function declaration.
 
I noticed that __fastcall seems to be a keyword, as its color is blue in the IDE.  However, when I specify __fastcall in a function declaration, I get a syntax error at compile time.
 
Example:
 
   long __fastcall Plx_lSwapBytes(long Value);
 
Is there a list of valid __declspec parameters somewhere?  I searched the documentation and could not find anything specifying what __declspec's are available.
 
Thanks,
-Todd

Message Edited by CrasyCat on 2007-04-13 02:20 PM

Labels (1)
0 Kudos
4 Replies

504 Views
CompilerGuru
NXP Employee
NXP Employee
Not sure if there is a declspec syntax for it, but there is a pragma.
#pragma register_abi


Check the
C:\Program Files\Freescale\CodeWarrior for ColdFire V6.3\Help\PDF\Targeting_ColdFire.pdf
pdf.

Daniel
0 Kudos

504 Views
toddL
Contributor I
It sounds like the #pragma you are referring to is a global option, just like the global option in the IDE.  And here's a note from the PDF that you referenced that also leads me to believe this is a global setting. 
 


NOTE: Be sure that all called functions have prototypes. When you compile and link, parameter passing should be the same for all files and libraries.



What I'm looking for is to individually specify functions to allow for register passing.  I don't want to do that wholescale for the entire compilation.
 
Any other ideas?
 
Thanks,
-Todd
0 Kudos

504 Views
CompilerGuru
NXP Employee
NXP Employee
The pragma works for your case.
I did write some test code in the past in which just some function were using the register calling convention.
Note that the pragma stays active until you switch to another calling convention (I think #pragma push/#pragma pop work too). Don't forget to switch back.
Also do respect the warning, just putting the
pragma before a function definition wont help code which just reads the declaration in a header file. The declaration and the definition have to have the same calling convention.

Daniel
0 Kudos

504 Views
toddL
Contributor I
Thank you.  That did the trick!
 
-Todd
0 Kudos