LLVM: lib/Frontend/Offloading/OffloadWrapper.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

30

31#include

32#include

33

34using namespace llvm;

37

38namespace {

39

40constexpr unsigned CudaFatMagic = 0x466243b1;

41constexpr unsigned HIPFatMagic = 0x48495046;

42

44 return M.getDataLayout().getIntPtrType(M.getContext());

45}

46

47

48

49

50

51

52

56 if (!ImageTy)

57 ImageTy =

61 return ImageTy;

62}

63

66}

67

68

69

70

71

72

73

77 if (!DescTy)

81 return DescTy;

82}

83

86}

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

128 bool Relocatable) {

130 auto [EntriesB, EntriesE] = EntryArray;

131

134

135

137 ImagesInits.reserve(Bufs.size());

139

143 ".omp_offloading.device_image" + Suffix);

145 Image->setSection(Relocatable ? ".llvm.offloading.relocatable"

146 : ".llvm.offloading");

148

150

153

154

155

156

157

159 const auto *Header =

161 Binary.bytes_begin());

162 const auto *Entry =

164 Binary.bytes_begin() + Header->EntryOffset);

165 BeginOffset = Entry->ImageOffset;

166 EndOffset = Entry->ImageOffset + Entry->ImageSize;

167 }

168

169 auto *Begin = ConstantInt::get(getSizeTTy(M), BeginOffset);

170 auto *Size = ConstantInt::get(getSizeTTy(M), EndOffset);

173

174 auto *ImageB =

176 auto *ImageE =

178

180 ImageE, EntriesB, EntriesE));

181 }

182

183

185 ArrayType::get(getDeviceImageTy(M), ImagesInits.size()), ImagesInits);

186

187 auto *Images =

188 new GlobalVariable(M, ImagesData->getType(), true,

190 ".omp_offloading.device_images" + Suffix);

192

193 auto *ImagesB =

195

196

198 getBinDescTy(M),

200 EntriesB, EntriesE);

201

202 return new GlobalVariable(M, DescInit->getType(), true,

204 ".omp_offloading.descriptor" + Suffix);

205}

206

213 ".omp_offloading.descriptor_unreg" + Suffix, &M);

214 Func->setSection(".text.startup");

215

216

218 false);

220 M.getOrInsertFunction("__tgt_unregister_lib", UnRegFuncTy);

221

222

224 Builder.CreateCall(UnRegFuncC, BinDesc);

225 Builder.CreateRetVoid();

226

228}

229

235 ".omp_offloading.descriptor_reg" + Suffix, &M);

236 Func->setSection(".text.startup");

237

238

240 false);

242 M.getOrInsertFunction("__tgt_register_lib", RegFuncTy);

243

246 FunctionCallee AtExit = M.getOrInsertFunction("atexit", AtExitTy);

247

248 Function *UnregFunc = createUnregisterFunction(M, BinDesc, Suffix);

249

250

252

253 Builder.CreateCall(RegFuncC, BinDesc);

254

255

256

257

258

259 Builder.CreateCall(AtExit, UnregFunc);

260 Builder.CreateRetVoid();

261

262

264}

265

266

267

268

269

270

271

275 if (!FatbinTy)

279 return FatbinTy;

280}

281

282

283

289

290

291 StringRef FatbinConstantSection =

292 IsHIP ? ".hip_fatbin"

293 : (Triple.isMacOSX() ? "__NV_CUDA,__nv_fatbin" : ".nv_fatbin");

295 auto *Fatbin = new GlobalVariable(M, Data->getType(), true,

297 ".fatbin_image" + Suffix);

298 Fatbin->setSection(FatbinConstantSection);

299

300

301 StringRef FatbinWrapperSection = IsHIP ? ".hipFatBinSegment"

303 : ".nvFatBinSegment";

304 Constant *FatbinWrapper[] = {

305 ConstantInt::get(Type::getInt32Ty(C), IsHIP ? HIPFatMagic : CudaFatMagic),

309

310 Constant *FatbinInitializer =

312

313 auto *FatbinDesc =

316 FatbinInitializer, ".fatbin_wrapper" + Suffix);

317 FatbinDesc->setSection(FatbinWrapperSection);

318 FatbinDesc->setAlignment(Align(8));

319

320 return FatbinDesc;

321}

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349Function *createRegisterGlobalsFunction(Module &M, bool IsHIP,

352 bool EmitSurfacesAndTextures) {

354 auto [EntriesB, EntriesE] = EntryArray;

355

356

362 {Int8PtrPtrTy, Int8PtrTy, Int8PtrTy, Int8PtrTy, Type::getInt32Ty(C),

363 Int8PtrTy, Int8PtrTy, Int8PtrTy, Int8PtrTy, Int32PtrTy},

364 false);

366 IsHIP ? "__hipRegisterFunction" : "__cudaRegisterFunction", RegFuncTy);

367

368

371 {Int8PtrPtrTy, Int8PtrTy, Int8PtrTy, Int8PtrTy, Type::getInt32Ty(C),

373 false);

375 IsHIP ? "__hipRegisterVar" : "__cudaRegisterVar", RegVarTy);

376

377

380 {Int8PtrPtrTy, Int8PtrTy, Int8PtrTy, Int8PtrTy,

382 false);

383 FunctionCallee RegManagedVar = M.getOrInsertFunction(

384 IsHIP ? "__hipRegisterManagedVar" : "__cudaRegisterManagedVar",

385 RegManagedVarTy);

386

387

390 {Int8PtrPtrTy, Int8PtrTy, Int8PtrTy, Int8PtrTy,

392 false);

394 IsHIP ? "__hipRegisterSurface" : "__cudaRegisterSurface", RegSurfaceTy);

395

396

399 {Int8PtrPtrTy, Int8PtrTy, Int8PtrTy, Int8PtrTy, Type::getInt32Ty(C),

401 false);

403 IsHIP ? "__hipRegisterTexture" : "__cudaRegisterTexture", RegTextureTy);

404

406 false);

407 auto *RegGlobalsFn =

409 IsHIP ? ".hip.globals_reg" : ".cuda.globals_reg", &M);

410 RegGlobalsFn->setSection(".text.startup");

411

412

424

425 auto *EntryCmp = Builder.CreateICmpNE(EntriesB, EntriesE);

426 Builder.CreateCondBr(EntryCmp, EntryBB, ExitBB);

427 Builder.SetInsertPoint(EntryBB);

429 auto *AddrPtr =

433 auto *Addr = Builder.CreateLoad(Int8PtrTy, AddrPtr, "addr");

434 auto *AuxAddrPtr =

438 auto *AuxAddr = Builder.CreateLoad(Int8PtrTy, AuxAddrPtr, "aux_addr");

439 auto *KindPtr =

444 auto *NamePtr =

448 auto *Name = Builder.CreateLoad(Int8PtrTy, NamePtr, "name");

449 auto *SizePtr =

454 auto *FlagsPtr =

458 auto *Flags = Builder.CreateLoad(Type::getInt32Ty(C), FlagsPtr, "flags");

459 auto *DataPtr =

