From: Scott Egerton Date: Thu, 9 Apr 2020 16:51:26 +0000 (+0100) Subject: [RISCV] Add Clang frontend support for Bitmanip extension X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=61ff29637501afcd7476e52064f7a266a95c6e28;p=platform%2Fupstream%2Fllvm.git [RISCV] Add Clang frontend support for Bitmanip extension This adds the __riscv_bitmanip macro and the 'b' target feature to enable it. Differential Revision: https://reviews.llvm.org/D71553 --- diff --git a/clang/lib/Basic/Targets/RISCV.cpp b/clang/lib/Basic/Targets/RISCV.cpp index ab8272c..5227764 100644 --- a/clang/lib/Basic/Targets/RISCV.cpp +++ b/clang/lib/Basic/Targets/RISCV.cpp @@ -125,6 +125,9 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts, if (HasC) Builder.defineMacro("__riscv_compressed"); + + if (HasB) + Builder.defineMacro("__riscv_bitmanip"); } /// Return true if has this feature, need to sync with handleTargetFeatures. @@ -139,6 +142,7 @@ bool RISCVTargetInfo::hasFeature(StringRef Feature) const { .Case("f", HasF) .Case("d", HasD) .Case("c", HasC) + .Case("experimental-b", HasB) .Default(false); } @@ -156,6 +160,8 @@ bool RISCVTargetInfo::handleTargetFeatures(std::vector &Features, HasD = true; else if (Feature == "+c") HasC = true; + else if (Feature == "+experimental-b") + HasB = true; } return true; diff --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h index 9118494..05da132 100644 --- a/clang/lib/Basic/Targets/RISCV.h +++ b/clang/lib/Basic/Targets/RISCV.h @@ -30,11 +30,12 @@ protected: bool HasF; bool HasD; bool HasC; + bool HasB; public: RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &) : TargetInfo(Triple), HasM(false), HasA(false), HasF(false), - HasD(false), HasC(false) { + HasD(false), HasC(false), HasB(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 a93d7e6..d8c18f7 100644 --- a/clang/test/Preprocessor/riscv-target-features.c +++ b/clang/test/Preprocessor/riscv-target-features.c @@ -7,6 +7,7 @@ // CHECK-NOT: __riscv_mul // CHECK-NOT: __riscv_muldiv // CHECK-NOT: __riscv_compressed +// CHECK-NOT: __riscv_bitmanip // CHECK-NOT: __riscv_flen // CHECK-NOT: __riscv_fdiv // CHECK-NOT: __riscv_fsqrt @@ -48,6 +49,12 @@ // RUN: -o - | FileCheck --check-prefix=CHECK-C-EXT %s // CHECK-C-EXT: __riscv_compressed 1 +// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions -march=rv32ib0p92 -x c -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s +// RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions -march=rv64ib0p92 -x c -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s +// CHECK-B-EXT: __riscv_bitmanip 1 + // RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ifd -mabi=ilp32 -x c -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-SOFT %s // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ifd -mabi=lp64 -x c -E -dM %s \