Skip to content

Commit 6f4a034

Browse files
committed
[RISCV][MC] Add Q support for Zfa
1 parent 5ee0513 commit 6f4a034

File tree

5 files changed

+484
-10
lines changed

5 files changed

+484
-10
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoZfa.td

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,28 @@ def FLEQ_H : FPCmp_rr<0b1010010, 0b100, "fleq.h", FPR16>;
175175
}
176176
} // Predicates = [HasStdExtZfa, HasStdExtZfh]
177177

178+
let Predicates = [HasStdExtZfa, HasStdExtQ] in {
179+
let isReMaterializable = 1, isAsCheapAsAMove = 1 in
180+
def FLI_Q : FPFLI_r<0b1111011, 0b00001, 0b000, FPR128, "fli.q">;
181+
182+
def FMINM_Q: FPALU_rr<0b0010111, 0b010, "fminm.q", FPR128, Commutable=1>;
183+
def FMAXM_Q: FPALU_rr<0b0010111, 0b011, "fmaxm.q", FPR128, Commutable=1>;
184+
185+
def FROUND_Q : FPUnaryOp_r_frm<0b0100011, 0b00100, FPR128, FPR128, "fround.q">;
186+
def FROUNDNX_Q : FPUnaryOp_r_frm<0b0100011, 0b00101, FPR128, FPR128,
187+
"froundnx.q">;
188+
189+
def FLTQ_Q : FPCmp_rr<0b1010011, 0b101, "fltq.q", FPR128>;
190+
def FLEQ_Q : FPCmp_rr<0b1010011, 0b100, "fleq.q", FPR128>;
191+
} // Predicates = [HasStdExtZfa, HasStdExtQ]
192+
193+
let Predicates = [HasStdExtZfa, HasStdExtQ, IsRV64] in {
194+
let mayRaiseFPException = 0 in {
195+
def FMVH_X_Q : FPUnaryOp_r<0b1110011, 0b00001, 0b000, GPR, FPR128, "fmvh.x.q">;
196+
def FMVP_Q_X : FPBinaryOp_rr<0b1011011, 0b000, FPR128, GPR, "fmvp.q.x">;
197+
}
198+
} // Predicates = [HasStdExtZfa, HasStdExtQ, IsRV64]
199+
178200
//===----------------------------------------------------------------------===//
179201
// Pseudo-instructions and codegen patterns
180202
//===----------------------------------------------------------------------===//
@@ -200,6 +222,13 @@ def : InstAlias<"fgeq.h $rd, $rs, $rt",
200222
(FLEQ_H GPR:$rd, FPR16:$rt, FPR16:$rs), 0>;
201223
}
202224

225+
let Predicates = [HasStdExtZfa, HasStdExtQ] in {
226+
def : InstAlias<"fgtq.q $rd, $rs, $rt",
227+
(FLTQ_Q GPR:$rd, FPR128:$rt, FPR128:$rs), 0>;
228+
def : InstAlias<"fgeq.q $rd, $rs, $rt",
229+
(FLEQ_Q GPR:$rd, FPR128:$rt, FPR128:$rs), 0>;
230+
}
231+
203232
//===----------------------------------------------------------------------===//
204233
// Codegen patterns
205234
//===----------------------------------------------------------------------===//
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# RUN: llvm-mc %s -triple=riscv64 -mattr=+zfa,+q,+zfh -M no-aliases -show-encoding \
2+
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
3+
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+zfa,+q,+zfh < %s \
4+
# RUN: | llvm-objdump --mattr=+zfa,+q,+zfh -M no-aliases -d -r - \
5+
# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
6+
#
7+
# RUN: not llvm-mc -triple riscv64 -mattr=+q,+zfh \
8+
# RUN: -M no-aliases -show-encoding < %s 2>&1 \
9+
# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
10+
11+
# CHECK-ASM-AND-OBJ: fmvh.x.q a1, fs1
12+
# CHECK-ASM: encoding: [0xd3,0x85,0x14,0xe6]
13+
# CHECK-NO-EXT: error: instruction requires the following: 'Zfa' (Additional Floating-Point){{$}}
14+
fmvh.x.q a1, fs1
15+
16+
# CHECK-ASM-AND-OBJ: fmvp.q.x fs1, a1, a2
17+
# CHECK-ASM: encoding: [0xd3,0x84,0xc5,0xb6]
18+
# CHECK-NO-EXT: error: instruction requires the following: 'Zfa' (Additional Floating-Point){{$}}
19+
fmvp.q.x fs1, a1, a2

