46 std::unique_ptr<MCStreamer> Streamer)
47 :
AsmPrinter(TM,
std::move(Streamer)), SM(*this), FM(*this) {}
58 SMShadowTracker.startFunction(MF);
93 static_cast<X86TargetStreamer *>(
OutStreamer->getTargetStreamer()))
103 static_cast<X86TargetStreamer *>(
OutStreamer->getTargetStreamer()))
104 XTS->emitFPOEndProc();
148 if (GVSym->
getName()[0] !=
'$')
202 void X86AsmPrinter::PrintOperand(
const MachineInstr *
MI,
unsigned OpNo,
231 PrintSymbolOperand(MO, O);
245 void X86AsmPrinter::PrintModifiedOperand(
const MachineInstr *MI,
unsigned OpNo,
249 return PrintOperand(MI, OpNo, O);
253 if (strncmp(Modifier,
"subreg", strlen(
"subreg")) == 0) {
254 unsigned Size = (strcmp(Modifier+6,
"64") == 0) ? 64 :
255 (strcmp(Modifier+6,
"32") == 0) ? 32 :
256 (strcmp(Modifier+6,
"16") == 0) ? 16 : 8;
265 void X86AsmPrinter::PrintPCRelImm(
const MachineInstr *MI,
unsigned OpNo,
272 PrintOperand(MI, OpNo, O);
278 PrintSymbolOperand(MO, O);
283 void X86AsmPrinter::PrintLeaMemReference(
const MachineInstr *MI,
unsigned OpNo,
290 bool HasBaseReg = BaseReg.
getReg() != 0;
291 if (HasBaseReg && Modifier && !strcmp(Modifier,
"no-rip") &&
292 BaseReg.
getReg() == X86::RIP)
296 bool HasParenPart = IndexReg.
getReg() || HasBaseReg;
302 int DispVal = DispSpec.
getImm();
303 if (DispVal || !HasParenPart)
309 PrintSymbolOperand(DispSpec, O);
313 if (Modifier && strcmp(Modifier,
"H") == 0)
318 "X86 doesn't allow scaling by ESP");
329 O <<
',' << ScaleVal;
335 void X86AsmPrinter::PrintMemReference(
const MachineInstr *MI,
unsigned OpNo,
337 assert(
isMem(*MI, OpNo) &&
"Invalid memory reference!");
343 PrintLeaMemReference(MI, OpNo, O, Modifier);
347 void X86AsmPrinter::PrintIntelMemReference(
const MachineInstr *MI,
349 const char *Modifier) {
357 bool HasBaseReg = BaseReg.
getReg() != 0;
358 if (HasBaseReg && Modifier && !strcmp(Modifier,
"no-rip") &&
359 BaseReg.
getReg() == X86::RIP)
370 bool NeedPlus =
false;
377 if (NeedPlus) O <<
" + ";
379 O << ScaleVal <<
'*';
384 if (!DispSpec.
isImm()) {
385 if (NeedPlus) O <<
" + ";
388 int64_t DispVal = DispSpec.
getImm();
389 if (DispVal || (!IndexReg.
getReg() && !HasBaseReg)) {
407 bool EmitPercent =
true;
409 if (!X86::GR8RegClass.
contains(Reg) &&
416 default:
return true;
451 if (ExtraCode && ExtraCode[0]) {
452 if (ExtraCode[1] != 0)
return true;
456 switch (ExtraCode[0]) {
472 PrintSymbolOperand(MO, O);
478 PrintOperand(MI, OpNo, O);
486 PrintOperand(MI, OpNo, O);
496 PrintSymbolOperand(MO, O);
504 PrintOperand(MI, OpNo, O);
517 PrintOperand(MI, OpNo, O);
521 PrintPCRelImm(MI, OpNo, O);
535 PrintOperand(MI, OpNo, O);
540 const char *ExtraCode,
542 if (ExtraCode && ExtraCode[0]) {
543 if (ExtraCode[1] != 0)
return true;
545 switch (ExtraCode[0]) {
546 default:
return true;
558 PrintMemReference(MI, OpNo, O,
"H");
563 PrintIntelMemReference(MI, OpNo, O,
"no-rip");
565 PrintMemReference(MI, OpNo, O,
"no-rip");
571 PrintIntelMemReference(MI, OpNo, O,
nullptr);
573 PrintMemReference(MI, OpNo, O,
nullptr);
583 unsigned FeatureFlagsAnd = 0;
589 if (FeatureFlagsAnd) {
628 int64_t Feat00Flags = 0;
640 Feat00Flags |= 0x800;
688 if (!Stubs.empty()) {
693 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)
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
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")
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
bool runOnMachineFunction(MachineFunction &F) override
runOnMachineFunction - Emit the function body.
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeX86AsmPrinter()
Address of indexed Jump Table for switch.
void EmitAlignment(Align Alignment, const GlobalObject *GV=nullptr) const
Emit an alignment directive to the specified power of two boundary.
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS) override
PrintAsmOperand - Print out an operand for an inline asm expression.
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...
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
MCRegister getX86SubSuperRegister(MCRegister, unsigned, bool High=false)
Returns the sub or super register of a specific X86 register.
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.
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...
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.
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)
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.
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.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false)
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...
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
Address of a basic block.
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 * GetBlockAddressSymbol(const BlockAddress *BA) const
Return the MCSymbol used to satisfy BlockAddress uses of the specified basic block.
InlineAsm::AsmDialect getInlineAsmDialect() const
MCSymbol * getSymbol(const GlobalValue *GV) const
void serializeToFaultMapSection()
MachineOperand class - Representation of each machine instruction operand.
AddrSegmentReg - The operand # of the segment in the memory 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.
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant...
bool isTargetWin32() const
#define LLVM_EXTERNAL_VISIBILITY
const Function & getFunction() const
Return the LLVM function that this machine code represents.
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
Representation of each machine instruction.
MO_GOTOFF - On a symbol operand this indicates that the immediate is the offset to the location of th...
virtual 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 isArch64Bit() const
Test whether the architecture is 64-bit.
int64_t getOffset() const
Return the offset from the symbol in this operand.
const BlockAddress * getBlockAddress() const
void EmitEndOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the end of their file...
bool usesMSVCFloatingPoint() const
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)
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
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.
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.
Register getReg() const
getReg - Returns the register number.
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.
const X86Subtarget & getSubtarget() const
Wrapper class representing virtual and physical registers.
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.