LLVM 22.0.0git
AllocToken.h
Go to the documentation of this file.
1//===- llvm/Support/AllocToken.h - Allocation Token Calculation -----*- 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// Definition of AllocToken modes and shared calculation of stateless token IDs.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_SUPPORT_ALLOCTOKEN_H
14#define LLVM_SUPPORT_ALLOCTOKEN_H
15
17#include "llvm/ADT/StringRef.h"
18#include <cstdint>
19#include <optional>
20
21namespace llvm {
22
23/// Modes for generating allocation token IDs.
24enum class AllocTokenMode {
25 /// Incrementally increasing token ID.
27
28 /// Simple mode that returns a statically-assigned random token ID.
30
31 /// Token ID based on allocated type hash.
33
34 /// Token ID based on allocated type hash, where the top half ID-space is
35 /// reserved for types that contain pointers and the bottom half for types
36 /// that do not contain pointers.
38};
39
40/// The default allocation token mode.
43
44/// Returns the AllocTokenMode from its canonical string name; if an invalid
45/// name was provided returns nullopt.
46LLVM_ABI std::optional<AllocTokenMode>
48
49/// Metadata about an allocation used to generate a token ID.
54
55/// Calculates stable allocation token ID. Returns std::nullopt for stateful
56/// modes that are only available in the AllocToken pass.
57///
58/// \param Mode The token generation mode.
59/// \param Metadata The metadata about the allocation.
60/// \param MaxTokens The maximum number of tokens (must not be 0)
61/// \return The calculated allocation token ID, or std::nullopt.
62LLVM_ABI std::optional<uint64_t>
64 uint64_t MaxTokens);
65
66} // end namespace llvm
67
68#endif // LLVM_SUPPORT_ALLOCTOKEN_H
#define LLVM_ABI
Definition Compiler.h:213
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
This file defines the SmallString class.
Root of the metadata hierarchy.
Definition Metadata.h:64
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition SmallString.h:26
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI std::optional< uint64_t > getAllocToken(AllocTokenMode Mode, const AllocTokenMetadata &Metadata, uint64_t MaxTokens)
Calculates stable allocation token ID.
constexpr AllocTokenMode DefaultAllocTokenMode
The default allocation token mode.
Definition AllocToken.h:41
AllocTokenMode
Modes for generating allocation token IDs.
Definition AllocToken.h:24
@ TypeHash
Token ID based on allocated type hash.
Definition AllocToken.h:32
@ Random
Simple mode that returns a statically-assigned random token ID.
Definition AllocToken.h:29
@ Increment
Incrementally increasing token ID.
Definition AllocToken.h:26
@ TypeHashPointerSplit
Token ID based on allocated type hash, where the top half ID-space is reserved for types that contain...
Definition AllocToken.h:37
LLVM_ABI std::optional< AllocTokenMode > getAllocTokenModeFromString(StringRef Name)
Returns the AllocTokenMode from its canonical string name; if an invalid name was provided returns nu...
Metadata about an allocation used to generate a token ID.
Definition AllocToken.h:50
SmallString< 64 > TypeName
Definition AllocToken.h:51