tie-asm.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * This header file contains assembly-language definitions (assembly
  3. * macros, etc.) for this specific Xtensa processor's TIE extensions
  4. * and options. It is customized to this Xtensa processor configuration.
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. *
  10. * Copyright (C) 1999-2007 Tensilica Inc.
  11. */
  12. #ifndef _XTENSA_CORE_TIE_ASM_H
  13. #define _XTENSA_CORE_TIE_ASM_H
  14. /* Selection parameter values for save-area save/restore macros: */
  15. /* Option vs. TIE: */
  16. #define XTHAL_SAS_TIE 0x0001 /* custom extension or coprocessor */
  17. #define XTHAL_SAS_OPT 0x0002 /* optional (and not a coprocessor) */
  18. /* Whether used automatically by compiler: */
  19. #define XTHAL_SAS_NOCC 0x0004 /* not used by compiler w/o special opts/code */
  20. #define XTHAL_SAS_CC 0x0008 /* used by compiler without special opts/code */
  21. /* ABI handling across function calls: */
  22. #define XTHAL_SAS_CALR 0x0010 /* caller-saved */
  23. #define XTHAL_SAS_CALE 0x0020 /* callee-saved */
  24. #define XTHAL_SAS_GLOB 0x0040 /* global across function calls (in thread) */
  25. /* Misc */
  26. #define XTHAL_SAS_ALL 0xFFFF /* include all default NCP contents */
  27. /* Macro to save all non-coprocessor (extra) custom TIE and optional state
  28. * (not including zero-overhead loop registers).
  29. * Save area ptr (clobbered): ptr (1 byte aligned)
  30. * Scratch regs (clobbered): at1..at4 (only first XCHAL_NCP_NUM_ATMPS needed)
  31. */
  32. .macro xchal_ncp_store ptr at1 at2 at3 at4 continue=0 ofs=-1 select=XTHAL_SAS_ALL
  33. xchal_sa_start \continue, \ofs
  34. .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~\select
  35. xchal_sa_align \ptr, 0, 1024-8, 4, 4
  36. rsr \at1, ACCLO // MAC16 accumulator
  37. rsr \at2, ACCHI
  38. s32i \at1, \ptr, .Lxchal_ofs_ + 0
  39. s32i \at2, \ptr, .Lxchal_ofs_ + 4
  40. .set .Lxchal_ofs_, .Lxchal_ofs_ + 8
  41. .endif
  42. .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~\select
  43. xchal_sa_align \ptr, 0, 1024-16, 4, 4
  44. rsr \at1, M0 // MAC16 registers
  45. rsr \at2, M1
  46. s32i \at1, \ptr, .Lxchal_ofs_ + 0
  47. s32i \at2, \ptr, .Lxchal_ofs_ + 4
  48. rsr \at1, M2
  49. rsr \at2, M3
  50. s32i \at1, \ptr, .Lxchal_ofs_ + 8
  51. s32i \at2, \ptr, .Lxchal_ofs_ + 12
  52. .set .Lxchal_ofs_, .Lxchal_ofs_ + 16
  53. .endif
  54. .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~\select
  55. xchal_sa_align \ptr, 0, 1024-4, 4, 4
  56. rsr \at1, SCOMPARE1 // conditional store option
  57. s32i \at1, \ptr, .Lxchal_ofs_ + 0
  58. .set .Lxchal_ofs_, .Lxchal_ofs_ + 4
  59. .endif
  60. .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_GLOB) & ~\select
  61. xchal_sa_align \ptr, 0, 1024-4, 4, 4
  62. rur \at1, THREADPTR // threadptr option
  63. s32i \at1, \ptr, .Lxchal_ofs_ + 0
  64. .set .Lxchal_ofs_, .Lxchal_ofs_ + 4
  65. .endif
  66. .endm // xchal_ncp_store
  67. /* Macro to save all non-coprocessor (extra) custom TIE and optional state
  68. * (not including zero-overhead loop registers).
  69. * Save area ptr (clobbered): ptr (1 byte aligned)
  70. * Scratch regs (clobbered): at1..at4 (only first XCHAL_NCP_NUM_ATMPS needed)
  71. */
  72. .macro xchal_ncp_load ptr at1 at2 at3 at4 continue=0 ofs=-1 select=XTHAL_SAS_ALL
  73. xchal_sa_start \continue, \ofs
  74. .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_CALR) & ~\select
  75. xchal_sa_align \ptr, 0, 1024-8, 4, 4
  76. l32i \at1, \ptr, .Lxchal_ofs_ + 0
  77. l32i \at2, \ptr, .Lxchal_ofs_ + 4
  78. wsr \at1, ACCLO // MAC16 accumulator
  79. wsr \at2, ACCHI
  80. .set .Lxchal_ofs_, .Lxchal_ofs_ + 8
  81. .endif
  82. .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~\select
  83. xchal_sa_align \ptr, 0, 1024-16, 4, 4
  84. l32i \at1, \ptr, .Lxchal_ofs_ + 0
  85. l32i \at2, \ptr, .Lxchal_ofs_ + 4
  86. wsr \at1, M0 // MAC16 registers
  87. wsr \at2, M1
  88. l32i \at1, \ptr, .Lxchal_ofs_ + 8
  89. l32i \at2, \ptr, .Lxchal_ofs_ + 12
  90. wsr \at1, M2
  91. wsr \at2, M3
  92. .set .Lxchal_ofs_, .Lxchal_ofs_ + 16
  93. .endif
  94. .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_NOCC | XTHAL_SAS_CALR) & ~\select
  95. xchal_sa_align \ptr, 0, 1024-4, 4, 4
  96. l32i \at1, \ptr, .Lxchal_ofs_ + 0
  97. wsr \at1, SCOMPARE1 // conditional store option
  98. .set .Lxchal_ofs_, .Lxchal_ofs_ + 4
  99. .endif
  100. .ifeq (XTHAL_SAS_OPT | XTHAL_SAS_CC | XTHAL_SAS_GLOB) & ~\select
  101. xchal_sa_align \ptr, 0, 1024-4, 4, 4
  102. l32i \at1, \ptr, .Lxchal_ofs_ + 0
  103. wur \at1, THREADPTR // threadptr option
  104. .set .Lxchal_ofs_, .Lxchal_ofs_ + 4
  105. .endif
  106. .endm // xchal_ncp_load
  107. #define XCHAL_NCP_NUM_ATMPS 2
  108. #define XCHAL_SA_NUM_ATMPS 2
  109. #endif /*_XTENSA_CORE_TIE_ASM_H*/