Skip to content

Commit

Permalink
[RISCV] Make zve32f imply F and zve64d imply D.
Browse files Browse the repository at this point in the history
The 1.0 vector spec PDF has text that says that Zve32f is compatible
with F or Zfinx and that Zve64d is compatible with D and Zdinx.
The references to *inx were removed from the spec in the github repository in
October 2021. The 1.0 pdf was made in September 2021.

Relevant commit riscv/riscv-v-spec@6fedb86

Reviewed By: jacquesguan

Differential Revision: https://reviews.llvm.org/D150021
  • Loading branch information
topperc committed May 7, 2023
1 parent df722b0 commit 728b8a1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 46 deletions.
24 changes: 1 addition & 23 deletions clang/test/Driver/riscv-arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,6 @@
// RV32-ORDER: error: invalid arch name 'rv32imcq',
// RV32-ORDER: standard user-level extension not given in canonical order 'q'

// RUN: %clang --target=riscv32-unknown-elf -march=rv32izve32f -### %s \
// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZVE32F-ER %s
// RV32-ZVE32F-ER: error: invalid arch name 'rv32izve32f',
// RV32-ZVE32F-ER: 'zve32f' requires 'f' or 'zfinx' extension to also be specified

// RUN: %clang --target=riscv32-unknown-elf -march=rv32ifzve64d -### %s \
// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZVE64D-ER %s
// RV32-ZVE64D-ER: error: invalid arch name 'rv32ifzve64d',
// RV32-ZVE64D-ER: 'zve64d' requires 'd' or 'zdinx' extension to also be specified

// RUN: %clang --target=riscv32-unknown-elf -march=rv32izvl64b -### %s \
// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZVL64B-ER %s
// RV32-ZVL64B-ER: error: invalid arch name 'rv32izvl64b',
Expand Down Expand Up @@ -498,10 +488,6 @@
// RV32-ZVE32X-GOODVERS: "-target-feature" "+zve32x"

// RUN: %clang --target=riscv32-unknown-elf -march=rv32izve32f -### %s -c 2>&1 | \
// RUN: FileCheck -check-prefix=RV32-ZVE32F-REQUIRE-F %s
// RV32-ZVE32F-REQUIRE-F: error: invalid arch name 'rv32izve32f', 'zve32f' requires 'f' or 'zfinx' extension to also be specified

// RUN: %clang --target=riscv32-unknown-elf -march=rv32ifzve32f -### %s -c 2>&1 | \
// RUN: FileCheck -check-prefix=RV32-ZVE32F-GOOD %s
// RV32-ZVE32F-GOOD: "-target-feature" "+zve32f"

Expand All @@ -510,18 +496,10 @@
// RV32-ZVE64X: "-target-feature" "+zve64x"

// RUN: %clang --target=riscv32-unknown-elf -march=rv32izve64f -### %s -c 2>&1 | \
// RUN: FileCheck -check-prefix=RV32-ZVE64F-REQUIRE-F %s
// RV32-ZVE64F-REQUIRE-F: error: invalid arch name 'rv32izve64f', 'zve32f' requires 'f' or 'zfinx' extension to also be specified

// RUN: %clang --target=riscv32-unknown-elf -march=rv32ifzve64f -### %s -c 2>&1 | \
// RUN: FileCheck -check-prefix=RV32-ZVE64F-GOOD %s
// RV32-ZVE64F-GOOD: "-target-feature" "+zve64f"

// RUN: %clang --target=riscv32-unknown-elf -march=rv32ifzve64d -### %s -c 2>&1 | \
// RUN: FileCheck -check-prefix=RV32-ZVE64D-REQUIRE-D %s
// RV32-ZVE64D-REQUIRE-D: error: invalid arch name 'rv32ifzve64d', 'zve64d' requires 'd' or 'zdinx' extension to also be specified

// RUN: %clang --target=riscv32-unknown-elf -march=rv32ifdzve64d -### %s -c 2>&1 | \
// RUN: %clang --target=riscv32-unknown-elf -march=rv32izve64d -### %s -c 2>&1 | \
// RUN: FileCheck -check-prefix=RV32-ZVE64D-GOOD %s
// RV32-ZVE64D-GOOD: "-target-feature" "+zve64d"

Expand Down
2 changes: 2 additions & 0 deletions llvm/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ Changes to the RISC-V Backend
RISCVTargetParser.h interface. Similar for ``parseTuneCPUkind`` and
``checkTuneCPUKind``.
* Add sifive-x280 processor.
* Zve32f is no longer allowed with Zfinx. Zve64d is no longer allowed with
Zdinx.

