[Mlir-commits] [mlir] [MLIR] modify BytecodeWriterConfig to return const refs for callbacks (PR #85926)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Mar 20 06:09:33 PDT 2024


https://github.com/0x00006000 updated https://github.com/llvm/llvm-project/pull/85926

>From 17294ada0845ad59a19681553d9f70c56e0a2981 Mon Sep 17 00:00:00 2001
From: Matrix <alexsei at cock.pm>
Date: Wed, 20 Mar 2024 12:49:19 +0000
Subject: [PATCH 1/3] [MLIR] modify BytecodeWriterConfig to return const refs
 for callbacks

---
 mlir/lib/Bytecode/Writer/BytecodeWriter.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp b/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp
index 9493a6c19a1067..33b25bf38a74d3 100644
--- a/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp
+++ b/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp
@@ -68,12 +68,12 @@ BytecodeWriterConfig::BytecodeWriterConfig(FallbackAsmResourceMap &map,
 }
 BytecodeWriterConfig::~BytecodeWriterConfig() = default;
 
-ArrayRef<std::unique_ptr<AttrTypeBytecodeWriter<Attribute>>>
+ArrayRef<const std::unique_ptr<AttrTypeBytecodeWriter<Attribute>> &>
 BytecodeWriterConfig::getAttributeWriterCallbacks() const {
   return impl->attributeWriterCallbacks;
 }
 
-ArrayRef<std::unique_ptr<AttrTypeBytecodeWriter<Type>>>
+ArrayRef<const std::unique_ptr<AttrTypeBytecodeWriter<Type>> &> 
 BytecodeWriterConfig::getTypeWriterCallbacks() const {
   return impl->typeWriterCallbacks;
 }

>From 074fd2eb35993fec809ba3d16a0891087e954760 Mon Sep 17 00:00:00 2001
From: Matrix <alexsei at cock.pm>
Date: Wed, 20 Mar 2024 12:59:46 +0000
Subject: [PATCH 2/3] [MLIR] fixed

---
 mlir/lib/Bytecode/Writer/BytecodeWriter.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp b/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp
index 33b25bf38a74d3..2bdb496d054324 100644
--- a/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp
+++ b/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp
@@ -73,7 +73,7 @@ BytecodeWriterConfig::getAttributeWriterCallbacks() const {
   return impl->attributeWriterCallbacks;
 }
 
-ArrayRef<const std::unique_ptr<AttrTypeBytecodeWriter<Type>> &> 
+ArrayRef<const std::unique_ptr<AttrTypeBytecodeWriter<Type>>>
 BytecodeWriterConfig::getTypeWriterCallbacks() const {
   return impl->typeWriterCallbacks;
 }

>From df789fddddb5ba20cd4625a16279ed7de6576fb2 Mon Sep 17 00:00:00 2001
From: Matrix <alexsei at cock.pm>
Date: Wed, 20 Mar 2024 13:09:25 +0000
Subject: [PATCH 3/3] Update BytecodeWriter.cpp

---
 mlir/lib/Bytecode/Writer/BytecodeWriter.cpp | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp b/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp
index 2bdb496d054324..acedc5bd030155 100644
--- a/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp
+++ b/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp
@@ -73,14 +73,14 @@ BytecodeWriterConfig::getAttributeWriterCallbacks() const {
   return impl->attributeWriterCallbacks;
 }
 
-ArrayRef<const std::unique_ptr<AttrTypeBytecodeWriter<Type>>>
-BytecodeWriterConfig::getTypeWriterCallbacks() const {
-  return impl->typeWriterCallbacks;
+ArrayRef<const std::unique_ptr<AttrTypeBytecodeWriter<Attribute>> &>
+BytecodeWriterConfig::getAttributeWriterCallbacks() const {
+  return impl->attributeWriterCallbacks;
 }
 
-void BytecodeWriterConfig::attachAttributeCallback(
-    std::unique_ptr<AttrTypeBytecodeWriter<Attribute>> callback) {
-  impl->attributeWriterCallbacks.emplace_back(std::move(callback));
+ArrayRef<const std::unique_ptr<AttrTypeBytecodeWriter<Type>> &>
+BytecodeWriterConfig::getTypeWriterCallbacks() const {
+  return impl->typeWriterCallbacks;
 }
 
 void BytecodeWriterConfig::attachTypeCallback(



More information about the Mlir-commits mailing list