[llvm] [IR] Add new Range attribute using new ConstantRange Attribute type (PR #83171)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 6 09:17:21 PST 2024


================
@@ -2997,6 +3000,51 @@ bool LLParser::parseRequiredTypeAttr(AttrBuilder &B, lltok::Kind AttrToken,
   return false;
 }
 
+/// parseRangeAttr
+///   ::= range(<ty> <n>,<n>)
+bool LLParser::parseRangeAttr(AttrBuilder &B) {
+  Lex.Lex();
+
+  APInt Lower;
+  APInt Upper;
+  Type *Ty = nullptr;
+  LocTy TyLoc;
+
+  auto ParseAPSInt = [&](llvm::TypeSize BitWidth, APInt &Val) {
+    if (Lex.getKind() != lltok::APSInt)
+      return tokError("expected integer");
+    if (Lex.getAPSIntVal().getBitWidth() > BitWidth)
+      return tokError("integer is to large for the BitWidth");
----------------
nikic wrote:

Also BitWidth -> bit width probably? Doesn't make sense to reference a variable name in a user visible message :)

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


More information about the llvm-commits mailing list