Skip to content

Commit 98c8d64

Browse files
authored
[AArch64] Add assembly/dissasembly for BFSCALE instructions (#113538)
This patch adds assembly/disassembly for following instructions: BFSCALE (multiple and single vector) BFSCALE (multiple vectors) As specified in https://developer.arm.com/documentation/ddi0602/2024-09 Co-authored-by: Momchil Velikov [[email protected]](mailto:[email protected])
1 parent f537792 commit 98c8d64

File tree

4 files changed

+196
-1
lines changed

4 files changed

+196
-1
lines changed

llvm/lib/Target/AArch64/AArch64SMEInstrInfo.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,11 @@ defm FMOPA_MPPZZ_BtoS : sme_outer_product_fp32<0b0, 0b01, ZPR8, "fmopa", null_fr
10001000

10011001
} //[HasSMEF8F32]
10021002

1003+
let Predicates = [HasSME2, HasSVEBFSCALE] in {
1004+
defm BFSCALE : sme2_bfscale_single<"bfscale">;
1005+
defm BFSCALE : sme2_bfscale_multi<"bfscale">;
1006+
}
1007+
10031008
let Predicates = [HasSME2p2] in {
10041009
def FTMOPA_M2ZZZI_HtoS : sme_tmopa_32b<0b11000, ZZ_h_mul_r, ZPR16, "ftmopa">;
10051010
def FTMOPA_M2ZZZI_StoS : sme_tmopa_32b<0b00000, ZZ_s_mul_r, ZPR32, "ftmopa">;

llvm/lib/Target/AArch64/SMEInstrFormats.td

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5189,6 +5189,16 @@ class sme2_luti4_vector_vg4_strided<bits<2> sz, bits<2> op, string mnemonic>
51895189
let Inst{1-0} = Zd{1-0};
51905190
}
51915191

