diff --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp --- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp +++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp @@ -62,6 +62,8 @@ Ext == "zbe" || Ext == "zbf" || Ext == "zbm" || Ext == "zbp" || Ext == "zbr" || Ext == "zbs" || Ext == "zbt" || Ext == "zbproposedc") return RISCVExtensionVersion{"0", "93"}; + if (Ext == "p") + return RISCVExtensionVersion{"0", "9"}; if (Ext == "v" || Ext == "zvamo" || Ext == "zvlsseg") return RISCVExtensionVersion{"1", "0"}; if (Ext == "zfh") @@ -427,6 +429,9 @@ Features.push_back("+experimental-zbs"); Features.push_back("+experimental-zbt"); break; + case 'p': + Features.push_back("+experimental-p"); + break; case 'v': Features.push_back("+experimental-v"); Features.push_back("+experimental-zvamo"); 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 @@ -369,6 +369,25 @@ // 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=rv32ip0p9 -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=rv32iv -### %s -c 2>&1 | \ // RUN: FileCheck -check-prefix=RV32-EXPERIMENTAL-V-NOFLAG %s // RV32-EXPERIMENTAL-V-NOFLAG: error: invalid arch name 'rv32iv'