JKTKops / JKTKops/cspim

Fix allocation for function arguments

Open
#1 6 comments 0 reactions 0 assignees View on GitHub
bug good first issue question
Dominant language
Haskell
Stars
5
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Currently function arguments are always placed as though they need 1 word, but this is obviously not always the case. This should be fixed. (edit: TODO comments are in src/Parser/Parser.hs)

Some considerations:
gcc (on -O0) sets up doubles to be passed via $f registers if they would've fit into $a registers, but then doesn't use the $a registers. For example, `(double d1, int a, double d2)` will pass d1 through $f12-13, a through $a2, and d2 on the stack.

That's certainly doable but this and similar optimizations could complicate interfacing with C code by hand for SpimBot.

I'm inclined to include an extra structure in the `Function` type that describes how to pass the arguments. This would effectively duplicate some of the information in the allocation table and would need to be kept in sync. _But_ it removes the implicit "pass them in the same order as the `args` list" and opens up the door to optimizing argument passing later, such that frequently-used arguments are passed via registers to begin with. Additionally, by including this table in a comment on the MIPS output, we can probably maintain the ability to manually interface with our C code for SpimBot.

@dchammond I'm still learning how to properly manage big projects (I plan to continue working on this after SpimBot and maybe get it to target x86) but I've seen other people use issues like this to track TODOs, especially when they don't know how to resolve them. Feel free to comment if you have thoughts :)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.