LLVM: lib/Target/X86/X86AsmPrinter.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

53

54using namespace llvm;

55

57 std::unique_ptr Streamer)

59

60

61

62

63

64

65

68 PSI = &PSIW->getPSI();

70 SDPI = &SDPIW->getStaticDataProfileInfo();

71

73

74 SMShadowTracker.startFunction(MF);

75 CodeEmitter.reset(TM.getTarget().createMCCodeEmitter(

76 *Subtarget->getInstrInfo(), MF.getContext()));

77

78 const Module *M = MF.getFunction().getParent();

79 EmitFPOData = Subtarget->isTargetWin32() && M->getCodeViewFlag();

80

81 IndCSPrefix = M->getModuleFlag("indirect_branch_cs_prefix");

82

84

85 if (Subtarget->isTargetCOFF()) {

86 bool Local = MF.getFunction().hasLocalLinkage();

93 }

94

95

97

98

100

101 EmitFPOData = false;

102

103 IndCSPrefix = false;

104

105

106 return false;

107}

108

110 if (EmitFPOData) {

111 auto *XTS =

116 }

117}

118

120 if (EmitFPOData) {

121 auto *XTS =

124 }

125}

126

128

129 const uint32_t InvalidValues[] = {

130 0xFA1E0FF3,

131 0xFB1E0FF3,

132 };

133 for (uint32_t N : InvalidValues) {

134

135

137 return Value + 1;

138 }

140}

141

142void X86AsmPrinter::EmitKCFITypePadding(const MachineFunction &MF,

143 bool HasType) {

144

145

146 int64_t PrefixBytes = 0;

147 (void)MF.getFunction()

148 .getFnAttribute("patchable-function-prefix")

149 .getValueAsString()

150 .getAsInteger(10, PrefixBytes);

151

152

153

154

155 if (HasType)

156 PrefixBytes += 5;

157

159}

160

161

162

165 if (F.getParent()->getModuleFlag("kcfi"))

166 return;

167

169 if (const MDNode *MD = F.getMetadata(LLVMContext::MD_kcfi_type))

171

172

173

175 EmitKCFITypePadding(MF, false);

176 return;

177 }

178

179

180

181

182

185 if (MAI->hasDotTypeDotSizeDirective())

188

189

190

191 EmitKCFITypePadding(MF);

192 unsigned DestReg = X86::EAX;

193

194 if (F.getParent()->getModuleFlag("kcfi-arity")) {

195

196 [[maybe_unused]] const auto &Triple = MF.getTarget().getTargetTriple();

198

199

200

201

202

203

204

205

206

207 const unsigned ArityToRegMap[8] = {X86::EAX, X86::ECX, X86::EDX, X86::EBX,

208 X86::ESP, X86::EBP, X86::ESI, X86::EDI};

209 int Arity;

211 Arity = 7;

212 } else {

213 Arity = 0;

214 for (const auto &LI : MF.getRegInfo().liveins()) {

215 auto Reg = LI.first;

216 if (X86::GR8RegClass.contains(Reg) || X86::GR16RegClass.contains(Reg) ||

217 X86::GR32RegClass.contains(Reg) ||

218 X86::GR64RegClass.contains(Reg)) {

219 ++Arity;

220 }

221 }

222 }

223 DestReg = ArityToRegMap[Arity];

224 }

225

226 EmitAndCountInstruction(MCInstBuilder(X86::MOV32ri)

227 .addReg(DestReg)

228 .addImm(MaskKCFIType(Type->getZExtValue())));

229

230 if (MAI->hasDotTypeDotSizeDirective()) {

233

237 OutStreamer->emitELFSize(FnSym, SizeExp);

238 }

239}

240

241

242

243

244void X86AsmPrinter::PrintSymbolOperand(const MachineOperand &MO,

251 break;

254

259 else

261

262

266 GVSym =

268

277 }

278

279

280

281 if (GVSym->getName()[0] != '$')

283 else {

284 O << '(';

286 O << ')';

287 }

289 break;

290 }

291 }

292

294 default:

297 break;

301

302 break;

304 O << " + [.-";

