Skip to content

Commit 3c3b5e5

Browse files
committed
Arrange code in SemaSYCL
1 parent 683d7eb commit 3c3b5e5

File tree

1 file changed

+22
-28
lines changed

1 file changed

+22
-28
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4972,8 +4972,8 @@ static void PrintNSClosingBraces(raw_ostream &OS, const DeclContext *DC) {
49724972
}
49734973

49744974
static std::string EmitShim(raw_ostream &OS, unsigned &ShimCounter,
4975-
const std::string &LastShim,
4976-
const NamespaceDecl *AnonNS) {
4975+
const std::string &LastShim,
4976+
const NamespaceDecl *AnonNS) {
49774977
std::string NewShimName =
49784978
"__sycl_detail::__shim_" + std::to_string(ShimCounter) + "()";
49794979
// Print opening-namespace
@@ -4992,8 +4992,7 @@ static std::string EmitShim(raw_ostream &OS, unsigned &ShimCounter,
49924992

49934993
// Emit the list of shims required for a DeclContext, calls itself recursively.
49944994
static void EmitShims(raw_ostream &OS, unsigned &ShimCounter,
4995-
const DeclContext *DC,
4996-
std::string &NameForLastShim) {
4995+
const DeclContext *DC, std::string &NameForLastShim) {
49974996
if (DC->isTranslationUnit()) {
49984997
NameForLastShim = "::" + NameForLastShim;
49994998
return;
@@ -5028,7 +5027,7 @@ static void EmitShims(raw_ostream &OS, unsigned &ShimCounter,
50285027
// Returns a string containing the FQN of the 'top most' shim, including its
50295028
// function call parameters.
50305029
static std::string EmitShims(raw_ostream &OS, unsigned &ShimCounter,
5031-
PrintingPolicy &Policy, const VarDecl *VD) {
5030+
PrintingPolicy &Policy, const VarDecl *VD) {
50325031
if (!VD->isInAnonymousNamespace())
50335032
return "";
50345033
std::string RelativeName;
@@ -5068,7 +5067,7 @@ bool SYCLIntegrationFooter::emit(raw_ostream &OS) {
50685067
if (llvm::find(Visited, VD) != Visited.end())
50695068
continue;
50705069

5071-
// We only want to emit the #includes if we have a spec-constant that needs
5070+
// We only want to emit the #includes if we have a variable that needs
50725071
// them, so emit this one on the first time through the loop.
50735072
if (!EmittedFirstSpecConstant && !DeviceGlobalsEmitted)
50745073
OS << "#include <CL/sycl/detail/defines_elementary.hpp>\n";
@@ -5078,37 +5077,32 @@ bool SYCLIntegrationFooter::emit(raw_ostream &OS) {
50785077
if (Util::isSyclDeviceGlobalType(VD->getType())) {
50795078
DeviceGlobalsEmitted = true;
50805079
DeviceGlobOS << "device_global_map::add(";
5080+
DeviceGlobOS << "(void *)&";
5081+
if (VD->isInAnonymousNamespace()) {
5082+
DeviceGlobOS << TopShim;
5083+
} else {
5084+
DeviceGlobOS << "::";
5085+
VD->getNameForDiagnostic(DeviceGlobOS, Policy, true);
5086+
}
5087+
DeviceGlobOS << ", \"";
5088+
DeviceGlobOS << SYCLUniqueStableIdExpr::ComputeName(S.getASTContext(),
5089+
VD);
5090+
DeviceGlobOS << "\");\n";
50815091
} else {
50825092
EmittedFirstSpecConstant = true;
50835093
OS << "__SYCL_INLINE_NAMESPACE(cl) {\n";
50845094
OS << "namespace sycl {\n";
50855095
OS << "namespace detail {\n";
50865096
OS << "template<>\n";
50875097
OS << "inline const char *get_spec_constant_symbolic_ID_impl<";
5088-
}
50895098

5090-
std::string VarRefName;
5091-
llvm::raw_string_ostream VarRefNameOS(VarRefName);
5092-
if (VD->isInAnonymousNamespace()) {
5093-
VarRefNameOS << TopShim;
5094-
} else {
5095-
VarRefNameOS << "::";
5096-
VD->getNameForDiagnostic(VarRefNameOS, Policy, true);
5097-
}
5098-
VarRefNameOS.flush();
5099-
if (Util::isSyclDeviceGlobalType(VD->getType())) {
5100-
DeviceGlobOS << "(void *)&";
5101-
DeviceGlobOS << VarRefName;
5102-
} else {
5103-
OS << VarRefName;
5104-
}
5099+
if (VD->isInAnonymousNamespace()) {
5100+
OS << TopShim;
5101+
} else {
5102+
OS << "::";
5103+
VD->getNameForDiagnostic(OS, Policy, true);
5104+
}
51055105

5106-
if (Util::isSyclDeviceGlobalType(VD->getType())) {
5107-
DeviceGlobOS << ", \"";
5108-
DeviceGlobOS << SYCLUniqueStableIdExpr::ComputeName(S.getASTContext(),
5109-
VD);
5110-
DeviceGlobOS << "\");\n";
5111-
} else {
51125106
OS << ">() {\n";
51135107
OS << " return \"";
51145108
OS << SYCLUniqueStableIdExpr::ComputeName(S.getASTContext(), VD);

0 commit comments

Comments
 (0)