LLVM API Documentation
00001 //===- lib/MC/MCStreamer.cpp - Streaming Machine Code Output --------------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 00010 #include "llvm/MC/MCStreamer.h" 00011 #include "llvm/ADT/SmallString.h" 00012 #include "llvm/ADT/Twine.h" 00013 #include "llvm/MC/MCAsmBackend.h" 00014 #include "llvm/MC/MCAsmInfo.h" 00015 #include "llvm/MC/MCContext.h" 00016 #include "llvm/MC/MCExpr.h" 00017 #include "llvm/MC/MCObjectFileInfo.h" 00018 #include "llvm/MC/MCObjectWriter.h" 00019 #include "llvm/MC/MCSymbol.h" 00020 #include "llvm/MC/MCWin64EH.h" 00021 #include "llvm/Support/ErrorHandling.h" 00022 #include "llvm/Support/LEB128.h" 00023 #include "llvm/Support/raw_ostream.h" 00024 #include <cstdlib> 00025 using namespace llvm; 00026 00027 // Pin the vtables to this file. 00028 MCTargetStreamer::~MCTargetStreamer() {} 00029 00030 MCTargetStreamer::MCTargetStreamer(MCStreamer &S) : Streamer(S) { 00031 S.setTargetStreamer(this); 00032 } 00033 00034 void MCTargetStreamer::emitLabel(MCSymbol *Symbol) {} 00035 00036 void MCTargetStreamer::finish() {} 00037 00038 void MCTargetStreamer::emitAssignment(MCSymbol *Symbol, const MCExpr *Value) {} 00039 00040 MCStreamer::MCStreamer(MCContext &Ctx) 00041 : Context(Ctx), CurrentWinFrameInfo(nullptr) { 00042 SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>()); 00043 } 00044 00045 MCStreamer::~MCStreamer() { 00046 for (unsigned i = 0; i < getNumWinFrameInfos(); ++i) 00047 delete WinFrameInfos[i]; 00048 } 00049 00050 void MCStreamer::reset() { 00051 DwarfFrameInfos.clear(); 00052 for (unsigned i = 0; i < getNumWinFrameInfos(); ++i) 00053 delete WinFrameInfos[i]; 00054 WinFrameInfos.clear(); 00055 CurrentWinFrameInfo = nullptr; 00056 SymbolOrdering.clear(); 00057 SectionStack.clear(); 00058 SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>()); 00059 } 00060 00061 raw_ostream &MCStreamer::GetCommentOS() { 00062 // By default, discard comments. 00063 return nulls(); 00064 } 00065 00066 void MCStreamer::emitRawComment(const Twine &T, bool TabPrefix) {} 00067 00068 void MCStreamer::generateCompactUnwindEncodings(MCAsmBackend *MAB) { 00069 for (auto &FI : DwarfFrameInfos) 00070 FI.CompactUnwindEncoding = 00071 (MAB ? MAB->generateCompactUnwindEncoding(FI.Instructions) : 0); 00072 } 00073 00074 /// EmitIntValue - Special case of EmitValue that avoids the client having to 00075 /// pass in a MCExpr for constant integers. 00076 void MCStreamer::EmitIntValue(uint64_t Value, unsigned Size) { 00077 assert(1 <= Size && Size <= 8 && "Invalid size"); 00078 assert((isUIntN(8 * Size, Value) || isIntN(8 * Size, Value)) && 00079 "Invalid size"); 00080 char buf[8]; 00081 const bool isLittleEndian = Context.getAsmInfo()->isLittleEndian(); 00082 for (unsigned i = 0; i != Size; ++i) { 00083 unsigned index = isLittleEndian ? i : (Size - i - 1); 00084 buf[i] = uint8_t(Value >> (index * 8)); 00085 } 00086 EmitBytes(StringRef(buf, Size)); 00087 } 00088 00089 /// EmitULEB128Value - Special case of EmitULEB128Value that avoids the 00090 /// client having to pass in a MCExpr for constant integers. 00091 void MCStreamer::EmitULEB128IntValue(uint64_t Value, unsigned Padding) { 00092 SmallString<128> Tmp; 00093 raw_svector_ostream OSE(Tmp); 00094 encodeULEB128(Value, OSE, Padding); 00095 EmitBytes(OSE.str()); 00096 } 00097 00098 /// EmitSLEB128Value - Special case of EmitSLEB128Value that avoids the 00099 /// client having to pass in a MCExpr for constant integers. 00100 void MCStreamer::EmitSLEB128IntValue(int64_t Value) { 00101 SmallString<128> Tmp; 00102 raw_svector_ostream OSE(Tmp); 00103 encodeSLEB128(Value, OSE); 00104 EmitBytes(OSE.str()); 00105 } 00106 00107 void MCStreamer::EmitValue(const MCExpr *Value, unsigned Size, 00108 const SMLoc &Loc) { 00109 EmitValueImpl(Value, Size, Loc); 00110 } 00111 00112 void MCStreamer::EmitSymbolValue(const MCSymbol *Sym, unsigned Size, 00113 bool IsSectionRelative) { 00114 assert((!IsSectionRelative || Size == 4) && 00115 "SectionRelative value requires 4-bytes"); 00116 00117 if (!IsSectionRelative) 00118 EmitValueImpl(MCSymbolRefExpr::Create(Sym, getContext()), Size); 00119 else 00120 EmitCOFFSecRel32(Sym); 00121 } 00122 00123 void MCStreamer::EmitGPRel64Value(const MCExpr *Value) { 00124 report_fatal_error("unsupported directive in streamer"); 00125 } 00126 00127 void MCStreamer::EmitGPRel32Value(const MCExpr *Value) { 00128 report_fatal_error("unsupported directive in streamer"); 00129 } 00130 00131 /// EmitFill - Emit NumBytes bytes worth of the value specified by 00132 /// FillValue. This implements directives such as '.space'. 00133 void MCStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue) { 00134 const MCExpr *E = MCConstantExpr::Create(FillValue, getContext()); 00135 for (uint64_t i = 0, e = NumBytes; i != e; ++i) 00136 EmitValue(E, 1); 00137 } 00138 00139 /// The implementation in this class just redirects to EmitFill. 00140 void MCStreamer::EmitZeros(uint64_t NumBytes) { 00141 EmitFill(NumBytes, 0); 00142 } 00143 00144 unsigned MCStreamer::EmitDwarfFileDirective(unsigned FileNo, 00145 StringRef Directory, 00146 StringRef Filename, unsigned CUID) { 00147 return getContext().GetDwarfFile(Directory, Filename, FileNo, CUID); 00148 } 00149 00150 void MCStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line, 00151 unsigned Column, unsigned Flags, 00152 unsigned Isa, 00153 unsigned Discriminator, 00154 StringRef FileName) { 00155 getContext().setCurrentDwarfLoc(FileNo, Line, Column, Flags, Isa, 00156 Discriminator); 00157 } 00158 00159 MCSymbol *MCStreamer::getDwarfLineTableSymbol(unsigned CUID) { 00160 MCDwarfLineTable &Table = getContext().getMCDwarfLineTable(CUID); 00161 if (!Table.getLabel()) { 00162 StringRef Prefix = Context.getAsmInfo()->getPrivateGlobalPrefix(); 00163 Table.setLabel( 00164 Context.GetOrCreateSymbol(Prefix + "line_table_start" + Twine(CUID))); 00165 } 00166 return Table.getLabel(); 00167 } 00168 00169 MCDwarfFrameInfo *MCStreamer::getCurrentDwarfFrameInfo() { 00170 if (DwarfFrameInfos.empty()) 00171 return nullptr; 00172 return &DwarfFrameInfos.back(); 00173 } 00174 00175 void MCStreamer::EnsureValidDwarfFrame() { 00176 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo(); 00177 if (!CurFrame || CurFrame->End) 00178 report_fatal_error("No open frame"); 00179 } 00180 00181 void MCStreamer::EmitEHSymAttributes(const MCSymbol *Symbol, 00182 MCSymbol *EHSymbol) { 00183 } 00184 00185 void MCStreamer::InitSections() { 00186 SwitchSection(getContext().getObjectFileInfo()->getTextSection()); 00187 } 00188 00189 void MCStreamer::AssignSection(MCSymbol *Symbol, const MCSection *Section) { 00190 if (Section) 00191 Symbol->setSection(*Section); 00192 else 00193 Symbol->setUndefined(); 00194 00195 // As we emit symbols into a section, track the order so that they can 00196 // be sorted upon later. Zero is reserved to mean 'unemitted'. 00197 SymbolOrdering[Symbol] = 1 + SymbolOrdering.size(); 00198 } 00199 00200 void MCStreamer::EmitLabel(MCSymbol *Symbol) { 00201 assert(!Symbol->isVariable() && "Cannot emit a variable symbol!"); 00202 assert(getCurrentSection().first && "Cannot emit before setting section!"); 00203 AssignSection(Symbol, getCurrentSection().first); 00204 00205 MCTargetStreamer *TS = getTargetStreamer(); 00206 if (TS) 00207 TS->emitLabel(Symbol); 00208 } 00209 00210 void MCStreamer::EmitCFISections(bool EH, bool Debug) { 00211 assert(EH || Debug); 00212 } 00213 00214 void MCStreamer::EmitCFIStartProc(bool IsSimple) { 00215 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo(); 00216 if (CurFrame && !CurFrame->End) 00217 report_fatal_error("Starting a frame before finishing the previous one!"); 00218 00219 MCDwarfFrameInfo Frame; 00220 Frame.IsSimple = IsSimple; 00221 EmitCFIStartProcImpl(Frame); 00222 00223 DwarfFrameInfos.push_back(Frame); 00224 } 00225 00226 void MCStreamer::EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) { 00227 } 00228 00229 void MCStreamer::EmitCFIEndProc() { 00230 EnsureValidDwarfFrame(); 00231 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo(); 00232 EmitCFIEndProcImpl(*CurFrame); 00233 } 00234 00235 void MCStreamer::EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) { 00236 // Put a dummy non-null value in Frame.End to mark that this frame has been 00237 // closed. 00238 Frame.End = (MCSymbol *) 1; 00239 } 00240 00241 MCSymbol *MCStreamer::EmitCFICommon() { 00242 EnsureValidDwarfFrame(); 00243 MCSymbol *Label = getContext().CreateTempSymbol(); 00244 EmitLabel(Label); 00245 return Label; 00246 } 00247 00248 void MCStreamer::EmitCFIDefCfa(int64_t Register, int64_t Offset) { 00249 MCSymbol *Label = EmitCFICommon(); 00250 MCCFIInstruction Instruction = 00251 MCCFIInstruction::createDefCfa(Label, Register, Offset); 00252 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo(); 00253 CurFrame->Instructions.push_back(Instruction); 00254 } 00255 00256 void MCStreamer::EmitCFIDefCfaOffset(int64_t Offset) { 00257 MCSymbol *Label = EmitCFICommon(); 00258 MCCFIInstruction Instruction = 00259 MCCFIInstruction::createDefCfaOffset(Label, Offset); 00260 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo(); 00261 CurFrame->Instructions.push_back(Instruction); 00262 } 00263 00264 void MCStreamer::EmitCFIAdjustCfaOffset(int64_t Adjustment) { 00265 MCSymbol *Label = EmitCFICommon(); 00266 MCCFIInstruction Instruction = 00267 MCCFIInstruction::createAdjustCfaOffset(Label, Adjustment); 00268 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo(); 00269 CurFrame->Instructions.push_back(Instruction); 00270 } 00271 00272 void MCStreamer::EmitCFIDefCfaRegister(int64_t Register) { 00273 MCSymbol *Label = EmitCFICommon(); 00274 MCCFIInstruction Instruction = 00275 MCCFIInstruction::createDefCfaRegister(Label, Register); 00276 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo(); 00277 CurFrame->Instructions.push_back(Instruction); 00278 } 00279 00280 void MCStreamer::EmitCFIOffset(int64_t Register, int64_t Offset) { 00281 MCSymbol *Label = EmitCFICommon(); 00282 MCCFIInstruction Instruction = 00283 MCCFIInstruction::createOffset(Label, Register, Offset); 00284 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo(); 00285 CurFrame->Instructions.push_back(Instruction); 00286 } 00287 00288 void MCStreamer::EmitCFIRelOffset(int64_t Register, int64_t Offset) { 00289 MCSymbol *Label = EmitCFICommon(); 00290 MCCFIInstruction Instruction = 00291 MCCFIInstruction::createRelOffset(Label, Register, Offset); 00292 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo(); 00293 CurFrame->Instructions.push_back(Instruction); 00294 } 00295 00296 void MCStreamer::EmitCFIPersonality(const MCSymbol *Sym, 00297 unsigned Encoding) { 00298 EnsureValidDwarfFrame(); 00299 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo(); 00300 CurFrame->Personality = Sym; 00301 CurFrame->PersonalityEncoding = Encoding; 00302 } 00303 00304 void MCStreamer::EmitCFILsda(const MCSymbol *Sym, unsigned Encoding) { 00305 EnsureValidDwarfFrame(); 00306 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo(); 00307 CurFrame->Lsda = Sym; 00308 CurFrame->LsdaEncoding = Encoding; 00309 } 00310 00311 void MCStreamer::EmitCFIRememberState() { 00312 MCSymbol *Label = EmitCFICommon(); 00313 MCCFIInstruction Instruction = MCCFIInstruction::createRememberState(Label); 00314 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo(); 00315 CurFrame->Instructions.push_back(Instruction); 00316 } 00317 00318 void MCStreamer::EmitCFIRestoreState() { 00319 // FIXME: Error if there is no matching cfi_remember_state. 00320 MCSymbol *Label = EmitCFICommon(); 00321 MCCFIInstruction Instruction = MCCFIInstruction::createRestoreState(Label); 00322 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo(); 00323 CurFrame->Instructions.push_back(Instruction); 00324 } 00325 00326 void MCStreamer::EmitCFISameValue(int64_t Register) { 00327 MCSymbol *Label = EmitCFICommon(); 00328 MCCFIInstruction Instruction = 00329 MCCFIInstruction::createSameValue(Label, Register); 00330 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo(); 00331 CurFrame->Instructions.push_back(Instruction); 00332 } 00333 00334 void MCStreamer::EmitCFIRestore(int64_t Register) { 00335 MCSymbol *Label = EmitCFICommon(); 00336 MCCFIInstruction Instruction = 00337 MCCFIInstruction::createRestore(Label, Register); 00338 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo(); 00339 CurFrame->Instructions.push_back(Instruction); 00340 } 00341 00342 void MCStreamer::EmitCFIEscape(StringRef Values) { 00343 MCSymbol *Label = EmitCFICommon(); 00344 MCCFIInstruction Instruction = MCCFIInstruction::createEscape(Label, Values); 00345 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo(); 00346 CurFrame->Instructions.push_back(Instruction); 00347 } 00348 00349 void MCStreamer::EmitCFISignalFrame() { 00350 EnsureValidDwarfFrame(); 00351 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo(); 00352 CurFrame->IsSignalFrame = true; 00353 } 00354 00355 void MCStreamer::EmitCFIUndefined(int64_t Register) { 00356 MCSymbol *Label = EmitCFICommon(); 00357 MCCFIInstruction Instruction = 00358 MCCFIInstruction::createUndefined(Label, Register); 00359 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo(); 00360 CurFrame->Instructions.push_back(Instruction); 00361 } 00362 00363 void MCStreamer::EmitCFIRegister(int64_t Register1, int64_t Register2) { 00364 MCSymbol *Label = EmitCFICommon(); 00365 MCCFIInstruction Instruction = 00366 MCCFIInstruction::createRegister(Label, Register1, Register2); 00367 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo(); 00368 CurFrame->Instructions.push_back(Instruction); 00369 } 00370 00371 void MCStreamer::EmitCFIWindowSave() { 00372 MCSymbol *Label = EmitCFICommon(); 00373 MCCFIInstruction Instruction = 00374 MCCFIInstruction::createWindowSave(Label); 00375 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo(); 00376 CurFrame->Instructions.push_back(Instruction); 00377 } 00378 00379 void MCStreamer::EnsureValidWinFrameInfo() { 00380 if (!CurrentWinFrameInfo || CurrentWinFrameInfo->End) 00381 report_fatal_error("No open Win64 EH frame function!"); 00382 } 00383 00384 void MCStreamer::EmitWinCFIStartProc(const MCSymbol *Symbol) { 00385 if (CurrentWinFrameInfo && !CurrentWinFrameInfo->End) 00386 report_fatal_error("Starting a function before ending the previous one!"); 00387 00388 MCSymbol *StartProc = getContext().CreateTempSymbol(); 00389 EmitLabel(StartProc); 00390 00391 WinFrameInfos.push_back(new WinEH::FrameInfo(Symbol, StartProc)); 00392 CurrentWinFrameInfo = WinFrameInfos.back(); 00393 } 00394 00395 void MCStreamer::EmitWinCFIEndProc() { 00396 EnsureValidWinFrameInfo(); 00397 if (CurrentWinFrameInfo->ChainedParent) 00398 report_fatal_error("Not all chained regions terminated!"); 00399 00400 MCSymbol *Label = getContext().CreateTempSymbol(); 00401 EmitLabel(Label); 00402 CurrentWinFrameInfo->End = Label; 00403 } 00404 00405 void MCStreamer::EmitWinCFIStartChained() { 00406 EnsureValidWinFrameInfo(); 00407 00408 MCSymbol *StartProc = getContext().CreateTempSymbol(); 00409 EmitLabel(StartProc); 00410 00411 WinFrameInfos.push_back(new WinEH::FrameInfo(CurrentWinFrameInfo->Function, 00412 StartProc, CurrentWinFrameInfo)); 00413 CurrentWinFrameInfo = WinFrameInfos.back(); 00414 } 00415 00416 void MCStreamer::EmitWinCFIEndChained() { 00417 EnsureValidWinFrameInfo(); 00418 if (!CurrentWinFrameInfo->ChainedParent) 00419 report_fatal_error("End of a chained region outside a chained region!"); 00420 00421 MCSymbol *Label = getContext().CreateTempSymbol(); 00422 EmitLabel(Label); 00423 00424 CurrentWinFrameInfo->End = Label; 00425 CurrentWinFrameInfo = 00426 const_cast<WinEH::FrameInfo *>(CurrentWinFrameInfo->ChainedParent); 00427 } 00428 00429 void MCStreamer::EmitWinEHHandler(const MCSymbol *Sym, bool Unwind, 00430 bool Except) { 00431 EnsureValidWinFrameInfo(); 00432 if (CurrentWinFrameInfo->ChainedParent) 00433 report_fatal_error("Chained unwind areas can't have handlers!"); 00434 CurrentWinFrameInfo->ExceptionHandler = Sym; 00435 if (!Except && !Unwind) 00436 report_fatal_error("Don't know what kind of handler this is!"); 00437 if (Unwind) 00438 CurrentWinFrameInfo->HandlesUnwind = true; 00439 if (Except) 00440 CurrentWinFrameInfo->HandlesExceptions = true; 00441 } 00442 00443 void MCStreamer::EmitWinEHHandlerData() { 00444 EnsureValidWinFrameInfo(); 00445 if (CurrentWinFrameInfo->ChainedParent) 00446 report_fatal_error("Chained unwind areas can't have handlers!"); 00447 } 00448 00449 void MCStreamer::EmitWinCFIPushReg(unsigned Register) { 00450 EnsureValidWinFrameInfo(); 00451 00452 MCSymbol *Label = getContext().CreateTempSymbol(); 00453 EmitLabel(Label); 00454 00455 WinEH::Instruction Inst = Win64EH::Instruction::PushNonVol(Label, Register); 00456 CurrentWinFrameInfo->Instructions.push_back(Inst); 00457 } 00458 00459 void MCStreamer::EmitWinCFISetFrame(unsigned Register, unsigned Offset) { 00460 EnsureValidWinFrameInfo(); 00461 if (CurrentWinFrameInfo->LastFrameInst >= 0) 00462 report_fatal_error("Frame register and offset already specified!"); 00463 if (Offset & 0x0F) 00464 report_fatal_error("Misaligned frame pointer offset!"); 00465 if (Offset > 240) 00466 report_fatal_error("Frame offset must be less than or equal to 240!"); 00467 00468 MCSymbol *Label = getContext().CreateTempSymbol(); 00469 EmitLabel(Label); 00470 00471 WinEH::Instruction Inst = 00472 Win64EH::Instruction::SetFPReg(Label, Register, Offset); 00473 CurrentWinFrameInfo->LastFrameInst = CurrentWinFrameInfo->Instructions.size(); 00474 CurrentWinFrameInfo->Instructions.push_back(Inst); 00475 } 00476 00477 void MCStreamer::EmitWinCFIAllocStack(unsigned Size) { 00478 EnsureValidWinFrameInfo(); 00479 if (Size == 0) 00480 report_fatal_error("Allocation size must be non-zero!"); 00481 if (Size & 7) 00482 report_fatal_error("Misaligned stack allocation!"); 00483 00484 MCSymbol *Label = getContext().CreateTempSymbol(); 00485 EmitLabel(Label); 00486 00487 WinEH::Instruction Inst = Win64EH::Instruction::Alloc(Label, Size); 00488 CurrentWinFrameInfo->Instructions.push_back(Inst); 00489 } 00490 00491 void MCStreamer::EmitWinCFISaveReg(unsigned Register, unsigned Offset) { 00492 EnsureValidWinFrameInfo(); 00493 if (Offset & 7) 00494 report_fatal_error("Misaligned saved register offset!"); 00495 00496 MCSymbol *Label = getContext().CreateTempSymbol(); 00497 EmitLabel(Label); 00498 00499 WinEH::Instruction Inst = 00500 Win64EH::Instruction::SaveNonVol(Label, Register, Offset); 00501 CurrentWinFrameInfo->Instructions.push_back(Inst); 00502 } 00503 00504 void MCStreamer::EmitWinCFISaveXMM(unsigned Register, unsigned Offset) { 00505 EnsureValidWinFrameInfo(); 00506 if (Offset & 0x0F) 00507 report_fatal_error("Misaligned saved vector register offset!"); 00508 00509 MCSymbol *Label = getContext().CreateTempSymbol(); 00510 EmitLabel(Label); 00511 00512 WinEH::Instruction Inst = 00513 Win64EH::Instruction::SaveXMM(Label, Register, Offset); 00514 CurrentWinFrameInfo->Instructions.push_back(Inst); 00515 } 00516 00517 void MCStreamer::EmitWinCFIPushFrame(bool Code) { 00518 EnsureValidWinFrameInfo(); 00519 if (CurrentWinFrameInfo->Instructions.size() > 0) 00520 report_fatal_error("If present, PushMachFrame must be the first UOP"); 00521 00522 MCSymbol *Label = getContext().CreateTempSymbol(); 00523 EmitLabel(Label); 00524 00525 WinEH::Instruction Inst = Win64EH::Instruction::PushMachFrame(Label, Code); 00526 CurrentWinFrameInfo->Instructions.push_back(Inst); 00527 } 00528 00529 void MCStreamer::EmitWinCFIEndProlog() { 00530 EnsureValidWinFrameInfo(); 00531 00532 MCSymbol *Label = getContext().CreateTempSymbol(); 00533 EmitLabel(Label); 00534 00535 CurrentWinFrameInfo->PrologEnd = Label; 00536 } 00537 00538 void MCStreamer::EmitCOFFSectionIndex(MCSymbol const *Symbol) { 00539 } 00540 00541 void MCStreamer::EmitCOFFSecRel32(MCSymbol const *Symbol) { 00542 } 00543 00544 /// EmitRawText - If this file is backed by an assembly streamer, this dumps 00545 /// the specified string in the output .s file. This capability is 00546 /// indicated by the hasRawTextSupport() predicate. 00547 void MCStreamer::EmitRawTextImpl(StringRef String) { 00548 errs() << "EmitRawText called on an MCStreamer that doesn't support it, " 00549 " something must not be fully mc'ized\n"; 00550 abort(); 00551 } 00552 00553 void MCStreamer::EmitRawText(const Twine &T) { 00554 SmallString<128> Str; 00555 EmitRawTextImpl(T.toStringRef(Str)); 00556 } 00557 00558 void MCStreamer::EmitWindowsUnwindTables() { 00559 } 00560 00561 void MCStreamer::Finish() { 00562 if (!DwarfFrameInfos.empty() && !DwarfFrameInfos.back().End) 00563 report_fatal_error("Unfinished frame!"); 00564 00565 MCTargetStreamer *TS = getTargetStreamer(); 00566 if (TS) 00567 TS->finish(); 00568 00569 FinishImpl(); 00570 } 00571 00572 void MCStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) { 00573 visitUsedExpr(*Value); 00574 Symbol->setVariableValue(Value); 00575 00576 MCTargetStreamer *TS = getTargetStreamer(); 00577 if (TS) 00578 TS->emitAssignment(Symbol, Value); 00579 } 00580 00581 void MCStreamer::visitUsedSymbol(const MCSymbol &Sym) { 00582 } 00583 00584 void MCStreamer::visitUsedExpr(const MCExpr &Expr) { 00585 switch (Expr.getKind()) { 00586 case MCExpr::Target: 00587 cast<MCTargetExpr>(Expr).visitUsedExpr(*this); 00588 break; 00589 00590 case MCExpr::Constant: 00591 break; 00592 00593 case MCExpr::Binary: { 00594 const MCBinaryExpr &BE = cast<MCBinaryExpr>(Expr); 00595 visitUsedExpr(*BE.getLHS()); 00596 visitUsedExpr(*BE.getRHS()); 00597 break; 00598 } 00599 00600 case MCExpr::SymbolRef: 00601 visitUsedSymbol(cast<MCSymbolRefExpr>(Expr).getSymbol()); 00602 break; 00603 00604 case MCExpr::Unary: 00605 visitUsedExpr(*cast<MCUnaryExpr>(Expr).getSubExpr()); 00606 break; 00607 } 00608 } 00609 00610 void MCStreamer::EmitInstruction(const MCInst &Inst, 00611 const MCSubtargetInfo &STI) { 00612 // Scan for values. 00613 for (unsigned i = Inst.getNumOperands(); i--;) 00614 if (Inst.getOperand(i).isExpr()) 00615 visitUsedExpr(*Inst.getOperand(i).getExpr()); 00616 } 00617 00618 void MCStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {} 00619 void MCStreamer::EmitThumbFunc(MCSymbol *Func) {} 00620 void MCStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {} 00621 void MCStreamer::BeginCOFFSymbolDef(const MCSymbol *Symbol) {} 00622 void MCStreamer::EndCOFFSymbolDef() {} 00623 void MCStreamer::EmitFileDirective(StringRef Filename) {} 00624 void MCStreamer::EmitCOFFSymbolStorageClass(int StorageClass) {} 00625 void MCStreamer::EmitCOFFSymbolType(int Type) {} 00626 void MCStreamer::EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {} 00627 void MCStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, 00628 unsigned ByteAlignment) {} 00629 void MCStreamer::EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol, 00630 uint64_t Size, unsigned ByteAlignment) {} 00631 void MCStreamer::ChangeSection(const MCSection *, const MCExpr *) {} 00632 void MCStreamer::EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) {} 00633 void MCStreamer::EmitBytes(StringRef Data) {} 00634 void MCStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, 00635 const SMLoc &Loc) { 00636 visitUsedExpr(*Value); 00637 } 00638 void MCStreamer::EmitULEB128Value(const MCExpr *Value) {} 00639 void MCStreamer::EmitSLEB128Value(const MCExpr *Value) {} 00640 void MCStreamer::EmitValueToAlignment(unsigned ByteAlignment, int64_t Value, 00641 unsigned ValueSize, 00642 unsigned MaxBytesToEmit) {} 00643 void MCStreamer::EmitCodeAlignment(unsigned ByteAlignment, 00644 unsigned MaxBytesToEmit) {} 00645 bool MCStreamer::EmitValueToOffset(const MCExpr *Offset, unsigned char Value) { 00646 return false; 00647 } 00648 void MCStreamer::EmitBundleAlignMode(unsigned AlignPow2) {} 00649 void MCStreamer::EmitBundleLock(bool AlignToEnd) {} 00650 void MCStreamer::FinishImpl() {} 00651 void MCStreamer::EmitBundleUnlock() {}