
Altera Corporation 9.1 3–33
November 2009 Nios II C2H Compiler User Guide
C-to-Hardware Mapping Reference
operations that come before it. Because arrays and structures are
equivalent to pointer operations, the same considerations apply when
indexing into an array or structures.
This section describes the implications of aliasing on the C2H Compiler
and outlines methods to prevent unnecessary dependencies.
Figure 3–14 shows the dependency graph for Example 3–27.
Example 3–27. Pointer Aliasing
void foo(int *ptr_a, int *ptr_b)
{
int a, b;
a = *ptr_a;
*ptr_a = a + 7;
b = *ptr_b;
*ptr_b = b + 8;
}
Figure 3–14. Pointer-Related Data Dependency
In this example, the C2H Compiler cannot determine whether or not
ptr_a and ptr_b ever point to the same address. Therefore, it schedules
conservatively, under the assumption that they do. The dependency
graph shows that the read operation from ptr_b depends on the write
operation to ptr_a. This is not a dependency on the variable ptr_a, but
rather a dependency on a location in memory that is unknown at
Comentários a estes Manuais