Common Stack Automaton Should be faster - Peephole optimization
- Dominant language
- Haskell
- Stars
- 16
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Each test should take less than one second :D
**Peephole optimization** - Basic optimizations:
* [ ] Optimize ALU instructions
* [x] **Constant folding and propagation** - Evaluate operations
* [ ] **Instruction selection**:
* [x] Optimize Halibut and Pick instructions
* [ ] Optimize Mul for ETA
* [ ] Use static, not dynamic
* [x] Use immediate instructions
* [ ] Use direct (offset) instructions
* [ ] Use immediate and copy instruction. First operand is immediate , second operand is copy, but index is immediate. For example `subIC 1 0`
* [ ] Add immediate output. For example `outputI value`
* [ ] Optimize `outputDec`
* [ ] Multi const. For example `constM [0, 1, 2, 3, 4, 5]`. 5 is the deepest
* [ ] `dec` and `inc` for address. They have normalize for 0x1000000 or other max value
* [ ] Optimize Load-Store instruction
* [ ] Add `storeID imedateValue directedAddress`
* [ ] Optimize Control Flow instructions
* [x] Optimize Transfer instruction
* [ ] Optimize jump for WS
* [x] Replace dynamic jumps with static ones
* [x] Find unconditional jumps
* [x] **Dead-code elimination** - Remove dead code after unconditional jumps
* [ ] Remove jumps to jumps
* [ ] Remove redundant labels
* [ ] only for static labels
* [ ] dynamic labels only for addresses, not for normal value. It is agresive optimalization
* [ ] Split numbers and addresses. Generate labels only for addresses
* [x] Add reversed jump. tJump with reversed operands
* [ ] Add soft call `callS label returnAddress`. It is simple join to instructuins `const returnAddress; jump label`, but it is important for debug
* [ ] Add `bNEI label value`. It is short for `sub value; bNZI label`
* [ ] Remove sequence `jumpA address; markA address;`
* [ ] R&D - Create statistics from the frequency of instruction pairs, and more
----
Advanced optimizations (they should be in other tickets):
* [ ] Build Basic Blocks
* [ ] Integrate with LLVM or generate LLVM code
----
Refactors and enhancements for basic optimizations:
* [ ] Use Dhall for writing all optimizations
* [ ] Split pattern Matching to [Alternatives](https://hackage.haskell.org/package/base-4.18.0.0/docs/Control-Applicative.html#g:2)
* [ ] Refactor immediate and direct jumps
* [ ] Add direct instructions (Now we have direct instruction only for 0 offset)
* [ ] Add immediate instructions (Now we have only direct instructions)
* [ ] Add TypeClass for memory like HasStack HasRam HasCM
* [x] Add method to create option structures in AppOptions
* [x] Change name to MemoryOptions for AutoOptions
* [x] Split Unit to:
* Combiner
* Memory
Contributor guide
Assessment
This issue has not been assessed yet.