[Mlir-commits] [mlir] 1a75be0 - [mlir][NFC] Use the native range instead of APInt when computing operand ranges

River Riddle llvmlistbot at llvm.org
Fri Mar 19 17:28:12 PDT 2021


Author: River Riddle
Date: 2021-03-19T17:11:46-07:00
New Revision: 1a75be0023cd80fd8560d689999a63d4368c90e6

URL: https://github.com/llvm/llvm-project/commit/1a75be0023cd80fd8560d689999a63d4368c90e6
DIFF: https://github.com/llvm/llvm-project/commit/1a75be0023cd80fd8560d689999a63d4368c90e6.diff

LOG: [mlir][NFC] Use the native range instead of APInt when computing operand ranges

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

Added: 
    

Modified: 
    mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index e137df4244f7..d2f2132b1a38 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -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};
 )";
 


        


More information about the Mlir-commits mailing list