asmdefs.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright (c) 2015 Imagination Technologies Ltd
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg 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. * FFmpeg 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 FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. /**
  21. * @file
  22. * MIPS assembly defines from sys/asm.h but rewritten for use with C inline
  23. * assembly (rather than from within .s files).
  24. */
  25. #ifndef AVUTIL_MIPS_ASMDEFS_H
  26. #define AVUTIL_MIPS_ASMDEFS_H
  27. #if defined(_ABI64) && _MIPS_SIM == _ABI64
  28. # define mips_reg int64_t
  29. # define PTRSIZE " 8 "
  30. # define PTRLOG " 3 "
  31. # define PTR_ADDU "daddu "
  32. # define PTR_ADDIU "daddiu "
  33. # define PTR_ADDI "daddi "
  34. # define PTR_SUBU "dsubu "
  35. # define PTR_L "ld "
  36. # define PTR_S "sd "
  37. # define PTR_SRA "dsra "
  38. # define PTR_SRL "dsrl "
  39. # define PTR_SLL "dsll "
  40. #else
  41. # define mips_reg int32_t
  42. # define PTRSIZE " 4 "
  43. # define PTRLOG " 2 "
  44. # define PTR_ADDU "addu "
  45. # define PTR_ADDIU "addiu "
  46. # define PTR_ADDI "addi "
  47. # define PTR_SUBU "subu "
  48. # define PTR_L "lw "
  49. # define PTR_S "sw "
  50. # define PTR_SRA "sra "
  51. # define PTR_SRL "srl "
  52. # define PTR_SLL "sll "
  53. #endif
  54. /*
  55. * parse_r var, r - Helper assembler macro for parsing register names.
  56. *
  57. * This converts the register name in $n form provided in \r to the
  58. * corresponding register number, which is assigned to the variable \var. It is
  59. * needed to allow explicit encoding of instructions in inline assembly where
  60. * registers are chosen by the compiler in $n form, allowing us to avoid using
  61. * fixed register numbers.
  62. *
  63. * It also allows newer instructions (not implemented by the assembler) to be
  64. * transparently implemented using assembler macros, instead of needing separate
  65. * cases depending on toolchain support.
  66. *
  67. * Simple usage example:
  68. * __asm__ __volatile__("parse_r __rt, %0\n\t"
  69. * ".insn\n\t"
  70. * "# di %0\n\t"
  71. * ".word (0x41606000 | (__rt << 16))"
  72. * : "=r" (status);
  73. */
  74. /* Match an individual register number and assign to \var */
  75. #define _IFC_REG(n) \
  76. ".ifc \\r, $" #n "\n\t" \
  77. "\\var = " #n "\n\t" \
  78. ".endif\n\t"
  79. __asm__(".macro parse_r var r\n\t"
  80. "\\var = -1\n\t"
  81. _IFC_REG(0) _IFC_REG(1) _IFC_REG(2) _IFC_REG(3)
  82. _IFC_REG(4) _IFC_REG(5) _IFC_REG(6) _IFC_REG(7)
  83. _IFC_REG(8) _IFC_REG(9) _IFC_REG(10) _IFC_REG(11)
  84. _IFC_REG(12) _IFC_REG(13) _IFC_REG(14) _IFC_REG(15)
  85. _IFC_REG(16) _IFC_REG(17) _IFC_REG(18) _IFC_REG(19)
  86. _IFC_REG(20) _IFC_REG(21) _IFC_REG(22) _IFC_REG(23)
  87. _IFC_REG(24) _IFC_REG(25) _IFC_REG(26) _IFC_REG(27)
  88. _IFC_REG(28) _IFC_REG(29) _IFC_REG(30) _IFC_REG(31)
  89. ".iflt \\var\n\t"
  90. ".error \"Unable to parse register name \\r\"\n\t"
  91. ".endif\n\t"
  92. ".endm");
  93. #endif /* AVCODEC_MIPS_ASMDEFS_H */