45 std::unique_ptr<MCStreamer> Streamer)
46 :
AsmPrinter(TM,
std::move(Streamer)), SM(*this), FM(*this) {}
57 SMShadowTracker.startFunction(MF);
92 static_cast<X86TargetStreamer *>(
OutStreamer->getTargetStreamer()))
102 static_cast<X86TargetStreamer *>(
OutStreamer->getTargetStreamer()))
103 XTS->emitFPOEndProc();
148 if (GVSym->
getName()[0] !=
'$')
204 const char *Modifier =
nullptr,
unsigned AsmVariant = 0);
228 unsigned OpNo,
raw_ostream &O,
const char *Modifier,
229 unsigned AsmVariant) {
235 if (AsmVariant == 0) O <<
'%';
237 if (Modifier && strncmp(Modifier,
"subreg", strlen(
"subreg")) == 0) {
238 unsigned Size = (strcmp(Modifier+6,
"64") == 0) ? 64 :
239 (strcmp(Modifier+6,
"32") == 0) ? 32 :
240 (strcmp(Modifier+6,
"16") == 0) ? 16 : 8;
248 if (AsmVariant == 0) O <<
'$';
253 if (AsmVariant == 0) O <<
'$';
262 const char *Modifier =
nullptr) {
268 bool HasBaseReg = BaseReg.
getReg() != 0;
269 if (HasBaseReg && Modifier && !strcmp(Modifier,
"no-rip") &&
270 BaseReg.
getReg() == X86::RIP)
274 bool HasParenPart = IndexReg.
getReg() || HasBaseReg;
280 int DispVal = DispSpec.
getImm();
281 if (DispVal || !HasParenPart)
290 if (Modifier && strcmp(Modifier,
"H") == 0)
295 "X86 doesn't allow scaling by ESP");
306 O <<
',' << ScaleVal;
314 const char *Modifier =
nullptr) {
315 assert(
isMem(*MI, Op) &&
"Invalid memory reference!");
326 const char *Modifier =
nullptr,
327 unsigned AsmVariant = 1) {
342 bool NeedPlus =
false;
349 if (NeedPlus) O <<
" + ";
351 O << ScaleVal <<
'*';
356 if (!DispSpec.
isImm()) {
357 if (NeedPlus) O <<
" + ";
360 int64_t DispVal = DispSpec.
getImm();
361 if (DispVal || (!IndexReg.
getReg() && !BaseReg.
getReg())) {
379 bool EmitPercent =
true;
381 if (!X86::GR8RegClass.
contains(Reg) &&
388 default:
return true;
424 if (ExtraCode && ExtraCode[0]) {
425 if (ExtraCode[1] != 0)
return true;
429 switch (ExtraCode[0]) {
513 unsigned OpNo,
unsigned AsmVariant,
514 const char *ExtraCode,
521 if (ExtraCode && ExtraCode[0]) {
522 if (ExtraCode[1] != 0)
return true;
524 switch (ExtraCode[0]) {
525 default:
return true;
550 unsigned FeatureFlagsAnd = 0;
556 if (FeatureFlagsAnd) {
595 int64_t Feat00Flags = 0;
607 Feat00Flags |= 0x800;
655 if (!Stubs.empty()) {
660 for (
auto &Stub : Stubs)
unsigned getTargetFlags() const
MO_SECREL - On a symbol operand this indicates that the immediate is the offset from beginning of sec...
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
bool is64Bit() const
Is this x86_64? (disregarding specific ABI / programming model)
SymbolListTy GetGVStubList()
Accessor methods to return the set of stubs in sorted order.
S_NON_LAZY_SYMBOL_POINTERS - Section with non-lazy symbol pointers.
static bool printAsmMRegister(X86AsmPrinter &P, const MachineOperand &MO, char Mode, raw_ostream &O)
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
void LLVMInitializeX86AsmPrinter()
bool hasLocalLinkage() const
static const char * getRegisterName(unsigned RegNo)
MO_COFFSTUB - On a symbol operand "FOO", this indicates that the reference is actually to the "...
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
This class represents lattice values for constants.
PointerTy getPointer() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
A Module instance is used to store all the information related to an LLVM module. ...
MO_TLSLD - On a symbol operand this indicates that the immediate is the offset of the GOT entry with ...
virtual void AddBlankLine()
AddBlankLine - Emit a blank line to a .s file to pretty it up.
MO_TLVP_PIC_BASE - On a symbol operand this indicates that the immediate is some TLS offset from the ...
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
MCContext & OutContext
This is the context for the output file that we are streaming.
const X86InstrInfo * getInstrInfo() const override
unsigned getReg() const
getReg - Returns the register number.
bool runOnMachineFunction(MachineFunction &F) override
runOnMachineFunction - Emit the function body.
Address of indexed Jump Table for switch.
MachineFunction * MF
The current machine function.
MachineModuleInfo & getMMI() const
MO_GOTPCREL - On a symbol operand this indicates that the immediate is offset to the GOT entry for th...
MO_DTPOFF - On a symbol operand this indicates that the immediate is the offset of the GOT entry with...
static void printSymbolOperand(X86AsmPrinter &P, const MachineOperand &MO, raw_ostream &O)
printSymbolOperand - Print a raw symbol reference operand.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
No complex type; simple scalar variable.
return AArch64::GPR64RegClass contains(Reg)
X86MachineFunctionInfo - This class is derived from MachineFunction and contains private X86 target-s...
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
MCContext & getContext() const
MO_DARWIN_NONLAZY_PIC_BASE - On a symbol operand "FOO", this indicates that the reference is actually...
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
static void printPCRelImm(X86AsmPrinter &P, const MachineInstr *MI, unsigned OpNo, raw_ostream &O)
printPCRelImm - This is used to print an immediate value that ends up being encoded as a pc-relative ...
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
bool isPICStyleRIPRel() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
bool isKnownWindowsMSVCEnvironment() const
Checks if the environment is MSVC.
Name of external global symbol.
static bool isMem(const MachineInstr &MI, unsigned Op)
void emitXRayTable()
Emit a table with all XRay instrumentation points.
void EmitFunctionBody()
This method emits the body and trailer for a function.
.code16 (X86) / .code 16 (ARM)
MCSectionMachO * getMachOSection(StringRef Segment, StringRef Section, unsigned TypeAndAttributes, unsigned Reserved2, SectionKind K, const char *BeginSymName=nullptr)
Return the MCSection for the specified mach-o section.
MO_GOT - On a symbol operand this indicates that the immediate is the offset to the GOT entry for the...
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
const MCContext & getContext() const
bool isArch32Bit() const
Test whether the architecture is 32-bit.
static void printLeaMemReference(X86AsmPrinter &P, const MachineInstr *MI, unsigned Op, raw_ostream &O, const char *Modifier=nullptr)
MO_GOTTPOFF - On a symbol operand this indicates that the immediate is the offset of the GOT entry wi...
RegisterAsmPrinter - Helper template for registering a target specific assembly printer, for use in the target machine initialization function.
static void emitNonLazySymbolPointer(MCStreamer &OutStreamer, MCSymbol *StubLabel, MachineModuleInfoImpl::StubValueTy &MCSym)
static void printOperand(X86AsmPrinter &P, const MachineInstr *MI, unsigned OpNo, raw_ostream &O, const char *Modifier=nullptr, unsigned AsmVariant=0)
Type is formed as (base + (derived << SCT_COMPLEX_TYPE_SHIFT))
void printOffset(int64_t Offset, raw_ostream &OS) const
This is just convenient handler for printing offsets.
MCCodeEmitter * createMCCodeEmitter(const MCInstrInfo &II, const MCRegisterInfo &MRI, MCContext &Ctx) const
createMCCodeEmitter - Create a target specific code emitter.
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS) override
PrintAsmOperand - Print out an operand for an inline asm expression.
virtual void EmitIntValue(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers...
MO_DARWIN_NONLAZY - On a symbol operand "FOO", this indicates that the reference is actually to the "...
void EmitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
MachineModuleInfo * MMI
This is a pointer to the current MachineModuleInfo.
unsigned getCodeViewFlag() const
Returns the CodeView Version by checking module flags.
MCContext & getContext() const
static void emitNonLazyStubs(MachineModuleInfo *MMI, MCStreamer &OutStreamer)
unsigned getArgumentStackSize() const
Address of a global value.
Streaming machine code generation interface.
MCSymbol * CurrentFnSym
The symbol for the current function.
MO_GOT_ABSOLUTE_ADDRESS - On a symbol operand, this represents a relocation of: SYMBOL_LABEL + [...
const MCAsmInfo * MAI
Target Asm Printer information.
PointerIntPair - This class implements a pair of a pointer and small integer.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
Metadata * getModuleFlag(StringRef Key) const
Return the corresponding value if Key appears in module flags, otherwise return null.
MO_GOTNTPOFF - On a symbol operand this indicates that the immediate is the offset of the GOT entry w...
MO_TLVP - On a symbol operand this indicates that the immediate is some TLS offset.
virtual void SwitchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
const GlobalValue * getGlobal() const
MO_TLSLDM - On a symbol operand this indicates that the immediate is the offset of the GOT entry with...
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant...
void EmitAlignment(unsigned NumBits, const GlobalObject *GV=nullptr) const
Emit an alignment directive to the specified power of two boundary.
void EmitFunctionBodyEnd() override
Targets can override this to emit stuff after the last basic block in the function.
TargetMachine & TM
Target machine description.
This class is intended to be used as a driving class for all asm writers.
virtual bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute)=0
Add the given Attribute to Symbol.
bool hasInternalLinkage() const
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
.subsections_via_symbols (MachO)
const Triple & getTargetTriple() const
MO_NTPOFF - On a symbol operand this indicates that the immediate is the negative thread-pointer offs...
Ty & getObjFileInfo()
Keep track of various per-function pieces of information for backends that would like to do so...
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
const Target & getTarget() const
void emitStackMaps(StackMaps &SM)
Emit the stack maps.
virtual MCSymbol * GetCPISymbol(unsigned CPID) const
Return the symbol for the specified constant pool entry.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Triple - Helper class for working with autoconf configuration names.
MO_TLSGD - On a symbol operand this indicates that the immediate is the offset of the GOT entry with ...
const X86RegisterInfo * getRegisterInfo() const override
MO_TPOFF - On a symbol operand this indicates that the immediate is the thread-pointer offset for the...
void EmitFunctionBodyStart() override
Targets can override this to emit stuff before the first basic block in the function.
MCSymbol * getSymbol(const GlobalValue *GV) const
void serializeToFaultMapSection()
MachineOperand class - Representation of each machine instruction operand.
Module.h This file contains the declarations for the Module class.
void EmitStartOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the start of their fi...
static SectionKind getMetadata()
EnvironmentType getEnvironment() const
getEnvironment - Get the parsed environment type of this triple.
bool isTargetWin32() const
const Function & getFunction() const
Return the LLVM function that this machine code represents.
unsigned getX86SubSuperRegister(unsigned, unsigned, bool High=false)
Returns the sub or super register of a specific X86 register.
static void printMemReference(X86AsmPrinter &P, const MachineInstr *MI, unsigned Op, raw_ostream &O, const char *Modifier=nullptr)
Representation of each machine instruction.
MO_GOTOFF - On a symbol operand this indicates that the immediate is the offset to the location of th...
void SetupMachineFunction(MachineFunction &MF)
This should be called when a new MachineFunction is being processed from runOnMachineFunction.
MO_INDNTPOFF - On a symbol operand this indicates that the immediate is the absolute address of the G...
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
bool isArch64Bit() const
Test whether the architecture is 64-bit.
static void printIntelMemReference(X86AsmPrinter &P, const MachineInstr *MI, unsigned Op, raw_ostream &O, const char *Modifier=nullptr, unsigned AsmVariant=1)
int64_t getOffset() const
Return the offset from the symbol in this operand.
void EmitEndOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the end of their file...
virtual void print(raw_ostream &OS, const Module *M) const
print - Print out the internal state of the pass.
bool isTargetCOFF() const
Target & getTheX86_32Target()
const Module * getModule() const
MachineModuleInfoMachO - This is a MachineModuleInfoImpl implementation for MachO targets...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
std::vector< std::pair< MCSymbol *, StubValueTy > > SymbolListTy
MO_PLT - On a symbol operand this indicates that the immediate is offset to the PLT entry of symbol n...
const std::string & getModuleInlineAsm() const
Get any module-scope inline assembly blocks.
StringRef getName() const
getName - Get the symbol name.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
MCSymbol * getPICBaseSymbol() const
getPICBaseSymbol - Return a function-local symbol to represent the PIC base.
virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
bool usesVAFloatArgument() const
This class implements an extremely fast bulk output stream that can only output to a stream...
Primary interface to the complete machine description for the target machine.
MO_PIC_BASE_OFFSET - On a symbol operand this indicates that the immediate should get the value of th...
StringRef - Represent a constant reference to a string, i.e.
Address of indexed Constant in Constant Pool.
AddrSegmentReg - The operand # of the segment in the memory operand.
X86AsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
MCSymbol * getSymbolWithGlobalValueBase(const GlobalValue *GV, StringRef Suffix) const
Return the MCSymbol for a private symbol with global value name as its base, with the specified suffi...
const MachineOperand & getOperand(unsigned i) const
Target & getTheX86_64Target()
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
This class can be derived from and used by targets to hold private target-specific information for ea...
const X86Subtarget & getSubtarget() const
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
MO_DLLIMPORT - On a symbol operand "FOO", this indicates that the reference is actually to the "__imp...
This class contains meta information specific to a module.
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
A function that returns a base type.