MLIR  19.0.0git
Serialization.cpp
Go to the documentation of this file.
1 //===- Serialization.cpp - MLIR SPIR-V Serialization ----------------------===//
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 defines the MLIR SPIR-V module to SPIR-V binary serialization entry
10 // point.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "Serializer.h"
15 
17 
19 #include "llvm/Support/Debug.h"
20 
21 #define DEBUG_TYPE "spirv-serialization"
22 
23 namespace mlir {
24 LogicalResult spirv::serialize(spirv::ModuleOp module,
25  SmallVectorImpl<uint32_t> &binary,
26  const SerializationOptions &options) {
27  if (!module.getVceTriple())
28  return module.emitError(
29  "module must have 'vce_triple' attribute to be serializeable");
30 
31  Serializer serializer(module, options);
32 
33  if (failed(serializer.serialize()))
34  return failure();
35 
36  LLVM_DEBUG(serializer.printValueIDMap(llvm::dbgs()));
37 
38  serializer.collect(binary);
39  return success();
40 }
41 } // namespace mlir
static llvm::ManagedStatic< PassManagerOptions > options
LogicalResult serialize(ModuleOp module, SmallVectorImpl< uint32_t > &binary, const SerializationOptions &options={})
Serializes the given SPIR-V module and writes to binary.
Include the generated interface declarations.
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
Definition: LogicalResult.h:62
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
Definition: LogicalResult.h:56
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value.
Definition: LogicalResult.h:72