-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add ARM64 encodings for groups IF_SVE_HO,HP,HS #99058
Add ARM64 encodings for groups IF_SVE_HO,HP,HS #99058
Conversation
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsCovers many floating point - integer conversion and floating point precision conversion variants. N.B. I had to change a few of the generated groups for these, some of the _K-M groups were added manually as the generator missed the half precision variants. Matching capstone output:
Contributing towards #94549
|
@a74nh @kunalspathak @dotnet/arm64-contrib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All LGTM, but @kunalspathak needs to comment on the table changes.
src/coreclr/jit/instrsarm64sve.h
Outdated
@@ -239,6 +239,43 @@ INST7(ld1sw, "ld1sw", 0, IF_SV | |||
// LD1SW {<Zt>.D }, <Pg>/Z, [<Xn|SP>, <Zm>.D] SVE_IU_4B_B 11000101010mmmmm 100gggnnnnnttttt C540 8000 | |||
// LD1SW {<Zt>.D }, <Pg>/Z, [<Zn>.D{, #<imm>}] SVE_IV_3A 11000101001iiiii 100gggnnnnnttttt C520 8000 | |||
|
|||
// enum name info SVE_HP_3B SVE_HP_3B_H SVE_HP_3B_I SVE_HP_3B_J SVE_HP_3B_K SVE_HP_3B_L SVE_HP_3B_M | |||
INST7(fcvtzs, "fcvtzs", 0, IF_SVE_7B, 0x659CA000, 0x65DCA000, 0x65D8A000, 0x65DEA000, 0x655AA000, 0x655CA000, 0x655EA000 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The H variant was missing from all these encodings. The changes here look fine to me, but I'll let @kunalspathak comment
Looking at FCVT, here is the information we have: bit 22 is "0":
bit 16 is "0":
Basically, bit 16 is "0" when we are downgrading the size and bit 22 is "0" when half <--> single conversion is involved. I didn't look deeply, but this should be applicable for other instructions as well like For completion, here are the scenarios when these bits are "1": bit 22 is "1":
bit 16 is "1":
|
You would also need to look at flipping bits 17 as well for FCVT. I've had a look across the different instructions and they have fairly inconsistent patterns between them for when you need to flip these bits, for example on SCVTF and UCVTF you also have to flip the 23rd bit sometimes and it is flipping 18:17 rather than 17:16. I'm wondering if this might be quite complex/branch-heavy? @a74nh any thoughts on this? |
Right and they are "1" when double <--> single conversion is involved. The point is we want to generalize and reduce the number of formats that we introduce just because they are difficult to maintain. As long as the position of bit pattern where we embed registers/special codes like size, element size is same, we try to give it same format name. In this case, regardless of which conversion we are on, runtime/src/coreclr/jit/instrsarm64.h Lines 1731 to 1732 in 049da22
and then, during encoding, we embed the right bits depending on the conversion: |
I think this would be: Update the hardcoded group table to have all those bits clear. Then during encoded potentially set some of those bits. For each group, you'd have 4 cases (B/H/S/D) to check, and then each case changes up to 4 bits. That's a little messy, but I think we have worse cases. I do think adding the groups (how you've done it) looks better in the code, but, I'm not sure on how fixed we are on keeping the tables unchanged. If so, then it'll need doing the bit twiddling way. |
src/coreclr/jit/instrsarm64sve.h
Outdated
// BFCVT <Zd>.H, <Pg>/M, <Zn>.S SVE_HO_3A 0110010110001010 101gggnnnnnddddd 658A A000 | ||
|
||
// enum name info SVE_HO_3B | ||
INST1(fcvt, "fcvt", 0, IF_SVE_HO_3B, 0x6508A000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bit 23 is always 1
and during the encoding, you are not setting it for all conversions. I am wondering with the current changes, is the encoding matching with capstone?
INST1(fcvt, "fcvt", 0, IF_SVE_HO_3B, 0x6508A000) | |
INST1(fcvt, "fcvt", 0, IF_SVE_HO_3B, 0x6588A000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is being set but not always explicitly, under (3 << 22)
in some of the cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// FCVT <Zd>.D, <Pg>/M, <Zn>.S SVE_HO_3B 0110010100001000 101gggnnnnnddddd 6508 A000 | ||
|
||
// enum name info SVE_HO_3C | ||
INST1(fcvtx, "fcvtx", 0, IF_SVE_HO_3C, 0x650AA000 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, fcvtx
and bfcvt
technically can have share the same format name of IF_SVE_HO_3A
unless you found a reason of have them different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I have kept them separate is because these variants only accept one combination of operand sizes so I consider them to have different format to avoid dealing with special cases after the group has been decided upon.
// enum name info SVE_HP_3A | ||
INST1(flogb, "flogb", 0, IF_SVE_HP_3A, 0x6518A000 ) | ||
// FLOGB <Zd>.<T>, <Pg>/M, <Zn>.<T> SVE_HP_3A 0110010100011xx0 101gggnnnnnddddd 6518 A000 | ||
|
||
// enum name info SVE_HP_3B | ||
INST1(fcvtzs, "fcvtzs", 0, IF_SVE_HP_3B, 0x6518A000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
likewise for fcvt
, fcvtzs
and fcvtzu
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because fcvtz[s,u]
has bits 18 and 17 varying with operand size, but fcvt
has bits 17 and 16 varying. They also accept different sizes of operands, for example fcvt
will accept D=>H
but fcvtz[s,u]
will not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, I agree.
src/coreclr/jit/codegenarm64test.cpp
Outdated
theEmitter->emitIns_R_R_R(INS_sve_bfcvt, EA_SCALABLE, REG_V3, REG_P2, REG_V9, | ||
INS_OPTS_S_TO_H); // BFCVT <Zd>.H, <Pg>/M, <Zn>.S | ||
|
||
// IF_SVE_HO_3A_B |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// IF_SVE_HO_3A_B | |
// IF_SVE_HO_3B |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
likewise most of the comments in this file needs to change to highlight the updated format name. e.g. IF_SVE_HP_3B_H
no longer exist.
src/coreclr/jit/instrsarm64sve.h
Outdated
// BFCVT <Zd>.H, <Pg>/M, <Zn>.S SVE_HO_3A 0110010110001010 101gggnnnnnddddd 658A A000 | ||
|
||
// enum name info SVE_HO_3B | ||
INST1(fcvt, "fcvt", 0, IF_SVE_HO_3B, 0x6508A000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
Covers many floating point - integer conversion and floating point precision conversion variants.
N.B. I had to change a few of the generated groups for these, some of the _K-M groups were added manually as the generator missed the half precision variants.
Matching capstone output:
Contributing towards #94549