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.

142 lines
2.6KB

  1. /*
  2. * Copyright (c) 2009 Loren Merritt
  3. *
  4. * This file is part of Libav.
  5. *
  6. * Libav is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * Libav is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with Libav; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include "config.h"
  21. #define GLUE(a, b) a ## b
  22. #define JOIN(a, b) GLUE(a, b)
  23. #define X(s) JOIN(EXTERN_ASM, s)
  24. #if ARCH_PPC64
  25. #define PTR .quad
  26. #define lp ld
  27. #define lpx ldx
  28. #define stp std
  29. #define stpu stdu
  30. #define PS 8
  31. #define L(s) JOIN(., s)
  32. .macro extfunc name
  33. .global X(\name)
  34. #if _CALL_ELF == 2
  35. .text
  36. X(\name):
  37. addis %r2, %r12, .TOC.-X(\name)@ha
  38. addi %r2, %r2, .TOC.-X(\name)@l
  39. .localentry X(\name), .-X(\name)
  40. #else
  41. .section .opd, "aw"
  42. X(\name):
  43. .quad L(\name), .TOC.@tocbase, 0
  44. .previous
  45. .type X(\name), STT_FUNC
  46. L(\name):
  47. #endif
  48. .endm
  49. .macro movrel rd, sym, gp
  50. ld \rd, \sym@got(r2)
  51. .endm
  52. .macro get_got rd
  53. .endm
  54. #else /* ARCH_PPC64 */
  55. #define PTR .int
  56. #define lp lwz
  57. #define lpx lwzx
  58. #define stp stw
  59. #define stpu stwu
  60. #define PS 4
  61. #define L(s) s
  62. .macro extfunc name
  63. .global X(\name)
  64. .type X(\name), STT_FUNC
  65. X(\name):
  66. \name:
  67. .endm
  68. .macro movrel rd, sym, gp
  69. #if CONFIG_PIC
  70. lwz \rd, \sym@got(\gp)
  71. #else
  72. lis \rd, \sym@ha
  73. la \rd, \sym@l(\rd)
  74. #endif
  75. .endm
  76. .macro get_got rd
  77. #if CONFIG_PIC
  78. bcl 20, 31, .Lgot\@
  79. .Lgot\@:
  80. mflr \rd
  81. addis \rd, \rd, _GLOBAL_OFFSET_TABLE_ - .Lgot\@@ha
  82. addi \rd, \rd, _GLOBAL_OFFSET_TABLE_ - .Lgot\@@l
  83. #endif
  84. .endm
  85. #endif /* ARCH_PPC64 */
  86. #if HAVE_IBM_ASM
  87. .macro DEFINE_REG n
  88. .equiv r\n, \n
  89. .equiv f\n, \n
  90. .equiv v\n, \n
  91. .endm
  92. DEFINE_REG 0
  93. DEFINE_REG 1
  94. DEFINE_REG 2
  95. DEFINE_REG 3
  96. DEFINE_REG 4
  97. DEFINE_REG 5
  98. DEFINE_REG 6
  99. DEFINE_REG 7
  100. DEFINE_REG 8
  101. DEFINE_REG 9
  102. DEFINE_REG 10
  103. DEFINE_REG 11
  104. DEFINE_REG 12
  105. DEFINE_REG 13
  106. DEFINE_REG 14
  107. DEFINE_REG 15
  108. DEFINE_REG 16
  109. DEFINE_REG 17
  110. DEFINE_REG 18
  111. DEFINE_REG 19
  112. DEFINE_REG 20
  113. DEFINE_REG 21
  114. DEFINE_REG 22
  115. DEFINE_REG 23
  116. DEFINE_REG 24
  117. DEFINE_REG 25
  118. DEFINE_REG 26
  119. DEFINE_REG 27
  120. DEFINE_REG 28
  121. DEFINE_REG 29
  122. DEFINE_REG 30
  123. DEFINE_REG 31
  124. #endif /* HAVE_IBM_ASM */