LLVM 24.0.0git
Version.h
Go to the documentation of this file.
1//===------------------------------------------------------------*- 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#ifndef LLVM_FRONTEND_DIRECTIVE_VERSION_H
10#define LLVM_FRONTEND_DIRECTIVE_VERSION_H
11
13
14#include <limits>
15
16namespace llvm {
17namespace directive {
18struct Version {
20 constexpr explicit Version(value_type Ver = 0) : V(Ver) {}
21 constexpr explicit operator bool() const { return V != 0; }
22 constexpr value_type value() const { return V; }
23
24 friend constexpr bool operator<(Version A, Version B);
25 friend constexpr bool operator==(Version A, Version B);
26
27 static constexpr Version Max() {
28 // The version values in .td files are "int", and the max value that
29 // can be specified there is 0x7fffffff.
30 return Version(std::numeric_limits<int>::max());
31 }
32
33private:
34 value_type V;
35};
36
37inline constexpr bool operator==(Version A, Version B) { return A.V == B.V; }
38inline constexpr bool operator!=(Version A, Version B) { return !(A == B); }
39inline constexpr bool operator<(Version A, Version B) { return A.V < B.V; }
40inline constexpr bool operator<=(Version A, Version B) {
41 return A < B || A == B;
42}
43inline constexpr bool operator>(Version A, Version B) { return !(A <= B); }
44inline constexpr bool operator>=(Version A, Version B) { return !(A < B); }
45
46inline constexpr bool operator==(Version A, int B) { return A == Version(B); }
47inline constexpr bool operator!=(Version A, int B) { return A != Version(B); }
48inline constexpr bool operator<(Version A, int B) { return A < Version(B); }
49inline constexpr bool operator<=(Version A, int B) { return A <= Version(B); }
50inline constexpr bool operator>(Version A, int B) { return A > Version(B); }
51inline constexpr bool operator>=(Version A, int B) { return A >= Version(B); }
52
56
57 constexpr bool operator<(const VersionRange &R) const {
58 return std::tie(Min, Max) < std::tie(R.Min, R.Max);
59 }
60 constexpr bool isValid() const { return Min <= Max; }
61 constexpr bool contains(Version V) const { return Min <= V && V <= Max; }
62};
63} // namespace directive
64
65template <> struct DenseMapInfo<directive::Version> {
66 static unsigned getHashValue(directive::Version V) {
67 using UnderlyingTy = directive::Version::value_type;
69 }
71 return LHS == RHS;
72 }
73};
74} // namespace llvm
75
76#endif // LLVM_FRONTEND_DIRECTIVE_VERSION_H
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file defines DenseMapInfo traits for DenseMap.
Value * RHS
Value * LHS
constexpr bool operator>(Version A, Version B)
Definition Version.h:43
constexpr bool operator==(Version A, Version B)
Definition Version.h:37
constexpr bool operator>=(Version A, Version B)
Definition Version.h:44
constexpr bool operator!=(Version A, Version B)
Definition Version.h:38
constexpr bool operator<=(Version A, Version B)
Definition Version.h:40
constexpr bool operator<(Version A, Version B)
Definition Version.h:39
This is an optimization pass for GlobalISel generic memory operations.
static unsigned getHashValue(directive::Version V)
Definition Version.h:66
static bool isEqual(directive::Version LHS, directive::Version RHS)
Definition Version.h:70
An information struct used to provide DenseMap with the various necessary components for a given valu...
constexpr bool isValid() const
Definition Version.h:60
constexpr bool contains(Version V) const
Definition Version.h:61
constexpr bool operator<(const VersionRange &R) const
Definition Version.h:57
constexpr value_type value() const
Definition Version.h:22
friend constexpr bool operator<(Version A, Version B)
Definition Version.h:39
friend constexpr bool operator==(Version A, Version B)
Definition Version.h:37
static constexpr Version Max()
Definition Version.h:27
constexpr Version(value_type Ver=0)
Definition Version.h:20