diff --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c --- a/clang/test/Driver/riscv-arch.c +++ b/clang/test/Driver/riscv-arch.c @@ -452,6 +452,82 @@ // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZBA %s // RV32-ZBA: "-target-feature" "+zba" +// RUN: %clang -target riscv32-unknown-elf -march=rv32ip -### %s -c 2>&1 | \ +// RUN: FileCheck -check-prefix=RV32-EXPERIMENTAL-P-NOFLAG %s +// RV32-EXPERIMENTAL-P-NOFLAG: error: invalid arch name 'rv32ip' +// RV32-EXPERIMENTAL-P-NOFLAG: requires '-menable-experimental-extensions' + +// RUN: %clang -target riscv32-unknown-elf -march=rv32ip -menable-experimental-extensions -### %s -c 2>&1 | \ +// RUN: FileCheck -check-prefix=RV32-EXPERIMENTAL-P-NOVERS %s +// RV32-EXPERIMENTAL-P-NOVERS: error: invalid arch name 'rv32ip' +// RV32-EXPERIMENTAL-P-NOVERS: experimental extension requires explicit version number + +// RUN: %clang -target riscv32-unknown-elf -march=rv32ip0p1 -menable-experimental-extensions -### %s -c 2>&1 | \ +// RUN: FileCheck -check-prefix=RV32-EXPERIMENTAL-P-BADVERS %s +// RV32-EXPERIMENTAL-P-BADVERS: error: invalid arch name 'rv32ip0p1' +// RV32-EXPERIMENTAL-P-BADVERS: unsupported version number 0.1 for experimental extension + +// RUN: %clang -target riscv32-unknown-elf -march=rv32ip0p911 -menable-experimental-extensions -### %s -c 2>&1 | \ +// RUN: FileCheck -check-prefix=RV32-EXPERIMENTAL-P-GOODVERS %s +// RV32-EXPERIMENTAL-P-GOODVERS: "-target-feature" "+experimental-p" + +// RUN: %clang -target riscv32-unknown-elf -march=rv32izbpbo -### %s -c 2>&1 | \ +// RUN: FileCheck -check-prefix=RV32-EXPERIMENTAL-ZBPBO-NOFLAG %s +// RV32-EXPERIMENTAL-ZBPBO-NOFLAG: error: invalid arch name 'rv32izbpbo' +// RV32-EXPERIMENTAL-ZBPBO-NOFLAG: requires '-menable-experimental-extensions' + +// RUN: %clang -target riscv32-unknown-elf -march=rv32izbpbo -menable-experimental-extensions -### %s -c 2>&1 | \ +// RUN: FileCheck -check-prefix=RV32-EXPERIMENTAL-ZBPBO-NOVERS %s +// RV32-EXPERIMENTAL-ZBPBO-NOVERS: error: invalid arch name 'rv32izbpbo' +// RV32-EXPERIMENTAL-ZBPBO-NOVERS: experimental extension requires explicit version number + +// RUN: %clang -target riscv32-unknown-elf -march=rv32izbpbo0p1 -menable-experimental-extensions -### %s -c 2>&1 | \ +// RUN: FileCheck -check-prefix=RV32-EXPERIMENTAL-ZBPBO-BADVERS %s +// RV32-EXPERIMENTAL-ZBPBO-BADVERS: error: invalid arch name 'rv32izbpbo0p1' +// RV32-EXPERIMENTAL-ZBPBO-BADVERS: unsupported version number 0.1 for experimental extension + +// RUN: %clang -target riscv32-unknown-elf -march=rv32izbpbo0p911 -menable-experimental-extensions -### %s -c 2>&1 | \ +// RUN: FileCheck -check-prefix=RV32-EXPERIMENTAL-ZBPBO-GOODVERS %s +// RV32-EXPERIMENTAL-ZBPBO-GOODVERS: "-target-feature" "+experimental-zbpbo" + +// RUN: %clang -target riscv32-unknown-elf -march=rv32izpn -### %s -c 2>&1 | \ +// RUN: FileCheck -check-prefix=RV32-EXPERIMENTAL-ZPN-NOFLAG %s +// RV32-EXPERIMENTAL-ZPN-NOFLAG: error: invalid arch name 'rv32izpn' +// RV32-EXPERIMENTAL-ZPN-NOFLAG: requires '-menable-experimental-extensions' + +// RUN: %clang -target riscv32-unknown-elf -march=rv32izpn -menable-experimental-extensions -### %s -c 2>&1 | \ +// RUN: FileCheck -check-prefix=RV32-EXPERIMENTAL-ZPN-NOVERS %s +// RV32-EXPERIMENTAL-ZPN-NOVERS: error: invalid arch name 'rv32izpn' +// RV32-EXPERIMENTAL-ZPN-NOVERS: experimental extension requires explicit version number + +// RUN: %clang -target riscv32-unknown-elf -march=rv32izpn0p1 -menable-experimental-extensions -### %s -c 2>&1 | \ +// RUN: FileCheck -check-prefix=RV32-EXPERIMENTAL-ZPN-BADVERS %s +// RV32-EXPERIMENTAL-ZPN-BADVERS: error: invalid arch name 'rv32izpn0p1' +// RV32-EXPERIMENTAL-ZPN-BADVERS: unsupported version number 0.1 for experimental extension + +// RUN: %clang -target riscv32-unknown-elf -march=rv32izpn0p911 -menable-experimental-extensions -### %s -c 2>&1 | \ +// RUN: FileCheck -check-prefix=RV32-EXPERIMENTAL-ZPN-GOODVERS %s +// RV32-EXPERIMENTAL-ZPN-GOODVERS: "-target-feature" "+experimental-zpn" + +// RUN: %clang -target riscv32-unknown-elf -march=rv32izpsfoperand -### %s -c 2>&1 | \ +// RUN: FileCheck -check-prefix=RV32-EXPERIMENTAL-ZPSFOPERAND-NOFLAG %s +// RV32-EXPERIMENTAL-ZPSFOPERAND-NOFLAG: error: invalid arch name 'rv32izpsfoperand' +// RV32-EXPERIMENTAL-ZPSFOPERAND-NOFLAG: requires '-menable-experimental-extensions' + +// RUN: %clang -target riscv32-unknown-elf -march=rv32izpsfoperand -menable-experimental-extensions -### %s -c 2>&1 | \ +// RUN: FileCheck -check-prefix=RV32-EXPERIMENTAL-ZPSFOPERAND-NOVERS %s +// RV32-EXPERIMENTAL-ZPSFOPERAND-NOVERS: error: invalid arch name 'rv32izpsfoperand' +// RV32-EXPERIMENTAL-ZPSFOPERAND-NOVERS: experimental extension requires explicit version number + +// RUN: %clang -target riscv32-unknown-elf -march=rv32izpsfoperand0p1 -menable-experimental-extensions -### %s -c 2>&1 | \ +// RUN: FileCheck -check-prefix=RV32-EXPERIMENTAL-ZPSFOPERAND-BADVERS %s +// RV32-EXPERIMENTAL-ZPSFOPERAND-BADVERS: error: invalid arch name 'rv32izpsfoperand0p1' +// RV32-EXPERIMENTAL-ZPSFOPERAND-BADVERS: unsupported version number 0.1 for experimental extension + +// RUN: %clang -target riscv32-unknown-elf -march=rv32izpsfoperand0p911 -menable-experimental-extensions -### %s -c 2>&1 | \ +// RUN: FileCheck -check-prefix=RV32-EXPERIMENTAL-ZPSFOPERAND-GOODVERS %s +// RV32-EXPERIMENTAL-ZPSFOPERAND-GOODVERS: "-target-feature" "+experimental-zpsfoperand" + // RUN: %clang --target=riscv32-unknown-elf -march=rv32iv0p1 -### %s -c 2>&1 | \ // RUN: FileCheck -check-prefix=RV32-V-BADVERS %s // RV32-V-BADVERS: error: invalid arch name 'rv32iv0p1' diff --git a/clang/test/Preprocessor/riscv-target-features.c b/clang/test/Preprocessor/riscv-target-features.c --- a/clang/test/Preprocessor/riscv-target-features.c +++ b/clang/test/Preprocessor/riscv-target-features.c @@ -42,6 +42,10 @@ // CHECK-NOT: __riscv_zkr // CHECK-NOT: __riscv_zkt // CHECK-NOT: __riscv_zk +// CHECK-NOT: __riscv_p +// CHECK-NOT: __riscv_zbpbo +// CHECK-NOT: __riscv_zpn +// CHECK-NOT: __riscv_zpsfoperand // CHECK-NOT: __riscv_zicbom // CHECK-NOT: __riscv_zicboz @@ -224,6 +228,44 @@ // CHECK-ZBT-NOT: __riscv_b // CHECK-ZBT-EXT: __riscv_zbt 93000{{$}} +// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions \ +// RUN: -march=rv32ip0p911 -x c -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-P-EXT %s +// RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions \ +// RUN: -march=rv64ip0p911 -x c -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-P-EXT %s +// CHECK-P-EXT: __riscv_p 911000{{$}} +// CHECK-P-EXT: __riscv_zbpbo 911000{{$}} +// CHECK-P-EXT: __riscv_zpn 911000{{$}} +// CHECK-P-EXT: __riscv_zpsfoperand 911000{{$}} + +// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions \ +// RUN: -march=rv32izbpbo0p911 -x c -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-ZBPBO-EXT %s +// RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions \ +// RUN: -march=rv64izbpbo0p911 -x c -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-ZBPBO-EXT %s +// CHECK-ZBPBO-NOT: __riscv_p +// CHECK-ZBPBO-EXT: __riscv_zbpbo 911000{{$}} + +// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions \ +// RUN: -march=rv32izpn0p911 -x c -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-ZPN-EXT %s +// RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions \ +// RUN: -march=rv64izpn0p911 -x c -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-ZPN-EXT %s +// CHECK-ZPN-NOT: __riscv_p +// CHECK-ZPN-EXT: __riscv_zpn 911000{{$}} + +// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions \ +// RUN: -march=rv32izpsfoperand0p911 -x c -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-ZPSFOPERAND-EXT %s +// RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions \ +// RUN: -march=rv64izpsfoperand0p911 -x c -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-ZPSFOPERAND-EXT %s +// CHECK-ZPSFOPERAND-NOT: __riscv_p +// CHECK-ZPSFOPERAND-EXT: __riscv_zpsfoperand 911000{{$}} + // RUN: %clang -target riscv32-unknown-linux-gnu \ // RUN: -march=rv32iv1p0 -x c -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-V-EXT %s diff --git a/llvm/lib/Support/RISCVISAInfo.cpp b/llvm/lib/Support/RISCVISAInfo.cpp --- a/llvm/lib/Support/RISCVISAInfo.cpp +++ b/llvm/lib/Support/RISCVISAInfo.cpp @@ -109,6 +109,11 @@ {"zbr", RISCVExtensionVersion{0, 93}}, {"zbt", RISCVExtensionVersion{0, 93}}, {"zvfh", RISCVExtensionVersion{0, 1}}, + + {"p", RISCVExtensionVersion{0, 911}}, + {"zbpbo", RISCVExtensionVersion{0, 911}}, + {"zpn", RISCVExtensionVersion{0, 911}}, + {"zpsfoperand", RISCVExtensionVersion{0, 911}}, }; static bool stripExperimentalPrefix(StringRef &Ext) { @@ -598,8 +603,8 @@ // The order is OK, then push it into features. // TODO: Use version number when setting target features - // Currently LLVM supports only "mafdcbv". - StringRef SupportedStandardExtension = "mafdcbv"; + // Currently LLVM supports only "mafdcbpv". + StringRef SupportedStandardExtension = "mafdcbpv"; if (!SupportedStandardExtension.contains(C)) return createStringError(errc::invalid_argument, "unsupported standard user-level extension '%c'", @@ -773,6 +778,7 @@ static const char *ImpliedExtsZkn[] = {"zbkb", "zbkc", "zbkx", "zkne", "zknd", "zknh"}; static const char *ImpliedExtsZks[] = {"zbkb", "zbkc", "zbkx", "zksed", "zksh"}; static const char *ImpliedExtsZvfh[] = {"zve32f"}; +static const char *ImpliedExtsP[] = {"zbpbo", "zpn", "zpsfoperand"}; struct ImpliedExtsEntry { StringLiteral Name; @@ -787,6 +793,7 @@ // Note: The table needs to be sorted by name. static constexpr ImpliedExtsEntry ImpliedExts[] = { + {{"p"}, {ImpliedExtsP}}, {{"v"}, {ImpliedExtsV}}, {{"zdinx"}, {ImpliedExtsZdinx}}, {{"zfh"}, {ImpliedExtsZfh}}, diff --git a/llvm/test/MC/RISCV/attribute-arch.s b/llvm/test/MC/RISCV/attribute-arch.s --- a/llvm/test/MC/RISCV/attribute-arch.s +++ b/llvm/test/MC/RISCV/attribute-arch.s @@ -187,3 +187,15 @@ .attribute arch, "rv32if_zkt1p0_zve32f1p0_zve32x1p0_zvl32b1p0" # CHECK: attribute 5, "rv32i2p0_f2p0_zkt1p0_zve32f1p0_zve32x1p0_zvl32b1p0" + +.attribute arch, "rv32ip0p911" +# CHECK: attribute 5, "rv32i2p0_p0p911_zbpbo0p911_zpn0p911_zpsfoperand0p911" + +.attribute arch, "rv32izbpbo0p911" +# CHECK: attribute 5, "rv32i2p0_zbpbo0p911" + +.attribute arch, "rv32izpn0p911" +# CHECK: attribute 5, "rv32i2p0_zpn0p911" + +.attribute arch, "rv32izpsfoperand0p911" +# CHECK: attribute 5, "rv32i2p0_zpsfoperand0p911"