[llvm] Add the 'initializes' attribute langref and support (PR #84803)

Jan Voung via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 11 09:56:15 PDT 2024


================
@@ -0,0 +1,44 @@
+//===- ConstantRangeList.cpp - ConstantRangeList implementation -----------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Represent a list of signed ConstantRange and do NOT support wrap around the
+// end of the numeric range. Ranges in the list should have the same bitwidth.
+// Each range's lower should be less than its upper. Special lists (take 8-bit
+// as an example):
+//
+// {[0, 0)}     = Empty set
+// {[255, 255)} = Full Set
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/IR/ConstantRangeList.h"
+#include <cstddef>
+
+using namespace llvm;
+
+ConstantRangeList::ConstantRangeList(uint32_t BitWidth, bool Full) {
+  APInt Lower =
+      Full ? APInt::getMaxValue(BitWidth) : APInt::getMinValue(BitWidth);
+  Ranges.push_back(ConstantRange(Lower, Lower));
+}
+
+ConstantRangeList::ConstantRangeList(int64_t Lower, int64_t Upper) {
+  Ranges.push_back(
+      ConstantRange(APInt(64, StringRef(std::to_string(Lower)), 10),
----------------
jvoung wrote:

This one could also use the numeric APInt ctor instead of going through strings?

Is this ctor used by anything?

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


More information about the llvm-commits mailing list