65 #define DEBUG_TYPE "asm-printer" 75 AArch64AsmPrinter(
TargetMachine &
TM, std::unique_ptr<MCStreamer> Streamer)
76 :
AsmPrinter(TM, std::move(Streamer)), MCInstLowering(OutContext, *
this),
79 StringRef getPassName()
const override {
return "AArch64 Assembly Printer"; }
87 void EmitStartOfAsmFile(
Module &M)
override;
88 void EmitJumpTableInfo()
override;
99 void LowerPATCHABLE_FUNCTION_ENTER(
const MachineInstr &MI);
100 void LowerPATCHABLE_FUNCTION_EXIT(
const MachineInstr &MI);
103 typedef std::tuple<unsigned, bool, uint32_t> HwasanMemaccessTuple;
104 std::map<HwasanMemaccessTuple, MCSymbol *> HwasanMemaccessSymbols;
105 void LowerHWASAN_CHECK_MEMACCESS(
const MachineInstr &MI);
106 void EmitHwasanMemaccessSymbols(
Module &M);
112 bool emitPseudoExpansionLowering(
MCStreamer &OutStreamer,
126 SetupMachineFunction(MF);
128 if (STI->isTargetCOFF()) {
158 bool PrintAsmOperand(
const MachineInstr *MI,
unsigned OpNum,
160 bool PrintAsmMemoryOperand(
const MachineInstr *MI,
unsigned OpNum,
165 void EmitFunctionBodyEnd()
override;
167 MCSymbol *GetCPISymbol(
unsigned CPID)
const override;
168 void EmitEndOfAsmFile(
Module &M)
override;
178 using MInstToMCSymbol = std::map<const MachineInstr *, MCSymbol *>;
180 MInstToMCSymbol LOHInstToLabel;
185 void AArch64AsmPrinter::EmitStartOfAsmFile(
Module &M) {
186 if (!
TM.getTargetTriple().isOSBinFormatELF())
204 errs() <<
"warning: some functions compiled with BTI and some compiled " 206 <<
"warning: not setting BTI in feature flags\n";
222 MCSection *Cur = OutStreamer->getCurrentSectionOnly();
223 MCSection *Nt = MMI->getContext().getELFSection(
225 OutStreamer->SwitchSection(Nt);
228 EmitAlignment(
Align(8));
229 OutStreamer->EmitIntValue(4, 4);
230 OutStreamer->EmitIntValue(4 * 4, 4);
232 OutStreamer->EmitBytes(
StringRef(
"GNU", 4));
236 OutStreamer->EmitIntValue(4, 4);
237 OutStreamer->EmitIntValue(Flags, 4);
238 OutStreamer->EmitIntValue(0, 4);
240 OutStreamer->endSection(Nt);
241 OutStreamer->SwitchSection(Cur);
244 void AArch64AsmPrinter::LowerPATCHABLE_FUNCTION_ENTER(
const MachineInstr &
MI)
257 EmitSled(MI, SledKind::FUNCTION_ENTER);
260 void AArch64AsmPrinter::LowerPATCHABLE_FUNCTION_EXIT(
const MachineInstr &MI)
262 EmitSled(MI, SledKind::FUNCTION_EXIT);
265 void AArch64AsmPrinter::LowerPATCHABLE_TAIL_CALL(
const MachineInstr &MI)
267 EmitSled(MI, SledKind::TAIL_CALL);
272 static const int8_t NoopsInSledCount = 7;
293 OutStreamer->EmitCodeAlignment(4);
294 auto CurSled = OutContext.createTempSymbol(
"xray_sled_",
true);
295 OutStreamer->EmitLabel(CurSled);
296 auto Target = OutContext.createTempSymbol();
303 for (int8_t
I = 0;
I < NoopsInSledCount;
I++)
304 EmitToStreamer(*OutStreamer,
MCInstBuilder(AArch64::HINT).addImm(0));
306 OutStreamer->EmitLabel(
Target);
307 recordSled(CurSled, MI, Kind);
310 void AArch64AsmPrinter::LowerHWASAN_CHECK_MEMACCESS(
const MachineInstr &MI) {
313 MI.
getOpcode() == AArch64::HWASAN_CHECK_MEMACCESS_SHORTGRANULES;
316 HwasanMemaccessSymbols[HwasanMemaccessTuple(Reg, IsShort, AccessInfo)];
319 if (!
TM.getTargetTriple().isOSBinFormatELF())
322 std::string SymName =
"__hwasan_check_x" +
utostr(Reg - AArch64::X0) +
"_" +
326 Sym = OutContext.getOrCreateSymbol(SymName);
329 EmitToStreamer(*OutStreamer,
334 void AArch64AsmPrinter::EmitHwasanMemaccessSymbols(
Module &M) {
335 if (HwasanMemaccessSymbols.empty())
340 std::unique_ptr<MCSubtargetInfo> STI(
341 TM.getTarget().createMCSubtargetInfo(TT.
str(),
"",
""));
344 OutContext.getOrCreateSymbol(
"__hwasan_tag_mismatch");
346 OutContext.getOrCreateSymbol(
"__hwasan_tag_mismatch_v2");
353 for (
auto &
P : HwasanMemaccessSymbols) {
354 unsigned Reg = std::get<0>(
P.first);
355 bool IsShort = std::get<1>(
P.first);
356 uint32_t AccessInfo = std::get<2>(
P.first);
358 IsShort ? HwasanTagMismatchV2Ref : HwasanTagMismatchV1Ref;
361 OutStreamer->SwitchSection(OutContext.getELFSection(
367 OutStreamer->EmitSymbolAttribute(Sym,
MCSA_Weak);
368 OutStreamer->EmitSymbolAttribute(Sym,
MCSA_Hidden);
369 OutStreamer->EmitLabel(Sym);
372 .addReg(AArch64::X16)
377 OutStreamer->EmitInstruction(
MCInstBuilder(AArch64::LDRBBroX)
378 .addReg(AArch64::W16)
380 .addReg(AArch64::X16)
384 OutStreamer->EmitInstruction(
386 .addReg(AArch64::XZR)
387 .addReg(AArch64::X16)
391 MCSymbol *HandleMismatchOrPartialSym = OutContext.createTempSymbol();
392 OutStreamer->EmitInstruction(
398 MCSymbol *ReturnSym = OutContext.createTempSymbol();
399 OutStreamer->EmitLabel(ReturnSym);
400 OutStreamer->EmitInstruction(
402 OutStreamer->EmitLabel(HandleMismatchOrPartialSym);
406 .addReg(AArch64::WZR)
407 .addReg(AArch64::W16)
411 MCSymbol *HandleMismatchSym = OutContext.createTempSymbol();
412 OutStreamer->EmitInstruction(
418 OutStreamer->EmitInstruction(
420 .addReg(AArch64::X17)
424 unsigned Size = 1 << (AccessInfo & 0xf);
427 .addReg(AArch64::X17)
428 .addReg(AArch64::X17)
433 .addReg(AArch64::WZR)
434 .addReg(AArch64::W16)
435 .addReg(AArch64::W17)
438 OutStreamer->EmitInstruction(
444 OutStreamer->EmitInstruction(
446 .addReg(AArch64::X16)
451 .addReg(AArch64::W16)
452 .addReg(AArch64::X16)
455 OutStreamer->EmitInstruction(
457 .addReg(AArch64::XZR)
458 .addReg(AArch64::X16)
462 OutStreamer->EmitInstruction(
468 OutStreamer->EmitLabel(HandleMismatchSym);
485 if (Reg != AArch64::X0)
488 .addReg(AArch64::XZR)
501 OutStreamer->EmitInstruction(
503 .addReg(AArch64::X16)
505 HwasanTagMismatchRef, AArch64MCExpr::VariantKind::VK_GOT_PAGE,
508 OutStreamer->EmitInstruction(
510 .addReg(AArch64::X16)
511 .addReg(AArch64::X16)
513 HwasanTagMismatchRef, AArch64MCExpr::VariantKind::VK_GOT_LO12,
516 OutStreamer->EmitInstruction(
521 void AArch64AsmPrinter::EmitEndOfAsmFile(
Module &M) {
522 EmitHwasanMemaccessSymbols(M);
536 void AArch64AsmPrinter::EmitLOHs() {
539 for (
const auto &
D : AArch64FI->getLOHContainer()) {
541 MInstToMCSymbol::iterator LabelIt = LOHInstToLabel.find(MI);
542 assert(LabelIt != LOHInstToLabel.end() &&
543 "Label hasn't been inserted for LOH related instruction");
546 OutStreamer->EmitLOHDirective(
D.getKind(), MCArgs);
551 void AArch64AsmPrinter::EmitFunctionBodyEnd() {
552 if (!AArch64FI->getLOHRelated().empty())
557 MCSymbol *AArch64AsmPrinter::GetCPISymbol(
unsigned CPID)
const {
561 if (!getDataLayout().getLinkerPrivateGlobalPrefix().
empty())
562 return OutContext.getOrCreateSymbol(
563 Twine(getDataLayout().getLinkerPrivateGlobalPrefix()) +
"CPI" +
564 Twine(getFunctionNumber()) +
"_" +
Twine(CPID));
587 PrintSymbolOperand(MO, O);
619 bool AArch64AsmPrinter::printAsmRegInClass(
const MachineOperand &MO,
622 assert(MO.
isReg() &&
"Should only get here with a register!");
625 unsigned RegToPrint = RC->
getRegister(RI->getEncodingValue(Reg));
626 assert(RI->regsOverlap(RegToPrint, Reg));
631 bool AArch64AsmPrinter::PrintAsmOperand(
const MachineInstr *MI,
unsigned OpNum,
640 if (ExtraCode && ExtraCode[0]) {
641 if (ExtraCode[1] != 0)
644 switch (ExtraCode[0]) {
652 unsigned Reg = ExtraCode[0] ==
'w' ? AArch64::WZR : AArch64::XZR;
666 switch (ExtraCode[0]) {
668 RC = &AArch64::FPR8RegClass;
671 RC = &AArch64::FPR16RegClass;
674 RC = &AArch64::FPR32RegClass;
677 RC = &AArch64::FPR64RegClass;
680 RC = &AArch64::FPR128RegClass;
683 RC = &AArch64::ZPRRegClass;
688 return printAsmRegInClass(MO, RC, AArch64::NoRegAltName, O);
701 if (AArch64::GPR32allRegClass.
contains(Reg) ||
702 AArch64::GPR64allRegClass.
contains(Reg))
705 unsigned AltName = AArch64::NoRegAltName;
707 if (AArch64::ZPRRegClass.
contains(Reg)) {
708 RegClass = &AArch64::ZPRRegClass;
709 }
else if (AArch64::PPRRegClass.
contains(Reg)) {
710 RegClass = &AArch64::PPRRegClass;
712 RegClass = &AArch64::FPR128RegClass;
713 AltName = AArch64::vreg;
717 return printAsmRegInClass(MO, RegClass, AltName, O);
724 bool AArch64AsmPrinter::PrintAsmMemoryOperand(
const MachineInstr *MI,
726 const char *ExtraCode,
728 if (ExtraCode && ExtraCode[0] && ExtraCode[0] !=
'a')
732 assert(MO.
isReg() &&
"unexpected inline asm memory operand");
737 void AArch64AsmPrinter::PrintDebugValueComment(
const MachineInstr *MI,
741 OS <<
'\t' << MAI->getCommentString() <<
"DEBUG_VALUE: ";
757 void AArch64AsmPrinter::EmitJumpTableInfo() {
762 if (JT.empty())
return;
766 bool JTInDiffSection =
767 !STI->isTargetCOFF() ||
771 if (JTInDiffSection) {
774 OutStreamer->SwitchSection(ReadOnlySec);
778 for (
unsigned JTI = 0,
e = JT.size(); JTI !=
e; ++JTI) {
779 const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
782 if (JTBBs.empty())
continue;
784 unsigned Size = AFI->getJumpTableEntrySize(JTI);
785 EmitAlignment(
Align(Size));
786 OutStreamer->EmitLabel(GetJTISymbol(JTI));
788 for (
auto *JTBB : JTBBs)
789 emitJumpTableEntry(MJTI, JTBB, JTI);
798 unsigned Size = AFI->getJumpTableEntrySize(JTI);
802 const TargetLowering *TLI = MF->getSubtarget().getTargetLowering();
807 const MCSymbol *BaseSym = AFI->getJumpTableEntryPCRelSymbol(JTI);
814 OutStreamer->EmitValue(Value, Size);
826 void AArch64AsmPrinter::LowerJumpTableDestSmall(
llvm::MCStreamer &OutStreamer,
831 STI->getRegisterInfo()->getSubReg(ScratchReg, AArch64::sub_32);
835 bool IsByteEntry = MI.
getOpcode() == AArch64::JumpTableDest8;
844 Label, MF->getContext())));
847 unsigned LdrOpcode = IsByteEntry ? AArch64::LDRBBroX : AArch64::LDRHHroX;
853 .addImm(IsByteEntry ? 0 : 1));
869 MCSymbol *MILabel = Ctx.createTempSymbol();
873 assert(NumNOPBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
879 while (NumNOPBytes > 0) {
880 if (MII == MBB.
end() || MII->isCall() ||
881 MII->getOpcode() == AArch64::DBG_VALUE ||
882 MII->getOpcode() == TargetOpcode::PATCHPOINT ||
883 MII->getOpcode() == TargetOpcode::STACKMAP)
890 for (
unsigned i = 0; i < NumNOPBytes; i += 4)
899 MCSymbol *MILabel = Ctx.createTempSymbol();
906 unsigned EncodedBytes = 0;
908 assert((CallTarget & 0xFFFFFFFFFFFF) == CallTarget &&
909 "High 16 bits of call target should be zero.");
915 .addImm((CallTarget >> 32) & 0xFFFF)
920 .addImm((CallTarget >> 16) & 0xFFFF)
925 .addImm(CallTarget & 0xFFFF)
927 EmitToStreamer(OutStreamer,
MCInstBuilder(AArch64::BLR).addReg(ScratchReg));
931 assert(NumBytes >= EncodedBytes &&
932 "Patchpoint can't request size less than the length of a call.");
933 assert((NumBytes - EncodedBytes) % 4 == 0 &&
934 "Invalid number of NOP bytes requested!");
935 for (
unsigned i = EncodedBytes; i < NumBytes; i += 4)
936 EmitToStreamer(OutStreamer,
MCInstBuilder(AArch64::HINT).addImm(0));
939 void AArch64AsmPrinter::EmitFMov0(
const MachineInstr &MI) {
941 if (STI->hasZeroCycleZeroingFP() && !STI->hasZeroCycleZeroingFPWorkaround()) {
943 if (AArch64::H0 <= DestReg && DestReg <= AArch64::H31)
944 DestReg = AArch64::Q0 + (DestReg - AArch64::H0);
945 else if (AArch64::S0 <= DestReg && DestReg <= AArch64::S31)
946 DestReg = AArch64::Q0 + (DestReg - AArch64::S0);
948 assert(AArch64::D0 <= DestReg && DestReg <= AArch64::D31);
949 DestReg = AArch64::Q0 + (DestReg - AArch64::D0);
952 MOVI.setOpcode(AArch64::MOVIv2d_ns);
955 EmitToStreamer(*OutStreamer, MOVI);
960 case AArch64::FMOVH0:
965 case AArch64::FMOVS0:
970 case AArch64::FMOVD0:
976 EmitToStreamer(*OutStreamer, FMov);
982 #include "AArch64GenMCPseudoLowering.inc" 984 void AArch64AsmPrinter::EmitInstruction(
const MachineInstr *MI) {
986 if (emitPseudoExpansionLowering(*OutStreamer, MI))
989 if (AArch64FI->getLOHRelated().count(MI)) {
991 MCSymbol *LOHLabel = createTempSymbol(
"loh");
993 LOHInstToLabel[
MI] = LOHLabel;
1003 case AArch64::HINT: {
1008 if (CurrentPatchableFunctionEntrySym &&
1009 CurrentPatchableFunctionEntrySym == CurrentFnBegin &&
1010 MI == &MF->front().front()) {
1012 if ((Imm & 32) && (Imm & 6)) {
1014 MCInstLowering.Lower(MI, Inst);
1015 EmitToStreamer(*OutStreamer, Inst);
1016 CurrentPatchableFunctionEntrySym = createTempSymbol(
"patch");
1017 OutStreamer->
EmitLabel(CurrentPatchableFunctionEntrySym);
1023 case AArch64::MOVMCSym: {
1032 MCInstLowering.lowerOperand(Hi_MOSym, Hi_MCSym);
1033 MCInstLowering.lowerOperand(Lo_MOSym, Lo_MCSym);
1040 EmitToStreamer(*OutStreamer, MovZ);
1048 EmitToStreamer(*OutStreamer, MovK);
1051 case AArch64::MOVIv2d_ns:
1054 if (STI->hasZeroCycleZeroingFPWorkaround() &&
1057 TmpInst.
setOpcode(AArch64::MOVIv16b_ns);
1060 EmitToStreamer(*OutStreamer, TmpInst);
1065 case AArch64::DBG_VALUE: {
1069 PrintDebugValueComment(MI, OS);
1074 case AArch64::EMITBKEY: {
1080 if (needsCFIMoves() == CFI_M_None)
1091 case AArch64::TCRETURNri:
1092 case AArch64::TCRETURNriBTI:
1093 case AArch64::TCRETURNriALL: {
1097 EmitToStreamer(*OutStreamer, TmpInst);
1100 case AArch64::TCRETURNdi: {
1102 MCInstLowering.lowerOperand(MI->
getOperand(0), Dest);
1106 EmitToStreamer(*OutStreamer, TmpInst);
1119 MCOperand Sym, SymTLSDescLo12, SymTLSDesc;
1122 MCInstLowering.lowerOperand(MO_Sym, Sym);
1123 MCInstLowering.lowerOperand(MO_TLSDESC_LO12, SymTLSDescLo12);
1124 MCInstLowering.lowerOperand(MO_TLSDESC, SymTLSDesc);
1130 EmitToStreamer(*OutStreamer, Adrp);
1138 EmitToStreamer(*OutStreamer, Ldr);
1146 EmitToStreamer(*OutStreamer, Add);
1151 TLSDescCall.
setOpcode(AArch64::TLSDESCCALL);
1153 EmitToStreamer(*OutStreamer, TLSDescCall);
1158 EmitToStreamer(*OutStreamer, Blr);
1163 case AArch64::JumpTableDest32: {
1171 EmitToStreamer(*OutStreamer,
MCInstBuilder(AArch64::LDRSWroX)
1184 case AArch64::JumpTableDest16:
1185 case AArch64::JumpTableDest8:
1186 LowerJumpTableDestSmall(*OutStreamer, *MI);
1189 case AArch64::FMOVH0:
1190 case AArch64::FMOVS0:
1191 case AArch64::FMOVD0:
1195 case TargetOpcode::STACKMAP:
1196 return LowerSTACKMAP(*OutStreamer, SM, *MI);
1198 case TargetOpcode::PATCHPOINT:
1199 return LowerPATCHPOINT(*OutStreamer, SM, *MI);
1201 case TargetOpcode::PATCHABLE_FUNCTION_ENTER:
1202 LowerPATCHABLE_FUNCTION_ENTER(*MI);
1205 case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
1206 LowerPATCHABLE_FUNCTION_EXIT(*MI);
1209 case TargetOpcode::PATCHABLE_TAIL_CALL:
1210 LowerPATCHABLE_TAIL_CALL(*MI);
1213 case AArch64::HWASAN_CHECK_MEMACCESS:
1214 case AArch64::HWASAN_CHECK_MEMACCESS_SHORTGRANULES:
1215 LowerHWASAN_CHECK_MEMACCESS(*MI);
1218 case AArch64::SEH_StackAlloc:
1222 case AArch64::SEH_SaveFPLR:
1226 case AArch64::SEH_SaveFPLR_X:
1228 "Pre increment SEH opcode must have a negative offset");
1232 case AArch64::SEH_SaveReg:
1237 case AArch64::SEH_SaveReg_X:
1239 "Pre increment SEH opcode must have a negative offset");
1244 case AArch64::SEH_SaveRegP:
1246 "Non-consecutive registers not allowed for save_regp");
1251 case AArch64::SEH_SaveRegP_X:
1253 "Non-consecutive registers not allowed for save_regp_x");
1255 "Pre increment SEH opcode must have a negative offset");
1260 case AArch64::SEH_SaveFReg:
1265 case AArch64::SEH_SaveFReg_X:
1267 "Pre increment SEH opcode must have a negative offset");
1272 case AArch64::SEH_SaveFRegP:
1274 "Non-consecutive registers not allowed for save_regp");
1279 case AArch64::SEH_SaveFRegP_X:
1281 "Non-consecutive registers not allowed for save_regp_x");
1283 "Pre increment SEH opcode must have a negative offset");
1288 case AArch64::SEH_SetFP:
1292 case AArch64::SEH_AddFP:
1296 case AArch64::SEH_Nop:
1300 case AArch64::SEH_PrologEnd:
1304 case AArch64::SEH_EpilogStart:
1308 case AArch64::SEH_EpilogEnd:
1315 MCInstLowering.Lower(MI, TmpInst);
1316 EmitToStreamer(*OutStreamer, TmpInst);
virtual void EmitARM64WinCFIEpilogStart()
Instances of this class represent a uniqued identifier for a section in the current translation unit...
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAArch64AsmPrinter()
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
Target & getTheAArch64beTarget()
static bool printAsmMRegister(X86AsmPrinter &P, const MachineOperand &MO, char Mode, raw_ostream &O)
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
const std::vector< MachineJumpTableEntry > & getJumpTables() const
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
unsigned getNextScratchIdx(unsigned StartIdx=0) const
Get the next scratch register operand index.
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
static const char * getRegisterName(unsigned RegNo, unsigned AltIdx=AArch64::NoRegAltName)
void EmitRawText(const Twine &String)
If this file is backed by a assembly streamer, this dumps the specified string in the output ...
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
MO_PAGE - A symbol operand with this flag represents the pc-relative offset of the 4K page containing...
Target & getTheARM64_32Target()
void setTargetFlags(unsigned F)
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. ...
static const AArch64MCExpr * create(const MCExpr *Expr, VariantKind Kind, MCContext &Ctx)
virtual void EndCOFFSymbolDef()
Marks the end of the symbol definition.
virtual void EmitARM64WinCFIEpilogEnd()
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Target & getTheAArch64leTarget()
unsigned getRegister(unsigned i) const
Return the specified register in the class.
void push_back(const T &Elt)
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
unsigned getSubReg() const
virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol)
Start emitting COFF symbol definition.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
A raw_ostream that writes to an SmallVector or SmallString.
static unsigned getXRegFromWReg(unsigned Reg)
MO_G0 - A symbol operand with this flag (granule 0) represents the bits 0-15 of a 64-bit address...
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
virtual void EmitCOFFSymbolStorageClass(int StorageClass)
Emit the storage class of the symbol.
return AArch64::GPR64RegClass contains(Reg)
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
MCContext & getContext() const
static MCOperand createReg(unsigned Reg)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
bool isStringAttribute() const
Return true if the attribute is a string (target-dependent) attribute.
unsigned getNumOperands() const
Retuns the total number of operands.
virtual void EmitARM64WinCFISaveRegP(unsigned Reg, int Offset)
virtual void EmitCOFFSymbolType(int Type)
Emit the type of the symbol.
Base class for the full range of assembler expressions which are needed for parsing.
virtual void EmitARM64WinCFIPrologEnd()
virtual void EmitARM64WinCFISetFP()
static StringRef getName(Value *V)
Represent a reference to a symbol from inside an expression.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
Target & getTheARM64Target()
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
void getAnalysisUsage(AnalysisUsage &AU) const override
Record analysis usage.
virtual void EmitARM64WinCFIAddFP(unsigned Size)
virtual void EmitARM64WinCFIAllocStack(unsigned Size)
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
EK_LabelDifference32 - Each entry is the address of the block minus the address of the jump table...
RegisterAsmPrinter - Helper template for registering a target specific assembly printer, for use in the target machine initialization function.
Type is formed as (base + (derived << SCT_COMPLEX_TYPE_SHIFT))
virtual void EmitARM64WinCFISaveFRegP(unsigned Reg, int Offset)
const std::string & str() const
Instances of this class represent a single low-level machine instruction.
virtual void EmitARM64WinCFISaveFRegX(unsigned Reg, int Offset)
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false)
static unsigned getShifterImm(AArch64_AM::ShiftExtendType ST, unsigned Imm)
getShifterImm - Encode the shift type and amount: imm: 6-bit shift amount shifter: 000 ==> lsl 001 ==...
static unsigned getWRegFromXReg(unsigned Reg)
virtual bool hasRawTextSupport() const
Return true if this asm streamer supports emitting unformatted text to the .s file with EmitRawText...
static unsigned getShiftValue(unsigned Imm)
getShiftValue - Extract the shift value.
Address of a global value.
Streaming machine code generation interface.
Control flow instructions. These all have token chains.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
MO_G1 - A symbol operand with this flag (granule 1) represents the bits 16-31 of a 64-bit address...
MCTargetStreamer * getTargetStreamer()
The instances of the Type class are immutable: once they are created, they are never changed...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
virtual bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const
Target & getTheAArch64_32Target()
This class is intended to be used as a driving class for all asm writers.
Represent the analysis usage information of a pass.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
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...
virtual void EmitARM64WinCFISaveFPLRX(int Offset)
.subsections_via_symbols (MachO)
MCInstBuilder & addImm(int64_t Val)
Add a new integer immediate operand.
MI-level patchpoint operands.
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual MCSymbol * GetCPISymbol(unsigned CPID) const
Return the symbol for the specified constant pool entry.
MO_TLS - Indicates that the operand being accessed is some kind of thread-local symbol.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static const MCBinaryExpr * createLShr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Triple - Helper class for working with autoconf configuration names.
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
virtual void EmitARM64WinCFISaveReg(unsigned Reg, int Offset)
static uint64_t encodeLogicalImmediate(uint64_t imm, unsigned regSize)
encodeLogicalImmediate - Return the encoded immediate value for a logical immediate instruction of th...
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given stackmap should emit.
void recordPatchPoint(const MCSymbol &L, const MachineInstr &MI)
Generate a stackmap record for a patchpoint instruction.
void setOpcode(unsigned Op)
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
virtual void EmitARM64WinCFISaveRegPX(unsigned Reg, int Offset)
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...
StringRef str()
Return a StringRef for the vector contents.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
#define LLVM_EXTERNAL_VISIBILITY
std::string utostr(uint64_t X, bool isNeg=false)
bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp) const
const Function & getFunction() const
Return the LLVM function that this machine code represents.
SymbolStorageClass
Storage class tells where and what the symbol represents.
Target - Wrapper for Target specific information.
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
void setPreservesAll()
Set by analyses that do not transform their input at all.
MO_S - Indicates that the bits of the symbol operand represented by MO_G0 etc are signed...
const MachineBasicBlock * getParent() const
Representation of each machine instruction.
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
virtual void EmitARM64WinCFISaveFPLR(int Offset)
AArch64MCInstLower - This class is used to lower an MachineInstr into an MCInst.
virtual void EmitARM64WinCFINop()
MI-level stackmap operands.
StringRef getValueAsString() const
Return the attribute's value as a string.
virtual void EmitARM64WinCFISaveFRegPX(unsigned Reg, int Offset)
.type _foo, STT_FUNC # aka
const BlockAddress * getBlockAddress() const
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
MO_PAGEOFF - A symbol operand with this flag represents the offset of that symbol within a 4K page...
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given patchpoint should emit.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
StringRef getName() const
getName - Get the symbol name.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
JTEntryKind getEntryKind() const
virtual void EmitCFIBKeyFrame()
virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
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.
virtual MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const
void recordStackMap(const MCSymbol &L, const MachineInstr &MI)
Generate a stackmap record for a stackmap instruction.
const MachineOperand & getCallTarget() const
Returns the target of the underlying call.
void addOperand(const MCOperand &Op)
StringRef - Represent a constant reference to a string, i.e.
MO_NC - Indicates whether the linker is expected to check the symbol reference for overflow...
DWARF-like instruction based exceptions.
virtual void EmitARM64WinCFISaveFReg(unsigned Reg, int Offset)
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
Instances of this class represent operands of the MCInst class.
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
static MCOperand createImm(int64_t Val)
virtual void EmitARM64WinCFISaveRegX(unsigned Reg, int Offset)
virtual const MCExpr * getPICJumpTableRelocBaseExpr(const MachineFunction *MF, unsigned JTI, MCContext &Ctx) const
This returns the relocation base for the given PIC jumptable, the same as getPICJumpTableRelocBase, but as an MCExpr.
const MDNode * getMetadata() const
Wrapper class representing virtual and physical registers.
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
A function that returns a base type.