LLVM  14.0.0git
ItaniumManglingCanonicalizer.h
Go to the documentation of this file.
1 //===--- ItaniumManglingCanonicalizer.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 // This file defines a class for computing equivalence classes of mangled names
10 // given a set of equivalences between name fragments.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_SUPPORT_ITANIUMMANGLINGCANONICALIZER_H
15 #define LLVM_SUPPORT_ITANIUMMANGLINGCANONICALIZER_H
16 
17 #include <cstddef>
18 #include <cstdint>
19 
20 namespace llvm {
21 
22 class StringRef;
23 
24 /// Canonicalizer for mangled names.
25 ///
26 /// This class allows specifying a list of "equivalent" manglings. For example,
27 /// you can specify that Ss is equivalent to
28 /// NSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE
29 /// and then manglings that refer to libstdc++'s 'std::string' will be
30 /// considered equivalent to manglings that are the same except that they refer
31 /// to libc++'s 'std::string'.
32 ///
33 /// This can be used when data (eg, profiling data) is available for a version
34 /// of a program built in a different configuration, with correspondingly
35 /// different manglings.
37 public:
40  void operator=(const ItaniumManglingCanonicalizer &) = delete;
42 
43  enum class EquivalenceError {
44  Success,
45 
46  /// Both the equivalent manglings have already been used as components of
47  /// some other mangling we've looked at. It's too late to add this
48  /// equivalence.
50 
51  /// The first equivalent mangling is invalid.
53 
54  /// The second equivalent mangling is invalid.
56  };
57 
58  enum class FragmentKind {
59  /// The mangling fragment is a <name> (or a predefined <substitution>).
60  Name,
61  /// The mangling fragment is a <type>.
62  Type,
63  /// The mangling fragment is an <encoding>.
64  Encoding,
65  };
66 
67  /// Add an equivalence between \p First and \p Second. Both manglings must
68  /// live at least as long as the canonicalizer.
70  StringRef Second);
71 
72  using Key = uintptr_t;
73 
74  /// Form a canonical key for the specified mangling. They key will be the
75  /// same for all equivalent manglings, and different for any two
76  /// non-equivalent manglings, but is otherwise unspecified.
77  ///
78  /// Returns Key() if (and only if) the mangling is not a valid Itanium C++
79  /// ABI mangling.
80  ///
81  /// The string denoted by Mangling must live as long as the canonicalizer.
82  Key canonicalize(StringRef Mangling);
83 
84  /// Find a canonical key for the specified mangling, if one has already been
85  /// formed. Otherwise returns Key().
86  Key lookup(StringRef Mangling);
87 
88 private:
89  struct Impl;
90  Impl *P;
91 };
92 } // namespace llvm
93 
94 #endif // LLVM_SUPPORT_ITANIUMMANGLINGCANONICALIZER_H
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::ItaniumManglingCanonicalizer::FragmentKind::Type
@ Type
The mangling fragment is a <type>.
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::ItaniumManglingCanonicalizer
Canonicalizer for mangled names.
Definition: ItaniumManglingCanonicalizer.h:36
llvm::ItaniumManglingCanonicalizer::FragmentKind
FragmentKind
Definition: ItaniumManglingCanonicalizer.h:58
llvm::ItaniumManglingCanonicalizer::ItaniumManglingCanonicalizer
ItaniumManglingCanonicalizer()
Definition: ItaniumManglingCanonicalizer.cpp:216
llvm::ItaniumManglingCanonicalizer::Impl
Definition: ItaniumManglingCanonicalizer.cpp:212
llvm::ItaniumManglingCanonicalizer::EquivalenceError::Success
@ Success
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::ItaniumManglingCanonicalizer::~ItaniumManglingCanonicalizer
~ItaniumManglingCanonicalizer()
Definition: ItaniumManglingCanonicalizer.cpp:217
llvm::ItaniumManglingCanonicalizer::operator=
void operator=(const ItaniumManglingCanonicalizer &)=delete
llvm::ItaniumManglingCanonicalizer::FragmentKind::Name
@ Name
The mangling fragment is a <name> (or a predefined <substitution>).
llvm::ItaniumManglingCanonicalizer::FragmentKind::Encoding
@ Encoding
The mangling fragment is an <encoding>.
llvm::ItaniumManglingCanonicalizer::EquivalenceError::InvalidSecondMangling
@ InvalidSecondMangling
The second equivalent mangling is invalid.
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::ItaniumManglingCanonicalizer::EquivalenceError::InvalidFirstMangling
@ InvalidFirstMangling
The first equivalent mangling is invalid.
llvm::ItaniumManglingCanonicalizer::EquivalenceError::ManglingAlreadyUsed
@ ManglingAlreadyUsed
Both the equivalent manglings have already been used as components of some other mangling we've looke...
llvm::ItaniumManglingCanonicalizer::EquivalenceError
EquivalenceError
Definition: ItaniumManglingCanonicalizer.h:43
llvm::ItaniumManglingCanonicalizer::canonicalize
Key canonicalize(StringRef Mangling)
Form a canonical key for the specified mangling.
Definition: ItaniumManglingCanonicalizer.cpp:315
llvm::ItaniumManglingCanonicalizer::addEquivalence
EquivalenceError addEquivalence(FragmentKind Kind, StringRef First, StringRef Second)
Add an equivalence between First and Second.
Definition: ItaniumManglingCanonicalizer.cpp:220
llvm::ItaniumManglingCanonicalizer::lookup
Key lookup(StringRef Mangling)
Find a canonical key for the specified mangling, if one has already been formed.
Definition: ItaniumManglingCanonicalizer.cpp:320
llvm::ItaniumManglingCanonicalizer::Key
uintptr_t Key
Definition: ItaniumManglingCanonicalizer.h:72