[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 @@
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 @@
.Case("f", HasF)
.Case("d", HasD)
.Case("c", HasC)
+ .Case("experimental-b", HasB)
.Default(false);
}
@@ -156,6 +160,8 @@
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 @@
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();