RegisterTest doesn't allow using sp
GoogleCodeExporter opened this issue · comments
Hi Markus!
Your OperatorsMarkusTest#RegisterTest doesn't allow me to read the
StackPointer. Is that intentional? I don't see any issue with that...
Failure message:
Error in RegisterTest (Subtest 3)
You use registers you aren't allowed to use: addiu $sp $t0 0
You might only use $v0, $v1 and $t0-$t9.
Original issue reported on code.google.com by felix@familie-freiberger.net
on 27 Jul 2012 at 2:20
You don't need to use the stack pointer in this example. The expression
requires only 10 registers to be evaluated, and cause it's an expression, you
don't need a function body or anything similar that needs the stack pointer. So
what do you want to do with the stack pointer?
In your example, addiu $sp $t0 0 looks like a move $sp $t0, so you're trying to
write $sp. I guess $t0 is used for expression evaluation, so I don't think it's
a good idea to overwrite the stack pointer with that.
I think you need the stack pointer only in two cases: building/removing a
function frame (not needed here) and maybe for expressions that are too large
to evaluate in 12 registers, what isn't the case here.
Maybe you have an error in your register management, so your code needs more
registers than needed and trys to swap that on the stack? I had a similar
mistake too. Make sure you always evaluate the bigger subtree first.
Original comment by rothe...@gmx.de
on 27 Jul 2012 at 4:38
I certainly don't need to read the stack pointer for that expression, but it is
allowed, so your test shouldn't fail.
> addiu $sp $t0 0 looks like a move $sp $t0
I suspect that the arguments are in the wrong order here. I definitely have
some commands "addiu $t0 $so 0" in my code, but these only read the stack
pointer.
I read the stack pointer because, for simplicity, I *always* use the stack to
evaluate expressions, so I don't have to add a special handling for expressions
needing more registers than available.
Original comment by felix@familie-freiberger.net
on 27 Jul 2012 at 5:11
I don't really know if it's allowed, the documentation says you should only use
the registers $v0-$vv1, $t0-$t9 for expression evaluation. Perhaps we should
ask Tobias if it's allowed.
Another problem might be located in the LocalVariable class: loading a variable
from the stack depends on the stack pointer, so if you change it, you'll load
values from wrong points:
asm.lw(target, Reg.sp, offset());
From this point, I suggest not allowing $sp because it results in a lot of hard
to find errors. But if somebody is in the mood rewriting the LocalVariable
class (or resetting the stack pointer before every variable load) we could
maybe warn him instead of failing the test.
Original comment by rothe...@gmx.de
on 27 Jul 2012 at 6:39
I don't "use" (write to) the stack pointer, I just read it.
That's also the reason why I don't get any problems with the LocalVariables.
Am 27.07.2012 um 20:39 schrieb "prog2tests@googlecode.com"
<prog2tests@googlecode.com>:
Original comment by felix@familie-freiberger.net
on 27 Jul 2012 at 6:44
Ok, in this case I suggest we allow $sp and write a warning in the console not
to write it. I'll update my testfile within the next hour.
I also posted the question in the forum, maybe we'll get a definite answer.
https://forum.st.cs.uni-saarland.de/boards/viewthread?thread=1576
Original comment by rothe...@gmx.de
on 27 Jul 2012 at 6:59
OK, that sounds reasonable. Thank you!
Am 27.07.2012 um 21:00 schrieb "prog2tests@googlecode.com"
<prog2tests@googlecode.com>:
Original comment by felix@familie-freiberger.net
on 27 Jul 2012 at 7:03
Ok here's the updated version. Only fails if you're writing $sp (with
additional message). Version is 1.2
As usual, please no code reformator :D
Original comment by rothe...@gmx.de
on 27 Jul 2012 at 7:18
Attachments:
Thank you! I pushed your update.
I'll leave that open until we get a reply from Tobias.
Original comment by felix@familie-freiberger.net
on 27 Jul 2012 at 7:24
- Changed state: Accepted
Tobias replied here:
https://forum.st.cs.uni-saarland.de/boards/viewthread?thread=1576
I'll close the issue now. Thank you for the update!
Original comment by felix@familie-freiberger.net
on 27 Jul 2012 at 7:45
- Changed state: Fixed