Skip to content

Commit

Permalink
Rename opencl-c headers into opencl-c-intel
Browse files Browse the repository at this point in the history
  • Loading branch information
lwesiers committed Jun 5, 2023
1 parent fe06526 commit af290b5
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 51 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ if(NOT USE_PREBUILT_LLVM)
${CMAKE_CURRENT_SOURCE_DIR}/patches/spirv
${SPIRV_BASE_REVISION}
${TARGET_BRANCH})
# Prepare opencl-c-intel.h and opencl-c-intel-base.h file
file(READ "${CLANG_SOURCE_DIR}/lib/Headers/opencl-c.h" opencl_c_old)
string(REGEX REPLACE "#include \"opencl-c-base\.h\"" "#include \"opencl-c-intel-base.h\"" opencl_c_intel_new ${opencl_c_old})
file(WRITE "${CLANG_SOURCE_DIR}/lib/Headers/opencl-c-intel.h" ${opencl_c_intel_new})
execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${CLANG_SOURCE_DIR}/lib/Headers/opencl-c-base.h" "${CLANG_SOURCE_DIR}/lib/Headers/opencl-c-intel-base.h")
endif(NOT USE_PREBUILT_LLVM)

#
Expand Down
44 changes: 22 additions & 22 deletions cl_headers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ if(USE_PREBUILT_LLVM)
else(USE_PREBUILT_LLVM)
set(OPENCL_HEADERS_DIR "${CLANG_SOURCE_DIR}/lib/Headers")
endif(USE_PREBUILT_LLVM)
copy_file(${OPENCL_HEADERS_DIR}/opencl-c.h opencl-c.h)
copy_file(${OPENCL_HEADERS_DIR}/opencl-c-base.h opencl-c-base.h)
copy_file(${OPENCL_HEADERS_DIR}/opencl-c-intel.h opencl-c-intel.h)
copy_file(${OPENCL_HEADERS_DIR}/opencl-c-intel-base.h opencl-c-intel-base.h)
copy_file(${CMAKE_CURRENT_SOURCE_DIR}/module.modulemap module.modulemap)

add_custom_target (
opencl.headers.target
DEPENDS
module.modulemap
opencl-c.h
opencl-c-base.h
opencl-c-intel.h
opencl-c-intel-base.h
)

function(create_pcm DST MODULE HEADER OPTS DEPS)
Expand Down Expand Up @@ -77,19 +77,19 @@ else()
endif()

set(OPTS -cl-ext=+all,-cl_khr_fp64,-__opencl_c_fp64)
create_pcm(opencl-c-12-spir.pcm cl12spir opencl-c-base.h "${SPIR_TRIPLE};${CL12};${OPTS}" "${DEPS}")
create_pcm(opencl-c-20-spir.pcm cl20spir opencl-c-base.h "${SPIR_TRIPLE};${CL20};${OPTS}" "${DEPS}")
create_pcm(opencl-c-30-spir.pcm cl30spir opencl-c-base.h "${SPIR_TRIPLE};${CL30};${OPTS};${OPTS30}" "${DEPS}")
create_pcm(opencl-c-12-spir64.pcm cl12spir64 opencl-c-base.h "${SPIR64_TRIPLE};${CL12};${OPTS}" "${DEPS}")
create_pcm(opencl-c-20-spir64.pcm cl20spir64 opencl-c-base.h "${SPIR64_TRIPLE};${CL20};${OPTS}" "${DEPS}")
create_pcm(opencl-c-30-spir64.pcm cl30spir64 opencl-c-base.h "${SPIR64_TRIPLE};${CL30};${OPTS};${OPTS30}" "${DEPS}")
create_pcm(opencl-c-12-spir.pcm cl12spir opencl-c-intel-base.h "${SPIR_TRIPLE};${CL12};${OPTS}" "${DEPS}")
create_pcm(opencl-c-20-spir.pcm cl20spir opencl-c-intel-base.h "${SPIR_TRIPLE};${CL20};${OPTS}" "${DEPS}")
create_pcm(opencl-c-30-spir.pcm cl30spir opencl-c-intel-base.h "${SPIR_TRIPLE};${CL30};${OPTS};${OPTS30}" "${DEPS}")
create_pcm(opencl-c-12-spir64.pcm cl12spir64 opencl-c-intel-base.h "${SPIR64_TRIPLE};${CL12};${OPTS}" "${DEPS}")
create_pcm(opencl-c-20-spir64.pcm cl20spir64 opencl-c-intel-base.h "${SPIR64_TRIPLE};${CL20};${OPTS}" "${DEPS}")
create_pcm(opencl-c-30-spir64.pcm cl30spir64 opencl-c-intel-base.h "${SPIR64_TRIPLE};${CL30};${OPTS};${OPTS30}" "${DEPS}")
set(OPTS -cl-ext=+all)
create_pcm(opencl-c-12-spir-fp64.pcm cl12spirfp64 opencl-c-base.h "${SPIR_TRIPLE};${CL12};${OPTS}" "${DEPS}")
create_pcm(opencl-c-20-spir-fp64.pcm cl20spirfp64 opencl-c-base.h "${SPIR_TRIPLE};${CL20};${OPTS}" "${DEPS}")
create_pcm(opencl-c-30-spir-fp64.pcm cl30spirfp64 opencl-c-base.h "${SPIR_TRIPLE};${CL30};${OPTS};${OPTS30};${OPTS30_FP64}" "${DEPS}")
create_pcm(opencl-c-12-spir64-fp64.pcm cl12spir64fp64 opencl-c-base.h "${SPIR64_TRIPLE};${CL12};${OPTS}" "${DEPS}")
create_pcm(opencl-c-20-spir64-fp64.pcm cl20spir64fp64 opencl-c-base.h "${SPIR64_TRIPLE};${CL20};${OPTS}" "${DEPS}")
create_pcm(opencl-c-30-spir64-fp64.pcm cl30spir64fp64 opencl-c-base.h "${SPIR64_TRIPLE};${CL30};${OPTS};${OPTS30};${OPTS30_FP64}" "${DEPS}")
create_pcm(opencl-c-12-spir-fp64.pcm cl12spirfp64 opencl-c-intel-base.h "${SPIR_TRIPLE};${CL12};${OPTS}" "${DEPS}")
create_pcm(opencl-c-20-spir-fp64.pcm cl20spirfp64 opencl-c-intel-base.h "${SPIR_TRIPLE};${CL20};${OPTS}" "${DEPS}")
create_pcm(opencl-c-30-spir-fp64.pcm cl30spirfp64 opencl-c-intel-base.h "${SPIR_TRIPLE};${CL30};${OPTS};${OPTS30};${OPTS30_FP64}" "${DEPS}")
create_pcm(opencl-c-12-spir64-fp64.pcm cl12spir64fp64 opencl-c-intel-base.h "${SPIR64_TRIPLE};${CL12};${OPTS}" "${DEPS}")
create_pcm(opencl-c-20-spir64-fp64.pcm cl20spir64fp64 opencl-c-intel-base.h "${SPIR64_TRIPLE};${CL20};${OPTS}" "${DEPS}")
create_pcm(opencl-c-30-spir64-fp64.pcm cl30spir64fp64 opencl-c-intel-base.h "${SPIR64_TRIPLE};${CL30};${OPTS};${OPTS30};${OPTS30_FP64}" "${DEPS}")

