53 class X86MCInstLower {
88 CurrentShadowSize += Code.
size();
89 if (CurrentShadowSize >= RequiredShadowSize)
94 void X86AsmPrinter::StackMapShadowTracker::emitShadowPadding(
96 if (InShadow && CurrentShadowSize < RequiredShadowSize) {
98 EmitNops(OutStreamer, RequiredShadowSize - CurrentShadowSize,
103 void X86AsmPrinter::EmitAndCountInstruction(
MCInst &Inst) {
105 EnablePrintSchedInfo &&
107 SMShadowTracker.count(Inst, getSubtargetInfo(), CodeEmitter.get());
112 : Ctx(mf.getContext()), MF(mf),
TM(mf.getTarget()), MAI(*
TM.getMCAsmInfo()),
124 "Isn't a symbol reference");
137 Suffix =
"$non_lazy_ptr";
149 }
else if (MO.
isMBB()) {
156 Sym = Ctx.getOrCreateSymbol(Name);
184 const MCExpr *Expr =
nullptr;
257 assert(MAI.doesSetDirectiveSuppressReloc());
287 "Unexpected instruction!");
291 if (Reg !=
X86::AL && Reg != X86::AX && Reg !=
X86::EAX && Reg != X86::RAX)
304 unsigned NewOpcode = 0;
309 case X86::MOVSX16rr8:
310 if (Op0 == X86::AX && Op1 ==
X86::AL)
311 NewOpcode = X86::CBW;
313 case X86::MOVSX32rr16:
314 if (Op0 ==
X86::EAX && Op1 == X86::AX)
315 NewOpcode = X86::CWDE;
317 case X86::MOVSX64rr32:
318 if (Op0 == X86::RAX && Op1 ==
X86::EAX)
319 NewOpcode = X86::CDQE;
323 if (NewOpcode != 0) {
338 unsigned AddrBase = IsStore;
339 unsigned RegOp = IsStore ? 0 : 5;
340 unsigned AddrOp = AddrBase + 3;
348 "Unexpected instruction!");
352 if (Reg !=
X86::AL && Reg != X86::AX && Reg !=
X86::EAX && Reg != X86::RAX)
382 return Subtarget.
is64Bit() ? X86::RETQ : X86::RETL;
422 if (
auto MaybeMCOp = LowerMachineOperand(MI, MO))
434 "Unexpected # of LEA operands");
436 "LEA has segment specified!");
441 case X86::VMOVZPQILo2PQIrr:
443 case X86::VMOVAPDYrr:
445 case X86::VMOVAPSYrr:
447 case X86::VMOVDQAYrr:
449 case X86::VMOVDQUYrr:
451 case X86::VMOVUPDYrr:
453 case X86::VMOVUPSYrr: {
459 case X86::VMOVZPQILo2PQIrr: NewOpc = X86::VMOVPQI2QIrr;
break;
460 case X86::VMOVAPDrr: NewOpc = X86::VMOVAPDrr_REV;
break;
461 case X86::VMOVAPDYrr: NewOpc = X86::VMOVAPDYrr_REV;
break;
462 case X86::VMOVAPSrr: NewOpc = X86::VMOVAPSrr_REV;
break;
463 case X86::VMOVAPSYrr: NewOpc = X86::VMOVAPSYrr_REV;
break;
464 case X86::VMOVDQArr: NewOpc = X86::VMOVDQArr_REV;
break;
465 case X86::VMOVDQAYrr: NewOpc = X86::VMOVDQAYrr_REV;
break;
466 case X86::VMOVDQUrr: NewOpc = X86::VMOVDQUrr_REV;
break;
467 case X86::VMOVDQUYrr: NewOpc = X86::VMOVDQUYrr_REV;
break;
468 case X86::VMOVUPDrr: NewOpc = X86::VMOVUPDrr_REV;
break;
469 case X86::VMOVUPDYrr: NewOpc = X86::VMOVUPDYrr_REV;
break;
470 case X86::VMOVUPSrr: NewOpc = X86::VMOVUPSrr_REV;
break;
471 case X86::VMOVUPSYrr: NewOpc = X86::VMOVUPSYrr_REV;
break;
478 case X86::VMOVSSrr: {
484 case X86::VMOVSDrr: NewOpc = X86::VMOVSDrr_REV;
break;
485 case X86::VMOVSSrr: NewOpc = X86::VMOVSSrr_REV;
break;
495 case X86::TAILJMPr64:
496 case X86::TAILJMPr64_REX:
498 case X86::CALL64pcrel32: {
508 case X86::EH_RETURN64: {
536 Opcode = X86::JMP32r;
537 goto SetTailJmpOpcode;
539 case X86::TAILJMPd64:
541 goto SetTailJmpOpcode;
542 case X86::TAILJMPd_CC:
543 case X86::TAILJMPd64_CC:
546 goto SetTailJmpOpcode;
565 case X86::DEC16r: Opcode = X86::DEC16r_alt;
break;
566 case X86::DEC32r: Opcode = X86::DEC32r_alt;
break;
567 case X86::INC16r: Opcode = X86::INC16r_alt;
break;
568 case X86::INC32r: Opcode = X86::INC32r_alt;
break;
577 case X86::ADD16rr_DB: OutMI.
setOpcode(X86::OR16rr);
goto ReSimplify;
578 case X86::ADD32rr_DB: OutMI.
setOpcode(X86::OR32rr);
goto ReSimplify;
579 case X86::ADD64rr_DB: OutMI.
setOpcode(X86::OR64rr);
goto ReSimplify;
580 case X86::ADD16ri_DB: OutMI.
setOpcode(X86::OR16ri);
goto ReSimplify;
581 case X86::ADD32ri_DB: OutMI.
setOpcode(X86::OR32ri);
goto ReSimplify;
582 case X86::ADD64ri32_DB: OutMI.
setOpcode(X86::OR64ri32);
goto ReSimplify;
583 case X86::ADD16ri8_DB: OutMI.
setOpcode(X86::OR16ri8);
goto ReSimplify;
584 case X86::ADD32ri8_DB: OutMI.
setOpcode(X86::OR32ri8);
goto ReSimplify;
585 case X86::ADD64ri8_DB: OutMI.
setOpcode(X86::OR64ri8);
goto ReSimplify;
590 case X86::ACQUIRE_MOV8rm: OutMI.
setOpcode(X86::MOV8rm);
goto ReSimplify;
591 case X86::ACQUIRE_MOV16rm: OutMI.
setOpcode(X86::MOV16rm);
goto ReSimplify;
592 case X86::ACQUIRE_MOV32rm: OutMI.
setOpcode(X86::MOV32rm);
goto ReSimplify;
593 case X86::ACQUIRE_MOV64rm: OutMI.
setOpcode(X86::MOV64rm);
goto ReSimplify;
594 case X86::RELEASE_MOV8mr: OutMI.
setOpcode(X86::MOV8mr);
goto ReSimplify;
595 case X86::RELEASE_MOV16mr: OutMI.
setOpcode(X86::MOV16mr);
goto ReSimplify;
596 case X86::RELEASE_MOV32mr: OutMI.
setOpcode(X86::MOV32mr);
goto ReSimplify;
597 case X86::RELEASE_MOV64mr: OutMI.
setOpcode(X86::MOV64mr);
goto ReSimplify;
598 case X86::RELEASE_MOV8mi: OutMI.
setOpcode(X86::MOV8mi);
goto ReSimplify;
599 case X86::RELEASE_MOV16mi: OutMI.
setOpcode(X86::MOV16mi);
goto ReSimplify;
600 case X86::RELEASE_MOV32mi: OutMI.
setOpcode(X86::MOV32mi);
goto ReSimplify;
601 case X86::RELEASE_MOV64mi32: OutMI.
setOpcode(X86::MOV64mi32);
goto ReSimplify;
602 case X86::RELEASE_ADD8mi: OutMI.
setOpcode(X86::ADD8mi);
goto ReSimplify;
603 case X86::RELEASE_ADD8mr: OutMI.
setOpcode(X86::ADD8mr);
goto ReSimplify;
604 case X86::RELEASE_ADD32mi: OutMI.
setOpcode(X86::ADD32mi);
goto ReSimplify;
605 case X86::RELEASE_ADD32mr: OutMI.
setOpcode(X86::ADD32mr);
goto ReSimplify;
606 case X86::RELEASE_ADD64mi32: OutMI.
setOpcode(X86::ADD64mi32);
goto ReSimplify;
607 case X86::RELEASE_ADD64mr: OutMI.
setOpcode(X86::ADD64mr);
goto ReSimplify;
608 case X86::RELEASE_AND8mi: OutMI.
setOpcode(X86::AND8mi);
goto ReSimplify;
609 case X86::RELEASE_AND8mr: OutMI.
setOpcode(X86::AND8mr);
goto ReSimplify;
610 case X86::RELEASE_AND32mi: OutMI.
setOpcode(X86::AND32mi);
goto ReSimplify;
611 case X86::RELEASE_AND32mr: OutMI.
setOpcode(X86::AND32mr);
goto ReSimplify;
612 case X86::RELEASE_AND64mi32: OutMI.
setOpcode(X86::AND64mi32);
goto ReSimplify;
613 case X86::RELEASE_AND64mr: OutMI.
setOpcode(X86::AND64mr);
goto ReSimplify;
614 case X86::RELEASE_OR8mi: OutMI.
setOpcode(X86::OR8mi);
goto ReSimplify;
615 case X86::RELEASE_OR8mr: OutMI.
setOpcode(X86::OR8mr);
goto ReSimplify;
616 case X86::RELEASE_OR32mi: OutMI.
setOpcode(X86::OR32mi);
goto ReSimplify;
617 case X86::RELEASE_OR32mr: OutMI.
setOpcode(X86::OR32mr);
goto ReSimplify;
618 case X86::RELEASE_OR64mi32: OutMI.
setOpcode(X86::OR64mi32);
goto ReSimplify;
619 case X86::RELEASE_OR64mr: OutMI.
setOpcode(X86::OR64mr);
goto ReSimplify;
620 case X86::RELEASE_XOR8mi: OutMI.
setOpcode(X86::XOR8mi);
goto ReSimplify;
621 case X86::RELEASE_XOR8mr: OutMI.
setOpcode(X86::XOR8mr);
goto ReSimplify;
622 case X86::RELEASE_XOR32mi: OutMI.
setOpcode(X86::XOR32mi);
goto ReSimplify;
623 case X86::RELEASE_XOR32mr: OutMI.
setOpcode(X86::XOR32mr);
goto ReSimplify;
624 case X86::RELEASE_XOR64mi32: OutMI.
setOpcode(X86::XOR64mi32);
goto ReSimplify;
625 case X86::RELEASE_XOR64mr: OutMI.
setOpcode(X86::XOR64mr);
goto ReSimplify;
626 case X86::RELEASE_INC8m: OutMI.
setOpcode(X86::INC8m);
goto ReSimplify;
627 case X86::RELEASE_INC16m: OutMI.
setOpcode(X86::INC16m);
goto ReSimplify;
628 case X86::RELEASE_INC32m: OutMI.
setOpcode(X86::INC32m);
goto ReSimplify;
629 case X86::RELEASE_INC64m: OutMI.
setOpcode(X86::INC64m);
goto ReSimplify;
630 case X86::RELEASE_DEC8m: OutMI.
setOpcode(X86::DEC8m);
goto ReSimplify;
631 case X86::RELEASE_DEC16m: OutMI.
setOpcode(X86::DEC16m);
goto ReSimplify;
632 case X86::RELEASE_DEC32m: OutMI.
setOpcode(X86::DEC32m);
goto ReSimplify;
633 case X86::RELEASE_DEC64m: OutMI.
setOpcode(X86::DEC64m);
goto ReSimplify;
642 case X86::MOV8mr_NOREX:
644 case X86::MOV8rm_NOREX:
653 case X86::MOV8mr_NOREX:
654 case X86::MOV8mr: NewOpc = X86::MOV8o32a;
break;
655 case X86::MOV8rm_NOREX:
656 case X86::MOV8rm: NewOpc = X86::MOV8ao32;
break;
657 case X86::MOV16mr: NewOpc = X86::MOV16o32a;
break;
658 case X86::MOV16rm: NewOpc = X86::MOV16ao32;
break;
659 case X86::MOV32mr: NewOpc = X86::MOV32o32a;
break;
660 case X86::MOV32rm: NewOpc = X86::MOV32ao32;
break;
666 case X86::ADC8ri:
case X86::ADC16ri:
case X86::ADC32ri:
case X86::ADC64ri32:
667 case X86::ADD8ri:
case X86::ADD16ri:
case X86::ADD32ri:
case X86::ADD64ri32:
668 case X86::AND8ri:
case X86::AND16ri:
case X86::AND32ri:
case X86::AND64ri32:
669 case X86::CMP8ri:
case X86::CMP16ri:
case X86::CMP32ri:
case X86::CMP64ri32:
670 case X86::OR8ri:
case X86::OR16ri:
case X86::OR32ri:
case X86::OR64ri32:
671 case X86::SBB8ri:
case X86::SBB16ri:
case X86::SBB32ri:
case X86::SBB64ri32:
672 case X86::SUB8ri:
case X86::SUB16ri:
case X86::SUB32ri:
case X86::SUB64ri32:
673 case X86::TEST8ri:
case X86::TEST16ri:
case X86::TEST32ri:
case X86::TEST64ri32:
674 case X86::XOR8ri:
case X86::XOR16ri:
case X86::XOR32ri:
case X86::XOR64ri32: {
678 case X86::ADC8ri: NewOpc = X86::ADC8i8;
break;
679 case X86::ADC16ri: NewOpc = X86::ADC16i16;
break;
680 case X86::ADC32ri: NewOpc = X86::ADC32i32;
break;
681 case X86::ADC64ri32: NewOpc = X86::ADC64i32;
break;
682 case X86::ADD8ri: NewOpc = X86::ADD8i8;
break;
683 case X86::ADD16ri: NewOpc = X86::ADD16i16;
break;
684 case X86::ADD32ri: NewOpc = X86::ADD32i32;
break;
685 case X86::ADD64ri32: NewOpc = X86::ADD64i32;
break;
686 case X86::AND8ri: NewOpc = X86::AND8i8;
break;
687 case X86::AND16ri: NewOpc = X86::AND16i16;
break;
688 case X86::AND32ri: NewOpc = X86::AND32i32;
break;
689 case X86::AND64ri32: NewOpc = X86::AND64i32;
break;
690 case X86::CMP8ri: NewOpc = X86::CMP8i8;
break;
691 case X86::CMP16ri: NewOpc = X86::CMP16i16;
break;
692 case X86::CMP32ri: NewOpc = X86::CMP32i32;
break;
693 case X86::CMP64ri32: NewOpc = X86::CMP64i32;
break;
694 case X86::OR8ri: NewOpc = X86::OR8i8;
break;
695 case X86::OR16ri: NewOpc = X86::OR16i16;
break;
696 case X86::OR32ri: NewOpc = X86::OR32i32;
break;
697 case X86::OR64ri32: NewOpc = X86::OR64i32;
break;
698 case X86::SBB8ri: NewOpc = X86::SBB8i8;
break;
699 case X86::SBB16ri: NewOpc = X86::SBB16i16;
break;
700 case X86::SBB32ri: NewOpc = X86::SBB32i32;
break;
701 case X86::SBB64ri32: NewOpc = X86::SBB64i32;
break;
702 case X86::SUB8ri: NewOpc = X86::SUB8i8;
break;
703 case X86::SUB16ri: NewOpc = X86::SUB16i16;
break;
704 case X86::SUB32ri: NewOpc = X86::SUB32i32;
break;
705 case X86::SUB64ri32: NewOpc = X86::SUB64i32;
break;
706 case X86::TEST8ri: NewOpc = X86::TEST8i8;
break;
707 case X86::TEST16ri: NewOpc = X86::TEST16i16;
break;
708 case X86::TEST32ri: NewOpc = X86::TEST32i32;
break;
709 case X86::TEST64ri32: NewOpc = X86::TEST64i32;
break;
710 case X86::XOR8ri: NewOpc = X86::XOR8i8;
break;
711 case X86::XOR16ri: NewOpc = X86::XOR16i16;
break;
712 case X86::XOR32ri: NewOpc = X86::XOR32i32;
break;
713 case X86::XOR64ri32: NewOpc = X86::XOR64i32;
break;
720 case X86::MOVSX16rr8:
721 case X86::MOVSX32rr16:
722 case X86::MOVSX64rr32:
728 void X86AsmPrinter::LowerTlsAddr(X86MCInstLower &MCInstLowering,
731 bool is64Bits = MI.
getOpcode() == X86::TLS_addr64 ||
734 bool needsPadding = MI.
getOpcode() == X86::TLS_addr64;
743 case X86::TLS_addr32:
744 case X86::TLS_addr64:
747 case X86::TLS_base_addr32:
750 case X86::TLS_base_addr64:
786 EmitAndCountInstruction(LEA);
794 StringRef name = is64Bits ?
"__tls_get_addr" :
"___tls_get_addr";
799 EmitAndCountInstruction(
800 MCInstBuilder(is64Bits ? X86::CALL64pcrel32 : X86::CALLpcrel32)
810 assert(Is64Bit &&
"EmitNops only supports X86-64");
813 unsigned Opc, BaseReg, ScaleVal, IndexReg, Displacement, SegmentReg;
814 Opc = IndexReg = Displacement = SegmentReg = 0;
872 SegmentReg = X86::CS;
876 unsigned NumPrefixes = std::min(NumBytes - NopSize, 5U);
877 NopSize += NumPrefixes;
878 for (
unsigned i = 0; i != NumPrefixes; ++i)
895 .addImm(Displacement)
900 assert(NopSize <= NumBytes &&
"We overemitted?");
907 unsigned NopsToEmit = NumBytes;
910 NumBytes -=
EmitNop(OS, NumBytes, Is64Bit, STI);
911 assert(NopsToEmit >= NumBytes &&
"Emitted more than I asked for!");
915 void X86AsmPrinter::LowerSTATEPOINT(
const MachineInstr &MI,
916 X86MCInstLower &MCIL) {
917 assert(Subtarget->
is64Bit() &&
"Statepoint currently only supports X86-64");
920 if (
unsigned PatchBytes = SOpers.getNumPatchBytes()) {
928 switch (CallTarget.
getType()) {
931 CallTargetMCOp = MCIL.LowerSymbolOperand(
932 CallTarget, MCIL.GetSymbolFromOperand(CallTarget));
933 CallOpcode = X86::CALL64pcrel32;
941 CallOpcode = X86::CALL64pcrel32;
953 CallOpcode = X86::CALL64r;
972 void X86AsmPrinter::LowerFAULTING_OP(
const MachineInstr &FaultingMI,
973 X86MCInstLower &MCIL) {
982 unsigned OperandsBeginIdx = 4;
990 if (DefRegister != X86::NoRegister)
996 if (
auto MaybeOperand = MCIL.LowerMachineOperand(&FaultingMI, *
I))
1002 void X86AsmPrinter::LowerFENTRY_CALL(
const MachineInstr &MI,
1003 X86MCInstLower &MCIL) {
1004 bool Is64Bits = Subtarget->
is64Bit();
1010 EmitAndCountInstruction(
1011 MCInstBuilder(Is64Bits ? X86::CALL64pcrel32 : X86::CALLpcrel32)
1015 void X86AsmPrinter::LowerPATCHABLE_OP(
const MachineInstr &MI,
1016 X86MCInstLower &MCIL) {
1025 if (
auto MaybeOperand = MCIL.LowerMachineOperand(&MI, MO))
1033 if (Code.
size() < MinSize) {
1034 if (MinSize == 2 && Opcode == X86::PUSH64r) {
1042 unsigned NopSize =
EmitNop(*OutStreamer, MinSize, Subtarget->
is64Bit(),
1044 assert(NopSize == MinSize &&
"Could not implement MinSize!");
1054 void X86AsmPrinter::LowerSTACKMAP(
const MachineInstr &MI) {
1058 SMShadowTracker.reset(NumShadowBytes);
1063 void X86AsmPrinter::LowerPATCHPOINT(
const MachineInstr &MI,
1064 X86MCInstLower &MCIL) {
1065 assert(Subtarget->
is64Bit() &&
"Patchpoint currently only supports X86-64");
1073 unsigned EncodedBytes = 0;
1090 CalleeMCOp = MCIL.LowerSymbolOperand(CalleeMO,
1091 MCIL.GetSymbolFromOperand(CalleeMO));
1103 EmitAndCountInstruction(
1108 "Lowering patchpoint with retpoline not yet implemented.");
1109 EmitAndCountInstruction(
MCInstBuilder(X86::CALL64r).addReg(ScratchReg));
1114 assert(NumBytes >= EncodedBytes &&
1115 "Patchpoint can't request size less than the length of a call.");
1121 void X86AsmPrinter::LowerPATCHABLE_EVENT_CALL(
const MachineInstr &MI,
1122 X86MCInstLower &MCIL) {
1123 assert(Subtarget->
is64Bit() &&
"XRay custom events only supports X86-64");
1146 OutStreamer->
AddComment(
"# XRay Custom Event Log");
1157 unsigned DestRegs[] = {X86::RDI, X86::RSI};
1158 bool UsedMask[] = {
false,
false};
1160 unsigned SrcRegs[] = {0, 0};
1168 if (
auto Op = MCIL.LowerMachineOperand(&MI, MI.
getOperand(
I))) {
1169 assert(
Op->isReg() &&
"Only support arguments in registers");
1170 SrcRegs[
I] =
Op->getReg();
1171 if (SrcRegs[
I] != DestRegs[
I]) {
1173 EmitAndCountInstruction(
1182 if (SrcRegs[
I] != DestRegs[
I])
1183 EmitAndCountInstruction(
1184 MCInstBuilder(X86::MOV64rr).addReg(DestRegs[I]).addReg(SrcRegs[I]));
1195 .
addOperand(MCIL.LowerSymbolOperand(TOp, TSym)));
1198 for (
unsigned I =
sizeof UsedMask; I-- > 0;)
1200 EmitAndCountInstruction(
MCInstBuilder(X86::POP64r).addReg(DestRegs[I]));
1204 OutStreamer->
AddComment(
"xray custom event end.");
1212 void X86AsmPrinter::LowerPATCHABLE_TYPED_EVENT_CALL(
const MachineInstr &MI,
1213 X86MCInstLower &MCIL) {
1214 assert(Subtarget->
is64Bit() &&
"XRay typed events only supports X86-64");
1237 OutStreamer->
AddComment(
"# XRay Typed Event Log");
1249 unsigned DestRegs[] = {X86::RDI, X86::RSI, X86::RDX};
1250 bool UsedMask[] = {
false,
false,
false};
1253 unsigned SrcRegs[] = {0, 0, 0};
1260 if (
auto Op = MCIL.LowerMachineOperand(&MI, MI.
getOperand(
I))) {
1262 assert(
Op->isReg() &&
"Only supports arguments in registers");
1263 SrcRegs[
I] =
Op->getReg();
1264 if (SrcRegs[
I] != DestRegs[
I]) {
1266 EmitAndCountInstruction(
1281 EmitAndCountInstruction(
1282 MCInstBuilder(X86::MOV64rr).addReg(DestRegs[I]).addReg(SrcRegs[I]));
1293 .
addOperand(MCIL.LowerSymbolOperand(TOp, TSym)));
1296 for (
unsigned I =
sizeof UsedMask; I-- > 0;)
1298 EmitAndCountInstruction(
MCInstBuilder(X86::POP64r).addReg(DestRegs[I]));
1302 OutStreamer->
AddComment(
"xray typed event end.");
1308 void X86AsmPrinter::LowerPATCHABLE_FUNCTION_ENTER(
const MachineInstr &MI,
1309 X86MCInstLower &MCIL) {
1335 void X86AsmPrinter::LowerPATCHABLE_RET(
const MachineInstr &MI,
1336 X86MCInstLower &MCIL) {
1358 if (
auto MaybeOperand = MCIL.LowerMachineOperand(&MI, MO))
1365 void X86AsmPrinter::LowerPATCHABLE_TAIL_CALL(
const MachineInstr &MI,
1366 X86MCInstLower &MCIL) {
1394 if (
auto MaybeOperand = MCIL.LowerMachineOperand(&MI, MO))
1404 while (MBBI == MBB->
begin()) {
1429 "Expected a constant of the same type!");
1435 std::string Comment;
1442 auto GetRegisterName = [](
unsigned RegNum) ->
StringRef {
1452 SrcOp1.
isReg() ? GetRegisterName(SrcOp1.
getReg()) :
"mem";
1454 SrcOp2.
isReg() ? GetRegisterName(SrcOp2.
getReg()) :
"mem";
1458 if (Src1Name == Src2Name)
1459 for (
int i = 0, e = ShuffleMask.size(); i != e; ++i)
1460 if (ShuffleMask[i] >= e)
1461 ShuffleMask[i] -= e;
1469 if (SrcOp1Idx > 1) {
1470 assert((SrcOp1Idx == 2 || SrcOp1Idx == 3) &&
"Unexpected writemask");
1473 if (WriteMaskOp.
isReg()) {
1474 CS <<
" {%" << GetRegisterName(WriteMaskOp.
getReg()) <<
"}";
1476 if (SrcOp1Idx == 2) {
1484 for (
int i = 0, e = ShuffleMask.size(); i != e; ++i) {
1494 bool isSrc1 = ShuffleMask[i] < (int)e;
1495 CS << (isSrc1 ? Src1Name : Src2Name) <<
'[';
1497 bool IsFirst =
true;
1499 (ShuffleMask[i] < (
int)e) == isSrc1) {
1507 CS << ShuffleMask[i] % (int)e;
1519 if (isa<UndefValue>(COp)) {
1521 }
else if (
auto *CI = dyn_cast<ConstantInt>(COp)) {
1522 if (CI->getBitWidth() <= 64) {
1523 CS << CI->getZExtValue();
1526 const auto &Val = CI->getValue();
1528 for (
int i = 0,
N = Val.getNumWords(); i <
N; ++i) {
1531 CS << Val.getRawData()[i];
1535 }
else if (
auto *CF = dyn_cast<ConstantFP>(COp)) {
1537 CF->getValueAPF().toString(Str);
1544 void X86AsmPrinter::EmitSEHInstruction(
const MachineInstr *MI) {
1555 case X86::SEH_PushReg:
1558 case X86::SEH_StackAlloc:
1561 case X86::SEH_SetFrame:
1563 ".cv_fpo_setframe takes no offset");
1566 case X86::SEH_EndPrologue:
1569 case X86::SEH_SaveReg:
1570 case X86::SEH_SaveXMM:
1571 case X86::SEH_PushFrame:
1582 case X86::SEH_PushReg:
1587 case X86::SEH_SaveReg:
1592 case X86::SEH_SaveXMM:
1597 case X86::SEH_StackAlloc:
1601 case X86::SEH_SetFrame:
1607 case X86::SEH_PushFrame:
1611 case X86::SEH_EndPrologue:
1621 X86MCInstLower MCInstLowering(*
MF, *
this);
1629 OutStreamer->
AddComment(
"EVEX TO VEX Compression ",
false);
1633 case TargetOpcode::DBG_VALUE:
1637 case X86::Int_MemBarrier:
1642 case X86::EH_RETURN64: {
1664 case X86::TAILJMPd_CC:
1665 case X86::TAILJMPr64:
1666 case X86::TAILJMPm64:
1667 case X86::TAILJMPd64:
1668 case X86::TAILJMPd64_CC:
1669 case X86::TAILJMPr64_REX:
1670 case X86::TAILJMPm64_REX:
1675 case X86::TLS_addr32:
1676 case X86::TLS_addr64:
1677 case X86::TLS_base_addr32:
1678 case X86::TLS_base_addr64:
1679 return LowerTlsAddr(MCInstLowering, *MI);
1681 case X86::MOVPC32r: {
1692 EmitAndCountInstruction(
1698 bool hasFP = FrameLowering->
hasFP(*
MF);
1706 if (HasActiveDwarfFrame && !hasFP) {
1714 EmitAndCountInstruction(
1717 if (HasActiveDwarfFrame && !hasFP) {
1723 case X86::MOVGOT64r: {
1744 const MCExpr *GOTDiffExpr =
1748 .addExpr(GOTDiffExpr));
1754 .addReg(ScratchReg));
1758 case X86::ADD32ri: {
1790 case TargetOpcode::STATEPOINT:
1791 return LowerSTATEPOINT(*MI, MCInstLowering);
1793 case TargetOpcode::FAULTING_OP:
1794 return LowerFAULTING_OP(*MI, MCInstLowering);
1796 case TargetOpcode::FENTRY_CALL:
1797 return LowerFENTRY_CALL(*MI, MCInstLowering);
1799 case TargetOpcode::PATCHABLE_OP:
1800 return LowerPATCHABLE_OP(*MI, MCInstLowering);
1802 case TargetOpcode::STACKMAP:
1803 return LowerSTACKMAP(*MI);
1805 case TargetOpcode::PATCHPOINT:
1806 return LowerPATCHPOINT(*MI, MCInstLowering);
1808 case TargetOpcode::PATCHABLE_FUNCTION_ENTER:
1809 return LowerPATCHABLE_FUNCTION_ENTER(*MI, MCInstLowering);
1811 case TargetOpcode::PATCHABLE_RET:
1812 return LowerPATCHABLE_RET(*MI, MCInstLowering);
1814 case TargetOpcode::PATCHABLE_TAIL_CALL:
1815 return LowerPATCHABLE_TAIL_CALL(*MI, MCInstLowering);
1817 case TargetOpcode::PATCHABLE_EVENT_CALL:
1818 return LowerPATCHABLE_EVENT_CALL(*MI, MCInstLowering);
1820 case TargetOpcode::PATCHABLE_TYPED_EVENT_CALL:
1821 return LowerPATCHABLE_TYPED_EVENT_CALL(*MI, MCInstLowering);
1823 case X86::MORESTACK_RET:
1827 case X86::MORESTACK_RET_RESTORE_R10:
1830 EmitAndCountInstruction(
1831 MCInstBuilder(X86::MOV64rr).addReg(X86::R10).addReg(X86::RAX));
1834 case X86::SEH_PushReg:
1835 case X86::SEH_SaveReg:
1836 case X86::SEH_SaveXMM:
1837 case X86::SEH_StackAlloc:
1838 case X86::SEH_SetFrame:
1839 case X86::SEH_PushFrame:
1840 case X86::SEH_EndPrologue:
1841 EmitSEHInstruction(MI);
1844 case X86::SEH_Epilogue: {
1853 if (!MBBI->isPseudo()) {
1866 case X86::VPSHUFBrm:
1867 case X86::VPSHUFBYrm:
1868 case X86::VPSHUFBZ128rm:
1869 case X86::VPSHUFBZ128rmk:
1870 case X86::VPSHUFBZ128rmkz:
1871 case X86::VPSHUFBZ256rm:
1872 case X86::VPSHUFBZ256rmk:
1873 case X86::VPSHUFBZ256rmkz:
1874 case X86::VPSHUFBZrm:
1875 case X86::VPSHUFBZrmk:
1876 case X86::VPSHUFBZrmkz: {
1879 unsigned SrcIdx, MaskIdx;
1883 case X86::VPSHUFBrm:
1884 case X86::VPSHUFBYrm:
1885 case X86::VPSHUFBZ128rm:
1886 case X86::VPSHUFBZ256rm:
1887 case X86::VPSHUFBZrm:
1888 SrcIdx = 1; MaskIdx = 5;
break;
1889 case X86::VPSHUFBZ128rmkz:
1890 case X86::VPSHUFBZ256rmkz:
1891 case X86::VPSHUFBZrmkz:
1892 SrcIdx = 2; MaskIdx = 6;
break;
1893 case X86::VPSHUFBZ128rmk:
1894 case X86::VPSHUFBZ256rmk:
1895 case X86::VPSHUFBZrmk:
1896 SrcIdx = 3; MaskIdx = 7;
break;
1900 "We should always have at least 6 operands!");
1913 case X86::VPERMILPSrm:
1914 case X86::VPERMILPSYrm:
1915 case X86::VPERMILPSZ128rm:
1916 case X86::VPERMILPSZ128rmk:
1917 case X86::VPERMILPSZ128rmkz:
1918 case X86::VPERMILPSZ256rm:
1919 case X86::VPERMILPSZ256rmk:
1920 case X86::VPERMILPSZ256rmkz:
1921 case X86::VPERMILPSZrm:
1922 case X86::VPERMILPSZrmk:
1923 case X86::VPERMILPSZrmkz:
1924 case X86::VPERMILPDrm:
1925 case X86::VPERMILPDYrm:
1926 case X86::VPERMILPDZ128rm:
1927 case X86::VPERMILPDZ128rmk:
1928 case X86::VPERMILPDZ128rmkz:
1929 case X86::VPERMILPDZ256rm:
1930 case X86::VPERMILPDZ256rmk:
1931 case X86::VPERMILPDZ256rmkz:
1932 case X86::VPERMILPDZrm:
1933 case X86::VPERMILPDZrmk:
1934 case X86::VPERMILPDZrmkz: {
1937 unsigned SrcIdx, MaskIdx;
1941 case X86::VPERMILPSrm:
1942 case X86::VPERMILPSYrm:
1943 case X86::VPERMILPSZ128rm:
1944 case X86::VPERMILPSZ256rm:
1945 case X86::VPERMILPSZrm:
1946 SrcIdx = 1; MaskIdx = 5; ElSize = 32;
break;
1947 case X86::VPERMILPSZ128rmkz:
1948 case X86::VPERMILPSZ256rmkz:
1949 case X86::VPERMILPSZrmkz:
1950 SrcIdx = 2; MaskIdx = 6; ElSize = 32;
break;
1951 case X86::VPERMILPSZ128rmk:
1952 case X86::VPERMILPSZ256rmk:
1953 case X86::VPERMILPSZrmk:
1954 SrcIdx = 3; MaskIdx = 7; ElSize = 32;
break;
1955 case X86::VPERMILPDrm:
1956 case X86::VPERMILPDYrm:
1957 case X86::VPERMILPDZ128rm:
1958 case X86::VPERMILPDZ256rm:
1959 case X86::VPERMILPDZrm:
1960 SrcIdx = 1; MaskIdx = 5; ElSize = 64;
break;
1961 case X86::VPERMILPDZ128rmkz:
1962 case X86::VPERMILPDZ256rmkz:
1963 case X86::VPERMILPDZrmkz:
1964 SrcIdx = 2; MaskIdx = 6; ElSize = 64;
break;
1965 case X86::VPERMILPDZ128rmk:
1966 case X86::VPERMILPDZ256rmk:
1967 case X86::VPERMILPDZrmk:
1968 SrcIdx = 3; MaskIdx = 7; ElSize = 64;
break;
1972 "We should always have at least 6 operands!");
1985 case X86::VPERMIL2PDrm:
1986 case X86::VPERMIL2PSrm:
1987 case X86::VPERMIL2PDYrm:
1988 case X86::VPERMIL2PSYrm: {
1992 "We should always have at least 8 operands!");
1995 if (!CtrlOp.isImm())
2001 case X86::VPERMIL2PSrm:
case X86::VPERMIL2PSYrm: ElSize = 32;
break;
2002 case X86::VPERMIL2PDrm:
case X86::VPERMIL2PDYrm: ElSize = 64;
break;
2016 case X86::VPPERMrrm: {
2020 "We should always have at least 7 operands!");
2033 case X86::MMX_MOVQ64rm: {
2039 std::string Comment;
2043 if (
auto *CF = dyn_cast<ConstantFP>(
C)) {
2044 CS <<
"0x" << CF->getValueAPF().bitcastToAPInt().toString(16,
false);
2051 #define MOV_CASE(Prefix, Suffix) \ 2052 case X86::Prefix##MOVAPD##Suffix##rm: \ 2053 case X86::Prefix##MOVAPS##Suffix##rm: \ 2054 case X86::Prefix##MOVUPD##Suffix##rm: \ 2055 case X86::Prefix##MOVUPS##Suffix##rm: \ 2056 case X86::Prefix##MOVDQA##Suffix##rm: \ 2057 case X86::Prefix##MOVDQU##Suffix##rm: 2059 #define MOV_AVX512_CASE(Suffix) \ 2060 case X86::VMOVDQA64##Suffix##rm: \ 2061 case X86::VMOVDQA32##Suffix##rm: \ 2062 case X86::VMOVDQU64##Suffix##rm: \ 2063 case X86::VMOVDQU32##Suffix##rm: \ 2064 case X86::VMOVDQU16##Suffix##rm: \ 2065 case X86::VMOVDQU8##Suffix##rm: \ 2066 case X86::VMOVAPS##Suffix##rm: \ 2067 case X86::VMOVAPD##Suffix##rm: \ 2068 case X86::VMOVUPS##Suffix##rm: \ 2069 case X86::VMOVUPD##Suffix##rm: 2071 #define CASE_ALL_MOV_RM() \ 2075 MOV_AVX512_CASE(Z) \ 2076 MOV_AVX512_CASE(Z256) \ 2077 MOV_AVX512_CASE(Z128) 2082 case X86::VBROADCASTF128:
2083 case X86::VBROADCASTI128:
2084 case X86::VBROADCASTF32X4Z256rm:
2085 case X86::VBROADCASTF32X4rm:
2086 case X86::VBROADCASTF32X8rm:
2087 case X86::VBROADCASTF64X2Z128rm:
2088 case X86::VBROADCASTF64X2rm:
2089 case X86::VBROADCASTF64X4rm:
2090 case X86::VBROADCASTI32X4Z256rm:
2091 case X86::VBROADCASTI32X4rm:
2092 case X86::VBROADCASTI32X8rm:
2093 case X86::VBROADCASTI64X2Z128rm:
2094 case X86::VBROADCASTI64X2rm:
2095 case X86::VBROADCASTI64X4rm:
2104 case X86::VBROADCASTF128: NumLanes = 2;
break;
2105 case X86::VBROADCASTI128: NumLanes = 2;
break;
2106 case X86::VBROADCASTF32X4Z256rm: NumLanes = 2;
break;
2107 case X86::VBROADCASTF32X4rm: NumLanes = 4;
break;
2108 case X86::VBROADCASTF32X8rm: NumLanes = 2;
break;
2109 case X86::VBROADCASTF64X2Z128rm: NumLanes = 2;
break;
2110 case X86::VBROADCASTF64X2rm: NumLanes = 4;
break;
2111 case X86::VBROADCASTF64X4rm: NumLanes = 2;
break;
2112 case X86::VBROADCASTI32X4Z256rm: NumLanes = 2;
break;
2113 case X86::VBROADCASTI32X4rm: NumLanes = 4;
break;
2114 case X86::VBROADCASTI32X8rm: NumLanes = 2;
break;
2115 case X86::VBROADCASTI64X2Z128rm: NumLanes = 2;
break;
2116 case X86::VBROADCASTI64X2rm: NumLanes = 4;
break;
2117 case X86::VBROADCASTI64X4rm: NumLanes = 2;
break;
2120 std::string Comment;
2124 if (
auto *CDS = dyn_cast<ConstantDataSequential>(
C)) {
2126 for (
int l = 0; l != NumLanes; ++l) {
2127 for (
int i = 0, NumElements = CDS->getNumElements(); i < NumElements;
2129 if (i != 0 || l != 0)
2131 if (CDS->getElementType()->isIntegerTy())
2132 CS << CDS->getElementAsInteger(i);
2133 else if (CDS->getElementType()->isFloatTy())
2134 CS << CDS->getElementAsFloat(i);
2135 else if (CDS->getElementType()->isDoubleTy())
2136 CS << CDS->getElementAsDouble(i);
2143 }
else if (
auto *CV = dyn_cast<ConstantVector>(
C)) {
2145 for (
int l = 0; l != NumLanes; ++l) {
2146 for (
int i = 0, NumOperands = CV->getNumOperands(); i < NumOperands;
2148 if (i != 0 || l != 0)
2158 case X86::VBROADCASTSSrm:
2159 case X86::VBROADCASTSSYrm:
2160 case X86::VBROADCASTSSZ128m:
2161 case X86::VBROADCASTSSZ256m:
2162 case X86::VBROADCASTSSZm:
2163 case X86::VBROADCASTSDYrm:
2164 case X86::VBROADCASTSDZ256m:
2165 case X86::VBROADCASTSDZm:
2166 case X86::VPBROADCASTBrm:
2167 case X86::VPBROADCASTBYrm:
2168 case X86::VPBROADCASTBZ128m:
2169 case X86::VPBROADCASTBZ256m:
2170 case X86::VPBROADCASTBZm:
2171 case X86::VPBROADCASTDrm:
2172 case X86::VPBROADCASTDYrm:
2173 case X86::VPBROADCASTDZ128m:
2174 case X86::VPBROADCASTDZ256m:
2175 case X86::VPBROADCASTDZm:
2176 case X86::VPBROADCASTQrm:
2177 case X86::VPBROADCASTQYrm:
2178 case X86::VPBROADCASTQZ128m:
2179 case X86::VPBROADCASTQZ256m:
2180 case X86::VPBROADCASTQZm:
2181 case X86::VPBROADCASTWrm:
2182 case X86::VPBROADCASTWYrm:
2183 case X86::VPBROADCASTWZ128m:
2184 case X86::VPBROADCASTWZ256m:
2185 case X86::VPBROADCASTWZm:
2194 case X86::VBROADCASTSSrm: NumElts = 4;
break;
2195 case X86::VBROADCASTSSYrm: NumElts = 8;
break;
2196 case X86::VBROADCASTSSZ128m: NumElts = 4;
break;
2197 case X86::VBROADCASTSSZ256m: NumElts = 8;
break;
2198 case X86::VBROADCASTSSZm: NumElts = 16;
break;
2199 case X86::VBROADCASTSDYrm: NumElts = 4;
break;
2200 case X86::VBROADCASTSDZ256m: NumElts = 4;
break;
2201 case X86::VBROADCASTSDZm: NumElts = 8;
break;
2202 case X86::VPBROADCASTBrm: NumElts = 16;
break;
2203 case X86::VPBROADCASTBYrm: NumElts = 32;
break;
2204 case X86::VPBROADCASTBZ128m: NumElts = 16;
break;
2205 case X86::VPBROADCASTBZ256m: NumElts = 32;
break;
2206 case X86::VPBROADCASTBZm: NumElts = 64;
break;
2207 case X86::VPBROADCASTDrm: NumElts = 4;
break;
2208 case X86::VPBROADCASTDYrm: NumElts = 8;
break;
2209 case X86::VPBROADCASTDZ128m: NumElts = 4;
break;
2210 case X86::VPBROADCASTDZ256m: NumElts = 8;
break;
2211 case X86::VPBROADCASTDZm: NumElts = 16;
break;
2212 case X86::VPBROADCASTQrm: NumElts = 2;
break;
2213 case X86::VPBROADCASTQYrm: NumElts = 4;
break;
2214 case X86::VPBROADCASTQZ128m: NumElts = 2;
break;
2215 case X86::VPBROADCASTQZ256m: NumElts = 4;
break;
2216 case X86::VPBROADCASTQZm: NumElts = 8;
break;
2217 case X86::VPBROADCASTWrm: NumElts = 8;
break;
2218 case X86::VPBROADCASTWYrm: NumElts = 16;
break;
2219 case X86::VPBROADCASTWZ128m: NumElts = 8;
break;
2220 case X86::VPBROADCASTWZ256m: NumElts = 16;
break;
2221 case X86::VPBROADCASTWZm: NumElts = 32;
break;
2224 std::string Comment;
2229 for (
int i = 0; i != NumElts; ++i) {
2240 MCInstLowering.Lower(MI, TmpInst);
2259 EmitAndCountInstruction(TmpInst);
unsigned getTargetFlags() const
MO_SECREL - On a symbol operand this indicates that the immediate is the offset from beginning of sec...
unsigned GetCondBranchFromCond(CondCode CC)
bool is64Bit() const
Is this x86_64? (disregarding specific ABI / programming model)
A parsed version of the target data layout string in and methods for querying it. ...
mop_iterator operands_end()
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.
static const char * getRegisterName(unsigned RegNo)
virtual void EmitWinCFIPushReg(unsigned Register, SMLoc Loc=SMLoc())
virtual bool emitFPOSetFrame(unsigned Reg, SMLoc L={})=0
bool isCall(QueryType Type=AnyInBundle) const
AddrNumOperands - Total number of operands in a memory reference.
MachineBasicBlock * getMBB() const
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)
MCTargetOptions MCOptions
Machine level options.
void DecodeVPERMILPMask(unsigned NumElts, unsigned ScalarBits, ArrayRef< uint64_t > RawMask, SmallVectorImpl< int > &ShuffleMask)
Decode a VPERMILPD/VPERMILPS variable mask from a raw array of constants.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Compute iterated dominance frontiers using a linear time algorithm.
PointerTy getPointer() const
static MachineOperand CreateMCSymbol(MCSymbol *Sym, unsigned char TargetFlags=0)
void setTargetFlags(unsigned F)
StringRef getPrivateGlobalPrefix() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
MO_TLSLD - On a symbol operand this indicates that the immediate is the offset of the GOT entry with ...
MO_TLVP_PIC_BASE - On a symbol operand this indicates that the immediate is some TLS offset from the ...
MCContext & OutContext
This is the context for the output file that we are streaming.
static MachineModuleInfoMachO & getMachOMMI(AsmPrinter &AP)
static MCOperand createExpr(const MCExpr *Val)
bool EnablePrintSchedInfo
Enable print [latency:throughput] in output.
const MCSubtargetInfo & getSubtargetInfo() const
Return information about subtarget.
virtual void EmitWinCFISaveXMM(unsigned Register, unsigned Offset, SMLoc Loc=SMLoc())
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
unsigned getReg() const
getReg - Returns the register number.
virtual void EmitBytes(StringRef Data)
Emit the bytes in Data into the output.
Address of indexed Jump Table for switch.
This class represents a function call, abstracting a target machine's calling convention.
PointerIntPair< MCSymbol *, 1, bool > StubValueTy
static std::string getShuffleComment(const MachineInstr *MI, unsigned SrcOp1Idx, unsigned SrcOp2Idx, ArrayRef< int > Mask)
A raw_ostream that writes to an SmallVector or SmallString.
MachineBasicBlock reference.
MachineFunction * MF
The current machine function.
bool isCPI() const
isCPI - Tests if this is a MO_ConstantPoolIndex operand.
MachineInstrBundleIterator< const MachineInstr > const_iterator
MO_GOTPCREL - On a symbol operand this indicates that the immediate is offset to the GOT entry for th...
MO_DTPOFF - On a symbol operand this indicates that the immediate is the offset of the GOT entry with...
static void EmitNops(MCStreamer &OS, unsigned NumBytes, bool Is64Bit, const MCSubtargetInfo &STI)
Emit the optimal amount of multi-byte nops on X86.
virtual bool emitFPOPushReg(unsigned Reg, SMLoc L={})=0
iterator_range< mop_iterator > operands()
print alias Alias Set Printer
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
static MCOperand LowerSymbolOperand(const MachineOperand &MO, AsmPrinter &AP)
unsigned getSlotSize() const
virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI, bool PrintSchedInfo=false)
Emit the given Instruction into the current section.
Mask of preserved registers.
static MCDisassembler::DecodeStatus addOperand(MCInst &Inst, const MCOperand &Opnd)
MCContext & getContext() const
void recordSled(MCSymbol *Sled, const MachineInstr &MI, SledKind Kind, uint8_t Version=0)
CLEANUPRET - Represents a return from a cleanup block funclet.
MO_DARWIN_NONLAZY_PIC_BASE - On a symbol operand "FOO", this indicates that the reference is actually...
bool isMachineConstantPoolEntry() const
isMachineConstantPoolEntry - Return true if the MachineConstantPoolEntry is indeed a target specific ...
static MCOperand createReg(unsigned Reg)
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
virtual bool emitFPOStackAlloc(unsigned StackAlloc, SMLoc L={})=0
unsigned getNumOperands() const
Access to explicit operands of the instruction.
virtual void encodeInstruction(const MCInst &Inst, raw_ostream &OS, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const =0
EncodeInstruction - Encode the given Inst to bytes on the output stream OS.
Base class for the full range of assembler expressions which are needed for parsing.
Name of external global symbol.
Represent a reference to a symbol from inside an expression.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const char * getSymbolName() const
#define CASE_ALL_MOV_RM()
unsigned getReg() const
Returns the register number.
Context object for machine code objects.
void recordFaultingOp(FaultKind FaultTy, const MCSymbol *HandlerLabel)
virtual void AddComment(const Twine &T, bool EOL=true)
Add a textual comment.
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register...
Type * getType() const
All values are typed, get the type of this value.
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
bool isPositionIndependent() const
MO_GOT - On a symbol operand this indicates that the immediate is the offset to the GOT entry for the...
MO_GOTTPOFF - On a symbol operand this indicates that the immediate is the offset of the GOT entry wi...
MO_ABS8 - On a symbol operand this indicates that the symbol is known to be an absolute symbol in ran...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
virtual void emitRawComment(const Twine &T, bool TabPrefix=true)
Print T and prefix it with the comment string (normally #) and optionally a tab.
This class is a data container for one entry in a MachineConstantPool.
virtual void EmitBinaryData(StringRef Data)
Functionally identical to EmitBytes.
const MCExpr * getExpr() const
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
MO_DARWIN_NONLAZY - On a symbol operand "FOO", this indicates that the reference is actually to the "...
void recordStatepoint(const MachineInstr &MI)
Generate a stackmap record for a statepoint instruction.
Instances of this class represent a single low-level machine instruction.
auto count(R &&Range, const E &Element) -> typename std::iterator_traits< decltype(adl_begin(Range))>::difference_type
Wrapper function around std::count to count the number of times an element Element occurs in the give...
bool isX86_64ExtendedReg(unsigned RegNo)
isX86_64ExtendedReg - Is the MachineOperand a x86-64 extended (r8 or higher) register? e.g.
const Constant * ConstVal
This class is intended to be used as a base class for asm properties and features specific to the tar...
Address of a global value.
Streaming machine code generation interface.
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
MCTargetStreamer * getTargetStreamer()
bool getAsmPrinterFlag(CommentFlag Flag) const
Return whether an AsmPrinter flag is set.
MO_GOT_ABSOLUTE_ADDRESS - On a symbol operand, this represents a relocation of: SYMBOL_LABEL + [...
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.
void DecodeVPPERMMask(ArrayRef< uint64_t > RawMask, SmallVectorImpl< int > &ShuffleMask)
Decode a VPPERM mask from a raw array of constants such as from BUILD_VECTOR.
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.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
unsigned getFlags() const
const GlobalValue * getGlobal() const
MO_TLSLDM - On a symbol operand this indicates that the immediate is the offset of the GOT entry with...
MCCodeEmitter - Generic instruction encoding interface.
void DecodeVPERMIL2PMask(unsigned NumElts, unsigned ScalarBits, unsigned M2Z, ArrayRef< uint64_t > RawMask, SmallVectorImpl< int > &ShuffleMask)
Decode a VPERMIL2PD/VPERMIL2PS variable mask from a raw array of constants.
TargetMachine & TM
Target machine description.
This class is intended to be used as a driving class for all asm writers.
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV) const
bool hasInternalLinkage() const
Address of a basic block.
static void SimplifyShortMoveForm(X86AsmPrinter &Printer, MCInst &Inst, unsigned Opcode)
Simplify things like MOV32rm to MOV32o32a.
MO_NTPOFF - On a symbol operand this indicates that the immediate is the negative thread-pointer offs...
MI-level patchpoint operands.
unsigned getNumOperands() const
int getSEHRegNum(unsigned i) const
void print(raw_ostream &OS, bool IsStandalone=true, bool SkipOpers=false, bool SkipDebugLoc=false, bool AddNewLine=true, const TargetInstrInfo *TII=nullptr) const
Print this MI to OS.
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
static const Constant * getConstantFromPool(const MachineInstr &MI, const MachineOperand &Op)
const MachineBasicBlock & front() const
virtual MCSymbol * GetCPISymbol(unsigned CPID) const
Return the symbol for the specified constant pool entry.
StubValueTy & getGVStubEntry(MCSymbol *Sym)
virtual void EmitWinCFISetFrame(unsigned Register, unsigned Offset, SMLoc Loc=SMLoc())
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void recordPatchPoint(const MachineInstr &MI)
Generate a stackmap record for a patchpoint instruction.
MO_TLSGD - On a symbol operand this indicates that the immediate is the offset of the GOT entry with ...
const std::vector< MachineConstantPoolEntry > & getConstants() const
virtual void EmitWinCFIPushFrame(bool Code, SMLoc Loc=SMLoc())
MO_TPOFF - On a symbol operand this indicates that the immediate is the thread-pointer offset for the...
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
void setFlags(unsigned F)
void setOpcode(unsigned Op)
MCSymbol * GetBlockAddressSymbol(const BlockAddress *BA) const
Return the MCSymbol used to satisfy BlockAddress uses of the specified basic block.
bool isJTI() const
isJTI - Tests if this is a MO_JumpTableIndex operand.
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
MCSymbol * getSymbol(const GlobalValue *GV) const
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 EmitWinCFIEndProlog(SMLoc Loc=SMLoc())
virtual void EmitCodeAlignment(unsigned ByteAlignment, unsigned MaxBytesToEmit=0)
Emit nops until the byte alignment ByteAlignment is reached.
const MCOperand & getOperand(unsigned i) const
virtual void EmitWinCFIAllocStack(unsigned Size, SMLoc Loc=SMLoc())
X86 target streamer implementing x86-only assembly directives.
MCSymbol reference (for debug/eh info)
Target - Wrapper for Target specific information.
void recordStackMap(const MachineInstr &MI)
Generate a stackmap record for a stackmap instruction.
virtual bool emitFPOEndPrologue(SMLoc L={})=0
CATCHRET - Represents a return from a catch block funclet.
const MachineBasicBlock * getParent() const
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MO_GOTOFF - On a symbol operand this indicates that the immediate is the offset to the location of th...
static unsigned getRetOpcode(const X86Subtarget &Subtarget)
unsigned getNumFrameInfos()
MCSymbol * GetJTISymbol(unsigned JTID, bool isLinkerPrivate=false) const
Return the symbol for the specified jump table entry.
MO_INDNTPOFF - On a symbol operand this indicates that the immediate is the absolute address of the G...
union llvm::MachineConstantPoolEntry::@146 Val
The constant itself.
virtual void EmitWinCFISaveReg(unsigned Register, unsigned Offset, SMLoc Loc=SMLoc())
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
LLVM_NODISCARD bool empty() const
int64_t getOffset() const
Return the offset from the symbol in this operand.
const BlockAddress * getBlockAddress() const
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
Generic base class for all target subtargets.
MI-level Statepoint operands.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given patchpoint should emit.
void EmitInstruction(const MachineInstr *MI) override
Targets should implement this to emit instructions.
bool isSymbol() const
isSymbol - Tests if this is a MO_ExternalSymbol operand.
MachineModuleInfoMachO - This is a MachineModuleInfoImpl implementation for MachO targets...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents 'eh_return' gcc dwarf builtin...
MO_PLT - On a symbol operand this indicates that the immediate is offset to the PLT entry of symbol n...
void DecodePSHUFBMask(ArrayRef< uint64_t > RawMask, SmallVectorImpl< int > &ShuffleMask)
Decode a PSHUFB mask from a raw array of constants such as from BUILD_VECTOR.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A raw_ostream that writes to an std::string.
MCSymbol * getMCSymbol() const
mop_iterator operands_begin()
ArrayRef< MCDwarfFrameInfo > getDwarfFrameInfos() const
MCSymbol * getPICBaseSymbol() const
getPICBaseSymbol - Return a function-local symbol to represent the PIC base.
static void printConstant(const Constant *COp, raw_ostream &CS)
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
bool useRetpoline() const
This class implements an extremely fast bulk output stream that can only output to a stream...
AddrSegmentReg - The operand # of the segment in the memory operand.
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...
void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable's name.
static MachineBasicBlock::const_iterator PrevCrossBBInst(MachineBasicBlock::const_iterator MBBI)
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.
bool isMBB() const
isMBB - Tests if this is a MO_MachineBasicBlock operand.
Address of indexed Constant in Constant Pool.
static MCSymbol * GetSymbolFromOperand(const MachineOperand &MO, AsmPrinter &AP)
unsigned getOpcode() const
virtual bool isVerboseAsm() const
Return true if this streamer supports verbose assembly and if it is enabled.
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)
static unsigned EmitNop(MCStreamer &OS, unsigned NumBytes, bool Is64Bit, const MCSubtargetInfo &STI)
Emit the largest nop instruction smaller than or equal to NumBytes bytes.
const X86Subtarget & getSubtarget() const
static void SimplifyShortImmForm(MCInst &Inst, unsigned Opcode)
Simplify FOO $imm, %{al,ax,eax,rax} to FOO $imm, for instruction with a short fixed-register form...
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment)
static void SimplifyMOVSX(MCInst &Inst)
If a movsx instruction has a shorter encoding for the used register simplify the instruction to use i...
uint8_t getAsmPrinterFlags() const
Return the asm printer flags bitvector.
MO_DLLIMPORT - On a symbol operand "FOO", this indicates that the reference is actually to the "__imp...