[InstCombine] Signed saturation patterns
[llvm-complete.git] / include / llvm / CodeGen / AsmPrinter.h
bloba4580da5aec93323e17f5b6f417d1a71b8a29d87
1 //===- llvm/CodeGen/AsmPrinter.h - AsmPrinter Framework ---------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains a class to be used as the base class for target specific
10 // asm writers. This class primarily handles common functionality used by
11 // all asm writers.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CODEGEN_ASMPRINTER_H
16 #define LLVM_CODEGEN_ASMPRINTER_H
18 #include "llvm/ADT/MapVector.h"
19 #include "llvm/ADT/SmallVector.h"
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/ADT/Twine.h"
22 #include "llvm/CodeGen/AsmPrinterHandler.h"
23 #include "llvm/CodeGen/DwarfStringPoolEntry.h"
24 #include "llvm/CodeGen/MachineFunctionPass.h"
25 #include "llvm/IR/InlineAsm.h"
26 #include "llvm/IR/LLVMContext.h"
27 #include "llvm/Support/ErrorHandling.h"
28 #include "llvm/Support/SourceMgr.h"
29 #include <cstdint>
30 #include <memory>
31 #include <utility>
32 #include <vector>
34 namespace llvm {
36 class BasicBlock;
37 class BlockAddress;
38 class Constant;
39 class ConstantArray;
40 class DataLayout;
41 class DIE;
42 class DIEAbbrev;
43 class DwarfDebug;
44 class GCMetadataPrinter;
45 class GCStrategy;
46 class GlobalIndirectSymbol;
47 class GlobalObject;
48 class GlobalValue;
49 class GlobalVariable;
50 class MachineBasicBlock;
51 class MachineConstantPoolValue;
52 class MachineDominatorTree;
53 class MachineFunction;
54 class MachineInstr;
55 class MachineJumpTableInfo;
56 class MachineLoopInfo;
57 class MachineModuleInfo;
58 class MachineOptimizationRemarkEmitter;
59 class MCAsmInfo;
60 class MCCFIInstruction;
61 struct MCCodePaddingContext;
62 class MCContext;
63 class MCExpr;
64 class MCInst;
65 class MCSection;
66 class MCStreamer;
67 class MCSubtargetInfo;
68 class MCSymbol;
69 class MCTargetOptions;
70 class MDNode;
71 class Module;
72 class raw_ostream;
73 class StackMaps;
74 class TargetLoweringObjectFile;
75 class TargetMachine;
77 /// This class is intended to be used as a driving class for all asm writers.
78 class AsmPrinter : public MachineFunctionPass {
79 public:
80 /// Target machine description.
81 TargetMachine &TM;
83 /// Target Asm Printer information.
84 const MCAsmInfo *MAI;
86 /// This is the context for the output file that we are streaming. This owns
87 /// all of the global MC-related objects for the generated translation unit.
88 MCContext &OutContext;
90 /// This is the MCStreamer object for the file we are generating. This
91 /// contains the transient state for the current translation unit that we are
92 /// generating (such as the current section etc).
93 std::unique_ptr<MCStreamer> OutStreamer;
95 /// The current machine function.
96 MachineFunction *MF = nullptr;
98 /// This is a pointer to the current MachineModuleInfo.
99 MachineModuleInfo *MMI = nullptr;
101 /// This is a pointer to the current MachineLoopInfo.
102 MachineDominatorTree *MDT = nullptr;
104 /// This is a pointer to the current MachineLoopInfo.
105 MachineLoopInfo *MLI = nullptr;
107 /// Optimization remark emitter.
108 MachineOptimizationRemarkEmitter *ORE;
110 /// The symbol for the current function. This is recalculated at the beginning
111 /// of each call to runOnMachineFunction().
112 MCSymbol *CurrentFnSym = nullptr;
114 /// The symbol for the current function descriptor on AIX. This is created
115 /// at the beginning of each call to SetupMachineFunction().
116 MCSymbol *CurrentFnDescSym = nullptr;
118 /// The symbol used to represent the start of the current function for the
119 /// purpose of calculating its size (e.g. using the .size directive). By
120 /// default, this is equal to CurrentFnSym.
121 MCSymbol *CurrentFnSymForSize = nullptr;
123 /// Map global GOT equivalent MCSymbols to GlobalVariables and keep track of
124 /// its number of uses by other globals.
125 using GOTEquivUsePair = std::pair<const GlobalVariable *, unsigned>;
126 MapVector<const MCSymbol *, GOTEquivUsePair> GlobalGOTEquivs;
128 private:
129 MCSymbol *CurrentFnBegin = nullptr;
130 MCSymbol *CurrentFnEnd = nullptr;
131 MCSymbol *CurExceptionSym = nullptr;
133 // The garbage collection metadata printer table.
134 void *GCMetadataPrinters = nullptr; // Really a DenseMap.
136 /// Emit comments in assembly output if this is true.
137 bool VerboseAsm;
139 static char ID;
141 protected:
142 /// Protected struct HandlerInfo and Handlers permit target extended
143 /// AsmPrinter adds their own handlers.
144 struct HandlerInfo {
145 std::unique_ptr<AsmPrinterHandler> Handler;
146 const char *TimerName;
147 const char *TimerDescription;
148 const char *TimerGroupName;
149 const char *TimerGroupDescription;
151 HandlerInfo(std::unique_ptr<AsmPrinterHandler> Handler,
152 const char *TimerName, const char *TimerDescription,
153 const char *TimerGroupName, const char *TimerGroupDescription)
154 : Handler(std::move(Handler)), TimerName(TimerName),
155 TimerDescription(TimerDescription), TimerGroupName(TimerGroupName),
156 TimerGroupDescription(TimerGroupDescription) {}
159 /// A vector of all debug/EH info emitters we should use. This vector
160 /// maintains ownership of the emitters.
161 SmallVector<HandlerInfo, 1> Handlers;
163 public:
164 struct SrcMgrDiagInfo {
165 SourceMgr SrcMgr;
166 std::vector<const MDNode *> LocInfos;
167 LLVMContext::InlineAsmDiagHandlerTy DiagHandler;
168 void *DiagContext;
171 private:
172 /// If generated on the fly this own the instance.
173 std::unique_ptr<MachineDominatorTree> OwnedMDT;
175 /// If generated on the fly this own the instance.
176 std::unique_ptr<MachineLoopInfo> OwnedMLI;
178 /// Structure for generating diagnostics for inline assembly. Only initialised
179 /// when necessary.
180 mutable std::unique_ptr<SrcMgrDiagInfo> DiagInfo;
182 /// If the target supports dwarf debug info, this pointer is non-null.
183 DwarfDebug *DD = nullptr;
185 /// If the current module uses dwarf CFI annotations strictly for debugging.
186 bool isCFIMoveForDebugging = false;
188 protected:
189 explicit AsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer);
191 public:
192 ~AsmPrinter() override;
194 DwarfDebug *getDwarfDebug() { return DD; }
195 DwarfDebug *getDwarfDebug() const { return DD; }
197 uint16_t getDwarfVersion() const;
198 void setDwarfVersion(uint16_t Version);
200 bool isPositionIndependent() const;
202 /// Return true if assembly output should contain comments.
203 bool isVerbose() const { return VerboseAsm; }
205 /// Return a unique ID for the current function.
206 unsigned getFunctionNumber() const;
208 /// Return symbol for the function pseudo stack if the stack frame is not a
209 /// register based.
210 virtual const MCSymbol *getFunctionFrameSymbol() const { return nullptr; }
212 MCSymbol *getFunctionBegin() const { return CurrentFnBegin; }
213 MCSymbol *getFunctionEnd() const { return CurrentFnEnd; }
214 MCSymbol *getCurExceptionSym();
216 /// Return information about object file lowering.
217 const TargetLoweringObjectFile &getObjFileLowering() const;
219 /// Return information about data layout.
220 const DataLayout &getDataLayout() const;
222 /// Return the pointer size from the TargetMachine
223 unsigned getPointerSize() const;
225 /// Return information about subtarget.
226 const MCSubtargetInfo &getSubtargetInfo() const;
228 void EmitToStreamer(MCStreamer &S, const MCInst &Inst);
230 /// Emits inital debug location directive.
231 void emitInitialRawDwarfLocDirective(const MachineFunction &MF);
233 /// Return the current section we are emitting to.
234 const MCSection *getCurrentSection() const;
236 void getNameWithPrefix(SmallVectorImpl<char> &Name,
237 const GlobalValue *GV) const;
239 MCSymbol *getSymbol(const GlobalValue *GV) const;
241 //===------------------------------------------------------------------===//
242 // XRay instrumentation implementation.
243 //===------------------------------------------------------------------===//
244 public:
245 // This describes the kind of sled we're storing in the XRay table.
246 enum class SledKind : uint8_t {
247 FUNCTION_ENTER = 0,
248 FUNCTION_EXIT = 1,
249 TAIL_CALL = 2,
250 LOG_ARGS_ENTER = 3,
251 CUSTOM_EVENT = 4,
252 TYPED_EVENT = 5,
255 // The table will contain these structs that point to the sled, the function
256 // containing the sled, and what kind of sled (and whether they should always
257 // be instrumented). We also use a version identifier that the runtime can use
258 // to decide what to do with the sled, depending on the version of the sled.
259 struct XRayFunctionEntry {
260 const MCSymbol *Sled;
261 const MCSymbol *Function;
262 SledKind Kind;
263 bool AlwaysInstrument;
264 const class Function *Fn;
265 uint8_t Version;
267 void emit(int, MCStreamer *, const MCSymbol *) const;
270 // All the sleds to be emitted.
271 SmallVector<XRayFunctionEntry, 4> Sleds;
273 // A unique ID used for ELF sections associated with a particular function.
274 unsigned XRayFnUniqueID = 0;
276 // Helper function to record a given XRay sled.
277 void recordSled(MCSymbol *Sled, const MachineInstr &MI, SledKind Kind,
278 uint8_t Version = 0);
280 /// Emit a table with all XRay instrumentation points.
281 void emitXRayTable();
283 //===------------------------------------------------------------------===//
284 // MachineFunctionPass Implementation.
285 //===------------------------------------------------------------------===//
287 /// Record analysis usage.
288 void getAnalysisUsage(AnalysisUsage &AU) const override;
290 /// Set up the AsmPrinter when we are working on a new module. If your pass
291 /// overrides this, it must make sure to explicitly call this implementation.
292 bool doInitialization(Module &M) override;
294 /// Shut down the asmprinter. If you override this in your pass, you must make
295 /// sure to call it explicitly.
296 bool doFinalization(Module &M) override;
298 /// Emit the specified function out to the OutStreamer.
299 bool runOnMachineFunction(MachineFunction &MF) override {
300 SetupMachineFunction(MF);
301 EmitFunctionBody();
302 return false;
305 //===------------------------------------------------------------------===//
306 // Coarse grained IR lowering routines.
307 //===------------------------------------------------------------------===//
309 /// This should be called when a new MachineFunction is being processed from
310 /// runOnMachineFunction.
311 virtual void SetupMachineFunction(MachineFunction &MF);
313 /// This method emits the body and trailer for a function.
314 void EmitFunctionBody();
316 void emitCFIInstruction(const MachineInstr &MI);
318 void emitFrameAlloc(const MachineInstr &MI);
320 void emitStackSizeSection(const MachineFunction &MF);
322 void emitRemarksSection(Module &M);
324 enum CFIMoveType { CFI_M_None, CFI_M_EH, CFI_M_Debug };
325 CFIMoveType needsCFIMoves() const;
327 /// Returns false if needsCFIMoves() == CFI_M_EH for any function
328 /// in the module.
329 bool needsOnlyDebugCFIMoves() const { return isCFIMoveForDebugging; }
331 bool needsSEHMoves();
333 /// Print to the current output stream assembly representations of the
334 /// constants in the constant pool MCP. This is used to print out constants
335 /// which have been "spilled to memory" by the code generator.
336 virtual void EmitConstantPool();
338 /// Print assembly representations of the jump tables used by the current
339 /// function to the current output stream.
340 virtual void EmitJumpTableInfo();
342 /// Emit the specified global variable to the .s file.
343 virtual void EmitGlobalVariable(const GlobalVariable *GV);
345 /// Check to see if the specified global is a special global used by LLVM. If
346 /// so, emit it and return true, otherwise do nothing and return false.
347 bool EmitSpecialLLVMGlobal(const GlobalVariable *GV);
349 /// Emit an alignment directive to the specified power of two boundary. If a
350 /// global value is specified, and if that global has an explicit alignment
351 /// requested, it will override the alignment request if required for
352 /// correctness.
353 void EmitAlignment(Align Alignment, const GlobalObject *GV = nullptr) const;
355 /// Lower the specified LLVM Constant to an MCExpr.
356 virtual const MCExpr *lowerConstant(const Constant *CV);
358 /// Print a general LLVM constant to the .s file.
359 void EmitGlobalConstant(const DataLayout &DL, const Constant *CV);
361 /// Unnamed constant global variables solely contaning a pointer to
362 /// another globals variable act like a global variable "proxy", or GOT
363 /// equivalents, i.e., it's only used to hold the address of the latter. One
364 /// optimization is to replace accesses to these proxies by using the GOT
365 /// entry for the final global instead. Hence, we select GOT equivalent
366 /// candidates among all the module global variables, avoid emitting them
367 /// unnecessarily and finally replace references to them by pc relative
368 /// accesses to GOT entries.
369 void computeGlobalGOTEquivs(Module &M);
371 /// Constant expressions using GOT equivalent globals may not be
372 /// eligible for PC relative GOT entry conversion, in such cases we need to
373 /// emit the proxies we previously omitted in EmitGlobalVariable.
374 void emitGlobalGOTEquivs();
376 /// Emit the stack maps.
377 void emitStackMaps(StackMaps &SM);
379 //===------------------------------------------------------------------===//
380 // Overridable Hooks
381 //===------------------------------------------------------------------===//
383 // Targets can, or in the case of EmitInstruction, must implement these to
384 // customize output.
386 /// This virtual method can be overridden by targets that want to emit
387 /// something at the start of their file.
388 virtual void EmitStartOfAsmFile(Module &) {}
390 /// This virtual method can be overridden by targets that want to emit
391 /// something at the end of their file.
392 virtual void EmitEndOfAsmFile(Module &) {}
394 /// Targets can override this to emit stuff before the first basic block in
395 /// the function.
396 virtual void EmitFunctionBodyStart() {}
398 /// Targets can override this to emit stuff after the last basic block in the
399 /// function.
400 virtual void EmitFunctionBodyEnd() {}
402 /// Targets can override this to emit stuff at the start of a basic block.
403 /// By default, this method prints the label for the specified
404 /// MachineBasicBlock, an alignment (if present) and a comment describing it
405 /// if appropriate.
406 virtual void EmitBasicBlockStart(const MachineBasicBlock &MBB);
408 /// Targets can override this to emit stuff at the end of a basic block.
409 virtual void EmitBasicBlockEnd(const MachineBasicBlock &MBB);
411 /// Targets should implement this to emit instructions.
412 virtual void EmitInstruction(const MachineInstr *) {
413 llvm_unreachable("EmitInstruction not implemented");
416 /// Return the symbol for the specified constant pool entry.
417 virtual MCSymbol *GetCPISymbol(unsigned CPID) const;
419 virtual void EmitFunctionEntryLabel();
421 virtual void EmitFunctionDescriptor() {
422 llvm_unreachable("Function descriptor is target-specific.");
425 virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV);
427 /// Targets can override this to change how global constants that are part of
428 /// a C++ static/global constructor list are emitted.
429 virtual void EmitXXStructor(const DataLayout &DL, const Constant *CV) {
430 EmitGlobalConstant(DL, CV);
433 /// Return true if the basic block has exactly one predecessor and the control
434 /// transfer mechanism between the predecessor and this block is a
435 /// fall-through.
436 virtual bool
437 isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const;
439 /// Targets can override this to customize the output of IMPLICIT_DEF
440 /// instructions in verbose mode.
441 virtual void emitImplicitDef(const MachineInstr *MI) const;
443 //===------------------------------------------------------------------===//
444 // Symbol Lowering Routines.
445 //===------------------------------------------------------------------===//
447 MCSymbol *createTempSymbol(const Twine &Name) const;
449 /// Return the MCSymbol for a private symbol with global value name as its
450 /// base, with the specified suffix.
451 MCSymbol *getSymbolWithGlobalValueBase(const GlobalValue *GV,
452 StringRef Suffix) const;
454 /// Return the MCSymbol for the specified ExternalSymbol.
455 MCSymbol *GetExternalSymbolSymbol(StringRef Sym) const;
457 /// Return the symbol for the specified jump table entry.
458 MCSymbol *GetJTISymbol(unsigned JTID, bool isLinkerPrivate = false) const;
460 /// Return the symbol for the specified jump table .set
461 /// FIXME: privatize to AsmPrinter.
462 MCSymbol *GetJTSetSymbol(unsigned UID, unsigned MBBID) const;
464 /// Return the MCSymbol used to satisfy BlockAddress uses of the specified
465 /// basic block.
466 MCSymbol *GetBlockAddressSymbol(const BlockAddress *BA) const;
467 MCSymbol *GetBlockAddressSymbol(const BasicBlock *BB) const;
469 //===------------------------------------------------------------------===//
470 // Emission Helper Routines.
471 //===------------------------------------------------------------------===//
473 /// This is just convenient handler for printing offsets.
474 void printOffset(int64_t Offset, raw_ostream &OS) const;
476 /// Emit a byte directive and value.
477 void emitInt8(int Value) const;
479 /// Emit a short directive and value.
480 void emitInt16(int Value) const;
482 /// Emit a long directive and value.
483 void emitInt32(int Value) const;
485 /// Emit a long long directive and value.
486 void emitInt64(uint64_t Value) const;
488 /// Emit something like ".long Hi-Lo" where the size in bytes of the directive
489 /// is specified by Size and Hi/Lo specify the labels. This implicitly uses
490 /// .set if it is available.
491 void EmitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo,
492 unsigned Size) const;
494 /// Emit something like ".uleb128 Hi-Lo".
495 void EmitLabelDifferenceAsULEB128(const MCSymbol *Hi,
496 const MCSymbol *Lo) const;
498 /// Emit something like ".long Label+Offset" where the size in bytes of the
499 /// directive is specified by Size and Label specifies the label. This
500 /// implicitly uses .set if it is available.
501 void EmitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset,
502 unsigned Size, bool IsSectionRelative = false) const;
504 /// Emit something like ".long Label" where the size in bytes of the directive
505 /// is specified by Size and Label specifies the label.
506 void EmitLabelReference(const MCSymbol *Label, unsigned Size,
507 bool IsSectionRelative = false) const {
508 EmitLabelPlusOffset(Label, 0, Size, IsSectionRelative);
511 /// Emit something like ".long Label + Offset".
512 void EmitDwarfOffset(const MCSymbol *Label, uint64_t Offset) const;
514 //===------------------------------------------------------------------===//
515 // Dwarf Emission Helper Routines
516 //===------------------------------------------------------------------===//
518 /// Emit the specified signed leb128 value.
519 void EmitSLEB128(int64_t Value, const char *Desc = nullptr) const;
521 /// Emit the specified unsigned leb128 value.
522 void EmitULEB128(uint64_t Value, const char *Desc = nullptr, unsigned PadTo = 0) const;
524 /// Emit a .byte 42 directive that corresponds to an encoding. If verbose
525 /// assembly output is enabled, we output comments describing the encoding.
526 /// Desc is a string saying what the encoding is specifying (e.g. "LSDA").
527 void EmitEncodingByte(unsigned Val, const char *Desc = nullptr) const;
529 /// Return the size of the encoding in bytes.
530 unsigned GetSizeOfEncodedValue(unsigned Encoding) const;
532 /// Emit reference to a ttype global with a specified encoding.
533 void EmitTTypeReference(const GlobalValue *GV, unsigned Encoding) const;
535 /// Emit a reference to a symbol for use in dwarf. Different object formats
536 /// represent this in different ways. Some use a relocation others encode
537 /// the label offset in its section.
538 void emitDwarfSymbolReference(const MCSymbol *Label,
539 bool ForceOffset = false) const;
541 /// Emit the 4-byte offset of a string from the start of its section.
543 /// When possible, emit a DwarfStringPool section offset without any
544 /// relocations, and without using the symbol. Otherwise, defers to \a
545 /// emitDwarfSymbolReference().
546 void emitDwarfStringOffset(DwarfStringPoolEntry S) const;
548 /// Emit the 4-byte offset of a string from the start of its section.
549 void emitDwarfStringOffset(DwarfStringPoolEntryRef S) const {
550 emitDwarfStringOffset(S.getEntry());
553 /// Emit reference to a call site with a specified encoding
554 void EmitCallSiteOffset(const MCSymbol *Hi, const MCSymbol *Lo,
555 unsigned Encoding) const;
556 /// Emit an integer value corresponding to the call site encoding
557 void EmitCallSiteValue(uint64_t Value, unsigned Encoding) const;
559 /// Get the value for DW_AT_APPLE_isa. Zero if no isa encoding specified.
560 virtual unsigned getISAEncoding() { return 0; }
562 /// Emit the directive and value for debug thread local expression
564 /// \p Value - The value to emit.
565 /// \p Size - The size of the integer (in bytes) to emit.
566 virtual void EmitDebugValue(const MCExpr *Value, unsigned Size) const;
568 //===------------------------------------------------------------------===//
569 // Dwarf Lowering Routines
570 //===------------------------------------------------------------------===//
572 /// Emit frame instruction to describe the layout of the frame.
573 void emitCFIInstruction(const MCCFIInstruction &Inst) const;
575 /// Emit Dwarf abbreviation table.
576 template <typename T> void emitDwarfAbbrevs(const T &Abbrevs) const {
577 // For each abbreviation.
578 for (const auto &Abbrev : Abbrevs)
579 emitDwarfAbbrev(*Abbrev);
581 // Mark end of abbreviations.
582 EmitULEB128(0, "EOM(3)");
585 void emitDwarfAbbrev(const DIEAbbrev &Abbrev) const;
587 /// Recursively emit Dwarf DIE tree.
588 void emitDwarfDIE(const DIE &Die) const;
590 //===------------------------------------------------------------------===//
591 // Inline Asm Support
592 //===------------------------------------------------------------------===//
594 // These are hooks that targets can override to implement inline asm
595 // support. These should probably be moved out of AsmPrinter someday.
597 /// Print information related to the specified machine instr that is
598 /// independent of the operand, and may be independent of the instr itself.
599 /// This can be useful for portably encoding the comment character or other
600 /// bits of target-specific knowledge into the asmstrings. The syntax used is
601 /// ${:comment}. Targets can override this to add support for their own
602 /// strange codes.
603 virtual void PrintSpecial(const MachineInstr *MI, raw_ostream &OS,
604 const char *Code) const;
606 /// Print the MachineOperand as a symbol. Targets with complex handling of
607 /// symbol references should override the base implementation.
608 virtual void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &OS);
610 /// Print the specified operand of MI, an INLINEASM instruction, using the
611 /// specified assembler variant. Targets should override this to format as
612 /// appropriate. This method can return true if the operand is erroneous.
613 virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
614 const char *ExtraCode, raw_ostream &OS);
616 /// Print the specified operand of MI, an INLINEASM instruction, using the
617 /// specified assembler variant as an address. Targets should override this to
618 /// format as appropriate. This method can return true if the operand is
619 /// erroneous.
620 virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
621 const char *ExtraCode, raw_ostream &OS);
623 /// Let the target do anything it needs to do before emitting inlineasm.
624 /// \p StartInfo - the subtarget info before parsing inline asm
625 virtual void emitInlineAsmStart() const;
627 /// Let the target do anything it needs to do after emitting inlineasm.
628 /// This callback can be used restore the original mode in case the
629 /// inlineasm contains directives to switch modes.
630 /// \p StartInfo - the original subtarget info before inline asm
631 /// \p EndInfo - the final subtarget info after parsing the inline asm,
632 /// or NULL if the value is unknown.
633 virtual void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
634 const MCSubtargetInfo *EndInfo) const;
636 /// This emits visibility information about symbol, if this is supported by
637 /// the target.
638 void EmitVisibility(MCSymbol *Sym, unsigned Visibility,
639 bool IsDefinition = true) const;
641 /// This emits linkage information about \p GVSym based on \p GV, if this is
642 /// supported by the target.
643 void EmitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const;
645 /// Return the alignment for the specified \p GV.
646 static Align getGVAlignment(const GlobalValue *GV, const DataLayout &DL,
647 Align InAlign = Align::None());
649 private:
650 /// Private state for PrintSpecial()
651 // Assign a unique ID to this machine instruction.
652 mutable const MachineInstr *LastMI = nullptr;
653 mutable unsigned LastFn = 0;
654 mutable unsigned Counter = ~0U;
656 /// This method emits the header for the current function.
657 virtual void EmitFunctionHeader();
659 /// Emit a blob of inline asm to the output streamer.
660 void
661 EmitInlineAsm(StringRef Str, const MCSubtargetInfo &STI,
662 const MCTargetOptions &MCOptions,
663 const MDNode *LocMDNode = nullptr,
664 InlineAsm::AsmDialect AsmDialect = InlineAsm::AD_ATT) const;
666 /// This method formats and emits the specified machine instruction that is an
667 /// inline asm.
668 void EmitInlineAsm(const MachineInstr *MI) const;
670 /// Add inline assembly info to the diagnostics machinery, so we can
671 /// emit file and position info. Returns SrcMgr memory buffer position.
672 unsigned addInlineAsmDiagBuffer(StringRef AsmStr,
673 const MDNode *LocMDNode) const;
675 //===------------------------------------------------------------------===//
676 // Internal Implementation Details
677 //===------------------------------------------------------------------===//
679 void EmitJumpTableEntry(const MachineJumpTableInfo *MJTI,
680 const MachineBasicBlock *MBB, unsigned uid) const;
681 void EmitLLVMUsedList(const ConstantArray *InitList);
682 /// Emit llvm.ident metadata in an '.ident' directive.
683 void EmitModuleIdents(Module &M);
684 /// Emit bytes for llvm.commandline metadata.
685 void EmitModuleCommandLines(Module &M);
686 void EmitXXStructorList(const DataLayout &DL, const Constant *List,
687 bool isCtor);
689 GCMetadataPrinter *GetOrCreateGCPrinter(GCStrategy &S);
690 /// Emit GlobalAlias or GlobalIFunc.
691 void emitGlobalIndirectSymbol(Module &M, const GlobalIndirectSymbol &GIS);
692 void setupCodePaddingContext(const MachineBasicBlock &MBB,
693 MCCodePaddingContext &Context) const;
696 } // end namespace llvm
698 #endif // LLVM_CODEGEN_ASMPRINTER_H