Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common Stack Automaton Should be faster - Peephole optimization #112

Open
11 of 42 tasks
kamil-adam opened this issue Feb 15, 2023 · 0 comments
Open
11 of 42 tasks

Common Stack Automaton Should be faster - Peephole optimization #112

kamil-adam opened this issue Feb 15, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@kamil-adam
Copy link
Contributor

kamil-adam commented Feb 15, 2023

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
@kamil-adam kamil-adam added the bug Something isn't working label Feb 15, 2023
@kamil-adam kamil-adam added this to the 2. Word Automata milestone Feb 15, 2023
@kamil-adam kamil-adam self-assigned this Feb 15, 2023
@kamil-adam kamil-adam pinned this issue Feb 15, 2023
@kamil-adam kamil-adam changed the title Common Stack Automaton Should be faster Common Stack Automaton Should be faster - Peephole optimization Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants