[Mlir-commits] [mlir] [MLIR][Target/Cpp] Natural induction variable naming. (PR #136102)

Gil Rapaport llvmlistbot at llvm.org
Sat Apr 26 13:33:26 PDT 2025


================
@@ -1245,7 +1278,29 @@ StringRef CppEmitter::getOrCreateName(Value val) {
     assert(!hasDeferredEmission(val.getDefiningOp()) &&
            "cacheDeferredOpResult should have been called on this value, "
            "update the emitOperation function.");
-    valueMapper.insert(val, formatv("v{0}", ++valueInScopeCount.top()));
+
+    valueMapper.insert(val, formatv("v{0}", ++valueCount));
+  }
+  return *valueMapper.begin(val);
+}
+
+/// Return the existing or a new name for a loop induction variable Value.
+/// Loop induction variables follow natural naming: i, j, k,...
+StringRef CppEmitter::getOrCreateName(emitc::ForOp forOp) {
----------------
aniragil wrote:

The `ForOp` isn't really used here except for retrieving its induction variable, plus it seems a bit awkward that a for loop has a name. Better to rename this `getOrCreateInductionVariable(Value val)`?

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


More information about the Mlir-commits mailing list