xref: /linux/arch/s390/include/asm/insn-common-asm.h (revision 0eaed89c18aeedf0898baf2dbf5ff027c6795152)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Assembler helper macros to generate .byte/.word code for instructions
4  * that are unknown to older binutils versions.
5  */
6 
7 #ifndef __ASM_S390_INSN_COMMON_ASM_H
8 #define __ASM_S390_INSN_COMMON_ASM_H
9 
10 #ifdef __ASSEMBLER__
11 
12 /*
13  * GR_NUM - Retrieve general-purpose register number
14  *
15  * @opd:	Operand to store register number
16  * @gr:		String designation register in the format "%rN"
17  */
18 .macro	GR_NUM	opd gr
19 	\opd = 255
20 	.irp rs,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
21 	.ifc \gr,%r\rs
22 		\opd = \rs
23 	.endif
24 	.endr
25 	.if \opd == 255
26 		\opd = \gr
27 	.endif
28 .endm
29 
30 /*
31  * VX_NUM - Retrieve vector register number
32  *
33  * @opd:	Operand to store register number
34  * @vxr:	String designation register in the format "%vN"
35  *
36  * The vector register number is used for as input number to the
37  * instruction and, as well as, to compute the RXB field of the
38  * instruction.
39  */
40 .macro	VX_NUM	opd vxr
41 	\opd = 255
42 	.irp vs,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
43 	.ifc \vxr,%v\vs
44 		\opd = \vs
45 	.endif
46 	.endr
47 	.if \opd == 255
48 		\opd = \vxr
49 	.endif
50 .endm
51 
52 #endif	/* __ASSEMBLER__ */
53 #endif	/* __ASM_S390_INSN_COMMON_ASM_H */
54