File: Linux2PPC.map

package info (click to toggle)
herdtools7 7.58-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,732 kB
  • sloc: ml: 128,583; ansic: 3,827; makefile: 670; python: 407; sh: 212; awk: 14
file content (127 lines) | stat: -rw-r--r-- 3,649 bytes parent folder | download
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
C to PPC

"if(%x != constvar:c) codevar:t; else codevar:f;" -> "cmpwi %x,&c;
                                     beq else;
                                     codevar:t;
                                     b end;
                                     else:
                                     codevar:f;
                                     end:"
"if(%x) codevar:t; else codevar:f;" -> "cmpwi %x,0;
                                     beq else;
                                     codevar:t;
                                     b end;
                                     else:
                                     codevar:f;
                                     end:"

"if(constvar:c == x) codevar:t;" -> "cmpwi %x,&c;
                                     bne else;
				     codevar:t;
				     else:"

"if(x == constvar:c) codevar:t;" -> "cmpwi %x,&c;
                                     bne else;
				     codevar:t;
				     else:"
"if(%x) codevar:t;" -> "cmpwi %x,0;
			beq else;
		        codevar:t;
		        else:"

"%x = constvar:c;" -> "li %x,&c"

"*%x = constvar:c;" -> "li %tmp,&c;
                       stw %tmp,0(%x)"

"%x = %y;"  -> "mr %x,%y"
"%x = %y == %z;"  -> "li %x,1; cmpw %y,%z; beq else; xor %x,%x,%x; else:"
"%x = %y != %z;"  -> "li %x,1; cmpw %y,%z; bne else; xor %x,%x,%x; else:"
"%x = %y == constvar:c;"  -> "li %x,1; cmpwi %y,&c; beq else; xor %x,%x,%x; else:"
"%x = %y != constvar:c;"  -> "li %x,1; cmpwi %y,&c; bne else; xor %x,%x,%x; else:"

"*%x = %y;" -> "stw %y,0(%x)"

"%x = *%y;" -> "lwz %x,0(%y)"

"%x = READ_ONCE(*%y);" -> "load:lwz %x,0(%y)"

"WRITE_ONCE(*%y, %x);" -> "store:stw %x,0(%y)"

"WRITE_ONCE(*%y, constvar:c);" -> "li %tmp,&c;
                                   store:stw %tmp,0(%y)"

"WRITE_ONCE(*%y, %x + constvar:c);" -> "li %tmp,&c;
                                        add %tmp, %tmp, %x;
                                        store:stw %tmp,0(%y)"

"%x = %t & constvar:c; %x = %x + constvar:d; WRITE_ONCE(*%y,%x);" ->
"andi. %x,%t,&c;
addi %x,%x,&d;
store: stw %x,0(%y)"

"%t0 = %r & constvar:c; %t1 = %x + %t0; WRITE_ONCE(*%t1,constvar:d);" ->
"andi. %t0,%r,&c;
add %t1,%x,%t0;
li %t2,&d;
store: stw %t2,0(%t1)"

"%x = %t & constvar:c; %x = %x + constvar:d; smp_store_release(%y,%x);" ->
"andi. %x,%t,&c;
addi %x,%x,&d;
lwsync;
store: stw %x,0(%y)"

"%t0 = %r & constvar:c; %t1 = %x + %t0; smp_store_release(%t1,constvar:d);" ->
"andi. %t0,%r,&c;
add %t1,%x,%t0;
li %t2,&d;
lwsync;
store: stw %t2,0(%t1)"

"%r = xchg_relaxed(%x, %y);" -> "loop:load:lwarx %r,r0,%x;
				store:stwcx. %y,r0,%x;
				bne loop"

"%r = cmpxchg_relaxed(%x, constvar:c, constvar:d);" -> "loop:li %tmp,&c;
							load:lwarx %r,r0,%x;
							cmpw %r,%tmp;
							bne out;
							li %tmp,&d;
							store:stwcx. %tmp,r0,%x;
							bne loop;
							out:"

"%r = xchg_relaxed(%x, constvar:c);" -> "li %tmp,&c;
					 loop:load:lwarx %r,r0,%x;
					 store:stwcx. %tmp,r0,%x;
					 bne loop"

"smp_mb();" -> "sync"

"smp_rmb();" -> "lwsync"

"smp_wmb();" -> "lwsync"

"release" : "" -> "lwsync;"

"acquire" : "^\([^;]+\)$" -> "\1;lwsync"

// this func will convert lwsync to stronger sync in the translation
"harden_lwsync" : "lwsync" -> "sync"

// On PPC, to convert a acq_rel into a fully-ordered primitive,
// we need to harden lwsync twice: one for the release lwsync and
// the other for the acquire lwsync
"full_on_acq_rel" : "harden_lwsync | harden_lwsync"

"full" : "acquire | release | full_on_acq_rel"

"id" : "" -> ""
"const_c_to_1" : "&c" -> "1"
"const_c_to_0" : "&c" -> "0"
"const_d_to_1" : "&d" -> "1"

"out_to_loop" : "bne out" -> "bne loop"

"lock" : "const_c_to_0 | const_d_to_1 | out_to_loop"