Skip to content

Commit 0365bd4

Browse files
committed
Merge remote-tracking branch 'intel_llvm/sycl' into llvmspirv_pulldown
2 parents 0621c56 + 4dc23a2 commit 0365bd4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1006
-523
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ xpti/ @tovinkere @andykaylor
7979
xptifw/ @tovinkere @andykaylor
8080

8181
# DPC++ tools
82+
llvm/**/append-file/ @mdtoguchi @AGindinson
8283
llvm/**/file-table-tform/ @mlychkov @AlexeySachkov @kbobrovs
8384
llvm/**/llvm-foreach/ @AlexeySachkov @Fznamznon
8485
llvm/**/llvm-no-spir-kernel/ @AGindinson @AlexeySachkov

.github/workflows/clang-format.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
- name: Run clang-format for the patch
2020
run: |
21-
git diff --no-color ${GITHUB_SHA}^1 ${GITHUB_SHA} --name-only -- | grep -v "/test/" | xargs git diff -U0 --no-color ${GITHUB_SHA}^1 ${GITHUB_SHA} -- | ./clang/tools/clang-format/clang-format-diff.py -p1 -binary clang-format-9 > ./clang-format.patch
21+
git diff --no-color ${GITHUB_SHA}^1 ${GITHUB_SHA} --name-only -- | grep -v "/test/" | xargs git diff -U0 --no-color ${GITHUB_SHA}^1 ${GITHUB_SHA} -- | ./clang/tools/clang-format/clang-format-diff.py -p1 -binary clang-format > ./clang-format.patch
2222
2323
# Add patch with formatting fixes to CI job artifacts
2424
- uses: actions/upload-artifact@v1

clang/include/clang/Basic/LangOptions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ LANGOPT(
264264
"SYCL compiler assumes value fits within MAX_INT for member function of "
265265
"get/operator[], get_id/operator[] and get_global_id/get_global_linear_id "
266266
"in SYCL class id, iterm and nd_iterm")
267+
LANGOPT(SYCLDisableRangeRounding, 1, 0, "Disable parallel for range rounding")
267268

268269
LANGOPT(HIPUseNewLaunchAPI, 1, 0, "Use new kernel launching API for HIP")
269270

