Skip to content

Commit d9715c6

Browse files
committed
[RISCV] Don't make Zacas or Zabha imply A in RISCVISAInfo.cpp
Zabha and Zacas are both documented as depending on Zaamo. I'm hesitant to make them imply Zaamo instead. So remove the implication and replace with a check that either A or Zaamo is enabled.
1 parent 469c8a0 commit d9715c6

File tree

10 files changed

+52
-37
lines changed

10 files changed

+52
-37
lines changed

clang/test/Preprocessor/riscv-target-features.c

+11-2
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
174174
// CHECK-NOT: __riscv_ssqosid{{.*$}}
175175
// CHECK-NOT: __riscv_supm{{.*$}}
176176
// CHECK-NOT: __riscv_zaamo {{.*$}}
177+
// CHECK-NOT: __riscv_zabha {{.*$}}
177178
// CHECK-NOT: __riscv_zalasr {{.*$}}
178179
// CHECK-NOT: __riscv_zalrsc {{.*$}}
179180
// CHECK-NOT: __riscv_zfbfmin {{.*$}}
@@ -698,10 +699,10 @@
698699
// CHECK-ZA64RS-EXT: __riscv_za64rs 1000000{{$}}
699700

700701
// RUN: %clang --target=riscv32 \
701-
// RUN: -march=rv32i_zacas1p0 -E -dM %s \
702+
// RUN: -march=rv32ia_zacas1p0 -E -dM %s \
702703
// RUN: -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
703704
// RUN: %clang --target=riscv64 \
704-
// RUN: -march=rv64i_zacas1p0 -E -dM %s \
705+
// RUN: -march=rv64ia_zacas1p0 -E -dM %s \
705706
// RUN: -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
706707
// CHECK-ZACAS-EXT: __riscv_zacas 1000000{{$}}
707708

@@ -1552,6 +1553,14 @@
15521553
// RUN: -o - | FileCheck --check-prefix=CHECK-ZAAMO-EXT %s
15531554
// CHECK-ZAAMO-EXT: __riscv_zaamo 2000{{$}}
15541555

1556+
// RUN: %clang --target=riscv32 -menable-experimental-extensions \
1557+
// RUN: -march=rv32ia_zabha1p0 -E -dM %s \
1558+
// RUN: -o - | FileCheck --check-prefix=CHECK-ZABHA-EXT %s
1559+
// RUN: %clang --target=riscv64 -menable-experimental-extensions \
1560+
// RUN: -march=rv64ia_zabha1p0 -E -dM %s \
1561+
// RUN: -o - | FileCheck --check-prefix=CHECK-ZABHA-EXT %s
1562+
// CHECK-ZABHA-EXT: __riscv_zabha 1000000{{$}}
1563+
15551564
// RUN: %clang --target=riscv32 -menable-experimental-extensions \
15561565
// RUN: -march=rv32i_zalasr0p1 -E -dM %s \
15571566
// RUN: -o - | FileCheck --check-prefix=CHECK-ZALASR-EXT %s

llvm/lib/TargetParser/RISCVISAInfo.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,16 @@ Error RISCVISAInfo::checkDependency() {
10281028
return createStringError(errc::invalid_argument,
10291029
"'zcf' is only supported for 'rv32'");
10301030

1031+
if (Exts.count("zacas") && !(Exts.count("a") || Exts.count("zamo")))
1032+
return createStringError(
1033+
errc::invalid_argument,
1034+
"'zacas' requires 'a' or 'zaamo' extension to also be specified");
1035+
1036+
if (Exts.count("zabha") && !(Exts.count("a") || Exts.count("zamo")))
1037+
return createStringError(
1038+
errc::invalid_argument,
1039+
"'zabha' requires 'a' or 'zaamo' extension to also be specified");
1040+
10311041
return Error::success();
10321042
}
10331043

