]> begriffs open source - cmsis/blob - CMSIS/Core/Include/cmsis_armclang.h
Fix wrong comment in SCB about MVFR2 register
[cmsis] / CMSIS / Core / Include / cmsis_armclang.h
1 /**************************************************************************//**
2  * @file     cmsis_armclang.h
3  * @brief    CMSIS compiler ARMCLANG (ARM compiler V6) header file
4  * @version  V5.0.3
5  * @date     27. March 2017
6  ******************************************************************************/
7 /*
8  * Copyright (c) 2009-2017 ARM Limited. All rights reserved.
9  *
10  * SPDX-License-Identifier: Apache-2.0
11  *
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
15  *
16  * www.apache.org/licenses/LICENSE-2.0
17  *
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.
23  */
24
25 //lint -esym(9058, IRQn)   disable MISRA 2012 Rule 2.4 for IRQn
26
27 #ifndef __CMSIS_ARMCLANG_H
28 #define __CMSIS_ARMCLANG_H
29
30 #ifndef __ARM_COMPAT_H
31 #include <arm_compat.h>    /* Compatibility header for ARM Compiler 5 intrinsics */
32 #endif
33
34 /* CMSIS compiler specific defines */
35 #ifndef   __ASM
36   #define __ASM                                  __asm
37 #endif
38 #ifndef   __INLINE
39   #define __INLINE                               __inline
40 #endif
41 #ifndef   __STATIC_INLINE
42   #define __STATIC_INLINE                        static __inline
43 #endif
44 #ifndef   __NO_RETURN
45   #define __NO_RETURN                            __attribute__((noreturn))
46 #endif
47 #ifndef   __USED
48   #define __USED                                 __attribute__((used))
49 #endif
50 #ifndef   __WEAK
51   #define __WEAK                                 __attribute__((weak))
52 #endif
53 #ifndef   __PACKED
54   #define __PACKED                               __attribute__((packed, aligned(1)))
55 #endif
56 #ifndef   __PACKED_STRUCT
57   #define __PACKED_STRUCT                        struct __attribute__((packed, aligned(1)))
58 #endif
59 #ifndef   __PACKED_UNION
60   #define __PACKED_UNION                         union __attribute__((packed, aligned(1)))
61 #endif
62 #ifndef   __UNALIGNED_UINT32        /* deprecated */
63   #pragma clang diagnostic push
64   #pragma clang diagnostic ignored "-Wpacked"
65 //lint -esym(9058, T_UINT32)  disable MISRA 2012 Rule 2.4 for T_UINT32
66   struct __attribute__((packed)) T_UINT32 { uint32_t v; };
67   #pragma clang diagnostic pop
68   #define __UNALIGNED_UINT32(x)                  (((struct T_UINT32 *)(x))->v)
69 #endif
70 #ifndef   __UNALIGNED_UINT16_WRITE
71   #pragma clang diagnostic push
72   #pragma clang diagnostic ignored "-Wpacked"
73 //lint -esym(9058, T_UINT16_WRITE)  disable MISRA 2012 Rule 2.4 for T_UINT16_WRITE
74   __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
75   #pragma clang diagnostic pop
76   #define __UNALIGNED_UINT16_WRITE(addr, val)    (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
77 #endif
78 #ifndef   __UNALIGNED_UINT16_READ
79   #pragma clang diagnostic push
80   #pragma clang diagnostic ignored "-Wpacked"
81 //lint -esym(9058, T_UINT16_READ)  disable MISRA 2012 Rule 2.4 for T_UINT16_READ
82   __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
83   #pragma clang diagnostic pop
84   #define __UNALIGNED_UINT16_READ(addr)          (((const struct T_UINT16_READ *)(const void *)(addr))->v)
85 #endif
86 #ifndef   __UNALIGNED_UINT32_WRITE
87   #pragma clang diagnostic push
88   #pragma clang diagnostic ignored "-Wpacked"
89 //lint -esym(9058, T_UINT32_WRITE)  disable MISRA 2012 Rule 2.4 for T_UINT32_WRITE
90   __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
91   #pragma clang diagnostic pop
92   #define __UNALIGNED_UINT32_WRITE(addr, val)    (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
93 #endif
94 #ifndef   __UNALIGNED_UINT32_READ
95   #pragma clang diagnostic push
96   #pragma clang diagnostic ignored "-Wpacked"
97 //lint -esym(9058, T_UINT32_READ)  disable MISRA 2012 Rule 2.4 for T_UINT32_READ
98   __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
99   #pragma clang diagnostic pop
100   #define __UNALIGNED_UINT32_READ(addr)          (((const struct T_UINT32_READ *)(const void *)(addr))->v)
101 #endif
102 #ifndef   __ALIGNED
103   #define __ALIGNED(x)                           __attribute__((aligned(x)))
104 #endif
105
106
107 /* ###########################  Core Function Access  ########################### */
108 /** \ingroup  CMSIS_Core_FunctionInterface
109     \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
110   @{
111  */
112
113 /**
114   \brief   Enable IRQ Interrupts
115   \details Enables IRQ interrupts by clearing the I-bit in the CPSR.
116            Can only be executed in Privileged modes.
117  */
118 /* intrinsic void __enable_irq();  see arm_compat.h */
119
120
121 /**
122   \brief   Disable IRQ Interrupts
123   \details Disables IRQ interrupts by setting the I-bit in the CPSR.
124            Can only be executed in Privileged modes.
125  */
126 /* intrinsic void __disable_irq();  see arm_compat.h */
127
128
129 /**
130   \brief   Get Control Register
131   \details Returns the content of the Control Register.
132   \return               Control Register value
133  */
134 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_CONTROL(void)
135 {
136   uint32_t result;
137
138   __ASM volatile ("MRS %0, control" : "=r" (result) );
139   return(result);
140 }
141
142
143 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
144 /**
145   \brief   Get Control Register (non-secure)
146   \details Returns the content of the non-secure Control Register when in secure mode.
147   \return               non-secure Control Register value
148  */
149 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_CONTROL_NS(void)
150 {
151   uint32_t result;
152
153   __ASM volatile ("MRS %0, control_ns" : "=r" (result) );
154   return(result);
155 }
156 #endif
157
158
159 /**
160   \brief   Set Control Register
161   \details Writes the given value to the Control Register.
162   \param [in]    control  Control Register value to set
163  */
164 __attribute__((always_inline)) __STATIC_INLINE void __set_CONTROL(uint32_t control)
165 {
166   __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
167 }
168
169
170 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
171 /**
172   \brief   Set Control Register (non-secure)
173   \details Writes the given value to the non-secure Control Register when in secure state.
174   \param [in]    control  Control Register value to set
175  */
176 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_CONTROL_NS(uint32_t control)
177 {
178   __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory");
179 }
180 #endif
181
182
183 /**
184   \brief   Get IPSR Register
185   \details Returns the content of the IPSR Register.
186   \return               IPSR Register value
187  */
188 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_IPSR(void)
189 {
190   uint32_t result;
191
192   __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
193   return(result);
194 }
195
196
197 /**
198   \brief   Get APSR Register
199   \details Returns the content of the APSR Register.
200   \return               APSR Register value
201  */
202 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_APSR(void)
203 {
204   uint32_t result;
205
206   __ASM volatile ("MRS %0, apsr" : "=r" (result) );
207   return(result);
208 }
209
210
211 /**
212   \brief   Get xPSR Register
213   \details Returns the content of the xPSR Register.
214   \return               xPSR Register value
215  */
216 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_xPSR(void)
217 {
218   uint32_t result;
219
220   __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
221   return(result);
222 }
223
224
225 /**
226   \brief   Get Process Stack Pointer
227   \details Returns the current value of the Process Stack Pointer (PSP).
228   \return               PSP Register value
229  */
230 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSP(void)
231 {
232   register uint32_t result;
233
234   __ASM volatile ("MRS %0, psp"  : "=r" (result) );
235   return(result);
236 }
237
238
239 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
240 /**
241   \brief   Get Process Stack Pointer (non-secure)
242   \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state.
243   \return               PSP Register value
244  */
245 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSP_NS(void)
246 {
247   register uint32_t result;
248
249   __ASM volatile ("MRS %0, psp_ns"  : "=r" (result) );
250   return(result);
251 }
252 #endif
253
254
255 /**
256   \brief   Set Process Stack Pointer
257   \details Assigns the given value to the Process Stack Pointer (PSP).
258   \param [in]    topOfProcStack  Process Stack Pointer value to set
259  */
260 __attribute__((always_inline)) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
261 {
262   __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
263 }
264
265
266 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
267 /**
268   \brief   Set Process Stack Pointer (non-secure)
269   \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state.
270   \param [in]    topOfProcStack  Process Stack Pointer value to set
271  */
272 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack)
273 {
274   __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : );
275 }
276 #endif
277
278
279 /**
280   \brief   Get Main Stack Pointer
281   \details Returns the current value of the Main Stack Pointer (MSP).
282   \return               MSP Register value
283  */
284 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSP(void)
285 {
286   register uint32_t result;
287
288   __ASM volatile ("MRS %0, msp" : "=r" (result) );
289   return(result);
290 }
291
292
293 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
294 /**
295   \brief   Get Main Stack Pointer (non-secure)
296   \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state.
297   \return               MSP Register value
298  */
299 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSP_NS(void)
300 {
301   register uint32_t result;
302
303   __ASM volatile ("MRS %0, msp_ns" : "=r" (result) );
304   return(result);
305 }
306 #endif
307
308
309 /**
310   \brief   Set Main Stack Pointer
311   \details Assigns the given value to the Main Stack Pointer (MSP).
312   \param [in]    topOfMainStack  Main Stack Pointer value to set
313  */
314 __attribute__((always_inline)) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
315 {
316   __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );
317 }
318
319
320 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
321 /**
322   \brief   Set Main Stack Pointer (non-secure)
323   \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state.
324   \param [in]    topOfMainStack  Main Stack Pointer value to set
325  */
326 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack)
327 {
328   __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : );
329 }
330 #endif
331
332
333 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
334 /**
335   \brief   Get Stack Pointer (non-secure)
336   \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state.
337   \return               SP Register value
338  */
339 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_SP_NS(void)
340 {
341   register uint32_t result;
342
343   __ASM volatile ("MRS %0, sp_ns" : "=r" (result) );
344   return(result);
345 }
346
347
348 /**
349   \brief   Set Stack Pointer (non-secure)
350   \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state.
351   \param [in]    topOfStack  Stack Pointer value to set
352  */
353 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_SP_NS(uint32_t topOfStack)
354 {
355   __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : );
356 }
357 #endif
358
359
360 /**
361   \brief   Get Priority Mask
362   \details Returns the current state of the priority mask bit from the Priority Mask Register.
363   \return               Priority Mask value
364  */
365 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PRIMASK(void)
366 {
367   uint32_t result;
368
369   __ASM volatile ("MRS %0, primask" : "=r" (result) );
370   return(result);
371 }
372
373
374 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
375 /**
376   \brief   Get Priority Mask (non-secure)
377   \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state.
378   \return               Priority Mask value
379  */
380 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PRIMASK_NS(void)
381 {
382   uint32_t result;
383
384   __ASM volatile ("MRS %0, primask_ns" : "=r" (result) );
385   return(result);
386 }
387 #endif
388
389
390 /**
391   \brief   Set Priority Mask
392   \details Assigns the given value to the Priority Mask Register.
393   \param [in]    priMask  Priority Mask
394  */
395 __attribute__((always_inline)) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
396 {
397   __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
398 }
399
400
401 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
402 /**
403   \brief   Set Priority Mask (non-secure)
404   \details Assigns the given value to the non-secure Priority Mask Register when in secure state.
405   \param [in]    priMask  Priority Mask
406  */
407 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PRIMASK_NS(uint32_t priMask)
408 {
409   __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory");
410 }
411 #endif
412
413
414 #if ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \
415      (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \
416      (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))    )
417 /**
418   \brief   Enable FIQ
419   \details Enables FIQ interrupts by clearing the F-bit in the CPSR.
420            Can only be executed in Privileged modes.
421  */
422 #define __enable_fault_irq                __enable_fiq   /* see arm_compat.h */
423
424
425 /**
426   \brief   Disable FIQ
427   \details Disables FIQ interrupts by setting the F-bit in the CPSR.
428            Can only be executed in Privileged modes.
429  */
430 #define __disable_fault_irq               __disable_fiq   /* see arm_compat.h */
431
432
433 /**
434   \brief   Get Base Priority
435   \details Returns the current value of the Base Priority register.
436   \return               Base Priority register value
437  */
438 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_BASEPRI(void)
439 {
440   uint32_t result;
441
442   __ASM volatile ("MRS %0, basepri" : "=r" (result) );
443   return(result);
444 }
445
446
447 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
448 /**
449   \brief   Get Base Priority (non-secure)
450   \details Returns the current value of the non-secure Base Priority register when in secure state.
451   \return               Base Priority register value
452  */
453 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_BASEPRI_NS(void)
454 {
455   uint32_t result;
456
457   __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) );
458   return(result);
459 }
460 #endif
461
462
463 /**
464   \brief   Set Base Priority
465   \details Assigns the given value to the Base Priority register.
466   \param [in]    basePri  Base Priority value to set
467  */
468 __attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
469 {
470   __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory");
471 }
472
473
474 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
475 /**
476   \brief   Set Base Priority (non-secure)
477   \details Assigns the given value to the non-secure Base Priority register when in secure state.
478   \param [in]    basePri  Base Priority value to set
479  */
480 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_BASEPRI_NS(uint32_t basePri)
481 {
482   __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory");
483 }
484 #endif
485
486
487 /**
488   \brief   Set Base Priority with condition
489   \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
490            or the new value increases the BASEPRI priority level.
491   \param [in]    basePri  Base Priority value to set
492  */
493 __attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
494 {
495   __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory");
496 }
497
498
499 /**
500   \brief   Get Fault Mask
501   \details Returns the current value of the Fault Mask register.
502   \return               Fault Mask register value
503  */
504 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FAULTMASK(void)
505 {
506   uint32_t result;
507
508   __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
509   return(result);
510 }
511
512
513 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
514 /**
515   \brief   Get Fault Mask (non-secure)
516   \details Returns the current value of the non-secure Fault Mask register when in secure state.
517   \return               Fault Mask register value
518  */
519 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_FAULTMASK_NS(void)
520 {
521   uint32_t result;
522
523   __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) );
524   return(result);
525 }
526 #endif
527
528
529 /**
530   \brief   Set Fault Mask
531   \details Assigns the given value to the Fault Mask register.
532   \param [in]    faultMask  Fault Mask value to set
533  */
534 __attribute__((always_inline)) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
535 {
536   __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
537 }
538
539
540 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
541 /**
542   \brief   Set Fault Mask (non-secure)
543   \details Assigns the given value to the non-secure Fault Mask register when in secure state.
544   \param [in]    faultMask  Fault Mask value to set
545  */
546 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
547 {
548   __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory");
549 }
550 #endif
551
552 #endif /* ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \
553            (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \
554            (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))    ) */
555
556
557 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
558      (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    )
559
560 /**
561   \brief   Get Process Stack Pointer Limit
562   \details Returns the current value of the Process Stack Pointer Limit (PSPLIM).
563   \return               PSPLIM Register value
564  */
565 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSPLIM(void)
566 {
567   register uint32_t result;
568
569   __ASM volatile ("MRS %0, psplim"  : "=r" (result) );
570   return(result);
571 }
572
573
574 #if ((defined (__ARM_FEATURE_CMSE  ) && (__ARM_FEATURE_CMSE   == 3)) && \
575      (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1))    )
576 /**
577   \brief   Get Process Stack Pointer Limit (non-secure)
578   \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
579   \return               PSPLIM Register value
580  */
581 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSPLIM_NS(void)
582 {
583   register uint32_t result;
584
585   __ASM volatile ("MRS %0, psplim_ns"  : "=r" (result) );
586   return(result);
587 }
588 #endif
589
590
591 /**
592   \brief   Set Process Stack Pointer Limit
593   \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM).
594   \param [in]    ProcStackPtrLimit  Process Stack Pointer Limit value to set
595  */
596 __attribute__((always_inline)) __STATIC_INLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
597 {
598   __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit));
599 }
600
601
602 #if ((defined (__ARM_FEATURE_CMSE  ) && (__ARM_FEATURE_CMSE   == 3)) && \
603      (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1))    )
604 /**
605   \brief   Set Process Stack Pointer (non-secure)
606   \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state.
607   \param [in]    ProcStackPtrLimit  Process Stack Pointer Limit value to set
608  */
609 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
610 {
611   __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit));
612 }
613 #endif
614
615
616 /**
617   \brief   Get Main Stack Pointer Limit
618   \details Returns the current value of the Main Stack Pointer Limit (MSPLIM).
619   \return               MSPLIM Register value
620  */
621 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSPLIM(void)
622 {
623   register uint32_t result;
624
625   __ASM volatile ("MRS %0, msplim" : "=r" (result) );
626
627   return(result);
628 }
629
630
631 #if ((defined (__ARM_FEATURE_CMSE  ) && (__ARM_FEATURE_CMSE   == 3)) && \
632      (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1))    )
633 /**
634   \brief   Get Main Stack Pointer Limit (non-secure)
635   \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state.
636   \return               MSPLIM Register value
637  */
638 __attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSPLIM_NS(void)
639 {
640   register uint32_t result;
641
642   __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) );
643   return(result);
644 }
645 #endif
646
647
648 /**
649   \brief   Set Main Stack Pointer Limit
650   \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM).
651   \param [in]    MainStackPtrLimit  Main Stack Pointer Limit value to set
652  */
653 __attribute__((always_inline)) __STATIC_INLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
654 {
655   __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit));
656 }
657
658
659 #if ((defined (__ARM_FEATURE_CMSE  ) && (__ARM_FEATURE_CMSE   == 3)) && \
660      (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1))    )
661 /**
662   \brief   Set Main Stack Pointer Limit (non-secure)
663   \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state.
664   \param [in]    MainStackPtrLimit  Main Stack Pointer value to set
665  */
666 __attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
667 {
668   __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit));
669 }
670 #endif
671
672 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
673            (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    ) */
674
675
676 #if ((defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \
677      (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))    )
678
679 /**
680   \brief   Get FPSCR
681   \details Returns the current value of the Floating Point Status/Control register.
682   \return               Floating Point Status/Control register value
683  */
684 /* #define __get_FPSCR      __builtin_arm_get_fpscr */
685 __attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FPSCR(void)
686 {
687 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
688      (defined (__FPU_USED   ) && (__FPU_USED    == 1U))     )
689   uint32_t result;
690
691   __ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
692   return(result);
693 #else
694   return(0U);
695 #endif
696 }
697
698
699 /**
700   \brief   Set FPSCR
701   \details Assigns the given value to the Floating Point Status/Control register.
702   \param [in]    fpscr  Floating Point Status/Control value to set
703  */
704 /* #define __set_FPSCR      __builtin_arm_set_fpscr */
705 __attribute__((always_inline)) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
706 {
707 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
708      (defined (__FPU_USED   ) && (__FPU_USED    == 1U))     )
709   __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "memory");
710 #else
711   (void)fpscr;
712 #endif
713 }
714
715 #endif /* ((defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \
716            (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))    ) */
717
718
719
720 /*@} end of CMSIS_Core_RegAccFunctions */
721
722
723 /* ##########################  Core Instruction Access  ######################### */
724 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
725   Access to dedicated instructions
726   @{
727 */
728
729 /* Define macros for porting to both thumb1 and thumb2.
730  * For thumb1, use low register (r0-r7), specified by constraint "l"
731  * Otherwise, use general registers, specified by constraint "r" */
732 #if defined (__thumb__) && !defined (__thumb2__)
733 #define __CMSIS_GCC_OUT_REG(r) "=l" (r)
734 #define __CMSIS_GCC_USE_REG(r) "l" (r)
735 #else
736 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
737 #define __CMSIS_GCC_USE_REG(r) "r" (r)
738 #endif
739
740 /**
741   \brief   No Operation
742   \details No Operation does nothing. This instruction can be used for code alignment purposes.
743  */
744 #define __NOP          __builtin_arm_nop
745
746 /**
747   \brief   Wait For Interrupt
748   \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
749  */
750 #define __WFI          __builtin_arm_wfi
751
752
753 /**
754   \brief   Wait For Event
755   \details Wait For Event is a hint instruction that permits the processor to enter
756            a low-power state until one of a number of events occurs.
757  */
758 #define __WFE          __builtin_arm_wfe
759
760
761 /**
762   \brief   Send Event
763   \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
764  */
765 #define __SEV          __builtin_arm_sev
766
767
768 /**
769   \brief   Instruction Synchronization Barrier
770   \details Instruction Synchronization Barrier flushes the pipeline in the processor,
771            so that all instructions following the ISB are fetched from cache or memory,
772            after the instruction has been completed.
773  */
774 #define __ISB()        __builtin_arm_isb(0xF);
775
776 /**
777   \brief   Data Synchronization Barrier
778   \details Acts as a special kind of Data Memory Barrier.
779            It completes when all explicit memory accesses before this instruction complete.
780  */
781 #define __DSB()        __builtin_arm_dsb(0xF);
782
783
784 /**
785   \brief   Data Memory Barrier
786   \details Ensures the apparent order of the explicit memory operations before
787            and after the instruction, without ensuring their completion.
788  */
789 #define __DMB()        __builtin_arm_dmb(0xF);
790
791
792 /**
793   \brief   Reverse byte order (32 bit)
794   \details Reverses the byte order in integer value.
795   \param [in]    value  Value to reverse
796   \return               Reversed value
797  */
798 #define __REV          __builtin_bswap32
799
800
801 /**
802   \brief   Reverse byte order (16 bit)
803   \details Reverses the byte order in two unsigned short values.
804   \param [in]    value  Value to reverse
805   \return               Reversed value
806  */
807 #define __REV16          __builtin_bswap16                /* ToDo ARMCLANG: check if __builtin_bswap16 could be used */
808 #if 0
809 __attribute__((always_inline)) __STATIC_INLINE uint32_t __REV16(uint32_t value)
810 {
811   uint32_t result;
812
813   __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
814   return(result);
815 }
816 #endif
817
818
819 /**
820   \brief   Reverse byte order in signed short value
821   \details Reverses the byte order in a signed short value with sign extension to integer.
822   \param [in]    value  Value to reverse
823   \return               Reversed value
824  */
825                                                           /* ToDo ARMCLANG: check if __builtin_bswap16 could be used */
826 __attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value)
827 {
828   int32_t result;
829
830   __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
831   return(result);
832 }
833
834
835 /**
836   \brief   Rotate Right in unsigned value (32 bit)
837   \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
838   \param [in]    op1  Value to rotate
839   \param [in]    op2  Number of Bits to rotate
840   \return               Rotated value
841  */
842 __attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
843 {
844   return (op1 >> op2) | (op1 << (32U - op2));
845 }
846
847
848 /**
849   \brief   Breakpoint
850   \details Causes the processor to enter Debug state.
851            Debug tools can use this to investigate system state when the instruction at a particular address is reached.
852   \param [in]    value  is ignored by the processor.
853                  If required, a debugger can use it to store additional information about the breakpoint.
854  */
855 #define __BKPT(value)                       __ASM volatile ("bkpt "#value)
856
857
858 /**
859   \brief   Reverse bit order of value
860   \details Reverses the bit order of the given value.
861   \param [in]    value  Value to reverse
862   \return               Reversed value
863  */
864                                                           /* ToDo ARMCLANG: check if __builtin_arm_rbit is supported */
865 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
866 {
867   uint32_t result;
868
869 #if ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \
870      (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \
871      (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))    )
872    __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
873 #else
874   int32_t s = (4 /*sizeof(v)*/ * 8) - 1; /* extra shift needed at end */
875
876   result = value;                      /* r will be reversed bits of v; first get LSB of v */
877   for (value >>= 1U; value; value >>= 1U)
878   {
879     result <<= 1U;
880     result |= value & 1U;
881     s--;
882   }
883   result <<= s;                        /* shift when v's highest bits are zero */
884 #endif
885   return(result);
886 }
887
888
889 /**
890   \brief   Count leading zeros
891   \details Counts the number of leading zeros of a data value.
892   \param [in]  value  Value to count the leading zeros
893   \return             number of leading zeros in value
894  */
895 #define __CLZ             __builtin_clz
896
897
898 #if ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \
899      (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \
900      (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
901      (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    )
902 /**
903   \brief   LDR Exclusive (8 bit)
904   \details Executes a exclusive LDR instruction for 8 bit value.
905   \param [in]    ptr  Pointer to data
906   \return             value of type uint8_t at (*ptr)
907  */
908 #define __LDREXB        (uint8_t)__builtin_arm_ldrex
909
910
911 /**
912   \brief   LDR Exclusive (16 bit)
913   \details Executes a exclusive LDR instruction for 16 bit values.
914   \param [in]    ptr  Pointer to data
915   \return        value of type uint16_t at (*ptr)
916  */
917 #define __LDREXH        (uint16_t)__builtin_arm_ldrex
918
919
920 /**
921   \brief   LDR Exclusive (32 bit)
922   \details Executes a exclusive LDR instruction for 32 bit values.
923   \param [in]    ptr  Pointer to data
924   \return        value of type uint32_t at (*ptr)
925  */
926 #define __LDREXW        (uint32_t)__builtin_arm_ldrex
927
928
929 /**
930   \brief   STR Exclusive (8 bit)
931   \details Executes a exclusive STR instruction for 8 bit values.
932   \param [in]  value  Value to store
933   \param [in]    ptr  Pointer to location
934   \return          0  Function succeeded
935   \return          1  Function failed
936  */
937 #define __STREXB        (uint32_t)__builtin_arm_strex
938
939
940 /**
941   \brief   STR Exclusive (16 bit)
942   \details Executes a exclusive STR instruction for 16 bit values.
943   \param [in]  value  Value to store
944   \param [in]    ptr  Pointer to location
945   \return          0  Function succeeded
946   \return          1  Function failed
947  */
948 #define __STREXH        (uint32_t)__builtin_arm_strex
949
950
951 /**
952   \brief   STR Exclusive (32 bit)
953   \details Executes a exclusive STR instruction for 32 bit values.
954   \param [in]  value  Value to store
955   \param [in]    ptr  Pointer to location
956   \return          0  Function succeeded
957   \return          1  Function failed
958  */
959 #define __STREXW        (uint32_t)__builtin_arm_strex
960
961
962 /**
963   \brief   Remove the exclusive lock
964   \details Removes the exclusive lock which is created by LDREX.
965  */
966 #define __CLREX             __builtin_arm_clrex
967
968 #endif /* ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \
969            (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \
970            (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
971            (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    ) */
972
973
974 #if ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \
975      (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \
976      (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))    )
977 /**
978   \brief   Signed Saturate
979   \details Saturates a signed value.
980   \param [in]  value  Value to be saturated
981   \param [in]    sat  Bit position to saturate to (1..32)
982   \return             Saturated value
983  */
984 #define __SSAT             __builtin_arm_ssat
985
986
987 /**
988   \brief   Unsigned Saturate
989   \details Saturates an unsigned value.
990   \param [in]  value  Value to be saturated
991   \param [in]    sat  Bit position to saturate to (0..31)
992   \return             Saturated value
993  */
994 #define __USAT             __builtin_arm_usat
995
996
997 /**
998   \brief   Rotate Right with Extend (32 bit)
999   \details Moves each bit of a bitstring right by one bit.
1000            The carry input is shifted in at the left end of the bitstring.
1001   \param [in]    value  Value to rotate
1002   \return               Rotated value
1003  */
1004 __attribute__((always_inline)) __STATIC_INLINE uint32_t __RRX(uint32_t value)
1005 {
1006   uint32_t result;
1007
1008   __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
1009   return(result);
1010 }
1011
1012
1013 /**
1014   \brief   LDRT Unprivileged (8 bit)
1015   \details Executes a Unprivileged LDRT instruction for 8 bit value.
1016   \param [in]    ptr  Pointer to data
1017   \return             value of type uint8_t at (*ptr)
1018  */
1019 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *ptr)
1020 {
1021   uint32_t result;
1022
1023   __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
1024   return ((uint8_t) result);    /* Add explicit type cast here */
1025 }
1026
1027
1028 /**
1029   \brief   LDRT Unprivileged (16 bit)
1030   \details Executes a Unprivileged LDRT instruction for 16 bit values.
1031   \param [in]    ptr  Pointer to data
1032   \return        value of type uint16_t at (*ptr)
1033  */
1034 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *ptr)
1035 {
1036   uint32_t result;
1037
1038   __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
1039   return ((uint16_t) result);    /* Add explicit type cast here */
1040 }
1041
1042
1043 /**
1044   \brief   LDRT Unprivileged (32 bit)
1045   \details Executes a Unprivileged LDRT instruction for 32 bit values.
1046   \param [in]    ptr  Pointer to data
1047   \return        value of type uint32_t at (*ptr)
1048  */
1049 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t *ptr)
1050 {
1051   uint32_t result;
1052
1053   __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
1054   return(result);
1055 }
1056
1057
1058 /**
1059   \brief   STRT Unprivileged (8 bit)
1060   \details Executes a Unprivileged STRT instruction for 8 bit values.
1061   \param [in]  value  Value to store
1062   \param [in]    ptr  Pointer to location
1063  */
1064 __attribute__((always_inline)) __STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
1065 {
1066   __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1067 }
1068
1069
1070 /**
1071   \brief   STRT Unprivileged (16 bit)
1072   \details Executes a Unprivileged STRT instruction for 16 bit values.
1073   \param [in]  value  Value to store
1074   \param [in]    ptr  Pointer to location
1075  */
1076 __attribute__((always_inline)) __STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
1077 {
1078   __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1079 }
1080
1081
1082 /**
1083   \brief   STRT Unprivileged (32 bit)
1084   \details Executes a Unprivileged STRT instruction for 32 bit values.
1085   \param [in]  value  Value to store
1086   \param [in]    ptr  Pointer to location
1087  */
1088 __attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
1089 {
1090   __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
1091 }
1092
1093 #endif /* ((defined (__ARM_ARCH_7M__      ) && (__ARM_ARCH_7M__      == 1)) || \
1094            (defined (__ARM_ARCH_7EM__     ) && (__ARM_ARCH_7EM__     == 1)) || \
1095            (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))    ) */
1096
1097
1098 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1099      (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    )
1100 /**
1101   \brief   Load-Acquire (8 bit)
1102   \details Executes a LDAB instruction for 8 bit value.
1103   \param [in]    ptr  Pointer to data
1104   \return             value of type uint8_t at (*ptr)
1105  */
1106 __attribute__((always_inline)) __STATIC_INLINE uint8_t __LDAB(volatile uint8_t *ptr)
1107 {
1108   uint32_t result;
1109
1110   __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) );
1111   return ((uint8_t) result);
1112 }
1113
1114
1115 /**
1116   \brief   Load-Acquire (16 bit)
1117   \details Executes a LDAH instruction for 16 bit values.
1118   \param [in]    ptr  Pointer to data
1119   \return        value of type uint16_t at (*ptr)
1120  */
1121 __attribute__((always_inline)) __STATIC_INLINE uint16_t __LDAH(volatile uint16_t *ptr)
1122 {
1123   uint32_t result;
1124
1125   __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) );
1126   return ((uint16_t) result);
1127 }
1128
1129
1130 /**
1131   \brief   Load-Acquire (32 bit)
1132   \details Executes a LDA instruction for 32 bit values.
1133   \param [in]    ptr  Pointer to data
1134   \return        value of type uint32_t at (*ptr)
1135  */
1136 __attribute__((always_inline)) __STATIC_INLINE uint32_t __LDA(volatile uint32_t *ptr)
1137 {
1138   uint32_t result;
1139
1140   __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) );
1141   return(result);
1142 }
1143
1144
1145 /**
1146   \brief   Store-Release (8 bit)
1147   \details Executes a STLB instruction for 8 bit values.
1148   \param [in]  value  Value to store
1149   \param [in]    ptr  Pointer to location
1150  */
1151 __attribute__((always_inline)) __STATIC_INLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
1152 {
1153   __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1154 }
1155
1156
1157 /**
1158   \brief   Store-Release (16 bit)
1159   \details Executes a STLH instruction for 16 bit values.
1160   \param [in]  value  Value to store
1161   \param [in]    ptr  Pointer to location
1162  */
1163 __attribute__((always_inline)) __STATIC_INLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
1164 {
1165   __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1166 }
1167
1168
1169 /**
1170   \brief   Store-Release (32 bit)
1171   \details Executes a STL instruction for 32 bit values.
1172   \param [in]  value  Value to store
1173   \param [in]    ptr  Pointer to location
1174  */
1175 __attribute__((always_inline)) __STATIC_INLINE void __STL(uint32_t value, volatile uint32_t *ptr)
1176 {
1177   __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1178 }
1179
1180
1181 /**
1182   \brief   Load-Acquire Exclusive (8 bit)
1183   \details Executes a LDAB exclusive instruction for 8 bit value.
1184   \param [in]    ptr  Pointer to data
1185   \return             value of type uint8_t at (*ptr)
1186  */
1187 #define     __LDAEXB                 (uint8_t)__builtin_arm_ldaex
1188
1189
1190 /**
1191   \brief   Load-Acquire Exclusive (16 bit)
1192   \details Executes a LDAH exclusive instruction for 16 bit values.
1193   \param [in]    ptr  Pointer to data
1194   \return        value of type uint16_t at (*ptr)
1195  */
1196 #define     __LDAEXH                 (uint16_t)__builtin_arm_ldaex
1197
1198
1199 /**
1200   \brief   Load-Acquire Exclusive (32 bit)
1201   \details Executes a LDA exclusive instruction for 32 bit values.
1202   \param [in]    ptr  Pointer to data
1203   \return        value of type uint32_t at (*ptr)
1204  */
1205 #define     __LDAEX                  (uint32_t)__builtin_arm_ldaex
1206
1207
1208 /**
1209   \brief   Store-Release Exclusive (8 bit)
1210   \details Executes a STLB exclusive instruction for 8 bit values.
1211   \param [in]  value  Value to store
1212   \param [in]    ptr  Pointer to location
1213   \return          0  Function succeeded
1214   \return          1  Function failed
1215  */
1216 #define     __STLEXB                 (uint32_t)__builtin_arm_stlex
1217
1218
1219 /**
1220   \brief   Store-Release Exclusive (16 bit)
1221   \details Executes a STLH exclusive instruction for 16 bit values.
1222   \param [in]  value  Value to store
1223   \param [in]    ptr  Pointer to location
1224   \return          0  Function succeeded
1225   \return          1  Function failed
1226  */
1227 #define     __STLEXH                 (uint32_t)__builtin_arm_stlex
1228
1229
1230 /**
1231   \brief   Store-Release Exclusive (32 bit)
1232   \details Executes a STL exclusive instruction for 32 bit values.
1233   \param [in]  value  Value to store
1234   \param [in]    ptr  Pointer to location
1235   \return          0  Function succeeded
1236   \return          1  Function failed
1237  */
1238 #define     __STLEX                  (uint32_t)__builtin_arm_stlex
1239
1240 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1241            (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1))    ) */
1242
1243 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
1244
1245
1246 /* ###################  Compiler specific Intrinsics  ########################### */
1247 /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
1248   Access to dedicated SIMD instructions
1249   @{
1250 */
1251
1252 #if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))
1253
1254 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD8(uint32_t op1, uint32_t op2)
1255 {
1256   uint32_t result;
1257
1258   __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1259   return(result);
1260 }
1261
1262 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD8(uint32_t op1, uint32_t op2)
1263 {
1264   uint32_t result;
1265
1266   __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1267   return(result);
1268 }
1269
1270 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2)
1271 {
1272   uint32_t result;
1273
1274   __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1275   return(result);
1276 }
1277
1278 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD8(uint32_t op1, uint32_t op2)
1279 {
1280   uint32_t result;
1281
1282   __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1283   return(result);
1284 }
1285
1286 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2)
1287 {
1288   uint32_t result;
1289
1290   __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1291   return(result);
1292 }
1293
1294 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2)
1295 {
1296   uint32_t result;
1297
1298   __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1299   return(result);
1300 }
1301
1302
1303 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2)
1304 {
1305   uint32_t result;
1306
1307   __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1308   return(result);
1309 }
1310
1311 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2)
1312 {
1313   uint32_t result;
1314
1315   __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1316   return(result);
1317 }
1318
1319 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2)
1320 {
1321   uint32_t result;
1322
1323   __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1324   return(result);
1325 }
1326
1327 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB8(uint32_t op1, uint32_t op2)
1328 {
1329   uint32_t result;
1330
1331   __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1332   return(result);
1333 }
1334
1335 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2)
1336 {
1337   uint32_t result;
1338
1339   __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1340   return(result);
1341 }
1342
1343 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2)
1344 {
1345   uint32_t result;
1346
1347   __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1348   return(result);
1349 }
1350
1351
1352 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SADD16(uint32_t op1, uint32_t op2)
1353 {
1354   uint32_t result;
1355
1356   __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1357   return(result);
1358 }
1359
1360 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QADD16(uint32_t op1, uint32_t op2)
1361 {
1362   uint32_t result;
1363
1364   __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1365   return(result);
1366 }
1367
1368 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2)
1369 {
1370   uint32_t result;
1371
1372   __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1373   return(result);
1374 }
1375
1376 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UADD16(uint32_t op1, uint32_t op2)
1377 {
1378   uint32_t result;
1379
1380   __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1381   return(result);
1382 }
1383
1384 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2)
1385 {
1386   uint32_t result;
1387
1388   __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1389   return(result);
1390 }
1391
1392 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2)
1393 {
1394   uint32_t result;
1395
1396   __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1397   return(result);
1398 }
1399
1400 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2)
1401 {
1402   uint32_t result;
1403
1404   __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1405   return(result);
1406 }
1407
1408 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2)
1409 {
1410   uint32_t result;
1411
1412   __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1413   return(result);
1414 }
1415
1416 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2)
1417 {
1418   uint32_t result;
1419
1420   __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1421   return(result);
1422 }
1423
1424 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USUB16(uint32_t op1, uint32_t op2)
1425 {
1426   uint32_t result;
1427
1428   __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1429   return(result);
1430 }
1431
1432 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2)
1433 {
1434   uint32_t result;
1435
1436   __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1437   return(result);
1438 }
1439
1440 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2)
1441 {
1442   uint32_t result;
1443
1444   __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1445   return(result);
1446 }
1447
1448 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SASX(uint32_t op1, uint32_t op2)
1449 {
1450   uint32_t result;
1451
1452   __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1453   return(result);
1454 }
1455
1456 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QASX(uint32_t op1, uint32_t op2)
1457 {
1458   uint32_t result;
1459
1460   __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1461   return(result);
1462 }
1463
1464 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHASX(uint32_t op1, uint32_t op2)
1465 {
1466   uint32_t result;
1467
1468   __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1469   return(result);
1470 }
1471
1472 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UASX(uint32_t op1, uint32_t op2)
1473 {
1474   uint32_t result;
1475
1476   __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1477   return(result);
1478 }
1479
1480 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQASX(uint32_t op1, uint32_t op2)
1481 {
1482   uint32_t result;
1483
1484   __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1485   return(result);
1486 }
1487
1488 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHASX(uint32_t op1, uint32_t op2)
1489 {
1490   uint32_t result;
1491
1492   __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1493   return(result);
1494 }
1495
1496 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SSAX(uint32_t op1, uint32_t op2)
1497 {
1498   uint32_t result;
1499
1500   __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1501   return(result);
1502 }
1503
1504 __attribute__((always_inline)) __STATIC_INLINE uint32_t __QSAX(uint32_t op1, uint32_t op2)
1505 {
1506   uint32_t result;
1507
1508   __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1509   return(result);
1510 }
1511
1512 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2)
1513 {
1514   uint32_t result;
1515
1516   __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1517   return(result);
1518 }
1519
1520 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAX(uint32_t op1, uint32_t op2)
1521 {
1522   uint32_t result;
1523
1524   __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1525   return(result);
1526 }
1527
1528 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2)
1529 {
1530   uint32_t result;
1531
1532   __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1533   return(result);
1534 }
1535
1536 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2)
1537 {
1538   uint32_t result;
1539
1540   __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1541   return(result);
1542 }
1543
1544 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USAD8(uint32_t op1, uint32_t op2)
1545 {
1546   uint32_t result;
1547
1548   __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1549   return(result);
1550 }
1551
1552 __attribute__((always_inline)) __STATIC_INLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3)
1553 {
1554   uint32_t result;
1555
1556   __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1557   return(result);
1558 }
1559
1560 #define __SSAT16(ARG1,ARG2) \
1561 ({                          \
1562   int32_t __RES, __ARG1 = (ARG1); \
1563   __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) :  "I" (ARG2), "r" (__ARG1) ); \
1564   __RES; \
1565  })
1566
1567 #define __USAT16(ARG1,ARG2) \
1568 ({                          \
1569   uint32_t __RES, __ARG1 = (ARG1); \
1570   __ASM ("usat16 %0, %1, %2" : "=r" (__RES) :  "I" (ARG2), "r" (__ARG1) ); \
1571   __RES; \
1572  })
1573
1574 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1)
1575 {
1576   uint32_t result;
1577
1578   __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1));
1579   return(result);
1580 }
1581
1582 __attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2)
1583 {
1584   uint32_t result;
1585
1586   __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1587   return(result);
1588 }
1589
1590 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1)
1591 {
1592   uint32_t result;
1593
1594   __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1));
1595   return(result);
1596 }
1597
1598 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2)
1599 {
1600   uint32_t result;
1601
1602   __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1603   return(result);
1604 }
1605
1606 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUAD  (uint32_t op1, uint32_t op2)
1607 {
1608   uint32_t result;
1609
1610   __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1611   return(result);
1612 }
1613
1614 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2)
1615 {
1616   uint32_t result;
1617
1618   __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1619   return(result);
1620 }
1621
1622 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3)
1623 {
1624   uint32_t result;
1625
1626   __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1627   return(result);
1628 }
1629
1630 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3)
1631 {
1632   uint32_t result;
1633
1634   __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1635   return(result);
1636 }
1637
1638 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc)
1639 {
1640   union llreg_u{
1641     uint32_t w32[2];
1642     uint64_t w64;
1643   } llr;
1644   llr.w64 = acc;
1645
1646 #ifndef __ARMEB__   /* Little endian */
1647   __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
1648 #else               /* Big endian */
1649   __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
1650 #endif
1651
1652   return(llr.w64);
1653 }
1654
1655 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc)
1656 {
1657   union llreg_u{
1658     uint32_t w32[2];
1659     uint64_t w64;
1660   } llr;
1661   llr.w64 = acc;
1662
1663 #ifndef __ARMEB__   /* Little endian */
1664   __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
1665 #else               /* Big endian */
1666   __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
1667 #endif
1668
1669   return(llr.w64);
1670 }
1671
1672 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSD  (uint32_t op1, uint32_t op2)
1673 {
1674   uint32_t result;
1675
1676   __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1677   return(result);
1678 }
1679
1680 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2)
1681 {
1682   uint32_t result;
1683
1684   __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1685   return(result);
1686 }
1687
1688 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3)
1689 {
1690   uint32_t result;
1691
1692   __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1693   return(result);
1694 }
1695
1696 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3)
1697 {
1698   uint32_t result;
1699
1700   __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1701   return(result);
1702 }
1703
1704 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc)
1705 {
1706   union llreg_u{
1707     uint32_t w32[2];
1708     uint64_t w64;
1709   } llr;
1710   llr.w64 = acc;
1711
1712 #ifndef __ARMEB__   /* Little endian */
1713   __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
1714 #else               /* Big endian */
1715   __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
1716 #endif
1717
1718   return(llr.w64);
1719 }
1720
1721 __attribute__((always_inline)) __STATIC_INLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc)
1722 {
1723   union llreg_u{
1724     uint32_t w32[2];
1725     uint64_t w64;
1726   } llr;
1727   llr.w64 = acc;
1728
1729 #ifndef __ARMEB__   /* Little endian */
1730   __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
1731 #else               /* Big endian */
1732   __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
1733 #endif
1734
1735   return(llr.w64);
1736 }
1737
1738 __attribute__((always_inline)) __STATIC_INLINE uint32_t __SEL  (uint32_t op1, uint32_t op2)
1739 {
1740   uint32_t result;
1741
1742   __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1743   return(result);
1744 }
1745
1746 __attribute__((always_inline)) __STATIC_INLINE  int32_t __QADD( int32_t op1,  int32_t op2)
1747 {
1748   int32_t result;
1749
1750   __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1751   return(result);
1752 }
1753
1754 __attribute__((always_inline)) __STATIC_INLINE  int32_t __QSUB( int32_t op1,  int32_t op2)
1755 {
1756   int32_t result;
1757
1758   __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1759   return(result);
1760 }
1761
1762 #if 0
1763 #define __PKHBT(ARG1,ARG2,ARG3) \
1764 ({                          \
1765   uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1766   __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) :  "r" (__ARG1), "r" (__ARG2), "I" (ARG3)  ); \
1767   __RES; \
1768  })
1769
1770 #define __PKHTB(ARG1,ARG2,ARG3) \
1771 ({                          \
1772   uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1773   if (ARG3 == 0) \
1774     __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) :  "r" (__ARG1), "r" (__ARG2)  ); \
1775   else \
1776     __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) :  "r" (__ARG1), "r" (__ARG2), "I" (ARG3)  ); \
1777   __RES; \
1778  })
1779 #endif
1780
1781 #define __PKHBT(ARG1,ARG2,ARG3)          ( ((((uint32_t)(ARG1))          ) & 0x0000FFFFUL) |  \
1782                                            ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL)  )
1783
1784 #define __PKHTB(ARG1,ARG2,ARG3)          ( ((((uint32_t)(ARG1))          ) & 0xFFFF0000UL) |  \
1785                                            ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL)  )
1786
1787 __attribute__((always_inline)) __STATIC_INLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
1788 {
1789   int32_t result;
1790
1791   __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r"  (op1), "r" (op2), "r" (op3) );
1792   return(result);
1793 }
1794
1795 #endif /* (__ARM_FEATURE_DSP == 1) */
1796 /*@} end of group CMSIS_SIMD_intrinsics */
1797
1798
1799 #endif /* __CMSIS_ARMCLANG_H */