PAPI 7.1.0.0
Loading...
Searching...
No Matches
instructions_testcode.c File Reference
Include dependency graph for instructions_testcode.c:

Go to the source code of this file.

Functions

int instructions_million (void)
 
int instructions_fldcw (void)
 
int instructions_rep (void)
 

Function Documentation

◆ instructions_fldcw()

int instructions_fldcw ( void  )

Definition at line 92 of file instructions_testcode.c.

92 {
93
94#if defined(__i386__) || (defined __x86_64__)
95
96 int saved_cw,result,cw;
97 double three=3.0;
98
99 asm( " mov $100000,%%ecx\n"
100 "44:\n"
101 " fldl %1 # load value onto fp stack\n"
102 " fnstcw %0 # store control word to mem\n"
103 " movzwl %0, %%eax # load cw from mem, zero extending\n"
104 " movb $12, %%ah # set cw for \"round to zero\"\n"
105 " movw %%ax, %3 # store back to memory\n"
106 " fldcw %3 # save new rounding mode\n"
107 " fistpl %2 # save stack value as integer to mem\n"
108 " fldcw %0 # restore old cw\n"
109 " loop 44b # loop to make the count more obvious\n"
110 : /* no output registers */
111 : "m"(saved_cw), "m"(three), "m"(result), "m"(cw) /* inputs */
112 : "cc", "%ecx","%eax" /* clobbered */
113 );
114 return 0;
115#endif
116
117 return CODE_UNIMPLEMENTED;
118}
volatile int result
#define CODE_UNIMPLEMENTED
Definition: testcode.h:2
Here is the caller graph for this function:

◆ instructions_million()

int instructions_million ( void  )

Definition at line 8 of file instructions_testcode.c.

8 {
9
10#if defined(__i386__) || (defined __x86_64__)
11 asm( " xor %%ecx,%%ecx\n"
12 " mov $499999,%%ecx\n"
13 "55:\n"
14 " dec %%ecx\n"
15 " jnz 55b\n"
16 : /* no output registers */
17 : /* no inputs */
18 : "cc", "%ecx" /* clobbered */
19 );
20 return 0;
21#elif defined(__PPC__)
22 asm( " nop # to give us an even million\n"
23 " lis 15,499997@ha # load high 16-bits of counter\n"
24 " addi 15,15,499997@l # load low 16-bits of counter\n"
25 "55:\n"
26 " addic. 15,15,-1 # decrement counter\n"
27 " bne 0,55b # loop until zero\n"
28 : /* no output registers */
29 : /* no inputs */
30 : "cc", "15" /* clobbered */
31 );
32 return 0;
33#elif defined(__ia64__)
34
35 asm( " mov loc6=166666 // below is 6 instr.\n"
36 " ;; // because of that we count 4 too few\n"
37 "55:\n"
38 " add loc6=-1,loc6 // decrement count\n"
39 " ;;\n"
40 " cmp.ne p2,p3=0,loc6\n"
41 "(p2) br.cond.dptk 55b // if not zero, loop\n"
42 : /* no output registers */
43 : /* no inputs */
44 : "p2", "loc6" /* clobbered */
45 );
46 return 0;
47#elif defined(__sparc__)
48 asm( " sethi %%hi(333333), %%l0\n"
49 " or %%l0,%%lo(333333),%%l0\n"
50 "55:\n"
51 " deccc %%l0 ! decrement count\n"
52 " bnz 55b ! repeat until zero\n"
53 " nop ! branch delay slot\n"
54 : /* no output registers */
55 : /* no inputs */
56 : "cc", "l0" /* clobbered */
57 );
58 return 0;
59#elif defined(__arm__)
60 asm( " ldr r2,42f @ set count\n"
61 " b 55f\n"
62 "42: .word 333332\n"
63 "55:\n"
64 " add r2,r2,#-1\n"
65 " cmp r2,#0\n"
66 " bne 55b @ repeat till zero\n"
67 : /* no output registers */
68 : /* no inputs */
69 : "cc", "r2" /* clobbered */
70 );
71 return 0;
72#elif defined(__aarch64__)
73 asm( " ldr x2,=333332 // set count\n"
74 "55:\n"
75 " add x2,x2,#-1\n"
76 " cmp x2,#0\n"
77 " bne 55b // repeat till zero\n"
78 : /* no output registers */
79 : /* no inputs */
80 : "cc", "r2" /* clobbered */
81 );
82 return 0;
83#endif
84
85 return CODE_UNIMPLEMENTED;
86
87}
Here is the caller graph for this function:

◆ instructions_rep()

int instructions_rep ( void  )

Definition at line 124 of file instructions_testcode.c.

124 {
125
126#if defined(__i386__) || defined(__ILP32__)
127
128 char buffer_out[16384];
129
130 asm( " mov $1000,%%edx\n"
131 " cld\n"
132 "66: # test 8-bit store\n"
133 " mov $0xd, %%al # set eax to d\n"
134 " mov $16384, %%ecx\n"
135 " mov %0, %%edi # set destination\n"
136 " rep stosb # store d 16384 times, auto-increment\n"
137 " dec %%edx\n"
138 " jnz 66b\n"
139 : /* outputs */
140 : "rm" (buffer_out) /* inputs */
141 : "cc", "%esi","%edi","%edx","%ecx","%eax","memory" /* clobbered */
142 );
143 return 0;
144#elif defined (__x86_64__)
145
146 char buffer_out[16384];
147
148 asm( " mov $1000,%%edx\n"
149 " cld\n"
150 "66: # test 8-bit store\n"
151 " mov $0xd, %%al # set eax to d\n"
152 " mov $16384, %%ecx\n"
153 " mov %0, %%rdi # set destination\n"
154 " rep stosb # store d 16384 times, auto-increment\n"
155 " dec %%edx\n"
156 " jnz 66b\n"
157 : /* outputs */
158 : "rm" (buffer_out) /* inputs */
159 : "cc", "%esi","%edi","%edx","%ecx","%eax","memory" /* clobbered */
160 );
161 return 0;
162#endif
163
164 return CODE_UNIMPLEMENTED;
165
166}
Here is the caller graph for this function: