Files
clang-p2996/mlir/test/Bytecode/bytecode_callback.mlir
Matteo Franciolini bff6a4292f Expose callbacks for encoding of types/attributes
[mlir] Expose a mechanism to provide a callback for encoding types and attributes in MLIR bytecode.

Two callbacks are exposed, respectively, to the BytecodeWriterConfig and to the ParserConfig. At bytecode parsing/printing, clients have the ability to specify a callback to be used to optionally read/write the encoding. On failure, fallback path will execute the default parsers and printers for the dialect.

Testing shows how to leverage this functionality to support back-deployment and backward-compatibility usecases when roundtripping to bytecode a client dialect with type/attributes dependencies on upstream.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D153383
2023-07-28 16:45:42 -07:00

15 lines
659 B
MLIR

// RUN: mlir-opt %s --test-bytecode-callback="test-dialect-version=1.2" -verify-diagnostics | FileCheck %s --check-prefix=VERSION_1_2
// RUN: mlir-opt %s --test-bytecode-callback="test-dialect-version=2.0" -verify-diagnostics | FileCheck %s --check-prefix=VERSION_2_0
func.func @base_test(%arg0 : i32) -> f32 {
%0 = "test.addi"(%arg0, %arg0) : (i32, i32) -> i32
%1 = "test.cast"(%0) : (i32) -> f32
return %1 : f32
}
// VERSION_1_2: Overriding IntegerType encoding...
// VERSION_1_2: Overriding parsing of IntegerType encoding...
// VERSION_2_0-NOT: Overriding IntegerType encoding...
// VERSION_2_0-NOT: Overriding parsing of IntegerType encoding...