tie-asm.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. * tie-asm.h -- compile-time HAL assembler definitions dependent on CORE & TIE
  3. *
  4. * NOTE: This header file is not meant to be included directly.
  5. */
  6. /* This header file contains assembly-language definitions (assembly
  7. macros, etc.) for this specific Xtensa processor's TIE extensions
  8. and options. It is customized to this Xtensa processor configuration.
  9. Copyright (c) 1999-2015 Cadence Design Systems Inc.
  10. Permission is hereby granted, free of charge, to any person obtaining
  11. a copy of this software and associated documentation files (the
  12. "Software"), to deal in the Software without restriction, including
  13. without limitation the rights to use, copy, modify, merge, publish,
  14. distribute, sublicense, and/or sell copies of the Software, and to
  15. permit persons to whom the Software is furnished to do so, subject to
  16. the following conditions:
  17. The above copyright notice and this permission notice shall be included
  18. in all copies or substantial portions of the Software.
  19. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  22. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  23. CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  24. TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  25. SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  26. #ifndef _XTENSA_CORE_TIE_ASM_H
  27. #define _XTENSA_CORE_TIE_ASM_H
  28. /* Selection parameter values for save-area save/restore macros: */
  29. /* Option vs. TIE: */
  30. #define XTHAL_SAS_TIE 0x0001 /* custom extension or coprocessor */
  31. #define XTHAL_SAS_OPT 0x0002 /* optional (and not a coprocessor) */
  32. #define XTHAL_SAS_ANYOT 0x0003 /* both of the above */
  33. /* Whether used automatically by compiler: */
  34. #define XTHAL_SAS_NOCC 0x0004 /* not used by compiler w/o special opts/code */
  35. #define XTHAL_SAS_CC 0x0008 /* used by compiler without special opts/code */
  36. #define XTHAL_SAS_ANYCC 0x000C /* both of the above */
  37. /* ABI handling across function calls: */
  38. #define XTHAL_SAS_CALR 0x0010 /* caller-saved */
  39. #define XTHAL_SAS_CALE 0x0020 /* callee-saved */
  40. #define XTHAL_SAS_GLOB 0x0040 /* global across function calls (in thread) */
  41. #define XTHAL_SAS_ANYABI 0x0070 /* all of the above three */
  42. /* Misc */
  43. #define XTHAL_SAS_ALL 0xFFFF /* include all default NCP contents */
  44. #define XTHAL_SAS3(optie,ccuse,abi) ( ((optie) & XTHAL_SAS_ANYOT) \
  45. | ((ccuse) & XTHAL_SAS_ANYCC) \
  46. | ((abi) & XTHAL_SAS_ANYABI) )
  47. /*
  48. * Macro to store all non-coprocessor (extra) custom TIE and optional state
  49. * (not including zero-overhead loop registers).
  50. * Required parameters:
  51. * ptr Save area pointer address register (clobbered)
  52. * (register must contain a 4 byte aligned address).
  53. * at1..at4 Four temporary address registers (first XCHAL_NCP_NUM_ATMPS
  54. * registers are clobbered, the remaining are unused).
  55. * Optional parameters:
  56. * continue If macro invoked as part of a larger store sequence, set to 1
  57. * if this is not the first in the sequence. Defaults to 0.
  58. * ofs Offset from start of larger sequence (from value of first ptr
  59. * in sequence) at which to store. Defaults to next available space
  60. * (or 0 if <continue> is 0).
  61. * select Select what category(ies) of registers to store, as a bitmask
  62. * (see XTHAL_SAS_xxx constants). Defaults to all registers.
  63. * alloc Select what category(ies) of registers to allocate; if any
  64. * category is selected here that is not in <select>, space for
  65. * the corresponding registers is skipped without doing any store.
  66. */
  67. .macro xchal_ncp_store ptr at1 at2 at3 at4 continue=0 ofs=-1 select=XTHAL_SAS_ALL alloc=0
  68. xchal_sa_start \continue, \ofs
  69. // Optional global registers used by default by the compiler:
  70. .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_GLOB) & ~(\select)
  71. xchal_sa_align \ptr, 0, 1020, 4, 4
  72. rur.THREADPTR \at1 // threadptr option
  73. s32i \at1, \ptr, .Lxchal_ofs_+0
  74. .set .Lxchal_ofs_, .Lxchal_ofs_ + 4
  75. .elseif ((XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_GLOB) & ~(\alloc)) == 0
  76. xchal_sa_align \ptr, 0, 1020, 4, 4
  77. .set .Lxchal_ofs_, .Lxchal_ofs_ + 4
  78. .endif
  79. // Optional caller-saved registers used by default by the compiler:
  80. .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~(\select)
  81. xchal_sa_align \ptr, 0, 1016, 4, 4
  82. rsr.ACCLO \at1 // MAC16 option
  83. s32i \at1, \ptr, .Lxchal_ofs_+0
  84. rsr.ACCHI \at1 // MAC16 option
  85. s32i \at1, \ptr, .Lxchal_ofs_+4
  86. .set .Lxchal_ofs_, .Lxchal_ofs_ + 8
  87. .elseif ((XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~(\alloc)) == 0
  88. xchal_sa_align \ptr, 0, 1016, 4, 4
  89. .set .Lxchal_ofs_, .Lxchal_ofs_ + 8
  90. .endif
  91. // Optional caller-saved registers not used by default by the compiler:
  92. .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~(\select)
  93. xchal_sa_align \ptr, 0, 1000, 4, 4
  94. rsr.BR \at1 // boolean option
  95. s32i \at1, \ptr, .Lxchal_ofs_+0
  96. rsr.SCOMPARE1 \at1 // conditional store option
  97. s32i \at1, \ptr, .Lxchal_ofs_+4
  98. rsr.M0 \at1 // MAC16 option
  99. s32i \at1, \ptr, .Lxchal_ofs_+8
  100. rsr.M1 \at1 // MAC16 option
  101. s32i \at1, \ptr, .Lxchal_ofs_+12
  102. rsr.M2 \at1 // MAC16 option
  103. s32i \at1, \ptr, .Lxchal_ofs_+16
  104. rsr.M3 \at1 // MAC16 option
  105. s32i \at1, \ptr, .Lxchal_ofs_+20
  106. .set .Lxchal_ofs_, .Lxchal_ofs_ + 24
  107. .elseif ((XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~(\alloc)) == 0
  108. xchal_sa_align \ptr, 0, 1000, 4, 4
  109. .set .Lxchal_ofs_, .Lxchal_ofs_ + 24
  110. .endif
  111. .endm // xchal_ncp_store
  112. /*
  113. * Macro to load all non-coprocessor (extra) custom TIE and optional state
  114. * (not including zero-overhead loop registers).
  115. * Required parameters:
  116. * ptr Save area pointer address register (clobbered)
  117. * (register must contain a 4 byte aligned address).
  118. * at1..at4 Four temporary address registers (first XCHAL_NCP_NUM_ATMPS
  119. * registers are clobbered, the remaining are unused).
  120. * Optional parameters:
  121. * continue If macro invoked as part of a larger load sequence, set to 1
  122. * if this is not the first in the sequence. Defaults to 0.
  123. * ofs Offset from start of larger sequence (from value of first ptr
  124. * in sequence) at which to load. Defaults to next available space
  125. * (or 0 if <continue> is 0).
  126. * select Select what category(ies) of registers to load, as a bitmask
  127. * (see XTHAL_SAS_xxx constants). Defaults to all registers.
  128. * alloc Select what category(ies) of registers to allocate; if any
  129. * category is selected here that is not in <select>, space for
  130. * the corresponding registers is skipped without doing any load.
  131. */
  132. .macro xchal_ncp_load ptr at1 at2 at3 at4 continue=0 ofs=-1 select=XTHAL_SAS_ALL alloc=0
  133. xchal_sa_start \continue, \ofs
  134. // Optional global registers used by default by the compiler:
  135. .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_GLOB) & ~(\select)
  136. xchal_sa_align \ptr, 0, 1020, 4, 4
  137. l32i \at1, \ptr, .Lxchal_ofs_+0
  138. wur.THREADPTR \at1 // threadptr option
  139. .set .Lxchal_ofs_, .Lxchal_ofs_ + 4
  140. .elseif ((XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_GLOB) & ~(\alloc)) == 0
  141. xchal_sa_align \ptr, 0, 1020, 4, 4
  142. .set .Lxchal_ofs_, .Lxchal_ofs_ + 4
  143. .endif
  144. // Optional caller-saved registers used by default by the compiler:
  145. .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~(\select)
  146. xchal_sa_align \ptr, 0, 1016, 4, 4
  147. l32i \at1, \ptr, .Lxchal_ofs_+0
  148. wsr.ACCLO \at1 // MAC16 option
  149. l32i \at1, \ptr, .Lxchal_ofs_+4
  150. wsr.ACCHI \at1 // MAC16 option
  151. .set .Lxchal_ofs_, .Lxchal_ofs_ + 8
  152. .elseif ((XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~(\alloc)) == 0
  153. xchal_sa_align \ptr, 0, 1016, 4, 4
  154. .set .Lxchal_ofs_, .Lxchal_ofs_ + 8
  155. .endif
  156. // Optional caller-saved registers not used by default by the compiler:
  157. .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~(\select)
  158. xchal_sa_align \ptr, 0, 1000, 4, 4
  159. l32i \at1, \ptr, .Lxchal_ofs_+0
  160. wsr.BR \at1 // boolean option
  161. l32i \at1, \ptr, .Lxchal_ofs_+4
  162. wsr.SCOMPARE1 \at1 // conditional store option
  163. l32i \at1, \ptr, .Lxchal_ofs_+8
  164. wsr.M0 \at1 // MAC16 option
  165. l32i \at1, \ptr, .Lxchal_ofs_+12
  166. wsr.M1 \at1 // MAC16 option
  167. l32i \at1, \ptr, .Lxchal_ofs_+16
  168. wsr.M2 \at1 // MAC16 option
  169. l32i \at1, \ptr, .Lxchal_ofs_+20
  170. wsr.M3 \at1 // MAC16 option
  171. .set .Lxchal_ofs_, .Lxchal_ofs_ + 24
  172. .elseif ((XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~(\alloc)) == 0
  173. xchal_sa_align \ptr, 0, 1000, 4, 4
  174. .set .Lxchal_ofs_, .Lxchal_ofs_ + 24
  175. .endif
  176. .endm // xchal_ncp_load
  177. #define XCHAL_NCP_NUM_ATMPS 1
  178. #define XCHAL_SA_NUM_ATMPS 1
  179. #endif /*_XTENSA_CORE_TIE_ASM_H*/