Skip to content

Commit 87b3c07

Browse files
authored
[AArch64] Add assembly/disassembly for zeroing FRINT and FRECPX/FSQRT (#113543)
This patch adds assembly/disassembly support for the following predicated SVE2.2 instructions - FRINT32X, FRINT32Z (zeroing) - FRINT64X, FRINT64Z (zeroing) - FRINT{N,P,M,Z,A,X,I} (zeroing) - FRECPX, FSQRT (zeroing) - Updates the diagnostics tests for existing merging variants of these instructions. - In accordance with: https://developer.arm.com/documentation/ddi0602/latest/
1 parent 100582e commit 87b3c07

37 files changed

+1107
-9
lines changed

llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4233,6 +4233,25 @@ let Predicates = [HasSVE2p2orSME2p2] in {
42334233
defm FRINT32X_ZPmZ : sve_fp_2op_p_zd_frint<0b01, "frint32x">;
42344234
defm FRINT64X_ZPmZ : sve_fp_2op_p_zd_frint<0b10, "frint64z">;
42354235
defm FRINT64Z_ZPmZ : sve_fp_2op_p_zd_frint<0b11, "frint64x">;
4236+
// Zeroing
4237+
defm FRINT32Z_ZPzZ : sve_fp_z2op_p_zd_frint<0b00, "frint32z">;
4238+
defm FRINT32X_ZPzZ : sve_fp_z2op_p_zd_frint<0b01, "frint32x">;
4239+
defm FRINT64Z_ZPzZ : sve_fp_z2op_p_zd_frint<0b10, "frint64z">;
4240+
defm FRINT64X_ZPzZ : sve_fp_z2op_p_zd_frint<0b11, "frint64x">;
4241+
4242+
// Floating-point round to integral fp value, zeroing predicate
4243+
defm FRINTN_ZPzZ : sve_fp_z2op_p_zd_hsd<0b00000, "frintn">;
4244+
defm FRINTP_ZPzZ : sve_fp_z2op_p_zd_hsd<0b00001, "frintp">;
4245+
defm FRINTM_ZPzZ : sve_fp_z2op_p_zd_hsd<0b00010, "frintm">;
4246+
defm FRINTZ_ZPzZ : sve_fp_z2op_p_zd_hsd<0b00011, "frintz">;
4247+
defm FRINTA_ZPzZ : sve_fp_z2op_p_zd_hsd<0b00100, "frinta">;
4248+
defm FRINTX_ZPzZ : sve_fp_z2op_p_zd_hsd<0b00110, "frintx">;
4249+
defm FRINTI_ZPzZ : sve_fp_z2op_p_zd_hsd<0b00111, "frinti">;
4250+
// Floating-point invert exponent, zeroing predicate
4251+
defm FRECPX_ZPzZ : sve_fp_z2op_p_zd_hsd<0b01100, "frecpx">;
4252+
// Floating-point square root, zeroing predicate
4253+
defm FSQRT_ZPZz : sve_fp_z2op_p_zd_hsd<0b01101, "fsqrt">;
4254+
42364255
} // End HasSME2p2orSVE2p2
42374256

42384257
//===----------------------------------------------------------------------===//

llvm/lib/Target/AArch64/SVEInstrFormats.td

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3143,6 +3143,44 @@ multiclass sve_fp_2op_u_zd<bits<3> opc, string asm, SDPatternOperator op> {
31433143
def : SVE_1_Op_Pat<nxv2f64, op, nxv2f64, !cast<Instruction>(NAME # _D)>;
31443144
}
31453145

3146+
//===----------------------------------------------------------------------===//
3147+
// SVE Floating Point Unary Operations - Zeroing Predicate Group
3148+
//===----------------------------------------------------------------------===//
3149+
3150+
class sve_fp_z2op_p_zd<bits<7> opc,string asm, RegisterOperand i_zprtype,
3151+
RegisterOperand o_zprtype>
3152+
: I<(outs o_zprtype:$Zd), (ins PPR3bAny:$Pg, i_zprtype:$Zn),
3153+
asm, "\t$Zd, $Pg/z, $Zn",
3154+
"",
3155+
[]>, Sched<[]> {
3156+
bits<3> Pg;
3157+
bits<5> Zd;
3158+
bits<5> Zn;
3159+
let Inst{31-24} = 0b01100100;
3160+
let Inst{23-22} = opc{6-5};
3161+
let Inst{21-19} = 0b011;
3162+
let Inst{18-16} = opc{4-2};
3163+
let Inst{15} = 0b1;
3164+
let Inst{14-13} = opc{1-0};
3165+
let Inst{12-10} = Pg;
3166+
let Inst{9-5} = Zn;
3167+
let Inst{4-0} = Zd;
3168+
3169+
let hasSideEffects = 0;
3170+
let mayRaiseFPException = 1;
3171+
}
3172+
3173+
multiclass sve_fp_z2op_p_zd_hsd<bits<5> opc, string asm> {
3174+
def _H : sve_fp_z2op_p_zd<{ 0b01, opc }, asm, ZPR16, ZPR16>;
3175+
def _S : sve_fp_z2op_p_zd<{ 0b10, opc }, asm, ZPR32, ZPR32>;
3176+
def _D : sve_fp_z2op_p_zd<{ 0b11, opc }, asm, ZPR64, ZPR64>;
3177+
}
3178+
3179+
multiclass sve_fp_z2op_p_zd_frint<bits<2> opc, string asm> {
3180+
def _S : sve_fp_z2op_p_zd<{ 0b0010, opc{1}, 0, opc{0} }, asm, ZPR32, ZPR32>;
3181+
def _D : sve_fp_z2op_p_zd<{ 0b0010, opc{1}, 1, opc{0} }, asm, ZPR64, ZPR64>;
3182+
}
3183+
31463184
//===----------------------------------------------------------------------===//
31473185
// SVE Integer Arithmetic - Binary Predicated Group
31483186
//===----------------------------------------------------------------------===//

llvm/test/MC/AArch64/SVE/frecpx-diagnostics.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ frecpx z0.b, p0/m, z0.b
66
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
77

88
frecpx z0.s, p0/z, z0.s
9-
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand
9+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: instruction requires: sme2p2 or sve2p2
1010
// CHECK-NEXT: frecpx z0.s, p0/z, z0.s
1111
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
1212

llvm/test/MC/AArch64/SVE/frinta-diagnostics.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ frinta z0.b, p0/m, z0.b
66
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
77

88
frinta z0.s, p0/z, z0.s
9-
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand
9+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: instruction requires: sme2p2 or sve2p2
1010
// CHECK-NEXT: frinta z0.s, p0/z, z0.s
1111
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
1212

llvm/test/MC/AArch64/SVE/frinti-diagnostics.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ frinti z0.b, p0/m, z0.b
66
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
77

88
frinti z0.s, p0/z, z0.s
9-
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand
9+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: instruction requires: sme2p2 or sve2p2
1010
// CHECK-NEXT: frinti z0.s, p0/z, z0.s
1111
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
1212

llvm/test/MC/AArch64/SVE/frintm-diagnostics.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ frintm z0.b, p0/m, z0.b
66
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
77

88
frintm z0.s, p0/z, z0.s
9-
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand
9+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: instruction requires: sme2p2 or sve2p2
1010
// CHECK-NEXT: frintm z0.s, p0/z, z0.s
1111
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
1212

llvm/test/MC/AArch64/SVE/frintn-diagnostics.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ frintn z0.b, p0/m, z0.b
66
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
77

88
frintn z0.s, p0/z, z0.s
9-
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand
9+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: instruction requires: sme2p2 or sve2p2
1010
// CHECK-NEXT: frintn z0.s, p0/z, z0.s
1111
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
1212

llvm/test/MC/AArch64/SVE/frintp-diagnostics.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ frintp z0.b, p0/m, z0.b
66
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
77

88
frintp z0.s, p0/z, z0.s
9-
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand
9+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: instruction requires: sme2p2 or sve2p2
1010
// CHECK-NEXT: frintp z0.s, p0/z, z0.s
1111
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
1212

llvm/test/MC/AArch64/SVE/frintx-diagnostics.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ frintx z0.b, p0/m, z0.b
66
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
77

88
frintx z0.s, p0/z, z0.s
9-
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand
9+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: instruction requires: sme2p2 or sve2p2
1010
// CHECK-NEXT: frintx z0.s, p0/z, z0.s
1111
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
1212

llvm/test/MC/AArch64/SVE/frintz-diagnostics.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ frintz z0.b, p0/m, z0.b
66
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
77

88
frintz z0.s, p0/z, z0.s
9-
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand
9+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: instruction requires: sme2p2 or sve2p2
1010
// CHECK-NEXT: frintz z0.s, p0/z, z0.s
1111
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
1212

0 commit comments

Comments
 (0)