• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- Serialization.h - MLIR SPIR-V (De)serialization ----------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares the entry points for serialize and deserialize SPIR-V
10 // binary modules.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef MLIR_DIALECT_SPIRV_SERIALIZATION_H_
15 #define MLIR_DIALECT_SPIRV_SERIALIZATION_H_
16 
17 #include "mlir/Support/LLVM.h"
18 
19 namespace mlir {
20 struct LogicalResult;
21 class MLIRContext;
22 
23 namespace spirv {
24 class ModuleOp;
25 class OwningSPIRVModuleRef;
26 
27 /// Serializes the given SPIR-V `module` and writes to `binary`. On failure,
28 /// reports errors to the error handler registered with the MLIR context for
29 /// `module`.
30 LogicalResult serialize(ModuleOp module, SmallVectorImpl<uint32_t> &binary,
31                         bool emitDebugInfo = false);
32 
33 /// Deserializes the given SPIR-V `binary` module and creates a MLIR ModuleOp
34 /// in the given `context`. Returns the ModuleOp on success; otherwise, reports
35 /// errors to the error handler registered with `context` and returns a null
36 /// module.
37 OwningSPIRVModuleRef deserialize(ArrayRef<uint32_t> binary,
38                                  MLIRContext *context);
39 
40 } // end namespace spirv
41 } // end namespace mlir
42 
43 #endif // MLIR_DIALECT_SPIRV_SERIALIZATION_H_
44