[chbot] GCC / Codesourcery #pragma for ARM Cortex M3
Michael Hope
michaelh at juju.net.nz
Sun Oct 16 00:26:58 BST 2011
On 16 October 2011 08:30, Mark Atherton <markaren1 at xtra.co.nz> wrote:
> Dunno if anyone has the answer off the top of their head...
>
> I need tight optimization around a small code block (can be made into
> a function if need be).
>
> The main body (10k lines) has been tested without any optimization,
> so, I am loathed to change optimization for the whole system and then
> have to re-test.
>
> Anyone know of an optimization pragma I can use just for this tight piece ?
>
> I guess the other option is do-it-in-assembler, which isn't such a
> bad idea now I come to think of it. The M3 is such a lovely target...
>
> Anyway, one step at a time (just trying to think of an M3 pun, maybe
> that is it :)
Hi Mark. The most portable way is to split the critical function into
another file. Failing that, you can use the 'optimize' function
attribute or #pragma GCC optimize to change the level on a per
function basis.
See:
http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
I've never used it and don't know which version the attribute appeared in.
-- Michael
More information about the Chchrobotics
mailing list