Skip to content
This repository has been archived by the owner on Oct 5, 2019. It is now read-only.

Milestone: Fibonacci function #3

Closed
sunfishcode opened this issue Nov 8, 2018 · 1 comment · Fixed by #7
Closed

Milestone: Fibonacci function #3

sunfishcode opened this issue Nov 8, 2018 · 1 comment · Fixed by #7

Comments

@sunfishcode
Copy link
Member

Recursive Fibonacci is a nice next milestone because it needs some control flow operators and calls, which should really help establish the shape of the backend.

The steps are:

  • Implement if+else+end.
    • We'll need a stack for tracking nested control flow constructs. To start with there's only one kind of control-flow stack entry, for if/else/end, but eventually we'll have more. It can hold DynamicLables to keep track of the labels for branching.
    • The result value of an if can be carried by the stack just like normal operator results. (For now; later with on-the-fly register allocation it can be more sophisticated.)
  • Implement calls
    • This is a good time to generalize the handling of function signatures. I think we can just collect all the FuncTypes from the type section into a Vec and pass that around for now.
    • Optionally, to keep things simple for this step, we could limit support to just 6 integer arguments, to avoid having to deal with stack arguments just yet.

I've left out a lot of the low-level details here; feel free to ask for more detail!

@pepyakin
Copy link
Collaborator

I will work on that!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants