Altera Nios II C2H Compiler Manual de usuario Pagina 74

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 138
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 73
3–34 9.1 Altera Corporation
Nios II C2H Compiler User Guide November 2009
Scheduling
compile-time due to the possibility of aliasing. This dependency causes
the read operation from ptr_b to be scheduled at State 2, rather than at
State 0.
__restrict__ Pointer Type Qualifier to Break Dependencies
If you know that a pointer never overlaps with another, you can inform
the compiler by declaring the pointer to be a restricted pointer. The
restrict type qualifier is introduced in the ISO C 99 specification. The
compiler ignores any or all aliasing implications of a pointer qualified by
__restrict__. The C99 specification states that if a pointer “p” is
declared with restrict, and another pointer “q” accesses any location also
accessed by “p,” the behavior is undefined. In other words, a restricted
pointer promises to never alias another pointer.
Example 3–28 demonstrates several pointers declared using the
__restrict__ type qualifier.
1 The qualifier comes after the *; __restrict__ qualifies the
pointer type, not the type that the pointer points to.
Example 3–28. Pointer Declarations with __restrict__
int * __restrict__ my_restricted_pointer_to_integer;
const int * __restrict__ my_restricted_pointer_to_constant_integer;
int * const __restrict__ my_constant_restricted_pointer_to_integer;
Figure 3–15 shows the dependency graph for Example 3–29, which uses
the __restrict__ type qualifier to inform the C2H Compiler that
ptr_a and ptr_b do not alias:
Example 3–29. Using __restrict__
void foo(int * __restrict__ ptr_a,
int * __restrict__ ptr_b)
{
int a, b;
a = *ptr_a;
*ptr_a = a + 7;
b = *ptr_b;
*ptr_b = b + 8;
}
Vista de pagina 73
1 2 ... 69 70 71 72 73 74 75 76 77 78 79 ... 137 138

Comentarios a estos manuales

Sin comentarios