xref: /kvm-unit-tests/lib/riscv/asm/asm.h (revision 1c49a8120bdf60d4fc2534385d96aad2e400635f)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef _ASMRISCV_ASM_H_
3 #define _ASMRISCV_ASM_H_
4 
5 #if __riscv_xlen == 64
6 #define __REG_SEL(a, b) a
7 #elif __riscv_xlen == 32
8 #define __REG_SEL(a, b) b
9 #else
10 #error "Unexpected __riscv_xlen"
11 #endif
12 
13 #define REG_L	__REG_SEL(ld, lw)
14 #define REG_S	__REG_SEL(sd, sw)
15 #define SZREG	__REG_SEL(8, 4)
16 
17 /* ASMARR() may be used with arrays of longs */
18 #define ASMARR(reg, idx)	((idx) * SZREG)(reg)
19 
20 #define FP_SIZE 16
21 
22 #endif /* _ASMRISCV_ASM_H_ */
23