Hi,
this is a specific question about using the new altivec instructions (altivec2 extensions) of the e6500 in gcc
I use the target specific option -mcpu=e6500.
Building file: main.cpp
"/home/freescale/CodeWarrior_PA_10.4.0/eclipse/../Cross_Tools/gcc-4.8.2-Ee6500-aeabi/bin/powerpc-aeabi-g++" "../Sources/main.cpp" @"Sources/main_1.args" -o"Sources/main.o"
Sources/main_1.args : -O0 -g -Wall -std=c++0x -trigraphs -fno-use-cxa-atexit -fno-exceptions -frtti -fno-threadsafe-statics --param max-inline-recursive-depth=8 -c -mbig-endian -fno-builtin -fomit-frame-pointer -Wno-unknown-pragmas -m32 -mcpu=e6500
With this option he compiler sets the predefined macro __ALTIVEC__,
which ist checked
e.g. in #include <altivec.h>
altivec.h
#if !defined(__VEC__) || !defined(__ALTIVEC__)
#error Use the "-maltivec" flag to enable PowerPC AltiVec support
#endif
altivec.h checks __ALTIVEC2__ as well
#ifdef __ALTIVEC2__
/* New Altivec instructions */
#define vec_absd __builtin_vec_absd
#define vec_lvexbx __builtin_vec_lvexbx
#define vec_lvexhx __builtin_vec_lvexhx
#define vec_lvexwx __builtin_vec_lvexwx
#define vec_stvexbx __builtin_vec_stvexbx
#define vec_stvexhx __builtin_vec_stvexhx
#define vec_stvexwx __builtin_vec_stvexwx
#define vec_lvswx __builtin_vec_lvswx
#define vec_lvswxl __builtin_vec_lvswxl
#define vec_stvswx __builtin_vec_stvswx
#define vec_stvswxl __builtin_vec_stvswxl
#define vec_lvsm __builtin_vec_lvsm
#define vec_lvtlx __builtin_vec_lvtlx
#define vec_lvtlxl __builtin_vec_lvtlxl
#define vec_lvtrx __builtin_vec_lvtrx
#define vec_lvtrxl __builtin_vec_lvtrxl
#define vec_stvflx __builtin_vec_stvflx
#define vec_stvflxl __builtin_vec_stvflxl
#define vec_stvfrx __builtin_vec_stvfrx
#define vec_stvfrxl __builtin_vec_stvfrxl
#endif
Apparently __ALTIVEC2__ is not set by the -mcpu=e6500 setting.
Seems that -maltivec2 option does the job and sets __ALTIVEC2__.
Should I use -maltivec2 option? Are there any recommendations ?
Does gcc generate new altivec instructions when I just use -mcpu=e6500 w/o-maltivec2 ?
best regards
Alois
Solved! Go to Solution.
Hello Alois,
In order to active ALTIVEC2 in the compiler, you need to define "#include <altivec.h>" in you source file, and add build option "-maltivec2" from Project->Properties->C/C++ Build->Setting->PowerPC AEABI e6500 C Compiler->Miscellaneous->other flags in CodeWarrior 10.4. In CodeWarrior 10.3.3(GCC 4.7), "-maltivec2" is enabled automatically if -mcpu=e6500 enabled, you could find this information from the attached patch gcc.e6500-FSF47 for CW 10.3.3. The patch gcc.e6500-FSF-48 is for CW 10.4.
Please refer to the following content in gcc.e6500-FSF47.
-@gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple @gol
--mnew-mnemonics -mpopcntb -mpopcntd -mpower -mpower2 -mpowerpc64 @gol
--mpowerpc-gpopt -mpowerpc-gfxopt -msingle-float -mdouble-float @gol
--msimple-fpu -mstring -mmulhw -mdlmzb -mmfpgpr -mvsx}
+@gccoptlist{-maltivec -maltivec2 -mfprnd -mhard-float -mmfcrf
+-mmultiple @gol -mnew-mnemonics -mpopcntb -mpopcntd -mpower -mpower2
+-mpowerpc64 @gol -mpowerpc-gpopt -mpowerpc-gfxopt -msingle-float
+-mdouble-float @gol -msimple-fpu -mstring -mmulhw -mdlmzb -mmfpgpr
+-mvsx}
Have a great day,
Yiping
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
addon:
seems that gcc-4.7.2-Ee6500 and gcc-4.8.2-Ee6500 behave different in that respect
freescale@freescale-sdk:~/LinuxShared/workspace_01_10.4.0/Hello_Hip-core00/RAM$ "/home/freescale/CodeWarrior_PA_10.3.3/eclipse/../Cross_Tools/gcc-4.7.2-Ee6500-aeabi/bin/powerpc-aeabi-g++" "../Sources/hipLinInterpolateVect4.cpp" -O0 -g -Wall -std=c++0x -trigraphs -fno-use-cxa-atexit -fno-exceptions -frtti -fno-threadsafe-statics --param max-inline-recursive-depth=8 -c -mbig-endian -fno-builtin -fomit-frame-pointer -Wno-unknown-pragmas -m32 -mcpu=e6500 -o"Sources/hipLinInterpolateVect4.o"
freescale@freescale-sdk:~/LinuxShared/workspace_01_10.4.0/Hello_Hip-core00/RAM$ "/home/freescale/CodeWarrior_PA_10.4.0/eclipse/../Cross_Tools/gcc-4.8.2-Ee6500-aeabi/bin/powerpc-aeabi-g++" "../Sources/hipLinInterpolateVect4.cpp" -O0 -g -Wall -std=c++0x -trigraphs -fno-use-cxa-atexit -fno-exceptions -frtti -fno-threadsafe-statics --param max-inline-recursive-depth=8 -c -mbig-endian -fno-builtin -fomit-frame-pointer -Wno-unknown-pragmas -m32 -mcpu=e6500 -o"Sources/hipLinInterpolateVect4.o"
../Sources/hipLinInterpolateVect4.cpp: In function 'void hipLinInterpolateVect4_vec(sVECT_d4*, ucVECT4*, ucVECT4*, sVECT_d4*, short unsigned int, unsigned int, unsigned int)':
../Sources/hipLinInterpolateVect4.cpp:92:79: error: 'vec_lvtlxl' was not declared in this scope
const vector int16_t vi16OffsetTemp_dp = vec_lvtlxl (0, (int16_t*)ptOffset);
^
../Sources/hipLinInterpolateVect4.cpp:191:73: error: 'vec_lvtlx' was not declared in this scope
vu8VectUL = vec_lvtlx (0, (uint8_t*)(ptSrcVect ));
^
Hello Alois,
In order to active ALTIVEC2 in the compiler, you need to define "#include <altivec.h>" in you source file, and add build option "-maltivec2" from Project->Properties->C/C++ Build->Setting->PowerPC AEABI e6500 C Compiler->Miscellaneous->other flags in CodeWarrior 10.4. In CodeWarrior 10.3.3(GCC 4.7), "-maltivec2" is enabled automatically if -mcpu=e6500 enabled, you could find this information from the attached patch gcc.e6500-FSF47 for CW 10.3.3. The patch gcc.e6500-FSF-48 is for CW 10.4.
Please refer to the following content in gcc.e6500-FSF47.
-@gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple @gol
--mnew-mnemonics -mpopcntb -mpopcntd -mpower -mpower2 -mpowerpc64 @gol
--mpowerpc-gpopt -mpowerpc-gfxopt -msingle-float -mdouble-float @gol
--msimple-fpu -mstring -mmulhw -mdlmzb -mmfpgpr -mvsx}
+@gccoptlist{-maltivec -maltivec2 -mfprnd -mhard-float -mmfcrf
+-mmultiple @gol -mnew-mnemonics -mpopcntb -mpopcntd -mpower -mpower2
+-mpowerpc64 @gol -mpowerpc-gpopt -mpowerpc-gfxopt -msingle-float
+-mdouble-float @gol -msimple-fpu -mstring -mmulhw -mdlmzb -mmfpgpr
+-mvsx}
Have a great day,
Yiping
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Yiping,
OK, thats fine for me now.
Just to be sure: so -maltivec2 (and -mcpu=e6500) will be required in future versions of gcc as well?
regards
Alois
Hello Alois,
Yes, and I suggest you add "-maltivec2" in the compiler options in your project from CodeWarrior IDE, no need to consider about GCC version.
Have a great day,
Yiping
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------