463 auto *Data = Builder.CreateTrunc(

466 auto *Type = Builder.CreateAnd(

468

469

470 auto *ExternBit = Builder.CreateAnd(

473 auto *Extern = Builder.CreateLShr(

478 auto *Const = Builder.CreateLShr(

480 auto *NormalizedBit = Builder.CreateAnd(

483 auto *Normalized = Builder.CreateLShr(

484 NormalizedBit, ConstantInt::get(Type::getInt32Ty(C), 5), "normalized");

485 auto *KindCond = Builder.CreateICmpEQ(

489 Builder.CreateCondBr(KindCond, IfKindBB, IfEndBB);

490 Builder.SetInsertPoint(IfKindBB);

491 auto *FnCond = Builder.CreateICmpEQ(

493 Builder.CreateCondBr(FnCond, IfThenBB, IfElseBB);

494

495

496 Builder.SetInsertPoint(IfThenBB);

497 Builder.CreateCall(RegFunc, {RegGlobalsFn->arg_begin(), Addr, Name, Name,

504 Builder.CreateBr(IfEndBB);

505 Builder.SetInsertPoint(IfElseBB);

506

507 auto *Switch = Builder.CreateSwitch(Type, IfEndBB);

508

509 Builder.SetInsertPoint(SwGlobalBB);

510 Builder.CreateCall(RegVar,

513 Builder.CreateBr(IfEndBB);

515 SwGlobalBB);

516

517

518 Builder.SetInsertPoint(SwManagedBB);

519 Builder.CreateCall(RegManagedVar, {RegGlobalsFn->arg_begin(), AuxAddr, Addr,

521 Builder.CreateBr(IfEndBB);

523 SwManagedBB);

524

525 Builder.SetInsertPoint(SwSurfaceBB);

526 if (EmitSurfacesAndTextures)

527 Builder.CreateCall(RegSurface, {RegGlobalsFn->arg_begin(), Addr, Name, Name,

529 Builder.CreateBr(IfEndBB);

531 SwSurfaceBB);

532

533

534 Builder.SetInsertPoint(SwTextureBB);

535 if (EmitSurfacesAndTextures)

536 Builder.CreateCall(RegTexture, {RegGlobalsFn->arg_begin(), Addr, Name, Name,

538 Builder.CreateBr(IfEndBB);

540 SwTextureBB);

541

542 Builder.SetInsertPoint(IfEndBB);

543 auto *NewEntry = Builder.CreateInBoundsGEP(

545 auto *Cmp = Builder.CreateICmpEQ(

546 NewEntry,

550 ConstantInt::get(getSizeTTy(M), 0)})));

551 Entry->addIncoming(

555 ConstantInt::get(getSizeTTy(M), 0)})),

556 &RegGlobalsFn->getEntryBlock());

557 Entry->addIncoming(NewEntry, IfEndBB);

558 Builder.CreateCondBr(Cmp, ExitBB, EntryBB);

559 Builder.SetInsertPoint(ExitBB);

560 Builder.CreateRetVoid();

561

562 return RegGlobalsFn;

563}

564

565

566

570 bool EmitSurfacesAndTextures) {

575 (IsHIP ? ".hip.fatbin_reg" : ".cuda.fatbin_reg") + Suffix, &M);

576 CtorFunc->setSection(".text.startup");

577

581 (IsHIP ? ".hip.fatbin_unreg" : ".cuda.fatbin_unreg") + Suffix, &M);

582 DtorFunc->setSection(".text.startup");

583

585

586

587 auto *RegFatTy = FunctionType::get(PtrTy, PtrTy, false);

589 IsHIP ? "__hipRegisterFatBinary" : "__cudaRegisterFatBinary", RegFatTy);

590

591 auto *RegFatEndTy =

594 M.getOrInsertFunction("__cudaRegisterFatBinaryEnd", RegFatEndTy);

595

596 auto *UnregFatTy =

599 IsHIP ? "__hipUnregisterFatBinary" : "__cudaUnregisterFatBinary",

600 UnregFatTy);

601

602 auto *AtExitTy =

604 FunctionCallee AtExit = M.getOrInsertFunction("atexit", AtExitTy);

605

609 (IsHIP ? ".hip.binary_handle" : ".cuda.binary_handle") + Suffix);

610

611

613 CallInst *Handle = CtorBuilder.CreateCall(

614 RegFatbin,

616 CtorBuilder.CreateAlignedStore(

617 Handle, BinaryHandleGlobal,

618 Align(M.getDataLayout().getPointerTypeSize(PtrTy)));

619 CtorBuilder.CreateCall(createRegisterGlobalsFunction(M, IsHIP, EntryArray,

620 Suffix,

621 EmitSurfacesAndTextures),

622 Handle);

623 if (!IsHIP)

624 CtorBuilder.CreateCall(RegFatbinEnd, Handle);

625 CtorBuilder.CreateCall(AtExit, DtorFunc);

626 CtorBuilder.CreateRetVoid();

627

628

629

630

632 LoadInst *BinaryHandle = DtorBuilder.CreateAlignedLoad(

633 PtrTy, BinaryHandleGlobal,

634 Align(M.getDataLayout().getPointerTypeSize(PtrTy)));

635 DtorBuilder.CreateCall(UnregFatbin, BinaryHandle);

636 DtorBuilder.CreateRetVoid();

637

638

640}

641

642

643class SYCLWrapper {

644public:

645 SYCLWrapper(Module &M, const SYCLJITOptions &Options)

646 : M(M), C(M.getContext()), Options(Options) {

648 SyclDeviceImageTy = getSyclDeviceImageTy();

649 SyclBinDescTy = getSyclBinDescTy();

650 }

651

652

653

654

655

656

657

658

659

660

661

662

663

664

665

666

667

668

669

670

671

672

673

674

675

676

677

678

679

680

681

682

683

684

685

686

687

688

689

690

691

692

693

694

695

696

697

698

699

700

701

702

704 StringRef OffloadKindTag = ".sycl_offloading.";

706 WrappedImages.reserve(OffloadFiles.size());

707 for (size_t I = 0, E = OffloadFiles.size(); I != E; ++I)

709 wrapImage(*OffloadFiles[I].getBinary(), Twine(I), OffloadKindTag));

710

711 return combineWrappedImages(WrappedImages, OffloadKindTag);

712 }

713

714 void createRegisterFatbinFunction(GlobalVariable *FatbinDesc) {

715 FunctionType *FuncTy =

716 FunctionType::get(Type::getVoidTy(C), false);

718 Twine("sycl") + ".descriptor_reg", &M);

719 Func->setSection(".text.startup");

720

721

722 FunctionType *RegFuncTy =

723 FunctionType::get(Type::getVoidTy(C), PointerType::getUnqual(C),

724 false);

725 FunctionCallee RegFuncC =

726 M.getOrInsertFunction("__sycl_register_lib", RegFuncTy);

727

728

730 Builder.CreateCall(RegFuncC, FatbinDesc);

731 Builder.CreateRetVoid();

732

733

735 }

736

737 void createUnregisterFunction(GlobalVariable *FatbinDesc) {

738 FunctionType *FuncTy =

739 FunctionType::get(Type::getVoidTy(C), false);

741 "sycl.descriptor_unreg", &M);

742 Func->setSection(".text.startup");

743

744

745 FunctionType *UnRegFuncTy =

746 FunctionType::get(Type::getVoidTy(C), PointerType::getUnqual(C),

747 false);

748 FunctionCallee UnRegFuncC =

749 M.getOrInsertFunction("__sycl_unregister_lib", UnRegFuncTy);

750

751

753 Builder.CreateCall(UnRegFuncC, FatbinDesc);

754 Builder.CreateRetVoid();

755

756

758 }

759

760private:

762 switch (M.getDataLayout().getPointerSize()) {

763 case 4:

764 return Type::getInt32Ty(C);

765 case 8:

766 return Type::getInt64Ty(C);

767 }

769 }

770

774 ConstantInt::get(SizeTTy, Second)};

775 }

776

777

778

779

780

781

782

783

784

785

786

787

788

789

790

791

792

793

794

795

796

797

798

799

800

801

802

803

804

805

806

807

808

809

810

811 StructType *getSyclDeviceImageTy() {

813 {

814 Type::getInt16Ty(C),

815 Type::getInt8Ty(C),

816 Type::getInt8Ty(C),

817 PointerType::getUnqual(C),

818 PointerType::getUnqual(C),

819 PointerType::getUnqual(C),

820 PointerType::getUnqual(C),

821 PointerType::getUnqual(C),

822 PointerType::getUnqual(C),

823 PointerType::getUnqual(C),

824 PointerType::getUnqual(C),

825 PointerType::getUnqual(C)

826 },

827 "__sycl.tgt_device_image");

