ARC Built-in Functions#
The following built-in functions are provided for ARC targets. The built-ins generate the corresponding assembly instructions. In the examples given below, the generated code often requires an operand or result to be in a register. Where necessary further code will be generated to ensure this is true, but for brevity this is not described in each case.
Note
Using a built-in to generate an instruction not supported by a target may cause problems. At present the compiler is not guaranteed to detect such misuse, and as a result an internal compiler error may be generated.
-
int __builtin_arc_aligned(void *val, int alignval)#
Return 1 if
val
is known to have the byte alignment given byalignval
, otherwise return 0. Note that this is different from__alignof__(*(char *)val) >= alignval
because __alignof__ sees only the type of the dereference, whereas __builtin_arc_align uses alignment information from the pointer as well as from the pointed-to type. The information available will depend on optimization level.
-
void __builtin_arc_brk(void)#
Generates
brk
-
unsigned int __builtin_arc_core_read(unsigned int regno)#
The operand is the number of a register to be read. Generates:
mov dest, rregno
where the value in
dest
will be the result returned from the built-in.
-
void __builtin_arc_core_write(unsigned int regno, unsigned int val)#
The first operand is the number of a register to be written, the second operand is a compile time constant to write into that register. Generates:
mov rregno, val
-
int __builtin_arc_divaw(int a, int b)#
Only available if either
-mcpu=ARC700
or-meA
is set. Generates:divaw dest, a, b
where the value in
dest
will be the result returned from the built-in.
-
void __builtin_arc_flag(unsigned int a)#
Generates
flag a
-
unsigned int __builtin_arc_lr(unsigned int auxr)#
The operand,
auxv
, is the address of an auxiliary register and must be a compile time constant. Generates:lr dest, [auxr]
Where the value in
dest
will be the result returned from the built-in.
-
void __builtin_arc_mul64(int a, int b)#
Only available with
-mmul64
. Generates:mul64 a, b
-
void __builtin_arc_mulu64(unsigned int a, unsigned int b)#
Only available with
-mmul64
. Generates:mulu64 a, b
-
void __builtin_arc_nop(void)#
Generates:
nop
-
int __builtin_arc_norm(int src)#
Only valid if the
norm
instruction is available through the-mnorm
option or by default with-mcpu=ARC700
. Generates:norm dest, src
Where the value in
dest
will be the result returned from the built-in.
-
short int __builtin_arc_normw(short int src)#
Only valid if the
normw
instruction is available through the-mnorm
option or by default with-mcpu=ARC700
. Generates:normw dest, src
Where the value in
dest
will be the result returned from the built-in.
-
void __builtin_arc_rtie(void)#
Generates:
rtie
-
void __builtin_arc_sleep(int a)#
Generates:
sleep a
-
void __builtin_arc_sr(unsigned int val, unsigned int auxr)#
The first argument,
val
, is a compile time constant to be written to the register, the second argument,auxr
, is the address of an auxiliary register. Generates:sr val, [auxr]
-
int __builtin_arc_swap(int src)#
Only valid with
-mswap
. Generates:swap dest, src
Where the value in
dest
will be the result returned from the built-in.
-
void __builtin_arc_swi(void)#
Generates:
swi
-
void __builtin_arc_sync(void)#
Only available with
-mcpu=ARC700
. Generates:sync
-
void __builtin_arc_trap_s(unsigned int c)#
Only available with
-mcpu=ARC700
. Generates:trap_s c
-
void __builtin_arc_unimp_s(void)#
Only available with
-mcpu=ARC700
. Generates:unimp_s
The instructions generated by the following builtins are not considered as candidates for scheduling. They are not moved around by the compiler during scheduling, and thus can be expected to appear where they are put in the C code:
__builtin_arc_brk()
__builtin_arc_core_read()
__builtin_arc_core_write()
__builtin_arc_flag()
__builtin_arc_lr()
__builtin_arc_sleep()
__builtin_arc_sr()
__builtin_arc_swi()