ARM Technical Support Knowledge Articles

PROGRAM STRUCTURE FOR REGISTER OPTIMIZATION

Applies to: General Topics

Answer


Information in this article applies to:


QUESTION

I have a problem with the code efficiency of my application. In my program, I have several small interface functions, but despite the fact that I am using Global Register Optimization, the calling functions seem to assume that these interface functions are using all CPU registers. The interface functions are pretty small and use almost no CPU registers.

What is the reason for that behavior?

ANSWER

The compiler generates the functions in the same order as they appear in the C source file. It is, therefore, important that the interface functions are in the C source before they are used. Otherwise, the Compiler does not know the function code and has to assume maximum register usage.

Therefore, the program structure inside a C source module should be:

  void my_simple_func1 (void)  {
    :
  }

  void my_simple_func2 (void)  {
    :
  }

  void my_complex_func (void)  {
    :
    my_simple_func1 ();
    my_simple_func2 ();
    :
  }

For optimum register allocation, it is important that the functions which are called by other functions are coded in the C source file.

MORE INFORMATION

Article last edited on: 2004-06-30 16:21:57

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential