1 /* Copyright (c) 2017  SiFive Inc. All rights reserved.
2 
3    This copyrighted material is made available to anyone wishing to use,
4    modify, copy, or redistribute it subject to the terms and conditions
5    of the FreeBSD License.   This program is distributed in the hope that
6    it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
7    including the implied warranties of MERCHANTABILITY or FITNESS FOR
8    A PARTICULAR PURPOSE.  A copy of this license is available at
9    http://www.opensource.org/licenses.
10 */
11 
12 #ifndef _SYS_ASM_H
13 #define _SYS_ASM_H
14 
15 /*
16  * Macros to handle different pointer/register sizes for 32/64-bit code
17  */
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 
32 #ifndef __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 # define SZFREG 8
36 # ifdef __riscv_float_abi_single
37 #  define FREG_L flw
38 #  define FREG_S fsw
39 # elif defined(__riscv_float_abi_double)
40 #  define FREG_L fld
41 #  define FREG_S fsd
42 # elif defined(__riscv_float_abi_quad)
43 #  define FREG_L flq
44 #  define FREG_S fsq
45 # else
46 #  error unsupported FLEN
47 # endif
48 #endif
49 
50 #endif /* sys/asm.h */
51