Is there a way to specify that all member functions for a class or template are placed in a specific region? Specifying a section for each member function works, but makes maintenance of large classes more tedious. Ideally there should be a way to do this for all functions in a class or template. In the example below square() is placed in "sram2" but cube() is not. Thanks.
#pragma arm section code = "sram2" class foo { public: int __attribute__((section("sram2"))) square(int x) { return x * x; } int cube(int x) { return x * x * x; } }; #pragma arm section code
Is there a way to specify that all member functions for a class or template are placed in a specific region?
For inline methods like in your example? Probably not. That would defeat the purpose of making them inline in the first place.
Inline methods don't have any particular location in memory to begin with, so no clear way of changing it. They are designed to appear in-line in every location they're called. That's their whole purpose.
Templated classes are less localizable than inlined ones by yet another wide margin.
If you want to control where a method implementation goes, you have to start by making the implementation out-of-line, and you should probably stop to even think about templates.
Thanks for your responses.
Implementing a member function within the class declaration does not necessarily make it inline. The ARM compiler appears to use a similar criteria for inlining member functions than for inlining standalone functions. Member functions can be placed in a specific section using __attribute__((section())), as is the case of foo::square() in the example. Specifying a section overrides the compiler's inlining criteria, e.g. the function will not be inlined if the caller is in a different section. It would be desirable to have a directive to place all members functions of a class in the same section, but apparently there is none.