5 #include "tests/malloc.h"
7 typedef unsigned char UChar
;
8 typedef unsigned int UInt
;
9 typedef unsigned long int UWord
;
10 typedef unsigned long long int ULong
;
13 typedef struct { UChar cs
[40]; } Block
;
15 void showBlock ( char* msg
, Block
* b
)
19 for (i
= 0; i
< 40; i
++)
20 printf("%02x", (UInt
)b
->cs
[i
]);
24 UChar
randUChar ( void )
26 static UInt seed
= 80021;
27 seed
= 1103515245 * seed
+ 12345;
28 return (seed
>> 17) & 0xFF;
31 void randBlock ( Block
* b
)
35 for (i
= 0; i
< sizeof(Block
); i
++)
39 /* Generate a function test_NAME, that tests the given insn.
40 The insn may only mention (%rax) and r9. */
42 #define GEN_test_Monly(_name, _mem_form) \
44 __attribute__ ((noinline)) static void test_##_name ( void ) \
46 Block* b = memalign32(sizeof(Block)); \
48 printf("%s\n", #_name); \
49 showBlock("before", b); \
50 __asm__ __volatile__( \
51 "leaq 16(%0),%%rax" "\n\t" \
52 "movq 24(%0),%%r9" "\n\t" \
54 "movq %%r9, 32(%0)" "\n\t" \
57 : /*TRASH*/"r9","rax","memory","cc" \
59 showBlock("after ", b); \
64 GEN_test_Monly( MOVBE_RtoM_64
, "movbe %%r9, 1(%%rax)")
65 GEN_test_Monly( MOVBE_RtoM_32
, "movbe %%r9d,1(%%rax)")
66 GEN_test_Monly( MOVBE_RtoM_16
, "movbe %%r9w,1(%%rax)")
68 GEN_test_Monly( MOVBE_MtoR_64
, "movbe 1(%%rax), %%r9")
69 GEN_test_Monly( MOVBE_MtoR_32
, "movbe 1(%%rax), %%r9d")
70 GEN_test_Monly( MOVBE_MtoR_16
, "movbe 1(%%rax), %%r9w")