Commit 5e953a27 authored by Hsiangkai Wang's avatar Hsiangkai Wang
Browse files

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

Differential Revision: https://reviews.llvm.org/D92650
parent db226cdf
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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;
  }
+2 −1
Original line number Diff line number Diff line
@@ -31,12 +31,13 @@ protected:
  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();
+8 −0
Original line number Diff line number Diff line
@@ -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 \