51#define DEBUG_TYPE "asm-printer"
54 std::unique_ptr<MCStreamer> Streamer)
56 MCP(nullptr), InConstantPool(
false), OptimizationGoals(-1) {}
63 InConstantPool =
false;
88 assert(
Size &&
"C++ constructor pointer had zero size!");
91 assert(GV &&
"C++ constructor pointer was not a GlobalValue!");
104 if (PromotedGlobals.count(GV))
126 PromotedGlobals.insert(GV);
129 unsigned OptimizationGoal;
132 OptimizationGoal = 6;
133 else if (
F.hasMinSize())
135 OptimizationGoal = 4;
136 else if (
F.hasOptSize())
138 OptimizationGoal = 3;
141 OptimizationGoal = 2;
144 OptimizationGoal = 1;
147 OptimizationGoal = 5;
150 if (OptimizationGoals == -1)
151 OptimizationGoals = OptimizationGoal;
152 else if (OptimizationGoals != (
int)OptimizationGoal)
153 OptimizationGoals = 0;
156 bool Local =
F.hasLocalLinkage();
176 if (! ThumbIndirectPads.empty()) {
179 for (std::pair<unsigned, MCSymbol *> &TIP : ThumbIndirectPads) {
187 ThumbIndirectPads.clear();
225 if(ARM::GPRPairRegClass.
contains(Reg)) {
228 Reg =
TRI->getSubReg(Reg, ARM::gsub_0);
259 if (Subtarget->genExecuteOnly())
278GetARMJTIPICJumpTableLabel(
unsigned uid)
const {
289 if (ExtraCode && ExtraCode[0]) {
290 if (ExtraCode[1] != 0)
return true;
292 switch (ExtraCode[0]) {
301 if (
MI->getOperand(OpNum).isReg()) {
302 MCRegister Reg =
MI->getOperand(OpNum).getReg().asMCReg();
309 bool Lane0 =
TRI->getSubReg(SR, ARM::ssub_0) == Reg;
316 if (!
MI->getOperand(OpNum).isImm())
318 O << ~(
MI->getOperand(OpNum).getImm());
321 if (!
MI->getOperand(OpNum).isImm())
323 O << (
MI->getOperand(OpNum).getImm() & 0xffff);
326 if (!
MI->getOperand(OpNum).isReg())
334 if (ARM::GPRPairRegClass.
contains(RegBegin)) {
336 Register Reg0 =
TRI->getSubReg(RegBegin, ARM::gsub_0);
338 RegBegin =
TRI->getSubReg(RegBegin, ARM::gsub_1);
346 unsigned RegOps = OpNum + 1;
347 while (
MI->getOperand(RegOps).isReg()) {
362 if (!FlagsOP.
isImm())
370 if (
F.isUseOperandTiedToDef(TiedIdx)) {
372 unsigned OpFlags =
MI->getOperand(OpNum).getImm();
374 OpNum +=
F.getNumOperandRegisters() + 1;
383 const unsigned NumVals =
F.getNumOperandRegisters();
392 if (ExtraCode[0] ==
'Q')
398 if (
F.hasRegClassConstraint(RC) &&
399 ARM::GPRPairRegClass.hasSubClassEq(
TRI->getRegClass(RC))) {
407 TRI->getSubReg(MO.
getReg(), FirstHalf ? ARM::gsub_0 : ARM::gsub_1);
413 unsigned RegOp = FirstHalf ? OpNum : OpNum + 1;
414 if (RegOp >=
MI->getNumOperands())
426 if (!
MI->getOperand(OpNum).isReg())
428 Register Reg =
MI->getOperand(OpNum).getReg();
429 if (!ARM::QPRRegClass.
contains(Reg))
433 TRI->getSubReg(Reg, ExtraCode[0] ==
'e' ? ARM::dsub_0 : ARM::dsub_1);
448 if(!ARM::GPRPairRegClass.
contains(Reg))
450 Reg =
TRI->getSubReg(Reg, ARM::gsub_1);
462 unsigned OpNum,
const char *ExtraCode,
465 if (ExtraCode && ExtraCode[0]) {
466 if (ExtraCode[1] != 0)
return true;
468 switch (ExtraCode[0]) {
470 default:
return true;
472 if (!
MI->getOperand(OpNum).isReg())
480 assert(MO.
isReg() &&
"unexpected inline asm memory operand");
493 const bool WasThumb =
isThumb(StartInfo);
494 if (!EndInfo || WasThumb !=
isThumb(*EndInfo)) {
505 if (TT.isOSBinFormatELF())
511 if (!M.getModuleInlineAsm().empty() && TT.isThumb())
541 if (TT.isOSBinFormatMachO()) {
551 if (!Stubs.empty()) {
556 for (
auto &Stub : Stubs)
564 if (!Stubs.empty()) {
569 for (
auto &Stub : Stubs)
588 if (OptimizationGoals > 0 &&
592 OptimizationGoals = -1;
609 return F.getFnAttribute(Attr).getValueAsString() !=
Value;
618 StringRef AttrVal =
F.getFnAttribute(Attr).getValueAsString();
623void ARMAsmPrinter::emitAttributes() {
642 ArchFS = (
Twine(ArchFS) +
"," +
FS).str();
644 ArchFS = std::string(FS);
648 const ARMSubtarget STI(TT, std::string(CPU), ArchFS, ATM,
658 }
else if (STI.isRWPI()) {
693 if (!STI.hasVFP2Base()) {
703 }
else if (STI.hasVFP3Base()) {
720 "no-trapping-math",
"true") ||
761 if (
auto WCharWidthValue = mdconst::extract_or_null<ConstantInt>(
762 SourceModule->getModuleFlag(
"wchar_size"))) {
763 int WCharWidth = WCharWidthValue->getZExtValue();
764 assert((WCharWidth == 2 || WCharWidth == 4) &&
765 "wchar_t width must be 2 or 4 bytes");
772 if (
auto EnumWidthValue = mdconst::extract_or_null<ConstantInt>(
773 SourceModule->getModuleFlag(
"min_enum_size"))) {
774 int EnumWidth = EnumWidthValue->getZExtValue();
775 assert((EnumWidth == 1 || EnumWidth == 4) &&
776 "Minimum enum width must be 1 or 4 bytes");
777 int EnumBuildAttr = EnumWidth == 1 ? 1 : 2;
781 auto *PACValue = mdconst::extract_or_null<ConstantInt>(
782 SourceModule->getModuleFlag(
"sign-return-address"));
783 if (PACValue && PACValue->isOne()) {
787 if (!STI.hasPACBTI()) {
794 auto *BTIValue = mdconst::extract_or_null<ConstantInt>(
795 SourceModule->getModuleFlag(
"branch-target-enforcement"));
796 if (BTIValue && BTIValue->isOne()) {
800 if (!STI.hasPACBTI()) {
812 else if (STI.isR9Reserved())
826 +
"BF" +
Twine(FunctionNumber) +
"_" +
Twine(LabelId));
834 +
"PC" +
Twine(FunctionNumber) +
"_" +
Twine(LabelId));
860 unsigned char TargetFlags) {
876 if (!StubSym.getPointer())
882 "Windows is the only supported COFF target");
904 if (!StubSym.getPointer())
932 auto *ACPC = cast<ARMConstantPoolConstant>(ACPV);
933 for (
const auto *GV : ACPC->promotedGlobals()) {
934 if (!EmittedPromotedGlobalLabels.count(GV)) {
937 EmittedPromotedGlobalLabels.insert(GV);
948 cast<ARMConstantPoolConstant>(ACPV)->getBlockAddress();
951 const GlobalValue *GV = cast<ARMConstantPoolConstant>(ACPV)->getGV();
956 MCSym = GetARMGVSymbol(GV, TF);
962 auto Sym = cast<ARMConstantPoolSymbol>(ACPV)->getSymbol();
1003 MCSymbol *JTISymbol = GetARMJTIPICJumpTableLabel(JTI);
1011 const std::vector<MachineJumpTableEntry> &JT = MJTI->
getJumpTables();
1012 const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
1049 MCSymbol *JTISymbol = GetARMJTIPICJumpTableLabel(JTI);
1054 const std::vector<MachineJumpTableEntry> &JT = MJTI->
getJumpTables();
1055 const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
1062 .addExpr(MBBSymbolExpr)
1069 unsigned OffsetWidth) {
1070 assert((OffsetWidth == 1 || OffsetWidth == 2) &&
"invalid tbb/tbh width");
1077 MCSymbol *JTISymbol = GetARMJTIPICJumpTableLabel(JTI);
1082 const std::vector<MachineJumpTableEntry> &JT = MJTI->
getJumpTables();
1083 const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
1089 for (
auto *
MBB : JTBBs) {
1125 const MCSymbol *BranchLabel)
const {
1135 BaseLabel = GetARMJTIPICJumpTableLabel(JTI);
1142 BaseLabel = BranchLabel;
1150 BaseLabel = BranchLabel;
1155 BaseLabel =
nullptr;
1162 return std::make_tuple(BaseLabel, BaseOffset, BranchLabel, EntrySize);
1165void ARMAsmPrinter::EmitUnwindingInstruction(
const MachineInstr *
MI) {
1167 "Only instruction which are involved into frame setup code are allowed");
1177 unsigned Opc =
MI->getOpcode();
1178 unsigned SrcReg, DstReg;
1183 SrcReg = DstReg = ARM::SP;
1187 case ARM::t2MOVTi16:
1208 DstReg =
MI->getOperand(0).getReg();
1211 SrcReg =
MI->getOperand(1).getReg();
1212 DstReg =
MI->getOperand(0).getReg();
1217 if (
MI->mayStore()) {
1219 assert(DstReg == ARM::SP &&
1220 "Only stack pointer as a destination reg is supported");
1224 unsigned StartOp = 2 + 2;
1226 unsigned NumOffset = 0;
1229 unsigned PadBefore = 0;
1232 unsigned PadAfter = 0;
1240 StartOp = 2; NumOffset = 2;
1242 case ARM::STMDB_UPD:
1243 case ARM::t2STMDB_UPD:
1244 case ARM::VSTMDDB_UPD:
1245 assert(SrcReg == ARM::SP &&
1246 "Only stack pointer as a source reg is supported");
1247 for (
unsigned i = StartOp, NumOps =
MI->getNumOperands() - NumOffset;
1260 "Pad registers must come before restored ones");
1274 case ARM::STR_PRE_IMM:
1275 case ARM::STR_PRE_REG:
1276 case ARM::t2STR_PRE:
1277 assert(
MI->getOperand(2).getReg() == ARM::SP &&
1278 "Only stack pointer as a source reg is supported");
1280 SrcReg = RemappedReg;
1284 case ARM::t2STRD_PRE:
1285 assert(
MI->getOperand(3).getReg() == ARM::SP &&
1286 "Only stack pointer as a source reg is supported");
1287 SrcReg =
MI->getOperand(1).getReg();
1289 SrcReg = RemappedReg;
1291 SrcReg =
MI->getOperand(2).getReg();
1293 SrcReg = RemappedReg;
1295 PadBefore = -
MI->getOperand(4).getImm() - 8;
1301 ATS.
emitRegSave(RegList, Opc == ARM::VSTMDDB_UPD);
1308 if (SrcReg == ARM::SP) {
1320 case ARM::t2ADDri12:
1321 case ARM::t2ADDspImm:
1322 case ARM::t2ADDspImm12:
1323 Offset = -
MI->getOperand(2).getImm();
1327 case ARM::t2SUBri12:
1328 case ARM::t2SUBspImm:
1329 case ARM::t2SUBspImm12:
1330 Offset =
MI->getOperand(2).getImm();
1333 Offset =
MI->getOperand(2).getImm()*4;
1337 Offset = -
MI->getOperand(2).getImm()*4;
1350 else if (DstReg == ARM::SP) {
1360 }
else if (DstReg == ARM::SP) {
1372 case ARM::tLDRpci: {
1375 unsigned CPI =
MI->getOperand(1).getIndex();
1379 assert(CPI != -1U &&
"Invalid constpool index");
1389 Offset =
MI->getOperand(1).getImm();
1392 case ARM::t2MOVTi16:
1393 Offset =
MI->getOperand(2).getImm();
1397 Offset =
MI->getOperand(2).getImm();
1401 assert(
MI->getOperand(3).getImm() == 8 &&
1402 "The shift amount is not equal to 8");
1403 assert(
MI->getOperand(2).getReg() ==
MI->getOperand(0).getReg() &&
1404 "The source register is not equal to the destination register");
1408 assert(
MI->getOperand(2).getReg() ==
MI->getOperand(0).getReg() &&
1409 "The source register is not equal to the destination register");
1410 Offset =
MI->getOperand(3).getImm();
1427#include "ARMGenMCPseudoLowering.inc"
1439 if (InConstantPool &&
MI->getOpcode() != ARM::CONSTPOOL_ENTRY) {
1441 InConstantPool =
false;
1447 EmitUnwindingInstruction(
MI);
1450 if (
MCInst OutInst; lowerPseudoInstExpansion(
MI, OutInst)) {
1456 "Pseudo flag setting opcode should be expanded early");
1459 unsigned Opc =
MI->getOpcode();
1461 case ARM::t2MOVi32imm:
llvm_unreachable(
"Should be lowered by thumb2it pass");
1462 case ARM::DBG_VALUE:
llvm_unreachable(
"Should be handled by generic printing");
1464 case ARM::tLEApcrel:
1465 case ARM::t2LEApcrel: {
1469 ARM::t2LEApcrel ? ARM::t2ADR
1470 : (
MI->getOpcode() == ARM::tLEApcrel ? ARM::tADR
1472 .
addReg(
MI->getOperand(0).getReg())
1475 .
addImm(
MI->getOperand(2).getImm())
1476 .
addReg(
MI->getOperand(3).getReg()));
1479 case ARM::LEApcrelJT:
1480 case ARM::tLEApcrelJT:
1481 case ARM::t2LEApcrelJT: {
1483 GetARMJTIPICJumpTableLabel(
MI->getOperand(1).getIndex());
1485 ARM::t2LEApcrelJT ? ARM::t2ADR
1486 : (
MI->getOpcode() == ARM::tLEApcrelJT ? ARM::tADR
1488 .
addReg(
MI->getOperand(0).getReg())
1491 .
addImm(
MI->getOperand(2).getImm())
1492 .
addReg(
MI->getOperand(3).getReg()));
1497 case ARM::BX_CALL: {
1507 assert(Subtarget->hasV4TOps());
1509 .addReg(
MI->getOperand(0).getReg()));
1512 case ARM::tBX_CALL: {
1513 if (Subtarget->hasV5TOps())
1524 for (std::pair<unsigned, MCSymbol *> &TIP : ThumbIndirectPads) {
1525 if (TIP.first == TReg) {
1526 TRegSym = TIP.second;
1533 ThumbIndirectPads.push_back(std::make_pair(TReg, TRegSym));
1543 case ARM::BMOVPCRX_CALL: {
1555 .addReg(
MI->getOperand(0).getReg())
1563 case ARM::BMOVPCB_CALL: {
1575 const unsigned TF =
Op.getTargetFlags();
1576 MCSymbol *GVSym = GetARMGVSymbol(GV, TF);
1585 case ARM::MOVi16_ga_pcrel:
1586 case ARM::t2MOVi16_ga_pcrel: {
1588 TmpInst.
setOpcode(Opc == ARM::MOVi16_ga_pcrel? ARM::MOVi16 : ARM::t2MOVi16);
1591 unsigned TF =
MI->getOperand(1).getTargetFlags();
1593 MCSymbol *GVSym = GetARMGVSymbol(GV, TF);
1600 unsigned PCAdj = (Opc == ARM::MOVi16_ga_pcrel) ? 8 : 4;
1601 const MCExpr *PCRelExpr =
1616 case ARM::MOVTi16_ga_pcrel:
1617 case ARM::t2MOVTi16_ga_pcrel: {
1619 TmpInst.
setOpcode(Opc == ARM::MOVTi16_ga_pcrel
1620 ? ARM::MOVTi16 : ARM::t2MOVTi16);
1624 unsigned TF =
MI->getOperand(2).getTargetFlags();
1626 MCSymbol *GVSym = GetARMGVSymbol(GV, TF);
1633 unsigned PCAdj = (Opc == ARM::MOVTi16_ga_pcrel) ? 8 : 4;
1634 const MCExpr *PCRelExpr =
1661 if (
MI->getOperand(1).isReg()) {
1663 MCInst.addReg(
MI->getOperand(1).getReg());
1666 const MCExpr *BranchTarget;
1667 if (
MI->getOperand(1).isMBB())
1670 else if (
MI->getOperand(1).isGlobal()) {
1673 GetARMGVSymbol(GV,
MI->getOperand(1).getTargetFlags()),
OutContext);
1674 }
else if (
MI->getOperand(1).isSymbol()) {
1681 MCInst.addExpr(BranchTarget);
1684 if (Opc == ARM::t2BFic) {
1689 MCInst.addExpr(ElseLabel);
1690 MCInst.addImm(
MI->getOperand(3).getImm());
1692 MCInst.addImm(
MI->getOperand(2).getImm())
1693 .addReg(
MI->getOperand(3).getReg());
1699 case ARM::t2BF_LabelPseudo: {
1708 case ARM::tPICADD: {
1721 .addReg(
MI->getOperand(0).getReg())
1722 .
addReg(
MI->getOperand(0).getReg())
1742 .addReg(
MI->getOperand(0).getReg())
1744 .
addReg(
MI->getOperand(1).getReg())
1746 .
addImm(
MI->getOperand(3).getImm())
1747 .
addReg(
MI->getOperand(4).getReg())
1759 case ARM::PICLDRSH: {
1773 switch (
MI->getOpcode()) {
1776 case ARM::PICSTR: Opcode = ARM::STRrs;
break;
1777 case ARM::PICSTRB: Opcode = ARM::STRBrs;
break;
1778 case ARM::PICSTRH: Opcode = ARM::STRH;
break;
1779 case ARM::PICLDR: Opcode = ARM::LDRrs;
break;
1780 case ARM::PICLDRB: Opcode = ARM::LDRBrs;
break;
1781 case ARM::PICLDRH: Opcode = ARM::LDRH;
break;
1782 case ARM::PICLDRSB: Opcode = ARM::LDRSB;
break;
1783 case ARM::PICLDRSH: Opcode = ARM::LDRSH;
break;
1786 .addReg(
MI->getOperand(0).getReg())
1788 .
addReg(
MI->getOperand(1).getReg())
1791 .
addImm(
MI->getOperand(3).getImm())
1792 .
addReg(
MI->getOperand(4).getReg()));
1796 case ARM::CONSTPOOL_ENTRY: {
1797 if (Subtarget->genExecuteOnly())
1805 unsigned LabelId = (
unsigned)
MI->getOperand(0).getImm();
1806 unsigned CPIdx = (
unsigned)
MI->getOperand(1).getIndex();
1809 if (!InConstantPool) {
1811 InConstantPool =
true;
1823 case ARM::JUMPTABLE_ADDRS:
1826 case ARM::JUMPTABLE_INSTS:
1829 case ARM::JUMPTABLE_TBB:
1830 case ARM::JUMPTABLE_TBH:
1833 case ARM::t2BR_JT: {
1836 .addReg(
MI->getOperand(0).getReg())
1843 case ARM::t2TBH_JT: {
1844 unsigned Opc =
MI->getOpcode() == ARM::t2TBB_JT ? ARM::t2TBB : ARM::t2TBH;
1848 .addReg(
MI->getOperand(0).getReg())
1849 .
addReg(
MI->getOperand(1).getReg())
1856 case ARM::tTBH_JT: {
1858 bool Is8Bit =
MI->getOpcode() == ARM::tTBB_JT;
1861 assert(
MI->getOperand(1).isKill() &&
"We need the index register as scratch!");
1874 if (
Base == ARM::PC) {
1897 unsigned Opc = Is8Bit ? ARM::tLDRBi : ARM::tLDRHi;
1901 .addImm(Is8Bit ? 4 : 2)
1911 unsigned Opc = Is8Bit ? ARM::tLDRBr : ARM::tLDRHr;
1944 unsigned Opc =
MI->getOpcode() == ARM::BR_JTr ?
1945 ARM::MOVr : ARM::tMOVr;
1953 if (Opc == ARM::MOVr)
1958 case ARM::BR_JTm_i12: {
1971 case ARM::BR_JTm_rs: {
1985 case ARM::BR_JTadd: {
1989 .addReg(
MI->getOperand(0).getReg())
1990 .
addReg(
MI->getOperand(1).getReg())
2012 case ARM::TRAPNaCl: {
2029 case ARM::t2Int_eh_sjlj_setjmp:
2030 case ARM::t2Int_eh_sjlj_setjmp_nofp:
2031 case ARM::tInt_eh_sjlj_setjmp: {
2040 Register SrcReg =
MI->getOperand(0).getReg();
2041 Register ValReg =
MI->getOperand(1).getReg();
2081 .addExpr(SymbolExpr)
2098 case ARM::Int_eh_sjlj_setjmp_nofp:
2099 case ARM::Int_eh_sjlj_setjmp: {
2106 Register SrcReg =
MI->getOperand(0).getReg();
2107 Register ValReg =
MI->getOperand(1).getReg();
2158 case ARM::Int_eh_sjlj_longjmp: {
2163 Register SrcReg =
MI->getOperand(0).getReg();
2164 Register ScratchReg =
MI->getOperand(1).getReg();
2212 assert(Subtarget->hasV4TOps());
2220 case ARM::tInt_eh_sjlj_longjmp: {
2226 Register SrcReg =
MI->getOperand(0).getReg();
2227 Register ScratchReg =
MI->getOperand(1).getReg();
2292 case ARM::tInt_WIN_eh_sjlj_longjmp: {
2297 Register SrcReg =
MI->getOperand(0).getReg();
2322 case ARM::PATCHABLE_FUNCTION_ENTER:
2325 case ARM::PATCHABLE_FUNCTION_EXIT:
2328 case ARM::PATCHABLE_TAIL_CALL:
2331 case ARM::SpeculationBarrierISBDSBEndBB: {
2343 case ARM::t2SpeculationBarrierISBDSBEndBB: {
2359 case ARM::SpeculationBarrierSBEndBB: {
2366 case ARM::t2SpeculationBarrierSBEndBB: {
2374 case ARM::SEH_StackAlloc:
2376 MI->getOperand(1).getImm());
2379 case ARM::SEH_SaveRegs:
2380 case ARM::SEH_SaveRegs_Ret:
2382 MI->getOperand(1).getImm());
2385 case ARM::SEH_SaveSP:
2389 case ARM::SEH_SaveFRegs:
2391 MI->getOperand(1).getImm());
2394 case ARM::SEH_SaveLR:
2399 case ARM::SEH_Nop_Ret:
2403 case ARM::SEH_PrologEnd:
2407 case ARM::SEH_EpilogStart:
2411 case ARM::SEH_EpilogEnd:
2415 case ARM::PseudoARMInitUndefMQPR:
2416 case ARM::PseudoARMInitUndefSPR:
2417 case ARM::PseudoARMInitUndefDPR_VFP2:
2418 case ARM::PseudoARMInitUndefGPR:
static void emitNonLazySymbolPointer(MCStreamer &OutStreamer, MCSymbol *StubLabel, MachineModuleInfoImpl::StubValueTy &MCSym)
static MCSymbolRefExpr::VariantKind getModifierVariantKind(ARMCP::ARMCPModifier Modifier)
static MCSymbol * getPICLabel(StringRef Prefix, unsigned FunctionNumber, unsigned LabelId, MCContext &Ctx)
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARMAsmPrinter()
static bool checkFunctionsAttributeConsistency(const Module &M, StringRef Attr, StringRef Value)
static bool isThumb(const MCSubtargetInfo &STI)
static MCSymbol * getBFLabel(StringRef Prefix, unsigned FunctionNumber, unsigned LabelId, MCContext &Ctx)
static bool checkDenormalAttributeConsistency(const Module &M, StringRef Attr, DenormalMode Value)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define LLVM_EXTERNAL_VISIBILITY
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
unsigned const TargetRegisterInfo * TRI
Module.h This file contains the declarations for the Module class.
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
static const unsigned FramePtr
void emitJumpTableAddrs(const MachineInstr *MI)
void emitJumpTableTBInst(const MachineInstr *MI, unsigned OffsetWidth)
void emitFunctionBodyEnd() override
Targets can override this to emit stuff after the last basic block in the function.
bool runOnMachineFunction(MachineFunction &F) override
runOnMachineFunction - This uses the emitInstruction() method to print assembly for each instruction.
MCSymbol * GetCPISymbol(unsigned CPID) const override
Return the symbol for the specified constant pool entry.
void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O)
void emitStartOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the start of their fi...
ARMAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
void emitFunctionEntryLabel() override
EmitFunctionEntryLabel - Emit the label that is the entrypoint for the function.
void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo, const MCSubtargetInfo *EndInfo) const override
Let the target do anything it needs to do after emitting inlineasm.
void LowerPATCHABLE_FUNCTION_EXIT(const MachineInstr &MI)
void emitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) override
EmitMachineConstantPoolValue - Print a machine constantpool value to the .s file.
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum, const char *ExtraCode, raw_ostream &O) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant.
void emitXXStructor(const DataLayout &DL, const Constant *CV) override
Targets can override this to change how global constants that are part of a C++ static/global constru...
void LowerPATCHABLE_FUNCTION_ENTER(const MachineInstr &MI)
void LowerPATCHABLE_TAIL_CALL(const MachineInstr &MI)
void emitEndOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the end of their file...
std::tuple< const MCSymbol *, uint64_t, const MCSymbol *, codeview::JumpTableEntrySize > getCodeViewJumpTableInfo(int JTI, const MachineInstr *BranchInstr, const MCSymbol *BranchLabel) const override
Gets information required to create a CodeView debug symbol for a jump table.
void emitJumpTableInsts(const MachineInstr *MI)
void emitGlobalVariable(const GlobalVariable *GV) override
Emit the specified global variable to the .s file.
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum, const char *ExtraCode, raw_ostream &O) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
void emitInstruction(const MachineInstr *MI) override
Targets should implement this to emit instructions.
void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &O) override
Print the MachineOperand as a symbol.
bool isLittleEndian() const
ARMConstantPoolValue - ARM specific constantpool value.
bool isPromotedGlobal() const
unsigned char getPCAdjustment() const
bool isMachineBasicBlock() const
bool isGlobalValue() const
ARMCP::ARMCPModifier getModifier() const
bool mustAddCurrentAddress() const
unsigned getLabelId() const
bool isBlockAddress() const
ARMFunctionInfo - This class is derived from MachineFunctionInfo and contains private ARM-specific in...
SmallPtrSet< const GlobalVariable *, 2 > & getGlobalsPromotedToConstantPool()
DenseMap< unsigned, unsigned > EHPrologueRemappedRegs
bool isThumbFunction() const
bool isCmseNSEntryFunction() const
DenseMap< unsigned, unsigned > EHPrologueOffsetInRegs
unsigned getOriginalCPIdx(unsigned CloneIdx) const
static const char * getRegisterName(MCRegister Reg, unsigned AltIdx=ARM::NoRegAltName)
static const ARMMCExpr * createLower16(const MCExpr *Expr, MCContext &Ctx)
static const ARMMCExpr * createUpper16(const MCExpr *Expr, MCContext &Ctx)
bool isTargetMachO() const
bool isTargetAEABI() const
bool isThumb1Only() const
MCPhysReg getFramePointerReg() const
bool isTargetWindows() const
bool isTargetEHABICompatible() const
bool isGVIndirectSymbol(const GlobalValue *GV) const
True if the GV will be accessed via an indirect symbol.
bool isTargetDarwin() const
bool isTargetCOFF() const
bool isTargetGNUAEABI() const
bool isTargetMuslAEABI() const
void emitTargetAttributes(const MCSubtargetInfo &STI)
Emit the build attributes that only depend on the hardware that we expect.
virtual void finishAttributeSection()
virtual void emitARMWinCFISaveSP(unsigned Reg)
virtual void emitInst(uint32_t Inst, char Suffix='\0')
virtual void emitARMWinCFISaveLR(unsigned Offset)
virtual void emitRegSave(const SmallVectorImpl< unsigned > &RegList, bool isVector)
virtual void emitTextAttribute(unsigned Attribute, StringRef String)
virtual void emitARMWinCFIAllocStack(unsigned Size, bool Wide)
virtual void emitMovSP(unsigned Reg, int64_t Offset=0)
virtual void emitARMWinCFISaveRegMask(unsigned Mask, bool Wide)
virtual void emitARMWinCFIEpilogEnd()
virtual void emitARMWinCFIPrologEnd(bool Fragment)
virtual void switchVendor(StringRef Vendor)
virtual void emitARMWinCFISaveFRegs(unsigned First, unsigned Last)
virtual void emitARMWinCFIEpilogStart(unsigned Condition)
virtual void emitPad(int64_t Offset)
virtual void emitAttribute(unsigned Attribute, unsigned Value)
virtual void emitARMWinCFINop(bool Wide)
virtual void emitSetFP(unsigned FpReg, unsigned SpReg, int64_t Offset=0)
This class is intended to be used as a driving class for all asm writers.
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
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...
MCSymbol * getSymbol(const GlobalValue *GV) const
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
virtual void emitGlobalVariable(const GlobalVariable *GV)
Emit the specified global variable to the .s file.
TargetMachine & TM
Target machine description.
void emitXRayTable()
Emit a table with all XRay instrumentation points.
MCSymbol * getMBBExceptionSym(const MachineBasicBlock &MBB)
const MCAsmInfo * MAI
Target Asm Printer information.
MachineFunction * MF
The current machine function.
virtual void SetupMachineFunction(MachineFunction &MF)
This should be called when a new MachineFunction is being processed from runOnMachineFunction.
void emitFunctionBody()
This method emits the body and trailer for a function.
virtual void emitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const
This emits linkage information about GVSym based on GV, if this is supported by the target.
unsigned getFunctionNumber() const
Return a unique ID for the current function.
void printOffset(int64_t Offset, raw_ostream &OS) const
This is just convenient handler for printing offsets.
void emitGlobalConstant(const DataLayout &DL, const Constant *CV, AliasMapTy *AliasList=nullptr)
EmitGlobalConstant - Print a general LLVM constant to the .s file.
MCSymbol * getSymbolPreferLocal(const GlobalValue &GV) const
Similar to getSymbol() but preferred for references.
MCSymbol * CurrentFnSym
The symbol for the current function.
MachineModuleInfo * MMI
This is a pointer to the current MachineModuleInfo.
void emitAlignment(Align Alignment, const GlobalObject *GV=nullptr, unsigned MaxBytesToEmit=0) const
Emit an alignment directive to the specified power of two boundary.
MCContext & OutContext
This is the context for the output file that we are streaming.
MCSymbol * GetExternalSymbolSymbol(Twine Sym) const
Return the MCSymbol for the specified ExternalSymbol.
bool isPositionIndependent() const
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV) const
MCSymbol * GetBlockAddressSymbol(const BlockAddress *BA) const
Return the MCSymbol used to satisfy BlockAddress uses of the specified basic block.
const DataLayout & getDataLayout() const
Return information about data layout.
virtual void emitFunctionEntryLabel()
EmitFunctionEntryLabel - Emit the label that is the entrypoint for the function.
const MCSubtargetInfo & getSubtargetInfo() const
Return information about subtarget.
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.
The address of a basic block.
This is an important base class in LLVM.
const Constant * stripPointerCasts() const
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
bool hasInternalLinkage() const
ExceptionHandling getExceptionHandlingType() const
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCBinaryExpr * createDiv(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Base class for the full range of assembler expressions which are needed for parsing.
MCInstBuilder & addReg(unsigned Reg)
Add a new register operand.
MCInstBuilder & addImm(int64_t Val)
Add a new integer immediate operand.
MCInstBuilder & addExpr(const MCExpr *Val)
Add a new MCExpr operand.
Instances of this class represent a single low-level machine instruction.
void addOperand(const MCOperand Op)
void setOpcode(unsigned Op)
MCSection * getThreadLocalPointerSection() const
MCSection * getNonLazySymbolPointerSection() const
static MCOperand createReg(unsigned Reg)
static MCOperand createExpr(const MCExpr *Val)
static MCOperand createImm(int64_t Val)
Wrapper class representing physical registers. Should be passed by value.
Streaming machine code generation interface.
virtual bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute)=0
Add the given Attribute to Symbol.
MCContext & getContext() const
void emitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
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.
Generic base class for all target subtargets.
bool hasFeature(unsigned Feature) const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
StringRef getName() const
getName - Get the symbol name.
Target specific streamer interface.
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
This class is a data container for one entry in a MachineConstantPool.
bool isMachineConstantPoolEntry() const
isMachineConstantPoolEntry - Return true if the MachineConstantPoolEntry is indeed a target specific ...
union llvm::MachineConstantPoolEntry::@204 Val
The constant itself.
MachineConstantPoolValue * MachineCPVal
const Constant * ConstVal
Abstract base class for all machine specific constantpool value subclasses.
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
const std::vector< MachineConstantPoolEntry > & getConstants() const
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
const MachineBasicBlock & front() const
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineOperand & getOperand(unsigned i) const
const std::vector< MachineJumpTableEntry > & getJumpTables() const
MachineModuleInfoCOFF - This is a MachineModuleInfoImpl implementation for COFF targets.
StubValueTy & getGVStubEntry(MCSymbol *Sym)
std::vector< std::pair< MCSymbol *, StubValueTy > > SymbolListTy
MachineModuleInfoMachO - This is a MachineModuleInfoImpl implementation for MachO targets.
SymbolListTy GetThreadLocalGVStubList()
StubValueTy & getGVStubEntry(MCSymbol *Sym)
StubValueTy & getThreadLocalGVStubEntry(MCSymbol *Sym)
SymbolListTy GetGVStubList()
Accessor methods to return the set of stubs in sorted order.
const Module * getModule() const
Ty & getObjFileInfo()
Keep track of various per-module pieces of information for backends that would like to do so.
MachineOperand class - Representation of each machine instruction operand.
unsigned getSubReg() const
const GlobalValue * getGlobal() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
MachineBasicBlock * getMBB() const
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
unsigned getTargetFlags() const
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
Register getReg() const
getReg - Returns the register number.
@ MO_Immediate
Immediate operand.
@ MO_ConstantPoolIndex
Address of indexed Constant in Constant Pool.
@ MO_GlobalAddress
Address of a global value.
@ MO_MachineBasicBlock
MachineBasicBlock reference.
@ MO_Register
Register operand.
int64_t getOffset() const
Return the offset from the symbol in this operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
A Module instance is used to store all the information related to an LLVM module.
virtual void print(raw_ostream &OS, const Module *M) const
print - Print out the internal state of the pass.
PointerIntPair - This class implements a pair of a pointer and small integer.
PointerTy getPointer() const
Wrapper class representing virtual and physical registers.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Primary interface to the complete machine description for the target machine.
CodeGenOptLevel getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
const Triple & getTargetTriple() const
StringRef getTargetFeatureString() const
StringRef getTargetCPU() const
unsigned UnsafeFPMath
UnsafeFPMath - This flag is enabled when the -enable-unsafe-fp-math flag is specified on the command ...
FloatABI::ABIType FloatABIType
FloatABIType - This setting is set by -float-abi=xxx option is specfied on the command line.
unsigned NoInfsFPMath
NoInfsFPMath - This flag is enabled when the -enable-no-infs-fp-math flag is specified on the command...
unsigned HonorSignDependentRoundingFPMathOption
HonorSignDependentRoundingFPMath - This returns true when the -enable-sign-dependent-rounding-fp-math...
unsigned NoNaNsFPMath
NoNaNsFPMath - This flag is enabled when the -enable-no-nans-fp-math flag is specified on the command...
unsigned NoTrappingFPMath
NoTrappingFPMath - This flag is enabled when the -enable-no-trapping-fp-math is specified on the comm...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
TypeSize getRegSizeInBits(const TargetRegisterClass &RC) const
Return the size in bits of a register from class RC.
virtual Register getFrameRegister(const MachineFunction &MF) const =0
Debug information queries.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
Triple - Helper class for working with autoconf configuration names.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an SmallVector or SmallString.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ SECREL
Thread Pointer Offset.
@ GOT_PREL
Thread Local Storage (General Dynamic Mode)
@ SBREL
Section Relative (Windows TLS)
@ GOTTPOFF
Global Offset Table, PC Relative.
@ TPOFF
Global Offset Table, Thread Pointer Offset.
@ MO_LO16
MO_LO16 - On a symbol operand, this represents a relocation containing lower 16 bit of the address.
@ MO_LO_0_7
MO_LO_0_7 - On a symbol operand, this represents a relocation containing bits 0 through 7 of the addr...
@ MO_LO_8_15
MO_LO_8_15 - On a symbol operand, this represents a relocation containing bits 8 through 15 of the ad...
@ MO_NONLAZY
MO_NONLAZY - This is an independent flag, on a symbol operand "FOO" it represents a symbol which,...
@ MO_HI_8_15
MO_HI_8_15 - On a symbol operand, this represents a relocation containing bits 24 through 31 of the a...
@ MO_HI16
MO_HI16 - On a symbol operand, this represents a relocation containing higher 16 bit of the address.
@ MO_DLLIMPORT
MO_DLLIMPORT - On a symbol operand, this represents that the reference to the symbol is for an import...
@ MO_HI_0_7
MO_HI_0_7 - On a symbol operand, this represents a relocation containing bits 16 through 23 of the ad...
@ MO_COFFSTUB
MO_COFFSTUB - On a symbol operand "FOO", this indicates that the reference is actually to the "....
std::string ParseARMTriple(const Triple &TT, StringRef CPU)
SymbolStorageClass
Storage class tells where and what the symbol represents.
@ IMAGE_SYM_CLASS_EXTERNAL
External symbol.
@ IMAGE_SYM_CLASS_STATIC
Static.
@ IMAGE_SYM_DTYPE_FUNCTION
A function that returns a base type.
@ SCT_COMPLEX_TYPE_SHIFT
Type is formed as (base + (derived << SCT_COMPLEX_TYPE_SHIFT))
Reg
All possible values of the reg field in the ModR/M byte.
This is an optimization pass for GlobalISel generic memory operations.
Target & getTheThumbBETarget()
@ MCDR_DataRegionEnd
.end_data_region
@ MCDR_DataRegion
.data_region
@ MCDR_DataRegionJT8
.data_region jt8
@ MCDR_DataRegionJT32
.data_region jt32
@ MCDR_DataRegionJT16
.data_region jt16
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
void LowerARMMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI, ARMAsmPrinter &AP)
@ MCAF_SyntaxUnified
.syntax (ARM/ELF)
@ MCAF_Code16
.code16 (X86) / .code 16 (ARM)
@ MCAF_Code32
.code32 (X86) / .code 32 (ARM)
@ MCAF_SubsectionsViaSymbols
.subsections_via_symbols (MachO)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
DenormalMode parseDenormalFPAttribute(StringRef Str)
Returns the denormal mode to use for inputs and outputs.
Target & getTheARMLETarget()
unsigned convertAddSubFlagsOpcode(unsigned OldOpc)
Map pseudo instructions that imply an 'S' bit onto real opcodes.
@ MCSA_IndirectSymbol
.indirect_symbol (MachO)
@ MCSA_ELF_TypeFunction
.type _foo, STT_FUNC # aka @function
Target & getTheARMBETarget()
Target & getTheThumbLETarget()
Implement std::hash so that hash_code can be used in STL containers.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Represent subnormal handling kind for floating point instruction inputs and outputs.
static constexpr DenormalMode getPositiveZero()
static constexpr DenormalMode getPreserveSign()
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...