LoongArch Function Attributes (Using the GNU Compiler Collection (GCC)) (original) (raw)


6.4.1.13 LoongArch Function Attributes

These function attributes are supported by the LoongArch end:

strict-align

no-strict-align

strict-align indicates that the compiler should not assume that unaligned memory references are handled by the system. To allow the compiler to assume that aligned memory references are handled by the system, the inverse attributeno-strict-align can be specified. The behavior is same as for the command-line option -mstrict-align and -mno-strict-align.

cmodel=

Indicates that code should be generated for a particular code model for this function. The behavior and permissible arguments are the same as for the command-line option -mcmodel=.

arch=

Specifies the architecture version and architectural extensions to use for this function. The behavior and permissible arguments are the same as for the -march= command-line option.

tune=

Specifies the core for which to tune the performance of this function. The behavior and permissible arguments are the same as for the -mtune=command-line option.

lsx

no-lsx

lsx indicates that vector instruction generation is allowed (not allowed) when compiling the function. The behavior is same as for the command-line option-mlsx and -mno-lsx.

lasx

no-lasx

lasx indicates that lasx instruction generation is allowed (not allowed) when compiling the function. The behavior is slightly different from the command-line option -mno-lasx. Example:

test.c: typedef int v4i32 attribute ((vector_size(16), aligned(16)));

v4i32 a, b, c; #ifdef WITH_ATTR attribute ((target("no-lasx"))) void #else void #endif test () { c = a + b; }

$ gcc test.c -o test.s -O2 -mlasx -DWITH_ATTR

Compiled as above, 128-bit vectorization is possible. But the following method cannot perform 128-bit vectorization.

$ gcc test.c -o test.s -O2 -mlasx -mno-lasx