305 MF->getPICBaseSymbol()->print(O, MAI);

306 O << ']';

307 break;

310 O << '-';

311 MF->getPICBaseSymbol()->print(O, MAI);

312 break;

329 O << "@TLVP" << '-';

330 MF->getPICBaseSymbol()->print(O, MAI);

331 break;

333 }

334}

335

336void X86AsmPrinter::PrintOperand(const MachineInstr *MI, unsigned OpNo,

338 const MachineOperand &MO = MI->getOperand(OpNo);

343 if (IsATT)

344 O << '%';

346 return;

347 }

348

350 if (IsATT)

351 O << '$';

353 return;

354

357 switch (MI->getInlineAsmDialect()) {

359 O << '$';

360 break;

362 O << "offset ";

363 break;

364 }

365 PrintSymbolOperand(MO, O);

366 break;

367 }

371 break;

372 }

373 }

374}

375

376

377

378

379void X86AsmPrinter::PrintModifiedOperand(const MachineInstr *MI, unsigned OpNo,

381 const MachineOperand &MO = MI->getOperand(OpNo);

383 return PrintOperand(MI, OpNo, O);

385 O << '%';

388 unsigned Size = (Modifier == "64") ? 64

389 : (Modifier == "32") ? 32

390 : (Modifier == "16") ? 16

391 : 8;

393 }

395}

396

397

398

399

400void X86AsmPrinter::PrintPCRelImm(const MachineInstr *MI, unsigned OpNo,

402 const MachineOperand &MO = MI->getOperand(OpNo);

404 default: llvm_unreachable("Unknown pcrel immediate operand");

406

407 PrintOperand(MI, OpNo, O);

408 return;

411 return;

413 PrintSymbolOperand(MO, O);

414 return;

415 }

416}

417

418void X86AsmPrinter::PrintLeaMemReference(const MachineInstr *MI, unsigned OpNo,

421 const MachineOperand &IndexReg = MI->getOperand(OpNo + X86::AddrIndexReg);

422 const MachineOperand &DispSpec = MI->getOperand(OpNo + X86::AddrDisp);

423

424

425 bool HasBaseReg = BaseReg.getReg() != 0;

426 if (HasBaseReg && Modifier == "no-rip" && BaseReg.getReg() == X86::RIP)

427 HasBaseReg = false;

428

429

430 bool HasParenPart = IndexReg.getReg() || HasBaseReg;

431

432 switch (DispSpec.getType()) {

433 default:

436 int DispVal = DispSpec.getImm();

437 if (DispVal || !HasParenPart)

438 O << DispVal;

439 break;

440 }

443 PrintSymbolOperand(DispSpec, O);

444 break;

445 }

446

447 if (Modifier == "H")

448 O << "+8";

449

450 if (HasParenPart) {

452 "X86 doesn't allow scaling by ESP");

453

454 O << '(';

455 if (HasBaseReg)

457

458 if (IndexReg.getReg()) {

459 O << ',';

462 if (ScaleVal != 1)

463 O << ',' << ScaleVal;

464 }

465 O << ')';

466 }

467}

468

470

471 return MI.getDesc().isReturn() && MI.getDesc().isCall();

472}

473

475 unsigned Opc = MI.getOpcode();

476 return MI.getDesc().isIndirectBranch() ||

477 Opc == X86::TAILJMPr || Opc == X86::TAILJMPm ||

478 Opc == X86::TAILJMPr64 || Opc == X86::TAILJMPm64 ||

479 Opc == X86::TCRETURNri || Opc == X86::TCRETURN_WIN64ri ||

480 Opc == X86::TCRETURN_HIPE32ri || Opc == X86::TCRETURNmi ||

481 Opc == X86::TCRETURN_WINmi64 || Opc == X86::TCRETURNri64 ||

482 Opc == X86::TCRETURNmi64 || Opc == X86::TCRETURNri64_ImpCall ||

483 Opc == X86::TAILJMPr64_REX || Opc == X86::TAILJMPm64_REX;

484}

485

487 if (Subtarget->hardenSlsRet() || Subtarget->hardenSlsIJmp()) {

488 auto I = MBB.getLastNonDebugInstr();

489 if (I != MBB.end()) {

495 }

496 }

