asm.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* Miscellaneous macros.
  2. Copyright (C) 2022-2026 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library. If not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #ifndef _SYS_ASM_H
  16. #define _SYS_ASM_H
  17. #include <sys/regdef.h>
  18. #include <sysdeps/generic/sysdep.h>
  19. /* Macros to handle different pointer/register sizes for 32/64-bit code. */
  20. #define SZREG 8
  21. #define SZFREG 8
  22. #define SZVREG 16
  23. #define SZXREG 32
  24. #define REG_L ld.d
  25. #define REG_S st.d
  26. #define SRLI srli.d
  27. #define SLLI slli.d
  28. #define ADDI addi.d
  29. #define ADD add.d
  30. #define SUB sub.d
  31. #define BSTRINS bstrins.d
  32. #define LI li.d
  33. #define FREG_L fld.d
  34. #define FREG_S fst.d
  35. /* Declare leaf routine.
  36. The usage of macro LEAF/ENTRY is as follows:
  37. 1. LEAF(fcn) -- the align value of fcn is .align 3 (default value)
  38. 2. LEAF(fcn, 6) -- the align value of fcn is .align 6
  39. */
  40. #define LEAF_IMPL(symbol, aln, ...) \
  41. .text; \
  42. .globl symbol; \
  43. .align aln; \
  44. .type symbol, @function; \
  45. symbol: \
  46. cfi_startproc;
  47. #define LEAF(...) LEAF_IMPL(__VA_ARGS__, 3)
  48. #define ENTRY(...) LEAF(__VA_ARGS__)
  49. #define LEAF_NO_ALIGN(symbol) \
  50. .text; \
  51. .globl symbol; \
  52. .type symbol, @function; \
  53. symbol: \
  54. cfi_startproc;
  55. #define ENTRY_NO_ALIGN(symbol) LEAF_NO_ALIGN(symbol)
  56. /* Mark end of function. */
  57. #undef END
  58. #define END(function) \
  59. cfi_endproc; \
  60. .size function, .- function;
  61. /* Stack alignment. */
  62. #define ALMASK ~15
  63. #endif /* sys/asm.h */