]> granicus.if.org Git - clang/commitdiff
bpf: Hook target feature "alu32" with LLVM
authorYonghong Song <yhs@fb.com>
Fri, 23 Feb 2018 23:55:29 +0000 (23:55 +0000)
committerYonghong Song <yhs@fb.com>
Fri, 23 Feb 2018 23:55:29 +0000 (23:55 +0000)
LLVM has supported a new target feature "alu32" which could be enabled or
disabled by "-mattr=[+|-]alu32" when using llc.

This patch link Clang with it, so it could be also done by passing related
options to Clang, for example:

  -Xclang -target-feature -Xclang +alu32

Signed-off-by: Jiong Wang <jiong.wang@netronome.com>
Reviewed-by: Yonghong Song <yhs@fb.com>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325996 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/Targets/BPF.h

index 836e47554bc0e8c580c0f0e46f2c98b52b0798a4..36d2da4dbf308027d7c9e8577601be4a5b8e0cad 100644 (file)
@@ -46,7 +46,14 @@ public:
   void getTargetDefines(const LangOptions &Opts,
                         MacroBuilder &Builder) const override;
 
-  bool hasFeature(StringRef Feature) const override { return Feature == "bpf"; }
+  bool hasFeature(StringRef Feature) const override {
+    return Feature == "bpf" || Feature == "alu32";
+  }
+
+  void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
+                         bool Enabled) const override {
+    Features[Name] = Enabled;
+  }
 
   ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }