LLVM: lib/DWARFLinker/Parallel/DWARFEmitterImpl.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

20

21using namespace llvm;

24

26 StringRef Swift5ReflectionSegmentName) {

27 std::string ErrorStr;

28 std::string TripleName;

29

30

31 const Target *TheTarget =

33 if (!TheTarget)

34 return createStringError(std::errc::invalid_argument, ErrorStr.c_str());

35 TripleName = TheTriple.getTriple();

36

37

39 if (!MRI)

41 "no register info for target %s",

42 TripleName.c_str());

43

47 MAI.reset(TheTarget->createMCAsmInfo(*MRI, TheTriple, MCOptions));

48 if (!MAI)

50 "no asm info for target %s", TripleName.c_str());

51

53 if (!MSTI)

55 "no subtarget info for target %s",

56 TripleName.c_str());

57

58 MC.reset(new MCContext(TheTriple, MAI.get(), MRI.get(), MSTI.get(), nullptr,

59 nullptr, true, Swift5ReflectionSegmentName));

61 MC->setObjectFileInfo(MOFI.get());

62

64 if (!MAB)

66 "no asm backend for target %s",

67 TripleName.c_str());

68

70 if (!MII)

72 "no instr info info for target %s",

73 TripleName.c_str());

74

76 if (!MCE)

78 "no code emitter for target %s",

79 TripleName.c_str());

80

81 switch (OutFileType) {

84 TheTriple, MAI->getAssemblerDialect(), *MAI, *MII, *MRI));

86 *MC, std::make_unique<formatted_raw_ostream>(OutFile), std::move(MIP),

87 std::unique_ptr(MCE),

88 std::unique_ptr(MAB));

89 break;

90 }

93 TheTriple, *MC, std::unique_ptr(MAB),

94 MAB->createObjectWriter(OutFile), std::unique_ptr(MCE),

95 *MSTI);

96 break;

97 }

98 }

99

100 if (!MS)

102 "no object streamer for target %s",

103 TripleName.c_str());

104

105

107 std::nullopt));

108 if (!TM)

110 "no target machine for target %s",

111 TripleName.c_str());

112

113 Asm.reset(TheTarget->createAsmPrinter(*TM, std::unique_ptr(MS)));

114 if (!Asm)

116 "no asm printer for target %s",

117 TripleName.c_str());

118 Asm->setDwarfUsesRelocationsAcrossSections(false);

119

120 DebugInfoSectionSize = 0;

121

123}

124

126 const SmallVector<std::unique_ptr> &Abbrevs,

127 unsigned DwarfVersion) {

128 MS->switchSection(MOFI->getDwarfAbbrevSection());

129 MC->setDwarfVersion(DwarfVersion);

130 Asm->emitDwarfAbbrevs(Abbrevs);

131}

132

134 MS->switchSection(MOFI->getDwarfInfoSection());

135 MC->setDwarfVersion(Unit.getVersion());

136

137

138

139

140 Asm->emitInt32(Unit.getUnitSize() - 4);

141 Asm->emitInt16(Unit.getVersion());

142

143 if (Unit.getVersion() >= 5) {

144 Asm->emitInt8(dwarf::DW_UT_compile);

145 Asm->emitInt8(Unit.getFormParams().AddrSize);

146

147 Asm->emitInt32(0);

148 DebugInfoSectionSize += 12;

149 } else {

150

151 Asm->emitInt32(0);

152 Asm->emitInt8(Unit.getFormParams().AddrSize);

153 DebugInfoSectionSize += 11;

154 }

155}

156

158 MS->switchSection(MOFI->getDwarfInfoSection());

159 Asm->emitDwarfDIE(Die);

160 DebugInfoSectionSize += Die.getSize();

161}

162

166 if (CUOffsets.empty())

167 return;

168

169 Asm->OutStreamer->switchSection(MOFI->getDwarfDebugNamesSection());

172

173

175 Asm.get(), Table, CUOffsets,

177 -> std::optionalDWARF5AccelTable::UnitIndexAndEncoding {

178 if (CUidToIdx.size() > 1)

179 return {{CUidToIdx[Entry.getUnitID()],

180 {dwarf::DW_IDX_compile_unit, Form}}};

181 return std::nullopt;

182 });

183}

184

187 Asm->OutStreamer->switchSection(MOFI->getDwarfAccelNamespaceSection());

188 auto *SectionBegin = Asm->createTempSymbol("namespac_begin");

189 Asm->OutStreamer->emitLabel(SectionBegin);

191}

192

195 Asm->OutStreamer->switchSection(MOFI->getDwarfAccelNamesSection());

196 auto *SectionBegin = Asm->createTempSymbol("names_begin");

197 Asm->OutStreamer->emitLabel(SectionBegin);

199}

200

203 Asm->OutStreamer->switchSection(MOFI->getDwarfAccelObjCSection());

204 auto *SectionBegin = Asm->createTempSymbol("objc_begin");

205 Asm->OutStreamer->emitLabel(SectionBegin);

207}

208

211 Asm->OutStreamer->switchSection(MOFI->getDwarfAccelTypesSection());

212 auto *SectionBegin = Asm->createTempSymbol("types_begin");

213 Asm->OutStreamer->emitLabel(SectionBegin);

215}