add_custom_target (
opencl.pcm.target
Expand Down Expand Up @@ -121,11 +121,11 @@ endfunction(pack_to_obj)
if(WIN32)
list(APPEND CL_HEADERS_SRC OpenCL.rc)
else()
pack_to_obj(opencl-c.h opencl-c.h.cpp "PCM_OPENCL_C_H")
pack_to_obj(opencl-c-base.h opencl-c-base.h.cpp "PCM_OPENCL_C_BASE_H")
pack_to_obj(opencl-c-intel.h opencl-c-intel.h.cpp "PCM_OPENCL_C_H")
pack_to_obj(opencl-c-intel-base.h opencl-c-intel-base.h.cpp "PCM_OPENCL_C_BASE_H")
list(APPEND CL_HEADERS_SRC
opencl-c.h.cpp
opencl-c-base.h.cpp
opencl-c-intel.h.cpp
opencl-c-intel-base.h.cpp
opencl-c-12-spir.mod.cpp
opencl-c-20-spir.mod.cpp
opencl-c-30-spir.mod.cpp
Expand Down Expand Up @@ -164,8 +164,8 @@ add_library(${CL_HEADERS_LIB} OBJECT

add_dependencies(${CL_HEADERS_LIB} opencl.pcm.target)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/opencl-c.h
${CMAKE_CURRENT_BINARY_DIR}/opencl-c-base.h
${CMAKE_CURRENT_BINARY_DIR}/opencl-c-intel.h
${CMAKE_CURRENT_BINARY_DIR}/opencl-c-intel-base.h
${CMAKE_CURRENT_BINARY_DIR}/module.modulemap
DESTINATION include/cclang
)
4 changes: 2 additions & 2 deletions cl_headers/OpenCL.rc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ END
// Module with OpenCL C declarations with corresponding headers
//

OPENCL_C_H PCM "opencl-c.h"
OPENCL_C_BASE_H PCM "opencl-c-base.h"
OPENCL_C_H PCM "opencl-c-intel.h"
OPENCL_C_BASE_H PCM "opencl-c-intel-base.h"
OPENCL_C_12_SPIR_PCM PCM "opencl-c-12-spir.pcm"
OPENCL_C_20_SPIR_PCM PCM "opencl-c-20-spir.pcm"
OPENCL_C_30_SPIR_PCM PCM "opencl-c-30-spir.pcm"
Expand Down
48 changes: 24 additions & 24 deletions cl_headers/module.modulemap
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
module cl12spir {
header "opencl-c.h"
header "opencl-c-base.h"
header "opencl-c-intel.h"
header "opencl-c-intel-base.h"
export *
}
module cl20spir {
header "opencl-c.h"
header "opencl-c-base.h"
header "opencl-c-intel.h"
header "opencl-c-intel-base.h"
export *
}
module cl30spir {
header "opencl-c.h"
header "opencl-c-base.h"
header "opencl-c-intel.h"
header "opencl-c-intel-base.h"
export *
}
module cl12spir64 {
header "opencl-c.h"
header "opencl-c-base.h"
header "opencl-c-intel.h"
header "opencl-c-intel-base.h"
export *
}
module cl20spir64 {
header "opencl-c.h"
header "opencl-c-base.h"
header "opencl-c-intel.h"
header "opencl-c-intel-base.h"
export *
}
module cl30spir64 {
header "opencl-c.h"
header "opencl-c-base.h"
header "opencl-c-intel.h"
header "opencl-c-intel-base.h"
export *
}
module cl12spirfp64 {
header "opencl-c.h"
header "opencl-c-base.h"
header "opencl-c-intel.h"
header "opencl-c-intel-base.h"
export *
}
module cl20spirfp64 {
header "opencl-c.h"
header "opencl-c-base.h"
header "opencl-c-intel.h"
header "opencl-c-intel-base.h"
export *
}
module cl30spirfp64 {
header "opencl-c.h"
header "opencl-c-base.h"
header "opencl-c-intel.h"
header "opencl-c-intel-base.h"
export *
}
module cl12spir64fp64 {
header "opencl-c.h"
header "opencl-c-base.h"
header "opencl-c-intel.h"
header "opencl-c-intel-base.h"
export *
}
module cl20spir64fp64 {
header "opencl-c.h"
header "opencl-c-base.h"
header "opencl-c-intel.h"
header "opencl-c-intel-base.h"
export *
}
module cl30spir64fp64 {
header "opencl-c.h"
header "opencl-c-base.h"
header "opencl-c-intel.h"
header "opencl-c-intel-base.h"
export *
}
4 changes: 2 additions & 2 deletions opencl_clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ static bool GetHeaders(std::vector<Resource> &Result) {
struct {
const char *ID;
const char *Name;
} Headers[] = {{OPENCL_C_H, "opencl-c.h"},
{OPENCL_C_BASE_H, "opencl-c-base.h"},
} Headers[] = {{OPENCL_C_H, "opencl-c-intel.h"},
{OPENCL_C_BASE_H, "opencl-c-intel-base.h"},
{OPENCL_C_12_SPIR_PCM, "opencl-c-12-spir.pcm"},
{OPENCL_C_20_SPIR_PCM, "opencl-c-20-spir.pcm"},
{OPENCL_C_30_SPIR_PCM, "opencl-c-30-spir.pcm"},
Expand Down
2 changes: 1 addition & 1 deletion options_compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ std::string EffectiveOptionsFilter::processOptions(const OpenCLArgList &args,
effectiveArgs.push_back(szTriple);

effectiveArgs.push_back("-include");
effectiveArgs.push_back("opencl-c.h");
effectiveArgs.push_back("opencl-c-intel.h");

// Don't optimize in the frontend
// clang defaults to -O0, and in that mode, does not produce IR that is
Expand Down

0 comments on commit af290b5

Please sign in to comment.