Skip to content

Common Stack Automaton Should be faster - Peephole optimization #112

@kamil-adam

Description

@kamil-adam

Each test should take less than one second :D

Peephole optimization - Basic optimizations:

  • Optimize ALU instructions
    • Constant folding and propagation - Evaluate operations
    • Instruction selection:
      • Optimize Halibut and Pick instructions
      • Optimize Mul for ETA
      • Use static, not dynamic
      • 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
    • Optimize Transfer instruction
    • Optimize jump for WS
    • Replace dynamic jumps with static ones
    • Find unconditional jumps
    • 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
    • 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
  • 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
  • Add method to create option structures in AppOptions
  • Change name to MemoryOptions for AutoOptions
  • Split Unit to:
    • Combiner
    • Memory

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions