]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/CodeGen/AsmPrinter/AddressPool.cpp
Merge ACPICA 20180105.
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / CodeGen / AsmPrinter / AddressPool.cpp
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"
11 #include "llvm/CodeGen/AsmPrinter.h"
12 #include "llvm/MC/MCStreamer.h"
13 #include "llvm/Target/TargetLoweringObjectFile.h"
14
15 using namespace llvm;
16
17 unsigned AddressPool::getIndex(const MCSymbol *Sym, bool TLS) {
18   HasBeenUsed = true;
19   auto IterBool =
20       Pool.insert(std::make_pair(Sym, AddressPoolEntry(Pool.size(), TLS)));
21   return IterBool.first->second.Number;
22 }
23
24 // Emit addresses into the section given.
25 void AddressPool::emit(AsmPrinter &Asm, MCSection *AddrSection) {
26   if (Pool.empty())
27     return;
28
29   // Start the dwarf addr section.
30   Asm.OutStreamer->SwitchSection(AddrSection);
31
32   // Order the address pool entries by ID
33   SmallVector<const MCExpr *, 64> Entries(Pool.size());
34
35   for (const auto &I : Pool)
36     Entries[I.second.Number] =
37         I.second.TLS
38             ? Asm.getObjFileLowering().getDebugThreadLocalSymbol(I.first)
39             : MCSymbolRefExpr::create(I.first, Asm.OutContext);
40
41   for (const MCExpr *Entry : Entries)
42     Asm.OutStreamer->EmitValue(Entry, Asm.getDataLayout().getPointerSize());
43 }