497 }

500}

501

502void X86AsmPrinter::PrintMemReference(const MachineInstr *MI, unsigned OpNo,

504 assert(isMem(*MI, OpNo) && "Invalid memory reference!");

506 if (Segment.getReg()) {

508 O << ':';

509 }

510 PrintLeaMemReference(MI, OpNo, O, Modifier);

511}

512

513void X86AsmPrinter::PrintIntelMemReference(const MachineInstr *MI,

518 const MachineOperand &IndexReg = MI->getOperand(OpNo + X86::AddrIndexReg);

519 const MachineOperand &DispSpec = MI->getOperand(OpNo + X86::AddrDisp);

521

522

523 bool HasBaseReg = BaseReg.getReg() != 0;

524 if (HasBaseReg && Modifier == "no-rip" && BaseReg.getReg() == X86::RIP)

525 HasBaseReg = false;

526

527

528 if ((DispSpec.isGlobal() || DispSpec.isSymbol()) && Modifier == "disp-only") {

529 HasBaseReg = false;

530 }

531

532

533 if (SegReg.getReg()) {

535 O << ':';

536 }

537

538 O << '[';

539

540 bool NeedPlus = false;

541 if (HasBaseReg) {

543 NeedPlus = true;

544 }

545

546 if (IndexReg.getReg()) {

547 if (NeedPlus) O << " + ";

548 if (ScaleVal != 1)

549 O << ScaleVal << '*';

551 NeedPlus = true;

552 }

553

554 if (!DispSpec.isImm()) {

555 if (NeedPlus) O << " + ";

556

557

558 PrintSymbolOperand(DispSpec, O);

559 } else {

560 int64_t DispVal = DispSpec.getImm();

561 if (DispVal || (!IndexReg.getReg() && !HasBaseReg)) {

562 if (NeedPlus) {

563 if (DispVal > 0)

564 O << " + ";

565 else {

566 O << " - ";

567 DispVal = -DispVal;

568 }

569 }

570 O << DispVal;

571 }

572 }

573 O << ']';

574}

575

578 return Subtarget;

579}

580

581void X86AsmPrinter::emitMachOIFuncStubBody(Module &M, const GlobalIFunc &GI,

583

584

585

587 MCInstBuilder(X86::JMP32m)

588 .addReg(X86::RIP)

589 .addImm(1)

590 .addReg(0)

593 .addReg(0),

594 *Subtarget);

595}

596

597void X86AsmPrinter::emitMachOIFuncStubHelperBody(Module &M,

600

601

602

603

604

605

606

607

608

609

610

611

612

613

614

615

616

617

618

619 for (int Reg :

620 {X86::RAX, X86::RDI, X86::RSI, X86::RDX, X86::RCX, X86::R8, X86::R9})

621 OutStreamer->emitInstruction(MCInstBuilder(X86::PUSH64r).addReg(Reg),

622 *Subtarget);

623

625 MCInstBuilder(X86::CALL64pcrel32)

627 *Subtarget);

628

630 MCInstBuilder(X86::MOV64mr)

631 .addReg(X86::RIP)

632 .addImm(1)

633 .addReg(0)

636 .addReg(0)

637 .addReg(X86::RAX),

638 *Subtarget);

639

640 for (int Reg :

641 {X86::R9, X86::R8, X86::RCX, X86::RDX, X86::RSI, X86::RDI, X86::RAX})

642 OutStreamer->emitInstruction(MCInstBuilder(X86::POP64r).addReg(Reg),

643 *Subtarget);

644

646 MCInstBuilder(X86::JMP32m)

647 .addReg(X86::RIP)

648 .addImm(1)

649 .addReg(0)

652 .addReg(0),

653 *Subtarget);

654}

655

660

665 return true;

666

667 switch (Mode) {

668 default: return true;

669 case 'b':

671 break;

672 case 'h':

674 if (Reg.isValid())

675 return true;

676 break;

677 case 'w':

679 break;

680 case 'k':

682 break;

683 case 'V':

684 EmitPercent = false;

685 [[fallthrough]];

686 case 'q':

687

688

690 break;

691 }

