Author: echristo
Date: Wed Nov 11 18:44:07 2015
New Revision: 252833

URL: http://llvm.org/viewvc/llvm-project?rev=252833&view=rev
Log:
Move checkTargetFeatures to CodeGenFunction.cpp to make it
more obvious that it's generic.

Modified:
    cfe/trunk/lib/CodeGen/CGBuiltin.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=252833&r1=252832&r2=252833&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Nov 11 18:44:07 2015
@@ -21,7 +21,6 @@
 #include "clang/Basic/TargetBuiltins.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
-#include "clang/Sema/SemaDiagnostic.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/IR/CallSite.h"
 #include "llvm/IR/DataLayout.h"
@@ -343,47 +342,6 @@ Value *CodeGenFunction::EmitVAStartEnd(V
   return Builder.CreateCall(CGM.getIntrinsic(inst), ArgValue);
 }
 
-// Returns true if we have a valid set of target features.
-void CodeGenFunction::checkTargetFeatures(const CallExpr *E,
-                                          const FunctionDecl *TargetDecl) {
-  // Early exit if this is an indirect call.
-  if (!TargetDecl)
-    return;
-
-  // Get the current enclosing function if it exists. If it doesn't
-  // we can't check the target features anyhow.
-  const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(CurFuncDecl);
-  if (!FD)
-    return;
-
-  unsigned BuiltinID = TargetDecl->getBuiltinID();
-  const char *FeatureList =
-      CGM.getContext().BuiltinInfo.getRequiredFeatures(BuiltinID);
-
-  if (!FeatureList || StringRef(FeatureList) == "")
-    return;
-
-  llvm::StringMap<bool> FeatureMap;
-  CGM.getFunctionFeatureMap(FeatureMap, FD);
-
-  // If we have at least one of the features in the feature list return
-  // true, otherwise return false.
-  SmallVector<StringRef, 1> AttrFeatures;
-  StringRef(FeatureList).split(AttrFeatures, ",");
-  if (!std::all_of(AttrFeatures.begin(), AttrFeatures.end(),
-                     [&](StringRef &Feature) {
-                       SmallVector<StringRef, 1> OrFeatures;
-                       Feature.split(OrFeatures, "|");
-                       return std::any_of(OrFeatures.begin(), OrFeatures.end(),
-                                          [&](StringRef &Feature) {
-                                            return FeatureMap[Feature];
-                                          });
-                  }))
-    CGM.getDiags().Report(E->getLocStart(), diag::err_builtin_needs_feature)
-        << TargetDecl->getDeclName()
-        << CGM.getContext().BuiltinInfo.getRequiredFeatures(BuiltinID);
-}
-
 RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
                                         unsigned BuiltinID, const CallExpr *E,
                                         ReturnValueSlot ReturnValue) {

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=252833&r1=252832&r2=252833&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Wed Nov 11 18:44:07 2015
@@ -29,6 +29,7 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
 #include "clang/Frontend/CodeGenOptions.h"
+#include "clang/Sema/SemaDiagnostic.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/MDBuilder.h"
@@ -1841,3 +1842,45 @@ template void CGBuilderInserter<Preserve
     llvm::Instruction *I, const llvm::Twine &Name, llvm::BasicBlock *BB,
     llvm::BasicBlock::iterator InsertPt) const;
 #undef PreserveNames
+
+// Returns true if we have a valid set of target features.
+void CodeGenFunction::checkTargetFeatures(const CallExpr *E,
+                                          const FunctionDecl *TargetDecl) {
+  // Early exit if this is an indirect call.
+  if (!TargetDecl)
+    return;
+
+  // Get the current enclosing function if it exists. If it doesn't
+  // we can't check the target features anyhow.
+  const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(CurFuncDecl);
+  if (!FD)
+    return;
+
+  unsigned BuiltinID = TargetDecl->getBuiltinID();
+  const char *FeatureList =
+      CGM.getContext().BuiltinInfo.getRequiredFeatures(BuiltinID);
+
+  if (!FeatureList || StringRef(FeatureList) == "")
+    return;
+
+  llvm::StringMap<bool> FeatureMap;
+  CGM.getFunctionFeatureMap(FeatureMap, FD);
+
+  // If we have at least one of the features in the feature list return
+  // true, otherwise return false.
+  SmallVector<StringRef, 1> AttrFeatures;
+  StringRef(FeatureList).split(AttrFeatures, ",");
+  if (!std::all_of(AttrFeatures.begin(), AttrFeatures.end(),
+                     [&](StringRef &Feature) {
+                       SmallVector<StringRef, 1> OrFeatures;
+                       Feature.split(OrFeatures, "|");
+                       return std::any_of(OrFeatures.begin(), OrFeatures.end(),
+                                          [&](StringRef &Feature) {
+                                            return FeatureMap[Feature];
+                                          });
+                  }))
+    CGM.getDiags().Report(E->getLocStart(), diag::err_builtin_needs_feature)
+        << TargetDecl->getDeclName()
+        << CGM.getContext().BuiltinInfo.getRequiredFeatures(BuiltinID);
+}
+


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to