about summary refs log tree commit diff stats
path: root/html/subx/029transforms.cc.html
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-08-13 21:25:22 -0700
committerKartik Agaram <vc@akkartik.com>2018-08-13 21:25:22 -0700
commit7328af20a1921d9258a60803ee5367da97a6082e (patch)
treee809d6cff85f290073a71982a5d24255848678ac /html/subx/029transforms.cc.html
parent5cec03b41425940ff5fa73c10ea8fb402a3b5ffa (diff)
downloadmu-7328af20a1921d9258a60803ee5367da97a6082e.tar.gz
4521
Diffstat (limited to 'html/subx/029transforms.cc.html')
-rw-r--r--html/subx/029transforms.cc.html124
1 files changed, 124 insertions, 0 deletions
diff --git a/html/subx/029transforms.cc.html b/html/subx/029transforms.cc.html
new file mode 100644
index 00000000..6f067d6f
--- /dev/null
+++ b/html/subx/029transforms.cc.html
@@ -0,0 +1,124 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+<title>Mu - subx/029transforms.cc</title>
+<meta name="Generator" content="Vim/7.4">
+<meta name="plugin-version" content="vim7.4_v2">
+<meta name="syntax" content="cpp">
+<meta name="settings" content="number_lines,use_css,pre_wrap,no_foldcolumn,expand_tabs,line_ids,prevent_copy=">
+<meta name="colorscheme" content="minimal">
+<style type="text/css">
+<!--
+pre { white-space: pre-wrap; font-family: monospace; color: #aaaaaa; background-color: #080808; }
+body { font-size: 12pt; font-family: monospace; color: #aaaaaa; background-color: #080808; }
+a { color:#eeeeee; text-decoration: none; }
+a:hover { text-decoration: underline; }
+* { font-size: 12pt; font-size: 1em; }
+.Comment { color: #9090ff; }
+.Comment a { color:#0000ee; text-decoration:underline; }
+.Delimiter { color: #800080; }
+.LineNr { color: #444444; }
+-->
+</style>
+
+<script type='text/javascript'>
+<!--
+
+/* function to open any folds containing a jumped-to line before jumping to it */
+function JumpToLine()
+{
+  var lineNum;
+  lineNum = window.location.hash;
+  lineNum = lineNum.substr(1); /* strip off '#' */
+
+  if (lineNum.indexOf('L') == -1) {
+    lineNum = 'L'+lineNum;
+  }
+  lineElem = document.getElementById(lineNum);
+  /* Always jump to new location even if the line was hidden inside a fold, or
+   * we corrected the raw number to a line ID.
+   */
+  if (lineElem) {
+    lineElem.scrollIntoView(true);
+  }
+  return true;
+}
+if ('onhashchange' in window) {
+  window.onhashchange = JumpToLine;
+}
+
+-->
+</script>
+</head>
+<body onload='JumpToLine();'>
+<pre id='vimCodeElement'>
+<span id="L1" class="LineNr"> 1 </span><span class="Comment">//: Ordering transforms is a well-known hard problem when building compilers.</span>
+<span id="L2" class="LineNr"> 2 </span><span class="Comment">//: In our case we also have the additional notion of layers. The ordering of</span>
+<span id="L3" class="LineNr"> 3 </span><span class="Comment">//: layers can have nothing in common with the ordering of transforms when</span>
+<span id="L4" class="LineNr"> 4 </span><span class="Comment">//: SubX is tangled and run. This can be confusing for readers, particularly</span>
+<span id="L5" class="LineNr"> 5 </span><span class="Comment">//: if later layers start inserting transforms at arbitrary points between</span>
+<span id="L6" class="LineNr"> 6 </span><span class="Comment">//: transforms introduced earlier. Over time adding transforms can get harder</span>
+<span id="L7" class="LineNr"> 7 </span><span class="Comment">//: and harder, having to meet the constraints of everything that's come</span>
+<span id="L8" class="LineNr"> 8 </span><span class="Comment">//: before. It's worth thinking about organization up-front so the ordering is</span>
+<span id="L9" class="LineNr"> 9 </span><span class="Comment">//: easy to hold in our heads, and it's obvious where to add a new transform.</span>
+<span id="L10" class="LineNr">10 </span><span class="Comment">//: Some constraints:</span>
+<span id="L11" class="LineNr">11 </span><span class="Comment">//:</span>
+<span id="L12" class="LineNr">12 </span><span class="Comment">//:   1. Layers force us to build SubX bottom-up; since we want to be able to</span>
+<span id="L13" class="LineNr">13 </span><span class="Comment">//:   build and run SubX after stopping loading at any layer, the overall</span>
+<span id="L14" class="LineNr">14 </span><span class="Comment">//:   organization has to be to introduce primitives before we start using</span>
+<span id="L15" class="LineNr">15 </span><span class="Comment">//:   them.</span>
+<span id="L16" class="LineNr">16 </span><span class="Comment">//:</span>
+<span id="L17" class="LineNr">17 </span><span class="Comment">//:   2. Transforms usually need to be run top-down, converting high-level</span>
+<span id="L18" class="LineNr">18 </span><span class="Comment">//:   representations to low-level ones so that low-level layers can be</span>
+<span id="L19" class="LineNr">19 </span><span class="Comment">//:   oblivious to them.</span>
+<span id="L20" class="LineNr">20 </span><span class="Comment">//:</span>
+<span id="L21" class="LineNr">21 </span><span class="Comment">//:   3. When running we'd often like new representations to be checked before</span>
+<span id="L22" class="LineNr">22 </span><span class="Comment">//:   they are transformed away. The whole reason for new representations is</span>
+<span id="L23" class="LineNr">23 </span><span class="Comment">//:   often to add new kinds of automatic checking for our machine code</span>
+<span id="L24" class="LineNr">24 </span><span class="Comment">//:   programs.</span>
+<span id="L25" class="LineNr">25 </span><span class="Comment">//:</span>
+<span id="L26" class="LineNr">26 </span><span class="Comment">//: Putting these constraints together, we'll use the following broad</span>
+<span id="L27" class="LineNr">27 </span><span class="Comment">//: organization:</span>
+<span id="L28" class="LineNr">28 </span><span class="Comment">//:</span>
+<span id="L29" class="LineNr">29 </span><span class="Comment">//:   a) We'll divide up our transforms into &quot;levels&quot;, each level consisting</span>
+<span id="L30" class="LineNr">30 </span><span class="Comment">//:   of multiple transforms, and dealing in some new set of representational</span>
+<span id="L31" class="LineNr">31 </span><span class="Comment">//:   ideas. Levels will be added in reverse order to the one their transforms</span>
+<span id="L32" class="LineNr">32 </span><span class="Comment">//:   will be run in.</span>
+<span id="L33" class="LineNr">33 </span><span class="Comment">//:</span>
+<span id="L34" class="LineNr">34 </span><span class="Comment">//:     To run all transforms:</span>
+<span id="L35" class="LineNr">35 </span><span class="Comment">//:       Load transforms for level n</span>
+<span id="L36" class="LineNr">36 </span><span class="Comment">//:       Load transforms for level n-1</span>
+<span id="L37" class="LineNr">37 </span><span class="Comment">//:       ...</span>
+<span id="L38" class="LineNr">38 </span><span class="Comment">//:       Load transforms for level 2</span>
+<span id="L39" class="LineNr">39 </span><span class="Comment">//:       Run code at level 1</span>
+<span id="L40" class="LineNr">40 </span><span class="Comment">//:</span>
+<span id="L41" class="LineNr">41 </span><span class="Comment">//:   b) *Within* a level we'll usually introduce transforms in the order</span>
+<span id="L42" class="LineNr">42 </span><span class="Comment">//:   they're run in.</span>
+<span id="L43" class="LineNr">43 </span><span class="Comment">//:</span>
+<span id="L44" class="LineNr">44 </span><span class="Comment">//:     To run transforms for level n:</span>
+<span id="L45" class="LineNr">45 </span><span class="Comment">//:       Perform transform of layer l</span>
+<span id="L46" class="LineNr">46 </span><span class="Comment">//:       Perform transform of layer l+1</span>
+<span id="L47" class="LineNr">47 </span><span class="Comment">//:       ...</span>
+<span id="L48" class="LineNr">48 </span><span class="Comment">//:</span>
+<span id="L49" class="LineNr">49 </span><span class="Comment">//:   c) Within a level it's often most natural to introduce a new</span>
+<span id="L50" class="LineNr">50 </span><span class="Comment">//:   representation by showing how it's transformed to the level below. To</span>
+<span id="L51" class="LineNr">51 </span><span class="Comment">//:   make such exceptions more obvious checks usually won't be first-class</span>
+<span id="L52" class="LineNr">52 </span><span class="Comment">//:   transforms; instead code that keeps the program unmodified will run</span>
+<span id="L53" class="LineNr">53 </span><span class="Comment">//:   within transforms before they mutate the program.</span>
+<span id="L54" class="LineNr">54 </span><span class="Comment">//:</span>
+<span id="L55" class="LineNr">55 </span><span class="Comment">//:     Level l transforms programs</span>
+<span id="L56" class="LineNr">56 </span><span class="Comment">//:     Level l+1 inserts checks to run *before* the transform of level l runs</span>
+<span id="L57" class="LineNr">57 </span><span class="Comment">//:</span>
+<span id="L58" class="LineNr">58 </span><span class="Comment">//: This may all seem abstract, but will hopefully make sense over time. The</span>
+<span id="L59" class="LineNr">59 </span><span class="Comment">//: goals are basically to always have a working program after any layer, to</span>
+<span id="L60" class="LineNr">60 </span><span class="Comment">//: have the order of layers make narrative sense, and to order transforms</span>
+<span id="L61" class="LineNr">61 </span><span class="Comment">//: correctly at runtime.</span>
+<span id="L62" class="LineNr">62 </span>
+<span id="L63" class="LineNr">63 </span><span class="Delimiter">:(before &quot;End One-time Setup&quot;)</span>
+<span id="L64" class="LineNr">64 </span><span class="Comment">// Begin Transforms</span>
+<span id="L65" class="LineNr">65 </span><span class="Comment">// End Transforms</span>
+</pre>
+</body>
+</html>
+<!-- vim: set foldmethod=manual : -->
kartik/mu/blame/cpp/018record?h=hlt&id=d265f2bd75bb193573931418288bbd031baa8705'>^
bc643692 ^


afa42503 ^
f608504a ^


0487a30e ^
5497090a ^
0487a30e ^


bc643692 ^





afa42503 ^
0487a30e ^


051c4738 ^
0487a30e ^
bc643692 ^





afa42503 ^
0487a30e ^


c6034af3 ^





72d5d018 ^
69f3fb0a ^
ac0e9db5 ^

6152ef13 ^
c6034af3 ^
5f98a10c ^
054e1b3c ^

e6f84542 ^
0487a30e ^
f608504a ^



9edabeaa ^




086acf39 ^
9edabeaa ^


7284d503 ^
88be3dbc ^
f608504a ^
bc643692 ^

afa42503 ^
f608504a ^
f608504a ^

1848b18f ^

916ae8f5 ^
363be37f ^
900e6a0e ^
916ae8f5 ^
900e6a0e ^
5f98a10c ^
900e6a0e ^



72d5d018 ^
5f98a10c ^
900e6a0e ^

c6034af3 ^
900e6a0e ^

5f98a10c ^
054e1b3c ^

af7a5722 ^
900e6a0e ^
af7a5722 ^
900e6a0e ^
5f98a10c ^
900e6a0e ^


af7a5722 ^





c6034af3 ^
af7a5722 ^
5f98a10c ^
fb85b3b4 ^
af7a5722 ^
900e6a0e ^



0487a30e ^
900e6a0e ^
ac0e9db5 ^
18e626df ^
5f98a10c ^
18e626df ^

c6034af3 ^
ac0e9db5 ^
2142ccfc ^
ac0e9db5 ^

50b48db0 ^
0487a30e ^
6cc46216 ^
cdd6fd09 ^
c6034af3 ^
cdd6fd09 ^
e853b94e ^
827898fc ^
c6034af3 ^
cfb142b9 ^
916ae8f5 ^


88be3dbc ^
6cc46216 ^
bc643692 ^


afa42503 ^
6cc46216 ^
57699011 ^
6cc46216 ^
551d155c ^
5f98a10c ^
551d155c ^
bc643692 ^


551d155c ^

5f98a10c ^
551d155c ^
051c4738 ^
5f98a10c ^
551d155c ^
bc643692 ^


551d155c ^

5f98a10c ^
551d155c ^
af7a5722 ^
5f98a10c ^
af7a5722 ^





5f98a10c ^
af7a5722 ^
c6034af3 ^









1848b18f ^

a4559f72 ^
363be37f ^
900e6a0e ^
a4559f72 ^
900e6a0e ^
5f98a10c ^
18e626df ^

900e6a0e ^

72d5d018 ^
5f98a10c ^
9a14c914 ^

c6034af3 ^
900e6a0e ^

5f98a10c ^
9a14c914 ^

fb5470bc ^
900e6a0e ^
fb5470bc ^
900e6a0e ^
5f98a10c ^
900e6a0e ^


fb5470bc ^



29057ed9 ^
fb5470bc ^
c6034af3 ^



fb5470bc ^
5f98a10c ^
fb85b3b4 ^
fb5470bc ^
900e6a0e ^







5f98a10c ^
551d155c ^

c6034af3 ^
900e6a0e ^
2142ccfc ^
ac0e9db5 ^

50b48db0 ^
0487a30e ^
79f4349c ^
cdd6fd09 ^
cfb142b9 ^
827898fc ^
a4559f72 ^

b98d3876 ^
551d155c ^
5f98a10c ^
551d155c ^
bc643692 ^


551d155c ^

5f98a10c ^
551d155c ^
051c4738 ^
5f98a10c ^
551d155c ^
bc643692 ^


551d155c ^

5f98a10c ^
551d155c ^
fb5470bc ^
5f98a10c ^
fb5470bc ^





6808ff7d ^
fb5470bc ^
b98d3876 ^







dd2e01e4 ^
d65bc172 ^



b98d3876 ^
56109c6d ^









dd2e01e4 ^
56109c6d ^




dd2e01e4 ^
56109c6d ^

b98d3876 ^

72d5d018 ^
b98d3876 ^





e3cb4d09 ^
dd2e01e4 ^
363be37f ^


b98d3876 ^
dd2e01e4 ^
b98d3876 ^
e6f84542 ^
363be37f ^
e6f84542 ^

b98d3876 ^



e6f84542 ^
b98d3876 ^
e6f84542 ^
dd2e01e4 ^
c6034af3 ^
12b51f36 ^
b98d3876 ^
e6f84542 ^
c6520d96 ^


363be37f ^
6152ef13 ^
c6034af3 ^
dd2e01e4 ^
b98d3876 ^
c6034af3 ^
b98d3876 ^
e6f84542 ^

b98d3876 ^

141c540b ^


5f98a10c ^
141c540b ^

1ccbf385 ^












5d1699c2 ^

1ccbf385 ^



b98d3876 ^

363be37f ^
b98d3876 ^


ac0e9db5 ^
363be37f ^
c6034af3 ^



b98d3876 ^


6152ef13 ^
363be37f ^


6152ef13 ^

363be37f ^
6152ef13 ^



363be37f ^
6152ef13 ^

b98d3876 ^

363be37f ^
b98d3876 ^
363be37f ^
b98d3876 ^
363be37f ^
b98d3876 ^
5f98a10c ^

6152ef13 ^
5f98a10c ^

6152ef13 ^

bc643692 ^
6152ef13 ^
c6034af3 ^
6152ef13 ^

5f98a10c ^
6152ef13 ^
a0fc38c9 ^
6152ef13 ^




5f98a10c ^

6152ef13 ^




363be37f ^
6152ef13 ^


c6034af3 ^
6152ef13 ^

c6034af3 ^
6152ef13 ^



c6034af3 ^

e3cb4d09 ^
c6034af3 ^

6152ef13 ^
c6034af3 ^

6152ef13 ^


5f98a10c ^
6152ef13 ^



c6034af3 ^
6152ef13 ^
23fd54f1 ^





dd2e01e4 ^
d65bc172 ^



23fd54f1 ^
0d9d2753 ^
6152ef13 ^



363be37f ^
6152ef13 ^
6152ef13 ^
c6034af3 ^
6152ef13 ^



02a55f71 ^




363be37f ^
2142ccfc ^



02a55f71 ^















bc643692 ^
02a55f71 ^


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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595