-[Overal course goals and learning outcomes.](#overal-course-goals-and-learning-outcomes)
-[Overal course goals and learning outcomes.](#overal-course-goals-and-learning-outcomes)
## Your repo
## Your repo
...
@@ -231,7 +232,7 @@ fn main() {
...
@@ -231,7 +232,7 @@ fn main() {
test();
test();
}
}
```
```
The function call moves the current state, $σ$ to the new derived state $σ'$ in the function, test()'s context. A function can evaluate void (none), i32 and bool.
The function call moves the current state, σ to the new derived state σ' in the function, test()'s context. A function can evaluate void (none), i32 and bool.
### Command sequence
### Command sequence
```math
```math
...
@@ -242,7 +243,7 @@ The function call moves the current state, $σ$ to the new derived state $σ'$ i
...
@@ -242,7 +243,7 @@ The function call moves the current state, $σ$ to the new derived state $σ'$ i
letx:i32=2;
letx:i32=2;
test();
test();
```
```
A sequence is a composition of commands where the first command is first executed then the second command. Otherwise the intermediate step, $σ'$ would be lost.
A sequence is a composition of commands where the first command is first executed then the second command. Otherwise the intermediate step, σ' would be lost.
### Operands for arithmetic expressions
### Operands for arithmetic expressions
```math
```math
...
@@ -322,7 +323,7 @@ let a : i32 = 1;
...
@@ -322,7 +323,7 @@ let a : i32 = 1;
letb:bool=true;
letb:bool=true;
letc:i32=test();// c will be assigned whaterver test() returns
letc:i32=test();// c will be assigned whaterver test() returns
```
```
For let commands, if the variable is already declared the state $σ$ will be changed to the one of the second command, state $σ'$, the variable will be lost. Otherwise the variable will be assigned to the state, $σ$.
For let commands, if the variable is already declared the state σ will be changed to the one of the second command, state σ', the variable will be lost. Otherwise the variable will be assigned to the state, σ.
### Assignment
### Assignment
```math
```math
...
@@ -570,12 +571,97 @@ The end goal of the borrow checker is to prevent data-racing. Data-racing is whe
...
@@ -570,12 +571,97 @@ The end goal of the borrow checker is to prevent data-racing. Data-racing is whe
## Your LLVM backend
## Your LLVM backend
- Let your backend produces LLVM-IR for your example program.
- Let your backend produces LLVM-IR for your example program.
-Describe where and why you introduced allocations and phi nodes.
-Allocation are done to store a variable on the stack, such that LLVM later can access the variable in the memory using given pointer. This is done when storing parameters, arguments, variables etc.
- If you have added optimization passes and/or attributed your code for better optimization (using e.g., `noalias`).
- Phi nodes are supposed to be used in if and while statements in my implementation. Because of the way I have built the block functionality it gave me a headech to change at this late of a stage- Therefor I will explain phi nodes. They way I interpreted them!
- Phi nodes are used to handle different blocks in e.g. a if block. There are two blocks and because SSA (Static single assignment) a variable cannot be assigned more than once.
- Compare your solution to the requirements (as stated in the README.md). What are your contributions to the implementation.
```rust
if...{
a.0=1;
}else{
a.1=2;
}
...
```
Since LLVM uses the variable with highest index, in the example above a.1 = 2. What if the condition were true? Then we want a.0 = 1! This is the problem with SSA in LLVM and therefor phi nodes are used e.g.
```rust
if...{
phi.if_block
}else{
phi.else_block
}
phi.cont_block
...
```
### Comparison
- No PassManager has been used or other optimization, except some [#inline] somewere and verify.
- LLVM is a good wrapper to the course as I will talk more about but I have been introduced to
- SSA form, it's hiccups and how we bypass them
- The concept of unique I would like to discuss
- LLVM optimization as the example of PassManager, verify, more to e discovered...
- By using the It's a New Kind of Wrapper for Exposing LLVM (safely) I have been introduced to some LLVM-API during implementation.
## Overal course goals and learning outcomes.
## Overal course goals and learning outcomes.
...
@@ -591,7 +677,7 @@ The end goal of the borrow checker is to prevent data-racing. Data-racing is whe
...
@@ -591,7 +677,7 @@ The end goal of the borrow checker is to prevent data-racing. Data-racing is whe
- At this point I excpect the interpreter not to fail.
- At this point I excpect the interpreter not to fail.
- LLVM
- LLVM
- This is the last step of my compiler, now we are generating actual machine code. It has linked this course with microcomputing which I feel has been rewarding. To think more of e.g. how boolean are represented in machine code. To grasp LLVM you could have a seperate course but it wraps up the comiler you have written and produce something useful.
- This is the last step of my compiler, now we are generating actual machine code. It has linked this course with microcomputing which I feel has been rewarding. To think more of e.g. how boolean are represented in machine code and the problems surrounding SSA form. To grasp LLVM you could have had a seperate course but it wraps up the compiler you have written and produce during the course to something useful.
Comment on additional things that you have experienced and learned throughout the course.
Comment on additional things that you have experienced and learned throughout the course.