Go to the documentation of this file.
50 std::unique_ptr<MCStreamer> Streamer)
62 SMShadowTracker.startFunction(
MF);
107 XTS->emitFPOEndProc();
151 if (GVSym->
getName()[0] !=
'$')
206 void X86AsmPrinter::PrintOperand(
const MachineInstr *
MI,
unsigned OpNo,
227 switch (
MI->getInlineAsmDialect()) {
235 PrintSymbolOperand(MO,
O);
249 void X86AsmPrinter::PrintModifiedOperand(
const MachineInstr *
MI,
unsigned OpNo,
253 return PrintOperand(
MI, OpNo,
O);
257 if (strncmp(Modifier,
"subreg", strlen(
"subreg")) == 0) {
258 unsigned Size = (strcmp(Modifier+6,
"64") == 0) ? 64 :
259 (strcmp(Modifier+6,
"32") == 0) ? 32 :
260 (strcmp(Modifier+6,
"16") == 0) ? 16 : 8;
269 void X86AsmPrinter::PrintPCRelImm(
const MachineInstr *
MI,
unsigned OpNo,
276 PrintOperand(
MI, OpNo,
O);
282 PrintSymbolOperand(MO,
O);
287 void X86AsmPrinter::PrintLeaMemReference(
const MachineInstr *
MI,
unsigned OpNo,
294 bool HasBaseReg = BaseReg.
getReg() != 0;
295 if (HasBaseReg && Modifier && !strcmp(Modifier,
"no-rip") &&
296 BaseReg.
getReg() == X86::RIP)
300 bool HasParenPart = IndexReg.
getReg() || HasBaseReg;
306 int DispVal = DispSpec.
getImm();
307 if (DispVal || !HasParenPart)
313 PrintSymbolOperand(DispSpec,
O);
317 if (Modifier && strcmp(Modifier,
"H") == 0)
322 "X86 doesn't allow scaling by ESP");
333 O <<
',' << ScaleVal;
339 void X86AsmPrinter::PrintMemReference(
const MachineInstr *
MI,
unsigned OpNo,
347 PrintLeaMemReference(
MI, OpNo,
O, Modifier);
351 void X86AsmPrinter::PrintIntelMemReference(
const MachineInstr *
MI,
353 const char *Modifier) {
361 bool HasBaseReg = BaseReg.
getReg() != 0;
362 if (HasBaseReg && Modifier && !strcmp(Modifier,
"no-rip") &&
363 BaseReg.
getReg() == X86::RIP)
368 !strcmp(Modifier,
"disp-only")) {
380 bool NeedPlus =
false;
387 if (NeedPlus)
O <<
" + ";
389 O << ScaleVal <<
'*';
394 if (!DispSpec.
isImm()) {
395 if (NeedPlus)
O <<
" + ";
398 int64_t DispVal = DispSpec.
getImm();
399 if (DispVal || (!IndexReg.
getReg() && !HasBaseReg)) {
426 default:
return true;
463 Index =
Reg - X86::XMM0;
465 Index =
Reg - X86::YMM0;
467 Index =
Reg - X86::ZMM0;
475 Reg = X86::XMM0 + Index;
478 Reg = X86::YMM0 + Index;
481 Reg = X86::ZMM0 + Index;
497 if (ExtraCode && ExtraCode[0]) {
498 if (ExtraCode[1] != 0)
return true;
502 switch (ExtraCode[0]) {
518 PrintSymbolOperand(MO,
O);
524 PrintOperand(
MI, OpNo,
O);
532 PrintOperand(
MI, OpNo,
O);
542 PrintSymbolOperand(MO,
O);
550 PrintOperand(
MI, OpNo,
O);
563 PrintOperand(
MI, OpNo,
O);
571 PrintOperand(
MI, OpNo,
O);
575 PrintPCRelImm(
MI, OpNo,
O);
589 PrintOperand(
MI, OpNo,
O);
594 const char *ExtraCode,
596 if (ExtraCode && ExtraCode[0]) {
597 if (ExtraCode[1] != 0)
return true;
599 switch (ExtraCode[0]) {
600 default:
return true;
612 PrintMemReference(
MI, OpNo,
O,
"H");
620 PrintIntelMemReference(
MI, OpNo,
O,
"disp-only");
622 PrintMemReference(
MI, OpNo,
O,
"disp-only");
628 PrintIntelMemReference(
MI, OpNo,
O,
nullptr);
630 PrintMemReference(
MI, OpNo,
O,
nullptr);
638 if (TT.isOSBinFormatELF()) {
640 unsigned FeatureFlagsAnd = 0;
641 if (
M.getModuleFlag(
"cf-protection-branch"))
643 if (
M.getModuleFlag(
"cf-protection-return"))
646 if (FeatureFlagsAnd) {
648 if (!TT.isArch32Bit() && !TT.isArch64Bit())
656 const int WordSize = TT.isArch64Bit() && !TT.isX32() ? 8 : 4;
674 if (TT.isOSBinFormatMachO())
677 if (TT.isOSBinFormatCOFF()) {
685 int64_t Feat00Flags = 0;
696 if (
M.getModuleFlag(
"cfguard")) {
697 Feat00Flags |= 0x800;
700 if (
M.getModuleFlag(
"ehcontguard")) {
701 Feat00Flags |= 0x4000;
713 if (
M.getModuleInlineAsm().empty() && is16)
750 if (!Stubs.empty()) {
755 for (
auto &Stub : Stubs)
766 if (TT.isOSBinFormatMachO()) {
781 }
else if (TT.isOSBinFormatCOFF()) {
797 (TT.getArch() ==
Triple::x86) ?
"__fltused" :
"_fltused";
803 }
else if (TT.isOSBinFormatELF()) {
@ GNU_PROPERTY_X86_FEATURE_1_AND
@ MO_TLVP
MO_TLVP - On a symbol operand this indicates that the immediate is some TLS offset.
@ MO_DARWIN_NONLAZY
MO_DARWIN_NONLAZY - On a symbol operand "FOO", this indicates that the reference is actually to the "...
@ MO_GOTTPOFF
MO_GOTTPOFF - On a symbol operand this indicates that the immediate is the offset of the GOT entry wi...
void emitFunctionBodyEnd() override
Targets can override this to emit stuff after the last basic block in the function.
@ MO_BlockAddress
Address of a basic block.
unsigned getArgumentStackSize() const
@ MO_Immediate
Immediate operand.
This is an optimization pass for GlobalISel generic memory operations.
void printOffset(int64_t Offset, raw_ostream &OS) const
This is just convenient handler for printing offsets.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - Emit the function body.
static SectionKind getMetadata()
@ GNU_PROPERTY_X86_FEATURE_1_SHSTK
const MCContext & getContext() const
@ IMAGE_SYM_CLASS_STATIC
Static.
static void emitNonLazyStubs(MachineModuleInfo *MMI, MCStreamer &OutStreamer)
const GlobalValue * getGlobal() const
MCContext & getContext() const
@ AddrSegmentReg
AddrSegmentReg - The operand # of the segment in the memory operand.
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Target & getTheX86_64Target()
const X86InstrInfo * getInstrInfo() const override
@ MO_INDNTPOFF
MO_INDNTPOFF - On a symbol operand this indicates that the immediate is the absolute address of the G...
const MCAsmInfo * MAI
Target Asm Printer information.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
return AArch64::GPR64RegClass contains(Reg)
unsigned getCodeViewFlag() const
Returns the CodeView Version by checking module flags.
const BlockAddress * getBlockAddress() const
@ MO_GOT_ABSOLUTE_ADDRESS
MO_GOT_ABSOLUTE_ADDRESS - On a symbol operand, this represents a relocation of: SYMBOL_LABEL + [.
@ MO_TLSGD
MO_TLSGD - On a symbol operand this indicates that the immediate is the offset of the GOT entry with ...
@ IMAGE_SYM_CLASS_EXTERNAL
External symbol.
Reg
All possible values of the reg field in the ModR/M byte.
@ MO_TLSLDM
MO_TLSLDM - On a symbol operand this indicates that the immediate is the offset of the GOT entry with...
@ SCT_COMPLEX_TYPE_SHIFT
Type is formed as (base + (derived << SCT_COMPLEX_TYPE_SHIFT))
Triple - Helper class for working with autoconf configuration names.
void emitStackMaps(StackMaps &SM)
Emit the stack maps.
std::vector< std::pair< MCSymbol *, StubValueTy > > SymbolListTy
void emitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
PointerIntPair< MCSymbol *, 1, bool > StubValueTy
bool isSymbol() const
isSymbol - Tests if this is a MO_ExternalSymbol operand.
void emitAlignment(Align Alignment, const GlobalObject *GV=nullptr, unsigned MaxBytesToEmit=0) const
Emit an alignment directive to the specified power of two boundary.
@ MO_SECREL
MO_SECREL - On a symbol operand this indicates that the immediate is the offset from beginning of sec...
@ MO_TPOFF
MO_TPOFF - On a symbol operand this indicates that the immediate is the thread-pointer offset for the...
unsigned getCodePointerSize() const
Get the code pointer size in bytes.
bool isPICStyleRIPRel() const
void emitStartOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the start of their fi...
virtual void AddBlankLine()
AddBlankLine - Emit a blank line to a .s file to pretty it up.
void serializeToFaultMapSection()
@ MO_GOTOFF
MO_GOTOFF - On a symbol operand this indicates that the immediate is the offset to the location of th...
int64_t getOffset() const
Return the offset from the symbol in this operand.
MCSymbol * lookupSymbol(const Twine &Name) const
Get the symbol for Name, or null.
@ MO_Register
Register operand.
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
MO_GOT - On a symbol operand this indicates that the immediate is the offset to the GOT entry for the...
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &O) override
PrintAsmOperand - Print out an operand for an inline asm expression.
static SectionKind getReadOnly()
MCCodeEmitter * createMCCodeEmitter(const MCInstrInfo &II, MCContext &Ctx) const
createMCCodeEmitter - Create a target specific code emitter.
Streaming machine code generation interface.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
@ MO_COFFSTUB
MO_COFFSTUB - On a symbol operand "FOO", this indicates that the reference is actually to the "....
@ MO_GlobalAddress
Address of a global value.
@ MO_PLT
MO_PLT - On a symbol operand this indicates that the immediate is offset to the PLT entry of symbol n...
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
bool isTargetWin32() const
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
@ MO_GOTPCREL
MO_GOTPCREL - On a symbol operand this indicates that the immediate is offset to the GOT entry for th...
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
virtual void SetupMachineFunction(MachineFunction &MF)
This should be called when a new MachineFunction is being processed from runOnMachineFunction.
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
@ MCAF_Code16
.code16 (X86) / .code 16 (ARM)
MachineOperand class - Representation of each machine instruction operand.
This class contains meta information specific to a module.
MCSymbol * CurrentFnSym
The symbol for the current function.
This class implements an extremely fast bulk output stream that can only output to a stream.
@ MO_GOTPCREL_NORELAX
MO_GOTPCREL_NORELAX - Same as MO_GOTPCREL except that R_X86_64_GOTPCREL relocations are guaranteed to...
bool hasInternalLinkage() const
StringRef getName() const
getName - Get the symbol name.
@ MO_TLVP_PIC_BASE
MO_TLVP_PIC_BASE - On a symbol operand this indicates that the immediate is some TLS offset from the ...
This struct is a compact representation of a valid (non-zero power of two) alignment.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
static void emitNonLazySymbolPointer(MCStreamer &OutStreamer, MCSymbol *StubLabel, MachineModuleInfoImpl::StubValueTy &MCSym)
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
@ S_NON_LAZY_SYMBOL_POINTERS
S_NON_LAZY_SYMBOL_POINTERS - Section with non-lazy symbol pointers.
static bool printAsmVRegister(const MachineOperand &MO, char Mode, raw_ostream &O)
PointerTy getPointer() const
MachineModuleInfo & getMMI() const
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Target & getTheX86_32Target()
@ MO_DARWIN_NONLAZY_PIC_BASE
MO_DARWIN_NONLAZY_PIC_BASE - On a symbol operand "FOO", this indicates that the reference is actually...
unsigned getTargetFlags() const
@ MCAF_SubsectionsViaSymbols
.subsections_via_symbols (MachO)
virtual MCSymbol * GetCPISymbol(unsigned CPID) const
Return the symbol for the specified constant pool entry.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Representation of each machine instruction.
@ MO_GOTNTPOFF
MO_GOTNTPOFF - On a symbol operand this indicates that the immediate is the offset of the GOT entry w...
@ MO_PIC_BASE_OFFSET
MO_PIC_BASE_OFFSET - On a symbol operand this indicates that the immediate should get the value of th...
#define LLVM_EXTERNAL_VISIBILITY
MCRegister getX86SubSuperRegister(MCRegister, unsigned, bool High=false)
Returns the sub or super register of a specific X86 register.
MCSymbol * GetBlockAddressSymbol(const BlockAddress *BA) const
Return the MCSymbol used to satisfy BlockAddress uses of the specified basic block.
MCSymbol * getSymbolPreferLocal(const GlobalValue &GV) const
Similar to getSymbol() but preferred for references.
bool isTargetCOFF() const
@ MO_DTPOFF
MO_DTPOFF - On a symbol operand this indicates that the immediate is the offset of the GOT entry with...
X86AsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MCSymbol * getSymbol(const GlobalValue *GV) const
static const char * getRegisterName(unsigned RegNo)
Primary interface to the complete machine description for the target machine.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
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.
bool hasLocalLinkage() const
MachineFunction * MF
The current machine function.
MCContext & OutContext
This is the context for the output file that we are streaming.
X86MachineFunctionInfo - This class is derived from MachineFunction and contains private X86 target-s...
InlineAsm::AsmDialect getInlineAsmDialect() const
Register getReg() const
getReg - Returns the register number.
A Module instance is used to store all the information related to an LLVM module.
@ MO_JumpTableIndex
Address of indexed Jump Table for switch.
MCSymbol * GetExternalSymbolSymbol(StringRef Sym) const
Return the MCSymbol for the specified ExternalSymbol.
@ MO_DLLIMPORT
MO_DLLIMPORT - On a symbol operand "FOO", this indicates that the reference is actually to the "__imp...
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &O) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
StringRef - Represent a constant reference to a string, i.e.
Analysis the ScalarEvolution expression for r is this
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeX86AsmPrinter()
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void emitEndOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the end of their file...
Instances of this class represent a uniqued identifier for a section in the current translation unit.
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
static bool printAsmMRegister(const X86AsmPrinter &P, const MachineOperand &MO, char Mode, raw_ostream &O)
@ MCSA_IndirectSymbol
.indirect_symbol (MachO)
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
Wrapper class representing virtual and physical registers.
MachineModuleInfo * MMI
This is a pointer to the current MachineModuleInfo.
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void emitFunctionBodyStart() override
Targets can override this to emit stuff before the first basic block in the function.
@ GNU_PROPERTY_X86_FEATURE_1_IBT
Function & getFunction()
Return the LLVM function that this machine code represents.
virtual bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute)=0
Add the given Attribute to Symbol.
@ MO_ExternalSymbol
Name of external global symbol.
SymbolListTy GetGVStubList()
Accessor methods to return the set of stubs in sorted order.
@ MO_TLSLD
MO_TLSLD - On a symbol operand this indicates that the immediate is the offset of the GOT entry with ...
This class is intended to be used as a driving class for all asm writers.
CodeModel::Model getCodeModel() const
Returns the code model.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
@ MCSA_Global
.type _foo, @gnu_unique_object
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
X86 target streamer implementing x86-only assembly directives.
virtual MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment) const
Given a constant with the SectionKind, return a section that it should be placed in.
MCSymbol * getPICBaseSymbol() const
getPICBaseSymbol - Return a function-local symbol to represent the PIC base.
PointerIntPair - This class implements a pair of a pointer and small integer.
MCContext & getContext() const
TargetMachine & TM
Target machine description.
@ IMAGE_SYM_DTYPE_NULL
No complex type; simple scalar variable.
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 TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
void emitFunctionBody()
This method emits the body and trailer for a function.
const Triple & getTargetTriple() const
static bool isMem(const MachineInstr &MI, unsigned Op)
const DataLayout & getDataLayout() const
Return information about data layout.
const char LLVMTargetMachineRef TM
void emitXRayTable()
Emit a table with all XRay instrumentation points.
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...
const Target & getTarget() const
@ MO_NTPOFF
MO_NTPOFF - On a symbol operand this indicates that the immediate is the negative thread-pointer offs...
@ IMAGE_SYM_DTYPE_FUNCTION
A function that returns a base type.
virtual void SwitchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
const Module * getModule() const
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.
Ty & getObjFileInfo()
Keep track of various per-module pieces of information for backends that would like to do so.
MachineModuleInfoMachO - This is a MachineModuleInfoImpl implementation for MachO targets.
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
bool usesMSVCFloatingPoint() const
@ MO_ConstantPoolIndex
Address of indexed Constant in Constant Pool.