diff --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h --- 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(); diff --git a/clang/lib/Basic/Targets/RISCV.cpp b/clang/lib/Basic/Targets/RISCV.cpp --- a/clang/lib/Basic/Targets/RISCV.cpp +++ b/clang/lib/Basic/Targets/RISCV.cpp @@ -125,6 +125,10 @@ 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 +143,7 @@ .Case("f", HasF) .Case("d", HasD) .Case("c", HasC) + .Case("b", HasB) .Default(false); } @@ -156,6 +161,8 @@ HasD = true; else if (Feature == "+c") HasC = true; + else if (Feature == "+b") + HasB = true; } return true; diff --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp --- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp +++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp @@ -331,6 +331,9 @@ case 'c': Features.push_back("+c"); break; + case 'b': + Features.push_back("+b"); + break; } }