@@ -46,6 +46,9 @@ using namespace llvm::util;
4646
4747namespace {
4848
49+ // / Enable preview breaking changes
50+ static bool PreviewBreakingChanges = false ;
51+
4952// / Note: Returned values are a part of ABI. If you want to change them
5053// / then coordinate it with SYCL Runtime.
5154int8_t binaryImageFormatToInt8 (SYCLBinaryImageFormat Format) {
@@ -137,7 +140,6 @@ struct Wrapper {
137140 }
138141
139142 // TODO: Drop Version in favor of the Version in Binary Descriptor.
140- // TODO: Drop Manifest fields.
141143 // / Creates a structure corresponding to:
142144 // / SYCL specific image descriptor type.
143145 // / \code
@@ -159,10 +161,12 @@ struct Wrapper {
159161 // / // a null-terminated string; target- and compiler-specific options
160162 // / // which are suggested to use to "link" program at runtime
161163 // / const char *LinkOptions;
164+ #ifndef __INTEL_PREVIEW_BREAKING_CHANGES
162165 // / // Pointer to the manifest data start
163166 // / const unsigned char *ManifestStart;
164167 // / // Pointer to the manifest data end
165168 // / const unsigned char *ManifestEnd;
169+ #endif // __INTEL_PREVIEW_BREAKING_CHANGES
166170 // / // Pointer to the device binary image start
167171 // / void *ImageStart;
168172 // / // Pointer to the device binary image end
@@ -175,24 +179,43 @@ struct Wrapper {
175179 // / };
176180 // / \endcode
177181 StructType *getSyclDeviceImageTy () {
178- return StructType::create (
179- {
180- Type::getInt16Ty (C), // Version
181- Type::getInt8Ty (C), // OffloadKind
182- Type::getInt8Ty (C), // Format
183- PointerType::getUnqual (C), // DeviceTargetSpec
184- PointerType::getUnqual (C), // CompileOptions
185- PointerType::getUnqual (C), // LinkOptions
186- PointerType::getUnqual (C), // ManifestStart
187- PointerType::getUnqual (C), // ManifestEnd
188- PointerType::getUnqual (C), // ImageStart
189- PointerType::getUnqual (C), // ImageEnd
190- PointerType::getUnqual (C), // EntriesBegin
191- PointerType::getUnqual (C), // EntriesEnd
192- PointerType::getUnqual (C), // PropertySetBegin
193- PointerType::getUnqual (C) // PropertySetEnd
194- },
195- " __sycl.tgt_device_image" );
182+ if (!PreviewBreakingChanges) {
183+ return StructType::create (
184+ {
185+ Type::getInt16Ty (C), // Version
186+ Type::getInt8Ty (C), // OffloadKind
187+ Type::getInt8Ty (C), // Format
188+ PointerType::getUnqual (C), // DeviceTargetSpec
189+ PointerType::getUnqual (C), // CompileOptions
190+ PointerType::getUnqual (C), // LinkOptions
191+ PointerType::getUnqual (C), // ManifestStart
192+ PointerType::getUnqual (C), // ManifestEnd
193+ PointerType::getUnqual (C), // ImageStart
194+ PointerType::getUnqual (C), // ImageEnd
195+ PointerType::getUnqual (C), // EntriesBegin
196+ PointerType::getUnqual (C), // EntriesEnd
197+ PointerType::getUnqual (C), // PropertySetBegin
198+ PointerType::getUnqual (C) // PropertySetEnd
199+ },
200+ " __sycl.tgt_device_image" );
201+ } else {
202+ return StructType::create (
203+ {
204+ Type::getInt16Ty (C), // Version
205+ Type::getInt8Ty (C), // OffloadKind
206+ Type::getInt8Ty (C), // Format
207+ PointerType::getUnqual (C), // DeviceTargetSpec
208+ PointerType::getUnqual (C), // CompileOptions
209+ PointerType::getUnqual (C), // LinkOptions
210+ PointerType::getUnqual (C), // ImageStart
211+ PointerType::getUnqual (C), // ImageEnd
212+ PointerType::getUnqual (C), // EntriesBegin
213+ PointerType::getUnqual (C), // EntriesEnd
214+ PointerType::getUnqual (C), // PropertySetBegin
215+ PointerType::getUnqual (C) // PropertySetEnd
216+ },
217+ " __sycl.tgt_device_image" );
218+ }
196219 }
197220
198221 // / Creates a structure for SYCL specific binary descriptor type. Corresponds
@@ -545,7 +568,12 @@ struct Wrapper {
545568 auto *NullPtr = Constant::getNullValue (PointerType::getUnqual (C));
546569 // DeviceImageStructVersion change log:
547570 // -- version 2: updated to PI 1.2 binary image format
548- constexpr uint16_t DeviceImageStructVersion = 2 ;
571+ // -- version 3: removed ManifestStart, ManifestEnd pointers
572+ #ifndef __INTEL_PREVIEW_BREAKING_CHANGES
573+ uint16_t DeviceImageStructVersion = PreviewBreakingChanges ? 3 : 2 ;
574+ #else // __INTEL_PREVIEW_BREAKING_CHANGES
575+ constexpr uint16_t DeviceImageStructVersion = 3 ;
576+ #endif // __INTEL_PREVIEW_BREAKING_CHANGES
549577 constexpr uint8_t SYCLOffloadKind = 4 ; // Corresponds to SYCL
550578 auto *Version =
551579 ConstantInt::get (Type::getInt16Ty (C), DeviceImageStructVersion);
@@ -573,20 +601,27 @@ struct Wrapper {
573601 Twine (OffloadKindTag) + ImageID + " .data" , Image.Target );
574602 }
575603
576- // TODO: Manifests are going to be removed.
577- // Note: Manifests are deprecated but corresponding nullptr fields should
578- // remain to comply ABI.
604+ #ifndef __INTEL_PREVIEW_BREAKING_CHANGES
579605 std::pair<Constant *, Constant *> Manifests = {NullPtr, NullPtr};
606+ #endif
580607
581608 // For SYCL image offload entries are defined here, by wrapper, so
582609 // those are created per image
583610 std::pair<Constant *, Constant *> ImageEntriesPtrs =
584611 addOffloadEntriesToModule (Image.Entries );
585- Constant *WrappedImage = ConstantStruct::get (
586- SyclDeviceImageTy, Version, Kind, Format, Target, CompileOptions,
587- LinkOptions, Manifests.first , Manifests.second , Binary.first ,
588- Binary.second , ImageEntriesPtrs.first , ImageEntriesPtrs.second ,
589- PropSets.first , PropSets.second );
612+ Constant *WrappedImage =
613+ PreviewBreakingChanges
614+ ? ConstantStruct::get (
615+ SyclDeviceImageTy, Version, Kind, Format, Target,
616+ CompileOptions, LinkOptions, Binary.first , Binary.second ,
617+ ImageEntriesPtrs.first , ImageEntriesPtrs.second ,
618+ PropSets.first , PropSets.second )
619+ : ConstantStruct::get (
620+ SyclDeviceImageTy, Version, Kind, Format, Target,
621+ CompileOptions, LinkOptions, Manifests.first ,
622+ Manifests.second , Binary.first , Binary.second ,
623+ ImageEntriesPtrs.first , ImageEntriesPtrs.second ,
624+ PropSets.first , PropSets.second );
590625
591626 if (Options.EmitRegistrationFunctions )
592627 emitRegistrationFunctions (Binary.first , Image.Image ->getBufferSize (),
@@ -648,7 +683,11 @@ struct Wrapper {
648683 // / ...
649684 // / static const char ImageN[] = { <Bufs.back() contents> };
650685 // /
686+ #ifndef __INTEL_PREVIEW_BREAKING_CHANGES
651687 // / static constexpr uint16_t Version = 2;
688+ #else // __INTEL_PREVIEW_BREAKING_CHANGES
689+ // / static constexpr uint16_t Version = 3;
690+ #endif // __INTEL_PREVIEW_BREAKING_CHANGES
652691 // / static constexpr uint16_t OffloadKind = 4; // SYCL
653692 // /
654693 // / static const __sycl.tgt_device_image Images[] = {
@@ -660,8 +699,10 @@ struct Wrapper {
660699 // NULL, /*DeviceTargetSpec*/
661700 // / CompileOptions0, /*CompileOptions0*/
662701 // / LinkOptions0, /*LinkOptions0*/
702+ #ifndef __INTEL_PREVIEW_BREAKING_CHANGES
663703 // / NULL, /*ManifestStart*/
664704 // / NULL, /*ManifestEnd*/
705+ #endif // __INTEL_PREVIEW_BREAKING_CHANGES
665706 // / Image0, /*ImageStart*/
666707 // / Image0 + sizeof(Image0), /*ImageEnd*/
667708 // / __start_offloading_entries0, /*EntriesBegin*/
@@ -785,7 +826,9 @@ struct Wrapper {
785826
786827Error llvm::offloading::wrapSYCLBinaries (llvm::Module &M,
787828 const SmallVector<SYCLImage> &Images,
788- SYCLWrappingOptions Options) {
829+ SYCLWrappingOptions Options,
830+ bool _PreviewBreakingChanges) {
831+ PreviewBreakingChanges = _PreviewBreakingChanges;
789832 Wrapper W (M, Options);
790833 GlobalVariable *Desc = W.createFatbinDesc (Images);
791834 if (!Desc)
0 commit comments