#ifndef LLVM_SUPPORT_ALIGNMENT_H_
#define LLVM_SUPPORT_ALIGNMENT_H_
#include "llvm/Support/MathExtras.h"
#include <cassert>
#include <optional>
#ifndef NDEBUG
#include <string>
#endif
namespace llvm {
#define ALIGN_CHECK_ISPOSITIVE …
struct Align { … };
inline Align assumeAligned(uint64_t Value) { … }
struct MaybeAlign : public std::optional<Align> { … };
inline bool isAligned(Align Lhs, uint64_t SizeInBytes) { … }
inline bool isAddrAligned(Align Lhs, const void *Addr) { … }
inline uint64_t alignTo(uint64_t Size, Align A) { … }
inline uint64_t alignTo(uint64_t Size, Align A, uint64_t Skew) { … }
inline uintptr_t alignAddr(const void *Addr, Align Alignment) { … }
inline uint64_t offsetToAlignment(uint64_t Value, Align Alignment) { … }
inline uint64_t offsetToAlignedAddr(const void *Addr, Align Alignment) { … }
inline unsigned Log2(Align A) { … }
inline Align commonAlignment(Align A, uint64_t Offset) { … }
inline unsigned encode(MaybeAlign A) { … }
inline MaybeAlign decodeMaybeAlign(unsigned Value) { … }
inline unsigned encode(Align A) { … }
inline bool operator==(Align Lhs, uint64_t Rhs) { … }
inline bool operator!=(Align Lhs, uint64_t Rhs) { … }
inline bool operator<=(Align Lhs, uint64_t Rhs) { … }
inline bool operator>=(Align Lhs, uint64_t Rhs) { … }
inline bool operator<(Align Lhs, uint64_t Rhs) { … }
inline bool operator>(Align Lhs, uint64_t Rhs) { … }
inline bool operator==(Align Lhs, Align Rhs) { … }
inline bool operator!=(Align Lhs, Align Rhs) { … }
inline bool operator<=(Align Lhs, Align Rhs) { … }
inline bool operator>=(Align Lhs, Align Rhs) { … }
inline bool operator<(Align Lhs, Align Rhs) { … }
inline bool operator>(Align Lhs, Align Rhs) { … }
bool operator<=(Align Lhs, MaybeAlign Rhs) = delete;
bool operator>=(Align Lhs, MaybeAlign Rhs) = delete;
bool operator<(Align Lhs, MaybeAlign Rhs) = delete;
bool operator>(Align Lhs, MaybeAlign Rhs) = delete;
bool operator<=(MaybeAlign Lhs, Align Rhs) = delete;
bool operator>=(MaybeAlign Lhs, Align Rhs) = delete;
bool operator<(MaybeAlign Lhs, Align Rhs) = delete;
bool operator>(MaybeAlign Lhs, Align Rhs) = delete;
bool operator<=(MaybeAlign Lhs, MaybeAlign Rhs) = delete;
bool operator>=(MaybeAlign Lhs, MaybeAlign Rhs) = delete;
bool operator<(MaybeAlign Lhs, MaybeAlign Rhs) = delete;
bool operator>(MaybeAlign Lhs, MaybeAlign Rhs) = delete;
inline bool operator==(MaybeAlign Lhs, Align Rhs) { … }
inline bool operator!=(MaybeAlign Lhs, Align Rhs) { … }
inline bool operator==(Align Lhs, MaybeAlign Rhs) { … }
inline bool operator!=(Align Lhs, MaybeAlign Rhs) { … }
inline bool operator==(MaybeAlign Lhs, MaybeAlign Rhs) { … }
inline bool operator!=(MaybeAlign Lhs, MaybeAlign Rhs) { … }
inline bool operator==(MaybeAlign Lhs, std::nullopt_t) { … }
inline bool operator!=(MaybeAlign Lhs, std::nullopt_t) { … }
inline bool operator==(std::nullopt_t, MaybeAlign Rhs) { … }
inline bool operator!=(std::nullopt_t, MaybeAlign Rhs) { … }
#ifndef NDEBUG
inline std::string DebugStr(const Align &A) {
return std::to_string(A.value());
}
inline std::string DebugStr(const MaybeAlign &MA) {
if (MA)
return std::to_string(MA->value());
return "None";
}
#endif
#undef ALIGN_CHECK_ISPOSITIVE
}
#endif