Skip to content

Commit d2c41fb

Browse files
authored
[RISCV] Correct the predicates for the flh/fsh InstAlias and assembler pseudos to include Zfbfmin. (#131920)
1 parent af7c8c4 commit d2c41fb

File tree

5 files changed

+69
-5
lines changed

5 files changed

+69
-5
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ foreach Ext = ZfhminDExts in {
218218
// Assembler Pseudo Instructions (User-Level ISA, Version 2.2, Chapter 20)
219219
//===----------------------------------------------------------------------===//
220220

221-
let Predicates = [HasStdExtZfhmin] in {
221+
let Predicates = [HasHalfFPLoadStoreMove] in {
222222
def : InstAlias<"flh $rd, (${rs1})", (FLH FPR16:$rd, GPR:$rs1, 0), 0>;
223223
def : InstAlias<"fsh $rs2, (${rs1})", (FSH FPR16:$rs2, GPR:$rs1, 0), 0>;
224224
} // Predicates = [HasStdExtZfhmin]
@@ -241,7 +241,7 @@ def PseudoQuietFLT_H : PseudoQuietFCMP<FPR16>;
241241
}
242242
} // Predicates = [HasStdExtZfh]
243243

244-
let Predicates = [HasStdExtZfhmin] in {
244+
let Predicates = [HasHalfFPLoadStoreMove] in {
245245
def PseudoFLH : PseudoFloatLoad<"flh", FPR16>;
246246
def PseudoFSH : PseudoStore<"fsh", FPR16>;
247247
} // Predicates = [HasStdExtZfhmin]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ fadd.h ft0, ft1, ft2 # CHECK: :[[@LINE]]:1: error: instruction requires the foll
190190
fadd.s a0, a1, a2 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'Zfinx' (Float in Integer){{$}}
191191
fadd.d a0, a2, a4 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'Zdinx' (Double in Integer){{$}}
192192
fadd.h a0, a1, a2 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'Zhinx' (Half Float in Integer){{$}}
193-
flh ft0, (a0) # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'Zfh' (Half-Precision Floating-Point) or 'Zfhmin' (Half-Precision Floating-Point Minimal){{$}}
193+
flh ft0, (a0) # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'Zfh' (Half-Precision Floating-Point) or 'Zfhmin' (Half-Precision Floating-Point Minimal) or 'Zfbfmin' (Scalar BF16 Converts){{$}}
194194
sh1add a0, a1, a2 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'Zba' (Address Generation Instructions) or 'Base P' (Packed-SIMD){{$}}
195195
clz a0, a1 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'Zbb' (Basic Bit-Manipulation) or 'Base P' (Packed-SIMD){{$}}
196196
clmul a0, a1, a2 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'Zbc' (Carry-Less Multiplication) or 'Zbkc' (Carry-less multiply instructions for Cryptography){{$}}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# RUN: llvm-mc %s -triple=riscv32 -mattr=+zfbfmin -M no-aliases \
2+
# RUN: | FileCheck -check-prefix=CHECK-INST %s
3+
# RUN: llvm-mc %s -triple=riscv32 -mattr=+zfbfmin \
4+
# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
5+
# RUN: llvm-mc %s -triple=riscv64 -mattr=+zfbfmin -M no-aliases \
6+
# RUN: | FileCheck -check-prefix=CHECK-INST %s
7+
# RUN: llvm-mc %s -triple=riscv64 -mattr=+zfbfmin \
8+
# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
9+
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+zfbfmin < %s \
10+
# RUN: | llvm-objdump -d --mattr=+zfbfmin --no-print-imm-hex -M no-aliases - \
11+
# RUN: | FileCheck -check-prefix=CHECK-INST %s
12+
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+zfbfmin < %s \
13+
# RUN: | llvm-objdump -d --mattr=+zfbfmin --no-print-imm-hex - \
14+
# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
15+
# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+zfbfmin < %s \
16+
# RUN: | llvm-objdump -d --mattr=+zfbfmin --no-print-imm-hex -M no-aliases - \
17+
# RUN: | FileCheck -check-prefix=CHECK-INST %s
18+
# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+zfbfmin < %s \
19+
# RUN: | llvm-objdump -d --mattr=+zfbfmin --no-print-imm-hex - \
20+
# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
21+
22+
##===----------------------------------------------------------------------===##
23+
## Assembler Pseudo Instructions (User-Level ISA, Version 2.2, Chapter 20)
24+
##===----------------------------------------------------------------------===##
25+
26+
# CHECK-INST: flh ft0, 0(a0)
27+
# CHECK-ALIAS: flh ft0, 0(a0)
28+
flh f0, (x10)
29+
# CHECK-INST: fsh ft0, 0(a0)
30+
# CHECK-ALIAS: fsh ft0, 0(a0)
31+
fsh f0, (x10)

llvm/test/MC/RISCV/rvzfh-pseudos.s

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
# RUN: llvm-mc %s -triple=riscv32 -mattr=+zfh | FileCheck %s
2-
# RUN: llvm-mc %s -triple=riscv64 -mattr=+zfh | FileCheck %s
1+
# RUN: llvm-mc %s -triple=riscv32 -mattr=+zfhmin | FileCheck %s
2+
# RUN: llvm-mc %s -triple=riscv64 -mattr=+zfhmin | FileCheck %s
3+
# RUN: llvm-mc %s -triple=riscv32 -mattr=+zfbfmin | FileCheck %s
4+
# RUN: llvm-mc %s -triple=riscv64 -mattr=+zfbfmin | FileCheck %s
35

46
# CHECK: .Lpcrel_hi0:
57
# CHECK: auipc a2, %pcrel_hi(a_symbol)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# RUN: llvm-mc %s -triple=riscv32 -mattr=+zfhmin -M no-aliases \
2+
# RUN: | FileCheck -check-prefix=CHECK-INST %s
3+
# RUN: llvm-mc %s -triple=riscv32 -mattr=+zfhmin \
4+
# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
5+
# RUN: llvm-mc %s -triple=riscv64 -mattr=+zfhmin -M no-aliases \
6+
# RUN: | FileCheck -check-prefix=CHECK-INST %s
7+
# RUN: llvm-mc %s -triple=riscv64 -mattr=+zfhmin \
8+
# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
9+
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+zfhmin < %s \
10+
# RUN: | llvm-objdump -d --mattr=+zfhmin --no-print-imm-hex -M no-aliases - \
11+
# RUN: | FileCheck -check-prefix=CHECK-INST %s
12+
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+zfhmin < %s \
13+
# RUN: | llvm-objdump -d --mattr=+zfhmin --no-print-imm-hex - \
14+
# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
15+
# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+zfhmin < %s \
16+
# RUN: | llvm-objdump -d --mattr=+zfhmin --no-print-imm-hex -M no-aliases - \
17+
# RUN: | FileCheck -check-prefix=CHECK-INST %s
18+
# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+zfhmin < %s \
19+
# RUN: | llvm-objdump -d --mattr=+zfhmin --no-print-imm-hex - \
20+
# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
21+
22+
##===----------------------------------------------------------------------===##
23+
## Assembler Pseudo Instructions (User-Level ISA, Version 2.2, Chapter 20)
24+
##===----------------------------------------------------------------------===##
25+
26+
# CHECK-INST: flh ft0, 0(a0)
27+
# CHECK-ALIAS: flh ft0, 0(a0)
28+
flh f0, (x10)
29+
# CHECK-INST: fsh ft0, 0(a0)
30+
# CHECK-ALIAS: fsh ft0, 0(a0)
31+
fsh f0, (x10)

0 commit comments

Comments
 (0)