Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: src/IceRangeSpec.h

Issue 1900543002: Subzero: Allow per-method controls. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: More cleanup Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/IceRangeSpec.h
diff --git a/src/IceRangeSpec.h b/src/IceRangeSpec.h
new file mode 100644
index 0000000000000000000000000000000000000000..cdd9c35738794b69bf7699beccd2275088fdf655
--- /dev/null
+++ b/src/IceRangeSpec.h
@@ -0,0 +1,73 @@
+//===- subzero/src/IceRangeSpec.h - Include/exclude specs -------*- C++ -*-===//
+//
+// The Subzero Code Generator
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// \brief Declares a class for specifying inclusion/exclusion of values, such
+/// as functions to match.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef SUBZERO_SRC_ICERANGESPEC_H
+#define SUBZERO_SRC_ICERANGESPEC_H
+
+#include "IceStringPool.h"
+
+#include <string>
+#include <unordered_set>
+#include <vector>
+
+#include "llvm/ADT/BitVector.h"
+
+namespace Ice {
+
+class RangeSpec {
+ RangeSpec(const RangeSpec &) = delete;
+ RangeSpec &operator=(const RangeSpec &) = delete;
+
+public:
+ static constexpr char DELIM_LIST = ',';
+ static constexpr char DELIM_RANGE = ':';
+ static constexpr uint32_t RangeMax = std::numeric_limits<uint32_t>::max();
+ RangeSpec() = default;
+ struct Desc {
+ // Set of names explicitly provided.
+ std::unordered_set<std::string> Names;
+ // Set of numbers explicitly provided.
+ llvm::BitVector Numbers;
+ // The smallest X for which the open-ended interval "X:" was provided. This
+ // is needed because the intervals are parsed before we know the largest
+ // number that might be matched against, and we can't make the Numbers
+ // bitvector infinitely long.
+ uint32_t AllFrom = RangeMax;
+ // Whether a clause was explicitly provided.
+ bool IsExplicit = false;
+ };
+ void init(const std::string &Spec);
+ bool match(const std::string &Name, uint32_t Number) const;
+ bool match(GlobalString Name, uint32_t Number) const {
+ return match(Name.toStringOrEmpty(), Number);
+ }
+ // Returns true if any RangeSpec object has had init() called with an explicit
+ // name rather than (or in addition to) a numeric range. If so, we want to
+ // construct explicit names for functions even in a non-DUMP build so that
+ // matching on function name works correctly. Note that this is not
+ // thread-safe, so we count on all this being handled by the startup thread.
+ static bool hasNames() { return HasNames; }
+
+private:
+ void include(const std::string &Token);
+ void exclude(const std::string &Token);
+ Desc Includes;
+ Desc Excludes;
+ static bool HasNames;
+};
+
+} // end of namespace Ice
+
+#endif // SUBZERO_SRC_ICERANGESPEC_H

Powered by Google App Engine
This is Rietveld 408576698