692

693 if (EmitPercent)

694 O << '%';

695

697 return false;

698}

699

704

705 unsigned Index;

707 Index = Reg - X86::XMM0;

708 else if (X86::VR256XRegClass.contains(Reg))

709 Index = Reg - X86::YMM0;

710 else if (X86::VR512RegClass.contains(Reg))

711 Index = Reg - X86::ZMM0;

712 else

713 return true;

714

715 switch (Mode) {

716 default:

717 return true;

718 case 'x':

719 Reg = X86::XMM0 + Index;

720 break;

721 case 't':

722 Reg = X86::YMM0 + Index;

723 break;

724 case 'g':

725 Reg = X86::ZMM0 + Index;

726 break;

727 }

728

729 if (EmitPercent)

730 O << '%';

731

733 return false;

734}

735

736

737

740

741 if (ExtraCode && ExtraCode[0]) {

742 if (ExtraCode[1] != 0) return true;

743

745

746 switch (ExtraCode[0]) {

747 default:

748

750 case 'a':

752 default:

753 return true;

756 return false;

762 PrintSymbolOperand(MO, O);

763 if (Subtarget->is64Bit())

764 O << "(%rip)";

765 return false;

767 O << '(';

768 PrintOperand(MI, OpNo, O);

769 O << ')';

770 return false;

771 }

772

773 case 'c':

775 default:

776 PrintOperand(MI, OpNo, O);

777 break;

780 break;

786 PrintSymbolOperand(MO, O);

787 break;

788 }

789 return false;

790

791 case 'A':

792 if (MO.isReg()) {

793 O << '*';

794 PrintOperand(MI, OpNo, O);

795 return false;

796 }

797 return true;

798

799 case 'b':

800 case 'h':

801 case 'w':

802 case 'k':

803 case 'q':

804 case 'V':

807 PrintOperand(MI, OpNo, O);

808 return false;

809

810 case 'x':

811 case 't':

812 case 'g':

815 PrintOperand(MI, OpNo, O);

816 return false;

817

818 case 'p': {

821 return true;

822 PrintSymbolOperand(MO, O);

823 return false;

824 }

825

826 case 'P':

827 PrintPCRelImm(MI, OpNo, O);

828 return false;

829

830 case 'n':

831

832

833 if (MO.isImm()) {

835 return false;

836 }

837 O << '-';

838 }

839 }

840

841 PrintOperand(MI, OpNo, O);

842 return false;

843}

844

846 const char *ExtraCode,

848 if (ExtraCode && ExtraCode[0]) {

849 if (ExtraCode[1] != 0) return true;

850

851 switch (ExtraCode[0]) {

852 default: return true;

853 case 'b':

854 case 'h':

855 case 'w':

856 case 'k':

857 case 'q':

858

859 break;

860 case 'H':

862 return true;

863 } else {

864 PrintMemReference(MI, OpNo, O, "H");

865 }

866 return false;

867

868

869

870 case 'P':

872 PrintIntelMemReference(MI, OpNo, O, "disp-only");

873 } else {

874 PrintMemReference(MI, OpNo, O, "disp-only");

875 }

876 return false;

877 }

878 }

880 PrintIntelMemReference(MI, OpNo, O);

881 } else {

882 PrintMemReference(MI, OpNo, O);

883 }

884 return false;

885}

886

888 const Triple &TT = TM.getTargetTriple();

889

890 if (TT.isOSBinFormatELF()) {

891

892 unsigned FeatureFlagsAnd = 0;

893 if (M.getModuleFlag("cf-protection-branch"))

895 if (M.getModuleFlag("cf-protection-return"))

897

898 if (FeatureFlagsAnd) {

899

900 assert((TT.isX86_32() || TT.isX86_64()) &&

901 "CFProtection used on invalid architecture!");

903 MCSection *Nt = MMI->getContext().getELFSection(

906

907

908 const int WordSize = TT.isX86_64() && !TT.isX32() ? 8 : 4;

910 OutStreamer->emitIntValue(4, 4 );

911 OutStreamer->emitIntValue(8 + WordSize, 4 );

914

915

918 OutStreamer->emitInt32(FeatureFlagsAnd);

920

922 }

923 }

924

925 if (TT.isOSBinFormatMachO())

927

928 if (TT.isOSBinFormatCOFF()) {

931

932 if (M.getModuleFlag("import-call-optimization"))

933 EnableImportCallOptimization = true;

934 }

936

937

938

940 if (M.getModuleInlineAsm().empty() && is16) {

941 auto *XTS =

944 }

945}

946

947static void

950

951 OutStreamer.emitLabel(StubLabel);

952

954

956

958 else

959

960

961

962

963

964

967 4 );

968}

969

971

974

975

977

978

980 if (!Stubs.empty()) {

984

985 for (auto &Stub : Stubs)

987

988 Stubs.clear();

990 }

991}

992

993

994

995

996

997

998

999

1001

1002 if (!TT.isWindowsMSVCEnvironment())

1003 return false;

1004

1007 if (I.getType()->isFloatingPointTy())

1008 return true;

1009

1010 for (const auto &Op : I.operands()) {

1011 if (Op->getType()->isFloatingPointTy())

1012 return true;

1013 }

1014 }

1015 }

1016

1017 return false;

1018}

1019

1021 const Triple &TT = TM.getTargetTriple();

1022

1023 if (TT.isOSBinFormatMachO()) {

1024

1025

1027

1028

1029 FM.serializeToFaultMapSection();

1030

1031

1032

1033

1034

1035

1036 OutStreamer->emitSubsectionsViaSymbols();

1037 } else if (TT.isOSBinFormatCOFF()) {

1038

1039

1040 if (EnableImportCallOptimization) {

1042

1043

1044 constexpr char ImpCallMagic[12] = "RetpolineV1";

1046

1047

1048

1049

1050

1051

1052

1053

1054 for (auto &[Section, CallsToImportedFuncs] :

1055 SectionToImportedFunctionCalls) {

1056 unsigned SectionSize =

1057 sizeof(uint32_t) * (2 + 2 * CallsToImportedFuncs.size());

1059 OutStreamer->emitCOFFSecNumber(Section->getBeginSymbol());

1060 for (auto &[CallsiteSymbol, Kind] : CallsToImportedFuncs) {

1062 OutStreamer->emitCOFFSecOffset(CallsiteSymbol);

1063 }

1064 }

1065 }

1066

1068

1069

1070

1071

1072

1073

1074

1075

1076

1077

1078

1079

1080

1082 (TT.getArch() == Triple::x86) ? "__fltused" : "_fltused";

1083 MCSymbol *S = MMI->getContext().getOrCreateSymbol(SymbolName);

1085 return;

1086 }

1087 } else if (TT.isOSBinFormatELF()) {

1088 FM.serializeToFaultMapSection();

1089 }

1090

1091

1093 if (MCSymbol *AddrSymbol = OutContext.lookupSymbol("__morestack_addr")) {

1094 Align Alignment(1);

1097 nullptr, Alignment);

1098 OutStreamer->switchSection(ReadOnlySection);

1100

1101 unsigned PtrSize = MAI->getCodePointerSize();

1103 PtrSize);

1104 }

1105 }

1106}

1107

1109

1111 false)

1112

1113

1114

1115

1116

1117

1118extern "C" LLVM_C_ABI void LLVMInitializeX86AsmPrinter() {

1121}

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

static MCDisassembler::DecodeStatus addOperand(MCInst &Inst, const MCOperand &Opnd)

static void emitNonLazySymbolPointer(MCStreamer &OutStreamer, MCSymbol *StubLabel, MachineModuleInfoImpl::StubValueTy &MCSym)

Expand Atomic instructions

Module.h This file contains the declarations for the Module class.

This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...

Promote Memory to Register

#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)

static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))

static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)

static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")

static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")

#define LLVM_C_ABI

LLVM_C_ABI is the export/visibility macro used to mark symbols declared in llvm-c as exported when bu...

static bool printAsmMRegister(const X86AsmPrinter &P, const MachineOperand &MO, char Mode, raw_ostream &O)

