Home | History | Annotate | Download | only in s390x
      1 #include <stdio.h>
      2 
      3 #define MUL_REG_MEM(insn, m1, m2)			\
      4 ({							\
      5 	unsigned long tmp1 = m1;			\
      6 	unsigned long tmp2 = m1;			\
      7 	asm volatile(	"lgr 2, %0\n"			\
      8 			"lgr 3, %1\n"			\
      9 			#insn " 2, %2\n"		\
     10 			"lgr %0,2\n"			\
     11 			"lgr %1,3\n"			\
     12 			: "+d" (tmp1), "+d" (tmp2)	\
     13 			: "Q" (m2)			\
     14 			: "2","3");			\
     15 	printf(#insn " %16.16lX * %16.16lX = %16.16lX%16.16lX\n", m1, m2, tmp1, tmp2); \
     16 })
     17 
     18 #define MUL_REG_REG(insn, m1, m2)			\
     19 ({							\
     20 	unsigned long tmp1 = m1;			\
     21 	unsigned long tmp2 = m1;			\
     22 	asm volatile(	"lgr 2, %0\n"			\
     23 			"lgr 3, %1\n"			\
     24 			#insn " 2, %2\n"		\
     25 			"lgr %0,2\n"			\
     26 			"lgr %1,3\n"			\
     27 			: "+d" (tmp1), "+d" (tmp2)	\
     28 			: "d" (m2)			\
     29 			: "2","3");			\
     30 	printf(#insn " %16.16lX * %16.16lX = %16.16lX%16.16lX\n", m1, m2, tmp1, tmp2); \
     31 })
     32 
     33 #define MUL_REG_IMM(insn, m1, m2)			\
     34 ({							\
     35 	unsigned long tmp1 = m1;			\
     36 	unsigned long tmp2 = m1;			\
     37 	asm volatile(	"lgr 2, %0\n"			\
     38 			"lgr 3, %1\n"			\
     39 			#insn " 2, " #m2 "\n"		\
     40 			"lgr %0,2\n"			\
     41 			"lgr %1,3\n"			\
     42 			: "+d" (tmp1), "+d" (tmp2)	\
     43 			:: "2","3");			\
     44 	printf(#insn " %16.16lX * %16.16lX = %16.16lX%16.16lX\n", m1, (unsigned long) m2, tmp1, tmp2); \
     45 })
     46 
     47 #define MUL_REG_XIMM(insn, m1, um2, m2)			\
     48 ({							\
     49 	unsigned long tmp1 = m1;			\
     50 	unsigned long tmp2 = m1;			\
     51 	asm volatile(	"lgr 2, %0\n"			\
     52 			"lgr 3, %1\n"			\
     53 			insn(2,m2)			\
     54 			"lgr %0,2\n"			\
     55 			"lgr %1,3\n"			\
     56 			: "+d" (tmp1), "+d" (tmp2)	\
     57 			:: "2","3");			\
     58 	printf(#insn " %16.16lX * %16.16lX = %16.16lX%16.16lX\n", m1, (unsigned long) 0x##um2##m2, tmp1, tmp2); \
     59 })
     60 
     61 
     62 #define memsweep(i, m2)					\
     63 ({							\
     64 	MUL_REG_MEM(i, 0ul, m2);			\
     65 	MUL_REG_MEM(i, 1ul, m2);			\
     66 	MUL_REG_MEM(i, 0xfffful, m2);			\
     67 	MUL_REG_MEM(i, 0x7ffful, m2);			\
     68 	MUL_REG_MEM(i, 0x8000ul, m2);			\
     69 	MUL_REG_MEM(i, 0xfffffffful, m2);		\
     70 	MUL_REG_MEM(i, 0x80000000ul, m2);		\
     71 	MUL_REG_MEM(i, 0x7ffffffful, m2);		\
     72 	MUL_REG_MEM(i, 0xfffffffffffffffful, m2);	\
     73 	MUL_REG_MEM(i, 0x8000000000000000ul, m2);	\
     74 	MUL_REG_MEM(i, 0x7ffffffffffffffful, m2);	\
     75 })
     76 
     77 #define regsweep(i, m2)					\
     78 ({							\
     79 	MUL_REG_REG(i, 0ul, m2);			\
     80 	MUL_REG_REG(i, 1ul, m2);			\
     81 	MUL_REG_REG(i, 0xfffful, m2);			\
     82 	MUL_REG_REG(i, 0x7ffful, m2);			\
     83 	MUL_REG_REG(i, 0x8000ul, m2);			\
     84 	MUL_REG_REG(i, 0xfffffffful, m2);		\
     85 	MUL_REG_REG(i, 0x80000000ul, m2);		\
     86 	MUL_REG_REG(i, 0x7ffffffful, m2);		\
     87 	MUL_REG_REG(i, 0xfffffffffffffffful, m2);	\
     88 	MUL_REG_REG(i, 0x8000000000000000ul, m2);	\
     89 	MUL_REG_REG(i, 0x7ffffffffffffffful, m2);	\
     90 })
     91 
     92 #define immsweep(i, m2)					\
     93 ({							\
     94 	MUL_REG_IMM(i, 0ul, m2);			\
     95 	MUL_REG_IMM(i, 1ul, m2);			\
     96 	MUL_REG_IMM(i, 0xfffful, m2);			\
     97 	MUL_REG_IMM(i, 0x7ffful, m2);			\
     98 	MUL_REG_IMM(i, 0x8000ul, m2);			\
     99 	MUL_REG_IMM(i, 0xfffffffful, m2);		\
    100 	MUL_REG_IMM(i, 0x80000000ul, m2);		\
    101 	MUL_REG_IMM(i, 0x7ffffffful, m2);		\
    102 	MUL_REG_IMM(i, 0xfffffffffffffffful, m2);	\
    103 	MUL_REG_IMM(i, 0x8000000000000000ul, m2);	\
    104 	MUL_REG_IMM(i, 0x7ffffffffffffffful, m2);	\
    105 })
    106 
    107 #define ximmsweep(i, um2, m2)				\
    108 ({							\
    109 	MUL_REG_XIMM(i, 0ul, um2, m2);			\
    110 	MUL_REG_XIMM(i, 1ul, um2, m2);			\
    111 	MUL_REG_XIMM(i, 0xfffful, um2, m2);		\
    112 	MUL_REG_XIMM(i, 0x7ffful, um2, m2);		\
    113 	MUL_REG_XIMM(i, 0x8000ul, um2, m2);		\
    114 	MUL_REG_XIMM(i, 0xfffffffful, um2, m2);		\
    115 	MUL_REG_XIMM(i, 0x80000000ul, um2, m2);		\
    116 	MUL_REG_XIMM(i, 0x7ffffffful, um2, m2);		\
    117 	MUL_REG_XIMM(i, 0xfffffffffffffffful, um2, m2);	\
    118 	MUL_REG_XIMM(i, 0x8000000000000000ul, um2, m2);	\
    119 	MUL_REG_XIMM(i, 0x7ffffffffffffffful, um2, m2);	\
    120 })
    121 
    122 #define MUL_MSY(m1, m2)					\
    123 ({							\
    124 	unsigned long tmp1 = m1;			\
    125 	unsigned long tmp2 = m1;			\
    126 	register unsigned long *addr asm("5") = &m2;	\
    127 	asm volatile(	"lgr 2, %0\n"			\
    128 			"lgr 3, %1\n"			\
    129 			MSY(2,0,5,000,00)		\
    130 			"lgr %0,2\n"			\
    131 			"lgr %1,3\n"			\
    132 			: "+d" (tmp1), "+d" (tmp2)	\
    133 			: "Q" (m2), "d" (addr)		\
    134 			: "2","3");			\
    135 	printf("msy %16.16lX * %16.16lX = %16.16lX%16.16lX\n", m1, m2, tmp1, tmp2); \
    136 })
    137 
    138 #define msysweep(s2)				\
    139 ({						\
    140 	MUL_MSY(0ul, s2);			\
    141 	MUL_MSY(1ul, s2);			\
    142 	MUL_MSY(0xfffful, s2);			\
    143 	MUL_MSY(0x7ffful, s2);			\
    144 	MUL_MSY(0x8000ul, s2);			\
    145 	MUL_MSY(0xfffffffful, s2);		\
    146 	MUL_MSY(0x80000000ul, s2);		\
    147 	MUL_MSY(0x7ffffffful, s2);		\
    148 	MUL_MSY(0xfffffffffffffffful, s2);	\
    149 	MUL_MSY(0x8000000000000000ul, s2);	\
    150 	MUL_MSY(0x7ffffffffffffffful, s2);	\
    151 })
    152 
    153 #define MUL_MHY(m1, m2)					\
    154 ({							\
    155 	unsigned long tmp1 = m1;			\
    156 	unsigned long tmp2 = m1;			\
    157 	register unsigned long *addr asm("5") = &m2;	\
    158 	asm volatile(	"lgr 2, %0\n"			\
    159 			"lgr 3, %1\n"			\
    160 			MHY(2,0,5,000,00)		\
    161 			"lgr %0,2\n"			\
    162 			"lgr %1,3\n"			\
    163 			: "+d" (tmp1), "+d" (tmp2)	\
    164 			: "Q" (m2), "d" (addr)		\
    165 			: "2","3");			\
    166 	printf("mhy %16.16lX * %16.16lX = %16.16lX%16.16lX\n", m1, m2, tmp1, tmp2); \
    167 })
    168 
    169 #define mhysweep(s2)				\
    170 ({						\
    171 	MUL_MHY(0ul, s2);			\
    172 	MUL_MHY(1ul, s2);			\
    173 	MUL_MHY(0xfffful, s2);			\
    174 	MUL_MHY(0x7ffful, s2);			\
    175 	MUL_MHY(0x8000ul, s2);			\
    176 	MUL_MHY(0xfffffffful, s2);		\
    177 	MUL_MHY(0x80000000ul, s2);		\
    178 	MUL_MHY(0x7ffffffful, s2);		\
    179 	MUL_MHY(0xfffffffffffffffful, s2);	\
    180 	MUL_MHY(0x8000000000000000ul, s2);	\
    181 	MUL_MHY(0x7ffffffffffffffful, s2);	\
    182 })
    183 
    184 #define MUL_MFY(m1, m2)					\
    185 ({							\
    186 	unsigned long tmp1 = m1;			\
    187 	unsigned long tmp2 = m1;			\
    188 	register unsigned long *addr asm("5") = &m2;	\
    189 	asm volatile(	"lgr 2, %0\n"			\
    190 			"lgr 3, %1\n"			\
    191 			MFY(2,0,5,000,00)		\
    192 			"lgr %0,2\n"			\
    193 			"lgr %1,3\n"			\
    194 			: "+d" (tmp1), "+d" (tmp2)	\
    195 			: "Q" (m2), "d" (addr)		\
    196 			: "2","3");			\
    197 	printf("mfy %16.16lX * %16.16lX = %16.16lX%16.16lX\n", m1, m2, tmp1, tmp2); \
    198 })
    199 
    200 #define mfysweep(s2)				\
    201 ({						\
    202 	MUL_MFY(0ul, s2);			\
    203 	MUL_MFY(1ul, s2);			\
    204 	MUL_MFY(0xfffful, s2);			\
    205 	MUL_MFY(0x7ffful, s2);			\
    206 	MUL_MFY(0x8000ul, s2);			\
    207 	MUL_MFY(0xfffffffful, s2);		\
    208 	MUL_MFY(0x80000000ul, s2);		\
    209 	MUL_MFY(0x7ffffffful, s2);		\
    210 	MUL_MFY(0xfffffffffffffffful, s2);	\
    211 	MUL_MFY(0x8000000000000000ul, s2);	\
    212 	MUL_MFY(0x7ffffffffffffffful, s2);	\
    213 })
    214