828 }

829

830

831

832

833

834

835

836

837

838

839

840

841

842

843

844

845

846 StructType *getSyclBinDescTy() {

848 {Type::getInt16Ty(C), Type::getInt16Ty(C), PointerType::getUnqual(C),

849 PointerType::getUnqual(C), PointerType::getUnqual(C)},

850 "__sycl.tgt_bin_desc");

851 }

852

853

854

855 GlobalVariable *addGlobalArrayVariable(const Twine &Name,

856 ArrayRef Initializer,

857 const Twine &Section = "") {

859 GlobalVariable *Var =

860 new GlobalVariable(M, Arr->getType(), true,

861 GlobalVariable::InternalLinkage, Arr, Name);

862 Var->setUnnamedAddr(GlobalValue::UnnamedAddr::Global);

863

864 SmallVector<char, 32> NameBuf;

868 return Var;

869 }

870

871

872

873

874 std::pair<Constant *, Constant *>

875 addArrayToModule(ArrayRef Buf, const Twine &Name,

876 const Twine &Section = "") {

877 GlobalVariable *Var = addGlobalArrayVariable(Name, Buf, Section);

879 getSizetConstPair(0, 0));

882 return std::make_pair(ImageB, ImageE);

883 }

884

885

886

887

888 Constant *addRawDataToModule(ArrayRef Data, const Twine &Name) {

889 GlobalVariable *Var = addGlobalArrayVariable(Name, Data);

891 getSizetConstPair(0, 0));

892 return DataPtr;

893 }

894

895

896

897

898

899

900 Constant *addStringToModule(StringRef Str, const Twine &Name) {

902 GlobalVariable *Var =

903 new GlobalVariable(M, Arr->getType(), true,

904 GlobalVariable::InternalLinkage, Arr, Name);

905 Var->setUnnamedAddr(GlobalValue::UnnamedAddr::Global);

906 ConstantInt *Zero = ConstantInt::get(getSizeTTy(), 0);

909 }

910

911

912

913

914

915

916 std::pair<Constant *, Constant *>

917 initOffloadEntriesPerImage(StringRef Entries, const Twine &OffloadKindTag) {

920 Entries, "", false);

921 for (line_iterator LI(*MB); !LI.is_at_eof(); ++LI) {

922 GlobalVariable *GV =

925 *LI, 0,

926 0, 0);

928 }

929

931 ArrayType::get(EntryTy, EntriesInits.size()), EntriesInits);

932 GlobalVariable *EntriesGV = new GlobalVariable(

933 M, Arr->getType(), true, GlobalVariable::InternalLinkage,

934 Arr, OffloadKindTag + "entries_arr");

935

937 EntriesGV->getValueType(), EntriesGV, getSizetConstPair(0, 0));

940 getSizetConstPair(0, EntriesInits.size()));

941 return std::make_pair(EntriesB, EntriesE);

942 }

943

