LLVM 23.0.0git
CHERICapabilityFormat.h
Go to the documentation of this file.
1//===--- CHERICapabilityFormat.h --------------------------------*- 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_SUPPORT_CHERICAPABILITYFORMAT_H
10#define LLVM_SUPPORT_CHERICAPABILITYFORMAT_H
11
12#include "llvm/ADT/ArrayRef.h"
14
15namespace llvm {
16
17template <typename Derived, typename AddressType>
20
21 static constexpr AddressType AddressMask = ~static_cast<AddressType>(0);
22
23 /// Returns the "alignment mask" for an allocation of size \p Length. This
24 /// mask is 0 where the capability format alignment requires the
25 /// address to be 0, and 1 otherwise.
26 LLVM_ABI static AddressType getAlignmentMask(AddressType Length);
27
28 /// Returns the required alignment for an allocation of size \p Length.
29 LLVM_ABI static Align getRequiredAlignment(AddressType Length);
30
31 /// Returns \p Length rounded up to the nearest representable allocation
32 /// length.
33 LLVM_ABI static AddressType getRepresentableLength(AddressType Length);
34};
35
36template <typename AddressType, unsigned MW, unsigned MAX_E>
39 RVYCapabilityFormat<AddressType, MW, MAX_E>, AddressType> {
41};
42
45
47 : public CHERICapabilityFormatBase<CHERIoTCapabilityFormat, uint32_t> {
49};
50
51} // namespace llvm
52
53#endif
#define LLVM_ABI
Definition Compiler.h:213
This is an optimization pass for GlobalISel generic memory operations.
@ Length
Definition DWP.cpp:558
RVYCapabilityFormat< uint32_t, 10, 24 > RV32YCapabilityFormat
RVYCapabilityFormat< uint64_t, 14, 24 > RV64YCapabilityFormat
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
static LLVM_ABI Align getRequiredAlignment(AddressType Length)
Returns the required alignment for an allocation of size Length.
static LLVM_ABI AddressType getAlignmentMask(AddressType Length)
Returns the "alignment mask" for an allocation of size Length.
static LLVM_ABI AddressType getRepresentableLength(AddressType Length)
Returns Length rounded up to the nearest representable allocation length.
static constexpr AddressType AddressMask
static LLVM_ABI uint32_t getAlignmentMask(uint32_t Length)
static LLVM_ABI AddressType getAlignmentMask(uint64_t Length)