1c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===- MCContext.h - Machine Code Context -----------------------*- C++ -*-===//
2c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
3c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//                     The LLVM Compiler Infrastructure
4c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
5c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// This file is distributed under the University of Illinois Open Source
6c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// License. See LICENSE.TXT for details.
7c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
8c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===----------------------------------------------------------------------===//
9c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
10c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#ifndef LLVM_MC_MCCONTEXT_H
11c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#define LLVM_MC_MCCONTEXT_H
12c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
13c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/DenseMap.h"
14c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/SetVector.h"
15c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/SmallString.h"
16c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/SmallVector.h"
17c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/StringMap.h"
18c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/StringRef.h"
19c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/Twine.h"
20c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/BinaryFormat/Dwarf.h"
21c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/MC/MCDwarf.h"
22c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/MC/MCSubtargetInfo.h"
23c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/MC/SectionKind.h"
24c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Support/Allocator.h"
25c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Support/Compiler.h"
26c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Support/raw_ostream.h"
27c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <algorithm>
28c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <cassert>
29c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <cstddef>
30c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <cstdint>
31c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <map>
32c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <memory>
33c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <string>
34c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <utility>
35c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <vector>
36c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
37c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotnamespace llvm {
38c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
39c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  class CodeViewContext;
40c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  class MCAsmInfo;
41c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  class MCLabel;
42c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  class MCObjectFileInfo;
43c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  class MCRegisterInfo;
44c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  class MCSection;
45c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  class MCSectionCOFF;
46c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  class MCSectionELF;
47c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  class MCSectionMachO;
48c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  class MCSectionWasm;
49c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  class MCStreamer;
50c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  class MCSymbol;
51c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  class MCSymbolELF;
52c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  class MCSymbolWasm;
53c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  class SMLoc;
54c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  class SourceMgr;
55c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
56c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Context object for machine code objects.  This class owns all of the
57c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// sections that it creates.
58c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
59c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  class MCContext {
60c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  public:
61c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    using SymbolTable = StringMap<MCSymbol *, BumpPtrAllocator &>;
62c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
63c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  private:
64c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// The SourceMgr for this object, if any.
65c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const SourceMgr *SrcMgr;
66c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
67c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// The SourceMgr for inline assembly, if any.
68c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SourceMgr *InlineSrcMgr;
69c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
70c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// The MCAsmInfo for this target.
71c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const MCAsmInfo *MAI;
72c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
73c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// The MCRegisterInfo for this target.
74c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const MCRegisterInfo *MRI;
75c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
76c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// The MCObjectFileInfo for this target.
77c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const MCObjectFileInfo *MOFI;
78c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
79c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    std::unique_ptr<CodeViewContext> CVContext;
80c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
81c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Allocator object used for creating machine code objects.
82c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ///
83c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// We use a bump pointer allocator to avoid the need to track all allocated
84c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// objects.
85c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    BumpPtrAllocator Allocator;
86c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
87c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SpecificBumpPtrAllocator<MCSectionCOFF> COFFAllocator;
88c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SpecificBumpPtrAllocator<MCSectionELF> ELFAllocator;
89c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SpecificBumpPtrAllocator<MCSectionMachO> MachOAllocator;
90c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SpecificBumpPtrAllocator<MCSectionWasm> WasmAllocator;
91c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
92c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Bindings of names to symbols.
93c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SymbolTable Symbols;
94c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
95c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// A mapping from a local label number and an instance count to a symbol.
96c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// For example, in the assembly
97c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ///     1:
98c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ///     2:
99c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ///     1:
100c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// We have three labels represented by the pairs (1, 0), (2, 0) and (1, 1)
101c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    DenseMap<std::pair<unsigned, unsigned>, MCSymbol *> LocalSymbols;
102c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
103c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Keeps tracks of names that were used both for used declared and
104c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// artificial symbols. The value is "true" if the name has been used for a
105c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// non-section symbol (there can be at most one of those, plus an unlimited
106c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// number of section symbols with the same name).
107c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    StringMap<bool, BumpPtrAllocator &> UsedNames;
108c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
109c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// The next ID to dole out to an unnamed assembler temporary symbol with
110c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// a given prefix.
111c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    StringMap<unsigned> NextID;
112c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
113c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Instances of directional local labels.
114c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    DenseMap<unsigned, MCLabel *> Instances;
115c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// NextInstance() creates the next instance of the directional local label
116c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// for the LocalLabelVal and adds it to the map if needed.
117c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    unsigned NextInstance(unsigned LocalLabelVal);
118c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// GetInstance() gets the current instance of the directional local label
119c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// for the LocalLabelVal and adds it to the map if needed.
120c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    unsigned GetInstance(unsigned LocalLabelVal);
121c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
122c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// The file name of the log file from the environment variable
123c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// AS_SECURE_LOG_FILE.  Which must be set before the .secure_log_unique
124c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// directive is used or it is an error.
125c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    char *SecureLogFile;
126c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// The stream that gets written to for the .secure_log_unique directive.
127c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    std::unique_ptr<raw_fd_ostream> SecureLog;
128c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Boolean toggled when .secure_log_unique / .secure_log_reset is seen to
129c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// catch errors if .secure_log_unique appears twice without
130c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// .secure_log_reset appearing between them.
131c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool SecureLogUsed = false;
132c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
133c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// The compilation directory to use for DW_AT_comp_dir.
134c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SmallString<128> CompilationDir;
135c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
136c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// The main file name if passed in explicitly.
137c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    std::string MainFileName;
138c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
139c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// The dwarf file and directory tables from the dwarf .file directive.
140c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// We now emit a line table for each compile unit. To reduce the prologue
141c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// size of each line table, the files and directories used by each compile
142c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// unit are separated.
143c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    std::map<unsigned, MCDwarfLineTable> MCDwarfLineTablesCUMap;
144c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
145c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// The current dwarf line information from the last dwarf .loc directive.
146c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCDwarfLoc CurrentDwarfLoc;
147c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool DwarfLocSeen = false;
148c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
149c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Generate dwarf debugging info for assembly source files.
150c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool GenDwarfForAssembly = false;
151c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
152c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// The current dwarf file number when generate dwarf debugging info for
153c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// assembly source files.
154c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    unsigned GenDwarfFileNumber = 0;
155c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
156c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Sections for generating the .debug_ranges and .debug_aranges sections.
157c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SetVector<MCSection *> SectionsForRanges;
158c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
159c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// The information gathered from labels that will have dwarf label
160c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// entries when generating dwarf assembly source files.
161c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    std::vector<MCGenDwarfLabelEntry> MCGenDwarfLabelEntries;
162c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
163c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// The string to embed in the debug information for the compile unit, if
164c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// non-empty.
165c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    StringRef DwarfDebugFlags;
166c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
167c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// The string to embed in as the dwarf AT_producer for the compile unit, if
168c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// non-empty.
169c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    StringRef DwarfDebugProducer;
170c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
171c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// The maximum version of dwarf that we should emit.
172c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    uint16_t DwarfVersion = 4;
173c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
174c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Honor temporary labels, this is useful for debugging semantic
175c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// differences between temporary and non-temporary labels (primarily on
176c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Darwin).
177c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool AllowTemporaryLabels = true;
178c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool UseNamesOnTempLabels = true;
179c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
180c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// The Compile Unit ID that we are currently processing.
181c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    unsigned DwarfCompileUnitID = 0;
182c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
183c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    struct ELFSectionKey {
184c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      std::string SectionName;
185c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      StringRef GroupName;
186c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      unsigned UniqueID;
187c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
188c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      ELFSectionKey(StringRef SectionName, StringRef GroupName,
189c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                    unsigned UniqueID)
190c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot          : SectionName(SectionName), GroupName(GroupName), UniqueID(UniqueID) {
191c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      }
192c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
193c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      bool operator<(const ELFSectionKey &Other) const {
194c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        if (SectionName != Other.SectionName)
195c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot          return SectionName < Other.SectionName;
196c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        if (GroupName != Other.GroupName)
197c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot          return GroupName < Other.GroupName;
198c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        return UniqueID < Other.UniqueID;
199c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      }
200c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    };
201c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
202c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    struct COFFSectionKey {
203c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      std::string SectionName;
204c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      StringRef GroupName;
205c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      int SelectionKey;
206c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      unsigned UniqueID;
207c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
208c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      COFFSectionKey(StringRef SectionName, StringRef GroupName,
209c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                     int SelectionKey, unsigned UniqueID)
210c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot          : SectionName(SectionName), GroupName(GroupName),
211c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot            SelectionKey(SelectionKey), UniqueID(UniqueID) {}
212c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
213c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      bool operator<(const COFFSectionKey &Other) const {
214c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        if (SectionName != Other.SectionName)
215c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot          return SectionName < Other.SectionName;
216c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        if (GroupName != Other.GroupName)
217c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot          return GroupName < Other.GroupName;
218c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        if (SelectionKey != Other.SelectionKey)
219c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot          return SelectionKey < Other.SelectionKey;
220c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        return UniqueID < Other.UniqueID;
221c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      }
222c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    };
223c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
224c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    struct WasmSectionKey {
225c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      std::string SectionName;
226c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      StringRef GroupName;
227c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      unsigned UniqueID;
228c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
229c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      WasmSectionKey(StringRef SectionName, StringRef GroupName,
230c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                     unsigned UniqueID)
231c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot          : SectionName(SectionName), GroupName(GroupName), UniqueID(UniqueID) {
232c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      }
233c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
234c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      bool operator<(const WasmSectionKey &Other) const {
235c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        if (SectionName != Other.SectionName)
236c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot          return SectionName < Other.SectionName;
237c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        if (GroupName != Other.GroupName)
238c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot          return GroupName < Other.GroupName;
239c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        return UniqueID < Other.UniqueID;
240c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      }
241c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    };
242c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
243c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    StringMap<MCSectionMachO *> MachOUniquingMap;
244c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    std::map<ELFSectionKey, MCSectionELF *> ELFUniquingMap;
245c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    std::map<COFFSectionKey, MCSectionCOFF *> COFFUniquingMap;
246c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    std::map<WasmSectionKey, MCSectionWasm *> WasmUniquingMap;
247c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    StringMap<bool> RelSecNames;
248c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
249c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SpecificBumpPtrAllocator<MCSubtargetInfo> MCSubtargetAllocator;
250c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
251c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Do automatic reset in destructor
252c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool AutoReset;
253c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
254c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool HadError = false;
255c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
256c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSymbol *createSymbolImpl(const StringMapEntry<bool> *Name,
257c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                               bool CanBeUnnamed);
258c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSymbol *createSymbol(StringRef Name, bool AlwaysAddSuffix,
259c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                           bool IsTemporary);
260c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
261c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSymbol *getOrCreateDirectionalLocalSymbol(unsigned LocalLabelVal,
262c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                                unsigned Instance);
263c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
264c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSectionELF *createELFSectionImpl(StringRef Section, unsigned Type,
265c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                       unsigned Flags, SectionKind K,
266c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                       unsigned EntrySize,
267c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                       const MCSymbolELF *Group,
268c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                       unsigned UniqueID,
269c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                       const MCSymbolELF *Associated);
270c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
271c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  public:
272c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    explicit MCContext(const MCAsmInfo *MAI, const MCRegisterInfo *MRI,
273c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                       const MCObjectFileInfo *MOFI,
274c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                       const SourceMgr *Mgr = nullptr, bool DoAutoReset = true);
275c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCContext(const MCContext &) = delete;
276c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCContext &operator=(const MCContext &) = delete;
277c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ~MCContext();
278c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
279c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const SourceMgr *getSourceManager() const { return SrcMgr; }
280c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
281c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void setInlineSourceManager(SourceMgr *SM) { InlineSrcMgr = SM; }
282c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
283c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const MCAsmInfo *getAsmInfo() const { return MAI; }
284c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
285c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const MCRegisterInfo *getRegisterInfo() const { return MRI; }
286c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
287c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const MCObjectFileInfo *getObjectFileInfo() const { return MOFI; }
288c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
289c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CodeViewContext &getCVContext();
290c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
291c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void setAllowTemporaryLabels(bool Value) { AllowTemporaryLabels = Value; }
292c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void setUseNamesOnTempLabels(bool Value) { UseNamesOnTempLabels = Value; }
293c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
294c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// \name Module Lifetime Management
295c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// @{
296c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
297c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// reset - return object to right after construction state to prepare
298c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// to process a new module
299c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void reset();
300c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
301c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// @}
302c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
303c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// \name Symbol Management
304c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// @{
305c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
306c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Create and return a new linker temporary symbol with a unique but
307c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// unspecified name.
308c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSymbol *createLinkerPrivateTempSymbol();
309c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
310c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Create and return a new assembler temporary symbol with a unique but
311c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// unspecified name.
312c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSymbol *createTempSymbol(bool CanBeUnnamed = true);
313c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
314c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSymbol *createTempSymbol(const Twine &Name, bool AlwaysAddSuffix,
315c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                               bool CanBeUnnamed = true);
316c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
317c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Create the definition of a directional local symbol for numbered label
318c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// (used for "1:" definitions).
319c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSymbol *createDirectionalLocalSymbol(unsigned LocalLabelVal);
320c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
321c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Create and return a directional local symbol for numbered label (used
322c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// for "1b" or 1f" references).
323c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSymbol *getDirectionalLocalSymbol(unsigned LocalLabelVal, bool Before);
324c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
325c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Lookup the symbol inside with the specified \p Name.  If it exists,
326c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// return it.  If not, create a forward reference and return it.
327c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ///
328c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// \param Name - The symbol name, which must be unique across all symbols.
329c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSymbol *getOrCreateSymbol(const Twine &Name);
330c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
331c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Gets a symbol that will be defined to the final stack offset of a local
332c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// variable after codegen.
333c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ///
334c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// \param Idx - The index of a local variable passed to @llvm.localescape.
335c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSymbol *getOrCreateFrameAllocSymbol(StringRef FuncName, unsigned Idx);
336c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
337c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSymbol *getOrCreateParentFrameOffsetSymbol(StringRef FuncName);
338c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
339c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSymbol *getOrCreateLSDASymbol(StringRef FuncName);
340c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
341c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Get the symbol for \p Name, or null.
342c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSymbol *lookupSymbol(const Twine &Name) const;
343c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
344c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Set value for a symbol.
345c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void setSymbolValue(MCStreamer &Streamer, StringRef Sym, uint64_t Val);
346c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
347c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// getSymbols - Get a reference for the symbol table for clients that
348c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// want to, for example, iterate over all symbols. 'const' because we
349c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// still want any modifications to the table itself to use the MCContext
350c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// APIs.
351c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const SymbolTable &getSymbols() const { return Symbols; }
352c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
353c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// @}
354c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
355c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// \name Section Management
356c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// @{
357c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
358c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    enum : unsigned {
359c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      /// Pass this value as the UniqueID during section creation to get the
360c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      /// generic section with the given name and characteristics. The usual
361c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      /// sections such as .text use this ID.
362c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      GenericSectionID = ~0U
363c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    };
364c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
365c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Return the MCSection for the specified mach-o section.  This requires
366c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// the operands to be valid.
367c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSectionMachO *getMachOSection(StringRef Segment, StringRef Section,
368c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                    unsigned TypeAndAttributes,
369c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                    unsigned Reserved2, SectionKind K,
370c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                    const char *BeginSymName = nullptr);
371c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
372c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSectionMachO *getMachOSection(StringRef Segment, StringRef Section,
373c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                    unsigned TypeAndAttributes, SectionKind K,
374c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                    const char *BeginSymName = nullptr) {
375c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return getMachOSection(Segment, Section, TypeAndAttributes, 0, K,
376c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                             BeginSymName);
377c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
378c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
379c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
380c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                unsigned Flags) {
381c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return getELFSection(Section, Type, Flags, 0, "");
382c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
383c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
384c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
385c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                unsigned Flags, unsigned EntrySize,
386c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                const Twine &Group) {
387c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return getELFSection(Section, Type, Flags, EntrySize, Group, ~0);
388c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
389c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
390c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
391c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                unsigned Flags, unsigned EntrySize,
392c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                const Twine &Group, unsigned UniqueID) {
393c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return getELFSection(Section, Type, Flags, EntrySize, Group, UniqueID,
394c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                           nullptr);
395c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
396c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
397c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
398c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                unsigned Flags, unsigned EntrySize,
399c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                const Twine &Group, unsigned UniqueID,
400c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                const MCSymbolELF *Associated);
401c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
402c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
403c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                unsigned Flags, unsigned EntrySize,
404c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                const MCSymbolELF *Group, unsigned UniqueID,
405c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                const MCSymbolELF *Associated);
406c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
407c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Get a section with the provided group identifier. This section is
408c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// named by concatenating \p Prefix with '.' then \p Suffix. The \p Type
409c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// describes the type of the section and \p Flags are used to further
410c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// configure this named section.
411c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSectionELF *getELFNamedSection(const Twine &Prefix, const Twine &Suffix,
412c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                     unsigned Type, unsigned Flags,
413c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                     unsigned EntrySize = 0);
414c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
415c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSectionELF *createELFRelSection(const Twine &Name, unsigned Type,
416c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                      unsigned Flags, unsigned EntrySize,
417c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                      const MCSymbolELF *Group,
418c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                      const MCSectionELF *RelInfoSection);
419c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
420c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void renameELFSection(MCSectionELF *Section, StringRef Name);
421c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
422c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSectionELF *createELFGroupSection(const MCSymbolELF *Group);
423c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
424c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSectionCOFF *getCOFFSection(StringRef Section, unsigned Characteristics,
425c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  SectionKind Kind, StringRef COMDATSymName,
426c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  int Selection,
427c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  unsigned UniqueID = GenericSectionID,
428c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  const char *BeginSymName = nullptr);
429c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
430c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSectionCOFF *getCOFFSection(StringRef Section, unsigned Characteristics,
431c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  SectionKind Kind,
432c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  const char *BeginSymName = nullptr);
433c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
434c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSectionCOFF *getCOFFSection(StringRef Section);
435c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
436c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Gets or creates a section equivalent to Sec that is associated with the
437c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// section containing KeySym. For example, to create a debug info section
438c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// associated with an inline function, pass the normal debug info section
439c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// as Sec and the function symbol as KeySym.
440c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSectionCOFF *
441c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    getAssociativeCOFFSection(MCSectionCOFF *Sec, const MCSymbol *KeySym,
442c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                              unsigned UniqueID = GenericSectionID);
443c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
444c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSectionWasm *getWasmSection(const Twine &Section, unsigned Type) {
445c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return getWasmSection(Section, Type, nullptr);
446c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
447c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
448c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSectionWasm *getWasmSection(const Twine &Section, unsigned Type,
449c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  const char *BeginSymName) {
450c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return getWasmSection(Section, Type, "", ~0, BeginSymName);
451c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
452c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
453c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSectionWasm *getWasmSection(const Twine &Section, unsigned Type,
454c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  const Twine &Group, unsigned UniqueID) {
455c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return getWasmSection(Section, Type, Group, UniqueID, nullptr);
456c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
457c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
458c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSectionWasm *getWasmSection(const Twine &Section, unsigned Type,
459c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  const Twine &Group, unsigned UniqueID,
460c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  const char *BeginSymName);
461c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
462c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSectionWasm *getWasmSection(const Twine &Section, unsigned Type,
463c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  const MCSymbolWasm *Group, unsigned UniqueID,
464c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  const char *BeginSymName);
465c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
466c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // Create and save a copy of STI and return a reference to the copy.
467c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCSubtargetInfo &getSubtargetCopy(const MCSubtargetInfo &STI);
468c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
469c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// @}
470c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
471c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// \name Dwarf Management
472c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// @{
473c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
474c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// \brief Get the compilation directory for DW_AT_comp_dir
475c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// The compilation directory should be set with \c setCompilationDir before
476c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// calling this function. If it is unset, an empty string will be returned.
477c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    StringRef getCompilationDir() const { return CompilationDir; }
478c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
479c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// \brief Set the compilation directory for DW_AT_comp_dir
480c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void setCompilationDir(StringRef S) { CompilationDir = S.str(); }
481c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
482c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// \brief Get the main file name for use in error messages and debug
483c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// info. This can be set to ensure we've got the correct file name
484c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// after preprocessing or for -save-temps.
485c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const std::string &getMainFileName() const { return MainFileName; }
486c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
487c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// \brief Set the main file name and override the default.
488c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void setMainFileName(StringRef S) { MainFileName = S; }
489c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
490c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Creates an entry in the dwarf file and directory tables.
491c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    unsigned getDwarfFile(StringRef Directory, StringRef FileName,
492c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                          unsigned FileNumber, unsigned CUID);
493c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
494c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID = 0);
495c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
496c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const std::map<unsigned, MCDwarfLineTable> &getMCDwarfLineTables() const {
497c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return MCDwarfLineTablesCUMap;
498c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
499c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
500c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MCDwarfLineTable &getMCDwarfLineTable(unsigned CUID) {
501c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return MCDwarfLineTablesCUMap[CUID];
502c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
503c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
504c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const MCDwarfLineTable &getMCDwarfLineTable(unsigned CUID) const {
505c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      auto I = MCDwarfLineTablesCUMap.find(CUID);
506c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      assert(I != MCDwarfLineTablesCUMap.end());
507c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return I->second;
508c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
509c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
510c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const SmallVectorImpl<MCDwarfFile> &getMCDwarfFiles(unsigned CUID = 0) {
511c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return getMCDwarfLineTable(CUID).getMCDwarfFiles();
512c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
513c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
514c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const SmallVectorImpl<std::string> &getMCDwarfDirs(unsigned CUID = 0) {
515c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return getMCDwarfLineTable(CUID).getMCDwarfDirs();
516c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
517c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
518c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool hasMCLineSections() const {
519c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      for (const auto &Table : MCDwarfLineTablesCUMap)
520c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        if (!Table.second.getMCDwarfFiles().empty() || Table.second.getLabel())
521c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot          return true;
522c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return false;
523c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
524c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
525c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    unsigned getDwarfCompileUnitID() { return DwarfCompileUnitID; }
526c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
527c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void setDwarfCompileUnitID(unsigned CUIndex) {
528c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      DwarfCompileUnitID = CUIndex;
529c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
530c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
531c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void setMCLineTableCompilationDir(unsigned CUID, StringRef CompilationDir) {
532c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      getMCDwarfLineTable(CUID).setCompilationDir(CompilationDir);
533c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
534c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
535c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Saves the information from the currently parsed dwarf .loc directive
536c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// and sets DwarfLocSeen.  When the next instruction is assembled an entry
537c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// in the line number table with this information and the address of the
538c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// instruction will be created.
539c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void setCurrentDwarfLoc(unsigned FileNum, unsigned Line, unsigned Column,
540c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                            unsigned Flags, unsigned Isa,
541c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                            unsigned Discriminator) {
542c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      CurrentDwarfLoc.setFileNum(FileNum);
543c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      CurrentDwarfLoc.setLine(Line);
544c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      CurrentDwarfLoc.setColumn(Column);
545c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      CurrentDwarfLoc.setFlags(Flags);
546c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      CurrentDwarfLoc.setIsa(Isa);
547c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      CurrentDwarfLoc.setDiscriminator(Discriminator);
548c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      DwarfLocSeen = true;
549c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
550c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
551c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void clearDwarfLocSeen() { DwarfLocSeen = false; }
552c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
553c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool getDwarfLocSeen() { return DwarfLocSeen; }
554c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const MCDwarfLoc &getCurrentDwarfLoc() { return CurrentDwarfLoc; }
555c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
556c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool getGenDwarfForAssembly() { return GenDwarfForAssembly; }
557c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void setGenDwarfForAssembly(bool Value) { GenDwarfForAssembly = Value; }
558c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    unsigned getGenDwarfFileNumber() { return GenDwarfFileNumber; }
559c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
560c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void setGenDwarfFileNumber(unsigned FileNumber) {
561c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      GenDwarfFileNumber = FileNumber;
562c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
563c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
564c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const SetVector<MCSection *> &getGenDwarfSectionSyms() {
565c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return SectionsForRanges;
566c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
567c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
568c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool addGenDwarfSection(MCSection *Sec) {
569c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return SectionsForRanges.insert(Sec);
570c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
571c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
572c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void finalizeDwarfSections(MCStreamer &MCOS);
573c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
574c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const std::vector<MCGenDwarfLabelEntry> &getMCGenDwarfLabelEntries() const {
575c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return MCGenDwarfLabelEntries;
576c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
577c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
578c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void addMCGenDwarfLabelEntry(const MCGenDwarfLabelEntry &E) {
579c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      MCGenDwarfLabelEntries.push_back(E);
580c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
581c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
582c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void setDwarfDebugFlags(StringRef S) { DwarfDebugFlags = S; }
583c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    StringRef getDwarfDebugFlags() { return DwarfDebugFlags; }
584c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
585c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void setDwarfDebugProducer(StringRef S) { DwarfDebugProducer = S; }
586c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    StringRef getDwarfDebugProducer() { return DwarfDebugProducer; }
587c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
588c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    dwarf::DwarfFormat getDwarfFormat() const {
589c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      // TODO: Support DWARF64
590c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return dwarf::DWARF32;
591c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
592c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
593c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void setDwarfVersion(uint16_t v) { DwarfVersion = v; }
594c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    uint16_t getDwarfVersion() const { return DwarfVersion; }
595c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
596c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// @}
597c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
598c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    char *getSecureLogFile() { return SecureLogFile; }
599c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    raw_fd_ostream *getSecureLog() { return SecureLog.get(); }
600c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
601c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void setSecureLog(std::unique_ptr<raw_fd_ostream> Value) {
602c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      SecureLog = std::move(Value);
603c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
604c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
605c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool getSecureLogUsed() { return SecureLogUsed; }
606c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void setSecureLogUsed(bool Value) { SecureLogUsed = Value; }
607c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
608c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void *allocate(unsigned Size, unsigned Align = 8) {
609c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return Allocator.Allocate(Size, Align);
610c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
611c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
612c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void deallocate(void *Ptr) {}
613c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
614c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool hadError() { return HadError; }
615c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void reportError(SMLoc L, const Twine &Msg);
616c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // Unrecoverable error has occurred. Display the best diagnostic we can
617c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // and bail via exit(1). For now, most MC backend errors are unrecoverable.
618c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // FIXME: We should really do something about that.
619c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    LLVM_ATTRIBUTE_NORETURN void reportFatalError(SMLoc L,
620c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                                  const Twine &Msg);
621c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  };
622c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
623c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} // end namespace llvm
624c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
625c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// operator new and delete aren't allowed inside namespaces.
626c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// The throw specifications are mandated by the standard.
627c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \brief Placement new for using the MCContext's allocator.
628c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot///
629c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// This placement form of operator new uses the MCContext's allocator for
630c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// obtaining memory. It is a non-throwing new, which means that it returns
631c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// null on error. (If that is what the allocator does. The current does, so if
632c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// this ever changes, this operator will have to be changed, too.)
633c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Usage looks like this (assuming there's an MCContext 'Context' in scope):
634c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \code
635c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// // Default alignment (8)
636c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// IntegerLiteral *Ex = new (Context) IntegerLiteral(arguments);
637c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// // Specific alignment
638c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// IntegerLiteral *Ex2 = new (Context, 4) IntegerLiteral(arguments);
639c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \endcode
640c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Please note that you cannot use delete on the pointer; it must be
641c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// deallocated using an explicit destructor call followed by
642c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \c Context.Deallocate(Ptr).
643c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot///
644c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \param Bytes The number of bytes to allocate. Calculated by the compiler.
645c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \param C The MCContext that provides the allocator.
646c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \param Alignment The alignment of the allocated memory (if the underlying
647c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot///                  allocator supports it).
648c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \return The allocated memory. Could be NULL.
649c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline void *operator new(size_t Bytes, llvm::MCContext &C,
650c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                          size_t Alignment = 8) noexcept {
651c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return C.allocate(Bytes, Alignment);
652c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
653c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \brief Placement delete companion to the new above.
654c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot///
655c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// This operator is just a companion to the new above. There is no way of
656c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// invoking it directly; see the new operator for more details. This operator
657c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// is called implicitly by the compiler if a placement new expression using
658c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// the MCContext throws in the object constructor.
659c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline void operator delete(void *Ptr, llvm::MCContext &C, size_t) noexcept {
660c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  C.deallocate(Ptr);
661c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
662c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
663c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// This placement form of operator new[] uses the MCContext's allocator for
664c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// obtaining memory. It is a non-throwing new[], which means that it returns
665c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// null on error.
666c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Usage looks like this (assuming there's an MCContext 'Context' in scope):
667c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \code
668c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// // Default alignment (8)
669c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// char *data = new (Context) char[10];
670c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// // Specific alignment
671c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// char *data = new (Context, 4) char[10];
672c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \endcode
673c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Please note that you cannot use delete on the pointer; it must be
674c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// deallocated using an explicit destructor call followed by
675c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \c Context.Deallocate(Ptr).
676c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot///
677c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \param Bytes The number of bytes to allocate. Calculated by the compiler.
678c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \param C The MCContext that provides the allocator.
679c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \param Alignment The alignment of the allocated memory (if the underlying
680c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot///                  allocator supports it).
681c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \return The allocated memory. Could be NULL.
682c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline void *operator new[](size_t Bytes, llvm::MCContext &C,
683c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                            size_t Alignment = 8) noexcept {
684c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return C.allocate(Bytes, Alignment);
685c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
686c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
687c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \brief Placement delete[] companion to the new[] above.
688c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot///
689c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// This operator is just a companion to the new[] above. There is no way of
690c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// invoking it directly; see the new[] operator for more details. This operator
691c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// is called implicitly by the compiler if a placement new[] expression using
692c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// the MCContext throws in the object constructor.
693c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline void operator delete[](void *Ptr, llvm::MCContext &C) noexcept {
694c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  C.deallocate(Ptr);
695c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
696c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
697c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#endif // LLVM_MC_MCCONTEXT_H
698