[PATCH] D71553: [RISCV] Add Clang frontend support for Bitmanip extension

Scott Egerton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 16 08:43:31 PST 2019


s.egerton created this revision.
s.egerton added reviewers: asb, simoncook, lewis-revill, PaoloS, lenary.
Herald added subscribers: cfe-commits, luismarques, apazos, sameer.abuasal, pzheng, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, MaskRay, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, johnrusso, rbar.
Herald added a project: clang.

This adds the __riscv_bitmanip macro and the 'b' target feature to enable it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71553

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp


Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ 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;
     }
   }
 
Index: clang/lib/Basic/Targets/RISCV.h
===================================================================
--- clang/lib/Basic/Targets/RISCV.h
+++ 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();
Index: clang/lib/Basic/Targets/RISCV.cpp
===================================================================
--- clang/lib/Basic/Targets/RISCV.cpp
+++ 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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71553.234078.patch
Type: text/x-patch
Size: 1697 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191216/98310230/attachment.bin>


More information about the cfe-commits mailing list