diff options
-rw-r--r-- | CMake/FindLLVM.cmake | 46 | ||||
-rw-r--r-- | CMakeLists.txt | 10 | ||||
-rw-r--r-- | backend/CMakeLists.txt | 3 | ||||
-rw-r--r-- | backend/src/CMakeLists.txt | 29 | ||||
-rw-r--r-- | backend/src/llvm/CMakeLists.txt | 19 | ||||
-rw-r--r-- | backend/src/ocl_stdlib_str.cpp | 5 | ||||
-rw-r--r-- | src/CMakeLists.txt | 8 | ||||
-rw-r--r-- | utests/CMakeLists.txt | 8 |
8 files changed, 82 insertions, 46 deletions
diff --git a/CMake/FindLLVM.cmake b/CMake/FindLLVM.cmake new file mode 100644 index 00000000..4fa10a53 --- /dev/null +++ b/CMake/FindLLVM.cmake @@ -0,0 +1,46 @@ +# Find the native LLVM includes and library +# +# LLVM_INCLUDE_DIR - where to find llvm include files +# LLVM_LIBRARY_DIR - where to find llvm libs +# LLVM_CFLAGS - llvm compiler flags +# LLVM_LFLAGS - llvm linker flags +# LLVM_MODULE_LIBS - list of llvm libs for working with modules. +# LLVM_FOUND - True if llvm found. + +find_program(LLVM_CONFIG_EXECUTABLE NAMES llvm-config DOC "llvm-config executable") + +if (LLVM_CONFIG_EXECUTABLE) + message(STATUS "LLVM llvm-config found at: ${LLVM_CONFIG_EXECUTABLE}") +else (LLVM_CONFIG_EXECUTABLE) + message(FATAL_ERROR "Could NOT find LLVM executable") +endif (LLVM_CONFIG_EXECUTABLE) + +execute_process( + COMMAND ${LLVM_CONFIG_EXECUTABLE} --includedir + OUTPUT_VARIABLE LLVM_INCLUDE_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +execute_process( + COMMAND ${LLVM_CONFIG_EXECUTABLE} --libdir + OUTPUT_VARIABLE LLVM_LIBRARY_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +execute_process( + COMMAND ${LLVM_CONFIG_EXECUTABLE} --cppflags + OUTPUT_VARIABLE LLVM_CFLAGS + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +execute_process( + COMMAND ${LLVM_CONFIG_EXECUTABLE} --ldflags + OUTPUT_VARIABLE LLVM_LFLAGS + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +execute_process( + COMMAND ${LLVM_CONFIG_EXECUTABLE} --libs + OUTPUT_VARIABLE LLVM_MODULE_LIBS + OUTPUT_STRIP_TRAILING_WHITESPACE +) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea840719..41307e58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,11 +44,11 @@ ELSE (USE_FULSIM) ADD_DEFINITIONS(-DUSE_FULSIM=0) ENDIF (USE_FULSIM) -SET(CMAKE_CXX_FLAGS "-Wall -Wno-invalid-offsetof -mfpmath=sse --no-rtti -Wcast-align -std=c++0x") -SET(CMAKE_C_FLAGS "-Wall -mfpmath=sse -msse2 -Wcast-align") +SET(CMAKE_CXX_FLAGS "-Wall -Wno-invalid-offsetof -mfpmath=sse --no-rtti -Wcast-align -std=c++0x -msse2 -msse3 -mssse3 -msse4.1 ") +SET(CMAKE_C_FLAGS "-Wall -mfpmath=sse -msse2 -Wcast-align -msse2 -msse3 -mssse3 -msse4.1 ") # Front end stuff we need -Find_Package(LLVM REQUIRED) +INCLUDE(CMake/FindLLVM.cmake) # XLib INCLUDE(CMake/FindXLib.cmake) @@ -66,6 +66,10 @@ ELSE(DRM_FOUND) MESSAGE(STATUS "Looking for DRM - not found") ENDIF(DRM_FOUND) +# OpenGL +find_package(OpenGL) +# Threads +find_package(Threads) # DRM Intel INCLUDE(CMake/FindDRMIntel.cmake) IF(DRM_INTEL_FOUND) diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt index c36f9701..a460ef3e 100644 --- a/backend/CMakeLists.txt +++ b/backend/CMakeLists.txt @@ -37,7 +37,8 @@ set (CMAKE_C_CXX_FLAGS "-fvisibility=hidden") if (COMPILER STREQUAL "GCC") set (CMAKE_C_CXX_FLAGS "${CMAKE_C_CXX_FLAGS} -funroll-loops -Wstrict-aliasing=2 -fstrict-aliasing -msse2 -msse3 -mssse3 -msse4.1 -ffast-math -fPIC -Wall") - set (CMAKE_CXX_FLAGS "${CMAKE_C_CXX_FLAGS} -fno-exceptions -Wno-invalid-offsetof -fno-rtti -std=c++0x") + set (CMAKE_C_CXX_FLAGS "${CMAKE_C_CXX_FLAGS} ${LLVM_CFLAGS}") + set (CMAKE_CXX_FLAGS "${CMAKE_C_CXX_FLAGS} -Wno-invalid-offsetof -fno-rtti -std=c++0x") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GBE_DEBUG_MEMORY_FLAG}") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GBE_COMPILE_UTESTS_FLAG}") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-E") diff --git a/backend/src/CMakeLists.txt b/backend/src/CMakeLists.txt index 904b5065..c2c91a51 100644 --- a/backend/src/CMakeLists.txt +++ b/backend/src/CMakeLists.txt @@ -1,4 +1,4 @@ -add_subdirectory(llvm) +#add_subdirectory(llvm) macro (stringify TO_STRINGIFY_PATH TO_STRINGIFY_FILES) foreach (to_stringify_file ${TO_STRINGIFY_FILES}) @@ -74,6 +74,12 @@ else (GBE_USE_BLOB) backend/program.cpp backend/program.hpp backend/program.h + llvm/llvm_gen_backend.cpp + llvm/llvm_passes.cpp + llvm/llvm_to_gen.cpp + llvm/llvm_gen_backend.hpp + llvm/llvm_gen_ocl_function.hxx + llvm/llvm_to_gen.hpp backend/gen/gen_mesa_disasm.c backend/gen_insn_selection.cpp backend/gen_insn_selection.hpp @@ -96,18 +102,15 @@ include_directories (.) link_directories (${LLVM_LIBRARY_DIRS}) include_directories(${LLVM_INCLUDE_DIRS}) add_library (gbe SHARED ${GBE_SRC}) -include (${LLVM_DIR}/AddLLVMDefinitions.cmake) -target_link_libraries (gbe - LLVMGenBackend - LLVMTransformUtils - LLVMCore - LLVMAnalysis - LLVMCodeGen - LLVMScalarOpts - LLVMSelectionDAG - LLVMSupport - LLVMAsmParser - LLVMBitReader) + +target_link_libraries( + gbe + ${DRM_INTEL_LIBRARY} + ${DRM_LIBRARY} + ${OPENGL_LIBRARIES} + ${LLVM_MODULE_LIBS} + ${CMAKE_THREAD_LIBS_INIT} + ${CMAKE_DL_LIBS}) install (TARGETS gbe LIBRARY DESTINATION lib) install (FILES backend/program.h DESTINATION include/gen) diff --git a/backend/src/llvm/CMakeLists.txt b/backend/src/llvm/CMakeLists.txt deleted file mode 100644 index b99aa6cf..00000000 --- a/backend/src/llvm/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -include (${LLVM_DIR}/AddLLVM.cmake) -include (${LLVM_DIR}/AddLLVMDefinitions.cmake) -include (${LLVM_DIR}/HandleLLVMOptions.cmake) -include (${LLVM_DIR}/LLVMProcessSources.cmake) -include_directories(${LLVM_INCLUDE_DIRS}) -include_directories(../) -add_llvm_target(GenBackend - llvm_to_gen.cpp - llvm_gen_backend.cpp - llvm_passes.cpp) -target_link_libraries (LLVMGenBackend - LLVMSupport - LLVMAnalysis - LLVMCodeGen - LLVMCore - LLVMScalarOpts - LLVMTarget - LLVMTransformUtils) - diff --git a/backend/src/ocl_stdlib_str.cpp b/backend/src/ocl_stdlib_str.cpp index 7ab67891..98bda56d 100644 --- a/backend/src/ocl_stdlib_str.cpp +++ b/backend/src/ocl_stdlib_str.cpp @@ -2,7 +2,7 @@ namespace gbe { std::string ocl_stdlib_str = "/* \n" -"uint* Copyright © 2012 Intel Corporation\n" +" * Copyright © 2012 Intel Corporation\n" " *\n" " * This library is free software; you can redistribute it and/or\n" " * modify it under the terms of the GNU Lesser General Public\n" @@ -24,6 +24,7 @@ std::string ocl_stdlib_str = "#define __GEN_OCL_STDLIB_H__\n" "\n" "#define INLINE __attribute__((always_inline)) inline\n" +"#define INLINE_OVERLOADABLE __attribute__((overloadable,always_inline))\n" "#define OVERLOADABLE __attribute__((overloadable))\n" "#define PURE __attribute__((pure))\n" "#define CONST __attribute__((const))\n" @@ -58,7 +59,6 @@ std::string ocl_stdlib_str = "DEF(ulong);\n" "DEF(float);\n" "#undef DEF\n" -"\n" "/////////////////////////////////////////////////////////////////////////////\n" "// OpenCL other built-in data types\n" "/////////////////////////////////////////////////////////////////////////////\n" @@ -661,6 +661,7 @@ std::string ocl_stdlib_str = " __gen_ocl_barrier_global();\n" "}\n" "\n" +"\n" "/////////////////////////////////////////////////////////////////////////////\n" "// Force the compilation to SIMD8 or SIMD16\n" "/////////////////////////////////////////////////////////////////////////////\n" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 78062fb4..ee119c75 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,6 +5,8 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} set(OPENCL_SRC cl_api.c + cl_mem_gl.c + cl_gl_api.c cl_alloc.c cl_kernel.c cl_program.c @@ -29,12 +31,14 @@ set(OPENCL_SRC link_directories (${LLVM_LIBRARY_DIRS}) add_library(cl SHARED ${OPENCL_SRC}) -target_link_libraries(cl +target_link_libraries( + cl gbe ${XLIB_LIBRARY} ${XEXT_LIBRARY} ${XFIXES_LIBRARY} ${DRM_INTEL_LIBRARY} - ${DRM_LIBRARY}) + ${DRM_LIBRARY} + ${OPENGL_LIBRARIES}) install (TARGETS cl LIBRARY DESTINATION lib) diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt index 2b52994a..42b18552 100644 --- a/utests/CMakeLists.txt +++ b/utests/CMakeLists.txt @@ -27,11 +27,6 @@ compiler_shader_toy.cpp compiler_lower_return1.cpp compiler_lower_return2.cpp compiler_multiple_kernels.cpp - compiler_obread.cpp - compiler_obwrite.cpp - compiler_region.cpp - compiler_region0.cpp - compiler_region1.cpp compiler_short_scatter.cpp compiler_sub_bytes.cpp compiler_sub_shorts.cpp @@ -61,7 +56,8 @@ compiler_shader_toy.cpp utest_file_map.cpp utest_helper.cpp) -TARGET_LINK_LIBRARIES(utests cl m) +TARGET_LINK_LIBRARIES(utests cl m ${OPENGL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) + ADD_EXECUTABLE(utest_run utest_run.cpp) TARGET_LINK_LIBRARIES(utest_run utests) |