[Alignment][NFC] Use Align with TargetLowering::setMinFunctionAlignment
[llvm-core.git] / include / llvm / TextAPI / MachO / PackedVersion.h
blob2d0138097dd92a425dcf4bde73eccca6e946eec0
1 //===- llvm/TextAPI/MachO/PackedVersion.h - PackedVersion -------*- 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 // Defines the Mach-O packed version format.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_TEXTAPI_MACHO_PACKED_VERSION_H
14 #define LLVM_TEXTAPI_MACHO_PACKED_VERSION_H
16 #include "llvm/ADT/StringRef.h"
17 #include "llvm/Support/raw_ostream.h"
19 namespace llvm {
20 namespace MachO {
22 class PackedVersion {
23 uint32_t Version{0};
25 public:
26 constexpr PackedVersion() = default;
27 explicit constexpr PackedVersion(uint32_t RawVersion) : Version(RawVersion) {}
28 PackedVersion(unsigned Major, unsigned Minor, unsigned Subminor)
29 : Version((Major << 16) | ((Minor & 0xff) << 8) | (Subminor & 0xff)) {}
31 bool empty() const { return Version == 0; }
33 /// Retrieve the major version number.
34 unsigned getMajor() const { return Version >> 16; }
36 /// Retrieve the minor version number, if provided.
37 unsigned getMinor() const { return (Version >> 8) & 0xff; }
39 /// Retrieve the subminor version number, if provided.
40 unsigned getSubminor() const { return Version & 0xff; }
42 bool parse32(StringRef Str);
43 std::pair<bool, bool> parse64(StringRef Str);
45 bool operator<(const PackedVersion &O) const { return Version < O.Version; }
47 bool operator==(const PackedVersion &O) const { return Version == O.Version; }
49 bool operator!=(const PackedVersion &O) const { return Version != O.Version; }
51 uint32_t rawValue() const { return Version; }
53 void print(raw_ostream &OS) const;
56 inline raw_ostream &operator<<(raw_ostream &OS, const PackedVersion &Version) {
57 Version.print(OS);
58 return OS;
61 } // end namespace MachO.
62 } // end namespace llvm.
64 #endif // LLVM_TEXTAPI_MACHO_PACKED_VERSION_H