944 Constant *wrapImage(const OffloadBinary &OB, const Twine &ImageID,

945 StringRef OffloadKindTag) {

946

947

948

949 constexpr uint16_t DeviceImageStructVersion = 3;

951 ConstantInt::get(Type::getInt16Ty(C), DeviceImageStructVersion);

952 Constant *OffloadKindConstant = ConstantInt::get(

953 Type::getInt8Ty(C), static_cast<uint8_t>(OB.getOffloadKind()));

954 Constant *ImageKindConstant = ConstantInt::get(

955 Type::getInt8Ty(C), static_cast<uint8_t>(OB.getImageKind()));

956 StringRef Triple = OB.getString("triple");

958 addStringToModule(Triple, Twine(OffloadKindTag) + "target." + ImageID);

960 addStringToModule(Options.CompileOptions,

961 Twine(OffloadKindTag) + "opts.compile." + ImageID);

962 Constant *LinkOptions = addStringToModule(

963 Options.LinkOptions, Twine(OffloadKindTag) + "opts.link." + ImageID);

964

965

966 std::pair<Constant *, Constant *> PropertiesConstants = {

969

970 StringRef RawImage = OB.getImage();

971 std::pair<Constant *, Constant *> Binary = addArrayToModule(

972 ArrayRef(RawImage.begin(), RawImage.end()),

973 Twine(OffloadKindTag) + ImageID + ".data", ".llvm.offloading");

974

975

976 std::pair<Constant *, Constant *> ImageEntriesPtrs =

977 initOffloadEntriesPerImage(OB.getString("symbols"), OffloadKindTag);

978

979

980

982 SyclDeviceImageTy, Version, OffloadKindConstant, ImageKindConstant,

983 TripleConstant, CompileOptions, LinkOptions, Binary.first,

984 Binary.second, ImageEntriesPtrs.first, ImageEntriesPtrs.second,

985 PropertiesConstants.first, PropertiesConstants.second);

986

987 return WrappedBinary;

988 }

989

991 StringRef OffloadKindTag) {

993 ArrayType::get(SyclDeviceImageTy, WrappedImages.size()), WrappedImages);

994 GlobalVariable *ImagesGV =

995 new GlobalVariable(M, ImagesData->getType(), true,

997 Twine(OffloadKindTag) + "device_images");

998 ImagesGV->setUnnamedAddr(GlobalValue::UnnamedAddr::Global);

999

1000 ConstantInt *Zero = ConstantInt::get(getSizeTTy(), 0);

1003 ImagesGV, ZeroZero);

1004

1007 static constexpr uint16_t BinDescStructVersion = 1;

1009 SyclBinDescTy,

1010 ConstantInt::get(Type::getInt16Ty(C), BinDescStructVersion),

1011 ConstantInt::get(Type::getInt16Ty(C), WrappedImages.size()), ImagesB,

1012 EntriesB, EntriesE);

1013

1014 return new GlobalVariable(M, DescInit->getType(), true,

1016 Twine(OffloadKindTag) + "descriptor");

1017 }

1018

1020 LLVMContext &C;

1021 SYCLJITOptions Options;

1022

1023 StructType *EntryTy = nullptr;

1024 StructType *SyclDeviceImageTy = nullptr;

1025 StructType *SyclBinDescTy = nullptr;

1026};

1027

1028}

1029

1034 createBinDesc(M, Images, EntryArray, Suffix, Relocatable);

1037 "No binary descriptors created.");

1038 createRegisterFunction(M, Desc, Suffix);

1040}

1041

1045 bool EmitSurfacesAndTextures) {

1046 GlobalVariable *Desc = createFatbinDesc(M, Image, false, Suffix);

1049 "No fatbin section created.");

1050

1051 createRegisterFatbinFunction(M, Desc, false, EntryArray, Suffix,

1052 EmitSurfacesAndTextures);

1054}

1055

1058 bool EmitSurfacesAndTextures) {

1059 GlobalVariable *Desc = createFatbinDesc(M, Image, true, Suffix);

1062 "No fatbin section created.");

1063

1064 createRegisterFatbinFunction(M, Desc, true, EntryArray, Suffix,

1065 EmitSurfacesAndTextures);

1067}

1068

1071 SYCLWrapper W(M, Options);

1073 "");

1076 return E;

1077

1081 "No binary descriptors created.");

1082

1083 W.createRegisterFatbinFunction(Desc);

1084 W.createUnregisterFunction(Desc);

1086}

static IntegerType * getSizeTTy(IRBuilderBase &B, const TargetLibraryInfo *TLI)

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

