LLVM: lib/MC/ConstantPools.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
19
20using namespace llvm;
21
22
23
24
25
27 if (Entries.empty())
28 return;
33 Streamer.emitValue(Entry.Value, Entry.Size, Entry.Loc);
34 }
36 Entries.clear();
37}
38
43
44
45 if (C) {
46 auto CItr = CachedConstantEntries.find(std::make_pair(C->getValue(), Size));
47 if (CItr != CachedConstantEntries.end())
48 return CItr->second;
49 }
50
51
52 if (S) {
53 auto SItr =
54 CachedSymbolEntries.find(std::make_pair(&(S->getSymbol()), Size));
55 if (SItr != CachedSymbolEntries.end())
56 return SItr->second;
57 }
58
59 MCSymbol *CPEntryLabel = Context.createTempSymbol();
60
63 if (C)
64 CachedConstantEntries[std::make_pair(C->getValue(), Size)] = SymRef;
65 if (S)
66 CachedSymbolEntries[std::make_pair(&(S->getSymbol()), Size)] = SymRef;
67 return SymRef;
68}
69
71
73 CachedConstantEntries.clear();
74 CachedSymbolEntries.clear();
75}
76
77
78
79
82 if (CP == ConstantPools.end())
83 return nullptr;
84
85 return &CP->second;
86}
87
89AssemblerConstantPools::getOrCreateConstantPool(MCSection *Section) {
90 return ConstantPools[Section];
91}
92
95 if (!CP.empty()) {
97 CP.emitEntries(Streamer);
98 }
99}
100
102
103 for (auto &CPI : ConstantPools) {
106
108 }
109}
110
116
119 if (ConstantPool *CP = getConstantPool(Section))
120 CP->clearCache();
121}
122
127 return getOrCreateConstantPool(Section).addEntry(Expr, Streamer.getContext(),
129}
static void emitConstantPool(MCStreamer &Streamer, MCSection *Section, ConstantPool &CP)
Definition ConstantPools.cpp:93
void emitAll(MCStreamer &Streamer)
Definition ConstantPools.cpp:101
void clearCacheForCurrentSection(MCStreamer &Streamer)
Definition ConstantPools.cpp:117
void emitForCurrentSection(MCStreamer &Streamer)
Definition ConstantPools.cpp:111
const MCExpr * addEntry(MCStreamer &Streamer, const MCExpr *Expr, unsigned Size, SMLoc Loc)
Definition ConstantPools.cpp:123
void clearCache()
Definition ConstantPools.cpp:72
const MCExpr * addEntry(const MCExpr *Value, MCContext &Context, unsigned Size, SMLoc Loc)
Definition ConstantPools.cpp:39
void emitEntries(MCStreamer &Streamer)
Definition ConstantPools.cpp:26
bool empty()
Definition ConstantPools.cpp:70
Context object for machine code objects.
Base class for the full range of assembler expressions which are needed for parsing.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Streaming machine code generation interface.
MCContext & getContext() const
void emitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
virtual void emitValueToAlignment(Align Alignment, int64_t Fill=0, uint8_t FillLen=1, unsigned MaxBytesToEmit=0)
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
virtual void emitDataRegion(MCDataRegionType Kind)
Note in the output the specified region Kind.
virtual void switchSection(MCSection *Section, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
MCSection * getCurrentSectionOnly() const
Represent a reference to a symbol from inside an expression.
const MCSymbol & getSymbol() const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
typename SmallVector< std::pair< MCSection *, ConstantPool >, 0 >::iterator iterator
iterator find(const KeyT &Key)
Represents a location in source code.
LLVM Value Representation.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
@ MCDR_DataRegionEnd
.end_data_region
@ MCDR_DataRegion
.data_region
This struct is a compact representation of a valid (non-zero power of two) alignment.