13#ifndef LLVM_CLANG_LIB_BASIC_BUILTINTARGETFEATURES_H
14#define LLVM_CLANG_LIB_BASIC_BUILTINTARGETFEATURES_H
15#include "llvm/ADT/StringMap.h"
16#include "llvm/ADT/StringRef.h"
33 struct FeatureListStatus {
35 StringRef CurFeaturesList;
38 const llvm::StringMap<bool> &CallerFeatureMap;
40 FeatureListStatus getAndFeatures(StringRef FeatureList) {
41 int InParentheses = 0;
42 bool HasFeatures =
true;
43 size_t SubexpressionStart = 0;
44 for (
size_t i = 0, e = FeatureList.size(); i < e; ++i) {
45 char CurrentToken = FeatureList[i];
46 switch (CurrentToken) {
50 if (InParentheses == 0)
51 SubexpressionStart = i + 1;
56 assert(InParentheses >= 0 &&
"Parentheses are not in pair");
60 if (InParentheses == 0) {
61 if (HasFeatures && i != SubexpressionStart) {
62 StringRef F = FeatureList.slice(SubexpressionStart, i);
64 : CallerFeatureMap.lookup(F);
66 SubexpressionStart = i + 1;
67 if (CurrentToken ==
'|') {
68 return {HasFeatures, FeatureList.substr(SubexpressionStart)};
74 assert(InParentheses == 0 &&
"Parentheses are not in pair");
75 if (HasFeatures && SubexpressionStart != FeatureList.size())
77 CallerFeatureMap.lookup(FeatureList.substr(SubexpressionStart));
78 return {HasFeatures, StringRef()};
83 FeatureListStatus FS = {
false, FeatureList};
84 while (!FS.HasFeatures && !FS.CurFeaturesList.empty())
85 FS = getAndFeatures(FS.CurFeaturesList);
86 return FS.HasFeatures;
90 : CallerFeatureMap(CallerFeatureMap) {}
TargetFeatures - This class is used to check whether the builtin function has the required tagert spe...
bool hasRequiredFeatures(StringRef FeatureList)
TargetFeatures(const llvm::StringMap< bool > &CallerFeatureMap)
The JSON file list parser is used to communicate input to InstallAPI.