Definition X86AsmPrinter.cpp:656

static bool isSimpleReturn(const MachineInstr &MI)

Definition X86AsmPrinter.cpp:469

static bool usesMSVCFloatingPoint(const Triple &TT, const Module &M)

True if this module is being built for windows/msvc, and uses floating point.

Definition X86AsmPrinter.cpp:1000

static bool isIndirectBranchOrTailCall(const MachineInstr &MI)

Definition X86AsmPrinter.cpp:474

static bool printAsmVRegister(const MachineOperand &MO, char Mode, raw_ostream &O)

Definition X86AsmPrinter.cpp:700

static void emitNonLazyStubs(MachineModuleInfo *MMI, MCStreamer &OutStreamer)

Definition X86AsmPrinter.cpp:970

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 emitNops(unsigned N)

Emit N NOP instructions.

void EmitToStreamer(MCStreamer &S, const MCInst &Inst)

TargetMachine & TM

Target machine description.

void emitXRayTable()

Emit a table with all XRay instrumentation points.

virtual void emitBasicBlockEnd(const MachineBasicBlock &MBB)

Targets can override this to emit stuff at the end of a basic block.

virtual MCSymbol * GetCPISymbol(unsigned CPID) const

Return the symbol for the specified constant pool entry.

const MCAsmInfo * MAI

Target Asm Printer information.

MachineFunction * MF

The current machine function.

virtual const MCExpr * lowerConstant(const Constant *CV, const Constant *BaseCV=nullptr, uint64_t Offset=0)

Lower the specified LLVM Constant to an MCExpr.

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.

AsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer, char &ID=AsmPrinter::ID)

void printOffset(int64_t Offset, raw_ostream &OS) const

This is just convenient handler for printing offsets.

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.

const StaticDataProfileInfo * SDPI

Provides the profile information for constants.

virtual const MCSubtargetInfo * getIFuncMCSubtargetInfo() const

getSubtargetInfo() cannot be used where this is needed because we don't have a MachineFunction when w...

std::unique_ptr< MCStreamer > OutStreamer

This is the MCStreamer object for the file we are generating.

const ProfileSummaryInfo * PSI

The profile summary information.

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.

void emitCOFFFeatureSymbol(Module &M)

Emits the @feat.00 symbol indicating the features enabled in this module.

MCSymbol * GetExternalSymbolSymbol(const Twine &Sym) const

Return the MCSymbol for the specified ExternalSymbol.

const MCSubtargetInfo & getSubtargetInfo() const

Return information about subtarget.

void emitCOFFReplaceableFunctionData(Module &M)

Emits symbols and data to allow functions marked with the loader-replaceable attribute to be replacea...

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.

This is the shared class of boolean and integer constants.

const Constant * getResolver() const

bool hasInternalLinkage() const

static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)

LLVM_ABI MCSectionMachO * getMachOSection(StringRef Segment, StringRef Section, unsigned TypeAndAttributes, unsigned Reserved2, SectionKind K, const char *BeginSymName=nullptr)

Return the MCSection for the specified mach-o section.

LLVM_ABI 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.

Instances of this class represent a single low-level machine instruction.

void setOpcode(unsigned Op)

static MCOperand createExpr(const MCExpr *Val)

Instances of this class represent a uniqued identifier for a section in the current translation unit.

Streaming machine code generation interface.

virtual void addBlankLine()

Emit a blank line to a .s file to pretty it up.

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.

virtual void switchSection(MCSection *Section, uint32_t Subsec=0)

Set the current section where code is being emitted to Section.

Generic base class for all target subtargets.

static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())

MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...

LLVM_ABI 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.

Representation of each machine instruction.

LLVM_ABI InlineAsm::AsmDialect getInlineAsmDialect() const

std::vector< std::pair< MCSymbol *, StubValueTy > > SymbolListTy

PointerIntPair< MCSymbol *, 1, bool > StubValueTy

MachineModuleInfoMachO - This is a MachineModuleInfoImpl implementation for MachO targets.

SymbolListTy GetGVStubList()

Accessor methods to return the set of stubs in sorted order.

This class contains meta information specific to a module.