@@ -1040,8 +1050,6 @@ static const char *ImpliedExtsXSfvfnrclipxfqf[] = {"zve32f"};
10401050
static const char *ImpliedExtsXSfvfwmaccqqq[] = {"zvfbfmin"};
10411051
static const char *ImpliedExtsXSfvqmaccdod[] = {"zve32x"};
10421052
static const char *ImpliedExtsXSfvqmaccqoq[] = {"zve32x"};
1043-
static const char *ImpliedExtsZabha[] = {"a"};
1044-
static const char *ImpliedExtsZacas[] = {"a"};
10451053
static const char *ImpliedExtsZcb[] = {"zca"};
10461054
static const char *ImpliedExtsZcd[] = {"d", "zca"};
10471055
static const char *ImpliedExtsZce[] = {"zcb", "zcmp", "zcmt"};
@@ -1115,8 +1123,6 @@ static constexpr ImpliedExtsEntry ImpliedExts[] = {
11151123
{{"xsfvqmaccdod"}, {ImpliedExtsXSfvqmaccdod}},
11161124
{{"xsfvqmaccqoq"}, {ImpliedExtsXSfvqmaccqoq}},
11171125
{{"xtheadvdot"}, {ImpliedExtsXTHeadVdot}},
1118-
{{"zabha"}, {ImpliedExtsZabha}},
1119-
{{"zacas"}, {ImpliedExtsZacas}},
11201126
{{"zcb"}, {ImpliedExtsZcb}},
11211127
{{"zcd"}, {ImpliedExtsZcd}},
11221128
{{"zce"}, {ImpliedExtsZce}},

llvm/test/CodeGen/RISCV/attributes.ll

+4-4
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@
112112
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zvfbfmin %s -o - | FileCheck --check-prefixes=CHECK,RV32ZVFBFMIN %s
113113
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zvfbfwma %s -o - | FileCheck --check-prefixes=CHECK,RV32ZVFBFWMA %s
114114
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zaamo %s -o - | FileCheck --check-prefix=RV32ZAAMO %s
115-
; RUN: llc -mtriple=riscv32 -mattr=+zacas %s -o - | FileCheck --check-prefix=RV32ZACAS %s
115+
; RUN: llc -mtriple=riscv32 -mattr=+a,zacas %s -o - | FileCheck --check-prefix=RV32ZACAS %s
116116
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zalasr %s -o - | FileCheck --check-prefix=RV32ZALASR %s
117117
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zalrsc %s -o - | FileCheck --check-prefix=RV32ZALRSC %s
118118
; RUN: llc -mtriple=riscv32 -mattr=+zama16b %s -o - | FileCheck --check-prefixes=CHECK,RV32ZAMA16B %s
119119
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zicfilp %s -o - | FileCheck --check-prefix=RV32ZICFILP %s
120-
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zabha %s -o - | FileCheck --check-prefix=RV32ZABHA %s
120+
; RUN: llc -mtriple=riscv32 -mattr=+a,+experimental-zabha %s -o - | FileCheck --check-prefix=RV32ZABHA %s
121121
; RUN: llc -mtriple=riscv32 -mattr=+experimental-ssnpm %s -o - | FileCheck --check-prefix=RV32SSNPM %s
122122
; RUN: llc -mtriple=riscv32 -mattr=+experimental-smnpm %s -o - | FileCheck --check-prefix=RV32SMNPM %s
123123
; RUN: llc -mtriple=riscv32 -mattr=+experimental-smmpm %s -o - | FileCheck --check-prefix=RV32SMMPM %s
@@ -244,11 +244,11 @@
244244
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zvfbfmin %s -o - | FileCheck --check-prefixes=CHECK,RV64ZVFBFMIN %s
245245
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zvfbfwma %s -o - | FileCheck --check-prefixes=CHECK,RV64ZVFBFWMA %s
246246
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zaamo %s -o - | FileCheck --check-prefix=RV64ZAAMO %s
247-
; RUN: llc -mtriple=riscv64 -mattr=+zacas %s -o - | FileCheck --check-prefix=RV64ZACAS %s
247+
; RUN: llc -mtriple=riscv64 -mattr=+a,zacas %s -o - | FileCheck --check-prefix=RV64ZACAS %s
248248
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zalasr %s -o - | FileCheck --check-prefix=RV64ZALASR %s
249249
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zalrsc %s -o - | FileCheck --check-prefix=RV64ZALRSC %s
250250
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zicfilp %s -o - | FileCheck --check-prefix=RV64ZICFILP %s
251-
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zabha %s -o - | FileCheck --check-prefix=RV64ZABHA %s
251+
; RUN: llc -mtriple=riscv64 -mattr=+a,+experimental-zabha %s -o - | FileCheck --check-prefix=RV64ZABHA %s
252252
; RUN: llc -mtriple=riscv64 -mattr=+experimental-ssnpm %s -o - | FileCheck --check-prefix=RV64SSNPM %s
253253
; RUN: llc -mtriple=riscv64 -mattr=+experimental-smnpm %s -o - | FileCheck --check-prefix=RV64SMNPM %s
254254
; RUN: llc -mtriple=riscv64 -mattr=+experimental-smmpm %s -o - | FileCheck --check-prefix=RV64SMMPM %s

llvm/test/MC/RISCV/attribute-arch.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@
366366
.attribute arch, "rv32i_zvfbfwma1p0"
367367
# CHECK: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zfbfmin1p0_zve32f1p0_zve32x1p0_zvfbfmin1p0_zvfbfwma1p0_zvl32b1p0"
368368

369-
.attribute arch, "rv32izacas1p0"
369+
.attribute arch, "rv32ia_zacas1p0"
370370
# CHECK: attribute 5, "rv32i2p1_a2p1_zacas1p0"
371371

372372
.attribute arch, "rv32izalasr0p1"

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# RUN: not llvm-mc -triple riscv32 -mattr=+zacas < %s 2>&1 | FileCheck %s
1+
# RUN: not llvm-mc -triple riscv32 -mattr=+a,zacas < %s 2>&1 | FileCheck %s
22

33
# Non-zero offsets not supported for the third operand (rs1).
44
amocas.w a1, a3, 1(a5) # CHECK: :[[@LINE]]:18: error: optional integer offset must be 0

llvm/test/MC/RISCV/rv32zacas-valid.s

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# RUN: llvm-mc %s -triple=riscv32 -mattr=+zacas -riscv-no-aliases -show-encoding \
1+
# RUN: llvm-mc %s -triple=riscv32 -mattr=+a,+zacas -riscv-no-aliases -show-encoding \
22
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
3-
# RUN: llvm-mc %s -triple=riscv64 -mattr=+zacas -riscv-no-aliases -show-encoding \
3+
# RUN: llvm-mc %s -triple=riscv64 -mattr=+a,+zacas -riscv-no-aliases -show-encoding \
44
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
5-
# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+zacas < %s \
6-
# RUN: | llvm-objdump --mattr=+zacas -M no-aliases -d -r - \
5+
# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+a,+zacas < %s \
6+
# RUN: | llvm-objdump --mattr=+a,+zacas -M no-aliases -d -r - \
77
# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
8-
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+zacas < %s \
9-
# RUN: | llvm-objdump --mattr=+zacas -M no-aliases -d -r - \
8+
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+a,+zacas < %s \
9+
# RUN: | llvm-objdump --mattr=+a,+zacas -M no-aliases -d -r - \
1010
# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
1111
# RUN: not llvm-mc -triple=riscv32 -mattr=+a -show-encoding %s 2>&1 \
1212
# RUN: | FileCheck %s --check-prefix=CHECK-ERROR

llvm/test/MC/RISCV/rv64zacas-valid.s

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# RUN: llvm-mc %s -triple=riscv64 -mattr=+zacas -riscv-no-aliases -show-encoding \
1+
# RUN: llvm-mc %s -triple=riscv64 -mattr=+a,zacas -riscv-no-aliases -show-encoding \
22
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
3-
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+zacas < %s \
4-
# RUN: | llvm-objdump --mattr=+zacas -M no-aliases -d -r - \
3+
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+a,zacas < %s \
4+
# RUN: | llvm-objdump --mattr=+a,zacas -M no-aliases -d -r - \
55
# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
66
# RUN: not llvm-mc -triple=riscv64 -mattr=+a -show-encoding %s 2>&1 \
77
# RUN: | FileCheck %s --check-prefix=CHECK-ERROR

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# RUN: not llvm-mc -triple riscv32 -mattr=+experimental-zabha < %s 2>&1 | FileCheck %s
2-
# RUN: not llvm-mc -triple riscv64 -mattr=+experimental-zabha < %s 2>&1 | FileCheck %s
1+
# RUN: not llvm-mc -triple riscv32 -mattr=+a,+experimental-zabha < %s 2>&1 | FileCheck %s
2+
# RUN: not llvm-mc -triple riscv64 -mattr=+a,+experimental-zabha < %s 2>&1 | FileCheck %s
33

44
# Final operand must have parentheses
55
amoswap.b a1, a2, a3 # CHECK: :[[@LINE]]:19: error: expected '(' or optional integer offset

llvm/test/MC/RISCV/rvzabha-valid.s

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zabha -riscv-no-aliases -show-encoding \
1+
# RUN: llvm-mc %s -triple=riscv32 -mattr=+a,+experimental-zabha -riscv-no-aliases -show-encoding \
22
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
3-
# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zabha -riscv-no-aliases -show-encoding \
3+
# RUN: llvm-mc %s -triple=riscv64 -mattr=+a,+experimental-zabha -riscv-no-aliases -show-encoding \
44
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
5-
# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zabha < %s \
6-
# RUN: | llvm-objdump --mattr=+experimental-zabha -M no-aliases -d -r - \
5+
# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+a,+experimental-zabha < %s \
6+
# RUN: | llvm-objdump --mattr=+a,+experimental-zabha -M no-aliases -d -r - \
77
# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
8-
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zabha < %s \
9-
# RUN: | llvm-objdump --mattr=+experimental-zabha -M no-aliases -d -r - \
8+
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+a,+experimental-zabha < %s \
9+
# RUN: | llvm-objdump --mattr=+a,+experimental-zabha -M no-aliases -d -r - \
1010
# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
1111

1212
# CHECK-ASM-AND-OBJ: amoswap.b a4, ra, (s0)

llvm/test/MC/RISCV/rvzabha-zacas-valid.s

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zabha,+zacas -riscv-no-aliases -show-encoding \
1+
# RUN: llvm-mc %s -triple=riscv32 -mattr=+a,+experimental-zabha,+zacas -riscv-no-aliases -show-encoding \
22
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
3-
# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zabha,+zacas -riscv-no-aliases -show-encoding \
3+
# RUN: llvm-mc %s -triple=riscv64 -mattr=+a,+experimental-zabha,+zacas -riscv-no-aliases -show-encoding \
44
# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
5-
# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zabha,+zacas < %s \
6-
# RUN: | llvm-objdump --mattr=+experimental-zabha,+zacas -M no-aliases -d -r - \
5+
# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+a,+experimental-zabha,+zacas < %s \
6+
# RUN: | llvm-objdump --mattr=+a,+experimental-zabha,+zacas -M no-aliases -d -r - \
77
# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
8-
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zabha,+zacas < %s \
9-
# RUN: | llvm-objdump --mattr=+experimental-zabha,+zacas -M no-aliases -d -r - \
8+
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+a,+experimental-zabha,+zacas < %s \
9+
# RUN: | llvm-objdump --mattr=+a,+experimental-zabha,+zacas -M no-aliases -d -r - \
1010
# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
11-
# RUN: not llvm-mc -triple=riscv32 -mattr=+experimental-zabha -show-encoding %s 2>&1 \
11+
# RUN: not llvm-mc -triple=riscv32 -mattr=+a,+experimental-zabha -show-encoding %s 2>&1 \
1212
# RUN: | FileCheck %s --check-prefix=CHECK-ERROR
13-
# RUN: not llvm-mc -triple=riscv64 -mattr=+experimental-zabha -show-encoding %s 2>&1 \
13+
# RUN: not llvm-mc -triple=riscv64 -mattr=+a,+experimental-zabha -show-encoding %s 2>&1 \
1414
# RUN: | FileCheck %s --check-prefix=CHECK-ERROR
1515

1616
# CHECK-ASM-AND-OBJ: amocas.b a1, a3, (a5)

0 commit comments

Comments
 (0)