From ed81cc5f8106134e08c9aeaca74d86839945fd57 Mon Sep 17 00:00:00 2001
From: Catherine <whitequark@whitequark.org>
Date: Tue, 16 Jan 2024 09:22:39 +0000
Subject: [PATCH] =?UTF-8?q?cxxrtl:=20rename=20observer::{on=5Fcommit?=
 =?UTF-8?q?=E2=86=92on=5Fupdate}.=20(breaking=20change)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The name `on_commit` was terrible since it would not be called, as one
may conclude from the name, on each `commit()`, but only whenever that
method actually updates a value.
---
 backends/cxxrtl/runtime/cxxrtl/cxxrtl.h        | 14 +++++++-------
 backends/cxxrtl/runtime/cxxrtl/cxxrtl_replay.h |  4 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/backends/cxxrtl/runtime/cxxrtl/cxxrtl.h b/backends/cxxrtl/runtime/cxxrtl/cxxrtl.h
index 3f8247226..e2729bfe4 100644
--- a/backends/cxxrtl/runtime/cxxrtl/cxxrtl.h
+++ b/backends/cxxrtl/runtime/cxxrtl/cxxrtl.h
@@ -865,19 +865,19 @@ struct observer {
 	// Called when the `commit()` method for a wire is about to update the `chunks` chunks at `base` with `chunks` chunks
 	// at `value` that have a different bit pattern. It is guaranteed that `chunks` is equal to the wire chunk count and
 	// `base` points to the first chunk.
-	virtual void on_commit(size_t chunks, const chunk_t *base, const chunk_t *value) = 0;
+	virtual void on_update(size_t chunks, const chunk_t *base, const chunk_t *value) = 0;
 
 	// Called when the `commit()` method for a memory is about to update the `chunks` chunks at `&base[chunks * index]`
 	// with `chunks` chunks at `value` that have a different bit pattern. It is guaranteed that `chunks` is equal to
 	// the memory element chunk count and `base` points to the first chunk of the first element of the memory.
-	virtual void on_commit(size_t chunks, const chunk_t *base, const chunk_t *value, size_t index) = 0;
+	virtual void on_update(size_t chunks, const chunk_t *base, const chunk_t *value, size_t index) = 0;
 };
 
 // The `null_observer` class has the same interface as `observer`, but has no invocation overhead, since its methods
 // are final and have no implementation. This allows the observer feature to be zero-cost when not in use.
 struct null_observer final: observer {
-	void on_commit(size_t chunks, const chunk_t *base, const chunk_t *value) override {}
-	void on_commit(size_t chunks, const chunk_t *base, const chunk_t *value, size_t index) override {}
+	void on_update(size_t chunks, const chunk_t *base, const chunk_t *value) override {}
+	void on_update(size_t chunks, const chunk_t *base, const chunk_t *value, size_t index) override {}
 };
 
 template<size_t Bits>
@@ -916,12 +916,12 @@ struct wire {
 
 	// This method intentionally takes a mandatory argument (to make it more difficult to misuse in
 	// black box implementations, leading to missed observer events). It is generic over its argument
-	// to make sure the `on_commit` call is devirtualized. This is somewhat awkward but lets us keep
+	// to make sure the `on_update` call is devirtualized. This is somewhat awkward but lets us keep
 	// a single implementation for both this method and the one in `memory`.
 	template<class ObserverT>
 	bool commit(ObserverT &observer) {
 		if (curr != next) {
-			observer.on_commit(curr.chunks, curr.data, next.data);
+			observer.on_update(curr.chunks, curr.data, next.data);
 			curr = next;
 			return true;
 		}
@@ -1003,7 +1003,7 @@ struct memory {
 			value<Width> elem = data[entry.index];
 			elem = elem.update(entry.val, entry.mask);
 			if (data[entry.index] != elem) {
-				observer.on_commit(value<Width>::chunks, data[0].data, elem.data, entry.index);
+				observer.on_update(value<Width>::chunks, data[0].data, elem.data, entry.index);
 				changed |= true;
 			}
 			data[entry.index] = elem;
diff --git a/backends/cxxrtl/runtime/cxxrtl/cxxrtl_replay.h b/backends/cxxrtl/runtime/cxxrtl/cxxrtl_replay.h
index 94f59bb0d..e44b1c4e1 100644
--- a/backends/cxxrtl/runtime/cxxrtl/cxxrtl_replay.h
+++ b/backends/cxxrtl/runtime/cxxrtl/cxxrtl_replay.h
@@ -561,12 +561,12 @@ public:
 			spool::writer *writer;
 
 			CXXRTL_ALWAYS_INLINE
-			void on_commit(size_t chunks, const chunk_t *base, const chunk_t *value) override {
+			void on_update(size_t chunks, const chunk_t *base, const chunk_t *value) override {
 				writer->write_change(ident_lookup->at(base), chunks, value);
 			}
 
 			CXXRTL_ALWAYS_INLINE
-			void on_commit(size_t chunks, const chunk_t *base, const chunk_t *value, size_t index) override {
+			void on_update(size_t chunks, const chunk_t *base, const chunk_t *value, size_t index) override {
 				writer->write_change(ident_lookup->at(base), chunks, value, index);
 			}
 		} record_observer;