Lesson 5: Writing Linear Assembly
2-25
Compiler Optimization Tutorial
2.6
Lesson 5: Writing Linear Assembly
When the compiler does not fully exploit the potential of the ’C6000 architec-
ture, you may be able to get better performance by writing your loop in linear
assembly. Linear assembly is the input for the assembly optimizer.
Linear assembly is similar to regular ’C6000 assembly code in that you use
’C6000 instructions to write your code. With linear assembly, however, you do
not need to specify all of the information that you need to specify in regular
’C6000 assembly code. With linear assembly code, you have the option of
specifying the information or letting the assembly optimizer specify it for you.
Here is the information that you do
not need to specify in linear assembly code:
-
Parallel instructions
-
Pipeline latency
-
Register usage
-
Which functional unit is being used
If you choose not to specify these things, the assembly optimizer determines
the information that you do not include, based on the information that it has
about your code. As with other code generation tools, you might need to modify
your linear assembly code until you are satisfied with its performance. When
you do this, you will probably want to add more detail to your linear assembly.
For example, you might want to specify which functional unit should be used.
Before you use the assembly optimizer, you need to know the following things
about how it works:
-
A linear assembly file must be specified with a .sa extension.
-
Linear assembly code should include the .cproc and .endproc directives.
The .cproc and .endproc directives delimit a section of your code that you
want the assembly optimizer to optimize. Use .cproc at the beginning of
the section and .endproc at the end of the section. In this way, you can set
off sections of your assembly code that you want to be optimized, like pro-
cedures or functions.
-
Linear assembly code may include a .reg directive. The .reg directive al-
lows you to use descriptive names for values that will be stored in regis-
ters. When you use .reg, the assembly optimizer chooses a register whose
use agrees with the functional units chosen for the instructions that oper-
ate on the value.
-
Linear assembly code may include a .trip directive. The .trip directive
specifies the value of the trip count. The trip count indicates how many
times a loop will iterate.