This class holds an abstract representation of an Accelerator Table, consisting of a sequence of buck...

static dwarf::Form BestForm(bool IsSigned, uint64_t Int)

Choose the best form for integer.

A structured debug information entry.

The Data class implementation for DWARF v5 accelerator table.

Lightweight error class with error context and mandatory checking.

static ErrorSuccess success()

Create a success value.

Context object for machine code objects.

DwarfDirectory MCUseDwarfDirectory

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

StringRef - Represent a constant reference to a string, i.e.

Target - Wrapper for Target specific information.

TargetMachine * createTargetMachine(const Triple &TT, StringRef CPU, StringRef Features, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM=std::nullopt, CodeGenOptLevel OL=CodeGenOptLevel::Default, bool JIT=false) const

createTargetMachine - Create a target specific machine implementation for the specified Triple.

MCCodeEmitter * createMCCodeEmitter(const MCInstrInfo &II, MCContext &Ctx) const

createMCCodeEmitter - Create a target specific code emitter.

MCObjectFileInfo * createMCObjectFileInfo(MCContext &Ctx, bool PIC, bool LargeCodeModel=false) const

Create a MCObjectFileInfo implementation for the specified target triple.

MCSubtargetInfo * createMCSubtargetInfo(StringRef TheTriple, StringRef CPU, StringRef Features) const

MCAsmBackend * createMCAsmBackend(const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options) const

createMCAsmBackend - Create a target specific assembly parser.

LLVM_ABI MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, std::unique_ptr< MCInstPrinter > IP, std::unique_ptr< MCCodeEmitter > CE, std::unique_ptr< MCAsmBackend > TAB) const

MCRegisterInfo * createMCRegInfo(StringRef TT) const

LLVM_ABI MCStreamer * createMCObjectStreamer(const Triple &T, MCContext &Ctx, std::unique_ptr< MCAsmBackend > TAB, std::unique_ptr< MCObjectWriter > OW, std::unique_ptr< MCCodeEmitter > Emitter, const MCSubtargetInfo &STI) const

Create a target specific MCStreamer.

MCAsmInfo * createMCAsmInfo(const MCRegisterInfo &MRI, StringRef TheTriple, const MCTargetOptions &Options) const

MCInstPrinter * createMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI) const

AsmPrinter * createAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > &&Streamer) const

createAsmPrinter - Create a target specific assembly printer pass.

MCInstrInfo * createMCInstrInfo() const

createMCInstrInfo - Create a MCInstrInfo implementation.

Triple - Helper class for working with autoconf configuration names.

const std::string & getTriple() const

void emitCompileUnitHeader(DwarfUnit &Unit)

Emit compile unit header.

Definition DWARFEmitterImpl.cpp:133

Error init(Triple TheTriple, StringRef Swift5ReflectionSegmentName)

Initialize AsmPrinter data.

Definition DWARFEmitterImpl.cpp:25

void emitAppleNames(AccelTable< AppleAccelTableStaticOffsetData > &Table)

Emits .apple_names section according to the specified Table.

Definition DWARFEmitterImpl.cpp:193

void emitAbbrevs(const SmallVector< std::unique_ptr< DIEAbbrev > > &Abbrevs, unsigned DwarfVersion)

Emit abbreviations.

Definition DWARFEmitterImpl.cpp:125

void emitAppleTypes(AccelTable< AppleAccelTableStaticTypeData > &Table)

Emits .apple_types section according to the specified Table.

Definition DWARFEmitterImpl.cpp:209

void emitDIE(DIE &Die)

Emit DIE recursively.

Definition DWARFEmitterImpl.cpp:157

void emitAppleNamespaces(AccelTable< AppleAccelTableStaticOffsetData > &Table)

Emits .apple_namespaces section according to the specified Table.

Definition DWARFEmitterImpl.cpp:185

void emitDebugNames(DWARF5AccelTable &Table, DebugNamesUnitsOffsets &CUOffsets, CompUnitIDToIdx &UnitIDToIdxMap)

Emits .debug_names section according to the specified Table.

Definition DWARFEmitterImpl.cpp:163

void emitAppleObjc(AccelTable< AppleAccelTableStaticOffsetData > &Table)

Emits .apple_objc section according to the specified Table.

Definition DWARFEmitterImpl.cpp:201

Base class for all Dwarf units(Compile unit/Type table unit).

std::vector< std::variant< MCSymbol *, uint64_t > > DebugNamesUnitsOffsets

DenseMap< unsigned, unsigned > CompUnitIDToIdx

LLVM_ABI MCTargetOptions InitMCTargetOptionsFromFlags()

This is an optimization pass for GlobalISel generic memory operations.

Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)

Create formatted StringError object.

void emitAppleAccelTable(AsmPrinter *Asm, AccelTable< DataT > &Contents, StringRef Prefix, const MCSymbol *SecBegin)

Emit an Apple Accelerator Table consisting of entries in the specified AccelTable.

LLVM_ABI void emitDWARF5AccelTable(AsmPrinter *Asm, DWARF5AccelTable &Contents, const DwarfDebug &DD, ArrayRef< std::unique_ptr< DwarfCompileUnit > > CUs)

static const Target * lookupTarget(StringRef TripleStr, std::string &Error)

lookupTarget - Lookup a target based on a target triple.