[llvm] 90f6a4c - [RISCV] Make D extension imply F extension.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 6 20:40:42 PST 2023


Author: Craig Topper
Date: 2023-03-06T19:59:47-08:00
New Revision: 90f6a4cc73d5c40add913e6ed5d34a7a9db58c79

URL: https://github.com/llvm/llvm-project/commit/90f6a4cc73d5c40add913e6ed5d34a7a9db58c79
DIFF: https://github.com/llvm/llvm-project/commit/90f6a4cc73d5c40add913e6ed5d34a7a9db58c79.diff

LOG: [RISCV] Make D extension imply F extension.

I believe this implies relationship is documented in the current
spec but may have been less clear in an older spec.

We used to report an error so I think it should be ok to change this.
Only someone expecting the error should be impacted.

Reviewed By: asb, luismarques

Differential Revision: https://reviews.llvm.org/D145125

Added: 
    

Modified: 
    clang/test/Driver/riscv-arch.c
    llvm/lib/Support/RISCVISAInfo.cpp

Removed: 
    


################################################################################
diff  --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c
index 26a58418fe457..3e9ff82fc8cf7 100644
--- a/clang/test/Driver/riscv-arch.c
+++ b/clang/test/Driver/riscv-arch.c
@@ -150,7 +150,7 @@
 
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32id -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32ID %s
-// RV32ID: error: invalid arch name 'rv32id'
+// RV32ID: "-target-feature" "+f" "-target-feature" "+d"
 
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32l -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32L %s
@@ -178,7 +178,7 @@
 
 // RUN: %clang --target=riscv64-unknown-elf -march=rv64id -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64ID %s
-// RV64ID: error: invalid arch name 'rv64id'
+// RV64ID: "-target-feature" "+f" "-target-feature" "+d"
 
 // RUN: %clang --target=riscv64-unknown-elf -march=rv64l -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64L %s
@@ -228,11 +228,6 @@
 // RV64-EER: error: invalid arch name 'rv64e',
 // RV64-EER: standard user-level extension 'e' requires 'rv32'
 
-// RUN: %clang --target=riscv32-unknown-elf -march=rv32id -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-DER %s
-// RV32-DER: error: invalid arch name 'rv32id',
-// RV32-DER: d requires f extension to also be specified
-
 // 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',

diff  --git a/llvm/lib/Support/RISCVISAInfo.cpp b/llvm/lib/Support/RISCVISAInfo.cpp
index d8702d7086189..fe923aa756832 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -839,14 +839,6 @@ Error RISCVISAInfo::checkDependency() {
         errc::invalid_argument,
         "standard user-level extension 'e' requires 'rv32'");
 
-  // It's illegal to specify the 'd' (double-precision floating point)
-  // extension without also specifying the 'f' (single precision
-  // floating-point) extension.
-  // TODO: This has been removed in later specs, which specify that D implies F
-  if (HasD && !HasF)
-    return createStringError(errc::invalid_argument,
-                             "d requires f extension to also be specified");
-
   if (HasZve32f && !HasF && !HasZfinx)
     return createStringError(
         errc::invalid_argument,
@@ -876,6 +868,7 @@ Error RISCVISAInfo::checkDependency() {
   return Error::success();
 }
 
+static const char *ImpliedExtsD[] = {"f"};
 static const char *ImpliedExtsV[] = {"zvl128b", "zve64d", "f", "d"};
 static const char *ImpliedExtsZfhmin[] = {"f"};
 static const char *ImpliedExtsZfh[] = {"f"};
@@ -920,6 +913,7 @@ struct ImpliedExtsEntry {
 
 // Note: The table needs to be sorted by name.
 static constexpr ImpliedExtsEntry ImpliedExts[] = {
+    {{"d"}, {ImpliedExtsD}},
     {{"v"}, {ImpliedExtsV}},
     {{"xtheadvdot"}, {ImpliedExtsXTHeadVdot}},
     {{"zcb"}, {ImpliedExtsZcb}},


        


More information about the llvm-commits mailing list