@@ -3086,6 +3086,14 @@ class SyclKernelIntHeaderCreator : public SyclKernelFieldHandler {
30863086 using SyclKernelFieldHandler::leaveStruct;
30873087};
30883088
3089+ class SyclKernelPostIntHeaderCreator : public SyclKernelFieldHandler {
3090+ SYCLPostIntegrationHeader &Header;
3091+
3092+ public:
3093+ SyclKernelPostIntHeaderCreator (Sema &S, SYCLPostIntegrationHeader &H)
3094+ : SyclKernelFieldHandler(S), Header(H) {}
3095+ };
3096+
30893097} // namespace
30903098
30913099class SYCLKernelNameTypeVisitor
@@ -3411,9 +3419,14 @@ void Sema::ConstructOpenCLKernel(FunctionDecl *KernelCallerFunc,
34113419 calculateKernelNameType (Context, KernelCallerFunc), KernelName,
34123420 StableName, KernelCallerFunc);
34133421
3422+ SyclKernelPostIntHeaderCreator post_int_header (
3423+ *this , getSyclPostIntegrationHeader ());
3424+
34143425 KernelObjVisitor Visitor{*this };
3415- Visitor.VisitRecordBases (KernelObj, kernel_decl, kernel_body, int_header);
3416- Visitor.VisitRecordFields (KernelObj, kernel_decl, kernel_body, int_header);
3426+ Visitor.VisitRecordBases (KernelObj, kernel_decl, kernel_body, int_header,
3427+ post_int_header);
3428+ Visitor.VisitRecordFields (KernelObj, kernel_decl, kernel_body, int_header,
3429+ post_int_header);
34173430
34183431 if (ParmVarDecl *KernelHandlerArg =
34193432 getSyclKernelHandlerArg (KernelCallerFunc)) {
@@ -4149,7 +4162,7 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
41494162 O << " \n " ;
41504163}
41514164
4152- bool SYCLIntegrationHeader::emit (const StringRef & IntHeaderName) {
4165+ bool SYCLIntegrationHeader::emit (StringRef IntHeaderName) {
41534166 if (IntHeaderName.empty ())
41544167 return false ;
41554168 int IntHeaderFD = 0 ;
@@ -4221,11 +4234,31 @@ void SYCLIntegrationHeader::setCallsThisGroup(bool B) {
42214234 K->FreeFunctionCalls .CallsThisGroup = B;
42224235}
42234236
4224- SYCLIntegrationHeader::SYCLIntegrationHeader (DiagnosticsEngine &_Diag,
4225- bool _UnnamedLambdaSupport,
4237+ SYCLIntegrationHeader::SYCLIntegrationHeader (bool _UnnamedLambdaSupport,
42264238 Sema &_S)
42274239 : UnnamedLambdaSupport(_UnnamedLambdaSupport), S(_S) {}
42284240
4241+ // Post-compile integration header support.
4242+ bool SYCLPostIntegrationHeader::emit (StringRef IntHeaderName) {
4243+ if (IntHeaderName.empty ())
4244+ return false ;
4245+ int IntHeaderFD = 0 ;
4246+ std::error_code EC =
4247+ llvm::sys::fs::openFileForWrite (IntHeaderName, IntHeaderFD);
4248+ if (EC) {
4249+ llvm::errs () << " Error: " << EC.message () << " \n " ;
4250+ // compilation will fail on absent include file - don't need to fail here
4251+ return false ;
4252+ }
4253+ llvm::raw_fd_ostream Out (IntHeaderFD, true /* close in destructor*/ );
4254+ return emit (Out);
4255+ }
4256+
4257+ bool SYCLPostIntegrationHeader::emit (raw_ostream &O) {
4258+ O << " // Post Integration Header contents to go here.\n " ;
4259+ return true ;
4260+ }
4261+
42294262// -----------------------------------------------------------------------------
42304263// Utility class methods
42314264// -----------------------------------------------------------------------------
0 commit comments