Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
DWPStringPool.h
Go to the documentation of this file.
1#ifndef LLVM_DWP_DWPSTRINGPOOL_H
2#define LLVM_DWP_DWPSTRINGPOOL_H
3
4#include "llvm/ADT/DenseMap.h"
5#include "llvm/MC/MCSection.h"
6#include "llvm/MC/MCStreamer.h"
7#include <cassert>
8
9namespacellvm {
10classDWPStringPool {
11
12structCStrDenseMapInfo {
13staticinlineconstchar *getEmptyKey() {
14returnreinterpret_cast<constchar *>(~static_cast<uintptr_t>(0));
15 }
16staticinlineconstchar *getTombstoneKey() {
17returnreinterpret_cast<constchar *>(~static_cast<uintptr_t>(1));
18 }
19staticunsigned getHashValue(constchar *Val) {
20assert(Val != getEmptyKey() &&"Cannot hash the empty key!");
21assert(Val != getTombstoneKey() &&"Cannot hash the tombstone key!");
22return (unsigned)hash_value(StringRef(Val));
23 }
24staticboolisEqual(constchar *LHS,constchar *RHS) {
25if (RHS == getEmptyKey())
26returnLHS == getEmptyKey();
27if (RHS == getTombstoneKey())
28returnLHS == getTombstoneKey();
29return strcmp(LHS,RHS) == 0;
30 }
31 };
32
33MCStreamer &Out;
34MCSection *Sec;
35DenseMap<const char *, uint32_t, CStrDenseMapInfo> Pool;
36uint32_t Offset = 0;
37
38public:
39DWPStringPool(MCStreamer &Out,MCSection *Sec) : Out(Out), Sec(Sec) {}
40
41uint32_tgetOffset(constchar *Str,unsignedLength) {
42assert(strlen(Str) + 1 ==Length &&"Ensure length hint is correct");
43
44auto Pair = Pool.insert(std::make_pair(Str, Offset));
45if (Pair.second) {
46 Out.switchSection(Sec);
47 Out.emitBytes(StringRef(Str,Length));
48 Offset +=Length;
49 }
50
51return Pair.first->second;
52 }
53};
54}// namespace llvm
55
56#endif// LLVM_DWP_DWPSTRINGPOOL_H
DenseMap.h
This file defines the DenseMap class.
MCSection.h
MCStreamer.h
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
RHS
Value * RHS
Definition:X86PartialReduction.cpp:74
LHS
Value * LHS
Definition:X86PartialReduction.cpp:73
llvm::DWPStringPool
Definition:DWPStringPool.h:10
llvm::DWPStringPool::getOffset
uint32_t getOffset(const char *Str, unsigned Length)
Definition:DWPStringPool.h:41
llvm::DWPStringPool::DWPStringPool
DWPStringPool(MCStreamer &Out, MCSection *Sec)
Definition:DWPStringPool.h:39
llvm::DenseMapBase::insert
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition:DenseMap.h:211
llvm::DenseMap
Definition:DenseMap.h:727
llvm::MCSection
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition:MCSection.h:36
llvm::MCStreamer
Streaming machine code generation interface.
Definition:MCStreamer.h:213
llvm::MCStreamer::switchSection
virtual void switchSection(MCSection *Section, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
Definition:MCStreamer.cpp:1303
llvm::MCStreamer::emitBytes
virtual void emitBytes(StringRef Data)
Emit the bytes in Data into the output.
Definition:MCStreamer.cpp:1266
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:StringRef.h:51
uint32_t
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::Length
@ Length
Definition:DWP.cpp:480
llvm::hash_value
hash_code hash_value(const FixedPointSemantics &Val)
Definition:APFixedPoint.h:136
llvm::isEqual
bool isEqual(const GCNRPTracker::LiveRegSet &S1, const GCNRPTracker::LiveRegSet &S2)
Definition:GCNRegPressure.cpp:22

Generated on Thu Jul 17 2025 10:00:36 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp