notes.txt (2150B)
1 2 Tracking Source Location 3 ------------------------ 4 LLVM Source Location is u32 5 - "sourcemanager" assigns files into global offset space 6 - high bit == macro expansion (separate space) 7 - 0 = invalid (errors not related to source like command line options) 8 9 10 Register Allocation 11 ------------------- 12 aho 2e pdf p565 8.5 -- a simple code generator 13 mogensen 2017 p130 -- simple IR 14 15 Register Spilling and Live-Range Splitting for SSA-Form Programs 16 Braun / Hack 2009 17 - adapts furtherst-first algo to ssa use, no coloring needed 18 19 Phys vs Virt Registers 20 ---------------------- 21 mogensen 2017 / 8.6.2 (p198pdf) 22 - phys regs can be used "pre-colored" for instructions with 23 limitations, func call params, etc 24 - "live range splitting" by inserting moves from colorless to pre-colored regs 25 26 cmu compilers class 2018 / register selection lecture 27 - similar comments re: special instructions, func calls, etc 28 29 30 Live Analysis 31 ------------- 32 torczon 2012 8.6.1 finding uninit vars w/ live info (p470pdf) 33 LiveOut / UEVar / VarKill iterative method 34 35 mogenson 2017 8.2 liveness analysis (p188pdf) 36 37 cmu compilers 2018 - 05-liveness-analysis.pdf 38 39 40 Constant Folding 41 ---------------- 42 simple constant folding 43 44 * -> C(C1*C2) 45 / \ 46 C1 C2 47 48 more complex const folding (various algebraic transforms, etc) 49 50 * -> * 51 / \ / \ 52 C1 * V1 C(C1*C2) 53 / \ 54 V1 C2 55 56 57 Assorted Resources 58 ------------------ 59 https://groups.seas.harvard.edu/courses/cs153/2019fa/schedule.html 60 https://blog.yossarian.net/2020/10/23/Understanding-static-single-assignment-forms 61 https://lowlevelbits.org/how-to-learn-compilers-llvm-edition/ 62 63 Tiny Scheme / 5k repl 64 --------------------- 65 http://www.iro.umontreal.ca/~feeley/papers/YvonFeeleyVMIL21.pdf 66 https://github.com/udem-dlteam/ribbit 67 68 69 Code Snippets 70 ------------- 71 72 int fib(int n) { 73 int a = 0; 74 int b = 1; 75 int z = 0; 76 while (n != z) { 77 int t = a + b; 78 a = b; 79 b = t; 80 n = n - 1; 81 z = 0; 82 } 83 return a; 84 } 85 86 int gcd(int x1, int x2) { 87 while (x2 != 0) { 88 int q = x1 / x2; 89 int t = q * x2; 90 int r = x1 - t; 91 x1 = x2; 92 x2 = r; 93 } 94 return x1; 95 } 96