1 //===- Serialization.cpp - MLIR SPIR-V Serialization ----------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // This file defines the MLIR SPIR-V module to SPIR-V binary serialization entry
12 //===----------------------------------------------------------------------===//
14 #include "Serializer.h"
16 #include "mlir/Target/SPIRV/Serialization.h"
18 #include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
19 #include "llvm/Support/Debug.h"
21 #define DEBUG_TYPE "spirv-serialization"
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");
31 Serializer
serializer(module
, options
);
33 if (failed(serializer
.serialize()))
36 LLVM_DEBUG(serializer
.printValueIDMap(llvm::dbgs()));
38 serializer
.collect(binary
);