[Mlir-commits] [mlir] [mlir][dataflow] Update dataflow tutorial doc and add dataflow example code (PR #149296)
lonely eagle
llvmlistbot at llvm.org
Fri Aug 8 20:53:24 PDT 2025
================
@@ -0,0 +1,114 @@
+//===-- MetadataAnalysis.cpp - dataflow tutorial ----------------*- c++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is contains the implementations of the methods in the
+// metadata-related classes in the dataflow tutorial.
+//
+//===----------------------------------------------------------------------===//
+
+#include "MetadataAnalysis.h"
+
+using namespace mlir;
+using namespace dataflow;
+
+namespace mlir {
+
+/// This method conservatively joins the information held by `lhs` and `rhs`
+/// into a new value. This method is required to be monotonic. `monotonicity`
+/// is implied by the satisfaction of the following axioms:
+/// * idempotence: join(x,x) == x
+/// * commutativity: join(x,y) == join(y,x)
+/// * associativity: join(x,join(y,z)) == join(join(x,y),z)
+///
+/// When the above axioms are satisfied, we achieve `monotonicity`:
+/// * monotonicity: join(x, join(x,y)) == join(x,y)
+MetadataLatticeValue
+MetadataLatticeValue::join(const MetadataLatticeValue &lhs,
+ const MetadataLatticeValue &rhs) {
+ // To join `lhs` and `rhs` we will define a simple policy, which is that we
+ // directly insert the metadata of rhs into the metadata of lhs.If lhs and rhs
+ // have overlapping attributes, keep the attribute value in lhs unchanged.
+ MetadataLatticeValue result;
+ for (auto &&lhsIt : lhs.metadata) {
----------------
linuxlonelyeagle wrote:
At first, I thought this was a complex type, so I used auto.
https://github.com/llvm/llvm-project/pull/149296
More information about the Mlir-commits
mailing list