1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 #ifndef _XTENSA_ASMMACRO_H
  12 #define _XTENSA_ASMMACRO_H
  13 
  14 #include <asm/core.h>
  15 
  16 
  17 
  18 
  19 
  20 
  21 
  22 
  23 
  24 
  25 
  26 
  27 
  28 
  29 
  30 
  31 
  32 
  33 
  34 
  35 
  36 
  37 
  38 
  39 
  40 
  41 
  42 
  43 
  44 
  45 
  46 
  47 
  48 
  49         .macro  __loopi ar, at, size, incr
  50 
  51 #if XCHAL_HAVE_LOOPS
  52                 movi    \at, ((\size + \incr - 1) / (\incr))
  53                 loop    \at, 99f
  54 #else
  55                 addi    \at, \ar, \size
  56                 98:
  57 #endif
  58 
  59         .endm
  60 
  61 
  62 
  63 
  64 
  65         .macro  __loops ar, as, at, incr_log2, mask_log2, cond, ncond
  66 
  67 #if XCHAL_HAVE_LOOPS
  68                 .ifgt \incr_log2 - 1
  69                         addi    \at, \as, (1 << \incr_log2) - 1
  70                         .ifnc \mask_log2,
  71                                 extui   \at, \at, \incr_log2, \mask_log2
  72                         .else
  73                                 srli    \at, \at, \incr_log2
  74                         .endif
  75                 .endif
  76                 loop\cond       \at, 99f
  77 #else
  78                 .ifnc \mask_log2,
  79                         extui   \at, \as, \incr_log2, \mask_log2
  80                 .else
  81                         .ifnc \ncond,
  82                                 srli    \at, \as, \incr_log2
  83                         .endif
  84                 .endif
  85                 .ifnc \ncond,
  86                         b\ncond \at, 99f
  87 
  88                 .endif
  89                 .ifnc \mask_log2,
  90                         slli    \at, \at, \incr_log2
  91                         add     \at, \ar, \at
  92                 .else
  93                         add     \at, \ar, \as
  94                 .endif
  95 #endif
  96                 98:
  97 
  98         .endm
  99 
 100 
 101 
 102 
 103 
 104         .macro  __loopt ar, as, at, incr_log2
 105 
 106 #if XCHAL_HAVE_LOOPS
 107                 sub     \at, \as, \ar
 108                 .ifgt   \incr_log2 - 1
 109                         addi    \at, \at, (1 << \incr_log2) - 1
 110                         srli    \at, \at, \incr_log2
 111                 .endif
 112                 loop    \at, 99f
 113 #else
 114                 98:
 115 #endif
 116 
 117         .endm
 118 
 119 
 120 
 121 
 122 
 123         .macro  __loop  as
 124 
 125 #if XCHAL_HAVE_LOOPS
 126                 loop    \as, 99f
 127 #else
 128                 98:
 129 #endif
 130 
 131         .endm
 132 
 133 
 134 
 135 
 136 
 137         .macro  __endl  ar, as
 138 #if !XCHAL_HAVE_LOOPS
 139                 bltu    \ar, \as, 98b
 140 #endif
 141                 99:
 142         .endm
 143 
 144 
 145 
 146 
 147 
 148         .macro  __endla ar, as, incr
 149                 addi    \ar, \ar, \incr
 150                 __endl  \ar \as
 151         .endm
 152 
 153 
 154 
 155 #define EX(handler)                             \
 156         .section __ex_table, "a";               \
 157         .word   97f, handler;                   \
 158         .previous                               \
 159 97:
 160 
 161 
 162 
 163 
 164 
 165 
 166 
 167 
 168         .macro __src_b  r, w0, w1
 169 #ifdef __XTENSA_EB__
 170                 src     \r, \w0, \w1
 171 #else
 172                 src     \r, \w1, \w0
 173 #endif
 174         .endm
 175 
 176 
 177 
 178 
 179 
 180 
 181 
 182 
 183 
 184 
 185 
 186         .macro __ssa8   r
 187 #ifdef __XTENSA_EB__
 188                 ssa8b   \r
 189 #else
 190                 ssa8l   \r
 191 #endif
 192         .endm
 193 
 194 #define XTENSA_STACK_ALIGNMENT          16
 195 
 196 #if defined(__XTENSA_WINDOWED_ABI__)
 197 #define XTENSA_FRAME_SIZE_RESERVE       16
 198 #define XTENSA_SPILL_STACK_RESERVE      32
 199 
 200 #define abi_entry(frame_size) \
 201         entry sp, (XTENSA_FRAME_SIZE_RESERVE + \
 202                    (((frame_size) + XTENSA_STACK_ALIGNMENT - 1) & \
 203                     -XTENSA_STACK_ALIGNMENT))
 204 #define abi_entry_default abi_entry(0)
 205 
 206 #define abi_ret(frame_size) retw
 207 #define abi_ret_default retw
 208 
 209 #elif defined(__XTENSA_CALL0_ABI__)
 210 
 211 #define XTENSA_SPILL_STACK_RESERVE      0
 212 
 213 #define abi_entry(frame_size) __abi_entry (frame_size)
 214 
 215         .macro  __abi_entry frame_size
 216         .ifgt \frame_size
 217         addi sp, sp, -(((\frame_size) + XTENSA_STACK_ALIGNMENT - 1) & \
 218                        -XTENSA_STACK_ALIGNMENT)
 219         .endif
 220         .endm
 221 
 222 #define abi_entry_default
 223 
 224 #define abi_ret(frame_size) __abi_ret (frame_size)
 225 
 226         .macro  __abi_ret frame_size
 227         .ifgt \frame_size
 228         addi sp, sp, (((\frame_size) + XTENSA_STACK_ALIGNMENT - 1) & \
 229                       -XTENSA_STACK_ALIGNMENT)
 230         .endif
 231         ret
 232         .endm
 233 
 234 #define abi_ret_default ret
 235 
 236 #else
 237 #error Unsupported Xtensa ABI
 238 #endif
 239 
 240 #endif