[llvm-branch-commits] [clang] 5e953a2 - [RISCV] Define preprocessor definitions for 'V' extension.

Hsiangkai Wang via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Dec 4 16:39:18 PST 2020


Author: Hsiangkai Wang
Date: 2020-12-05T08:34:32+08:00
New Revision: 5e953a274b2ada5bfa54b3d765e391abb03f474f

URL: https://github.com/llvm/llvm-project/commit/5e953a274b2ada5bfa54b3d765e391abb03f474f
DIFF: https://github.com/llvm/llvm-project/commit/5e953a274b2ada5bfa54b3d765e391abb03f474f.diff

LOG: [RISCV] Define preprocessor definitions for 'V' extension.

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

Added: 
    

Modified: 
    clang/lib/Basic/Targets/RISCV.cpp
    clang/lib/Basic/Targets/RISCV.h
    clang/test/Preprocessor/riscv-target-features.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Basic/Targets/RISCV.cpp b/clang/lib/Basic/Targets/RISCV.cpp
index 2b076c9c16f2..4436db904d59 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -136,6 +136,9 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts,
   if (HasB)
     Builder.defineMacro("__riscv_bitmanip");
 
+  if (HasV)
+    Builder.defineMacro("__riscv_vector");
+
   if (HasZfh)
     Builder.defineMacro("__riscv_zfh");
 }
@@ -153,6 +156,7 @@ bool RISCVTargetInfo::hasFeature(StringRef Feature) const {
       .Case("d", HasD)
       .Case("c", HasC)
       .Case("experimental-b", HasB)
+      .Case("experimental-v", HasV)
       .Case("experimental-zfh", HasZfh)
       .Default(false);
 }
@@ -173,6 +177,8 @@ bool RISCVTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
       HasC = true;
     else if (Feature == "+experimental-b")
       HasB = true;
+    else if (Feature == "+experimental-v")
+      HasV = true;
     else if (Feature == "+experimental-zfh")
       HasZfh = true;
   }

diff  --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h
index 20a7b1c73175..8430407b041e 100644
--- a/clang/lib/Basic/Targets/RISCV.h
+++ b/clang/lib/Basic/Targets/RISCV.h
@@ -31,12 +31,13 @@ class RISCVTargetInfo : public TargetInfo {
   bool HasD;
   bool HasC;
   bool HasB;
+  bool HasV;
   bool HasZfh;
 
 public:
   RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
       : TargetInfo(Triple), HasM(false), HasA(false), HasF(false), HasD(false),
-        HasC(false), HasB(false), HasZfh(false) {
+        HasC(false), HasB(false), HasV(false), HasZfh(false) {
     LongDoubleWidth = 128;
     LongDoubleAlign = 128;
     LongDoubleFormat = &llvm::APFloat::IEEEquad();

diff  --git a/clang/test/Preprocessor/riscv-target-features.c b/clang/test/Preprocessor/riscv-target-features.c
index c0ffd83bc7e2..d60e7039a92f 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -79,6 +79,14 @@
 // CHECK-DOUBLE-NOT: __riscv_float_abi_soft
 // CHECK-DOUBLE-NOT: __riscv_float_abi_single
 
+// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions \
+// RUN:   -march=rv32iv0p9 -x c -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-V-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions \
+// RUN:   -march=rv64iv0p9 -x c -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-V-EXT %s
+// CHECK-V-EXT: __riscv_vector 1
+//
 // RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions -march=rv32izfh0p1 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZFH-EXT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions -march=rv64izfh0p1 -x c -E -dM %s \


        


More information about the llvm-branch-commits mailing list