defs.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. /* Definitions for Xtensa instructions, types, and protos. */
  2. /*
  3. * Copyright (c) 2003 Tensilica, Inc. All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of version 2.1 of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it would be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. *
  13. * Further, this software is distributed without any warranty that it is
  14. * free of the rightful claim of any third person regarding infringement
  15. * or the like. Any license provided herein, whether implied or
  16. * otherwise, applies only to this software file. Patent licenses, if
  17. * any, provided herein do not apply to combinations of this program with
  18. * other software, or any other product whatsoever.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with this program; if not, write the Free Software
  22. * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307,
  23. * USA.
  24. */
  25. /* Do not modify. This is automatically generated.*/
  26. #ifndef _XTENSA_BASE_HEADER
  27. #define _XTENSA_BASE_HEADER
  28. #ifdef __XTENSA__
  29. #if defined(__GNUC__) && !defined(__XCC__)
  30. #define L8UI_ASM(arr, ars, imm) { \
  31. __asm__ volatile("l8ui %0, %1, %2" : "=a" (arr) : "a" (ars) , "i" (imm)); \
  32. }
  33. #define XT_L8UI(ars, imm) \
  34. ({ \
  35. unsigned char _arr; \
  36. const unsigned char *_ars = ars; \
  37. L8UI_ASM(_arr, _ars, imm); \
  38. _arr; \
  39. })
  40. #define L16UI_ASM(arr, ars, imm) { \
  41. __asm__ volatile("l16ui %0, %1, %2" : "=a" (arr) : "a" (ars) , "i" (imm)); \
  42. }
  43. #define XT_L16UI(ars, imm) \
  44. ({ \
  45. unsigned short _arr; \
  46. const unsigned short *_ars = ars; \
  47. L16UI_ASM(_arr, _ars, imm); \
  48. _arr; \
  49. })
  50. #define L16SI_ASM(arr, ars, imm) {\
  51. __asm__ volatile("l16si %0, %1, %2" : "=a" (arr) : "a" (ars) , "i" (imm)); \
  52. }
  53. #define XT_L16SI(ars, imm) \
  54. ({ \
  55. signed short _arr; \
  56. const signed short *_ars = ars; \
  57. L16SI_ASM(_arr, _ars, imm); \
  58. _arr; \
  59. })
  60. #define L32I_ASM(arr, ars, imm) { \
  61. __asm__ volatile("l32i %0, %1, %2" : "=a" (arr) : "a" (ars) , "i" (imm)); \
  62. }
  63. #define XT_L32I(ars, imm) \
  64. ({ \
  65. unsigned _arr; \
  66. const unsigned *_ars = ars; \
  67. L32I_ASM(_arr, _ars, imm); \
  68. _arr; \
  69. })
  70. #define S8I_ASM(arr, ars, imm) {\
  71. __asm__ volatile("s8i %0, %1, %2" : : "a" (arr), "a" (ars) , "i" (imm) : "memory" ); \
  72. }
  73. #define XT_S8I(arr, ars, imm) \
  74. ({ \
  75. signed char _arr = arr; \
  76. const signed char *_ars = ars; \
  77. S8I_ASM(_arr, _ars, imm); \
  78. })
  79. #define S16I_ASM(arr, ars, imm) {\
  80. __asm__ volatile("s16i %0, %1, %2" : : "a" (arr), "a" (ars) , "i" (imm) : "memory" ); \
  81. }
  82. #define XT_S16I(arr, ars, imm) \
  83. ({ \
  84. signed short _arr = arr; \
  85. const signed short *_ars = ars; \
  86. S16I_ASM(_arr, _ars, imm); \
  87. })
  88. #define S32I_ASM(arr, ars, imm) { \
  89. __asm__ volatile("s32i %0, %1, %2" : : "a" (arr), "a" (ars) , "i" (imm) : "memory" ); \
  90. }
  91. #define XT_S32I(arr, ars, imm) \
  92. ({ \
  93. signed int _arr = arr; \
  94. const signed int *_ars = ars; \
  95. S32I_ASM(_arr, _ars, imm); \
  96. })
  97. #define ADDI_ASM(art, ars, imm) {\
  98. __asm__ ("addi %0, %1, %2" : "=a" (art) : "a" (ars), "i" (imm)); \
  99. }
  100. #define XT_ADDI(ars, imm) \
  101. ({ \
  102. unsigned _art; \
  103. unsigned _ars = ars; \
  104. ADDI_ASM(_art, _ars, imm); \
  105. _art; \
  106. })
  107. #define ABS_ASM(arr, art) {\
  108. __asm__ ("abs %0, %1" : "=a" (arr) : "a" (art)); \
  109. }
  110. #define XT_ABS(art) \
  111. ({ \
  112. unsigned _arr; \
  113. signed _art = art; \
  114. ABS_ASM(_arr, _art); \
  115. _arr; \
  116. })
  117. /* Note: In the following macros that reference SAR, the magic "state"
  118. register is used to capture the dependency on SAR. This is because
  119. SAR is a 5-bit register and thus there are no C types that can be
  120. used to represent it. It doesn't appear that the SAR register is
  121. even relevant to GCC, but it is marked as "clobbered" just in
  122. case. */
  123. #define SRC_ASM(arr, ars, art) {\
  124. register int _xt_sar __asm__ ("state"); \
  125. __asm__ ("src %0, %1, %2" \
  126. : "=a" (arr) : "a" (ars), "a" (art), "t" (_xt_sar)); \
  127. }
  128. #define XT_SRC(ars, art) \
  129. ({ \
  130. unsigned _arr; \
  131. unsigned _ars = ars; \
  132. unsigned _art = art; \
  133. SRC_ASM(_arr, _ars, _art); \
  134. _arr; \
  135. })
  136. #define SSR_ASM(ars) {\
  137. register int _xt_sar __asm__ ("state"); \
  138. __asm__ ("ssr %1" : "=t" (_xt_sar) : "a" (ars) : "sar"); \
  139. }
  140. #define XT_SSR(ars) \
  141. ({ \
  142. unsigned _ars = ars; \
  143. SSR_ASM(_ars); \
  144. })
  145. #define SSL_ASM(ars) {\
  146. register int _xt_sar __asm__ ("state"); \
  147. __asm__ ("ssl %1" : "=t" (_xt_sar) : "a" (ars) : "sar"); \
  148. }
  149. #define XT_SSL(ars) \
  150. ({ \
  151. unsigned _ars = ars; \
  152. SSL_ASM(_ars); \
  153. })
  154. #define SSA8B_ASM(ars) {\
  155. register int _xt_sar __asm__ ("state"); \
  156. __asm__ ("ssa8b %1" : "=t" (_xt_sar) : "a" (ars) : "sar"); \
  157. }
  158. #define XT_SSA8B(ars) \
  159. ({ \
  160. unsigned _ars = ars; \
  161. SSA8B_ASM(_ars); \
  162. })
  163. #define SSA8L_ASM(ars) {\
  164. register int _xt_sar __asm__ ("state"); \
  165. __asm__ ("ssa8l %1" : "=t" (_xt_sar) : "a" (ars) : "sar"); \
  166. }
  167. #define XT_SSA8L(ars) \
  168. ({ \
  169. unsigned _ars = ars; \
  170. SSA8L_ASM(_ars); \
  171. })
  172. #define SSAI_ASM(imm) {\
  173. register int _xt_sar __asm__ ("state"); \
  174. __asm__ ("ssai %1" : "=t" (_xt_sar) : "i" (imm) : "sar"); \
  175. }
  176. #define XT_SSAI(imm) \
  177. ({ \
  178. SSAI_ASM(imm); \
  179. })
  180. #endif /* __GNUC__ && !__XCC__ */
  181. #ifdef __XCC__
  182. /* Core load/store instructions */
  183. extern unsigned char _TIE_L8UI(const unsigned char * ars, immediate imm);
  184. extern unsigned short _TIE_L16UI(const unsigned short * ars, immediate imm);
  185. extern signed short _TIE_L16SI(const signed short * ars, immediate imm);
  186. extern unsigned _TIE_L32I(const unsigned * ars, immediate imm);
  187. extern void _TIE_S8I(unsigned char arr, unsigned char * ars, immediate imm);
  188. extern void _TIE_S16I(unsigned short arr, unsigned short * ars, immediate imm);
  189. extern void _TIE_S32I(unsigned arr, unsigned * ars, immediate imm);
  190. #define XT_L8UI _TIE_L8UI
  191. #define XT_L16UI _TIE_L16UI
  192. #define XT_L16SI _TIE_L16SI
  193. #define XT_L32I _TIE_L32I
  194. #define XT_S8I _TIE_S8I
  195. #define XT_S16I _TIE_S16I
  196. #define XT_S32I _TIE_S32I
  197. /* Add-immediate instruction */
  198. extern unsigned _TIE_ADDI(unsigned ars, immediate imm);
  199. #define XT_ADDI _TIE_ADDI
  200. /* Absolute value instruction */
  201. extern unsigned _TIE_ABS(int art);
  202. #define XT_ABS _TIE_ABS
  203. /* funnel shift instructions */
  204. extern unsigned _TIE_SRC(unsigned ars, unsigned art);
  205. #define XT_SRC _TIE_SRC
  206. extern void _TIE_SSR(unsigned ars);
  207. #define XT_SSR _TIE_SSR
  208. extern void _TIE_SSL(unsigned ars);
  209. #define XT_SSL _TIE_SSL
  210. extern void _TIE_SSA8B(unsigned ars);
  211. #define XT_SSA8B _TIE_SSA8B
  212. extern void _TIE_SSA8L(unsigned ars);
  213. #define XT_SSA8L _TIE_SSA8L
  214. extern void _TIE_SSAI(immediate imm);
  215. #define XT_SSAI _TIE_SSAI
  216. #endif /* __XCC__ */
  217. #endif /* __XTENSA__ */
  218. #endif /* !_XTENSA_BASE_HEADER */