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

[RyuJIT] Refactor the codegen/emitter for MOVD/MODQ #9973

Closed
fiigii opened this issue Mar 19, 2018 · 4 comments
Closed

[RyuJIT] Refactor the codegen/emitter for MOVD/MODQ #9973

fiigii opened this issue Mar 19, 2018 · 4 comments

Comments

@fiigii
Copy link
Contributor

fiigii commented Mar 19, 2018

The codegen/emitter of MOVD/MODQ is very messy in the current backend.
It has several "instructions" to generate MOVD/MODQ (e.g., mov_i2xmm, mov_xmm2i, movd, and movd), but the codegen is not consistent.
For example, mov_i2xmm can generate MOVD and MOVQ based on different emit-size, but it just accepts some of the valid sizes.

INST3( mov_i2xmm,   "movd"        , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE, PCKDBL(0x6E)) 
INST3( mov_xmm2i,   "movd"        , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE, PCKDBL(0x7E)) 
INST3( movd,        "movd"        , 0, IUM_WR, 0, 0, PCKDBL(0x7E), BAD_CODE, PCKDBL(0x6E))
INST3( movq,        "movq"        , 0, IUM_WR, 0, 0, PCKDBL(0xD6), BAD_CODE, SSEFLT(0x7E))

cc @CarolEidt @tannergooding

@mikedn
Copy link
Contributor

mikedn commented Mar 19, 2018

For example, mov_i2xmm can generate MOVD and MOVQ based on different emit-size, but it just accepts some of the valid sizes.

What do you mean? It sounds like a contradiction, either it can generate based on different emit-size or it can't because there are only 2 valid sizes.

@fiigii
Copy link
Contributor Author

fiigii commented Mar 19, 2018

For example, mov_i2xmm + 64-bit can generate MOVQ xmm, rax, but mov_i2xmm + 32-bit does not work, we need mov_i2xmm + 128-bit to generate MOVD xmm, eax.

@mikedn
Copy link
Contributor

mikedn commented Mar 19, 2018

For example, mov_i2xmm + 64-bit can generate MOVQ xmm, rax, but mov_i2xmm + 32-bit does not work, we need mov_i2xmm + 128-bit to generate MOVD xmm, eax.

Seems to be working fine for me:

getEmitter()->emitIns_R_R(INS_mov_i2xmm, EA_4BYTE, REG_XMM6, REG_RDX);
getEmitter()->emitIns_R_R(INS_mov_i2xmm, EA_8BYTE, REG_XMM5, REG_RBX);
getEmitter()->emitIns_R_R(INS_mov_xmm2i, EA_4BYTE, REG_XMM4, REG_RCX);
getEmitter()->emitIns_R_R(INS_mov_xmm2i, EA_8BYTE, REG_XMM3, REG_RAX);

generates

C4E1796EF2           vmovd    xmm6, edx
C4E1F96EEB           vmovd    xmm5, rbx
C4E1797EE1           vmovd    ecx, xmm4
C4E1F97ED8           vmovd    rax, xmm3

@fiigii
Copy link
Contributor Author

fiigii commented Mar 19, 2018

@mikedn Oh, you are right! I used the wrong emit-size in dotnet/coreclr#17030 (should be emitActualTypeSize rather than emitTypeSize). Thank you!

@fiigii fiigii closed this as completed Mar 19, 2018
@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants