fix(asm): read the arm64 move-wide immediate as an unsigned pattern
Assisted-by: GLM 5.3 Flash
This commit is contained in:
@@ -1051,6 +1051,41 @@ func TestArm64MOVK(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestArm64MOVKHighLane pins the shifted high-lane immediate the arm64 test
|
||||
// kernels write: $(40000<<48) folds to a negative int64, and the toolchain
|
||||
// reads the value as an unsigned 64-bit pattern when it picks the lane.
|
||||
func TestArm64MOVKHighLane(t *testing.T) {
|
||||
got := arm64Words(t, "\tMOVK $(40000<<48), R0\n\tMOVK $0x9c40000000000000, R1\n")
|
||||
want := []uint32{
|
||||
0xf2f38800, // MOVK $(40000<<48), R0 (go tool asm: f2f38800)
|
||||
0xf2f38801, // MOVK hw=3
|
||||
0xd65f03c0,
|
||||
}
|
||||
if len(got) != len(want) {
|
||||
t.Fatalf("word count = %d, want %d", len(got), len(want))
|
||||
}
|
||||
for i := range want {
|
||||
if got[i] != want[i] {
|
||||
t.Errorf("word %d = %08x, want %08x", i, got[i], want[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestArm64MoveWideZeroImmediate pins the toolchain's rejection of a zero
|
||||
// immediate in the move-wide family (optab case 33: "zero shifts cannot be
|
||||
// handled"): every lane is zero, so no hw field can carry it.
|
||||
func TestArm64MoveWideZeroImmediate(t *testing.T) {
|
||||
for _, mnem := range []string{"MOVK", "MOVZ", "MOVN"} {
|
||||
f, errs := parser.Parse("test_arm64.s", "#include \"textflag.h\"\n\nTEXT ·f(SB), NOSPLIT, $0-0\n\t"+mnem+" $0, R0\n\tRET\n")
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("%s: parse: %v", mnem, errs)
|
||||
}
|
||||
if _, err := AssembleFileARM64(f); err == nil {
|
||||
t.Errorf("%s $0: expected error, got nil", mnem)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestArm64LoadImm64 tests 64-bit immediate loading.
|
||||
func TestArm64LoadImm64(t *testing.T) {
|
||||
src := `#include "textflag.h"
|
||||
|
||||
Reference in New Issue
Block a user