This file contains the declarations for the subclasses of Constant, which represent the different fla...

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

Machine Check Debug Module

This file defines the SmallVector class.

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

size_t size() const

size - Get the array size.

static LLVM_ABI ArrayType * get(Type *ElementType, uint64_t NumElements)

This static method is the primary way to construct an ArrayType.

static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)

Creates a new BasicBlock.

This class represents a function call, abstracting a target machine's calling convention.

static LLVM_ABI Constant * get(ArrayType *T, ArrayRef< Constant * > V)

static LLVM_ABI Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true)

This method constructs a CDS and initializes it with a text string.

static Constant * get(LLVMContext &Context, ArrayRef< ElementTy > Elts)

get() constructor - Return a constant with array type with an element count and element type matching...

static Constant * getInBoundsGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList)

Create an "inbounds" getelementptr.

static LLVM_ABI Constant * getPointerBitCastOrAddrSpaceCast(Constant *C, Type *Ty)

Create a BitCast or AddrSpaceCast for a pointer type depending on the address space.

static Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList, GEPNoWrapFlags NW=GEPNoWrapFlags::none(), std::optional< ConstantRange > InRange=std::nullopt, Type *OnlyIfReducedTy=nullptr)

Getelementptr form.

static LLVM_ABI ConstantPointerNull * get(PointerType *T)

Static factory methods - Return objects of the specified value.

static LLVM_ABI Constant * get(StructType *T, ArrayRef< Constant * > V)

This is an important base class in LLVM.

static LLVM_ABI Constant * getNullValue(Type *Ty)

Constructor to create a '0' constant of arbitrary type.

Lightweight error class with error context and mandatory checking.

static ErrorSuccess success()

Create a success value.

A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...

static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)

This static method is the primary way of constructing a FunctionType.

static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)

LLVM_ABI void setSection(StringRef S)

Change the section for this global.

void setUnnamedAddr(UnnamedAddr Val)

@ InternalLinkage

Rename collisions when linking (static functions).

Type * getValueType() const

const Constant * getInitializer() const

getInitializer - Return the initializer for this global variable.

This provides a uniform API for creating instructions and inserting them into a basic block: either a...

Class to represent integer types.

This is an important class for using LLVM in a threaded context.

An instruction for reading from memory.

static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)

Open the specified memory range as a MemoryBuffer.

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

static PointerType * getUnqual(Type *ElementType)

This constructs a pointer to an object of the specified type in the default address space (address sp...

static LLVM_ABI PointerType * get(Type *ElementType, unsigned AddressSpace)

This constructs a pointer to an object of the specified type in a numbered address space.

void reserve(size_type N)

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.

Class to represent struct types.

static LLVM_ABI StructType * getTypeByName(LLVMContext &C, StringRef Name)

Return the type with the specified name, or null if there is none by that name.

static LLVM_ABI StructType * create(LLVMContext &Context, StringRef Name)

This creates an identified struct.

Triple - Helper class for working with autoconf configuration names.

bool isMacOSX() const

Is this a Mac OS X triple.

The instances of the Type class are immutable: once they are created, they are never changed.

static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)

static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)

static LLVM_ABI Type * getVoidTy(LLVMContext &C)

static LLVM_ABI IntegerType * getInt16Ty(LLVMContext &C)

Type * getType() const

All values are typed, get the type of this value.

static uint64_t getAlignment()

#define llvm_unreachable(msg)

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

@ C

The default llvm calling convention, compatible with C.

@ OB

OB - OneByte - Set if this instruction has a one byte opcode.

@ Switch

The "resume-switch" lowering, where there are separate resume and destroy functions that are shared b...

LLVM_ABI Error extractOffloadBinaries(MemoryBufferRef Buffer, SmallVectorImpl< OffloadFile > &Binaries)

Extracts embedded device offloading code from a memory Buffer to a list of Binaries.

