asm.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Miscellaneous macros.
  2. Copyright (C) 2000-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. /* Macros to handle different pointer/register sizes for 32/64-bit code. */
  18. #if __riscv_xlen == 64
  19. # define PTRLOG 3
  20. # define SZREG 8
  21. # define REG_S sd
  22. # define REG_L ld
  23. #elif __riscv_xlen == 32
  24. # define PTRLOG 2
  25. # define SZREG 4
  26. # define REG_S sw
  27. # define REG_L lw
  28. #else
  29. # error __riscv_xlen must equal 32 or 64
  30. #endif
  31. #if !defined __riscv_float_abi_soft
  32. /* For ABI uniformity, reserve 8 bytes for floats, even if double-precision
  33. floating-point is not supported in hardware. */
  34. # if defined __riscv_float_abi_double
  35. # define FREG_L fld
  36. # define FREG_S fsd
  37. # define SZFREG 8
  38. # else
  39. # error unsupported FLEN
  40. # endif
  41. #endif
  42. /* Declare leaf routine. */
  43. #define LEAF(symbol) \
  44. .globl symbol; \
  45. .align 2; \
  46. .type symbol,@function; \
  47. symbol: \
  48. cfi_startproc;
  49. /* Mark end of function. */
  50. #undef END
  51. #define END(function) \
  52. cfi_endproc; \
  53. .size function,.-function
  54. /* Stack alignment. */
  55. #define ALMASK ~15
  56. #endif /* sys/asm.h */