LLVM  8.0.1
MsgPack.h
Go to the documentation of this file.
1 //===-- MsgPack.h - MessagePack Constants -----------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// This file contains constants used for implementing MessagePack support.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_BINARYFORMAT_MSGPACK_H
16 #define LLVM_BINARYFORMAT_MSGPACK_H
17 
18 #include "llvm/Support/DataTypes.h"
19 #include "llvm/Support/Endian.h"
20 
21 namespace llvm {
22 namespace msgpack {
23 
24 /// The endianness of all multi-byte encoded values in MessagePack.
26 
27 /// The first byte identifiers of MessagePack object formats.
28 namespace FirstByte {
29 #define HANDLE_MP_FIRST_BYTE(ID, NAME) constexpr uint8_t NAME = ID;
30 #include "llvm/BinaryFormat/MsgPack.def"
31 }
32 
33 /// Most significant bits used to identify "Fix" variants in MessagePack.
34 ///
35 /// For example, FixStr objects encode their size in the five least significant
36 /// bits of their first byte, which is identified by the bit pattern "101" in
37 /// the three most significant bits. So FixBits::String contains 0b10100000.
38 ///
39 /// A corresponding mask of the bit pattern is found in \c FixBitsMask.
40 namespace FixBits {
41 #define HANDLE_MP_FIX_BITS(ID, NAME) constexpr uint8_t NAME = ID;
42 #include "llvm/BinaryFormat/MsgPack.def"
43 }
44 
45 /// Mask of bits used to identify "Fix" variants in MessagePack.
46 ///
47 /// For example, FixStr objects encode their size in the five least significant
48 /// bits of their first byte, which is identified by the bit pattern "101" in
49 /// the three most significant bits. So FixBitsMask::String contains
50 /// 0b11100000.
51 ///
52 /// The corresponding bit pattern to mask for is found in FixBits.
53 namespace FixBitsMask {
54 #define HANDLE_MP_FIX_BITS_MASK(ID, NAME) constexpr uint8_t NAME = ID;
55 #include "llvm/BinaryFormat/MsgPack.def"
56 }
57 
58 /// The maximum value or size encodable in "Fix" variants of formats.
59 ///
60 /// For example, FixStr objects encode their size in the five least significant
61 /// bits of their first byte, so the largest encodable size is 0b00011111.
62 namespace FixMax {
63 #define HANDLE_MP_FIX_MAX(ID, NAME) constexpr uint8_t NAME = ID;
64 #include "llvm/BinaryFormat/MsgPack.def"
65 }
66 
67 /// The exact size encodable in "Fix" variants of formats.
68 ///
69 /// The only objects for which an exact size makes sense are of Extension type.
70 ///
71 /// For example, FixExt4 stores an extension type containing exactly four bytes.
72 namespace FixLen {
73 #define HANDLE_MP_FIX_LEN(ID, NAME) constexpr uint8_t NAME = ID;
74 #include "llvm/BinaryFormat/MsgPack.def"
75 }
76 
77 /// The minimum value or size encodable in "Fix" variants of formats.
78 ///
79 /// The only object for which a minimum makes sense is a negative FixNum.
80 ///
81 /// Negative FixNum objects encode their signed integer value in one byte, but
82 /// they must have the pattern "111" as their three most significant bits. This
83 /// means all values are negative, and the smallest representable value is
84 /// 0b11100000.
85 namespace FixMin {
86 #define HANDLE_MP_FIX_MIN(ID, NAME) constexpr int8_t NAME = ID;
87 #include "llvm/BinaryFormat/MsgPack.def"
88 }
89 
90 } // end namespace msgpack
91 } // end namespace llvm
92 
93 #endif // LLVM_BINARYFORMAT_MSGPACK_H
This class represents lattice values for constants.
Definition: AllocatorList.h:24
constexpr support::endianness Endianness
The endianness of all multi-byte encoded values in MessagePack.
Definition: MsgPack.h:25