LLVM_ABI GlobalVariable * emitOffloadingEntry(Module &M, object::OffloadKind Kind, Constant *Addr, StringRef Name, uint64_t Size, uint32_t Flags, uint64_t Data, Constant *AuxAddr=nullptr, StringRef SectionName="llvm_offload_entries")

Create an offloading section struct used to register this global at runtime.

LLVM_ABI StructType * getEntryTy(Module &M)

Returns the type of the offloading entry we use to store kernels and globals that will be registered ...

LLVM_ABI llvm::Error wrapSYCLBinaries(llvm::Module &M, llvm::ArrayRef< char > Buffer, SYCLJITOptions Options=SYCLJITOptions())

Wraps OffloadBinaries in the given Buffers into the module M as global symbols and registers the imag...

Definition OffloadWrapper.cpp:1069

@ OffloadGlobalSurfaceEntry

Mark the entry as a surface variable.

@ OffloadGlobalTextureEntry

Mark the entry as a texture variable.

@ OffloadGlobalNormalized

Mark the entry as being a normalized surface.

@ OffloadGlobalEntry

Mark the entry as a global entry.

@ OffloadGlobalManagedEntry

Mark the entry as a managed global variable.

@ OffloadGlobalExtern

Mark the entry as being extern.

@ OffloadGlobalConstant

Mark the entry as being constant.

LLVM_ABI llvm::Error wrapOpenMPBinaries(llvm::Module &M, llvm::ArrayRef< llvm::ArrayRef< char > > Images, EntryArrayTy EntryArray, llvm::StringRef Suffix="", bool Relocatable=false)

Wraps the input device images into the module M as global symbols and registers the images with the O...

Definition OffloadWrapper.cpp:1030

std::pair< GlobalVariable *, GlobalVariable * > EntryArrayTy

LLVM_ABI llvm::Error wrapHIPBinary(llvm::Module &M, llvm::ArrayRef< char > Images, EntryArrayTy EntryArray, llvm::StringRef Suffix="", bool EmitSurfacesAndTextures=true)

Wraps the input bundled image into the module M as global symbols and registers the images with the H...

Definition OffloadWrapper.cpp:1056

LLVM_ABI llvm::Error wrapCudaBinary(llvm::Module &M, llvm::ArrayRef< char > Images, EntryArrayTy EntryArray, llvm::StringRef Suffix="", bool EmitSurfacesAndTextures=true)

Wraps the input fatbinary image into the module M as global symbols and registers the images with the...

Definition OffloadWrapper.cpp:1042

NodeAddr< FuncNode * > Func

Context & getContext() const

This is an optimization pass for GlobalISel generic memory operations.

LLVM_ABI file_magic identify_magic(StringRef magic)

Identify the type of a binary file based on how magical it is.

LLVM_ABI std::error_code inconvertibleErrorCode()

The value returned by this function can be returned from convertToErrorCode for Error values where no...

Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)

Create formatted StringError object.

FunctionAddr VTableAddr uintptr_t uintptr_t Version

class LLVM_GSL_OWNER SmallVector

Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...

@ First

Helpers to iterate all locations in the MemoryEffectsBase class.

FunctionAddr VTableAddr uintptr_t uintptr_t Data

IRBuilder(LLVMContext &, FolderTy, InserterTy, MDNode *, ArrayRef< OperandBundleDef >) -> IRBuilder< FolderTy, InserterTy >

ArrayRef(const T &OneElt) -> ArrayRef< T >

LLVM_ABI void appendToGlobalCtors(Module &M, Function *F, int Priority, Constant *Data=nullptr)

Append F to the list of global ctors of module M with the given Priority.

LLVM_ABI void appendToGlobalDtors(Module &M, Function *F, int Priority, Constant *Data=nullptr)

Same as appendToGlobalCtors(), but for global dtors.

@ Extern

Replace returns with jump to thunk, don't emit thunk.

This struct is a compact representation of a valid (non-zero power of two) alignment.

@ offload_binary

LLVM offload object file.