const MCContext & getContext() 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.

const GlobalValue * getGlobal() const

bool isReg() const

isReg - Tests if this is a MO_Register operand.

bool isImm() const

isImm - Tests if this is a MO_Immediate operand.

bool isSymbol() const

isSymbol - Tests if this is a MO_ExternalSymbol operand.

const BlockAddress * getBlockAddress() const

MachineInstr * getParent()

getParent - Return the instruction that this operand belongs to.

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_BlockAddress

Address of a basic block.

@ MO_Register

Register operand.

@ MO_ExternalSymbol

Name of external global symbol.

@ MO_JumpTableIndex

Address of indexed Jump Table for switch.

int64_t getOffset() const

Return the offset from the symbol in this operand.

A Module instance is used to store all the information related to an LLVM module.

AnalysisType * getAnalysisIfAvailable() const

getAnalysisIfAvailable() - Subclasses use this function to get analysis information tha...

PointerTy getPointer() const

Wrapper class representing virtual and physical registers.

static SectionKind getMetadata()

static SectionKind getReadOnly()

StringRef - Represent a constant reference to a string, i.e.

constexpr bool empty() const

empty - Check if the string is empty.

bool consume_front(StringRef Prefix)

Returns true if this StringRef has the given prefix and removes that prefix.

virtual MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment) const

Given a constant with the SectionKind, return a section that it should be placed in.

Primary interface to the complete machine description for the target machine.

Triple - Helper class for working with autoconf configuration names.

bool isX86_64() const

Tests whether the target is x86 (64-bit).

bool isOSWindows() const

Tests whether the OS is Windows.

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.

static const char * getRegisterName(MCRegister Reg)

bool runOnMachineFunction(MachineFunction &MF) override

runOnMachineFunction - Emit the function body.

Definition X86AsmPrinter.cpp:66

void emitKCFITypeId(const MachineFunction &MF) override

emitKCFITypeId - Emit the KCFI type information in architecture specific format.

Definition X86AsmPrinter.cpp:163

void emitStartOfAsmFile(Module &M) override

This virtual method can be overridden by targets that want to emit something at the start of their fi...

Definition X86AsmPrinter.cpp:887

void emitEndOfAsmFile(Module &M) override

This virtual method can be overridden by targets that want to emit something at the end of their file...

Definition X86AsmPrinter.cpp:1020

void emitFunctionBodyEnd() override

Targets can override this to emit stuff after the last basic block in the function.

Definition X86AsmPrinter.cpp:119

bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &O) override

Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...

Definition X86AsmPrinter.cpp:845

void emitBasicBlockEnd(const MachineBasicBlock &MBB) override

Targets can override this to emit stuff at the end of a basic block.

Definition X86AsmPrinter.cpp:486

X86AsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)

Definition X86AsmPrinter.cpp:56

bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &O) override

PrintAsmOperand - Print out an operand for an inline asm expression.

Definition X86AsmPrinter.cpp:738

void emitFunctionBodyStart() override

Targets can override this to emit stuff before the first basic block in the function.

Definition X86AsmPrinter.cpp:109

X86MachineFunctionInfo - This class is derived from MachineFunction and contains private X86 target-s...

unsigned getArgumentStackSize() const

X86 target streamer implementing x86-only assembly directives.

virtual bool emitFPOProc(const MCSymbol *ProcSym, unsigned ParamsSize, SMLoc L={})

virtual void emitCode16()

virtual bool emitFPOEndProc(SMLoc L={})

This class implements an extremely fast bulk output stream that can only output to a stream.

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

@ 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))

@ GNU_PROPERTY_X86_FEATURE_1_AND

@ GNU_PROPERTY_X86_FEATURE_1_SHSTK

@ GNU_PROPERTY_X86_FEATURE_1_IBT

@ S_NON_LAZY_SYMBOL_POINTERS

S_NON_LAZY_SYMBOL_POINTERS - Section with non-lazy symbol pointers.

@ MO_TLSLD

MO_TLSLD - On a symbol operand this indicates that the immediate is the offset of the GOT entry with ...

@ MO_GOTPCREL_NORELAX

