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.

134 lines
2.4KB

  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. .section .opd, "aw"
  35. X(\name):
  36. .quad L(\name), .TOC.@tocbase, 0
  37. .previous
  38. .type X(\name), STT_FUNC
  39. L(\name):
  40. .endm
  41. .macro movrel rd, sym, gp
  42. ld \rd, \sym@got(r2)
  43. .endm
  44. .macro get_got rd
  45. .endm
  46. #else /* ARCH_PPC64 */
  47. #define PTR .int
  48. #define lp lwz
  49. #define lpx lwzx
  50. #define stp stw
  51. #define stpu stwu
  52. #define PS 4
  53. #define L(s) s
  54. .macro extfunc name
  55. .global X(\name)
  56. .type X(\name), STT_FUNC
  57. X(\name):
  58. \name:
  59. .endm
  60. .macro movrel rd, sym, gp
  61. #if CONFIG_PIC
  62. lwz \rd, \sym@got(\gp)
  63. #else
  64. lis \rd, \sym@ha
  65. la \rd, \sym@l(\rd)
  66. #endif
  67. .endm
  68. .macro get_got rd
  69. #if CONFIG_PIC
  70. bcl 20, 31, .Lgot\@
  71. .Lgot\@:
  72. mflr \rd
  73. addis \rd, \rd, _GLOBAL_OFFSET_TABLE_ - .Lgot\@@ha
  74. addi \rd, \rd, _GLOBAL_OFFSET_TABLE_ - .Lgot\@@l
  75. #endif
  76. .endm
  77. #endif /* ARCH_PPC64 */
  78. #if HAVE_IBM_ASM
  79. .macro DEFINE_REG n
  80. .equiv r\n, \n
  81. .equiv f\n, \n
  82. .equiv v\n, \n
  83. .endm
  84. DEFINE_REG 0
  85. DEFINE_REG 1
  86. DEFINE_REG 2
  87. DEFINE_REG 3
  88. DEFINE_REG 4
  89. DEFINE_REG 5
  90. DEFINE_REG 6
  91. DEFINE_REG 7
  92. DEFINE_REG 8
  93. DEFINE_REG 9
  94. DEFINE_REG 10
  95. DEFINE_REG 11
  96. DEFINE_REG 12
  97. DEFINE_REG 13
  98. DEFINE_REG 14
  99. DEFINE_REG 15
  100. DEFINE_REG 16
  101. DEFINE_REG 17
  102. DEFINE_REG 18
  103. DEFINE_REG 19
  104. DEFINE_REG 20
  105. DEFINE_REG 21
  106. DEFINE_REG 22
  107. DEFINE_REG 23
  108. DEFINE_REG 24
  109. DEFINE_REG 25
  110. DEFINE_REG 26
  111. DEFINE_REG 27
  112. DEFINE_REG 28
  113. DEFINE_REG 29
  114. DEFINE_REG 30
  115. DEFINE_REG 31
  116. #endif /* HAVE_IBM_ASM */