[mlir][NFC] Use the native range instead of APInt when computing operand ranges
authorRiver Riddle <riddleriver@gmail.com>
Sat, 20 Mar 2021 00:11:23 +0000 (17:11 -0700)
committerRiver Riddle <riddleriver@gmail.com>
Sat, 20 Mar 2021 00:11:46 +0000 (17:11 -0700)
This removes the need to construct an APInt for each value, given that it is guaranteed to contain 32 bit elements.

BEGIN_PUBLIC
    ...text exposed to open source public git repo...
END_PUBLIC

mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

index e137df4..d2f2132 100644 (file)
@@ -90,13 +90,14 @@ const char *adapterSegmentSizeAttrInitCode = R"(
   auto sizeAttr = odsAttrs.get("{0}").cast<::mlir::DenseIntElementsAttr>();
 )";
 const char *opSegmentSizeAttrInitCode = R"(
-  auto sizeAttr = (*this)->getAttrOfType<::mlir::DenseIntElementsAttr>("{0}");
+  auto sizeAttr = (*this)->getAttr("{0}").cast<::mlir::DenseIntElementsAttr>();
 )";
 const char *attrSizedSegmentValueRangeCalcCode = R"(
+  auto sizeAttrValues = sizeAttr.getValues<uint32_t>();
   unsigned start = 0;
   for (unsigned i = 0; i < index; ++i)
-    start += (*(sizeAttr.begin() + i)).getZExtValue();
-  unsigned size = (*(sizeAttr.begin() + index)).getZExtValue();
+    start += *(sizeAttrValues.begin() + i);
+  unsigned size = *(sizeAttrValues.begin() + index);
   return {start, size};
 )";