asm.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* Copyright (c) 2017 SiFive Inc. All rights reserved.
  2. This copyrighted material is made available to anyone wishing to use,
  3. modify, copy, or redistribute it subject to the terms and conditions
  4. of the FreeBSD License. This program is distributed in the hope that
  5. it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
  6. including the implied warranties of MERCHANTABILITY or FITNESS FOR
  7. A PARTICULAR PURPOSE. A copy of this license is available at
  8. http://www.opensource.org/licenses.
  9. */
  10. #ifndef _SYS_ASM_H
  11. #define _SYS_ASM_H
  12. /*
  13. * Macros to handle different pointer/register sizes for 32/64-bit code
  14. */
  15. #if __riscv_xlen == 64
  16. # define PTRLOG 3
  17. # define SZREG 8
  18. # define REG_S sd
  19. # define REG_L ld
  20. #elif __riscv_xlen == 32
  21. # define PTRLOG 2
  22. # define SZREG 4
  23. # define REG_S sw
  24. # define REG_L lw
  25. #else
  26. # error __riscv_xlen must equal 32 or 64
  27. #endif
  28. #ifndef __riscv_float_abi_soft
  29. /* For ABI uniformity, reserve 8 bytes for floats, even if double-precision
  30. floating-point is not supported in hardware. */
  31. # define SZFREG 8
  32. # ifdef __riscv_float_abi_single
  33. # define FREG_L flw
  34. # define FREG_S fsw
  35. # elif defined(__riscv_float_abi_double)
  36. # define FREG_L fld
  37. # define FREG_S fsd
  38. # elif defined(__riscv_float_abi_quad)
  39. # define FREG_L flq
  40. # define FREG_S fsq
  41. # else
  42. # error unsupported FLEN
  43. # endif
  44. #endif
  45. #endif /* sys/asm.h */