feat(asm): encode the arm64 SVE2 crypto, counter and reduction families
Assisted-by: GLM 5.3
This commit is contained in:
1 parent
dac0a5b51b
commit
6faf850793
5 files changed
+1211
-16
No files matched your search
@@ -424,3 +424,141 @@ func TestArm64AssembleExtensionStage2Golden(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestArm64AssembleExtensionStage3Golden drives the stage-three families
|
||||
// through the full assembler: corpus text in, corpus word out. The
|
||||
// statements carry the spellings the layer reads: the read-back crypto
|
||||
// destinations, the ZR of the dropped counter results, the bare governing
|
||||
// predicates and the V destinations of the reductions.
|
||||
func TestArm64AssembleExtensionStage3Golden(t *testing.T) {
|
||||
tests := []struct {
|
||||
stmt string
|
||||
want uint32
|
||||
}{
|
||||
// The crypto family.
|
||||
{"ZADCLB Z7.D, Z23.D, Z13.D", 0x4547d2ed},
|
||||
{"ZADCLT Z7.D, Z23.D, Z13.D", 0x4547d6ed},
|
||||
{"ZSBCLB Z7.D, Z23.D, Z13.D", 0x45c7d2ed},
|
||||
{"ZSBCLT Z7.D, Z23.D, Z13.D", 0x45c7d6ed},
|
||||
{"ZRAX1 Z7.D, Z6.D, Z23.D", 0x4527f4d7},
|
||||
{"ZSM4EKEY Z7.S, Z6.S, Z23.S", 0x4527f0d7},
|
||||
{"ZSM4E Z7.S, Z6.S, Z6.S", 0x4523e0e6},
|
||||
{"ZAESD Z7.B, Z6.B, Z6.B", 0x4522e4e6},
|
||||
{"ZAESE Z7.B, Z6.B, Z6.B", 0x4522e0e6},
|
||||
{"ZAESIMC Z11.B, Z11.B", 0x4520e40b},
|
||||
{"ZAESMC Z11.B, Z11.B", 0x4520e00b},
|
||||
// The terminators and counters.
|
||||
{"CTERMEQ ZR, R25", 0x25ff2320},
|
||||
{"CTERMEQW ZR, R25", 0x25bf2320},
|
||||
{"CTERMNE ZR, R25", 0x25ff2330},
|
||||
{"CTERMNEW ZR, R25", 0x25bf2330},
|
||||
{"CTERMEQ R0, R25", 0x25e02320},
|
||||
{"PCNTP P2.B, P14, R2", 0x2520b842},
|
||||
{"PFIRSTP P2.B, P14, R2", 0x2521b842},
|
||||
{"PLASTP P2.B, P14, R2", 0x2522b842},
|
||||
{"PDECP P14.S, ZR", 0x25ad89df},
|
||||
{"PINCP P14.S, ZR", 0x25ac89df},
|
||||
{"PSQDECP P14.S, ZR", 0x25aa8ddf},
|
||||
{"PSQINCP P14.S, ZR", 0x25a88ddf},
|
||||
{"PUQDECP P14.S, ZR", 0x25ab8ddf},
|
||||
{"PUQINCP P14.S, ZR", 0x25a98ddf},
|
||||
{"PUQDECPW P14.S, ZR", 0x25ab89df},
|
||||
{"PUQINCPW P14.S, ZR", 0x25a989df},
|
||||
{"PSQDECPW R8, P10.D, R8", 0x25ea8948},
|
||||
{"PSQINCPW R8, P10.D, R8", 0x25e88948},
|
||||
{"PWHILEGEW R2, R10, P10.H", 0x2562014a},
|
||||
{"PWHILEGTW R2, R10, P10.H", 0x2562015a},
|
||||
{"PWHILEHIW R2, R10, P10.H", 0x2562095a},
|
||||
{"PWHILEHSW R2, R10, P10.H", 0x2562094a},
|
||||
{"PWHILELEW R2, R10, P10.H", 0x2562055a},
|
||||
{"PWHILELOW R2, R10, P10.H", 0x25620d4a},
|
||||
{"PWHILELSW R2, R10, P10.H", 0x25620d5a},
|
||||
{"PWHILELTW R2, R10, P10.H", 0x2562054a},
|
||||
// The reductions.
|
||||
{"ZSADDVD Z6.B, P3, V2", 0x04002cc2},
|
||||
{"ZUADDVD Z10.D, P3, V15", 0x04c12d4f},
|
||||
{"ZANDVB Z6.B, P3, V2", 0x041a2cc2},
|
||||
{"ZANDVH Z3.H, P1, V29", 0x045a247d},
|
||||
{"ZANDVS Z17.S, P1, V27", 0x049a263b},
|
||||
{"ZANDVD Z10.D, P3, V15", 0x04da2d4f},
|
||||
{"ZEORVB Z6.B, P3, V2", 0x04192cc2},
|
||||
{"ZEORVD Z10.D, P3, V15", 0x04d92d4f},
|
||||
{"ZORVB Z6.B, P3, V2", 0x04182cc2},
|
||||
{"ZORVD Z10.D, P3, V15", 0x04d82d4f},
|
||||
{"ZSMAXVB Z6.B, P3, V2", 0x04082cc2},
|
||||
{"ZSMAXVH Z3.H, P1, V29", 0x0448247d},
|
||||
{"ZSMAXVS Z17.S, P1, V27", 0x0488263b},
|
||||
{"ZSMAXVD Z10.D, P3, V15", 0x04c82d4f},
|
||||
{"ZSMINVB Z6.B, P3, V2", 0x040a2cc2},
|
||||
{"ZSMINVD Z10.D, P3, V15", 0x04ca2d4f},
|
||||
{"ZUMAXVB Z6.B, P3, V2", 0x04092cc2},
|
||||
{"ZUMAXVD Z10.D, P3, V15", 0x04c92d4f},
|
||||
{"ZUMINVB Z6.B, P3, V2", 0x040b2cc2},
|
||||
{"ZUMINVD Z10.D, P3, V15", 0x04cb2d4f},
|
||||
{"ZFADDVH Z3.H, P1, V29", 0x6540247d},
|
||||
{"ZFADDVS Z17.S, P1, V27", 0x6580263b},
|
||||
{"ZFADDVD Z10.D, P3, V15", 0x65c02d4f},
|
||||
{"ZFMAXNMVH Z3.H, P1, V29", 0x6544247d},
|
||||
{"ZFMAXNMVD Z10.D, P3, V15", 0x65c42d4f},
|
||||
{"ZFMAXVH Z3.H, P1, V29", 0x6546247d},
|
||||
{"ZFMAXVD Z10.D, P3, V15", 0x65c62d4f},
|
||||
{"ZFMINNMVH Z3.H, P1, V29", 0x6545247d},
|
||||
{"ZFMINNMVD Z10.D, P3, V15", 0x65c52d4f},
|
||||
{"ZFMINVH Z3.H, P1, V29", 0x6547247d},
|
||||
{"ZFMINVD Z10.D, P3, V15", 0x65c72d4f},
|
||||
{"ZFADDAH Z8.H, V15, P2, V15", 0x6558290f},
|
||||
{"ZFADDAS Z26.S, V30, P7, V30", 0x65983f5e},
|
||||
{"ZFADDAD Z9.D, V10, P2, V10", 0x65d8292a},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
words := assembleArm64Words(t, arm64ExtProbeHead+"\t"+tt.stmt+"\n\tRET\n")
|
||||
if len(words) != 2 {
|
||||
t.Fatalf("%s: got %d words, want the statement and RET", tt.stmt, len(words))
|
||||
}
|
||||
if words[0] != tt.want {
|
||||
t.Errorf("%s:\n got %08x\n want %08x", tt.stmt, words[0], tt.want)
|
||||
}
|
||||
if words[1] != 0xd65f03c0 {
|
||||
t.Errorf("%s: RET encoded %08x", tt.stmt, words[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestArm64AssembleExtensionStage3Refusals pins the diagnostics the
|
||||
// stage-three statements get from the layer: the read-back mismatches, the
|
||||
// locked arrangements, the dropped-result zero register and the narrow
|
||||
// governing predicates.
|
||||
func TestArm64AssembleExtensionStage3Refusals(t *testing.T) {
|
||||
tests := []struct {
|
||||
stmt string
|
||||
want string
|
||||
}{
|
||||
{"ZSM4E Z7.S, Z6.S, Z5.S", "the same register Zd"},
|
||||
{"ZSM4E Z7.D, Z6.D, Z6.D", "want .S"},
|
||||
{"ZAESIMC Z11.B, Z12.B", "the same register Zd"},
|
||||
{"ZADCLB Z7.S, Z23.S, Z13.S", "want .D"},
|
||||
{"CTERMEQ RSP, R25", "wants ZR here"},
|
||||
{"CTERMEQ R31, R25", "outside R0-R30"},
|
||||
{"PCNTP P2.B, P14, R31", "outside R0-R30"},
|
||||
{"PCNTP P2.Q, P14, R2", "no size encoding"},
|
||||
{"PDECP P14.S, R0", "spelled ZR"},
|
||||
{"PDECP P14.Q, ZR", "no size encoding"},
|
||||
{"PSQDECPW R8, P10.D, R9", "the same register"},
|
||||
{"ZSADDVD Z6.B, P9, V2", "outside P0-P7"},
|
||||
{"ZSADDVD Z6.B, P3/M, V2", "takes no qualifier"},
|
||||
{"ZSADDVD Z6.B, P3, V32", "outside V0-V31"},
|
||||
{"ZSADDVD Z6.B, P3, R2", "wants a SIMD register"},
|
||||
{"ZANDVB Z6.S, P3, V2", "want .B"},
|
||||
{"ZFADDAD Z9.D, V10, P2, V11", "the same register Vd"},
|
||||
{"PWHILEGEW R2, R10, P10.H", ""},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if tt.want == "" {
|
||||
continue
|
||||
}
|
||||
got := assembleArm64SrcError(t, arm64ExtProbeHead+"\t"+tt.stmt+"\n\tRET\n")
|
||||
if !strings.Contains(got, tt.want) {
|
||||
t.Errorf("%s: error %q does not name %q", tt.stmt, got, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user