[OpenACC] Create AST nodes for 'data' constructs
[llvm-project.git] / mlir / lib / Target / SPIRV / Serialization / Serialization.cpp
blob80d1bb85611db6edd00af2c0cbb8933731caed25
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.
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"
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");
31 Serializer serializer(module, options);
33 if (failed(serializer.serialize()))
34 return failure();
36 LLVM_DEBUG(serializer.printValueIDMap(llvm::dbgs()));
38 serializer.collect(binary);
39 return success();
41 } // namespace mlir