Skip to content

Commit

Permalink
[SYCL] Added a new CLANG pass that adapts the names of OclCXX
Browse files Browse the repository at this point in the history
classes and funcs for translation to SPIRV.

Signed-off-by: Vladimir Lazarev <vladimir.lazarev@intel.com>
  • Loading branch information
vladimirlaz committed Jan 22, 2019
1 parent 71d6139 commit 2260ff1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/TargetOptions.h"
#include "clang/CodeGen/OclCxxRewrite/BifNameReflower.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/Frontend/Utils.h"
#include "clang/Lex/HeaderSearchOptions.h"
Expand Down Expand Up @@ -39,6 +40,7 @@
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Support/BuryPointer.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/TargetRegistry.h"
Expand Down Expand Up @@ -801,6 +803,10 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
PerFunctionPasses.add(
createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));

if (LangOpts.SYCL) {
PerModulePasses.add(createOclCxxBifNameReflowerPass());
}

CreatePasses(PerModulePasses, PerFunctionPasses);

legacy::PassManager CodeGenPasses;
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/CodeGen/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
add_subdirectory(OclCxxRewrite)

set(LLVM_LINK_COMPONENTS
Analysis
BitReader
Expand Down Expand Up @@ -105,4 +107,5 @@ add_clang_library(clangCodeGen
clangFrontend
clangLex
clangSerialization
clangOclCxxRewrite
)
14 changes: 14 additions & 0 deletions clang/lib/CodeGen/CodeGenTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@ void CodeGenTypes::addRecordTypeName(const RecordDecl *RD,
llvm::raw_svector_ostream OS(TypeName);
OS << RD->getKindName() << '.';

// NOTE: The following block of code is copied from CLANG-3.6 with
// support of OpenCLCPlusPlus. It is rather the temporary solution
// that is going to be used until the general solution is ported/developed
// in the latest llvm trunc.
//
// For SYCL, the mangled type name is attached, so it can be
// reflown to proper name later.
if (getContext().getLangOpts().SYCL) {
std::unique_ptr<MangleContext> MC(getContext().createMangleContext());
auto RDT = getContext().getRecordType(RD);
MC->mangleCXXRTTIName(RDT, OS);
OS << ".";
}

// Name the codegen type after the typedef name
// if there is no tag type name available
if (RD->getIdentifier()) {
Expand Down

0 comments on commit 2260ff1

Please sign in to comment.