[Mlir-commits] [mlir] [mlir][LLVM] Refactor how range() annotations are handled for ROCDL intrinsics (PR #107658)

Krzysztof Drewniak llvmlistbot at llvm.org
Mon Sep 9 15:12:59 PDT 2024


================
@@ -1034,6 +1034,37 @@ def LLVM_TBAATagArrayAttr
   let constBuilderCall = ?;
 }
 
+//===----------------------------------------------------------------------===//
+// ConstantRangeAttr
+//===----------------------------------------------------------------------===//
+def LLVM_ConstantRangeAttr : LLVM_Attr<"ConstantRange", "constant_range"> {
+  let parameters = (ins
+    "IntegerAttr":$lower,
+    "IntegerAttr":$upper
+  );
+  let summary = "A range of two integers, corresponding to LLVM's ConstantRange";
+  let description = [{
+    A pair of two integers, mapping to the ConstantRange structure in LLVM IR,
+    which is allowed to wrap or be empty.
+
+    The range represented is [Lower, Upper), and is either signed or unsigned
+    depending on context.
+
+    `lower` and `upper` must have the same width.
+  }];
+
+  let builders = [
+    AttrBuilder<(ins "uint32_t":$bitWidth, "int64_t":$lower, "int64_t":$upper)>
----------------
krzysz00 wrote:

In further notes:

The `VScaleRangeAttr` elsewhere is this file is also defined as `<IntegerAttr, IntegerAttr>` - so using a pair of attributes for a pair of APInt is established practice in this file.

Also, a pair of APInt wouldn't save encoding the bitwidth twice - both APInt values need the width.

And, last I checked, none of the `(uint32_t bitwidth, int64_t value)`-type builders actually check for the width being under 64 bits (partly because `IntegerAttr(context, /*bitwidth=*/128, /*value=*/0)` is legitimate, and that translates to the equivalent `ConstantRanges` builder)

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


More information about the Mlir-commits mailing list