Website Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit6cb81338a50fb5bde467e6d62b6e43473a2e27bf (patch)
Author
 Dimitar Trendafilov <dimitar@coherent-labs.com>
2018-10-03 22:55:51 +0300
Committer
 Dimitar Trendafilov <dimitar@coherent-labs.com>
2018-10-03 22:55:51 +0300
Files4a221236733ee7c1bf2f0a91732bf3471223c202
IPL-6cb81338a50fb5bde467e6d62b6e43473a2e27bf.tar
IPL-6cb81338a50fb5bde467e6d62b6e43473a2e27bf.tar.gz
IPL-6cb81338a50fb5bde467e6d62b6e43473a2e27bf.zip
Parentc7e758cb7d1de6d5aced26aa0b9527639e7411cd (diff)
polish for the introductin slides
1 files changed, 45 insertions, 10 deletions
-rw-r--r--website/content/slides/01_dragons/_index.md55
diff --git a/website/content/slides/01_dragons/_index.md b/website/content/slides/01_dragons/_index.md
index b311f65..b1dfd0c 100644
--- a/website/content/slides/01_dragons/_index.md
+++ b/website/content/slides/01_dragons/_index.md
@@ -1,7 +1,7 @@
---
title: "The dragons"
date: 2018-08-02T17:45:53+03:00
-draft: true
+draft: false
outputs: ["Reveal"]
---
# The dragons
@@ -73,8 +73,8 @@ Three-stage compiler structure
1. Front end
- understands the program
-2. Middle end
- - does the optimizations
+2. Middle
+ - does the optimizations and removes syntactic sugar
3. Back end
- generates the machine code
@@ -200,7 +200,7 @@ LR(n) and LALR(n) are family of parsing algorithms for CFG
# TODO: use JavaScript AST dumper
---
-### Middle end
+### Middle
Takes the AST and transforms that to some *Intermediate Representation* (IR)
that is convinient for:
@@ -211,14 +211,29 @@ that is convinient for:
---
### IR
-- Static Single Assignment form
+- A compiler might have different levels and types of IR
+ - text and binary
+- [Static Single Assignment form](https://en.wikipedia.org/wiki/Static_single_assignment_form)
-# TODO: expand
+---
+### IR in LLVM - C
+
+ int mul_add(int x, int y, int z) {
+ return x * y + z;
+ }
---
-### IR in LLVM
+### IR in LLVM - IR
+
+ define i32 @mul_add(i32 %x, i32 %y, i32 %z) {
+ entry:
+ %tmp = mul i32 %x, %y
+ %tmp2 = add i32 %tmp, %z
+ ret i32 %tmp2
+ }
+---
+###
-# TODO: find a clang AST dumper
---
### Back end
@@ -226,13 +241,24 @@ that is convinient for:
> Takes the IR and produces native code for a particular machine
---
-## Interperter
+## Interpreter
> Like the compiler, but instead of producing machine code, executes the program
> instruction by instruction translating from program instructions to machine
> instructions.
---
+## Interpreter
+
+- Most interpreters have a REPL which makes them great for experiments.
+- You don't need build an executable to run your program
+
+---
+### Compiler vs Interpreter
+
+- https://www.youtube.com/watch?v=_C5AHaS1mOA
+
+---
### AOT compilation
- Ahead of Time - the program is compiled before it is being run
@@ -281,12 +307,21 @@ collection and most of the standard library of the language.
### VMs
- stack based
+ - all computations are done with operands pushed onto a stack, then popped
+ and the result is pushed back
+ - simple, but inefficient
- register based
+ - some of the computations are using registers (generally each local
+ variable gets a register)
+ - code generation is a bit harder, but the machine is more efficient
---
### RPN as an interperter
-# TODO: expand
+Calculating an expression using postfix notation is actually an interpreter for
+expressions.
+
+- Forth is a complete programming language based on that.
---
## What is a machine?