Make use of intrinsic functions

The Arm C Language Extensions (ACLE) are a set of features to enable C/C++ code to exploit the advanced features of the Arm Architecture. One such extension is the definition of intrinsic functions that map to specific Arm instructions that may not otherwise be generated by the compiler.

ASCET-DEVELOPER allows the creation of an Arithmetic Services file that defines a function to be called in a specific scenario. That can subsequently be mapped to an intrinsic function at compile time.

For example, consider the following variable definition, which saturates at +/-32K:

representation R_Speed{
		range = -32768 .. 32767;
		datatype = sint16;
		formula = f_0bn0;
	}
type T_Speed is real using R_Speed;

By default, this definition may result in inefficient source code being generated, with additional saturation code being applied, as seen in the code:

	_t1sint32 = a+b;
x = (sint16)(((_t1sint32 >= =32768) ? (((_t1sint32 <=32767) ?
               _t1sint32 : 32767))  : -32768));

The following code shows how you can define an arithmetic service so that a function is used to implement the code instead:

+1|s16|s16|s16=(sint16)ADDLIM_S16S16_S16(%i1%,%i2%)

The ASCET-DEVELOPER code generator will be able to make use of this function, for example:

	x = ADDLIM_S16S16_S16(a, b);

You can then map this code to an ACLE intrinsic function in a user provided header file, for example:

#define ADDLIM_S16S16_S16(a, b)	__QADD16(a, b)

This will compile into a single QADD instruction.

Previous Next