LLVM 24.0.0git
Mangling.h
Go to the documentation of this file.
1//===------ Mangling.h -- Name Mangling Utilities for ORC -------*- 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// Name mangling utilities for ORC.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_EXECUTIONENGINE_ORC_MANGLING_H
14#define LLVM_EXECUTIONENGINE_ORC_MANGLING_H
15
19#include "llvm/IR/Module.h"
23
24namespace llvm::orc {
25
26/// Mangles symbol names then uniques them in the context of an
27/// ExecutionSession.
29public:
31
33 : ES(ES), M(std::move(M)) {}
37 : ES(ES), M(ES.getTargetTriple(), ABIName) {}
39 : ES(ES), M(DL.getStringRepresentation()) {}
40
41 const Mangler &mangler() const { return M; }
42
44 return M.withMangledNameDo(
45 [this](StringRef MangledName) { return ES.intern(MangledName); },
46 NameSpec);
47 }
48
50 return (*this)(SymbolNameSpec(Name, SymbolNameKind::IR));
51 }
52
53private:
55 Mangler M;
56};
57
58/// Maps IR global values to their linker symbol names / flags.
59///
60/// This utility can be used when adding new IR globals in the JIT.
62public:
64 bool EmulatedTLS = false;
65 };
66
67 using SymbolNameToDefinitionMap = std::map<SymbolStringPtr, GlobalValue *>;
68
69 /// Add mangled symbols for the given GlobalValues to SymbolFlags.
70 /// If a SymbolToDefinitionMap pointer is supplied then it will be populated
71 /// with Name-to-GlobalValue* mappings. Note that this mapping is not
72 /// necessarily one-to-one: thread-local GlobalValues, for example, may
73 /// produce more than one symbol, in which case the map will contain duplicate
74 /// values.
75 LLVM_ABI static void
78 SymbolNameToDefinitionMap *SymbolToDefinition = nullptr);
79};
80
81} // namespace llvm::orc
82
83#endif // LLVM_EXECUTIONENGINE_ORC_MANGLING_H
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
#define LLVM_ABI
Definition Compiler.h:215
Module.h This file contains the declarations for the Module class.
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")))
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
An ExecutionSession represents a running JIT program.
Definition Core.h:1111
Maps IR global values to their linker symbol names / flags.
Definition Mangling.h:61
static LLVM_ABI void add(ExecutionSession &ES, const ManglingOptions &MO, ArrayRef< GlobalValue * > GVs, SymbolFlagsMap &SymbolFlags, SymbolNameToDefinitionMap *SymbolToDefinition=nullptr)
Add mangled symbols for the given GlobalValues to SymbolFlags.
Definition Mangling.cpp:17
std::map< SymbolStringPtr, GlobalValue * > SymbolNameToDefinitionMap
Definition Mangling.h:67
SymbolStringPtr operator()(StringRef Name)
Definition Mangling.h:49
const Mangler & mangler() const
Definition Mangling.h:41
MangleAndInterner(ExecutionSession &ES, Mangler M)
Definition Mangling.h:32
SymbolStringPtr operator()(const SymbolNameSpec &NameSpec)
Definition Mangling.h:43
MangleAndInterner(ExecutionSession &ES, StringRef ABIName="")
Definition Mangling.h:36
MangleAndInterner(ExecutionSession &ES, ManglingMode Mode)
Definition Mangling.h:34
Mangler::Mode ManglingMode
Definition Mangling.h:30
MangleAndInterner(ExecutionSession &ES, const DataLayout &DL)
Definition Mangling.h:38
Applies linker name-mangling for a target.
Definition Mangler.h:28
Mode
The linker name-mangling scheme for a target, determined by its object format.
Definition Mangler.h:33
A symbol name together with the naming level (SymbolNameKind) it is expressed in, so that a Mangler /...
Pointer to a pooled string representing a symbol name.
DenseMap< SymbolStringPtr, JITSymbolFlags > SymbolFlagsMap
A map from symbol names (as SymbolStringPtrs) to JITSymbolFlags.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1917
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878