1 /**************************************************************************//**
2 * @file cmsis_armclang.h
3 * @brief CMSIS compiler armclang (Arm Compiler 6) header file
6 ******************************************************************************/
8 * Copyright (c) 2009-2021 Arm Limited. All rights reserved.
10 * SPDX-License-Identifier: Apache-2.0
12 * Licensed under the Apache License, Version 2.0 (the License); you may
13 * not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
16 * www.apache.org/licenses/LICENSE-2.0
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
25 /*lint -esym(9058, IRQn)*/ /* disable MISRA 2012 Rule 2.4 for IRQn */
27 #ifndef __CMSIS_ARMCLANG_H
28 #define __CMSIS_ARMCLANG_H
30 #pragma clang system_header /* treat file as system include file */
32 #ifndef __ARM_COMPAT_H
33 #include <arm_compat.h> /* Compatibility header for Arm Compiler 5 intrinsics */
36 /* CMSIS compiler specific defines */
41 #define __INLINE __inline
43 #ifndef __STATIC_INLINE
44 #define __STATIC_INLINE static __inline
46 #ifndef __STATIC_FORCEINLINE
47 #define __STATIC_FORCEINLINE __attribute__((always_inline)) static __inline
50 #define __NO_RETURN __attribute__((__noreturn__))
53 #define __USED __attribute__((used))
56 #define __WEAK __attribute__((weak))
59 #define __PACKED __attribute__((packed, aligned(1)))
61 #ifndef __PACKED_STRUCT
62 #define __PACKED_STRUCT struct __attribute__((packed, aligned(1)))
64 #ifndef __PACKED_UNION
65 #define __PACKED_UNION union __attribute__((packed, aligned(1)))
67 #ifndef __UNALIGNED_UINT32 /* deprecated */
68 #pragma clang diagnostic push
69 #pragma clang diagnostic ignored "-Wpacked"
70 /*lint -esym(9058, T_UINT32)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32 */
71 struct __attribute__((packed)) T_UINT32 { uint32_t v; };
72 #pragma clang diagnostic pop
73 #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
75 #ifndef __UNALIGNED_UINT16_WRITE
76 #pragma clang diagnostic push
77 #pragma clang diagnostic ignored "-Wpacked"
78 /*lint -esym(9058, T_UINT16_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_WRITE */
79 __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
80 #pragma clang diagnostic pop
81 #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
83 #ifndef __UNALIGNED_UINT16_READ
84 #pragma clang diagnostic push
85 #pragma clang diagnostic ignored "-Wpacked"
86 /*lint -esym(9058, T_UINT16_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_READ */
87 __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
88 #pragma clang diagnostic pop
89 #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
91 #ifndef __UNALIGNED_UINT32_WRITE
92 #pragma clang diagnostic push
93 #pragma clang diagnostic ignored "-Wpacked"
94 /*lint -esym(9058, T_UINT32_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_WRITE */
95 __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
96 #pragma clang diagnostic pop
97 #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
99 #ifndef __UNALIGNED_UINT32_READ
100 #pragma clang diagnostic push
101 #pragma clang diagnostic ignored "-Wpacked"
102 /*lint -esym(9058, T_UINT32_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_READ */
103 __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
104 #pragma clang diagnostic pop
105 #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
108 #define __ALIGNED(x) __attribute__((aligned(x)))
111 #define __RESTRICT __restrict
113 #ifndef __COMPILER_BARRIER
114 #define __COMPILER_BARRIER() __ASM volatile("":::"memory")
117 /* ######################### Startup and Lowlevel Init ######################## */
119 #ifndef __PROGRAM_START
120 #define __PROGRAM_START __main
124 #define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit
127 #ifndef __STACK_LIMIT
128 #define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base
131 #ifndef __VECTOR_TABLE
132 #define __VECTOR_TABLE __Vectors
135 #ifndef __VECTOR_TABLE_ATTRIBUTE
136 #define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section("RESET")))
139 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
141 #define __STACK_SEAL Image$$STACKSEAL$$ZI$$Base
144 #ifndef __TZ_STACK_SEAL_SIZE
145 #define __TZ_STACK_SEAL_SIZE 8U
148 #ifndef __TZ_STACK_SEAL_VALUE
149 #define __TZ_STACK_SEAL_VALUE 0xFEF5EDA5FEF5EDA5ULL
153 __STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop) {
154 *((uint64_t *)stackTop) = __TZ_STACK_SEAL_VALUE;
159 /* ########################### Core Function Access ########################### */
160 /** \ingroup CMSIS_Core_FunctionInterface
161 \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
166 \brief Enable IRQ Interrupts
167 \details Enables IRQ interrupts by clearing special-purpose register PRIMASK.
168 Can only be executed in Privileged modes.
170 /* intrinsic void __enable_irq(); see arm_compat.h */
174 \brief Disable IRQ Interrupts
175 \details Disables IRQ interrupts by setting special-purpose register PRIMASK.
176 Can only be executed in Privileged modes.
178 /* intrinsic void __disable_irq(); see arm_compat.h */
182 \brief Get Control Register
183 \details Returns the content of the Control Register.
184 \return Control Register value
186 __STATIC_FORCEINLINE uint32_t __get_CONTROL(void)
190 __ASM volatile ("MRS %0, control" : "=r" (result) );
195 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
197 \brief Get Control Register (non-secure)
198 \details Returns the content of the non-secure Control Register when in secure mode.
199 \return non-secure Control Register value
201 __STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void)
205 __ASM volatile ("MRS %0, control_ns" : "=r" (result) );
212 \brief Set Control Register
213 \details Writes the given value to the Control Register.
214 \param [in] control Control Register value to set
216 __STATIC_FORCEINLINE void __set_CONTROL(uint32_t control)
218 __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
222 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
224 \brief Set Control Register (non-secure)
225 \details Writes the given value to the non-secure Control Register when in secure state.
226 \param [in] control Control Register value to set
228 __STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control)
230 __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory");
236 \brief Get IPSR Register
237 \details Returns the content of the IPSR Register.
238 \return IPSR Register value
240 __STATIC_FORCEINLINE uint32_t __get_IPSR(void)
244 __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
250 \brief Get APSR Register
251 \details Returns the content of the APSR Register.
252 \return APSR Register value
254 __STATIC_FORCEINLINE uint32_t __get_APSR(void)
258 __ASM volatile ("MRS %0, apsr" : "=r" (result) );
264 \brief Get xPSR Register
265 \details Returns the content of the xPSR Register.
266 \return xPSR Register value
268 __STATIC_FORCEINLINE uint32_t __get_xPSR(void)
272 __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
278 \brief Get Process Stack Pointer
279 \details Returns the current value of the Process Stack Pointer (PSP).
280 \return PSP Register value
282 __STATIC_FORCEINLINE uint32_t __get_PSP(void)
286 __ASM volatile ("MRS %0, psp" : "=r" (result) );
291 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
293 \brief Get Process Stack Pointer (non-secure)
294 \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state.
295 \return PSP Register value
297 __STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void)
301 __ASM volatile ("MRS %0, psp_ns" : "=r" (result) );
308 \brief Set Process Stack Pointer
309 \details Assigns the given value to the Process Stack Pointer (PSP).
310 \param [in] topOfProcStack Process Stack Pointer value to set
312 __STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack)
314 __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
318 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
320 \brief Set Process Stack Pointer (non-secure)
321 \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state.
322 \param [in] topOfProcStack Process Stack Pointer value to set
324 __STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack)
326 __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : );
332 \brief Get Main Stack Pointer
333 \details Returns the current value of the Main Stack Pointer (MSP).
334 \return MSP Register value
336 __STATIC_FORCEINLINE uint32_t __get_MSP(void)
340 __ASM volatile ("MRS %0, msp" : "=r" (result) );
345 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
347 \brief Get Main Stack Pointer (non-secure)
348 \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state.
349 \return MSP Register value
351 __STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void)
355 __ASM volatile ("MRS %0, msp_ns" : "=r" (result) );
362 \brief Set Main Stack Pointer
363 \details Assigns the given value to the Main Stack Pointer (MSP).
364 \param [in] topOfMainStack Main Stack Pointer value to set
366 __STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack)
368 __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );
372 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
374 \brief Set Main Stack Pointer (non-secure)
375 \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state.
376 \param [in] topOfMainStack Main Stack Pointer value to set
378 __STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack)
380 __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : );
385 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
387 \brief Get Stack Pointer (non-secure)
388 \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state.
389 \return SP Register value
391 __STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void)
395 __ASM volatile ("MRS %0, sp_ns" : "=r" (result) );
401 \brief Set Stack Pointer (non-secure)
402 \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state.
403 \param [in] topOfStack Stack Pointer value to set
405 __STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack)
407 __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : );
413 \brief Get Priority Mask
414 \details Returns the current state of the priority mask bit from the Priority Mask Register.
415 \return Priority Mask value
417 __STATIC_FORCEINLINE uint32_t __get_PRIMASK(void)
421 __ASM volatile ("MRS %0, primask" : "=r" (result) );
426 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
428 \brief Get Priority Mask (non-secure)
429 \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state.
430 \return Priority Mask value
432 __STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void)
436 __ASM volatile ("MRS %0, primask_ns" : "=r" (result) );
443 \brief Set Priority Mask
444 \details Assigns the given value to the Priority Mask Register.
445 \param [in] priMask Priority Mask
447 __STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask)
449 __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
453 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
455 \brief Set Priority Mask (non-secure)
456 \details Assigns the given value to the non-secure Priority Mask Register when in secure state.
457 \param [in] priMask Priority Mask
459 __STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask)
461 __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory");
466 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
467 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
468 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
469 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) )
472 \details Enables FIQ interrupts by clearing special-purpose register FAULTMASK.
473 Can only be executed in Privileged modes.
475 #define __enable_fault_irq __enable_fiq /* see arm_compat.h */
480 \details Disables FIQ interrupts by setting special-purpose register FAULTMASK.
481 Can only be executed in Privileged modes.
483 #define __disable_fault_irq __disable_fiq /* see arm_compat.h */
487 \brief Get Base Priority
488 \details Returns the current value of the Base Priority register.
489 \return Base Priority register value
491 __STATIC_FORCEINLINE uint32_t __get_BASEPRI(void)
495 __ASM volatile ("MRS %0, basepri" : "=r" (result) );
500 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
502 \brief Get Base Priority (non-secure)
503 \details Returns the current value of the non-secure Base Priority register when in secure state.
504 \return Base Priority register value
506 __STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void)
510 __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) );
517 \brief Set Base Priority
518 \details Assigns the given value to the Base Priority register.
519 \param [in] basePri Base Priority value to set
521 __STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri)
523 __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory");
527 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
529 \brief Set Base Priority (non-secure)
530 \details Assigns the given value to the non-secure Base Priority register when in secure state.
531 \param [in] basePri Base Priority value to set
533 __STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri)
535 __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory");
541 \brief Set Base Priority with condition
542 \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
543 or the new value increases the BASEPRI priority level.
544 \param [in] basePri Base Priority value to set
546 __STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri)
548 __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory");
553 \brief Get Fault Mask
554 \details Returns the current value of the Fault Mask register.
555 \return Fault Mask register value
557 __STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void)
561 __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
566 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
568 \brief Get Fault Mask (non-secure)
569 \details Returns the current value of the non-secure Fault Mask register when in secure state.
570 \return Fault Mask register value
572 __STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void)
576 __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) );
583 \brief Set Fault Mask
584 \details Assigns the given value to the Fault Mask register.
585 \param [in] faultMask Fault Mask value to set
587 __STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask)
589 __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
593 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
595 \brief Set Fault Mask (non-secure)
596 \details Assigns the given value to the non-secure Fault Mask register when in secure state.
597 \param [in] faultMask Fault Mask value to set
599 __STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
601 __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory");
605 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
606 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
607 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
608 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */
611 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
612 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \
613 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) )
616 \brief Get Process Stack Pointer Limit
617 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
618 Stack Pointer Limit register hence zero is returned always in non-secure
621 \details Returns the current value of the Process Stack Pointer Limit (PSPLIM).
622 \return PSPLIM Register value
624 __STATIC_FORCEINLINE uint32_t __get_PSPLIM(void)
626 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
627 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \
628 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
629 // without main extensions, the non-secure PSPLIM is RAZ/WI
633 __ASM volatile ("MRS %0, psplim" : "=r" (result) );
638 #if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3))
640 \brief Get Process Stack Pointer Limit (non-secure)
641 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
642 Stack Pointer Limit register hence zero is returned always in non-secure
645 \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
646 \return PSPLIM Register value
648 __STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void)
650 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
651 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) )
652 // without main extensions, the non-secure PSPLIM is RAZ/WI
656 __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) );
664 \brief Set Process Stack Pointer Limit
665 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
666 Stack Pointer Limit register hence the write is silently ignored in non-secure
669 \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM).
670 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
672 __STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
674 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
675 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \
676 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
677 // without main extensions, the non-secure PSPLIM is RAZ/WI
678 (void)ProcStackPtrLimit;
680 __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit));
685 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
687 \brief Set Process Stack Pointer (non-secure)
688 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
689 Stack Pointer Limit register hence the write is silently ignored in non-secure
692 \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
693 \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
695 __STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
697 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
698 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) )
699 // without main extensions, the non-secure PSPLIM is RAZ/WI
700 (void)ProcStackPtrLimit;
702 __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit));
709 \brief Get Main Stack Pointer Limit
710 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
711 Stack Pointer Limit register hence zero is returned always.
713 \details Returns the current value of the Main Stack Pointer Limit (MSPLIM).
714 \return MSPLIM Register value
716 __STATIC_FORCEINLINE uint32_t __get_MSPLIM(void)
718 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
719 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \
720 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
721 // without main extensions, the non-secure MSPLIM is RAZ/WI
725 __ASM volatile ("MRS %0, msplim" : "=r" (result) );
731 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
733 \brief Get Main Stack Pointer Limit (non-secure)
734 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
735 Stack Pointer Limit register hence zero is returned always.
737 \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state.
738 \return MSPLIM Register value
740 __STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void)
742 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
743 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) )
744 // without main extensions, the non-secure MSPLIM is RAZ/WI
748 __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) );
756 \brief Set Main Stack Pointer Limit
757 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
758 Stack Pointer Limit register hence the write is silently ignored.
760 \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM).
761 \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set
763 __STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
765 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
766 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \
767 (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
768 // without main extensions, the non-secure MSPLIM is RAZ/WI
769 (void)MainStackPtrLimit;
771 __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit));
776 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
778 \brief Set Main Stack Pointer Limit (non-secure)
779 Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
780 Stack Pointer Limit register hence the write is silently ignored.
782 \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state.
783 \param [in] MainStackPtrLimit Main Stack Pointer value to set
785 __STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
787 #if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
788 (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) )
789 // without main extensions, the non-secure MSPLIM is RAZ/WI
790 (void)MainStackPtrLimit;
792 __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit));
797 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
798 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \
799 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */
803 \details Returns the current value of the Floating Point Status/Control register.
804 \return Floating Point Status/Control register value
806 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
807 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
808 #define __get_FPSCR (uint32_t)__builtin_arm_get_fpscr
810 #define __get_FPSCR() ((uint32_t)0U)
815 \details Assigns the given value to the Floating Point Status/Control register.
816 \param [in] fpscr Floating Point Status/Control value to set
818 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
819 (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
820 #define __set_FPSCR __builtin_arm_set_fpscr
822 #define __set_FPSCR(x) ((void)(x))
826 /*@} end of CMSIS_Core_RegAccFunctions */
829 /* ########################## Core Instruction Access ######################### */
830 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
831 Access to dedicated instructions
835 /* Define macros for porting to both thumb1 and thumb2.
836 * For thumb1, use low register (r0-r7), specified by constraint "l"
837 * Otherwise, use general registers, specified by constraint "r" */
838 #if defined (__thumb__) && !defined (__thumb2__)
839 #define __CMSIS_GCC_OUT_REG(r) "=l" (r)
840 #define __CMSIS_GCC_RW_REG(r) "+l" (r)
841 #define __CMSIS_GCC_USE_REG(r) "l" (r)
843 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
844 #define __CMSIS_GCC_RW_REG(r) "+r" (r)
845 #define __CMSIS_GCC_USE_REG(r) "r" (r)
850 \details No Operation does nothing. This instruction can be used for code alignment purposes.
852 #define __NOP __builtin_arm_nop
855 \brief Wait For Interrupt
856 \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
858 #define __WFI __builtin_arm_wfi
862 \brief Wait For Event
863 \details Wait For Event is a hint instruction that permits the processor to enter
864 a low-power state until one of a number of events occurs.
866 #define __WFE __builtin_arm_wfe
871 \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
873 #define __SEV __builtin_arm_sev
877 \brief Instruction Synchronization Barrier
878 \details Instruction Synchronization Barrier flushes the pipeline in the processor,
879 so that all instructions following the ISB are fetched from cache or memory,
880 after the instruction has been completed.
882 #define __ISB() __builtin_arm_isb(0xF)
885 \brief Data Synchronization Barrier
886 \details Acts as a special kind of Data Memory Barrier.
887 It completes when all explicit memory accesses before this instruction complete.
889 #define __DSB() __builtin_arm_dsb(0xF)
893 \brief Data Memory Barrier
894 \details Ensures the apparent order of the explicit memory operations before
895 and after the instruction, without ensuring their completion.
897 #define __DMB() __builtin_arm_dmb(0xF)
901 \brief Reverse byte order (32 bit)
902 \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
903 \param [in] value Value to reverse
904 \return Reversed value
906 #define __REV(value) __builtin_bswap32(value)
910 \brief Reverse byte order (16 bit)
911 \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
912 \param [in] value Value to reverse
913 \return Reversed value
915 #define __REV16(value) __ROR(__REV(value), 16)
919 \brief Reverse byte order (16 bit)
920 \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
921 \param [in] value Value to reverse
922 \return Reversed value
924 #define __REVSH(value) (int16_t)__builtin_bswap16(value)
928 \brief Rotate Right in unsigned value (32 bit)
929 \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
930 \param [in] op1 Value to rotate
931 \param [in] op2 Number of Bits to rotate
932 \return Rotated value
934 __STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
941 return (op1 >> op2) | (op1 << (32U - op2));
947 \details Causes the processor to enter Debug state.
948 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
949 \param [in] value is ignored by the processor.
950 If required, a debugger can use it to store additional information about the breakpoint.
952 #define __BKPT(value) __ASM volatile ("bkpt "#value)
956 \brief Reverse bit order of value
957 \details Reverses the bit order of the given value.
958 \param [in] value Value to reverse
959 \return Reversed value
961 #define __RBIT __builtin_arm_rbit
964 \brief Count leading zeros
965 \details Counts the number of leading zeros of a data value.
966 \param [in] value Value to count the leading zeros
967 \return number of leading zeros in value
969 __STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value)
971 /* Even though __builtin_clz produces a CLZ instruction on ARM, formally
972 __builtin_clz(0) is undefined behaviour, so handle this case specially.
973 This guarantees ARM-compatible results if happening to compile on a non-ARM
974 target, and ensures the compiler doesn't decide to activate any
975 optimisations using the logic "value was passed to __builtin_clz, so it
977 ARM Compiler 6.10 and possibly earlier will optimise this test away, leaving a
978 single CLZ instruction.
984 return __builtin_clz(value);
988 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
989 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
990 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
991 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \
992 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) )
995 \brief LDR Exclusive (8 bit)
996 \details Executes a exclusive LDR instruction for 8 bit value.
997 \param [in] ptr Pointer to data
998 \return value of type uint8_t at (*ptr)
1000 #define __LDREXB (uint8_t)__builtin_arm_ldrex
1004 \brief LDR Exclusive (16 bit)
1005 \details Executes a exclusive LDR instruction for 16 bit values.
1006 \param [in] ptr Pointer to data
1007 \return value of type uint16_t at (*ptr)
1009 #define __LDREXH (uint16_t)__builtin_arm_ldrex
1013 \brief LDR Exclusive (32 bit)
1014 \details Executes a exclusive LDR instruction for 32 bit values.
1015 \param [in] ptr Pointer to data
1016 \return value of type uint32_t at (*ptr)
1018 #define __LDREXW (uint32_t)__builtin_arm_ldrex
1022 \brief STR Exclusive (8 bit)
1023 \details Executes a exclusive STR instruction for 8 bit values.
1024 \param [in] value Value to store
1025 \param [in] ptr Pointer to location
1026 \return 0 Function succeeded
1027 \return 1 Function failed
1029 #define __STREXB (uint32_t)__builtin_arm_strex
1033 \brief STR Exclusive (16 bit)
1034 \details Executes a exclusive STR instruction for 16 bit values.
1035 \param [in] value Value to store
1036 \param [in] ptr Pointer to location
1037 \return 0 Function succeeded
1038 \return 1 Function failed
1040 #define __STREXH (uint32_t)__builtin_arm_strex
1044 \brief STR Exclusive (32 bit)
1045 \details Executes a exclusive STR instruction for 32 bit values.
1046 \param [in] value Value to store
1047 \param [in] ptr Pointer to location
1048 \return 0 Function succeeded
1049 \return 1 Function failed
1051 #define __STREXW (uint32_t)__builtin_arm_strex
1055 \brief Remove the exclusive lock
1056 \details Removes the exclusive lock which is created by LDREX.
1058 #define __CLREX __builtin_arm_clrex
1060 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1061 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1062 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1063 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \
1064 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */
1067 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1068 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1069 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1070 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) )
1073 \brief Signed Saturate
1074 \details Saturates a signed value.
1075 \param [in] value Value to be saturated
1076 \param [in] sat Bit position to saturate to (1..32)
1077 \return Saturated value
1079 #define __SSAT __builtin_arm_ssat
1083 \brief Unsigned Saturate
1084 \details Saturates an unsigned value.
1085 \param [in] value Value to be saturated
1086 \param [in] sat Bit position to saturate to (0..31)
1087 \return Saturated value
1089 #define __USAT __builtin_arm_usat
1093 \brief Rotate Right with Extend (32 bit)
1094 \details Moves each bit of a bitstring right by one bit.
1095 The carry input is shifted in at the left end of the bitstring.
1096 \param [in] value Value to rotate
1097 \return Rotated value
1099 __STATIC_FORCEINLINE uint32_t __RRX(uint32_t value)
1103 __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
1109 \brief LDRT Unprivileged (8 bit)
1110 \details Executes a Unprivileged LDRT instruction for 8 bit value.
1111 \param [in] ptr Pointer to data
1112 \return value of type uint8_t at (*ptr)
1114 __STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr)
1118 __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
1119 return ((uint8_t) result); /* Add explicit type cast here */
1124 \brief LDRT Unprivileged (16 bit)
1125 \details Executes a Unprivileged LDRT instruction for 16 bit values.
1126 \param [in] ptr Pointer to data
1127 \return value of type uint16_t at (*ptr)
1129 __STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr)
1133 __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
1134 return ((uint16_t) result); /* Add explicit type cast here */
1139 \brief LDRT Unprivileged (32 bit)
1140 \details Executes a Unprivileged LDRT instruction for 32 bit values.
1141 \param [in] ptr Pointer to data
1142 \return value of type uint32_t at (*ptr)
1144 __STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr)
1148 __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
1154 \brief STRT Unprivileged (8 bit)
1155 \details Executes a Unprivileged STRT instruction for 8 bit values.
1156 \param [in] value Value to store
1157 \param [in] ptr Pointer to location
1159 __STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
1161 __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1166 \brief STRT Unprivileged (16 bit)
1167 \details Executes a Unprivileged STRT instruction for 16 bit values.
1168 \param [in] value Value to store
1169 \param [in] ptr Pointer to location
1171 __STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
1173 __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1178 \brief STRT Unprivileged (32 bit)
1179 \details Executes a Unprivileged STRT instruction for 32 bit values.
1180 \param [in] value Value to store
1181 \param [in] ptr Pointer to location
1183 __STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
1185 __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
1188 #else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1189 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1190 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1191 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */
1194 \brief Signed Saturate
1195 \details Saturates a signed value.
1196 \param [in] value Value to be saturated
1197 \param [in] sat Bit position to saturate to (1..32)
1198 \return Saturated value
1200 __STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat)
1202 if ((sat >= 1U) && (sat <= 32U))
1204 const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
1205 const int32_t min = -1 - max ;
1219 \brief Unsigned Saturate
1220 \details Saturates an unsigned value.
1221 \param [in] value Value to be saturated
1222 \param [in] sat Bit position to saturate to (0..31)
1223 \return Saturated value
1225 __STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat)
1229 const uint32_t max = ((1U << sat) - 1U);
1230 if (val > (int32_t)max)
1239 return (uint32_t)val;
1242 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1243 (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1244 (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1245 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */
1248 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1249 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \
1250 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) )
1253 \brief Load-Acquire (8 bit)
1254 \details Executes a LDAB instruction for 8 bit value.
1255 \param [in] ptr Pointer to data
1256 \return value of type uint8_t at (*ptr)
1258 __STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr)
1262 __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
1263 return ((uint8_t) result);
1268 \brief Load-Acquire (16 bit)
1269 \details Executes a LDAH instruction for 16 bit values.
1270 \param [in] ptr Pointer to data
1271 \return value of type uint16_t at (*ptr)
1273 __STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr)
1277 __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
1278 return ((uint16_t) result);
1283 \brief Load-Acquire (32 bit)
1284 \details Executes a LDA instruction for 32 bit values.
1285 \param [in] ptr Pointer to data
1286 \return value of type uint32_t at (*ptr)
1288 __STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr)
1292 __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" );
1298 \brief Store-Release (8 bit)
1299 \details Executes a STLB instruction for 8 bit values.
1300 \param [in] value Value to store
1301 \param [in] ptr Pointer to location
1303 __STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
1305 __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
1310 \brief Store-Release (16 bit)
1311 \details Executes a STLH instruction for 16 bit values.
1312 \param [in] value Value to store
1313 \param [in] ptr Pointer to location
1315 __STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
1317 __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
1322 \brief Store-Release (32 bit)
1323 \details Executes a STL instruction for 32 bit values.
1324 \param [in] value Value to store
1325 \param [in] ptr Pointer to location
1327 __STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr)
1329 __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" );
1334 \brief Load-Acquire Exclusive (8 bit)
1335 \details Executes a LDAB exclusive instruction for 8 bit value.
1336 \param [in] ptr Pointer to data
1337 \return value of type uint8_t at (*ptr)
1339 #define __LDAEXB (uint8_t)__builtin_arm_ldaex
1343 \brief Load-Acquire Exclusive (16 bit)
1344 \details Executes a LDAH exclusive instruction for 16 bit values.
1345 \param [in] ptr Pointer to data
1346 \return value of type uint16_t at (*ptr)
1348 #define __LDAEXH (uint16_t)__builtin_arm_ldaex
1352 \brief Load-Acquire Exclusive (32 bit)
1353 \details Executes a LDA exclusive instruction for 32 bit values.
1354 \param [in] ptr Pointer to data
1355 \return value of type uint32_t at (*ptr)
1357 #define __LDAEX (uint32_t)__builtin_arm_ldaex
1361 \brief Store-Release Exclusive (8 bit)
1362 \details Executes a STLB exclusive instruction for 8 bit values.
1363 \param [in] value Value to store
1364 \param [in] ptr Pointer to location
1365 \return 0 Function succeeded
1366 \return 1 Function failed
1368 #define __STLEXB (uint32_t)__builtin_arm_stlex
1372 \brief Store-Release Exclusive (16 bit)
1373 \details Executes a STLH exclusive instruction for 16 bit values.
1374 \param [in] value Value to store
1375 \param [in] ptr Pointer to location
1376 \return 0 Function succeeded
1377 \return 1 Function failed
1379 #define __STLEXH (uint32_t)__builtin_arm_stlex
1383 \brief Store-Release Exclusive (32 bit)
1384 \details Executes a STL exclusive instruction for 32 bit values.
1385 \param [in] value Value to store
1386 \param [in] ptr Pointer to location
1387 \return 0 Function succeeded
1388 \return 1 Function failed
1390 #define __STLEX (uint32_t)__builtin_arm_stlex
1392 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1393 (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \
1394 (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */
1396 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
1399 /* ################### Compiler specific Intrinsics ########################### */
1400 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
1401 Access to dedicated SIMD instructions
1405 #if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))
1407 #define __SADD8 __builtin_arm_sadd8
1408 #define __QADD8 __builtin_arm_qadd8
1409 #define __SHADD8 __builtin_arm_shadd8
1410 #define __UADD8 __builtin_arm_uadd8
1411 #define __UQADD8 __builtin_arm_uqadd8
1412 #define __UHADD8 __builtin_arm_uhadd8
1413 #define __SSUB8 __builtin_arm_ssub8
1414 #define __QSUB8 __builtin_arm_qsub8
1415 #define __SHSUB8 __builtin_arm_shsub8
1416 #define __USUB8 __builtin_arm_usub8
1417 #define __UQSUB8 __builtin_arm_uqsub8
1418 #define __UHSUB8 __builtin_arm_uhsub8
1419 #define __SADD16 __builtin_arm_sadd16
1420 #define __QADD16 __builtin_arm_qadd16
1421 #define __SHADD16 __builtin_arm_shadd16
1422 #define __UADD16 __builtin_arm_uadd16
1423 #define __UQADD16 __builtin_arm_uqadd16
1424 #define __UHADD16 __builtin_arm_uhadd16
1425 #define __SSUB16 __builtin_arm_ssub16
1426 #define __QSUB16 __builtin_arm_qsub16
1427 #define __SHSUB16 __builtin_arm_shsub16
1428 #define __USUB16 __builtin_arm_usub16
1429 #define __UQSUB16 __builtin_arm_uqsub16
1430 #define __UHSUB16 __builtin_arm_uhsub16
1431 #define __SASX __builtin_arm_sasx
1432 #define __QASX __builtin_arm_qasx
1433 #define __SHASX __builtin_arm_shasx
1434 #define __UASX __builtin_arm_uasx
1435 #define __UQASX __builtin_arm_uqasx
1436 #define __UHASX __builtin_arm_uhasx
1437 #define __SSAX __builtin_arm_ssax
1438 #define __QSAX __builtin_arm_qsax
1439 #define __SHSAX __builtin_arm_shsax
1440 #define __USAX __builtin_arm_usax
1441 #define __UQSAX __builtin_arm_uqsax
1442 #define __UHSAX __builtin_arm_uhsax
1443 #define __USAD8 __builtin_arm_usad8
1444 #define __USADA8 __builtin_arm_usada8
1445 #define __SSAT16 __builtin_arm_ssat16
1446 #define __USAT16 __builtin_arm_usat16
1447 #define __UXTB16 __builtin_arm_uxtb16
1448 #define __UXTAB16 __builtin_arm_uxtab16
1449 #define __SXTB16 __builtin_arm_sxtb16
1450 #define __SXTAB16 __builtin_arm_sxtab16
1451 #define __SMUAD __builtin_arm_smuad
1452 #define __SMUADX __builtin_arm_smuadx
1453 #define __SMLAD __builtin_arm_smlad
1454 #define __SMLADX __builtin_arm_smladx
1455 #define __SMLALD __builtin_arm_smlald
1456 #define __SMLALDX __builtin_arm_smlaldx
1457 #define __SMUSD __builtin_arm_smusd
1458 #define __SMUSDX __builtin_arm_smusdx
1459 #define __SMLSD __builtin_arm_smlsd
1460 #define __SMLSDX __builtin_arm_smlsdx
1461 #define __SMLSLD __builtin_arm_smlsld
1462 #define __SMLSLDX __builtin_arm_smlsldx
1463 #define __SEL __builtin_arm_sel
1464 #define __QADD __builtin_arm_qadd
1465 #define __QSUB __builtin_arm_qsub
1467 #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
1468 ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
1470 #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
1471 ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
1473 #define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2))
1475 #define __SXTAB16_RORn(ARG1, ARG2, ARG3) __SXTAB16(ARG1, __ROR(ARG2, ARG3))
1477 __STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
1481 __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
1485 #endif /* (__ARM_FEATURE_DSP == 1) */
1486 /*@} end of group CMSIS_SIMD_intrinsics */
1489 #endif /* __CMSIS_ARMCLANG_H */