asm.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* Miscellaneous macros.
  2. Copyright (C) 2000-2018 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. <http://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. // # warning "rv32i-based targets are experimental"
  29. #else
  30. # error __riscv_xlen must equal 32 or 64
  31. #endif
  32. #if !defined __riscv_float_abi_soft
  33. /* For ABI uniformity, reserve 8 bytes for floats, even if double-precision
  34. floating-point is not supported in hardware. */
  35. # if defined __riscv_float_abi_double
  36. # define FREG_L fld
  37. # define FREG_S fsd
  38. # define SZFREG 8
  39. # else
  40. # error unsupported FLEN
  41. # endif
  42. #endif
  43. /* Declare leaf routine. */
  44. #define LEAF(symbol) \
  45. .globl symbol; \
  46. .align 2; \
  47. .type symbol,@function; \
  48. symbol: \
  49. cfi_startproc;
  50. /* Mark end of function. */
  51. #undef END
  52. #define END(function) \
  53. cfi_endproc; \
  54. .size function,.-function
  55. /* Stack alignment. */
  56. #define ALMASK ~15
  57. #endif /* sys/asm.h */