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 @@ -417,6 +417,63 @@ // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-ZBA %s // RV32-EXPERIMENTAL-ZBA: "-target-feature" "+experimental-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=rv32ip0p96 -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=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=rv32izpn0p96 -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=rv32izpsfoperand0p96 -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=rv32iv -### %s -c 2>&1 | \ // RUN: FileCheck -check-prefix=RV32-EXPERIMENTAL-V-NOFLAG %s // RV32-EXPERIMENTAL-V-NOFLAG: error: invalid arch name 'rv32iv' 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 @@ -218,6 +218,34 @@ // CHECK-ZBT-NOT: __riscv_b // CHECK-ZBT-EXT: __riscv_zbt 93000 +// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions \ +// RUN: -march=rv32ip0p96 -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=rv64ip0p96 -x c -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-P-EXT %s +// CHECK-P-EXT: __riscv_p 96000 +// CHECK-P-EXT: __riscv_zpn 96000 +// CHECK-P-EXT: __riscv_zpsfoperand 96000 + +// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions \ +// RUN: -march=rv32izpn0p96 -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=rv64izpn0p96 -x c -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-ZPN-EXT %s +// CHECK-ZPN-NOT: __riscv_p +// CHECK-ZPN-EXT: __riscv_zpn 96000 + +// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions \ +// RUN: -march=rv32izpsfoperand0p96 -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=rv64izpsfoperand0p96 -x c -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-ZPSFOPERAND-EXT %s +// CHECK-ZPSFOPERAND-NOT: __riscv_p +// CHECK-ZPSFOPERAND-EXT: __riscv_zpsfoperand 96000 + // RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions \ // RUN: -march=rv32iv0p10 -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 @@ -50,6 +50,7 @@ static const RISCVSupportedExtension SupportedExperimentalExtensions[] = { {"b", RISCVExtensionVersion{0, 93}}, + {"p", RISCVExtensionVersion{0, 96}}, {"v", RISCVExtensionVersion{0, 10}}, {"zba", RISCVExtensionVersion{0, 93}}, {"zbb", RISCVExtensionVersion{0, 93}}, @@ -63,6 +64,9 @@ {"zbt", RISCVExtensionVersion{0, 93}}, {"zbproposedc", RISCVExtensionVersion{0, 93}}, + {"zpn", RISCVExtensionVersion{0, 96}}, + {"zpsfoperand", RISCVExtensionVersion{0, 96}}, + {"zvamo", RISCVExtensionVersion{0, 10}}, {"zvlsseg", RISCVExtensionVersion{0, 10}}, @@ -600,6 +604,11 @@ ISAInfo->addExtension("zbs", Major, Minor); ISAInfo->addExtension("zbt", Major, Minor); break; + case 'p': + ISAInfo->addExtension("p", Major, Minor); + ISAInfo->addExtension("zpn", Major, Minor); + ISAInfo->addExtension("zpsfoperand", Major, Minor); + break; case 'v': ISAInfo->addExtension("v", Major, Minor); ISAInfo->addExtension("zvlsseg", Major, Minor); diff --git a/llvm/test/CodeGen/RISCV/attributes.ll b/llvm/test/CodeGen/RISCV/attributes.ll --- a/llvm/test/CodeGen/RISCV/attributes.ll +++ b/llvm/test/CodeGen/RISCV/attributes.ll @@ -20,6 +20,9 @@ ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbs %s -o - | FileCheck --check-prefix=RV32ZBS %s ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbt %s -o - | FileCheck --check-prefix=RV32ZBT %s ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbb,+experimental-zfh,+experimental-zvamo,+experimental-v,+f,+experimental-zvlsseg %s -o - | FileCheck --check-prefix=RV32COMBINED %s +; RUN: llc -mtriple=riscv32 -mattr=+experimental-p %s -o - | FileCheck --check-prefix=RV32P %s +; RUN: llc -mtriple=riscv32 -mattr=+experimental-zpn %s -o - | FileCheck --check-prefix=RV32ZPN %s +; RUN: llc -mtriple=riscv32 -mattr=+experimental-zpsfoperand %s -o - | FileCheck --check-prefix=RV32ZPSFOPERAND %s ; RUN: llc -mtriple=riscv64 -mattr=+m %s -o - | FileCheck --check-prefix=RV64M %s ; RUN: llc -mtriple=riscv64 -mattr=+a %s -o - | FileCheck --check-prefix=RV64A %s ; RUN: llc -mtriple=riscv64 -mattr=+f %s -o - | FileCheck --check-prefix=RV64F %s @@ -40,6 +43,9 @@ ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbs %s -o - | FileCheck --check-prefix=RV64ZBS %s ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbt %s -o - | FileCheck --check-prefix=RV64ZBT %s ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbb,+experimental-zfh,+experimental-zvamo,+experimental-v,+f,+experimental-zvlsseg %s -o - | FileCheck --check-prefix=RV64COMBINED %s +; RUN: llc -mtriple=riscv64 -mattr=+experimental-p %s -o - | FileCheck --check-prefix=RV64P %s +; RUN: llc -mtriple=riscv64 -mattr=+experimental-zpn %s -o - | FileCheck --check-prefix=RV64ZPN %s +; RUN: llc -mtriple=riscv64 -mattr=+experimental-zpsfoperand %s -o - | FileCheck --check-prefix=RV64ZPSFOPERAND %s ; RV32M: .attribute 5, "rv32i2p0_m2p0" ; RV32A: .attribute 5, "rv32i2p0_a2p0" @@ -61,6 +67,9 @@ ; RV32ZBS: .attribute 5, "rv32i2p0_zbs0p93" ; RV32ZBT: .attribute 5, "rv32i2p0_zbt0p93" ; RV32COMBINED: .attribute 5, "rv32i2p0_f2p0_v0p10_zfh0p1_zbb0p93_zvamo0p10_zvlsseg0p10" +; RV32P: .attribute 5, "rv32i2p0_p0p96_zpn0p96_zpsfoperand0p96" +; RV32ZPN: .attribute 5, "rv32i2p0_zpn0p96" +; RV32ZPSFOPERAND: .attribute 5, "rv32i2p0_zpsfoperand0p96" ; RV64M: .attribute 5, "rv64i2p0_m2p0" ; RV64A: .attribute 5, "rv64i2p0_a2p0" @@ -82,6 +91,9 @@ ; RV64ZBT: .attribute 5, "rv64i2p0_zbt0p93" ; RV64V: .attribute 5, "rv64i2p0_v0p10_zvamo0p10_zvlsseg0p10" ; RV64COMBINED: .attribute 5, "rv64i2p0_f2p0_v0p10_zfh0p1_zbb0p93_zvamo0p10_zvlsseg0p10" +; RV64P: .attribute 5, "rv64i2p0_p0p96_zpn0p96_zpsfoperand0p96" +; RV64ZPN: .attribute 5, "rv64i2p0_zpn0p96" +; RV64ZPSFOPERAND: .attribute 5, "rv64i2p0_zpsfoperand0p96" define i32 @addi(i32 %a) { 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 @@ -36,6 +36,9 @@ .attribute arch, "rv32ib" # CHECK: attribute 5, "rv32i2p0_b0p93_zba0p93_zbb0p93_zbc0p93_zbe0p93_zbf0p93_zbm0p93_zbp0p93_zbr0p93_zbs0p93_zbt0p93" +.attribute arch, "rv32ip" +# CHECK: attribute 5, "rv32i2p0_p0p96_zpn0p96_zpsfoperand0p96" + .attribute arch, "rv32iv" # CHECK: attribute 5, "rv32i2p0_v0p10_zvlsseg0p10" @@ -72,6 +75,12 @@ .attribute arch, "rv32izbt" # CHECK: attribute 5, "rv32i2p0_zbt0p93" +.attribute arch, "rv32izpn" +# CHECK: attribute 5, "rv32i2p0_zpn0p96" + +.attribute arch, "rv32izpsfoperand" +# CHECK: attribute 5, "rv32i2p0_zpsfoperand0p96" + .attribute arch, "rv32ifzfh" # CHECK: attribute 5, "rv32i2p0_f2p0_zfh0p1"