Summary of intrinsic functions
The intrinsic functions provide direct access to low-level processor operations and can be very useful in, for example, time-critical routines. The intrinsic functions compile into inline code, either as a single instruction or as a short sequence of instructions.
The IAR C/C++ Compiler for RISC-V can be used with more than one set of intrinsic functions.
To use the IAR generic intrinsic functions in an application, include the header file intrinsics.h.
Note that the intrinsic function names start with double underscores, for example:
__disable_interrupt
This table summarizes the generic intrinsic functions:
Intrinsic function | Description |
|---|---|
Clears bits in a control and status register. | |
Disables interrupts | |
Enables interrupts | |
Returns the absolute value. | |
Classifies a floating-point value. | |
Returns an argument value with the sign of another argument. | |
Returns the largest of two values. | |
Returns the smallest of two values. | |
Returns an argument value with the inverted sign of another argument. | |
Returns the square root of an argument. | |
Returns an argument value with the sign bit combined from the sign bits of that argument and another argument. | |
Returns the interrupt state | |
Inserts the | |
Inserts the | |
Inserts the | |
Inserts the | |
Inserts the | |
Inserts the | |
Inserts the | |
Clears the Xandesdsp extension overflow bit. | |
Reads the Xandesdsp extension overflow bit. | |
Inserts a | |
Reads a control and status register. | |
Returns the return address. | |
Inserts an | |
Inserts an | |
Inserts an | |
Inserts an | |
Sets bits in a control and status register. | |
Restores the interrupt state | |
Inserts a | |
Writes a value to a control and status register. |
Intrinsic functions for bit manipulation
The header file iar_bitmanip_intrinsics.h defines three groups of bitmanip intrinsic functions:
__rv_XXXfunctions that operate on thelongdata type__rv32_XXXfunctions that operate on theint32_tdata type__rv64_XXXfunctions that operate on theint64_tdata type
The __rv64_XXX functions are only available on RV64.
These bitmanip functions are taken from the header file rvintrin.h.
Intrinsic functions for the P extension
The header file pext_intrinsic.h defines intrinsic functions for Packed-SIMD Instructions (the P extension). The P extension intrinsic functions use the prefix __rv_.
Intrinsic functions for the Cache Management extensions
By including the header file intrinsics.h, you also get access to intrinsic functions for CMO instructions (the standard extensions Zicbom, Zicbop, and Zicboz). The cache management extensions intrinsic functions use the prefix __iar_riscv_.
Intrinsic functions for Scalar cryptography
The header file iar_cryptography_intrinsics.h, defines __rv_xxx_ functions that operate on the long data type, with the exceptions __rv_sm4e and __rv_sm4ks, whose parameters are unsigned int on all architectures. Depending on the target architecture, that is RV32 or RV64, the appropriate intrinsic functions will be enabled, using the corresponding parameter sizes.
Intrinsic functions for AndeStar™ extensions
The instructions in the Xandesdsp (AndeStar™ DSP) instruction set extension can be accessed directly in your code, via a set of intrinsic functions, by including the header file nds_intrinsic.h. For information about the functions and instructions, see the AndeStar V5 DSP ISA Extension Specification, available at www.andestech.com. The IAR C/C++ Compiler for RISC-V supports the intrinsic functions on the formats __nds__instruction() and __nds__v_instruction().
The __nds__v_instruction() functions use vector types, for example uint8xt_t, which behave like arrays, but which can be placed in processor registers. In addition, arithmetical operations like + can be applied to vector types.
The header file iar_andesperf_intrinsics.h contains a small number of intrinsic functions that can be used when the Andes Performance Extension is enabled. Include this file if you want to use these functions.
Intrinsic functions for Nuclei DSP (Xxldsp)
The header file iar_nuclei_intrinsic.h defines two groups of intrinsic functions:
__nuclei_expdfunctions are defined in terms of theNNunsigned longdata type__nuclei_v_expdfunctions are defined in terms of the SIMD vector typeNNuint8x4_t(RV32) oruint8x8_t(RV64).