LLVM  3.7.0
AddressPool.cpp
Go to the documentation of this file.
1 //===-- llvm/CodeGen/AddressPool.cpp - Dwarf Debug Framework ---*- C++ -*--===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "AddressPool.h"
12 #include "llvm/MC/MCStreamer.h"
14 
15 using namespace llvm;
16 
17 class MCExpr;
18 
19 unsigned AddressPool::getIndex(const MCSymbol *Sym, bool TLS) {
20  HasBeenUsed = true;
21  auto IterBool =
22  Pool.insert(std::make_pair(Sym, AddressPoolEntry(Pool.size(), TLS)));
23  return IterBool.first->second.Number;
24 }
25 
26 // Emit addresses into the section given.
27 void AddressPool::emit(AsmPrinter &Asm, MCSection *AddrSection) {
28  if (Pool.empty())
29  return;
30 
31  // Start the dwarf addr section.
32  Asm.OutStreamer->SwitchSection(AddrSection);
33 
34  // Order the address pool entries by ID
35  SmallVector<const MCExpr *, 64> Entries(Pool.size());
36 
37  for (const auto &I : Pool)
38  Entries[I.second.Number] =
39  I.second.TLS
41  : MCSymbolRefExpr::create(I.first, Asm.OutContext);
42 
43  for (const MCExpr *Entry : Entries)
44  Asm.OutStreamer->EmitValue(Entry, Asm.getDataLayout().getPointerSize());
45 }
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:48
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition: AsmPrinter.h:83
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:315
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:39
const DataLayout & getDataLayout() const
Return information about data layout.
Definition: AsmPrinter.cpp:139
MCContext & OutContext
This is the context for the output file that we are streaming.
Definition: AsmPrinter.h:78
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:33
virtual const MCExpr * getDebugThreadLocalSymbol(const MCSymbol *Sym) const
Create a symbol reference to describe the given TLS variable when emitting the address in debug info...
void emit(AsmPrinter &Asm, MCSection *AddrSection)
Definition: AddressPool.cpp:27
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:66
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:861
#define I(x, y, z)
Definition: MD5.cpp:54
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
Definition: AsmPrinter.cpp:134
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size FIXME: The defaults need to be removed once all of the backends/clients are updat...
Definition: DataLayout.cpp:593
unsigned getIndex(const MCSymbol *Sym, bool TLS=false)
Returns the index into the address pool with the given label/symbol.
Definition: AddressPool.cpp:19