MO_GOTPCREL_NORELAX - Same as MO_GOTPCREL except that R_X86_64_GOTPCREL relocations are guaranteed to...

@ MO_GOTOFF

MO_GOTOFF - On a symbol operand this indicates that the immediate is the offset to the location of th...

@ MO_DARWIN_NONLAZY_PIC_BASE

MO_DARWIN_NONLAZY_PIC_BASE - On a symbol operand "FOO", this indicates that the reference is actually...

@ MO_GOT_ABSOLUTE_ADDRESS

MO_GOT_ABSOLUTE_ADDRESS - On a symbol operand, this represents a relocation of: SYMBOL_LABEL + [.

@ MO_COFFSTUB

MO_COFFSTUB - On a symbol operand "FOO", this indicates that the reference is actually to the "....

@ MO_NTPOFF

MO_NTPOFF - On a symbol operand this indicates that the immediate is the negative thread-pointer offs...

@ MO_DARWIN_NONLAZY

MO_DARWIN_NONLAZY - On a symbol operand "FOO", this indicates that the reference is actually to the "...

@ MO_INDNTPOFF

MO_INDNTPOFF - On a symbol operand this indicates that the immediate is the absolute address of the G...

@ MO_GOTNTPOFF

MO_GOTNTPOFF - On a symbol operand this indicates that the immediate is the offset of the GOT entry w...

@ MO_TPOFF

MO_TPOFF - On a symbol operand this indicates that the immediate is the thread-pointer offset for the...

@ MO_TLVP_PIC_BASE

MO_TLVP_PIC_BASE - On a symbol operand this indicates that the immediate is some TLS offset from the ...

@ MO_GOT

MO_GOT - On a symbol operand this indicates that the immediate is the offset to the GOT entry for the...

@ MO_PLT

MO_PLT - On a symbol operand this indicates that the immediate is offset to the PLT entry of symbol n...

@ MO_TLSGD

MO_TLSGD - On a symbol operand this indicates that the immediate is the offset of the GOT entry with ...

@ MO_NO_FLAG

MO_NO_FLAG - No flag for the operand.

@ MO_TLVP

MO_TLVP - On a symbol operand this indicates that the immediate is some TLS offset.

@ MO_DLLIMPORT

MO_DLLIMPORT - On a symbol operand "FOO", this indicates that the reference is actually to the "__imp...

@ MO_GOTTPOFF

MO_GOTTPOFF - On a symbol operand this indicates that the immediate is the offset of the GOT entry wi...

@ MO_SECREL

MO_SECREL - On a symbol operand this indicates that the immediate is the offset from beginning of sec...

@ MO_DTPOFF

MO_DTPOFF - On a symbol operand this indicates that the immediate is the offset of the GOT entry with...

@ MO_PIC_BASE_OFFSET

MO_PIC_BASE_OFFSET - On a symbol operand this indicates that the immediate should get the value of th...

@ MO_TLSLDM

MO_TLSLDM - On a symbol operand this indicates that the immediate is the offset of the GOT entry with...

@ MO_GOTPCREL

MO_GOTPCREL - On a symbol operand this indicates that the immediate is offset to the GOT entry for th...

std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)

Extract a Value from Metadata.

BaseReg

Stack frame base register. Bit 0 of FREInfo.Info.

This is an optimization pass for GlobalISel generic memory operations.

FunctionAddr VTableAddr Value

static bool isMem(const MachineInstr &MI, unsigned Op)

MCRegister getX86SubSuperRegister(MCRegister Reg, unsigned Size, bool High=false)

Target & getTheX86_32Target()

uint64_t offsetToAlignment(uint64_t Value, Align Alignment)

Returns the offset to the next integer (mod 2**64) that is greater than or equal to Value and is a mu...

DWARFExpression::Operation Op

OutputIt move(R &&Range, OutputIt Out)

Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.

Target & getTheX86_64Target()

@ MCSA_IndirectSymbol

.indirect_symbol (MachO)

@ MCSA_Global

.type _foo, @gnu_unique_object

@ MCSA_ELF_TypeFunction

.type _foo, STT_FUNC # aka @function

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.

RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...