MLIR 22.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
18#include "llvm/Support/Debug.h"
19
20#define DEBUG_TYPE "spirv-serialization"
21
22namespace mlir {
23LogicalResult spirv::serialize(spirv::ModuleOp module,
24 SmallVectorImpl<uint32_t> &binary,
25 const SerializationOptions &options) {
26 if (!module.getVceTriple())
27 return module.emitError(
28 "module must have 'vce_triple' attribute to be serializeable");
29
30 Serializer serializer(module, options);
31
32 if (failed(serializer.serialize()))
33 return failure();
34
35 LLVM_DEBUG(serializer.printValueIDMap(llvm::dbgs()));
36
37 serializer.collect(binary);
38 return success();
39}
40} // namespace mlir
return success()
static llvm::ManagedStatic< PassManagerOptions > options
LogicalResult serialize(ModuleOp moduleOp, SmallVectorImpl< uint32_t > &binary, const SerializationOptions &options={})
Serializes the given SPIR-V moduleOp and writes to binary.
Include the generated interface declarations.