This source file includes following definitions.
- test_tar
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <unistd.h>
17 #include <string.h>
18
19 #include "tm.h"
20 #include "utils.h"
21
22 int num_loops = 10000;
23
24 int test_tar(void)
25 {
26 int i;
27
28 SKIP_IF(!have_htm());
29 SKIP_IF(!is_ppc64le());
30
31 for (i = 0; i < num_loops; i++)
32 {
33 uint64_t result = 0;
34 asm __volatile__(
35 "li 7, 1;"
36 "mtspr %[tar], 7;"
37 "tbegin.;"
38 "beq 3f;"
39 "li 4, 0x7000;"
40 "2:;"
41 "li 7, 2;"
42 "mtspr %[tar], 7;"
43 "tsuspend.;"
44 "li 7, 3;"
45 "mtspr %[tar], 7;"
46 "tresume.;"
47 "subi 4, 4, 1;"
48 "cmpdi 4, 0;"
49 "bne 2b;"
50 "tend.;"
51
52
53 "mfspr 7, %[tar];"
54 "ori %[res], 7, 4;"
55 "b 4f;"
56
57
58 "3:;"
59 "mfspr 7, %[tar];"
60 "ori %[res], 7, 8;"
61 "4:;"
62
63 : [res]"=r"(result)
64 : [tar]"i"(SPRN_TAR)
65 : "memory", "r0", "r4", "r7");
66
67
68
69 if ((result != 7) && (result != 9))
70 return 1;
71 }
72 return 0;
73 }
74
75 int main(int argc, char *argv[])
76 {
77
78 if (argc > 1) {
79 if (strcmp(argv[1], "-h") == 0) {
80 printf("Syntax:\n\t%s [<num loops>]\n",
81 argv[0]);
82 return 1;
83 } else {
84 num_loops = atoi(argv[1]);
85 }
86 }
87
88 printf("Starting, %d loops\n", num_loops);
89
90 return test_harness(test_tar, "tm_tar");
91 }