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

MOVZ/MOVN does not gives correct code. #36

Open
nihilus opened this issue Sep 14, 2015 · 14 comments
Open

MOVZ/MOVN does not gives correct code. #36

nihilus opened this issue Sep 14, 2015 · 14 comments
Assignees

Comments

@nihilus
Copy link
Owner

nihilus commented Sep 14, 2015

@hlide any clues why this is so?

@nihilus nihilus self-assigned this Sep 14, 2015
@hlide
Copy link

hlide commented Sep 14, 2015

did you fix the issue?

@nihilus
Copy link
Owner Author

nihilus commented Sep 14, 2015

No... :-( I am going to bed now.

@hlide
Copy link

hlide commented Sep 15, 2015

Ok, can you elaborate what the issue is exactly and in which context (for instance, MOVZ/N are systematically wrong or just inside a delay slot? etc.).

@nihilus
Copy link
Owner Author

nihilus commented Sep 15, 2015

The statements does not generate the move function. So it is generally broken. And in a delayslot after a JR it will not generate the statement before the JR but in a separate function.

@nihilus
Copy link
Owner Author

nihilus commented Sep 17, 2015

403dbc: jalr $t9
403dc0: movn $a0, $a3, $v0

gives the following 'extra function':

void fun_403dc0() {
    int32_t v0_1;

    if (!v0_1) 
        goto "???";
}

@nihilus
Copy link
Owner Author

nihilus commented Sep 17, 2015

403604: move $v1, $zero
403608: addiu $v1, $zero, 2
40360c: addiu $v0, $zero, 1
403610: movz $v1, $v0, $a0
403614: jr $ra

just generates the return-statement.

@hlide
Copy link

hlide commented Sep 17, 2015

snowman tends to discard a lot of values in a function.

I think snowman doesn't understand movn is setting the first function argument (a0) conditionally BEFORE calling the function given in t9 in:

403dbc: jalr $t9
403dc0: movn $a0, $a3, $v0

that is,

if (v0) t9(a0 = a3); else t9(a0);

-->

if (v0) t9(a3); else t9(a0);

and we have a similar issue but with return value being a 64-bit integer (v1:v0), the v1 of which is also set conditionally BEFORE the return. It should have been:

v1 = 2; v0 = 1; if (a0) return LLONG(v1,v0); else LLONG((v1 = v0),v0);

-->

if (a0) return 0x000000200000001ULL; else return 0x0000000100000001ULL;

@nihilus
Copy link
Owner Author

nihilus commented Sep 17, 2015

@hlide that's why I implemented addNonVolatileRegister() :-) Then it won't discard so those registers.

@nihilus
Copy link
Owner Author

nihilus commented Sep 17, 2015

I guess part of the problem is for fixing when it is a delay slot.

@nihilus
Copy link
Owner Author

nihilus commented Sep 17, 2015

@hlide I can see the logic is correct however if you wanna try this I suggest you use 'tuxera.bench' (BE MIPS-I)

@nihilus
Copy link
Owner Author

nihilus commented Sep 20, 2015

I improved the code generation in 8be261d

@nihilus nihilus closed this as completed Sep 20, 2015
@nihilus
Copy link
Owner Author

nihilus commented Sep 20, 2015

@hlide actually when there is a jump statement in the delay slot like having MOVN/MOVZ in a delay slot, the generated code will not come before the branching but in a separate function. Any clues? This is not specific for MOVN/MOVZ but for jumps to a 'MipsExpressionFactoryCallback'

@nihilus nihilus reopened this Sep 20, 2015
@hlide
Copy link

hlide commented Sep 21, 2015

There were a long discussion in a topic about that and how to fix the issue with two contiguous jumps in a block. A solution was found and applied in my snowman repository. I thought it was fixed once for all.

@nihilus
Copy link
Owner Author

nihilus commented Sep 21, 2015

@hlide: I'll try to find a MIPS-LE file for using with Allegrex.

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

No branches or pull requests

2 participants