tie-asm.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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 caller-saved registers used by default by the compiler:
  70. .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~(\select)
  71. xchal_sa_align \ptr, 0, 1016, 4, 4
  72. rsr.ACCLO \at1 // MAC16 option
  73. s32i \at1, \ptr, .Lxchal_ofs_+0
  74. rsr.ACCHI \at1 // MAC16 option
  75. s32i \at1, \ptr, .Lxchal_ofs_+4
  76. .set .Lxchal_ofs_, .Lxchal_ofs_ + 8
  77. .elseif ((XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~(\alloc)) == 0
  78. xchal_sa_align \ptr, 0, 1016, 4, 4
  79. .set .Lxchal_ofs_, .Lxchal_ofs_ + 8
  80. .endif
  81. // Optional caller-saved registers not used by default by the compiler:
  82. .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~(\select)
  83. xchal_sa_align \ptr, 0, 1004, 4, 4
  84. rsr.SCOMPARE1 \at1 // conditional store option
  85. s32i \at1, \ptr, .Lxchal_ofs_+0
  86. rsr.M0 \at1 // MAC16 option
  87. s32i \at1, \ptr, .Lxchal_ofs_+4
  88. rsr.M1 \at1 // MAC16 option
  89. s32i \at1, \ptr, .Lxchal_ofs_+8
  90. rsr.M2 \at1 // MAC16 option
  91. s32i \at1, \ptr, .Lxchal_ofs_+12
  92. rsr.M3 \at1 // MAC16 option
  93. s32i \at1, \ptr, .Lxchal_ofs_+16
  94. .set .Lxchal_ofs_, .Lxchal_ofs_ + 20
  95. .elseif ((XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~(\alloc)) == 0
  96. xchal_sa_align \ptr, 0, 1004, 4, 4
  97. .set .Lxchal_ofs_, .Lxchal_ofs_ + 20
  98. .endif
  99. .endm // xchal_ncp_store
  100. /*
  101. * Macro to load all non-coprocessor (extra) custom TIE and optional state
  102. * (not including zero-overhead loop registers).
  103. * Required parameters:
  104. * ptr Save area pointer address register (clobbered)
  105. * (register must contain a 4 byte aligned address).
  106. * at1..at4 Four temporary address registers (first XCHAL_NCP_NUM_ATMPS
  107. * registers are clobbered, the remaining are unused).
  108. * Optional parameters:
  109. * continue If macro invoked as part of a larger load sequence, set to 1
  110. * if this is not the first in the sequence. Defaults to 0.
  111. * ofs Offset from start of larger sequence (from value of first ptr
  112. * in sequence) at which to load. Defaults to next available space
  113. * (or 0 if <continue> is 0).
  114. * select Select what category(ies) of registers to load, as a bitmask
  115. * (see XTHAL_SAS_xxx constants). Defaults to all registers.
  116. * alloc Select what category(ies) of registers to allocate; if any
  117. * category is selected here that is not in <select>, space for
  118. * the corresponding registers is skipped without doing any load.
  119. */
  120. .macro xchal_ncp_load ptr at1 at2 at3 at4 continue=0 ofs=-1 select=XTHAL_SAS_ALL alloc=0
  121. xchal_sa_start \continue, \ofs
  122. // Optional caller-saved registers used by default by the compiler:
  123. .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~(\select)
  124. xchal_sa_align \ptr, 0, 1016, 4, 4
  125. l32i \at1, \ptr, .Lxchal_ofs_+0
  126. wsr.ACCLO \at1 // MAC16 option
  127. l32i \at1, \ptr, .Lxchal_ofs_+4
  128. wsr.ACCHI \at1 // MAC16 option
  129. .set .Lxchal_ofs_, .Lxchal_ofs_ + 8
  130. .elseif ((XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~(\alloc)) == 0
  131. xchal_sa_align \ptr, 0, 1016, 4, 4
  132. .set .Lxchal_ofs_, .Lxchal_ofs_ + 8
  133. .endif
  134. // Optional caller-saved registers not used by default by the compiler:
  135. .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~(\select)
  136. xchal_sa_align \ptr, 0, 1004, 4, 4
  137. l32i \at1, \ptr, .Lxchal_ofs_+0
  138. wsr.SCOMPARE1 \at1 // conditional store option
  139. l32i \at1, \ptr, .Lxchal_ofs_+4
  140. wsr.M0 \at1 // MAC16 option
  141. l32i \at1, \ptr, .Lxchal_ofs_+8
  142. wsr.M1 \at1 // MAC16 option
  143. l32i \at1, \ptr, .Lxchal_ofs_+12
  144. wsr.M2 \at1 // MAC16 option
  145. l32i \at1, \ptr, .Lxchal_ofs_+16
  146. wsr.M3 \at1 // MAC16 option
  147. .set .Lxchal_ofs_, .Lxchal_ofs_ + 20
  148. .elseif ((XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~(\alloc)) == 0
  149. xchal_sa_align \ptr, 0, 1004, 4, 4
  150. .set .Lxchal_ofs_, .Lxchal_ofs_ + 20
  151. .endif
  152. .endm // xchal_ncp_load
  153. #define XCHAL_NCP_NUM_ATMPS 1
  154. #define XCHAL_SA_NUM_ATMPS 1
  155. #endif /*_XTENSA_CORE_TIE_ASM_H*/