You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

135 lines
6.1KB

  1. /*
  2. * Alpha optimized DSP utils
  3. * Copyright (c) 2002 Falk Hueffner <falk@debian.org>
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #ifndef LIBAVCODEC_ALPHA_ASM_H
  20. #define LIBAVCODEC_ALPHA_ASM_H
  21. #include <inttypes.h>
  22. #define AMASK_BWX (1 << 0)
  23. #define AMASK_FIX (1 << 1)
  24. #define AMASK_CIX (1 << 2)
  25. #define AMASK_MVI (1 << 8)
  26. inline static uint64_t BYTE_VEC(uint64_t x)
  27. {
  28. x |= x << 8;
  29. x |= x << 16;
  30. x |= x << 32;
  31. return x;
  32. }
  33. inline static uint64_t WORD_VEC(uint64_t x)
  34. {
  35. x |= x << 16;
  36. x |= x << 32;
  37. return x;
  38. }
  39. #define ldq(p) (*(const uint64_t *) (p))
  40. #define ldl(p) (*(const int32_t *) (p))
  41. #define stl(l, p) do { *(uint32_t *) (p) = (l); } while (0)
  42. #define stq(l, p) do { *(uint64_t *) (p) = (l); } while (0)
  43. #ifdef __GNUC__
  44. #define ASM_ACCEPT_MVI asm (".arch pca56")
  45. struct unaligned_long { uint64_t l; } __attribute__((packed));
  46. #define ldq_u(p) (*(const uint64_t *) (((uint64_t) (p)) & ~7ul))
  47. #define uldq(a) (((const struct unaligned_long *) (a))->l)
  48. #if __GNUC__ >= 3 && __GNUC_MINOR__ >= 3
  49. #define cmpbge __builtin_alpha_cmpbge
  50. /* Avoid warnings. */
  51. #define extql(a, b) __builtin_alpha_extql(a, (uint64_t) (b))
  52. #define extqh(a, b) __builtin_alpha_extqh(a, (uint64_t) (b))
  53. #define zap __builtin_alpha_zap
  54. #define zapnot __builtin_alpha_zapnot
  55. #define amask __builtin_alpha_amask
  56. #define implver __builtin_alpha_implver
  57. #define rpcc __builtin_alpha_rpcc
  58. #define minub8 __builtin_alpha_minub8
  59. #define minsb8 __builtin_alpha_minsb8
  60. #define minuw4 __builtin_alpha_minuw4
  61. #define minsw4 __builtin_alpha_minsw4
  62. #define maxub8 __builtin_alpha_maxub8
  63. #define maxsb8 __builtin_alpha_maxsb8
  64. #define maxuw4 __builtin_alpha_maxuw4
  65. #define maxsw4 __builtin_alpha_maxsw4
  66. #define perr __builtin_alpha_perr
  67. #define pklb __builtin_alpha_pklb
  68. #define pkwb __builtin_alpha_pkwb
  69. #define unpkbl __builtin_alpha_unpkbl
  70. #define unpkbw __builtin_alpha_unpkbw
  71. #else
  72. #define cmpbge(a, b) ({ uint64_t __r; asm ("cmpbge %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
  73. #define extql(a, b) ({ uint64_t __r; asm ("extql %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
  74. #define extqh(a, b) ({ uint64_t __r; asm ("extqh %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
  75. #define zap(a, b) ({ uint64_t __r; asm ("zap %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
  76. #define zapnot(a, b) ({ uint64_t __r; asm ("zapnot %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; })
  77. #define amask(a) ({ uint64_t __r; asm ("amask %1,%0" : "=r" (__r) : "rI" (a)); __r; })
  78. #define implver() ({ uint64_t __r; asm ("implver %0" : "=r" (__r)); __r; })
  79. #define rpcc() ({ uint64_t __r; asm volatile ("rpcc %0" : "=r" (__r)); __r; })
  80. #define minub8(a, b) ({ uint64_t __r; asm ("minub8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
  81. #define minsb8(a, b) ({ uint64_t __r; asm ("minsb8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
  82. #define minuw4(a, b) ({ uint64_t __r; asm ("minuw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
  83. #define minsw4(a, b) ({ uint64_t __r; asm ("minsw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
  84. #define maxub8(a, b) ({ uint64_t __r; asm ("maxub8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
  85. #define maxsb8(a, b) ({ uint64_t __r; asm ("maxsb8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
  86. #define maxuw4(a, b) ({ uint64_t __r; asm ("maxuw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
  87. #define maxsw4(a, b) ({ uint64_t __r; asm ("maxsw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; })
  88. #define perr(a, b) ({ uint64_t __r; asm ("perr %r1,%r2,%0" : "=r" (__r) : "%rJ" (a), "rJ" (b)); __r; })
  89. #define pklb(a) ({ uint64_t __r; asm ("pklb %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
  90. #define pkwb(a) ({ uint64_t __r; asm ("pkwb %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
  91. #define unpkbl(a) ({ uint64_t __r; asm ("unpkbl %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
  92. #define unpkbw(a) ({ uint64_t __r; asm ("unpkbw %r1,%0" : "=r" (__r) : "rJ" (a)); __r; })
  93. #endif
  94. #elif defined(__DECC) /* Digital/Compaq "ccc" compiler */
  95. #include <c_asm.h>
  96. #define ASM_ACCEPT_MVI
  97. #define ldq_u(a) asm ("ldq_u %v0,0(%a0)", a)
  98. #define uldq(a) (*(const __unaligned uint64_t *) (a))
  99. #define cmpbge(a, b) asm ("cmpbge %a0,%a1,%v0", a, b)
  100. #define extql(a, b) asm ("extql %a0,%a1,%v0", a, b)
  101. #define extqh(a, b) asm ("extqh %a0,%a1,%v0", a, b)
  102. #define zap(a, b) asm ("zap %a0,%a1,%v0", a, b)
  103. #define zapnot(a, b) asm ("zapnot %a0,%a1,%v0", a, b)
  104. #define amask(a) asm ("amask %a0,%v0", a)
  105. #define implver() asm ("implver %v0")
  106. #define rpcc() asm ("rpcc %v0")
  107. #define minub8(a, b) asm ("minub8 %a0,%a1,%v0", a, b)
  108. #define minsb8(a, b) asm ("minsb8 %a0,%a1,%v0", a, b)
  109. #define minuw4(a, b) asm ("minuw4 %a0,%a1,%v0", a, b)
  110. #define minsw4(a, b) asm ("minsw4 %a0,%a1,%v0", a, b)
  111. #define maxub8(a, b) asm ("maxub8 %a0,%a1,%v0", a, b)
  112. #define maxsb8(a, b) asm ("maxsb8 %a0,%a1,%v0", a, b)
  113. #define maxuw4(a, b) asm ("maxuw4 %a0,%a1,%v0", a, b)
  114. #define maxsw4(a, b) asm ("maxsw4 %a0,%a1,%v0", a, b)
  115. #define perr(a, b) asm ("perr %a0,%a1,%v0", a, b)
  116. #define pklb(a) asm ("pklb %a0,%v0", a)
  117. #define pkwb(a) asm ("pkwb %a0,%v0", a)
  118. #define unpkbl(a) asm ("unpkbl %a0,%v0", a)
  119. #define unpkbw(a) asm ("unpkbw %a0,%v0", a)
  120. #else
  121. #error "Unknown compiler!"
  122. #endif
  123. #endif /* LIBAVCODEC_ALPHA_ASM_H */