[llvm] [IR][TableGen] Add RangeSet TableGen intrinsic property (PR #203623)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 5 08:56:05 PDT 2026


================
@@ -31,6 +32,44 @@ using namespace llvm;
 // return is 257.
 static constexpr unsigned MaxNumReturn = 257;
 
+static std::pair<int64_t, int64_t>
+getHalfOpenRange(const Record *R, const ListInit *Range, StringRef AttrName) {
+  if (!Range || Range->size() != 2)
+    PrintFatalError(R->getLoc(),
+                    Twine(AttrName) + " range must have exactly two bounds");
+
+  auto GetBound = [&](const Init *Bound) -> int64_t {
+    if (const auto *II = dyn_cast<IntInit>(Bound))
+      return II->getValue();
+    PrintFatalError(R->getLoc(),
+                    Twine(AttrName) +
+                        " bound is not an integer: " + Bound->getAsString());
+  };
+
+  int64_t Lower = GetBound(Range->getElement(0));
+  int64_t Upper = GetBound(Range->getElement(1));
+  if (Upper == std::numeric_limits<int64_t>::max())
+    PrintFatalError(R->getLoc(),
+                    Twine(AttrName) + " closed upper bound is too large");
+  return std::pair<int64_t, int64_t>(Lower, Upper + 1);
+}
+
+static void
+appendHalfOpenRange(const Record *R,
+                    SmallVectorImpl<std::pair<int64_t, int64_t>> &Ranges,
+                    std::pair<int64_t, int64_t> Range) {
+  if (!Ranges.empty()) {
+    if (Range.first < Ranges.back().second)
+      PrintFatalError(R->getLoc(),
----------------
jurahul wrote:

Again, is this redundant considering the asserts you have?

https://github.com/llvm/llvm-project/pull/203623


More information about the llvm-commits mailing list