Update prebuilt Clang to r365631c1 from Android.
The version we had was segfaulting.
Bug: 132420445
Change-Id: Icb45a6fe0b4e2166f7895e669df1157cec9fb4e0
diff --git a/linux-x64/clang/include/llvm/MC/SubtargetFeature.h b/linux-x64/clang/include/llvm/MC/SubtargetFeature.h
index 5f49d38..fc9565c 100644
--- a/linux-x64/clang/include/llvm/MC/SubtargetFeature.h
+++ b/linux-x64/clang/include/llvm/MC/SubtargetFeature.h
@@ -18,6 +18,7 @@
#define LLVM_MC_SUBTARGETFEATURE_H
#include "llvm/ADT/StringRef.h"
+#include <array>
#include <bitset>
#include <initializer_list>
#include <string>
@@ -25,11 +26,12 @@
namespace llvm {
-template <typename T> class ArrayRef;
class raw_ostream;
class Triple;
-const unsigned MAX_SUBTARGET_FEATURES = 192;
+const unsigned MAX_SUBTARGET_WORDS = 3;
+const unsigned MAX_SUBTARGET_FEATURES = MAX_SUBTARGET_WORDS * 64;
+
/// Container class for subtarget features.
/// This is convenient because std::bitset does not have a constructor
/// with an initializer list of set bits.
@@ -44,38 +46,34 @@
for (auto I : Init)
set(I);
}
-};
-//===----------------------------------------------------------------------===//
-
-/// Used to provide key value pairs for feature and CPU bit flags.
-struct SubtargetFeatureKV {
- const char *Key; ///< K-V key string
- const char *Desc; ///< Help descriptor
- FeatureBitset Value; ///< K-V integer value
- FeatureBitset Implies; ///< K-V bit mask
-
- /// Compare routine for std::lower_bound
- bool operator<(StringRef S) const {
- return StringRef(Key) < S;
- }
-
- /// Compare routine for std::is_sorted.
- bool operator<(const SubtargetFeatureKV &Other) const {
- return StringRef(Key) < StringRef(Other.Key);
+ bool operator < (const FeatureBitset &Other) const {
+ for (unsigned I = 0, E = size(); I != E; ++I) {
+ bool LHS = test(I), RHS = Other.test(I);
+ if (LHS != RHS)
+ return LHS < RHS;
+ }
+ return false;
}
};
-//===----------------------------------------------------------------------===//
+/// Class used to store the subtarget bits in the tables created by tablegen.
+/// The std::initializer_list constructor of FeatureBitset can't be done at
+/// compile time and requires a static constructor to run at startup.
+class FeatureBitArray {
+ std::array<uint64_t, MAX_SUBTARGET_WORDS> Bits;
-/// Used to provide key value pairs for CPU and arbitrary pointers.
-struct SubtargetInfoKV {
- const char *Key; ///< K-V key string
- const void *Value; ///< K-V pointer value
+public:
+ constexpr FeatureBitArray(const std::array<uint64_t, MAX_SUBTARGET_WORDS> &B)
+ : Bits(B) {}
- /// Compare routine for std::lower_bound
- bool operator<(StringRef S) const {
- return StringRef(Key) < S;
+ FeatureBitset getAsBitset() const {
+ FeatureBitset Result;
+
+ for (unsigned i = 0, e = Bits.size(); i != e; ++i)
+ Result |= FeatureBitset(Bits[i]) << (64 * i);
+
+ return Result;
}
};
@@ -101,19 +99,6 @@
/// Adds Features.
void AddFeature(StringRef String, bool Enable = true);
- /// Toggles a feature and update the feature bits.
- static void ToggleFeature(FeatureBitset &Bits, StringRef String,
- ArrayRef<SubtargetFeatureKV> FeatureTable);
-
- /// Applies the feature flag and update the feature bits.
- static void ApplyFeatureFlag(FeatureBitset &Bits, StringRef Feature,
- ArrayRef<SubtargetFeatureKV> FeatureTable);
-
- /// Returns feature bits of a CPU.
- FeatureBitset getFeatureBits(StringRef CPU,
- ArrayRef<SubtargetFeatureKV> CPUTable,
- ArrayRef<SubtargetFeatureKV> FeatureTable);
-
/// Returns the vector of individual subtarget features.
const std::vector<std::string> &getFeatures() const { return Features; }
@@ -125,6 +110,32 @@
/// Adds the default features for the specified target triple.
void getDefaultSubtargetFeatures(const Triple& Triple);
+
+ /// Determine if a feature has a flag; '+' or '-'
+ static bool hasFlag(StringRef Feature) {
+ assert(!Feature.empty() && "Empty string");
+ // Get first character
+ char Ch = Feature[0];
+ // Check if first character is '+' or '-' flag
+ return Ch == '+' || Ch =='-';
+ }
+
+ /// Return string stripped of flag.
+ static std::string StripFlag(StringRef Feature) {
+ return hasFlag(Feature) ? Feature.substr(1) : Feature;
+ }
+
+ /// Return true if enable flag; '+'.
+ static inline bool isEnabled(StringRef Feature) {
+ assert(!Feature.empty() && "Empty string");
+ // Get first character
+ char Ch = Feature[0];
+ // Check if first character is '+' for enabled
+ return Ch == '+';
+ }
+
+ /// Splits a string of comma separated items in to a vector of strings.
+ static void Split(std::vector<std::string> &V, StringRef S);
};
} // end namespace llvm