clang/include/clang/Driver/Action.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class Action {
8080
SYCLPostLinkJobClass,
8181
BackendCompileJobClass,
8282
FileTableTformJobClass,
83+
AppendFooterJobClass,
8384
StaticLibJobClass,
8485

8586
JobClassFirst = PreprocessJobClass,
@@ -807,6 +808,17 @@ class FileTableTformJobAction : public JobAction {
807808
SmallVector<Tform, 2> Tforms; // transformation actions requested
808809
};
809810

811+
class AppendFooterJobAction : public JobAction {
812+
void anchor() override;
813+
814+
public:
815+
AppendFooterJobAction(Action *Input, types::ID Type);
816+
817+
static bool classof(const Action *A) {
818+
return A->getKind() == AppendFooterJobClass;
819+
}
820+
};
821+
810822
class StaticLibJobAction : public JobAction {
811823
void anchor() override;
812824

clang/include/clang/Driver/Driver.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,8 @@ class Driver {
658658
/// A list of inputs and their corresponding integration headers. These
659659
/// files are generated during the device compilation and are consumed
660660
/// by the host compilation.
661-
mutable llvm::StringMap<StringRef> IntegrationFileList;
661+
mutable llvm::StringMap<const std::pair<StringRef, StringRef>>
662+
IntegrationFileList;
662663

663664
/// Unique ID used for SYCL compilations. Each file will use a different
664665
/// unique ID, but the same ID will be used for different compilation
@@ -708,13 +709,22 @@ class Driver {
708709

709710
/// addIntegrationFiles - Add the integration files that will be populated
710711
/// by the device compilation and used by the host compile.
711-
void addIntegrationFiles(StringRef IntHeaderName, StringRef FileName) const {
712-
IntegrationFileList.insert({FileName, IntHeaderName});
712+
void addIntegrationFiles(StringRef IntHeaderName, StringRef IntFooterName,
713+
StringRef FileName) const {
714+
IntegrationFileList.insert(
715+
{FileName, std::make_pair(IntHeaderName, IntFooterName)});
713716
}
714717
/// getIntegrationHeader - Get the integration header file
715718
StringRef getIntegrationHeader(StringRef FileName) const {
716-
return IntegrationFileList[FileName];
719+
return IntegrationFileList[FileName].first;
717720
}
721+
/// getIntegrationFooter - Get the integration footer file
722+
StringRef getIntegrationFooter(StringRef FileName) const {
723+
return IntegrationFileList[FileName].second;
724+
}
725+
/// createAppendedFooterInput - Create new source file.
726+
void createAppendedFooterInput(Action *&Input, Compilation &C,
727+
const llvm::opt::ArgList &Args) const;
718728

719729
/// setSYCLUniqueID - set the Unique ID that is used for all FE invocations
720730
/// when performing compilations for SYCL.

clang/include/clang/Driver/Options.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2602,6 +2602,9 @@ def fsycl_host_compiler_options_EQ : Joined<["-"], "fsycl-host-compiler-options=
26022602
Flags<[CoreOption]>, HelpText<"When performing the host compilation with "
26032603
"-fsycl-host-compiler specified, use the given options during that compile. "
26042604
"Options are expected to be a quoted list of space separated options.">;
2605+
def fsycl_use_footer : Flag<["-"], "fsycl-use-footer">, Flags<[CoreOption]>,
2606+
HelpText<"Enable usage of the integration footer during SYCL enabled "
2607+
"compilations.">;
26052608
def fsyntax_only : Flag<["-"], "fsyntax-only">,
26062609
Flags<[NoXarchOption,CoreOption,CC1Option,FC1Option]>, Group<Action_Group>;
26072610
def ftabstop_EQ : Joined<["-"], "ftabstop=">, Group<f_Group>;
@@ -5836,6 +5839,9 @@ defm sycl_allow_func_ptr: BoolFOption<"sycl-allow-func-ptr",
58365839
def fenable_sycl_dae : Flag<["-"], "fenable-sycl-dae">,
58375840
HelpText<"Enable Dead Argument Elimination in SPIR kernels">,
58385841
MarshallingInfoFlag<LangOpts<"EnableDAEInSpirKernels">>;
5842+
def fsycl_disable_range_rounding : Flag<["-"], "fsycl-disable-range-rounding">,
5843+
HelpText<"Disable parallel for range rounding.">,
5844+
MarshallingInfoFlag<LangOpts<"SYCLDisableRangeRounding">>;
58395845

58405846
} // let Flags = [CC1Option, NoDriverOption]
58415847

clang/include/clang/Driver/ToolChain.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ class ToolChain {
149149
mutable std::unique_ptr<Tool> SPIRCheck;
150150
mutable std::unique_ptr<Tool> SYCLPostLink;
151151
mutable std::unique_ptr<Tool> BackendCompiler;
152+
mutable std::unique_ptr<Tool> AppendFooter;
152153
mutable std::unique_ptr<Tool> FileTableTform;
153154

154155
Tool *getClang() const;
@@ -165,6 +166,7 @@ class ToolChain {
165166
Tool *getSPIRCheck() const;
166167
Tool *getSYCLPostLink() const;
167168
Tool *getBackendCompiler() const;
169+
Tool *getAppendFooter() const;
168170
Tool *getTableTform() const;
169171

170172
mutable std::unique_ptr<SanitizerArgs> SanitizerArguments;

clang/lib/Driver/Action.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ const char *Action::getClassName(ActionClass AC) {
5555
return "backend-compiler";
5656
case FileTableTformJobClass:
5757
return "file-table-tform";
58+
case AppendFooterJobClass:
59+
return "append-footer";
5860
case StaticLibJobClass:
5961
return "static-lib-linker";
6062
}
@@ -510,6 +512,11 @@ void FileTableTformJobAction::addRenameColumnTform(StringRef From,
510512
Tforms.emplace_back(Tform(Tform::RENAME, {From, To}));
511513
}
512514

515+
void AppendFooterJobAction::anchor() {}
516+
517+
AppendFooterJobAction::AppendFooterJobAction(Action *Input, types::ID Type)
518+
: JobAction(AppendFooterJobClass, Input, Type) {}
519+
513520
void StaticLibJobAction::anchor() {}
514521

515522
StaticLibJobAction::StaticLibJobAction(ActionList &Inputs, types::ID Type)

clang/lib/Driver/Driver.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5179,7 +5179,11 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
51795179
llvm::sys::path::stem(SrcFileName).str() + "-header", "h");
51805180
StringRef TmpFileHeader =
51815181
C.addTempFile(C.getArgs().MakeArgString(TmpFileNameHeader));
5182-
addIntegrationFiles(TmpFileHeader, SrcFileName);
5182+
std::string TmpFileNameFooter = C.getDriver().GetTemporaryPath(
5183+
llvm::sys::path::stem(SrcFileName).str() + "-footer", "h");
5184+
StringRef TmpFileFooter =
5185+
C.addTempFile(C.getArgs().MakeArgString(TmpFileNameFooter));
5186+
addIntegrationFiles(TmpFileHeader, TmpFileFooter, SrcFileName);
51835187
}
51845188
}
51855189

@@ -5552,6 +5556,18 @@ Action *Driver::ConstructPhaseAction(
55525556
return C.MakeAction<CompileJobAction>(Input, types::TY_ModuleFile);
55535557
if (Args.hasArg(options::OPT_verify_pch))
55545558
return C.MakeAction<VerifyPCHJobAction>(Input, types::TY_Nothing);
5559+
if (Args.hasArg(options::OPT_fsycl) &&
5560+
Args.hasArg(options::OPT_fsycl_use_footer) &&
5561+
TargetDeviceOffloadKind == Action::OFK_None) {
5562+
// Performing a host compilation with -fsycl. Append the integrated
5563+
// footer to the preprocessed source file. We then add another
5564+
// preprocessed step so the new file is considered a full compilation.
5565+
auto *AppendFooter =
5566+
C.MakeAction<AppendFooterJobAction>(Input, types::TY_CXX);
5567+
auto *Preprocess =
5568+
C.MakeAction<PreprocessJobAction>(AppendFooter, Input->getType());
5569+
return C.MakeAction<CompileJobAction>(Preprocess, types::TY_LLVM_BC);
5570+
}
55555571
return C.MakeAction<CompileJobAction>(Input, types::TY_LLVM_BC);
55565572
}
55575573
case phases::Backend: {
@@ -6175,7 +6191,6 @@ InputInfo Driver::BuildJobsForActionNoCache(
61756191
}
61766192
return InputInfo(A, &Input, /* _BaseInput = */ "");
61776193
}
6178-
61796194
if (const BindArchAction *BAA = dyn_cast<BindArchAction>(A)) {
61806195
const ToolChain *TC;
61816196
StringRef ArchName = BAA->getArchName();

clang/lib/Driver/ToolChain.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,12 @@ Tool *ToolChain::getBackendCompiler() const {
361361
return BackendCompiler.get();
362362
}
363363

364+
Tool *ToolChain::getAppendFooter() const {
365+
if (!AppendFooter)
366+
AppendFooter.reset(new tools::AppendFooter(*this));
367+
return AppendFooter.get();
368+
}
369+
364370
Tool *ToolChain::getTableTform() const {
365371
if (!FileTableTform)
366372
FileTableTform.reset(new tools::FileTableTform(*this));
@@ -421,6 +427,9 @@ Tool *ToolChain::getTool(Action::ActionClass AC) const {
421427
case Action::BackendCompileJobClass:
422428
return getBackendCompiler();
423429

430+
case Action::AppendFooterJobClass:
431+
return getAppendFooter();
432+
424433
case Action::FileTableTformJobClass:
425434
return getTableTform();
426435
}

0 commit comments

Comments
 (0)