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.

113 lines
3.2KB

  1. /*
  2. * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
  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. #ifndef AVUTIL_X86_ASM_H
  21. #define AVUTIL_X86_ASM_H
  22. #include <stdint.h>
  23. #include "config.h"
  24. typedef struct xmm_reg { uint64_t a, b; } xmm_reg;
  25. #if ARCH_X86_64
  26. # define OPSIZE "q"
  27. # define REG_a "rax"
  28. # define REG_b "rbx"
  29. # define REG_c "rcx"
  30. # define REG_d "rdx"
  31. # define REG_D "rdi"
  32. # define REG_S "rsi"
  33. # define PTR_SIZE "8"
  34. typedef int64_t x86_reg;
  35. # define REG_SP "rsp"
  36. # define REG_BP "rbp"
  37. # define REGBP rbp
  38. # define REGa rax
  39. # define REGb rbx
  40. # define REGc rcx
  41. # define REGd rdx
  42. # define REGSP rsp
  43. #elif ARCH_X86_32
  44. # define OPSIZE "l"
  45. # define REG_a "eax"
  46. # define REG_b "ebx"
  47. # define REG_c "ecx"
  48. # define REG_d "edx"
  49. # define REG_D "edi"
  50. # define REG_S "esi"
  51. # define PTR_SIZE "4"
  52. typedef int32_t x86_reg;
  53. # define REG_SP "esp"
  54. # define REG_BP "ebp"
  55. # define REGBP ebp
  56. # define REGa eax
  57. # define REGb ebx
  58. # define REGc ecx
  59. # define REGd edx
  60. # define REGSP esp
  61. #else
  62. typedef int x86_reg;
  63. #endif
  64. #define HAVE_7REGS (ARCH_X86_64 || (HAVE_EBX_AVAILABLE && HAVE_EBP_AVAILABLE))
  65. #define HAVE_6REGS (ARCH_X86_64 || (HAVE_EBX_AVAILABLE || HAVE_EBP_AVAILABLE))
  66. #if ARCH_X86_64 && defined(PIC)
  67. # define BROKEN_RELOCATIONS 1
  68. #endif
  69. /*
  70. * If gcc is not set to support sse (-msse) it will not accept xmm registers
  71. * in the clobber list for inline asm. XMM_CLOBBERS takes a list of xmm
  72. * registers to be marked as clobbered and evaluates to nothing if they are
  73. * not supported, or to the list itself if they are supported. Since a clobber
  74. * list may not be empty, XMM_CLOBBERS_ONLY should be used if the xmm
  75. * registers are the only in the clobber list.
  76. * For example a list with "eax" and "xmm0" as clobbers should become:
  77. * : XMM_CLOBBERS("xmm0",) "eax"
  78. * and a list with only "xmm0" should become:
  79. * XMM_CLOBBERS_ONLY("xmm0")
  80. */
  81. #if HAVE_XMM_CLOBBERS
  82. # define XMM_CLOBBERS(...) __VA_ARGS__
  83. # define XMM_CLOBBERS_ONLY(...) : __VA_ARGS__
  84. #else
  85. # define XMM_CLOBBERS(...)
  86. # define XMM_CLOBBERS_ONLY(...)
  87. #endif
  88. /* Use to export labels from asm. */
  89. #define LABEL_MANGLE(a) EXTERN_PREFIX #a
  90. // Use rip-relative addressing if compiling PIC code on x86-64.
  91. #if ARCH_X86_64 && defined(PIC)
  92. # define LOCAL_MANGLE(a) #a "(%%rip)"
  93. #else
  94. # define LOCAL_MANGLE(a) #a
  95. #endif
  96. #define MANGLE(a) EXTERN_PREFIX LOCAL_MANGLE(a)
  97. #endif /* AVUTIL_X86_ASM_H */