Champs,
This is a question about C compiler for C6000 architecture (especially C64x+).
A distributor engineer has said that #pragma DATA_ALIGN overrode architecture's natural alignment to a smaller alignment as explained below in detail.
As described in the section 2.13 Linking C6400 Code With C6200/C6700/Older C6400 Object Code of SPRU187U, the alignment of top-level arrays for the C6400 family is 8 bytes. The compiler always try to use STDW or LDDW instead of STNDW or LDNDW even if an array is declared externally as following.
extern int array[100];
...
for (i = 0; i < 100; i ++)
foo = array[i];
However, the engineer found that we could override the alignment by #pragma DATA_ALIGN(array, 4) in the separate file which actually defined the array[100].
In the case, the above code does not work as expected if the array is NOT aligned to 8. (Instead we need LDNDW or STNDW.)
My question is, when we specify smaller alignment size than architecture's natural (or default) one, can the pragma override the alignment to the smaller value? How can we tell compiler that the array[] is aligned at 4 bytes instead of 8? I found that #pragma DATA_ALIGN could not applied to the extern declaration as following.
#pragma DATA_ALIGN(array, 4);
extern int array[100]; // Did not work. Compiler warns of this.
_nassert((int) array % 8 == 4); // This neither work.
Compiler version is 7.3.9. Any suggestion would be helpful.
Regards,
Atsushi