Changes to the WebAssembly Backend
----------------------------------
Expand Down
23 changes: 4 additions & 19 deletions llvm/lib/Support/RISCVISAInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -856,10 +856,7 @@ Error RISCVISAInfo::checkDependency() {
bool HasD = Exts.count("d") != 0;
bool HasF = Exts.count("f") != 0;
bool HasZfinx = Exts.count("zfinx") != 0;
bool HasZdinx = Exts.count("zdinx") != 0;
bool HasVector = Exts.count("zve32x") != 0;
bool HasZve32f = Exts.count("zve32f") != 0;
bool HasZve64d = Exts.count("zve64d") != 0;
bool HasZvl = MinVLen != 0;
bool HasZcmt = Exts.count("zcmt") != 0;
bool HasZcd = Exts.count("zcd") != 0;
Expand All @@ -868,22 +865,10 @@ Error RISCVISAInfo::checkDependency() {
return createStringError(errc::invalid_argument,
"'f' and 'zfinx' extensions are incompatible");

if (HasZve32f && !HasF && !HasZfinx)
if (Exts.count("zvfh") && !Exts.count("zfh") && !Exts.count("zfhmin"))
return createStringError(
errc::invalid_argument,
"'zve32f' requires 'f' or 'zfinx' extension to also be specified");

if (HasZve64d && !HasD && !HasZdinx)
return createStringError(
errc::invalid_argument,
"'zve64d' requires 'd' or 'zdinx' extension to also be specified");

if (Exts.count("zvfh") && !Exts.count("zfh") && !Exts.count("zfhmin") &&
!Exts.count("zhinx") && !Exts.count("zhinxmin"))
return createStringError(
errc::invalid_argument,
"'zvfh' requires 'zfh', 'zfhmin', 'zhinx' or 'zhinxmin' extension to "
"also be specified");
"'zvfh' requires 'zfh' or 'zfhmin extension to also be specified");

if (HasZvl && !HasVector)
return createStringError(
Expand Down Expand Up @@ -949,9 +934,9 @@ static const char *ImpliedExtsZk[] = {"zkn", "zkt", "zkr"};
static const char *ImpliedExtsZkn[] = {"zbkb", "zbkc", "zbkx",
"zkne", "zknd", "zknh"};
static const char *ImpliedExtsZks[] = {"zbkb", "zbkc", "zbkx", "zksed", "zksh"};
static const char *ImpliedExtsZve32f[] = {"zve32x"};
static const char *ImpliedExtsZve32f[] = {"zve32x", "f"};
static const char *ImpliedExtsZve32x[] = {"zvl32b", "zicsr"};
static const char *ImpliedExtsZve64d[] = {"zve64f"};
static const char *ImpliedExtsZve64d[] = {"zve64f", "d"};
static const char *ImpliedExtsZve64f[] = {"zve64x", "zve32f"};
static const char *ImpliedExtsZve64x[] = {"zve32x", "zvl64b"};
static const char *ImpliedExtsZvfh[] = {"zve32f"};
Expand Down
7 changes: 3 additions & 4 deletions llvm/lib/Target/RISCV/RISCVFeatures.td
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def FeatureStdExtZve32f
: SubtargetFeature<"zve32f", "HasStdExtZve32f", "true",
"'Zve32f' (Vector Extensions for Embedded Processors "
"with maximal 32 EEW and F extension)",
[FeatureStdExtZve32x]>;
[FeatureStdExtZve32x, FeatureStdExtF]>;

def FeatureStdExtZve64x
: SubtargetFeature<"zve64x", "HasStdExtZve64x", "true",
Expand All @@ -415,13 +415,12 @@ def FeatureStdExtZve64d
: SubtargetFeature<"zve64d", "HasStdExtZve64d", "true",
"'Zve64d' (Vector Extensions for Embedded Processors "
"with maximal 64 EEW, F and D extension)",
[FeatureStdExtZve64f]>;
[FeatureStdExtZve64f, FeatureStdExtD]>;

def FeatureStdExtV
: SubtargetFeature<"v", "HasStdExtV", "true",
"'V' (Vector Extension for Application Processors)",
[FeatureStdExtZvl128b, FeatureStdExtZve64d,
FeatureStdExtF, FeatureStdExtD]>;
[FeatureStdExtZvl128b, FeatureStdExtZve64d]>;

def HasVInstructions : Predicate<"Subtarget->hasVInstructions()">,
AssemblerPredicate<
Expand Down

0 comments on commit 728b8a1

Please sign in to comment.