OSDN Git Service

[CallSiteSplitting] Report edge deletion to DomTreeUpdater
[android-x86/external-llvm.git] / include / llvm / TextAPI / MachO / PackedVersion.h
1 //===- llvm/TextAPI/PackedVersion.h - PackedVersion -------------*- 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 /// \brief Defines the Mach-O packed version format.
12 ///
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_TEXTAPI_MACHO_PACKED_VERSION_H
16 #define LLVM_TEXTAPI_MACHO_PACKED_VERSION_H
17
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/Support/raw_ostream.h"
20
21 namespace llvm {
22 namespace MachO {
23
24 class PackedVersion {
25   uint32_t Version{0};
26
27 public:
28   constexpr PackedVersion() = default;
29   explicit constexpr PackedVersion(uint32_t RawVersion) : Version(RawVersion) {}
30   PackedVersion(unsigned Major, unsigned Minor, unsigned Subminor)
31       : Version((Major << 16) | ((Minor & 0xff) << 8) | (Subminor & 0xff)) {}
32
33   bool empty() const { return Version == 0; }
34
35   /// Retrieve the major version number.
36   unsigned getMajor() const { return Version >> 16; }
37
38   /// Retrieve the minor version number, if provided.
39   unsigned getMinor() const { return (Version >> 8) & 0xff; }
40
41   /// Retrieve the subminor version number, if provided.
42   unsigned getSubminor() const { return Version & 0xff; }
43
44   bool parse32(StringRef Str);
45   std::pair<bool, bool> parse64(StringRef Str);
46
47   bool operator<(const PackedVersion &O) const { return Version < O.Version; }
48
49   bool operator==(const PackedVersion &O) const { return Version == O.Version; }
50
51   bool operator!=(const PackedVersion &O) const { return Version != O.Version; }
52
53   uint32_t rawValue() const { return Version; }
54
55   void print(raw_ostream &OS) const;
56 };
57
58 inline raw_ostream &operator<<(raw_ostream &OS, const PackedVersion &Version) {
59   Version.print(OS);
60   return OS;
61 }
62
63 } // end namespace MachO.
64 } // end namespace llvm.
65
66 #endif // LLVM_TEXTAPI_MACHO_PACKED_VERSION_H