llvm/test/MC/RISCV/zfa-invalid.s

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# RUN: not llvm-mc -triple riscv64 -mattr=+zfa,+d,+zfh < %s 2>&1 | FileCheck -check-prefixes=CHECK-NO-RV32 %s
2-
# RUN: not llvm-mc -triple riscv32 -mattr=+zfa,+d,+zfh < %s 2>&1 | FileCheck -check-prefixes=CHECK-NO-RV64 %s
1+
# RUN: not llvm-mc -triple riscv64 -mattr=+zfa,+q,+zfh < %s 2>&1 | FileCheck -check-prefixes=CHECK-NO-RV32 %s
2+
# RUN: not llvm-mc -triple riscv32 -mattr=+zfa,+q,+zfh < %s 2>&1 | FileCheck -check-prefixes=CHECK-NO-RV64 %s
33

44
# Invalid rounding modes
55
# CHECK-NO-RV64: error: operand must be 'rtz' floating-point rounding mode
@@ -35,6 +35,10 @@ fli.d ft1, 3.560000e+02
3535
# CHECK-NO-RV32: error: operand must be a valid floating-point constant
3636
fli.h ft1, 1.600000e+00
3737

38+
# CHECK-NO-RV64: error: operand must be a valid floating-point constant
39+
# CHECK-NO-RV32: error: operand must be a valid floating-point constant
40+
fli.q ft1, 2.250000e+00
41+
3842
# CHECK-NO-RV64: error: invalid floating point immediate
3943
# CHECK-NO-RV32: error: invalid floating point immediate
4044
fli.s ft1, -min
@@ -72,6 +76,11 @@ fli.d ft1, 1.1754943508222875079687365372222456778186655567720875215087517062784
7276
# CHECK-NO-RV32: error: operand must be a valid floating-point constant
7377
fli.h ft1, 1.1754943508222875079687365372222456778186655567720875215087517062784172594547271728515625e-38
7478

79+
# Don't accept single precision minimum for quad.
80+
# CHECK-NO-RV64: error: operand must be a valid floating-point constant
81+
# CHECK-NO-RV32: error: operand must be a valid floating-point constant
82+
fli.q ft1, 1.1754943508222875079687365372222456778186655567720875215087517062784172594547271728515625e-38
83+
7584
# Don't accept integers.
7685
# CHECK-NO-RV32: error: invalid floating point immediate
7786
# CHECK-NO-RV64: error: invalid floating point immediate

llvm/test/MC/RISCV/zfa-quad-invalid.s

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# RUN: not llvm-mc -triple riscv32 -mattr=+zfa,+zfh \
2+
# RUN: -M no-aliases -show-encoding < %s 2>&1 \
3+
# RUN: | FileCheck -check-prefixes=CHECK-NO-EXTQ %s
4+
# RUN: not llvm-mc -triple riscv64 -mattr=+zfa,+zfh \
5+
# RUN: -M no-aliases -show-encoding < %s 2>&1 \
6+
# RUN: | FileCheck -check-prefixes=CHECK-NO-EXTQ %s
7+
8+
# CHECK-NO-EXTQ: error: instruction requires the following: 'Q' (Quad-Precision Floating-Point){{$}}
9+
fminm.q fa0, fa1, fa2
10+
11+
# CHECK-NO-EXTQ: error: instruction requires the following: 'Q' (Quad-Precision Floating-Point){{$}}
12+
fmaxm.q fs3, fs4, fs5
13+
14+
# CHECK-NO-EXTQ: error: instruction requires the following: 'Q' (Quad-Precision Floating-Point){{$}}
15+
fround.q fs1, fs2
16+
17+
# CHECK-NO-EXTQ: error: instruction requires the following: 'Q' (Quad-Precision Floating-Point){{$}}
18+
fround.q fs1, fs2, dyn
19+
20+
# CHECK-NO-EXTQ: error: instruction requires the following: 'Q' (Quad-Precision Floating-Point){{$}}
21+
fround.q fs1, fs2, rtz
22+
23+
# CHECK-NO-EXTQ: error: instruction requires the following: 'Q' (Quad-Precision Floating-Point){{$}}
24+
fround.q fs1, fs2, rne
25+
26+
# CHECK-NO-EXTQ: error: instruction requires the following: 'Q' (Quad-Precision Floating-Point){{$}}
27+
froundnx.q fs1, fs2
28+
29+
# CHECK-NO-EXTQ: error: instruction requires the following: 'Q' (Quad-Precision Floating-Point){{$}}
30+
froundnx.q fs1, fs2, dyn
31+
32+
# CHECK-NO-EXTQ: error: instruction requires the following: 'Q' (Quad-Precision Floating-Point){{$}}
33+
froundnx.q fs1, fs2, rtz
34+
35+
# CHECK-NO-EXTQ: error: instruction requires the following: 'Q' (Quad-Precision Floating-Point){{$}}
36+
froundnx.q fs1, fs2, rne
37+
38+
# CHECK-NO-EXTQ: error: instruction requires the following: 'Q' (Quad-Precision Floating-Point){{$}}
39+
fltq.q a1, fs1, fs2
40+
41+
# CHECK-NO-EXTQ: error: instruction requires the following: 'Q' (Quad-Precision Floating-Point){{$}}
42+
fleq.q a1, ft1, ft2

0 commit comments

Comments
 (0)