4 ms·
in my (incredibly limited) experience, a fairly naive approach works ok. mips has lots of registers. for my C compiler, leave the arguments in a register. 5 arg
by jfoutz 11y ago
in my (incredibly limited) experience, a fairly naive approach works ok. mips has lots of registers. for my C compiler, leave the arguments in a register. 5 args, 5 registers. pretend the next n registers are the top of the stack, 5 - 32 = 27, each variable gets it's own register, just pretend the 27 available registers are simply the top of the stack. when var 28 comes along, it becomes complicated, you have to fool around with saving something to memory. but really, that's pretty rare.
the obvious penalty is the push/pop pair around each function call. as a first optimization pass, skip the pop when the pushed values aren't used - if a register isn't touched, you can get away with this. it's damn fast, because the push can rely on l1 cache. there's no stall when the processor promises to write that out eventually. you don't care till you need to do the corresponding pop. i had plans to skip the push , depending on usage, but didn't quite get that far.
anyway, the point is, just using registers as the top of the stack can get pretty good results with just a few man-months of effort.