10
10
< link rel ="stylesheet " href ="drw.css ">
11
11
12
12
< style >
13
- td .reg {
14
- background-color : # 333 ;
15
- text-align : center !important
13
+ .faded {
14
+ opacity : 0.7 ;
16
15
}
17
16
18
- .replaceable {
19
- position : absolute !important ;
20
- width : 800px ;
17
+ div .footnote {
18
+ margin-top : 4em ;
19
+ font-size : smaller;
20
+ font-style : italic;
21
21
}
22
22
23
- .replacecontainer {
24
- position : relative;
23
+ # registers th {
24
+ font-size : smaller;
25
+ text-align : center;
25
26
}
26
27
27
- .faded {
28
- opacity : 0.7 ;
28
+ # registers td {
29
+ text-align : center;
30
+ }
31
+
32
+ # registers td .register {
33
+ border : 1px solid black;
34
+ }
35
+
36
+ # registers td .rax {
37
+ background : rgb (141 , 211 , 199 );
38
+ }
39
+
40
+ # registers td .eax {
41
+ background : rgb (255 , 255 , 179 );
42
+ }
43
+
44
+ # registers td .ax {
45
+ background : rgb (190 , 186 , 218 );
46
+ }
47
+
48
+ # registers td .ah {
49
+ background : rgb (251 , 128 , 114 );
50
+ }
51
+
52
+ # registers td .al {
53
+ background : rgb (128 , 177 , 211 );
29
54
}
30
55
</ style >
31
56
44
69
<!-- TODO compile all with -Wall -Wextra -->
45
70
<!-- TODO unify indentation -->
46
71
< section class ="slides ">
47
- < section id ="intro ">
72
+ < section id ="title ">
48
73
< em > September 2017</ em >
49
74
<!-- TODO, better title format -->
50
75
< h3 > Unbolting the Compiler's Lid:</ h3 >
@@ -71,7 +96,15 @@ <h3>Why am I here?</h3>
71
96
</ section >
72
97
< section >
73
98
< h3 > My background</ h3 >
74
- <!-- TODO z80 and 6502 pics -->
99
+ < div class ="fragment ">
100
+ < img src ="images/6502_z80.jpg " width ="200 ">
101
+ < img src ="images/red_dog.png " width ="200 ">
102
+ </ div >
103
+ < div class ="fragment ">
104
+ < img src ="images/profactor.jpg " width ="100 ">
105
+ < img src ="images/google.png " width ="100 ">
106
+ < img src ="images/DRWSmallLogo.png " width ="100 ">
107
+ </ div >
75
108
< aside class ="notes ">
76
109
< h4 > Potted history:</ h4 >
77
110
< ul >
@@ -118,6 +151,7 @@ <h3>Backstory</h3>
118
151
for (int x : v) result += x;
119
152
return result;
120
153
}</ code > </ pre >
154
+ < div class ="fragment "> Which is better? Check the compiler output!</ div >
121
155
< aside class ="notes ">
122
156
< ul >
123
157
< li > love performance</ li >
@@ -151,15 +185,70 @@ <h3>WARNING</h3>
151
185
<!-- reference "just enough asm to be dangerous talk -->
152
186
< section >
153
187
< h3 > x86 Assembly 101</ h3 >
154
- < h5 > Registers</ h5 >
155
188
</ section >
156
189
< section >
157
- < h3 > x86 Assembly 101</ h3 >
158
- < h5 > Calling convention</ h5 >
190
+ < h3 > Registers</ h3 >
191
+ < ul >
192
+ < li > rax, rbx, rcx, rdx, rsp, rbp, rsi, rdi, r8-r15</ li >
193
+ < li > xmm0-15, ymm0-15, zmm0-15</ li >
194
+ < li > cs, ds, ss, es, fs, gs</ li >
195
+ < li > flags</ li >
196
+ </ ul >
159
197
</ section >
160
198
< section >
161
- < h3 > x86 Assembly 101</ h3 >
162
- < h5 > Instructions</ h5 >
199
+ < h3 > Registers</ h3 >
200
+ < table id ="registers ">
201
+ < thead >
202
+ < tr >
203
+ < th > 63...56</ th >
204
+ < th > 55...48</ th >
205
+ < th > 47...40</ th >
206
+ < th > 39...32</ th >
207
+ < th > 31...24</ th >
208
+ < th > 23...16</ th >
209
+ < th > 15...8</ th >
210
+ < th > 7...0</ th >
211
+ </ tr >
212
+ </ thead >
213
+ < tbody >
214
+ < tr >
215
+ < td colspan ="8 " class ="register rax "> rax</ td >
216
+ </ tr >
217
+ < tr >
218
+ < td colspan ="4 "> (zeroed out)</ td >
219
+ < td colspan ="4 " class ="register eax "> eax</ td >
220
+ </ tr >
221
+ < tr >
222
+ < td colspan ="6 "> </ td >
223
+ < td colspan ="2 " class ="register ax "> ax</ td >
224
+ </ tr >
225
+ < tr >
226
+ < td colspan ="6 "> </ td >
227
+ < td colspan ="1 " class ="register ah "> ah</ td >
228
+ < td colspan ="1 "> </ td >
229
+ </ tr >
230
+ < tr >
231
+ < td colspan ="7 "> </ td >
232
+ < td colspan ="1 " class ="register al "> al</ td >
233
+ </ tr >
234
+ </ tbody >
235
+ </ table >
236
+ </ section >
237
+ < section >
238
+ < h3 > Calling convention</ h3 >
239
+ < pre > < code class ="cpp "> long func(int a, short b, char c);</ code > </ pre >
240
+ < ul class ="fragment ">
241
+ < li > Params: rdi, rsi, rdx, rcx, r8, r9; xmm0-7</ li >
242
+ < li > Return: eax / xmm0</ li >
243
+ < li > Callee-save: rbp, rbx, r12–r15</ li >
244
+ </ ul >
245
+ < div class ="fragment ">
246
+ < pre > < code class ="cpp "> rax func(edi a, si b, dl c);</ code > </ pre >
247
+ </ div >
248
+ < div class ="footnote "> (System V AMD64 ABI)</ div >
249
+ </ section >
250
+ < section >
251
+ < h3 > Instructions</ h3 >
163
252
< pre > < code data-trim class ="x86asm ">
164
253
mov eax, 1234 ; eax = 1234
165
254
mov ecx, 5678 ; ecx = 5678
@@ -169,20 +258,27 @@ <h5>Instructions</h5>
169
258
</ code > </ pre >
170
259
</ section >
171
260
< section >
172
- < h3 > x86 Assembly 101</ h3 >
173
- < h5 > Instructions</ h5 >
261
+ < h3 > Instructions</ h3 >
174
262
< pre > < code data-trim class ="x86asm ">
175
- mov eax, DWORD PTR [r14] ; eax = *(int32_t *)rdi
176
- mov eax, DWORD PTR [r14 + 4] ; eax = *(int32_t *)(rdi + 4)
263
+ mov eax, DWORD PTR [r14] ; eax = *(uint32_t *)rdi
264
+ mov eax, DWORD PTR [r14 + 4] ; eax = *(uint32_t *)(rdi + 4)
177
265
mov eax, DWORD PTR [r14 + 4 * rbx]
178
- ; eax = *(int32_t *)(rdi + 4 * rbx)
179
- lea eax, [r14 + 4 * rbx]
180
- ; eax = (rdi + 4 * rbx)
181
- </ code > </ pre >
266
+ ; eax = *(uint32_t *)(rdi + 4 * rbx)
267
+ lea rax, [r14 + 4 * rbx] ; eax = (rdi + 4 * rbx)
268
+ </ code > </ pre >
269
+ < pre class ="fragment "> < code data-trim class ="cpp ">
270
+ int eax = *r14; // int *r14;
271
+ int eax = r14[1];
272
+ int eax = r14[rbx];
273
+ int *rax = &r14[rbx];
274
+ </ code > </ pre >
182
275
</ section >
183
276
< section >
184
- < h3 > Miscellaneous </ h3 >
277
+ < h3 > Instructions </ h3 >
185
278
< pre > < code data-trim class ="x86asm ">
279
+ sub eax, edi
280
+ movsx rax, di
281
+ push rax
186
282
vpaddd ymm0, ymm0, ymmword ptr [rax]
187
283
popcnt rax
188
284
bsf rax
@@ -211,15 +307,11 @@ <h3>Where were we?</h3>
211
307
}</ code > </ pre >
212
308
</ section >
213
309
< section >
214
- < h3 > CE v1 </ h3 >
310
+ < h3 > Compiler Explorer v0.1 </ h3 >
215
311
< pre > < code data-noescape data-trim class ="bash ">
216
312
$ g++ /tmp/test.cc -O1 -c -S -o -masm=intel -
217
- < span class ="fragment " data-fragment-index ="3 "> | c++filt</ span >
218
- < span class ="fragment " data-fragment-index ="4 "> | grep -vE '\s+\.'</ span >
219
313
</ code > </ pre >
220
- < div class ="replacecontainer ">
221
- < pre class ="fragment current-visible replaceable " data-fragment-index ="2 "> < code class ="x86asm "
222
- data-trim >
314
+ < pre class ="fragment "> < code class ="x86asm " data-trim >
223
315
.file "test.cc"
224
316
.text
225
317
.globl _Z3sumRKSt6vectorIiSaIiEE
@@ -231,8 +323,13 @@ <h3>CE v1</h3>
231
323
mov rax, QWORD PTR 8[rdi]
232
324
sub rax, rcx
233
325
...</ code > </ pre >
234
- < pre class ="fragment current-visible replaceable " data-fragment-index ="3 "> < code class ="x86asm "
235
- data-trim >
326
+ </ section >
327
+ < section >
328
+ < h3 > Compiler Explorer v0.1</ h3 >
329
+ < pre > < code data-noescape data-trim class ="bash ">
330
+ $ g++ /tmp/test.cc -O1 -c -S -o -masm=intel - | c++filt
331
+ </ code > </ pre >
332
+ < pre > < code class ="x86asm " data-trim >
236
333
.file "test.cc"
237
334
.text
238
335
.globl sum(std::vector<int, std::allocator<int> > const&)
@@ -244,8 +341,14 @@ <h3>CE v1</h3>
244
341
mov rax, QWORD PTR 8[rdi]
245
342
sub rax, rcx
246
343
...</ code > </ pre >
247
- < pre class ="fragment current-visible replaceable " data-fragment-index ="4 "> < code class ="x86asm "
248
- data-trim >
344
+ </ section >
345
+ < section >
346
+ < h3 > Compiler Explorer v0.1</ h3 >
347
+ < pre > < code data-noescape data-trim class ="bash ">
348
+ $ g++ /tmp/test.cc -O1 -c -S -o -masm=intel - | c++filt \
349
+ | grep -vE '\s+\.'
350
+ </ code > </ pre >
351
+ < pre > < code class ="x86asm " data-trim >
249
352
sum(std::vector<int, std::allocator<int> > const&):
250
353
.LFB786:
251
354
mov rcx, QWORD PTR [rdi]
@@ -257,7 +360,6 @@ <h3>CE v1</h3>
257
360
mov edx, 0
258
361
mov eax, 0
259
362
...</ code > </ pre >
260
- </ div >
261
363
</ section >
262
364
</ section >
263
365
@@ -1127,7 +1229,7 @@ <h3>Variant</h3>
1127
1229
1128
1230
< div class ="footer ">
1129
1231
< hr >
1130
- < img src ="DRWSmallLogo.png " width ="50 " height ="16 ">
1232
+ < img src ="images/ DRWSmallLogo.png " width ="50 " height ="16 ">
1131
1233
</ div >
1132
1234
</ section >
1133
1235
</ div >
0 commit comments