MLIR  17.0.0git
Encoding.h
Go to the documentation of this file.
1 //===- Encoding.h - MLIR binary format encoding information -----*- 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 header defines enum values describing the structure of MLIR bytecode
10 // files.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LIB_MLIR_BYTECODE_ENCODING_H
15 #define LIB_MLIR_BYTECODE_ENCODING_H
16 
17 #include <cstdint>
18 
19 namespace mlir {
20 namespace bytecode {
21 //===----------------------------------------------------------------------===//
22 // General constants
23 //===----------------------------------------------------------------------===//
24 
25 enum {
26  /// The current bytecode version.
27  kVersion = 0,
28 
29  /// An arbitrary value used to fill alignment padding.
31 };
32 
33 //===----------------------------------------------------------------------===//
34 // Sections
35 //===----------------------------------------------------------------------===//
36 
37 namespace Section {
38 enum ID : uint8_t {
39  /// This section contains strings referenced within the bytecode.
40  kString = 0,
41 
42  /// This section contains the dialects referenced within an IR module.
43  kDialect = 1,
44 
45  /// This section contains the attributes and types referenced within an IR
46  /// module.
47  kAttrType = 2,
48 
49  /// This section contains the offsets for the attribute and types within the
50  /// AttrType section.
52 
53  /// This section contains the list of operations serialized into the bytecode,
54  /// and their nested regions/operations.
55  kIR = 4,
56 
57  /// This section contains the resources of the bytecode.
58  kResource = 5,
59 
60  /// This section contains the offsets of resources within the Resource
61  /// section.
63 
64  /// The total number of section types.
66 };
67 } // namespace Section
68 
69 //===----------------------------------------------------------------------===//
70 // IR Section
71 //===----------------------------------------------------------------------===//
72 
73 /// This enum represents a mask of all of the potential components of an
74 /// operation. This mask is used when encoding an operation to indicate which
75 /// components are present in the bytecode.
76 namespace OpEncodingMask {
77 enum : uint8_t {
78  // clang-format off
79  kHasAttrs = 0b00000001,
80  kHasResults = 0b00000010,
81  kHasOperands = 0b00000100,
82  kHasSuccessors = 0b00001000,
83  kHasInlineRegions = 0b00010000,
84  // clang-format on
85 };
86 } // namespace OpEncodingMask
87 
88 } // namespace bytecode
89 } // namespace mlir
90 
91 #endif
@ kAttrType
This section contains the attributes and types referenced within an IR module.
Definition: Encoding.h:47
@ kAttrTypeOffset
This section contains the offsets for the attribute and types within the AttrType section.
Definition: Encoding.h:51
@ kIR
This section contains the list of operations serialized into the bytecode, and their nested regions/o...
Definition: Encoding.h:55
@ kResource
This section contains the resources of the bytecode.
Definition: Encoding.h:58
@ kResourceOffset
This section contains the offsets of resources within the Resource section.
Definition: Encoding.h:62
@ kDialect
This section contains the dialects referenced within an IR module.
Definition: Encoding.h:43
@ kString
This section contains strings referenced within the bytecode.
Definition: Encoding.h:40
@ kNumSections
The total number of section types.
Definition: Encoding.h:65
@ kAlignmentByte
An arbitrary value used to fill alignment padding.
Definition: Encoding.h:30
@ kVersion
The current bytecode version.
Definition: Encoding.h:27
Include the generated interface declarations.