5192+
multiclass sme2_bfscale_single<string mnemonic> {
5193+
def _2ZZ : sme2_sve_destructive_vector_vg2_single<0b00, 0b0011000, ZZ_h_mul_r, ZPR4b16, mnemonic>;
5194+
def _4ZZ : sme2_sve_destructive_vector_vg4_single<0b00, 0b0011000, ZZZZ_h_mul_r, ZPR4b16, mnemonic>;
5195+
}
5196+
5197+
multiclass sme2_bfscale_multi<string mnemonic> {
5198+
def _2Z2Z : sme2_sve_destructive_vector_vg2_multi<0b00, 0b0011000, ZZ_h_mul_r, mnemonic>;
5199+
def _4Z4Z : sme2_sve_destructive_vector_vg4_multi<0b00, 0b0011000, ZZZZ_h_mul_r, mnemonic>;
5200+
}
5201+
51925202
class sme2_bf16_fp32_quarter_tile_outer_product<bit M, bit N, bit S, string mnemonic, RegisterOperand zn_ty, RegisterOperand zm_ty>
51935203
: I<(outs TileOp32:$ZAda),
51945204
(ins TileOp32:$_ZAda, zn_ty:$Zn, zm_ty:$Zm),
@@ -5334,4 +5344,4 @@ multiclass sme2_multi4_fmul_mm<string mnemonic> {
53345344
multiclass sme2_bfmul_multi<string mnemonic> {
53355345
def _2Z2Z : sme2_multi2_fmul_mm<0b00, mnemonic, ZZ_h_mul_r>;
53365346
def _4Z4Z : sme2_multi4_fmul_mm<0b00, mnemonic, ZZZZ_h_mul_r>;
5337-
}
5347+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// RUN: not llvm-mc -triple=aarch64 -show-encoding -mattr=+sme2,+sve-bfscale 2>&1 < %s| FileCheck %s
2+
3+
// Multiple and single vector, 2 regs
4+
5+
bfscale {z0.s-z1.s}, {z0.s-z1.s}, z0.h
6+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
7+
8+
bfscale {z1.h-z2.h}, {z1.h-z2.h}, z0.h
9+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid vector list, expected list with 2 consecutive SVE vectors, where the first vector is a multiple of 2 and with matching element types
10+
11+
bfscale {z0.h-z2.h}, {z0.h-z2.h}, z0.h
12+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
13+
14+
bfscale {z0.h-z1.h}, {z0.h-z1.h}, z0.s
15+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid restricted vector register, expected z0.h..z15.h
16+
17+
bfscale {z0.h-z1.h}, {z0.h-z1.h}, z16.h
18+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid restricted vector register, expected z0.h..z15.h
19+
20+
bfscale {z0.h-z1.h}, {z2.h-z3.h}, z8.h
21+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: operand must match destination register list
22+
23+
// Multiple and single vector, 4 regs
24+
25+
bfscale {z0.s-z3.s}, {z0.s-z3.s}, z0.h
26+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
27+
28+
bfscale {z1.h-z4.h}, {z1.h-z4.h}, z0.h
29+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid vector list, expected list with 4 consecutive SVE vectors, where the first vector is a multiple of 4 and with matching element types
30+
31+
bfscale {z0.h-z4.h}, {z0.h-z4.h}, z0.h
32+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid number of vectors
33+
34+
bfscale {z0.h-z3.h}, {z0.h-z3.h}, z0.s
35+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid restricted vector register, expected z0.h..z15.h
36+
37+
bfscale {z0.h-z3.h}, {z0.h-z3.h}, z16.h
38+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid restricted vector register, expected z0.h..z15.h
39+
40+
bfscale {z0.h-z3.h}, {z4.h-z7.h}, z8.h
41+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: operand must match destination register list
42+
43+
// Multiple vectors, 2 regs
44+
45+
bfscale {z0.s-z1.s}, {z0.s-z1.s}, {z2.h-z3.h}
46+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
47+
48+
bfscale {z1.h-z2.h}, {z1.h-z2.h}, {z2.h-z3.h}
49+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid vector list, expected list with 2 consecutive SVE vectors, where the first vector is a multiple of 2 and with matching element types
50+
51+
bfscale {z0.h-z2.h}, {z0.h-z4.h}, {z2.h-z3.h}
52+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid number of vectors
53+
54+
bfscale {z0.h-z1.h}, {z0.h-z1.h}, {z2.s-z3.s}
55+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
56+
57+
bfscale {z0.h-z1.h}, {z0.h-z1.h}, {z28.h-z30.h}
58+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
59+
60+
bfscale {z0.h-z1.h}, {z0.h-z1.h}, {z29.h-z30.h}
61+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid vector list, expected list with 2 consecutive SVE vectors, where the first vector is a multiple of 2 and with matching element types
62+
63+
bfscale {z0.h-z1.h}, {z2.h-z3.h}, {z28.h-z29.h}
64+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: operand must match destination register list
65+
66+
// Multiple vectors, 4 regs
67+
68+
bfscale {z0.s-z3.s}, {z0.s-z3.s}, {z4.h-z7.h}
69+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
70+
71+
bfscale {z1.h-z4.h}, {z1.h-z4.h}, z0.h
72+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid vector list, expected list with 4 consecutive SVE vectors, where the first vector is a multiple of 4 and with matching element types
73+
74+
bfscale {z0.h-z4.h}, {z0.h-z4.h}, {z4.h-z7.h}
75+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid number of vectors
76+
77+
bfscale {z0.h-z3.h}, {z0.h-z3.h}, {z4.s-z7.s}
78+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
79+
80+
bfscale {z0.h-z3.h}, {z0.h-z3.h}, {z4.h-z8.h}
81+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid number of vectors
82+
83+
bfscale {z0.h-z3.h}, {z0.h-z3.h}, {z5.h-z8.h}
84+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid vector list, expected list with 4 consecutive SVE vectors, where the first vector is a multiple of 4 and with matching element types
85+
86+
bfscale {z0.h-z3.h}, {z4.h-z7.h}, {z8.h-z11.h}
87+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: operand must match destination register list

llvm/test/MC/AArch64/SME2/bfscale.s

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sme2,+sve-bfscale < %s \
2+
// RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
3+
// RUN: not llvm-mc -triple=aarch64 -show-encoding < %s 2>&1 \
4+
// RUN: | FileCheck %s --check-prefix=CHECK-ERROR
5+
// RUN: llvm-mc -triple=aarch64 -filetype=obj -mattr=+sme2,+sve-bfscale < %s \
6+
// RUN: | llvm-objdump -d --mattr=+sme2,+sve-bfscale - | FileCheck %s --check-prefix=CHECK-INST
7+
// RUN: llvm-mc -triple=aarch64 -filetype=obj -mattr=+sme2,+sve-bfscale < %s \
8+
// RUN: | llvm-objdump -d --mattr=-sme2 - | FileCheck %s --check-prefix=CHECK-UNKNOWN
9+
// Disassemble encoding and check the re-encoding (-show-encoding) matches.
10+
// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sme2,+sve-bfscale < %s \
11+
// RUN: | sed '/.text/d' | sed 's/.*encoding: //g' \
12+
// RUN: | llvm-mc -triple=aarch64 -mattr=+sme2,+sve-bfscale -disassemble -show-encoding \
13+
// RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
14+
15+
// Multiple and single vector, 2 regs
16+
17+
bfscale {z0.h-z1.h}, {z0.h-z1.h}, z0.h // 11000001-00100000-10100001-10000000
18+
// CHECK-INST: bfscale { z0.h, z1.h }, { z0.h, z1.h }, z0.h
19+
// CHECK-ENCODING: [0x80,0xa1,0x20,0xc1]
20+
// CHECK-ERROR: instruction requires: sme2 sve-bfscale
21+
// CHECK-UNKNOWN: c120a180 <unknown>
22+
23+
bfscale {z20.h-z21.h}, {z20.h-z21.h}, z5.h // 11000001-00100101-10100001-10010100
24+
// CHECK-INST: bfscale { z20.h, z21.h }, { z20.h, z21.h }, z5.h
25+
// CHECK-ENCODING: [0x94,0xa1,0x25,0xc1]
26+
// CHECK-ERROR: instruction requires: sme2 sve-bfscale
27+
// CHECK-UNKNOWN: c125a194 <unknown>
28+
29+
bfscale {z30.h-z31.h}, {z30.h-z31.h}, z15.h // 11000001-00101111-10100001-10011110
30+
// CHECK-INST: bfscale { z30.h, z31.h }, { z30.h, z31.h }, z15.h
31+
// CHECK-ENCODING: [0x9e,0xa1,0x2f,0xc1]
32+
// CHECK-ERROR: instruction requires: sme2 sve-bfscale
33+
// CHECK-UNKNOWN: c12fa19e <unknown>
34+
35+
// Multiple and single vector, 4 regs
36+
37+
bfscale {z0.h-z3.h}, {z0.h-z3.h}, z0.h // 11000001-00100000-10101001-10000000
38+
// CHECK-INST: bfscale { z0.h - z3.h }, { z0.h - z3.h }, z0.h
39+
// CHECK-ENCODING: [0x80,0xa9,0x20,0xc1]
40+
// CHECK-ERROR: instruction requires: sme2 sve-bfscale
41+
// CHECK-UNKNOWN: c120a980 <unknown>
42+
43+
bfscale {z20.h-z23.h}, {z20.h-z23.h}, z5.h // 11000001-00100101-10101001-10010100
44+
// CHECK-INST: bfscale { z20.h - z23.h }, { z20.h - z23.h }, z5.h
45+
// CHECK-ENCODING: [0x94,0xa9,0x25,0xc1]
46+
// CHECK-ERROR: instruction requires: sme2 sve-bfscale
47+
// CHECK-UNKNOWN: c125a994 <unknown>
48+
49+
bfscale {z28.h-z31.h}, {z28.h-z31.h}, z15.h // 11000001-00101111-10101001-10011100
50+
// CHECK-INST: bfscale { z28.h - z31.h }, { z28.h - z31.h }, z15.h
51+
// CHECK-ENCODING: [0x9c,0xa9,0x2f,0xc1]
52+
// CHECK-ERROR: instruction requires: sme2 sve-bfscale
53+
// CHECK-UNKNOWN: c12fa99c <unknown>
54+
55+
// Multiple vectors, 2 regs
56+
57+
bfscale {z0.h-z1.h}, {z0.h-z1.h}, {z0.h-z1.h} // 11000001-00100000-10110001-10000000
58+
// CHECK-INST: bfscale { z0.h, z1.h }, { z0.h, z1.h }, { z0.h, z1.h }
59+
// CHECK-ENCODING: [0x80,0xb1,0x20,0xc1]
60+
// CHECK-ERROR: instruction requires: sme2 sve-bfscale
61+
// CHECK-UNKNOWN: c120b180 <unknown>
62+
63+
bfscale {z20.h-z21.h}, {z20.h-z21.h}, {z20.h-z21.h} // 11000001-00110100-10110001-10010100
64+
// CHECK-INST: bfscale { z20.h, z21.h }, { z20.h, z21.h }, { z20.h, z21.h }
65+
// CHECK-ENCODING: [0x94,0xb1,0x34,0xc1]
66+
// CHECK-ERROR: instruction requires: sme2 sve-bfscale
67+
// CHECK-UNKNOWN: c134b194 <unknown>
68+
69+
bfscale {z30.h-z31.h}, {z30.h-z31.h}, {z30.h-z31.h} // 11000001-00111110-10110001-10011110
70+
// CHECK-INST: bfscale { z30.h, z31.h }, { z30.h, z31.h }, { z30.h, z31.h }
71+
// CHECK-ENCODING: [0x9e,0xb1,0x3e,0xc1]
72+
// CHECK-ERROR: instruction requires: sme2 sve-bfscale
73+
// CHECK-UNKNOWN: c13eb19e <unknown>
74+
75+
// Multiple vectors, 4 regs
76+
77+
bfscale {z0.h-z3.h}, {z0.h-z3.h}, {z0.h-z3.h} // 11000001-00100000-10111001-10000000
78+
// CHECK-INST: bfscale { z0.h - z3.h }, { z0.h - z3.h }, { z0.h - z3.h }
79+
// CHECK-ENCODING: [0x80,0xb9,0x20,0xc1]
80+
// CHECK-ERROR: instruction requires: sme2 sve-bfscale
81+
// CHECK-UNKNOWN: c120b980 <unknown>
82+
83+
bfscale {z20.h-z23.h}, {z20.h-z23.h}, {z20.h-z23.h} // 11000001-00110100-10111001-10010100
84+
// CHECK-INST: bfscale { z20.h - z23.h }, { z20.h - z23.h }, { z20.h - z23.h }
85+
// CHECK-ENCODING: [0x94,0xb9,0x34,0xc1]
86+
// CHECK-ERROR: instruction requires: sme2 sve-bfscale
87+
// CHECK-UNKNOWN: c134b994 <unknown>
88+
89+
bfscale {z28.h-z31.h}, {z28.h-z31.h}, {z28.h-z31.h} // 11000001-00111100-10111001-10011100
90+
// CHECK-INST: bfscale { z28.h - z31.h }, { z28.h - z31.h }, { z28.h - z31.h }
91+
// CHECK-ENCODING: [0x9c,0xb9,0x3c,0xc1]
92+
// CHECK-ERROR: instruction requires: sme2 sve-bfscale
93+
// CHECK-UNKNOWN: c13cb99c <unknown>

0 commit comments

Comments
 (0)