diff --git a/rocclr/CMakeLists.txt b/rocclr/CMakeLists.txt index 22e010104f..9c051543a6 100644 --- a/rocclr/CMakeLists.txt +++ b/rocclr/CMakeLists.txt @@ -1,170 +1,199 @@ -cmake_minimum_required(VERSION 3.4.3) +project(vdi) +cmake_minimum_required(VERSION 3.5) +#example command: +#cmake -DUSE_COMGR_LIBRARY=yes -DOPENCL_DIR=/home/pghafari/git-ocl -DCMAKE_PREFIX_PATH="/home/pghafari/rocmgitvdi/support/lib/comgr;/home/pghafari/rocmgitvdi/support/lib/comgr/build;home/pghafari/rocmgitvdi/hsa-runtime/opensrc/hsa-runtime/build;/home/pghafari/rocmgitvdi/hsa-runtime/opensrc" -DLLVM_INCLUDES=/home/pghafari/rocmgit/llvm-project/llvm/include .. -if (POLICY CMP0048) - cmake_policy(SET CMP0048 NEW) - set(PROJ_VERSION VERSION 1.5.0) -endif() - -# FIXME: Remove following line after enabling COMGR by default -set(USE_COMGR_LIBRARY "no" CACHE STRING "Do not enable COMGR by default") - -# Build ROCm-OpenCL with ccache if the package is present. -set(ROCM_OPENCL_CCACHE_BUILD OFF CACHE BOOL "Set to ON for a ccache enabled build") -if(ROCM_OPENCL_CCACHE_BUILD) - find_program(CCACHE_PROGRAM ccache) - if(CCACHE_PROGRAM) - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PROGRAM}) - else() - message(FATAL_ERROR "Unable to find the program ccache. Set ROCM_OPENCL_CCACHE_BUILD to OFF") - endif() - - # FIXME: Remove following if block after enabling COMGR by default - if (${USE_COMGR_LIBRARY} STREQUAL "no") - set(LLVM_CCACHE_BUILD ON CACHE BOOL "") - set(ROCM_DEVICE_LIBS_CCACHE_BUILD ON CACHE BOOL "") - set(ROCM_OPENCL_DRIVER_CCACHE_BUILD ON CACHE BOOL "") - endif() # if (${USE_COMGR_LIBRARY} STREQUAL "no") -endif() - -project(rocm-opencl) +#cmake -DLLVM_INCLUDES=/home/ixt-rack-79/payam/include -DOPENCL_DIR=/home/ixt-rack-79/payam/ocl4/opencl .. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") -set(OPENCL_ICD_LOADER_HEADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2" CACHE PATH "") +set(USE_COMGR_LIBRARY "yes") +add_definitions(-DUSE_COMGR_LIBRARY -DCOMGR_DYN_DLL) +add_definitions(-DBSD_LIBELF) +find_package(amd_comgr REQUIRED CONFIG + PATHS + /opt/rocm/ + PATH_SUFFIXES + cmake/amd_comgr + lib/cmake/amd_comgr +) +MESSAGE(STATUS "Code Object Manager found at ${amd_comgr_DIR}.") + +find_path(COMGR_INCLUDE + NAMES amd_comgr.h + PATH_SUFFIXES include + PATHS /opt/rocm +) + +find_library( OpenCL REQUIRED CONFIG + PATHS + /opt/rocm +) + +find_path(OPENCL_INCLUDE_DIR + NAMES OpenCL/cl.h CL/cl.h + PATH_SUFFIXES include opencl/include inc include/x86_64 include/x64 + PATHS /opt/rocm + DOC "OpenCL include header OpenCL/cl.h or CL/cl.h" +) + +MESSAGE(STATUS "Opencl fund at ${OPENCL_INCLUDE_DIR}.") +set(OPENCL_ICD_LOADER_HEADERS_DIR "${OPENCL_INCLUDE_DIR}") + +#/khronos/headers/opencl2.2" CACHE PATH "") find_package(ROCT REQUIRED) find_package(ROCR REQUIRED) +set(THREADS_PREFER_PTHREAD_FLAG ON) +find_package(Threads REQUIRED) -# FIXME: Remove following if block after enabling COMGR by default -if (${USE_COMGR_LIBRARY} STREQUAL "no") - set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "") - set(LLVM_BUILD_TOOLS OFF CACHE BOOL "") - set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "") - set(LLVM_TARGETS_TO_BUILD "AMDGPU" CACHE STRING "") - set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "") - set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC") - # override default option value in library and driver - set(GENERIC_IS_ZERO ON CACHE BOOL ON FORCE) +add_definitions(-DLINUX -D__x86_64__ -D__AMD64__ -DUNIX_OS -DqLittleEndian -DOPENCL_MAJOR=2 -DOPENCL_MINOR=1 -DWITH_AQL -DWITH_ONLINE_COMPILER -DATI_OS_LINUX -DATI_ARCH_X86 -DLITTLEENDIAN_CPU -DATI_BITS_64 -DATI_COMP_GCC -DWITH_HSA_DEVICE -DWITH_TARGET_AMDGCN -DOPENCL_EXPORTS -DCL_USE_DEPRECATED_OPENCL_1_0_APIS -DCL_USE_DEPRECATED_OPENCL_1_1_APIS -DCL_USE_DEPRECATED_OPENCL_1_2_APIS -DCL_USE_DEPRECATED_OPENCL_2_0_APIS -DVEGA10_ONLY=false -DWITH_LIGHTNING_COMPILER) +add_definitions(-DOPENCL_C_MAJOR=2 -DOPENCL_C_MINOR=0) - add_subdirectory(compiler/llvm EXCLUDE_FROM_ALL) +set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic -Wl,--unresolved-symbols=report-all") +set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib) - find_package(LLVM REQUIRED CONFIG PATHS ${CMAKE_BINARY_DIR}/compiler/llvm NO_DEFAULT_PATH) - - list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}") - include(AddLLVM) - - add_definitions(${LLVM_DEFINITIONS}) - # TODO: add find_package for Clang and lld, and also use LLVM/Clang variables got from their config - include_directories(${CMAKE_SOURCE_DIR}/compiler/llvm/tools/clang/include) - include_directories(${CMAKE_BINARY_DIR}/compiler/llvm/tools/clang/include) - include_directories(${CMAKE_SOURCE_DIR}/compiler/llvm/tools/lld/include) - - # TODO: move AMDGPU.h header to include folder - include_directories(${CMAKE_SOURCE_DIR}/compiler/llvm/lib/Target/AMDGPU) - include_directories(${CMAKE_BINARY_DIR}/compiler/llvm/lib/Target/AMDGPU) - - set(BUILD_HC_LIB OFF CACHE BOOL "") - set(ROCM_DEVICELIB_INCLUDE_TESTS OFF CACHE BOOL "") - set(AMDGCN_TARGETS_LIB_LIST "AMDGCN_LIB_TARGETS") - set(AMDGCN_TARGETS_LIB_DEPS "AMDGCN_DEP_TARGETS") - set(AMDGPU_TARGET_TRIPLE "amdgcn-amd-amdhsa") - add_subdirectory(library/amdgcn EXCLUDE_FROM_ALL) - add_subdirectory(compiler/driver EXCLUDE_FROM_ALL) - - install(PROGRAMS $ $ - DESTINATION bin/x86_64 - COMPONENT DEV) - - foreach(AMDGCN_LIB_TARGET ${AMDGCN_LIB_TARGETS}) - get_target_property(lib_file_name ${AMDGCN_LIB_TARGET} ARCHIVE_OUTPUT_NAME) - get_target_property(lib_file_path ${AMDGCN_LIB_TARGET} ARCHIVE_OUTPUT_DIRECTORY) - install(FILES ${lib_file_path}/${lib_file_name}.amdgcn.bc - DESTINATION lib/x86_64/bitcode - COMPONENT DEV) - endforeach() -endif() # if (${USE_COMGR_LIBRARY} STREQUAL "no") - -if(${USE_COMGR_LIBRARY} MATCHES "yes") - set(COMGR_DYN_DLL "yes") - add_definitions(-DCOMGR_DYN_DLL) - add_definitions(-DUSE_COMGR_LIBRARY) - if( ${BUILD_HIP} MATCHES "yes") - add_subdirectory(api/hip) - endif() +if(CMAKE_BUILD_TYPE MATCHES "^Debug$") + add_definitions(-DDEBUG) endif() -add_subdirectory(api/opencl/amdocl) -add_subdirectory(compiler/lib/loaders/elf/utils/libelf) -add_subdirectory(runtime) -add_subdirectory(tools/clinfo) +include_directories(${ROCR_INCLUDES}) +if (DEFINED LLVM_INCLUDES AND NOT ${LLVM_INCLUDES} STREQUAL "") + include_directories(${LLVM_INCLUDES}) +endif() # if (DEFINED LLVM_INCLUDES AND NOT ${LLVM_INCLUDES} STREQUAL "") -set(BUILD_SHARED_LIBS "Build shared libs" ON) -add_subdirectory(api/opencl/khronos/icd) +include_directories(${CMAKE_SOURCE_DIR}) +include_directories(${CMAKE_SOURCE_DIR}/include) +include_directories(${CMAKE_SOURCE_DIR}/device/rocm) +include_directories(${OPENCL_DIR}) +include_directories(${OPENCL_DIR}/amdocl) +include_directories(${OPENCL_DIR}/khronos) +include_directories(${OPENCL_DIR}/khronos/headers) +include_directories(${OPENCL_DIR}/khronos/headers/opencl2.2) +include_directories(${OPENCL_INCLUDE_DIR}) +include_directories(${COMGR_INCLUDE}) +#message (${OPENCL_DIR}/opencl/khronos/headers/opencl2.2) -###--- Packaging ------------------------------------------------------------### -find_package(ROCM QUIET CONFIG PATHS /opt/rocm) -include(ROCMSetupVersion) -rocm_setup_version( VERSION "2.0.0" ) +include_directories(${CMAKE_SOURCE_DIR}/compiler/lib) +include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/include) +include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/backends/common) -# MAIN package -install(PROGRAMS $ - DESTINATION bin/x86_64 - COMPONENT MAIN) -install(PROGRAMS $ - DESTINATION lib/x86_64 - COMPONENT MAIN) -install(PROGRAMS $ - DESTINATION lib/x86_64 - COMPONENT MAIN) -install(PROGRAMS $ - DESTINATION lib/x86_64 - COMPONENT MAIN) +include_directories(${CMAKE_SOURCE_DIR}/elf/utils/common) +include_directories(${CMAKE_SOURCE_DIR}/elf/utils/libelf) -# DEV package -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2/CL" - DESTINATION include - COMPONENT DEV - USE_SOURCE_PERMISSIONS - PATTERN cl_d3d10.h EXCLUDE - PATTERN cl_d3d11.h EXCLUDE - PATTERN cl_dx9_media_sharing.h EXCLUDE - PATTERN cl_egl.h EXCLUDE) -install(PROGRAMS $ - DESTINATION lib/x86_64 - COMPONENT DEV) +add_subdirectory(device/rocm) -# Generic CPACK variables -set(CPACK_GENERATOR "DEB;RPM" CACHE STRING "Default packaging generators") -set(CPACK_PACKAGE_CONTACT "Advanced Micro Devices Inc.") -set(CPACK_PACKAGE_VENDOR "AMD") -set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/rocm/opencl") -set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) -# Debian CPACK variables -set(CPACK_DEB_COMPONENT_INSTALL ON) +#find_package(amd_comgr REQUIRED CONFIG) +include_directories("$") +set(COMGR_CPP device/comgrctx.cpp) -set(CPACK_DEBIAN_MAIN_FILE_NAME "rocm-opencl-${PROJECT_VERSION}-Linux.deb") -set(CPACK_DEBIAN_MAIN_PACKAGE_NAME "rocm-opencl") -set(CPACK_DEBIAN_MAIN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/DEB/postinst;${CMAKE_CURRENT_SOURCE_DIR}/DEB/prerm") +add_subdirectory( elf/utils/libelf "${CMAKE_CURRENT_BINARY_DIR}/libelf" ) +add_library(oclruntime OBJECT + thread/thread.cpp + thread/monitor.cpp + thread/semaphore.cpp + utils/flags.cpp + utils/debug.cpp + device/appprofile.cpp + device/device.cpp + device/hwdebug.cpp + device/blitcl.cpp + device/blit.cpp + device/devkernel.cpp + device/devwavelimiter.cpp + device/devprogram.cpp + platform/activity.cpp + platform/kernel.cpp + platform/context.cpp + platform/command.cpp + platform/ndrange.cpp + platform/runtime.cpp + platform/object.cpp + platform/memory.cpp + platform/program.cpp + platform/commandqueue.cpp + platform/agent.cpp + os/os_win32.cpp + os/alloc.cpp + os/os.cpp + os/os_posix.cpp + compiler/lib/utils/options.cpp + elf/elf.cpp + elf/elf_utils.cpp + #${CMAKE_SOURCE_DIR}/compiler/tools/caching/cache.cpp + ${COMGR_CPP} +) -set(CPACK_DEBIAN_FILE_NAME "rocm-opencl-dev-${PROJECT_VERSION}-Linux.deb") -set(CPACK_DEBIAN_PACKAGE_NAME "rocm-opencl-dev") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "rocm-opencl") +set_target_properties(oclruntime PROPERTIES POSITION_INDEPENDENT_CODE ON) -# RPM CPACK variables -set(CPACK_RPM_COMPONENT_INSTALL ON) +add_library(amdvdi_static STATIC + $ + $ + $ + ) +set_target_properties(amdvdi_static PROPERTIES POSITION_INDEPENDENT_CODE ON) +#add_library(oclelf STATIC IMPORTED) +#set_target_properties(oclelf PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/libelf/liboclelf.a") +#target_link_libraries(oclruntime_static PRIVATE oclelf) +target_link_libraries(amdvdi_static PUBLIC Threads::Threads) +target_link_libraries(amdvdi_static PUBLIC dl ${ROCT_LIBRARIES} ${ROCR_LIBRARIES} ) -set(CPACK_RPM_MAIN_FILE_NAME "rocm-opencl-${PROJECT_VERSION}-Linux.rpm") -set(CPACK_RPM_MAIN_PACKAGE_NAME "rocm-opencl") -set(CPACK_RPM_MAIN_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/RPM/rpm_post") -set(CPACK_RPM_MAIN_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/RPM/rpm_postun") +if (UNIX) + set(VDI_DEFAULT_INSTALL_PREFIX "/opt/rocm/vdi") +endif() +#comment out as it's not available in cmake 3.5 +#if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) +if(NOT CMAKE_INSTALL_PREFIX) + if(CMAKE_BUILD_TYPE MATCHES Debug) + set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "Installation path for vdi" FORCE) + #elseif(CMAKE_BUILD_TYPE MATCHES Release) + else() + set(CMAKE_INSTALL_PREFIX ${VDI_DEFAULT_INSTALL_PREFIX} CACHE PATH "Installation path for vdi" FORCE) + # message(FATAL_ERROR "Invalid CMAKE_BUILD_TYPE specified. Valid values are Debug and Release") + endif() +#endif() +endif() +message("cmake install path ${CMAKE_INSTALL_PREFIX}") -set(CPACK_RPM_DEV_FILE_NAME "rocm-opencl-devel-${PROJECT_VERSION}-Linux.rpm") -set(CPACK_RPM_DEV_PACKAGE_NAME "rocm-opencl-devel") -set(CPACK_RPM_DEV_PACKAGE_DEPENDS "rocm-opencl") +install( TARGETS amdvdi_static ARCHIVE DESTINATION lib LIBRARY DESTINATION lib COMPONENT applications) +FILE(GLOB headerfiles "${CMAKE_CURRENT_SOURCE_DIR}/*.h*") +INSTALL ( + FILES ${headerfiles} + DESTINATION include) +INSTALL ( + DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/compiler" + DESTINATION include + FILES_MATCHING PATTERN "*.h*") +INSTALL ( + DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/utils" + DESTINATION include + FILES_MATCHING PATTERN "*.h*") +INSTALL ( + DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/platform" + DESTINATION include + FILES_MATCHING PATTERN "*.h*") +INSTALL ( + DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/thread" + DESTINATION include + FILES_MATCHING PATTERN "*.h*") +INSTALL ( + DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/os" + DESTINATION include + FILES_MATCHING PATTERN "*.h*") +INSTALL ( + DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/device" + DESTINATION include + FILES_MATCHING PATTERN "*.h*") + #set(AMDGCN_DEP_LIST) + #if(AMDGCN_TARGETS_LIB_DEPS) + #set(${AMDGCN_TARGETS_LIB_DEPS} ${AMDGCN_DEP_LIST} PARENT_SCOPE) + #endif() -set(CPACK_COMPONENTS_ALL MAIN DEV) -include(CPack) + #foreach(AMDGCN_DEP_TARGET ${AMDGCN_DEP_TARGETS}) + #add_dependencies(oclruntime ${AMDGCN_DEP_TARGET}) + #endforeach() diff --git a/rocclr/compiler/lib/Doxyfile b/rocclr/compiler/lib/Doxyfile deleted file mode 100644 index 1c59052d73..0000000000 --- a/rocclr/compiler/lib/Doxyfile +++ /dev/null @@ -1,1606 +0,0 @@ -# Doxyfile 1.6.3 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = CompilerLibrary - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = 0.9 - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = D:/hq/stg/opencl/drivers/opencl/compiler/lib/docs - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, -# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, -# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = "The $name class" \ - "The $name widget" \ - "The $name file" \ - is \ - provides \ - specifies \ - contains \ - represents \ - a \ - an \ - the - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = NO - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = YES - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified -# scopes will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for -# Fortran. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for -# VHDL. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it parses. -# With this tag you can assign which parser to use for a given extension. -# Doxygen has a built-in mapping, but you can override or extend it using this tag. -# The format is ext=language, where ext is a file extension, and language is one of -# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, -# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat -# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), -# use: inc=Fortran f=C. Note that for custom extensions you also need to set -# FILE_PATTERNS otherwise the files are not read by doxygen. - -EXTENSION_MAPPING = - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = YES - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public -# instead of private inheritance when no explicit protection keyword is present. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate getter -# and setter methods for a property. Setting this option to YES (the default) -# will make doxygen to replace the get and set methods by a property in the -# documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the -# methods anyway, you should set this option to NO. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = YES - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. - -TYPEDEF_HIDES_STRUCT = YES - -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to -# determine which symbols to keep in memory and which to flush to disk. -# When the cache is full, less often used symbols will be written to disk. -# For small to medium size projects (<1000 input files) the default value is -# probably good enough. For larger projects a too small cache size can cause -# doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penality. -# If the system has enough physical memory increasing the cache will improve the -# performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will rougly double the -# memory usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols - -SYMBOL_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = YES - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = YES - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespace are hidden. - -EXTRACT_ANON_NSPACES = YES - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = NO - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation -# rather than with sharp brackets. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen -# will sort the (brief and detailed) documentation of class members so that -# constructors and destructors are listed first. If set to NO (the default) -# the constructors will appear in the respective orders defined by -# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. -# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO -# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) -# the group names will appear in their defined order. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the -# Folder Tree View (if specified). The default is YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. This will remove the Namespaces entry from the Quick Index -# and from the Folder Tree View (if specified). The default is YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by -# doxygen. The layout file controls the global structure of the generated output files -# in an output format independent way. The create the layout file that represents -# doxygen's defaults, run doxygen with the -l option. You can optionally specify a -# file name after the option, if omitted DoxygenLayout.xml will be used as the name -# of the layout file. - -LAYOUT_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = YES - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = D:/hq/stg/opencl/drivers/opencl/compiler/lib - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for -# the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 - -FILE_PATTERNS = *.c \ - *.cc \ - *.cxx \ - *.cpp \ - *.c++ \ - *.d \ - *.java \ - *.ii \ - *.ixx \ - *.ipp \ - *.i++ \ - *.inl \ - *.h \ - *.hh \ - *.hxx \ - *.hpp \ - *.h++ \ - *.idl \ - *.odl \ - *.cs \ - *.php \ - *.php3 \ - *.inc \ - *.m \ - *.mm \ - *.dox \ - *.py \ - *.f90 \ - *.f \ - *.vhd \ - *.vhdl - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = D:/hq/stg/opencl/drivers/opencl/compiler/lib/backends/gpu/sc \ - D:/hq/stg/opencl/drivers/opencl/compiler/lib/loaders/elf \ - D:/hq/stg/opencl/drivers/opencl/compiler/lib/promotions \ - D:/hq/stg/opencl/drivers/opencl/compiler/lib/loaders/bif/amuabi \ - D:/hq/stg/opencl/drivers/opencl/compiler/lib/include/v0_7 \ - D:/hq/stg/opencl/drivers/opencl/compiler/lib/api/v0_7 \ - D:/hq/stg/opencl/drivers/opencl/compiler/lib/loaders/plugins - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = YES - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = *.d - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = * - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = YES - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = YES - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentation. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = NO - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting -# this to NO can help when comparing the output of multiple runs. - -HTML_TIMESTAMP = YES - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox -# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). - -HTML_DYNAMIC_SECTIONS = NO - -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. - -GENERATE_DOCSET = NO - -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) -# can be grouped. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen -# will append .docset to the name. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file -# content. - -CHM_INDEX_ENCODING = - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER -# are set, an additional index file will be generated that can be used as input for -# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated -# HTML documentation. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. -# The path specified is relative to the HTML output folder. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#namespace - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#virtual-folders - -QHP_VIRTUAL_FOLDER = doc - -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. -# For more information please see -# http://doc.trolltech.com/qthelpproject.html#custom-filters - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see -# Qt Help Project / Custom Filters. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's -# filter section matches. -# Qt Help Project / Filter Attributes. - -QHP_SECT_FILTER_ATTRS = - -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated -# .qhp file. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before -# the help appears. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have -# this name. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. - -GENERATE_TREEVIEW = YES - -# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, -# and Class Hierarchy pages using a tree view instead of an ordered list. - -USE_INLINE_TREES = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory -# to force them to be regenerated. - -FORMULA_FONTSIZE = 10 - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box -# for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using -# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets -# (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine -# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. - -SEARCHENGINE = NO - -# When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a PHP enabled web server instead of at the web client -# using Javascript. Doxygen will generate the search PHP script and index -# file to put on the web server. The advantage of the server -# based approach is that it scales better to large projects and allows -# full text search. The disadvances is that it is more difficult to setup -# and does not have live searching capabilities. - -SERVER_BASED_SEARCH = NO - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. -# Note that when enabling USE_PDFLATEX this option is only used for -# generating bitmaps for formulas in the HTML output, but not in the -# Makefile that is written to the output directory. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = YES - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = YES - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -# If LATEX_SOURCE_CODE is set to YES then doxygen will include -# source code with syntax highlighting in the LaTeX output. -# Note that which sources are shown also depends on other settings -# such as SOURCE_BROWSER. - -LATEX_SOURCE_CODE = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# By default doxygen will write a font called FreeSans.ttf to the output -# directory and reference it in all dot files that doxygen generates. This -# font does not include all possible unicode characters however, so when you need -# these (or just want a differently looking font) you can specify the font name -# using DOT_FONTNAME. You need need to make sure dot is able to find the font, -# which can be done by putting it in a standard location or by setting the -# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory -# containing the font. - -DOT_FONTNAME = FreeSans - -# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. -# The default size is 10pt. - -DOT_FONTSIZE = 10 - -# By default doxygen will tell dot to use the output directory to look for the -# FreeSans.ttf font (which doxygen will put there itself). If you specify a -# different font using DOT_FONTNAME you can set the path where dot -# can find it using this tag. - -DOT_FONTPATH = - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs -# for selected functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller -# graphs for selected functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note -# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. - -DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not -# seem to support this out of the box. Warning: Depending on the platform used, -# enabling this option may lead to badly anti-aliased labels on the edges of -# a graph (i.e. they become hard to read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES diff --git a/rocclr/compiler/lib/amdoclcl.def.in b/rocclr/compiler/lib/amdoclcl.def.in deleted file mode 100644 index a4f923e8c8..0000000000 --- a/rocclr/compiler/lib/amdoclcl.def.in +++ /dev/null @@ -1,52 +0,0 @@ -EXPORTS -aclLoader_OnLoad -aclLoader_OnUnload -aclCompilerInit -aclCompilerFini -aclCompilerVersion -aclVersionSize -aclGetErrorString -aclGetArchInfo -aclGetDeviceInfo -aclGetTargetInfo -aclGetArchitecture -aclGetFamily -aclGetChip -aclBinaryInit -aclBinaryFini -aclReadFromFile -aclReadFromMem -aclWriteToFile -aclWriteToMem -aclCreateFromBinary -aclBinaryVersion -aclInsertSection -aclRemoveSection -aclExtractSection -aclInsertSymbol -aclRemoveSymbol -aclExtractSymbol -aclDbgAddArgument -aclDbgRemoveArgument -aclQueryInfo -aclCompile -aclLink -aclGetCompilerLog -aclRetrieveType -aclSetType -aclConvertType -aclDisassemble -aclGetDeviceBinary -aclInsertKernelStatistics -aclDumpBinary -aclJITObjectImageCreate -aclJITObjectImageCopy -aclJITObjectImageDestroy -aclJITObjectImageFinalize -aclJITObjectImageSize -aclJITObjectImageData -#if defined(LEGACY_COMPLIB) -aclJITObjectImageDisassembleKernel -#endif -aclJITObjectImageIterateSymbols -aclJITObjectImageGetGlobalsSize diff --git a/rocclr/compiler/lib/amdoclcl.map.in b/rocclr/compiler/lib/amdoclcl.map.in deleted file mode 100644 index fe63d57d10..0000000000 --- a/rocclr/compiler/lib/amdoclcl.map.in +++ /dev/null @@ -1,58 +0,0 @@ -ACL_API_0.8 { -global: - aclCompilerInit; - aclCompilerFini; - aclCompilerVersion; - aclVersionSize; - aclGetErrorString; - aclGetArchInfo; - aclGetFamilyInfo; - aclGetDeviceInfo; - aclGetAsicInfo; - aclGetTargetInfo; - aclGetArchitecture; - aclGetFamily; - aclGetChip; - aclGetAsic; - aclBinaryInit; - aclBinaryFini; - aclReadFromFile; - aclReadFromMem; - aclWriteToFile; - aclWriteToMem; - aclCreateFromBinary; - aclBinaryVersion; - aclInsertSection; - aclRemoveSection; - aclExtractSection; - aclInsertSymbol; - aclRemoveSymbol; - aclExtractSymbol; - aclQueryInfo; - aclDbgAddArgument; - aclDbgRemoveArgument; - aclCompile; - aclLink; - aclGetCompilerLog; - aclRetrieveType; - aclSetType; - aclConvertType; - aclDisassemble; - aclInsertKernelStatistics; - aclGetDeviceBinary; - aclLoader_OnLoad; - aclLoader_OnUnload; - aclJITObjectImageCreate; - aclJITObjectImageCopy; - aclJITObjectImageDestroy; - aclJITObjectImageFinalize; - aclJITObjectImageSize; - aclJITObjectImageData; -#if defined(LEGACY_COMPLIB) - aclJITObjectImageDisassembleKernel; -#endif - aclJITObjectImageIterateSymbols; - aclJITObjectImageGetGlobalsSize; -local: - *; -}; diff --git a/rocclr/compiler/lib/amdoclcl.rc b/rocclr/compiler/lib/amdoclcl.rc deleted file mode 100644 index c0b14d40ed..0000000000 --- a/rocclr/compiler/lib/amdoclcl.rc +++ /dev/null @@ -1,75 +0,0 @@ -#define STR(__macro__) #__macro__ -#define XSTR(__macro__) STR(__macro__) - -#if defined(_DEBUG) -#define DEBUG_ONLY(x) x -#else -#define DEBUG_ONLY(x) -#endif - -#define VERSION_PREFIX_MAJOR 1 -#define VERSION_PREFIX_MINOR 1 - - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "winresrc.h" -#include "utils/versions.hpp" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION AMD_COMPILER_MAJOR_VERSION,AMD_COMPILER_MINOR_VERSION,AMD_COMPILER_BUILD_NUMBER,AMD_COMPILER_REVISION_NUMBER - PRODUCTVERSION AMD_COMPILER_MAJOR_VERSION,AMD_COMPILER_MINOR_VERSION,AMD_COMPILER_BUILD_NUMBER,AMD_COMPILER_REVISION_NUMBER - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "Comments", " \0" - VALUE "CompanyName", "Advanced Micro Devices Inc.\0" - VALUE "FileDescription", AMD_COMPILER_NAME " OpenCL " XSTR(VERSION_PREFIX_MAJOR) "." XSTR(VERSION_PREFIX_MINOR) " Compiler\0" - VALUE "FileVersion", XSTR(AMD_COMPILER_MAJOR_VERSION) ", " XSTR(AMD_COMPILER_MINOR_VERSION) ", " XSTR(AMD_COMPILER_BUILD_NUMBER) ", " XSTR(AMD_COMPILER_REVISION_NUMBER) ", " XSTR(AMD_SC_COMPILER_REVISION_NUMBER) - VALUE "InternalName", "AOC" - VALUE "LegalCopyright", "Copyright (C) 2011 Advanced Micro Devices Inc.\0" - VALUE "OriginalFilename", "amdoclcl.dll" - VALUE "ProductName", "AMD Compiler Library " XSTR(VERSION_PREFIX_MAJOR) "." XSTR(VERSION_PREFIX_MINOR) " " AMD_COMPILER_INFO "\0" - VALUE "ProductVersion", XSTR(AMD_COMPILER_MAJOR_VERSION) ", " XSTR(AMD_COMPILER_MINOR_VERSION) ", " XSTR(AMD_COMPILER_BUILD_NUMBER) ", " XSTR(AMD_COMPILER_REVISION_NUMBER) ", " XSTR(AMD_SC_COMPILER_REVISION_NUMBER) - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// diff --git a/rocclr/compiler/lib/backends/common/Disassembler.cpp b/rocclr/compiler/lib/backends/common/Disassembler.cpp deleted file mode 100644 index 1c7f70e151..0000000000 --- a/rocclr/compiler/lib/backends/common/Disassembler.cpp +++ /dev/null @@ -1,345 +0,0 @@ -//===- Disassembler.cpp - Disassembler for hex strings --------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This class implements the disassembler of strings of bytes written in -// hexadecimal, from standard input or from a file. -// -//===----------------------------------------------------------------------===// - -#if defined(LEGACY_COMPLIB) -#include "Disassembler.h" -#include "lib/MC/MCDisassembler/EDDisassembler.h" -#include "lib/MC/MCDisassembler/EDInst.h" -#include "lib/MC/MCDisassembler/EDOperand.h" -#include "lib/MC/MCDisassembler/EDToken.h" -#include "llvm/MC/MCDisassembler.h" -#include "llvm/MC/MCInst.h" -#include "llvm/MC/MCStreamer.h" -#include "llvm/MC/MCSubtargetInfo.h" -#include "llvm/ADT/OwningPtr.h" -#include "llvm/ADT/Triple.h" -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/MemoryObject.h" -#include "llvm/Support/SourceMgr.h" -#include "llvm/Support/TargetRegistry.h" -#include "llvm/Support/raw_ostream.h" - -using namespace llvm; - -typedef std::vector > ByteArrayTy; - -namespace { -class VectorMemoryObject : public MemoryObject { -private: - const ByteArrayTy &Bytes; -public: - VectorMemoryObject(const ByteArrayTy &bytes) : Bytes(bytes) {} - - uint64_t getBase() const { return 0; } - uint64_t getExtent() const { return Bytes.size(); } - - int readByte(uint64_t Addr, uint8_t *Byte) const { - if (Addr >= getExtent()) - return -1; - *Byte = Bytes[Addr].first; - return 0; - } -}; -} - -static bool PrintInsts(const MCDisassembler &DisAsm, - const ByteArrayTy &Bytes, - SourceMgr &SM, raw_ostream &Out, - MCStreamer &Streamer) { - // Wrap the vector in a MemoryObject. - VectorMemoryObject memoryObject(Bytes); - - // Disassemble it to strings. - uint64_t Size; - uint64_t Index; - - for (Index = 0; Index < Bytes.size(); Index += Size) { - MCInst Inst; - - MCDisassembler::DecodeStatus S; - S = DisAsm.getInstruction(Inst, Size, memoryObject, Index, - /*REMOVE*/ nulls(), nulls()); - switch (S) { - case MCDisassembler::Fail: - SM.PrintMessage(SMLoc::getFromPointer(Bytes[Index].second), - SourceMgr::DK_Warning, - "invalid instruction encoding"); - if (Size == 0) - Size = 1; // skip illegible bytes - break; - - case MCDisassembler::SoftFail: - SM.PrintMessage(SMLoc::getFromPointer(Bytes[Index].second), - SourceMgr::DK_Warning, - "potentially undefined instruction encoding"); - // Fall through - - case MCDisassembler::Success: - Streamer.EmitInstruction(Inst); - break; - } - } - - return false; -} - -static bool ByteArrayFromString(ByteArrayTy &ByteArray, - StringRef &Str, - SourceMgr &SM) { - while (!Str.empty()) { - // Strip horizontal whitespace. - if (size_t Pos = Str.find_first_not_of(" \t\r")) { - Str = Str.substr(Pos); - continue; - } - - // If this is the end of a line or start of a comment, remove the rest of - // the line. - if (Str[0] == '\n' || Str[0] == '#') { - // Strip to the end of line if we already processed any bytes on this - // line. This strips the comment and/or the \n. - if (Str[0] == '\n') { - Str = Str.substr(1); - } else { - Str = Str.substr(Str.find_first_of('\n')); - if (!Str.empty()) - Str = Str.substr(1); - } - continue; - } - - // Get the current token. - size_t Next = Str.find_first_of(" \t\n\r#"); - StringRef Value = Str.substr(0, Next); - - // Convert to a byte and add to the byte vector. - unsigned ByteVal = 0; - if (Value.getAsInteger(0, ByteVal) || ByteVal > 255) { - // If we have an error, print it and skip to the end of line. - SM.PrintMessage(SMLoc::getFromPointer(Value.data()), SourceMgr::DK_Error, - "invalid input token"); - Str = Str.substr(Str.find('\n')); - ByteArray.clear(); - continue; - } - - ByteArray.push_back(std::make_pair((unsigned char)ByteVal, Value.data())); - Str = Str.substr(Next); - } - - return false; -} - -int Disassembler::disassemble(const Target &T, - const std::string &Triple, - MCSubtargetInfo &STI, - MCStreamer &Streamer, - MemoryBuffer &Buffer, - SourceMgr &SM, - raw_ostream &Out) { - OwningPtr DisAsm(T.createMCDisassembler(STI)); - if (!DisAsm) { - errs() << "error: no disassembler for target " << Triple << "\n"; - return -1; - } - - // Set up initial section manually here - Streamer.InitSections(); - - bool ErrorOccurred = false; - - // Convert the input to a vector for disassembly. - ByteArrayTy ByteArray; - StringRef Str = Buffer.getBuffer(); - - ErrorOccurred |= ByteArrayFromString(ByteArray, Str, SM); - - if (!ByteArray.empty()) - ErrorOccurred |= PrintInsts(*DisAsm, ByteArray, SM, Out, Streamer); - - return ErrorOccurred; -} - -static int byteArrayReader(uint8_t *B, uint64_t A, void *Arg) { - ByteArrayTy &ByteArray = *((ByteArrayTy*)Arg); - - if (A >= ByteArray.size()) - return -1; - - *B = ByteArray[A].first; - - return 0; -} - -static int verboseEvaluator(uint64_t *V, unsigned R, void *Arg) { - EDDisassembler &disassembler = *(EDDisassembler *)((void **)Arg)[0]; - raw_ostream &Out = *(raw_ostream *)((void **)Arg)[1]; - - if (const char *regName = disassembler.nameWithRegisterID(R)) - Out << "[" << regName << "/" << R << "]"; - - if (disassembler.registerIsStackPointer(R)) - Out << "(sp)"; - if (disassembler.registerIsProgramCounter(R)) - Out << "(pc)"; - - *V = 0; - return 0; -} - -int Disassembler::disassembleEnhanced(const std::string &TS, - MemoryBuffer &Buffer, - SourceMgr &SM, - raw_ostream &Out) { - ByteArrayTy ByteArray; - StringRef Str = Buffer.getBuffer(); - - if (ByteArrayFromString(ByteArray, Str, SM)) { - return -1; - } - - Triple T(TS); - EDDisassembler::AssemblySyntax AS; - - switch (T.getArch()) { - default: - errs() << "error: no default assembly syntax for " << TS.c_str() << "\n"; - return -1; - case Triple::arm: - case Triple::thumb: - AS = EDDisassembler::kEDAssemblySyntaxARMUAL; - break; - case Triple::x86: - case Triple::x86_64: - AS = EDDisassembler::kEDAssemblySyntaxX86ATT; - break; - } - - OwningPtr - disassembler(EDDisassembler::getDisassembler(TS.c_str(), AS)); - - if (disassembler == 0) { - errs() << "error: couldn't get disassembler for " << TS << '\n'; - return -1; - } - - while (ByteArray.size()) { - OwningPtr - inst(disassembler->createInst(byteArrayReader, 0, &ByteArray)); - - if (inst == 0) { - errs() << "error: Didn't get an instruction\n"; - return -1; - } - - ByteArray.erase (ByteArray.begin(), ByteArray.begin() + inst->byteSize()); - - unsigned numTokens = inst->numTokens(); - if ((int)numTokens < 0) { - errs() << "error: couldn't count the instruction's tokens\n"; - return -1; - } - - for (unsigned tokenIndex = 0; tokenIndex != numTokens; ++tokenIndex) { - EDToken *token; - - if (inst->getToken(token, tokenIndex)) { - errs() << "error: Couldn't get token\n"; - return -1; - } - - const char *buf; - if (token->getString(buf)) { - errs() << "error: Couldn't get string for token\n"; - return -1; - } - - Out << '['; - int operandIndex = token->operandID(); - - if (operandIndex >= 0) - Out << operandIndex << "-"; - - switch (token->type()) { - case EDToken::kTokenWhitespace: Out << "w"; break; - case EDToken::kTokenPunctuation: Out << "p"; break; - case EDToken::kTokenOpcode: Out << "o"; break; - case EDToken::kTokenLiteral: Out << "l"; break; - case EDToken::kTokenRegister: Out << "r"; break; - } - - Out << ":" << buf; - - if (token->type() == EDToken::kTokenLiteral) { - Out << "="; - if (token->literalSign()) - Out << "-"; - uint64_t absoluteValue; - if (token->literalAbsoluteValue(absoluteValue)) { - errs() << "error: Couldn't get the value of a literal token\n"; - return -1; - } - Out << absoluteValue; - } else if (token->type() == EDToken::kTokenRegister) { - Out << "="; - unsigned regID; - if (token->registerID(regID)) { - errs() << "error: Couldn't get the ID of a register token\n"; - return -1; - } - Out << "r" << regID; - } - - Out << "]"; - } - - Out << " "; - - if (inst->isBranch()) - Out << "
"; - if (inst->isMove()) - Out << " "; - - unsigned numOperands = inst->numOperands(); - - if ((int)numOperands < 0) { - errs() << "error: Couldn't count operands\n"; - return -1; - } - - for (unsigned operandIndex = 0; operandIndex != numOperands; - ++operandIndex) { - Out << operandIndex << ":"; - - EDOperand *operand; - if (inst->getOperand(operand, operandIndex)) { - errs() << "error: couldn't get operand\n"; - return -1; - } - - uint64_t evaluatedResult; - void *Arg[] = { disassembler.get(), &Out }; - if (operand->evaluate(evaluatedResult, verboseEvaluator, Arg)) { - errs() << "error: Couldn't evaluate an operand\n"; - return -1; - } - Out << "=" << evaluatedResult << " "; - } - - Out << '\n'; - } - - return 0; -} -#endif // LEGACY_COMPLIB \ No newline at end of file diff --git a/rocclr/compiler/lib/backends/common/Disassembler.h b/rocclr/compiler/lib/backends/common/Disassembler.h deleted file mode 100644 index 17d622f1d9..0000000000 --- a/rocclr/compiler/lib/backends/common/Disassembler.h +++ /dev/null @@ -1,47 +0,0 @@ -//===- Disassembler.h - Text File Disassembler ----------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This class implements the disassembler of strings of bytes written in -// hexadecimal, from standard input or from a file. -// -//===----------------------------------------------------------------------===// - -#ifndef DISASSEMBLER_H -#define DISASSEMBLER_H - -#include - -namespace llvm { - -class MemoryBuffer; -class Target; -class raw_ostream; -class SourceMgr; -class MCSubtargetInfo; -class MCStreamer; - -class Disassembler { -public: - static int disassemble(const Target &T, - const std::string &Triple, - MCSubtargetInfo &STI, - MCStreamer &Streamer, - MemoryBuffer &Buffer, - SourceMgr &SM, - raw_ostream &Out); - - static int disassembleEnhanced(const std::string &tripleString, - MemoryBuffer &buffer, - SourceMgr &SM, - raw_ostream &Out); -}; - -} // namespace llvm - -#endif diff --git a/rocclr/compiler/lib/backends/common/LICENSE.TXT b/rocclr/compiler/lib/backends/common/LICENSE.TXT deleted file mode 100644 index 34fdc34016..0000000000 --- a/rocclr/compiler/lib/backends/common/LICENSE.TXT +++ /dev/null @@ -1,72 +0,0 @@ -============================================================================== -LLVM Release License -============================================================================== -University of Illinois/NCSA -Open Source License - -Copyright (c) 2003-2017 University of Illinois at Urbana-Champaign. -All rights reserved. - -Developed by: - - LLVM Team - - University of Illinois at Urbana-Champaign - - http://llvm.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal with -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimers. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimers in the - documentation and/or other materials provided with the distribution. - - * Neither the names of the LLVM Team, University of Illinois at - Urbana-Champaign, nor the names of its contributors may be used to - endorse or promote products derived from this Software without specific - prior written permission. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE -SOFTWARE. - -============================================================================== -Copyrights and Licenses for Third Party Software Distributed with LLVM: -============================================================================== -The LLVM software contains code written by third parties. Such software will -have its own individual LICENSE.TXT file in the directory in which it appears. -This file will describe the copyrights, license, and restrictions which apply -to that code. - -The disclaimer of warranty in the University of Illinois Open Source License -applies to all code in the LLVM Distribution, and nothing in any of the -other licenses gives permission to use the names of the LLVM Team or the -University of Illinois to endorse or promote products derived from this -Software. - -The following pieces of software have additional or alternate copyrights, -licenses, and/or restrictions: - -Program Directory -------- --------- -Google Test llvm/utils/unittest/googletest -OpenBSD regex llvm/lib/Support/{reg*, COPYRIGHT.regex} -pyyaml tests llvm/test/YAMLParser/{*.data, LICENSE.TXT} -ARM contributions llvm/lib/Target/ARM/LICENSE.TXT -md5 contributions llvm/lib/Support/MD5.cpp llvm/include/llvm/Support/MD5.h - -Open source files: -Disassembler.cpp -Disassembler.h diff --git a/rocclr/compiler/lib/backends/common/backend.hpp b/rocclr/compiler/lib/backends/common/backend.hpp deleted file mode 100644 index e7e9cdd3e7..0000000000 --- a/rocclr/compiler/lib/backends/common/backend.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// -// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _BE_BACKEND_HPP_ -#define _BE_BACKEND_HPP_ -#include "compiler_stage.hpp" - -namespace amdcl -{ - /*! \addtogroup Compiler Library - * - * \copydoc amdcl::Backend - * - * @{ - */ - class Backend : public CompilerStage { - Backend(Backend&); // DO NOT IMPLEMENT. - Backend(); // DO NOT IMPLEMENT. - public: - Backend(aclCompiler *cl, aclBinary *elf, aclLogFunction log) - : CompilerStage(cl, elf, log) {} - - virtual ~Backend() {} - - /*! Function that takes in a string that is a source file - * and generates the backend binary that is then - * inserted into the elf file at the correct location. - */ - virtual int jit(const std::string &source) = 0; - }; // class Backend - /*@}*/ -}; // amdcl namespace -#endif // _BE_BACKEND_HPP diff --git a/rocclr/compiler/lib/backends/common/codegen.cpp b/rocclr/compiler/lib/backends/common/codegen.cpp deleted file mode 100644 index 760e6aa602..0000000000 --- a/rocclr/compiler/lib/backends/common/codegen.cpp +++ /dev/null @@ -1,652 +0,0 @@ -// -// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved. -// -#include "top.hpp" - -#include "codegen.hpp" -#include "utils/libUtils.h" -#include "os/os.hpp" -#include "utils/target_mappings.h" -#ifdef _MSC_VER -/* for disabling warning in llvm/ADT/Statistic.h */ -#pragma warning(disable:4146) -#endif -#include "llvm/ADT/Statistic.h" -#ifdef _MSC_VER -#pragma warning(default:4146) -#endif -#if defined(LEGACY_COMPLIB) -#include "llvm/DataLayout.h" -#include "llvm/Module.h" -#include "llvm/ExecutionEngine/ObjectImage.h" -#else -#include "llvm/IR/DataLayout.h" -#include "llvm/IR/Module.h" -#include "llvm/Object/ObjectFile.h" -#endif -#include "llvm/Support/CodeGen.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/FormattedStream.h" -#include "llvm/Support/Host.h" -#include "llvm/Support/raw_ostream.h" -#include "llvm/Support/TargetSelect.h" -#include "llvm/Support/TargetRegistry.h" -#include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetOptions.h" -#include "llvm/Target/TargetSubtargetInfo.h" -#include "llvm/ExecutionEngine/JITEventListener.h" -#include "llvm/ExecutionEngine/MCJIT.h" -#include -#include -#include -#include - -using namespace amdcl; -using namespace llvm; - -//!--------------------------------------------------------------------------!// -// JIT Memory manager -//!--------------------------------------------------------------------------!// -OCLMCJITMemoryManager::~OCLMCJITMemoryManager() { - for (llvm::SmallVectorImpl::iterator - I = AllocatedCodeMem.begin(), E = AllocatedCodeMem.end(); - I != E; ++I) - llvm::sys::Memory::releaseMappedMemory(I->first); - for (llvm::SmallVectorImpl::iterator - I = AllocatedDataMem.begin(), E = AllocatedDataMem.end(); - I != E; ++I) - llvm::sys::Memory::releaseMappedMemory(I->first); -} - -void -OCLMCJITMemoryManager::deallocateSection(uint8_t* BasePtr) { - for (llvm::SmallVectorImpl::iterator - I = AllocatedCodeMem.begin(), E = AllocatedCodeMem.end(); - I != E; ++I) - if (I->first.base() == BasePtr) { - llvm::sys::Memory::releaseMappedMemory(I->first); - AllocatedCodeMem.erase(I); - return; - } - for (llvm::SmallVectorImpl::iterator - I = AllocatedDataMem.begin(), E = AllocatedDataMem.end(); - I != E; ++I) - if (I->first.base() == BasePtr) { - llvm::sys::Memory::releaseMappedMemory(I->first); - AllocatedDataMem.erase(I); - return; - } -} - -void OCLMCJITMemoryManager::reserveMemory(uint64_t Size) { - llvm::sys::MemoryBlock Block = allocateSection(Size); - AllocatedCodeMem.push_back(Allocation(Block, 64)); - allocPtr = (uint8_t*)Block.base(); - allocMaxPtr = allocPtr + Block.size(); -} - -uint8_t *OCLMCJITMemoryManager:: -allocateCodeSection(uintptr_t Size, unsigned Alignment, unsigned SectionID -#if !defined(LEGACY_COMPLIB) - , llvm::StringRef SectionName -#endif - ) { - // The recording memory manager is just a local copy of the remote target. - // The alignment requirement is just stored here for later use. Regular - // heap storage is sufficient here, but we're using mapped memory to work - // around a bug in MCJIT. - uint8_t* address = reservedAlloc(Size, Alignment); - if(address != NULL) { - return address; - } else { - llvm::sys::MemoryBlock Block = allocateSection(Size); - AllocatedCodeMem.push_back(Allocation(Block, Alignment)); - return (uint8_t*)Block.base(); - } -} - -uint8_t *OCLMCJITMemoryManager:: -allocateDataSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, -#if !defined(LEGACY_COMPLIB) - llvm::StringRef SectionName, -#endif - bool isReadOnly) { - // The recording memory manager is just a local copy of the remote target. - // The alignment requirement is just stored here for later use. Regular - // heap storage is sufficient here, but we're using mapped memory to work - // around a bug in MCJIT. - uint8_t* address = reservedAlloc(Size, Alignment); - if(address != NULL) { - return address; - } else { - llvm::sys::MemoryBlock Block = allocateSection(Size); - AllocatedDataMem.push_back(Allocation(Block, Alignment)); - return (uint8_t*)Block.base(); - } -} - -uint8_t * OCLMCJITMemoryManager::reservedAlloc(uintptr_t Size, unsigned Alignment) { - if(allocPtr != NULL) { - uint8_t *allocPtrAligned = - (uint8_t*)(((uintptr_t)allocPtr + - ((uintptr_t)Alignment-1)) & ~((uintptr_t)Alignment-1)); - uint8_t *allocPtrNext = allocPtrAligned + Size; - if(allocPtrNext < allocMaxPtr) { - allocPtr = allocPtrNext; - return allocPtrAligned; - } - } - return NULL; -} - -llvm::sys::MemoryBlock OCLMCJITMemoryManager::allocateSection(uintptr_t Size) { -#if defined(LEGACY_COMPLIB) - llvm::error_code ec; -#else - std::error_code ec; -#endif - llvm::sys::MemoryBlock MB = - llvm::sys::Memory::allocateMappedMemory(Size, - &Near, - llvm::sys::Memory::MF_READ | - llvm::sys::Memory::MF_WRITE | - llvm::sys::Memory::MF_EXEC, - ec); - assert(!ec && MB.base()); - - // FIXME: This is part of a work around to keep sections near one another - // when MCJIT performs relocations after code emission but before - // the generated code is moved to the remote target. - // Save this address as the basis for our next request - Near = MB; - return MB; -} - -#if !defined(LEGACY_COMPLIB) -void OCLMCJITMemoryManager::reserveAllocationSpace(uintptr_t CodeSize, - uint32_t CodeAlign, - uintptr_t RODataSize, - uint32_t RODataAlign, - uintptr_t RWDataSize, - uint32_t RWDataAlign) { - uint64_t GOTTableReserveSize = 4096; - uint64_t Size = (uint64_t)CodeSize + (uint64_t)RODataSize + - (uint64_t)RWDataSize + GOTTableReserveSize; - if ((uint64_t)allocPtr + (uint64_t)Size > (uint64_t)allocMaxPtr) - reserveMemory(Size); -} -#endif // !LEGACY_COMPLIB - -void OCLMCJITMemoryManager::setMemoryWritable() { - assert(!"Unexpected"); -} - -void OCLMCJITMemoryManager::setMemoryExecutable() { - assert(!"Unexpected"); -} - -void OCLMCJITMemoryManager::setPoisonMemory(bool poison) { - assert(!"Unexpected"); -} - -void OCLMCJITMemoryManager::AllocateGOT() { - assert(!"Unexpected"); -} - -uint8_t *OCLMCJITMemoryManager::getGOTBase() const { - assert(!"Unexpected"); - return 0; -} -uint8_t *OCLMCJITMemoryManager::startFunctionBody(const llvm::Function *F, - uintptr_t &ActualSize) { - assert(!"Unexpected"); - return 0; -} -uint8_t *OCLMCJITMemoryManager::allocateStub(const llvm::GlobalValue* F, - unsigned StubSize, - unsigned Alignment) { - assert(!"Unexpected"); - return 0; -} -void OCLMCJITMemoryManager::endFunctionBody(const llvm::Function *F, - uint8_t *FunctionStart, - uint8_t *FunctionEnd) { - assert(!"Unexpected"); -} -uint8_t *OCLMCJITMemoryManager::allocateSpace(intptr_t Size, - unsigned Alignment) { - assert(!"Unexpected"); - return 0; -} -uint8_t *OCLMCJITMemoryManager::allocateGlobal(uintptr_t Size, - unsigned Alignment) { - assert(!"Unexpected"); - return 0; -} -void OCLMCJITMemoryManager::deallocateFunctionBody(void *Body) { - assert(!"Unexpected"); -} -uint8_t* OCLMCJITMemoryManager::startExceptionTable(const llvm::Function* F, - uintptr_t &ActualSize) { - assert(!"Unexpected"); - return 0; -} -void OCLMCJITMemoryManager::endExceptionTable(const llvm::Function *F, - uint8_t *TableStart, - uint8_t *TableEnd, - uint8_t* FrameRegister) { - assert(!"Unexpected"); -} -void OCLMCJITMemoryManager::deallocateExceptionTable(void *ET) { - assert(!"Unexpected"); -} - -static int jit_noop() { - return 0; -} - -void *OCLMCJITMemoryManager::getPointerToNamedFunction(const std::string &Name, - bool AbortOnFailure) { - // We should not invoke parent's ctors/dtors from generated main()! - // On Mingw and Cygwin, the symbol __main is resolved to - // callee's(eg. tools/lli) one, to invoke wrong duplicated ctors - // (and register wrong callee's dtors with atexit(3)). - // We expect ExecutionEngine::runStaticConstructorsDestructors() - // is called before ExecutionEngine::runFunctionAsMain() is called. - if (Name == "__main") return (void*)(intptr_t)&jit_noop; - - return NULL; -} - -//!--------------------------------------------------------------------------!// -// JIT Event Listener -//!--------------------------------------------------------------------------!// -class OclJITEventListener : public llvm::JITEventListener -{ -private: - std::string* output_; - -public: - OclJITEventListener(std::string &output) { - output_ = &output; - } - - virtual void NotifyObjectEmitted -#if defined(LEGACY_COMPLIB) - (const llvm::ObjectImage &Obj) -#else - (const llvm::object::ObjectFile &Obj, const llvm::RuntimeDyld::LoadedObjectInfo &L) -#endif - override { - encodeObjectImage(Obj.getData(), *output_); - } - - // Encoding and decoding are used to eliminate 0x00 ('\0') from the - // string so it is safe to use it as a null terminated c string. - // Translate: - // 0x00 -> 0xaa 0x55 - // 0xaa -> 0xaa 0xaa - static void encodeObjectImage(std::string objectImage, std::string &encodedObjectImage) { - size_t length = objectImage.length(); - for (size_t i = 0; i < length; ++i) { - unsigned char c = objectImage[i]; - switch (c) { - case 0x00U: - encodedObjectImage.push_back(0xaaU); - encodedObjectImage.push_back(0x55U); - break; - case 0xaaU: - encodedObjectImage.push_back(0xaaU); - encodedObjectImage.push_back(0xaaU); - break; - default: - encodedObjectImage.push_back(c); - break; - } - } - } - - // Translate: - // 0xaa 0x55 -> 0x00 - // 0xaa 0xaa -> 0xaa - static void decodeObjectImage(std::string encodedObjectImage, std::string &decodedObjectImage) { - size_t length = encodedObjectImage.length(); - for (size_t i = 0; i < length; ++i) { - unsigned char c = encodedObjectImage[i]; - switch (c) { - case 0xaaU: - { - i = i + 1; // Increment to advance two characters - unsigned char cnext = encodedObjectImage[i]; - if (cnext == 0xaaU) { - decodedObjectImage.push_back(0xaaU); - } else if (cnext == 0x55U) { - decodedObjectImage.push_back(0x00U); - } else { - assert(!"Bad encoding encountered"); - } - } - break; - default: - decodedObjectImage.push_back(c); - break; - } - } - } - -}; - -void decodeObjectImage(std::string encodedObjectImage, std::string &decodedObjectImage) { - OclJITEventListener::decodeObjectImage(encodedObjectImage, decodedObjectImage); -} - -// Returns empty string if code generation was successful, -// otherwise the return string contains the error the MCJIT encountered. -std::string -jitCodeGen(llvm::Module* Composite, - llvm::TargetMachine* TargetMachine, - llvm::CodeGenOpt::Level OLvl, - std::string& output) { - std::string ErrStr; - OclJITEventListener Listener(output); - llvm::InitializeNativeTargetAsmParser(); - llvm::InitializeNativeTargetAsmPrinter(); -#if defined(LEGACY_COMPLIB) - OCLMCJITMemoryManager* MemMgr = new OCLMCJITMemoryManager(); - llvm::EngineBuilder builder(Composite); -#else - std::unique_ptr MemMgr(new OCLMCJITMemoryManager()); - // FIXME: this llvm::Module* actually seems to be got from unique_ptr::get() - // somewhere, but acl functions use Module* instead of std::unique_ptr - // llvm::EngineBuilder does std::move on this pointer further so Module* can be - // deleted twice... llvm::EngineBuilder builder(Composite); - std::unique_ptr MPtr(Composite); - llvm::EngineBuilder builder(std::move(MPtr)); -#endif - builder.setOptLevel(OLvl); - builder.setErrorStr(&ErrStr); -#if defined(LEGACY_COMPLIB) - builder.setJITMemoryManager(MemMgr); - builder.setUseMCJIT(true); -#else - builder.setMCJITMemoryManager(std::move(MemMgr)); -#endif - // builder.setRelocationModel(llvm::Reloc::PIC_) - // builder.setCodeModel(llvm::CodeModel::Large) -#ifndef ANDROID - std::unique_ptr - TheExecutionEngine(builder.create(TargetMachine)); - - TheExecutionEngine->RegisterJITEventListener(&Listener); - TheExecutionEngine->finalizeObject(); - TheExecutionEngine->removeModule(Composite); -#endif - return ErrStr; -} - -int -llvmCodeGen( - Module* Composite, - amd::option::Options *OptionsObj, - std::string& output, - aclBinary* binary) -{ - const FamilyMapping &familyMap = familySet[binary->target.arch_id]; - const bool optimize = (OptionsObj ? (OptionsObj->oVariables->OptLevel > amd::option::OPT_O0) : true); - const TargetMapping* targetMap = familyMap.target; - unsigned famID = binary->target.chip_id; - if (!targetMap || !targetMap[famID].supported) { - LogError("Device is not supported by code generator!"); - return 1; - } - - // Load the module to be compiled... - Module &mod = *Composite; - - // FIXME: The triple given in this map is wrong and isn't really - // useful. Only need the architecture. - const std::string TargetTriple = std::string(familyMap.triple); - Triple TheTriple(TargetTriple); - if (TheTriple.getTriple().empty()) { - TheTriple.setTriple(sys::getDefaultTargetTriple()); - } - - Triple::ArchType arch = TheTriple.getArch(); - - bool isGPU = (arch == Triple::amdil || arch == Triple::amdil64 || - arch == Triple::hsail || arch == Triple::hsail64); - - if (isGPU) { - TheTriple.setOS(Triple::UnknownOS); - } else { // CPUs - // FIXME: This should come from somewhere else. -#ifdef __linux__ - TheTriple.setOS(Triple::Linux); -#else -#if defined(LEGACY_COMPLIB) - TheTriple.setOS(Triple::MinGW32); -#else - TheTriple.setOS(Triple::Win32); -#endif -#endif - } - - TheTriple.setEnvironment(Triple::AMDOpenCL); - // FIXME: need to make AMDOpenCL be the same as ELF - if (OptionsObj->oVariables->UseJIT) -#if defined(LEGACY_COMPLIB) - TheTriple.setEnvironment(Triple::ELF); -#else - TheTriple.setObjectFormat(Triple::ELF); -#endif - mod.setTargetTriple(TheTriple.getTriple()); - - // Allocate target machine. First, check whether the user has explicitly - // specified an architecture to compile for. If so we have to look it up by - // name, because it might be a backend that has no mapping to a target triple. - const Target *TheTarget = 0; - assert(binary->target.arch_id != aclError && "Cannot have the error device!"); - - std::string MArch = familyMap.architecture; - -#ifdef WITH_TARGET_HSAIL - if (MArch == "hsail" && OptionsObj->oVariables->GPU64BitIsa) { - MArch = std::string("hsail64"); - } -#endif - -#if defined(LEGACY_COMPLIB) - for (TargetRegistry::iterator it = TargetRegistry::begin(), - ie = TargetRegistry::end(); it != ie; ++it) { -#else - for (TargetRegistry::iterator it = TargetRegistry::targets().begin(), - ie = TargetRegistry::targets().end(); it != ie; ++it) { -#endif - if (MArch == it->getName()) { - TheTarget = &*it; - break; - } - } - - if (!TheTarget) { - errs() << ": ERROR: invalid target '" << MArch << "'.\n"; - return 1; - } - - CodeGenOpt::Level OLvl = CodeGenOpt::None; - switch (OptionsObj->oVariables->OptLevel) { - case amd::option::OPT_O0: // -O0 - OLvl = CodeGenOpt::None; - break; - case amd::option::OPT_O1: // -O1 - OLvl = CodeGenOpt::Less; - break; - default: - assert(!"Error with optimization level"); - case amd::option::OPT_O2: // -O2 - case amd::option::OPT_O5: // -O5 - case amd::option::OPT_OG: // -Og - case amd::option::OPT_OS: // -Os - OLvl = CodeGenOpt::Default; - break; - case amd::option::OPT_O3: // -O3 - case amd::option::OPT_O4: // -O4 - OLvl = CodeGenOpt::Aggressive; - break; - }; - - // Adjust the triple to match (if known), otherwise stick with the - // module/host triple. - Triple::ArchType Type = Triple::getArchTypeForLLVMName(MArch); - if (Type != Triple::UnknownArch) - TheTriple.setArch(Type); - - // Package up features to be passed to target/subtarget - std::string FeatureStr = getFeatureString(binary->target, OptionsObj); - - llvm::TargetOptions targetOptions; - targetOptions.StackAlignmentOverride = - OptionsObj->oVariables->CPUStackAlignment; - // jgolds - //targetOptions.EnableEBB = (optimize && OptionsObj->oVariables->CGEBB); - //targetOptions.EnableBFO = OptionsObj->oVariables->CGBFO; - //targetOptions.NoExcessFPPrecision = !OptionsObj->oVariables->EnableFMA; - - // Don't allow unsafe optimizations for CPU because the library - // contains code that is not safe. See bug 9567. - if (isGPU) - targetOptions.UnsafeFPMath = OptionsObj->oVariables->UnsafeMathOpt; - targetOptions.LessPreciseFPMADOption = OptionsObj->oVariables->MadEnable || - OptionsObj->oVariables->EnableMAD; - targetOptions.NoInfsFPMath = OptionsObj->oVariables->FiniteMathOnly; - // Need to add a support for OptionsObj->oVariables->NoSignedZeros, - targetOptions.NoNaNsFPMath = OptionsObj->oVariables->FiniteMathOnly; - - std::auto_ptr - target(TheTarget->createTargetMachine(TheTriple.getTriple(), - aclutGetCodegenName(binary->target), FeatureStr, targetOptions, - WINDOWS_SWITCH(Reloc::DynamicNoPIC, Reloc::PIC_), - CodeModel::Default, OLvl)); - assert(target.get() && "Could not allocate target machine!"); - - // MCJIT(Jan) - if(!isGPU && OptionsObj->oVariables->UseJIT) { - TargetMachine* jittarget(TheTarget->createTargetMachine(TheTriple.getTriple(), - aclutGetCodegenName(binary->target), FeatureStr, targetOptions, - WINDOWS_SWITCH(Reloc::DynamicNoPIC, Reloc::PIC_), - CodeModel::Default, OLvl)); - - std::string ErrStr = jitCodeGen(Composite, jittarget, OLvl, output); - - if (!ErrStr.empty()) { - LogError("MCJIT failed to generate code"); - LogError(ErrStr.c_str()); - return 1; - } - return 0; - } - - - TargetMachine &Target = *target; - - // Figure out where we are going to send the output... -#if defined(LEGACY_COMPLIB) - raw_string_ostream *RSOut = new raw_string_ostream(output); - formatted_raw_ostream *Out = new formatted_raw_ostream(*RSOut, formatted_raw_ostream::DELETE_STREAM); -#else - auto RSOut = llvm::make_unique(output); - if (!RSOut) { - LogError("llvmCodeGen couldn't create an output stream"); - return 1; - } - auto Out = llvm::make_unique(*RSOut); -#endif - if (!Out) { - LogError("llvmCodeGen couldn't create an output stream"); - return 1; - } - - // Build up all of the passes that we want to do to the module or function or - // Basic Block. - legacy::PassManager Passes; - - // Add the target data from the target machine, if it exists, or the module. - mod.setDataLayout(Target.createDataLayout()); - // Override default to generate verbose assembly, if the device is not the GPU. - // The GPU sets this in AMDILTargetMachine.cpp. - if (familyMap.target == (const TargetMapping*)&X86TargetMapping || - familyMap.target == (const TargetMapping*)&X64TargetMapping - ) { -#if defined(LEGACY_COMPLIB) - Target.setAsmVerbosityDefault(true); -#else - Target.Options.MCOptions.AsmVerbose = true; -#endif - } - -#ifdef WITH_TARGET_HSAIL - if (isHSAILTarget(binary->target)) { - if (Target.addPassesToEmitFile(Passes, *Out, TargetMachine::CGFT_ObjectFile, true)) { -#if defined(LEGACY_COMPLIB) - delete Out; -#endif - return 1; - } - } else -#endif - { -#ifndef NDEBUG - if (Target.addPassesToEmitFile(Passes, *Out, TargetMachine::CGFT_AssemblyFile, false)) -#else - if (Target.addPassesToEmitFile(Passes, *Out, TargetMachine::CGFT_AssemblyFile, true)) -#endif - { -#if defined(LEGACY_COMPLIB) - delete Out; -#endif - return 1; - } - } - - Passes.run(mod); - llvm::PrintStatistics(); -#if defined(LEGACY_COMPLIB) - delete Out; -#endif - return 0; -} - - int -CLCodeGen::codegen(llvm::Module *input) -{ - uint64_t time_cg = 0ULL; - if (Options()->oVariables->EnableBuildTiming) { - time_cg = amd::Os::timeNanos(); - } - llvmbinary_ = input; - amdcl::CompilerStage *cs = reinterpret_cast(this); - if (!isHSAILTarget(cs->Elf()->target)) { - setWholeProgram(true); - } - setUniformWorkGroupSize(Options()->oVariables->UniformWorkGroupSize); - - int ret = llvmCodeGen(LLVMBinary(), Options(), Source(), Elf()); - - if (Options()->oVariables->EnableBuildTiming) { - time_cg = amd::Os::timeNanos() - time_cg; - std::stringstream tmp_ss; - tmp_ss << " LLVM CodeGen time: " - << time_cg/1000ULL - << "us\n"; - appendLogToCL(CL(), tmp_ss.str()); - } - if (!Source().empty() && Options()->isDumpFlagSet(amd::option::DUMP_CGIL)) { - std::string ilFileName = Options()->getDumpFileName(".il"); - std::fstream f; - f.open(ilFileName.c_str(), (std::fstream::out | std::fstream::binary)); - f.write(Source().data(), Source().length()); - f.close(); - } - - return ret; -} diff --git a/rocclr/compiler/lib/backends/common/codegen.hpp b/rocclr/compiler/lib/backends/common/codegen.hpp deleted file mode 100644 index c36899cd5b..0000000000 --- a/rocclr/compiler/lib/backends/common/codegen.hpp +++ /dev/null @@ -1,191 +0,0 @@ -// -// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _BE_CODEGEN_HPP_ -#define _BE_CODEGEN_HPP_ -#include "compiler_stage.hpp" -#if defined(LEGACY_COMPLIB) -#include "llvm/ExecutionEngine/JITMemoryManager.h" -#else -#include "llvm/ExecutionEngine/RTDyldMemoryManager.h" -#endif - -namespace amdcl -{ - /*! \addtogroup Compiler Library - * - * \copydoc amdcl::CodeGen - * - * @{ - */ - class CodeGen : public LLVMCompilerStage { - CodeGen(CodeGen&); // DO NOT IMPLEMENT. - CodeGen(); // DO NOT IMPLEMENT. - public: - CodeGen(aclCompiler *cl, aclBinary *elf, aclLogFunction log) - : LLVMCompilerStage(cl, elf, log) {} - - virtual ~CodeGen() {} - - /*! Function that takes in an LLVM module as input - * and generates code for it based on the target - * device. - * Returns 0 on success and non-zero on failure. - */ - virtual int codegen(llvm::Module *input) = 0; - - }; // class CodeGen - /*@}*/ - - /*! \addtogroup Compiler Library - * - * \copydoc amdcl::CLCodeGen - * - * @{ - */ - class CLCodeGen : public CodeGen { - CLCodeGen(CLCodeGen&); // DO NOT IMPLEMENT. - CLCodeGen(); // DO NOT IMPLEMENT. - public: - CLCodeGen(aclCompiler *cl, aclBinary *elf, aclLogFunction log) - : CodeGen(cl, elf, log) {} - - virtual ~CLCodeGen() {} - - /*! Function that takes in an LLVM module as input - * and generates code for it based on the target - * device. - * Returns 0 on success and non-zero on failure. - */ - virtual int codegen(llvm::Module *input); - - }; // class CLCodeGen - /*@}*/ - -#if 0 - /*! \addtogroup Compiler Library - * - * \copydoc amdcl::AMDILCodeGen - * - * @{ - */ - class AMDILCodeGen : public CodeGen { - AMDILCodeGen(AMDILCodeGen&); // DO NOT IMPLEMENT. - AMDILCodeGen(); // DO NOT IMPLEMENT. - public: - AMDILCodeGen(aclCompiler *cl, aclBinary *elf, llvm::LLVMContext *ctx) - : CLCodeGen(cl, elf, ctx) {} - - virtual ~AMDILCodeGen() {} - - /*! Function that takes in an LLVM module as input - * and generates code for it based on the target - * device. - * Returns 0 on success and non-zero on failure. - */ - int codegen(llvm::Module *input) = 0; - - }; // class AMDILCodeGen - /*@}*/ -#endif -} // amdcl namespace - -//!--------------------------------------------------------------------------!// -// JIT Memory manager -//!--------------------------------------------------------------------------!// -class OCLMCJITMemoryManager : public -#if defined(LEGACY_COMPLIB) - llvm::JITMemoryManager -#else - llvm::RTDyldMemoryManager -#endif -{ -public: - typedef std::pair Allocation; - -private: - llvm::SmallVector AllocatedDataMem; - llvm::SmallVector AllocatedCodeMem; - - // FIXME: This is part of a work around to keep sections near one another - // when MCJIT performs relocations after code emission but before - // the generated code is moved to the remote target. - llvm::sys::MemoryBlock Near; - uint8_t * reservedAlloc(uintptr_t Size, unsigned Alignment); - llvm::sys::MemoryBlock allocateSection(uintptr_t Size); - - uint8_t *allocPtr; - uint8_t *allocMaxPtr; - -public: - OCLMCJITMemoryManager() : allocPtr(NULL), allocMaxPtr(NULL) {} - virtual ~OCLMCJITMemoryManager(); - - typedef llvm::SmallVectorImpl::const_iterator const_data_iterator; - typedef llvm::SmallVectorImpl::const_iterator const_code_iterator; - - const_data_iterator data_begin() const { return AllocatedDataMem.begin(); } - const_data_iterator data_end() const { return AllocatedDataMem.end(); } - const_code_iterator code_begin() const { return AllocatedCodeMem.begin(); } - const_code_iterator code_end() const { return AllocatedCodeMem.end(); } - - virtual void reserveMemory(uint64_t size); - -#if defined(LEGACY_COMPLIB) - uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment, - unsigned SectionID); - - uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment, - unsigned SectionID, bool isReadOnly); - - bool applyPermissions(std::string *ErrMsg) { return false; } - -#else - virtual bool needsToReserveAllocationSpace() override { return true; } - - virtual void reserveAllocationSpace(uintptr_t CodeSize, uint32_t CodeAlign, - uintptr_t RODataSize, - uint32_t RODataAlign, - uintptr_t RWDataSize, - uint32_t RWDataAlign) override; - - uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment, - unsigned SectionID, llvm::StringRef SectionName) override; - - uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment, - unsigned SectionID, llvm::StringRef SectionName, - bool isReadOnly) override; - - bool finalizeMemory(std::string *ErrMsg = nullptr) override { return false; } -#endif - - void *getPointerToNamedFunction(const std::string &Name, - bool AbortOnFailure = true); - - // The following obsolete JITMemoryManager calls are stubbed out for - // this model. - void setMemoryWritable(); - void setMemoryExecutable(); - void setPoisonMemory(bool poison); - void AllocateGOT(); - uint8_t *getGOTBase() const; - uint8_t *startFunctionBody(const llvm::Function *F, uintptr_t &ActualSize); - uint8_t *allocateStub(const llvm::GlobalValue* F, unsigned StubSize, - unsigned Alignment); - void endFunctionBody(const llvm::Function *F, uint8_t *FunctionStart, - uint8_t *FunctionEnd); - uint8_t *allocateSpace(intptr_t Size, unsigned Alignment); - uint8_t *allocateGlobal(uintptr_t Size, unsigned Alignment); - void deallocateFunctionBody(void *Body); - uint8_t* startExceptionTable(const llvm::Function* F, uintptr_t &ActualSize); - void endExceptionTable(const llvm::Function *F, uint8_t *TableStart, - uint8_t *TableEnd, uint8_t* FrameRegister); - void deallocateExceptionTable(void *ET); - void deallocateSection(uint8_t* BasePtr); -}; - -// The jitCodeGen function creates a string where the '\0' characters -// have been encoded. decodeObjectImage puts the '\0' characters back. -void decodeObjectImage(std::string encodedObjectImage, std::string &decodedObjectImage); - -#endif // _BE_CODEGEN_HPP_ diff --git a/rocclr/compiler/lib/backends/common/compiler_stage.cpp b/rocclr/compiler/lib/backends/common/compiler_stage.cpp deleted file mode 100644 index e9f2450c0b..0000000000 --- a/rocclr/compiler/lib/backends/common/compiler_stage.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// -// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved. -// -#include "compiler_stage.hpp" -#include "utils/libUtils.h" -#if defined(LEGACY_COMPLIB) -#include "llvm/Assembly/Parser.h" -#include "llvm/LLVMContext.h" -#else -#include "llvm/AsmParser/Parser.h" -#include "llvm/IR/LLVMContext.h" -#endif - -using namespace amdcl; - -CompilerStage::CompilerStage(aclCompiler* cl, aclBinary* elf, - aclLogFunction callback) -: cl_(cl), elf_(elf), binary_(NULL), - source_(""), log_(""), callback_(callback) -{ - opts_ = (amd::option::Options*)Elf()->options; -} - -CompilerStage::~CompilerStage() -{ } - -LLVMCompilerStage::LLVMCompilerStage(aclCompiler *cl, aclBinary *elf, - aclLogFunction callback) -: CompilerStage(cl, elf, callback), - llvmbinary_(NULL), - context_(NULL) -{ - if (!Options()->oVariables->DisableAllWarnings) { - hookup_.LLVMBuildLog = &log_; - } - // Expose some options to LLVM. - llvm::AMDOptions *amdopts = &hookup_.amdoptions; - amdopts->OptLiveness = Options()->oVariables->OptLiveness; - if (isHSAILTarget(Elf()->target)) { - if ((amdopts->NumAvailGPRs == ~0u) || (Options()->NumAvailGPRs != -1)) - amdopts->NumAvailGPRs = Options()->NumAvailGPRs; - } else { - amdopts->OptPrintLiveness = Options()->oVariables->OptPrintLiveness; - amdopts->OptMem2reg = Options()->oVariables->OptMem2reg; - amdopts->UseJIT = Options()->oVariables->UseJIT; - amdopts->APThreshold = Options()->oVariables->APThreshold; - amdopts->AAForBarrier = Options()->oVariables->AAForBarrier; - amdopts->UnrollScratchThreshold = 500; - amdopts->AmdilUseDefaultResId = Options()->oVariables->DefaultResourceId; - } - amdopts->OptSimplifyLibCall = Options()->oVariables->OptSimplifyLibCall; - amdopts->EnableFDiv2FMul = Options()->oVariables->EnableFDiv2FMul; - amdopts->SRThreshold = Options()->oVariables->SRThreshold; - amdopts->OptMemCombineMaxVecGen = Options()->oVariables->OptMemCombineMaxVecGen; - amdopts->OptLICM = Options()->oVariables->OptLICM; - - // math-related options - amdopts->UnsafeMathOpt = Options()->oVariables->UnsafeMathOpt; - amdopts->NoSignedZeros = Options()->oVariables->NoSignedZeros; - amdopts->FiniteMathOnly = Options()->oVariables->FiniteMathOnly; - amdopts->FastRelaxedMath = Options()->oVariables->FastRelaxedMath; - - amdopts->LUThreshold = Options()->oVariables->LUThreshold; - amdopts->LUCount = Options()->oVariables->LUCount; - amdopts->LUAllowPartial = Options()->oVariables->LUAllowPartial; - amdopts->GPUArch = (uint32_t)getLibraryType(&elf->target); -} - - void -LLVMCompilerStage::setContext(aclContext *ctx) -{ - context_ = reinterpret_cast(ctx); - if (ctx) { - Context().setAMDLLVMContextHook(&hookup_); - } -} - -LLVMCompilerStage::~LLVMCompilerStage() -{ - if (context_) { - Context().setAMDLLVMContextHook(NULL); - } -} - - llvm::Module* -LLVMCompilerStage::loadBitcode(std::string& llvmBinary) -{ - if (!llvm::isBitcode(reinterpret_cast(llvmBinary.data()), - reinterpret_cast(llvmBinary.data() - + llvmBinary.length()))) { - llvm::SMDiagnostic diags; -#if defined(LEGACY_COMPLIB) - return ParseAssemblyString(llvmBinary.c_str(), llvmbinary_, diags, Context()); -#else - llvmbinary_ = llvm::parseAssemblyString(llvmBinary.c_str(), diags, Context()).release(); - return llvmbinary_; -#endif - } -#if defined(LEGACY_COMPLIB) - // Use getMemBuffer() ? - if (llvm::MemoryBuffer *Buffer = - llvm::MemoryBuffer::getMemBufferCopy( - llvm::StringRef(llvmBinary), "input.bc")) { - std::string ErrorMessage; - llvm::Module* M = - llvm::ParseBitcodeFile(Buffer, Context(), &ErrorMessage); - delete Buffer; - return M; - } -#else - if (std::unique_ptr Buffer = - llvm::MemoryBuffer::getMemBufferCopy( - llvm::StringRef(llvmBinary), "input.bc")) { - auto ModuleOrErr = llvm::parseBitcodeFile(Buffer->getMemBufferRef(), Context()); - if( !ModuleOrErr.getError() ) return ModuleOrErr.get().release(); - } -#endif - return NULL; -} diff --git a/rocclr/compiler/lib/backends/common/compiler_stage.hpp b/rocclr/compiler/lib/backends/common/compiler_stage.hpp deleted file mode 100644 index 019342ddcc..0000000000 --- a/rocclr/compiler/lib/backends/common/compiler_stage.hpp +++ /dev/null @@ -1,122 +0,0 @@ -// -// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _BE_COMPILER_STAGE_HPP_ -#define _BE_COMPILER_STAGE_HPP_ - -#if defined DEBUG -#undef DEBUG -#endif - -#include "llvm/AMDLLVMContextHook.h" -#if defined(LEGACY_COMPLIB) -#include "llvm/PassManager.h" -#else -#include "llvm/IR/LegacyPassManager.h" -#endif -#include "llvm/Pass.h" -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/SourceMgr.h" -#include "llvm/Bitcode/ReaderWriter.h" - -#include "aclTypes.h" -#include "utils/options.hpp" - -#include -#include - -namespace llvm -{ - class LLVMContext; - class Module; -} - -namespace amdcl -{ - /*! \addtogroup CompilerLibrary - * - * \copydoc amdcl::CompilerStage - * - * @{ - */ - class CompilerStage { - private: - CompilerStage(); // DO NOT IMPLEMENT. - CompilerStage(CompilerStage&); // DO NOT IMPLEMENT. - public: - CompilerStage(aclCompiler* cl, aclBinary* elf, aclLogFunction callback); - - virtual ~CompilerStage(); - - /*! Returns the Compiler */ - aclCompiler* CL() const { return cl_; } - - /*! Returns the elf binary */ - aclBinary* Elf() const { return elf_; } - - /*! Returns the callback */ - aclLogFunction Callback() const { return callback_; } - - /*! Returns the options */ - amd::option::Options* Options() const { - assert(opts_ && "Options should not be null"); - return opts_; - } - - - /*! Returns the source file */ - std::string& Source() { return source_; } - - /*! Returns the build log */ - std::string& BuildLog() { return log_; } - - protected: - aclCompiler *cl_; - aclBinary *elf_; - void *binary_; - amd::option::Options* opts_; - std::string source_; - std::string log_; - aclLogFunction callback_; - }; // class CompilerStage - - class LLVMCompilerStage : public CompilerStage { - public: - LLVMCompilerStage(aclCompiler *cl, aclBinary *elf, - aclLogFunction callback); - virtual ~LLVMCompilerStage(); - void setContext(aclContext *ctx); - - /*! Returns the local context */ - llvm::LLVMContext& Context() { return (*context_); } - - /*! Loads bitcode in either text or binary format and return - * and LLVM module. */ - virtual llvm::Module* loadBitcode(std::string& llvmBinary); - - void setGPU(bool isForGPU) { hookup_.amdoptions.IsGPU = isForGPU; } - void setWholeProgram(bool Val) { hookup_.amdoptions.WholeProgram = Val; } - void setNoSignedZeros(bool Val) { hookup_.amdoptions.NoSignedZeros = Val; } - void setFastRelaxedMath(bool Val) { hookup_.amdoptions.FastRelaxedMath = Val; } - void setOptSimplifyLibCall(bool Val) { hookup_.amdoptions.OptSimplifyLibCall = Val; } - void setUnsafeMathOpt(bool Val) { hookup_.amdoptions.UnsafeMathOpt = Val; } - void setFiniteMathOnly(bool Val) { hookup_.amdoptions.FiniteMathOnly = Val; } - void setIsPreLinkOpt(bool Val) { hookup_.amdoptions.IsPreLinkOpt = Val; } - void setFP32RoundDivideSqrt(bool Val) { hookup_.amdoptions.FP32RoundDivideSqrt = Val; } - void setUseNative(const char * Val) { if(Val) hookup_.amdoptions.OptUseNative = Val; } - void setDenormsAreZero(bool Val) { hookup_.amdoptions.DenormsAreZero = Val; } - void setUniformWorkGroupSize(bool Val) { hookup_.amdoptions.UniformWorkGroupSize = Val; } - void setHaveFastFMA32(bool Val) { hookup_.amdoptions.HaveFastFMA32 = Val; } - void setISAVersion(int Val) { hookup_.amdoptions.ISAVersion = Val; } - - /*! Returns the llvm binary */ - llvm::Module* LLVMBinary() const { return llvmbinary_; } - aclModule* Module() const { return reinterpret_cast(llvmbinary_);} - protected: - llvm::Module *llvmbinary_; - llvm::LLVMContext *context_; - llvm::AMDLLVMContextHook hookup_; - }; // class CompilerStage - /*@}*/ -} -#endif // _BE_COMPILER_STAGE_HPP_ diff --git a/rocclr/compiler/lib/backends/common/frontend.cpp b/rocclr/compiler/lib/backends/common/frontend.cpp deleted file mode 100644 index 3a21f1bd72..0000000000 --- a/rocclr/compiler/lib/backends/common/frontend.cpp +++ /dev/null @@ -1,251 +0,0 @@ -// -// Copyright (c) 2011 Advanced Micro Devices, Inc. All rights reserved. -// -#include "top.hpp" -#include "frontend.hpp" -#include "bif/bifbase.hpp" -#include "utils/target_mappings.h" -#include "utils/options.hpp" -#include "os/os.hpp" -#include "llvm/ADT/StringRef.h" -#include -#include -#include -#include -#include - -bool Is64bitMachine() {return sizeof(void*) == 8;} - -void -amdcl::OCLFrontend::appendCLVersionFlag(std::stringstream &ss, - const amd::option::Options *opts) -{ - llvm::StringRef clStd(opts->oVariables->CLStd); - - if (clStd == "CL1.0") { - ss << "--opencl=1.0 "; - } else if (clStd == "CL1.1") { - ss << "--opencl=1.1 "; - } else if (clStd == "CL1.2") { - ss << "--opencl=1.2 "; - } else { - if (clStd != "CL2.0") { - appendLogToCL(CL(), "Warning: invalid value for -cl-std, defaulting to CL1.2"); - ss << "--opencl=1.2 "; - return; - } - - ss << "--opencl=2.0 "; - } -} - -/// -/// @brief Function that converts elf + src combo into the correct -/// sequence of commands to call the CLC frontend. -/// -/// FIXME: This needs to be modified so writing to a file is -/// not necessary! -std::string -amdcl::OCLFrontend::getFrontendCommand(aclBinary *elf, - const std::string &src, - std::string &logFile, - std::string &clFile, - bool preprocessOnly) -{ - std::stringstream systemPath; - std::fstream f; - amd::option::Options* Opts = (amd::option::Options*)elf->options; - - f.open(clFile.c_str(), (std::fstream::out | std::fstream::binary)); - f.write(src.data(), src.length()); - f.close(); - - bool enableSpir = false; -#ifdef DEBUG - enableSpir = getenv("AMD_OCL_ENABLE_SPIR"); -#endif - - if (enableSpir) - systemPath << "clc --spir --emit=spirbc "; - else - systemPath << "clc --emit=llvmbc "; - - appendCLVersionFlag(systemPath, Opts); - - if (enableSpir) - systemPath << "--amd-options-begin " << Opts->origOptionStr << " --amd-options-end "; - - if (checkFlag(aclutGetCaps(elf), capImageSupport)) { - systemPath << "-D__IMAGE_SUPPORT__=1 "; - } - - if (checkFlag(aclutGetCaps(elf), capFMA)) { - systemPath << "-DFP_FAST_FMAF=1 "; - systemPath << "-DFP_FAST_FMA=1 "; - } - - // F_IMAGES - if (Options()->oVariables->ImageSupport) { - systemPath << "-D__IMAGE_SUPPORT__=1 "; - } - - if (Options()->oVariables->FastFMA) { - systemPath << "-DFP_FAST_FMA=1 "; - } - - if (Options()->oVariables->FastFMAF) { - systemPath << "-DFP_FAST_FMAF=1 "; - } - - systemPath << "-D__AMD__=1 "; - uint32_t chipName = elf->target.chip_id; - assert(chipName < familySet[elf->target.arch_id].children_size && "Cannot index past end of array!"); - switch(elf->target.arch_id) { - default: - assert(!"Unknown target device ID!"); - case aclX64: - systemPath << "--march=x86-64 -D__X86_64__=1 -D__" << X64TargetMapping[chipName].chip_name << "__=1 "; - break; - case aclX86: - systemPath << "--march=x86 -D__X86__=1 -D__" << X86TargetMapping[chipName].chip_name << "__=1 "; - break; - case aclAMDIL: - systemPath << "-D__AMDIL__ -D__" << AMDILTargetMapping[chipName].chip_name << "__=1 "; - break; - case aclAMDIL64: - systemPath << "--march=gpu-64 -D__AMDIL_64__ -D__" << AMDIL64TargetMapping[chipName].chip_name << "__=1 "; - break; - case aclHSAIL: - systemPath << "--march=hsail -D__HSAIL__ -D__" << HSAILTargetMapping[chipName].chip_name << "__=1 "; - break; - case aclHSAIL64: - systemPath << "--march=hsail64 -D__HSAIL__ -D__" << HSAIL64TargetMapping[chipName].chip_name << "__=1 "; - break; - }; - // AMDIL and non CPU HSAIL targets get the GPU define, everything - // else gets CPU define. - if (!isCpuTarget(elf->target)) { - systemPath << "-D__GPU__=1 "; - } else { - systemPath << "-D__CPU__=1 "; - } - - if (elf->target.arch_id == aclAMDIL - && AMDILTargetMapping[chipName].family_enum == FAMILY_RV7XX) { - systemPath << "-Dcl_amd_vec3=1 -Dcl_amd_printf=1 --opencl=1.0"; - } - - if (Opts) { - systemPath << Opts->clcOptions; - } - -#ifdef WITH_TARGET_HSAIL - if ((Is64bitMachine() && isHSAILTarget(elf->target)) || - (Opts->oVariables->GPU64BitIsa && (elf->target.arch_id == aclHSAIL))) - systemPath << " --march=hsail64 "; -#endif - -#ifdef DEBUG - const char* env = getenv("AMD_EDG_OPTIONS"); - if (env) - systemPath << env << " "; -#endif - -#ifdef DEBUG - if (!getenv("AMD_OCL_SHOW_COMPILER_OUTPUT")) -#endif - systemPath << " --error_output \"" << logFile << "\" "; - if(preprocessOnly) { - std::string clppFileName = Opts->getDumpFileName(".i"); - systemPath << " -E -o \"" << clppFileName << "\""; - } - systemPath << " \"" << clFile << "\" "; - - LogPrintfDebug("Invoking CL to LLVM binary compilation:\n %s", - systemPath.str().c_str()); - -#ifdef DEBUG - if(getenv("AMD_OCL_SHOW_CMD_LINE")) - std::cout << "command line: " << systemPath.str() << std::endl; -#endif - - if (Opts && Opts->isDumpFlagSet(amd::option::DUMP_CL) && !preprocessOnly) { - dumpSource(src, Opts); - } - std::string clcCmd = systemPath.str(); - return clcCmd; -} -// CLC_IN_PROCESS_CHANGE -extern int openclFrontEnd(const char* cmdline, std::string*, std::string* typeInfo = NULL); - -static std::string -loadFileToStr(std::string file) -{ - std::string str = ""; - std::ifstream log(file.c_str(), std::ios::in|std::ios::ate); - if (log.is_open()) { - size_t size = (size_t)log.tellg(); - log.seekg(0, std::ios::beg); - std::vector buffer(size+1); - log.read(&buffer[0],size); - log.close(); - //for safety - buffer[size] = '\0'; - str += &buffer[0]; - } - return str; -} - -int -amdcl::OCLFrontend::compileCommand(const std::string& singleSrc) -{ - std::string tempFileName = amd::Os::getTempFileName(); - std::string logFile = tempFileName + ".log"; - std::string clFile = tempFileName + ".cl"; - std::string frontendCmd = getFrontendCommand(Elf(), singleSrc, logFile, - clFile, false); - std::string logStr; - uint64_t start_time = 0, stop_time = 0; - amd::option::Options* Opts = (amd::option::Options*)Elf()->options; - - if (Options()->oVariables->EnableBuildTiming) { - start_time = amd::Os::timeNanos(); - } - if (!checkFlag(aclutGetCaps(Elf()), capSaveSOURCE)) { - CL()->clAPI.remSec(CL(), Elf(), aclSOURCE); - } - int ret = openclFrontEnd(frontendCmd.c_str(), &Source(), NULL); - - // We dump the preprocessed code by invoking clc a second time after the - // original call, just in case somthing really bad happens in the original - // call. - if (Opts && Opts->isDumpFlagSet(amd::option::DUMP_I)) { - std::string pplogFile = tempFileName + "preprocess.log"; - std::string ppFrontendCmd = - getFrontendCommand(Elf(), singleSrc, pplogFile, clFile, true); - (void) openclFrontEnd(ppFrontendCmd.c_str(), &Source(), NULL); - amd::Os::unlink(pplogFile.c_str()); - } - if (Options()->oVariables->EnableBuildTiming) { - stop_time = amd::Os::timeNanos(); - std::stringstream tmp_ss; - tmp_ss << " OpenCL FE time: " << (stop_time - start_time)/1000ULL - << "us\n"; - appendLogToCL(CL(), tmp_ss.str()); - } - llvmbinary_ = loadBitcode(Source()); - if (!llvmbinary_) { - ret |= 1; - } - if (!ret) { - CL()->clAPI.insSec(CL(), Elf(), Source().data(), Source().size(), aclLLVMIR); - } - log_ += loadFileToStr(logFile); - amd::Os::unlink(logFile.c_str()); - if (isCpuTarget(Elf()->target) && Options()->oVariables->EnableDebug) { - Options()->sourceFileName_.assign(clFile); - } else { - amd::Os::unlink(clFile.c_str()); - } - return ret; -} diff --git a/rocclr/compiler/lib/backends/common/frontend.hpp b/rocclr/compiler/lib/backends/common/frontend.hpp deleted file mode 100644 index f9755e6175..0000000000 --- a/rocclr/compiler/lib/backends/common/frontend.hpp +++ /dev/null @@ -1,114 +0,0 @@ -// -// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _BE_FRONTEND_HPP_ -#define _BE_FRONTEND_HPP_ -#include -#include -#include "aclTypes.h" -#include "compiler_stage.hpp" -#include "utils/libUtils.h" - -namespace amdcl -{ - /*! \addtogroup CompilerLibrary - * - * \copydoc amdcl::Frontend - * - * @{ - * \brief Interface parent class for the frontend child classes. - * This class should never be instantiated directly. - */ - class Frontend : public LLVMCompilerStage { - Frontend(Frontend&); // DO NOT IMPLEMENT. - Frontend(); // DO NOT IMPLEMENT. - public: - Frontend(aclCompiler* cl, aclBinary* elf, aclLogFunction log) - : LLVMCompilerStage(cl, elf, log) {} - //! Virtual destructer that makes sure everything is cleaned up. - virtual ~Frontend() {} - - //! Function that converts from OpenCL singleSrc into - // OpenCL formatted LLVM-IR stored as a std::string. - // This function generates a command string for clc to execute. - virtual int compileCommand(const std::string& singleSrc) = 0; - - virtual std::string getClassName() = 0; - - //! Dumps source CL text with compiler options in a file. - void dumpSource(const std::string& src, amd::option::Options* opts) { - std::ofstream f(opts->getDumpFileName(".cl").c_str(), std::ios::trunc); - if(f.is_open()) { - f << "/* Compiler options:\n" << opts->origOptionStr << "\n*/\n\n" << src; - } else { - appendLogToCL(CL(), "File for dumping source cl isn't opened"); - } - } - }; // class Frontend - /*@}*/ - - /*! \addtogroup CompilerLibrary - * - * \copydoc amdcl::OCLFrontend - * - * @{ - * \brief Implementation of the Frontend interface to compile - * from OpenCL C to LLVM-IR. - */ - class OCLFrontend : public Frontend { - OCLFrontend(OCLFrontend&); // DO NOT IMPLEMENT. - OCLFrontend(); // DO NOT IMPLEMENT. - - void appendCLVersionFlag( - std::stringstream &ss, - const amd::option::Options *opts); - - std::string getFrontendCommand( - aclBinary *elf, - const std::string &src, - std::string &logFile, - std::string &clFile, - bool preprocessOnly); - - public: - OCLFrontend(aclCompiler* cl, aclBinary* elf, aclLogFunction log) - : Frontend(cl, elf, log) {} - - virtual ~OCLFrontend() {} - - //! Function that converts from OpenCL singleSrc into - // OpenCL formatted LLVM-IR stored as a std::string. - // This function generates a command string for clc to execute. - virtual int compileCommand(const std::string& singleSrc); - - virtual std::string getClassName() {return "OCLFrontend";} - }; // class OCLFrontend - /*@}*/ - - - /*! \addtogroup CompilerLibrary - * - * \copydoc amdcl::Frontend - * - * @{ - * \brief This is the class which calls the clang front-end. - * This class will be used if user asks for it (By default EDG will be - * called). - */ - class ClangOCLFrontend : public Frontend { - //! Options to be passed to the ClangOCLFE library. - - public: - ClangOCLFrontend(aclCompiler* cl, aclBinary* elf, aclLogFunction log); - - //! Virtual destructer that makes sure everything is cleaned up. - virtual ~ClangOCLFrontend() {} - - //! This function generates a command string for ClangOCLFE to execute. - virtual int compileCommand(const std::string& singleSrc); - - virtual std::string getClassName() {return "ClangOCLFrontend";} - }; // class Frontend - /*@}*/ -} // namespac amdcl -#endif // _BE_FRONTEND_HPP_ diff --git a/rocclr/compiler/lib/backends/common/frontend_clang.cpp b/rocclr/compiler/lib/backends/common/frontend_clang.cpp deleted file mode 100644 index 933e540ad4..0000000000 --- a/rocclr/compiler/lib/backends/common/frontend_clang.cpp +++ /dev/null @@ -1,232 +0,0 @@ -// -// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved. -// - -#include "OpenCLFE.h" - -#include "bif/bifbase.hpp" -#include "frontend.hpp" -#include "os/os.hpp" -#include "top.hpp" -#include "utils/options.hpp" -#include "utils/target_mappings.h" - -#include "llvm/IR/LLVMContext.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/SPIRV.h" -#include "llvm/Support/raw_ostream.h" -#include "llvm/ADT/StringRef.h" - -#include -#include - -amdcl::ClangOCLFrontend::ClangOCLFrontend(aclCompiler* cl, aclBinary* elf, - aclLogFunction log) - : Frontend(cl, elf, log){} - -/// @brief This function generates the required command-line options to -/// call the ClangOCLFE library. -int amdcl::ClangOCLFrontend::compileCommand(const std::string& src) { - - std::vector argsToClang; - std::string tempFileName = amd::Os::getTempFileName(); - std::string logFileName = tempFileName + ".log"; - std::string inpCLFileName = tempFileName + ".cl"; - std::string logFromClang; - int ret = 0; - - aclBinary *elf = Elf(); - amd::option::Options* amdOpts = (amd::option::Options*)elf->options; - - // Following are the options passed to the ClangOCLFE library - // and then to Clang itself. - - // handle -O0 - if (amdOpts && amdOpts->origOptionStr.find("-O0") != std::string::npos) { - amdOpts->clangOptions.push_back("-O0"); - } - - // Passing the compiler FE options to clang. - if (amdOpts) { - for (std::vector::const_iterator it = amdOpts->clangOptions.begin(); - it != amdOpts->clangOptions.end(); ++it) { - if ("-g" == *it) { - argsToClang.push_back("-dwarf-version=2"); - argsToClang.push_back("-debug-info-kind=standalone"); - } else { - argsToClang.push_back((*it).c_str()); - } - } - } - - if (Options()->oVariables->ImageSupport) { - argsToClang.push_back ("-D__IMAGE_SUPPORT__=1 "); - } - - if (Options()->oVariables->FastFMA) { - argsToClang.push_back ("-DFP_FAST_FMA=1 "); - } - - if (Options()->oVariables->FastFMAF) { - argsToClang.push_back ("-DFP_FAST_FMAF=1 "); - } - - argsToClang.push_back ("-D__AMD__=1 "); - - if (Options()->oVariables->FEGenSPIRV) { - argsToClang.push_back("-D__AMD_SPIRV__ "); - } - - // Other options are passed using OptionsInfo structure. - clc2::OptionsInfo ClangOptions; - - ClangOptions.InFilename = inpCLFileName; - - // Generate target triple. - // TODO: Refine the triple as necessary. - uint32_t chipName = elf->target.chip_id; - assert(chipName < familySet[elf->target.arch_id].children_size && - "Cannot index past end of array!"); - switch (elf->target.arch_id) { - default: - log_ += "\nerror: Unknown target device ID!\n"; - ret |= 1; - return ret; - break; - case aclX86: - case aclAMDIL: - case aclHSAIL: - // See bug: http://ocltc.amd.com/bugs/show_bug.cgi?id=9631 - if (sizeof(void*) != 4) { - log_ += "\nerror: 32-bit kernels not supported on a 64-bit executable\n"; - ret |= 1; - return ret; - } - ClangOptions.TargetArch = llvm::Triple::spir; - break; - case aclX64: - case aclAMDIL64: - case aclHSAIL64: - // See bug: http://ocltc.amd.com/bugs/show_bug.cgi?id=9631 - if (sizeof(void*) != 8) { - log_ += "\nerror: 64-bit kernels not supported on a 32-bit executable\n"; - ret |= 1; - return ret; - } - ClangOptions.TargetArch = llvm::Triple::spir64; - break; - }; - - // Copy the source to a buffer. Note that the input - // file itself is not passed to the ClangOCLFE library. It is a passed - // as a string for compilation. - - std::unique_ptr srcBufferPtr = - llvm::MemoryBuffer::getMemBuffer(src, inpCLFileName.c_str(), - true); - ClangOptions.Src.swap(srcBufferPtr); - assert(ClangOptions.Src.get() && "ClangOCLFE: Memory Buffer" - " initialization error\n"); - - // Set Pre-processor output if user asks for it. - if (amdOpts && amdOpts->isDumpFlagSet(amd::option::DUMP_I)) { - ClangOptions.PreProcOut = amdOpts->getDumpFileName(".i"); - } - - // Set the LLVMContext for the front-end compilation. - // Clang needs to use a separate LLVMContext since the generated bitcode - // needs to be loaded again. Using the same LLVMContext causes name collision - // for named struct types in bitcode loader. - llvm::LLVMContext ClangCtx; - ClangOptions.CompilerContext = &ClangCtx; - - if (amdOpts && amdOpts->isDumpFlagSet(amd::option::DUMP_CL)) { - dumpSource(src, amdOpts); - } - - //Start the compilation - uint64_t start_time = 0, stop_time = 0; - - if (Options()->oVariables->EnableBuildTiming) { - start_time = amd::Os::timeNanos(); - } - - if (!checkFlag(aclutGetCaps(Elf()), capSaveSOURCE)) { - CL()->clAPI.remSec(CL(), Elf(), aclSOURCE); - } - - // Pass OpenCL version option to Clang - llvm::StringRef OCLVer(amdOpts->oVariables->CLStd); - if (OCLVer.equals("CL1.2")) { - ClangOptions.OCLVer = clc2::OCL_12; - } else if (OCLVer.equals("CL2.0")) { - ClangOptions.OCLVer = clc2::OCL_20; - } else { - llvm_unreachable("Unknown OpenCL version"); - } - - // Call the Clang Front-end to generate serialized llvm::Module - // from the OpenCL source. -#ifdef ANDROID - // We will not exercise Clang for RenderScript. - log_ += "\nerror: Clang front-end compilation unsupported on Android!\n"; - ret |= 1; - return ret; -#else - if (!parseOCLSource(ClangOptions, argsToClang, &Source(), &logFromClang)) { - log_ += logFromClang; - log_ += "\nerror: Clang front-end compilation failed!\n"; - ret |= 1; - return ret; - } -#endif - - if (Options()->oVariables->EnableBuildTiming) { - stop_time = amd::Os::timeNanos(); - std::stringstream tmp_ss; - tmp_ss << " OpenCL FE time: " - << (stop_time - start_time)/1000ULL - << "us\n"; - appendLogToCL(CL(), tmp_ss.str()); - } - - llvmbinary_ = loadBitcode(Source()); - - if (!llvmbinary_) { - ret |= 1; - } - - if (!ret) { - CL()->clAPI.insSec(CL(), Elf(), Source().data(), Source().size(), aclLLVMIR); - } - - if (Options()->oVariables->FEGenSPIRV) { - std::string s; - llvm::raw_string_ostream ss(s); - std::string err; - - if (Options()->getLLVMArgc()) { - llvm::cl::ParseCommandLineOptions(Options()->getLLVMArgc(), - Options()->getLLVMArgv(), "LLVM/SPIRV converter"); - } - if (WriteSPIRV(llvmbinary_, ss, err)) { - std::string img = ss.str(); - CL()->clAPI.insSec(CL(), Elf(), img.data(), img.size(), aclSPIRV); - } - - if (!log_.empty()) - log_ += std::string(" "); - log_ += err; - } - - log_ += logFromClang; - if (isCpuTarget(Elf()->target) - && Options()->oVariables->EnableDebug) { - Options()->sourceFileName_ = inpCLFileName; - } else { - amd::Os::unlink(inpCLFileName.c_str()); - } - return ret; -} diff --git a/rocclr/compiler/lib/backends/common/if_acl.h b/rocclr/compiler/lib/backends/common/if_acl.h deleted file mode 100644 index 5850e0bb9e..0000000000 --- a/rocclr/compiler/lib/backends/common/if_acl.h +++ /dev/null @@ -1,8 +0,0 @@ -// -// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _IF_ACL_H_ -#define _IF_ACL_H_ -#include "aclTypes.h" -#include "v0_8/if_acl.h" -#endif // _IF_ACL_H_ diff --git a/rocclr/compiler/lib/backends/common/library.cpp b/rocclr/compiler/lib/backends/common/library.cpp deleted file mode 100644 index 35aeb62725..0000000000 --- a/rocclr/compiler/lib/backends/common/library.cpp +++ /dev/null @@ -1,293 +0,0 @@ - -// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved. -// - -#include -#include - -#include "top.hpp" -#include "aclTypes.h" -#include "library.hpp" -#include "utils/options.hpp" - -namespace amd { - -/* - Integrated bitcode libraries - */ - -// GPU libraries -#if defined(WITH_TARGET_AMDIL) -#include "builtins-gpugen-comm.inc" -#include "builtins-gpugen-diff.gpu.inc" -#include "builtins-gpugen-diff.gpu-64.inc" -#include "builtins-gpucommon-comm.inc" -#include "builtins-gpucommon-diff.gpu.inc" -#include "builtins-gpucommon-diff.gpu-64.inc" -#include "builtins-SI-comm.inc" -#include "builtins-SI-diff.gpu.inc" -#include "builtins-SI-diff.gpu-64.inc" -#include "builtins-CI-comm.inc" -#include "builtins-CI-diff.gpu.inc" -#include "builtins-CI-diff.gpu-64.inc" -#endif // WITH_TARGET_AMDIL - -// CPU libraries -#if defined(WITH_TARGET_X86) -#include "builtins-cpugen.x86.inc" -#include "builtins-cpucommon.x86.inc" -#include "builtins-avx.x86.inc" -#include "builtins-fma4.x86.inc" -#include "builtins-cpugen.x86-64.inc" -#include "builtins-cpucommon.x86-64.inc" -#include "builtins-avx.x86-64.inc" -#include "builtins-fma4.x86-64.inc" -#endif // WITH_TARGET_X86 - -#if defined(WITH_TARGET_ARM) -#include "builtins-cpugen.arm.inc" -#include "builtins-cpucommon.arm.inc" -#endif // WITH_TARGET_ARM - -#ifdef WITH_TARGET_HSAIL -// HSAIL libraries -#include "builtins-hsail.inc" -#include "builtins-gcn.inc" -#include "builtins-ocml.inc" -#include "builtins-spirv.inc" -#endif - -#include -// getLibsDesc() : returns a list of libraries that need to be linked with the -// application. The max number of libraries is defined by -// enum MAX_NUM_LIBRARY_DESCS in class LibraryDescriptor. -// -// Return 0: successful -// : error happened -int -getLibDescs ( - LibrarySelector LibType, // input - LibraryDescriptor* LibDesc, // output - int& LibDescSize // output -- LibDesc[0:LibDescSize-1] -) -{ - switch (LibType) { -#if defined(WITH_TARGET_AMDIL) - case GPU_Library_Evergreen: - // Library order is important! - LibDesc[0].start = reinterpret_cast - (builtins_gpucommon_comm); - LibDesc[0].size = builtins_gpucommon_comm_size; - LibDesc[1].start = reinterpret_cast - (builtins_gpucommon_diff_gpu); - LibDesc[1].size = builtins_gpucommon_diff_gpu_size; - LibDesc[2].start = reinterpret_cast - (builtins_gpugen_comm); - LibDesc[2].size = builtins_gpugen_comm_size; - LibDesc[3].start = reinterpret_cast - (builtins_gpugen_diff_gpu); - LibDesc[3].size = builtins_gpugen_diff_gpu_size; - LibDescSize = 4; - break; - - case GPU_Library_SI: - // Library order is important! - LibDesc[0].start = reinterpret_cast - (builtins_SI_comm); - LibDesc[0].size = builtins_SI_comm_size; - LibDesc[1].start = reinterpret_cast - (builtins_SI_diff_gpu); - LibDesc[1].size = builtins_SI_diff_gpu_size; - LibDesc[2].start = reinterpret_cast - (builtins_gpucommon_comm); - LibDesc[2].size = builtins_gpucommon_comm_size; - LibDesc[3].start = reinterpret_cast - (builtins_gpucommon_diff_gpu); - LibDesc[3].size = builtins_gpucommon_diff_gpu_size; - LibDesc[4].start = reinterpret_cast - (builtins_gpugen_comm); - LibDesc[4].size = builtins_gpugen_comm_size; - LibDesc[5].start = reinterpret_cast - (builtins_gpugen_diff_gpu); - LibDesc[5].size = builtins_gpugen_diff_gpu_size; - LibDescSize = 6; - break; - - case GPU64_Library_SI: - // Library order is important! - LibDesc[0].start = reinterpret_cast - (builtins_SI_comm); - LibDesc[0].size = builtins_SI_comm_size; - LibDesc[1].start = reinterpret_cast - (builtins_SI_diff_gpu_64); - LibDesc[1].size = builtins_SI_diff_gpu_64_size; - LibDesc[2].start = reinterpret_cast - (builtins_gpucommon_comm); - LibDesc[2].size = builtins_gpucommon_comm_size; - LibDesc[3].start = reinterpret_cast - (builtins_gpucommon_diff_gpu_64); - LibDesc[3].size = builtins_gpucommon_diff_gpu_64_size; - LibDesc[4].start = reinterpret_cast - (builtins_gpugen_comm); - LibDesc[4].size = builtins_gpugen_comm_size; - LibDesc[5].start = reinterpret_cast - (builtins_gpugen_diff_gpu_64); - LibDesc[5].size = builtins_gpugen_diff_gpu_64_size; - LibDescSize = 6; - break; - - case GPU_Library_CI: - // Library order is important! - LibDesc[0].start = reinterpret_cast - (builtins_CI_comm); - LibDesc[0].size = builtins_CI_comm_size; - LibDesc[1].start = reinterpret_cast - (builtins_CI_diff_gpu); - LibDesc[1].size = builtins_CI_diff_gpu_size; - LibDesc[2].start = reinterpret_cast - (builtins_SI_comm); - LibDesc[2].size = builtins_SI_comm_size; - LibDesc[3].start = reinterpret_cast - (builtins_SI_diff_gpu); - LibDesc[3].size = builtins_SI_diff_gpu_size; - LibDesc[4].start = reinterpret_cast - (builtins_gpucommon_comm); - LibDesc[4].size = builtins_gpucommon_comm_size; - LibDesc[5].start = reinterpret_cast - (builtins_gpucommon_diff_gpu); - LibDesc[5].size = builtins_gpucommon_diff_gpu_size; - LibDesc[6].start = reinterpret_cast - (builtins_gpugen_comm); - LibDesc[6].size = builtins_gpugen_comm_size; - LibDesc[7].start = reinterpret_cast - (builtins_gpugen_diff_gpu); - LibDesc[7].size = builtins_gpugen_diff_gpu_size; - LibDescSize = 8; - break; - - case GPU64_Library_CI: - // Library order is important! - LibDesc[0].start = reinterpret_cast - (builtins_CI_comm); - LibDesc[0].size = builtins_CI_comm_size; - LibDesc[1].start = reinterpret_cast - (builtins_CI_diff_gpu_64); - LibDesc[1].size = builtins_CI_diff_gpu_64_size; - LibDesc[2].start = reinterpret_cast - (builtins_SI_comm); - LibDesc[2].size = builtins_SI_comm_size; - LibDesc[3].start = reinterpret_cast - (builtins_SI_diff_gpu_64); - LibDesc[3].size = builtins_SI_diff_gpu_64_size; - LibDesc[4].start = reinterpret_cast - (builtins_gpucommon_comm); - LibDesc[4].size = builtins_gpucommon_comm_size; - LibDesc[5].start = reinterpret_cast - (builtins_gpucommon_diff_gpu_64); - LibDesc[5].size = builtins_gpucommon_diff_gpu_64_size; - LibDesc[6].start = reinterpret_cast - (builtins_gpugen_comm); - LibDesc[6].size = builtins_gpugen_comm_size; - LibDesc[7].start = reinterpret_cast - (builtins_gpugen_diff_gpu_64); - LibDesc[7].size = builtins_gpugen_diff_gpu_64_size; - LibDescSize = 8; - break; - -#endif // WITH_TARGET_AMDIL - -#if defined(WITH_TARGET_X86) - case CPU64_Library_Generic: - LibDesc[0].start = reinterpret_cast(builtins_cpucommon_x86_64); - LibDesc[0].size = builtins_cpucommon_x86_64_size; - LibDesc[1].start = reinterpret_cast(builtins_cpugen_x86_64); - LibDesc[1].size = builtins_cpugen_x86_64_size; - LibDescSize = 2; - break; - - case CPU64_Library_AVX: - LibDesc[0].start = reinterpret_cast(builtins_avx_x86_64); - LibDesc[0].size = builtins_avx_x86_64_size; - LibDesc[1].start = reinterpret_cast(builtins_cpucommon_x86_64); - LibDesc[1].size = builtins_cpucommon_x86_64_size; - LibDesc[2].start = reinterpret_cast(builtins_cpugen_x86_64); - LibDesc[2].size = builtins_cpugen_x86_64_size; - LibDescSize = 3; - break; - - case CPU64_Library_FMA4: - LibDesc[0].start = reinterpret_cast(builtins_fma4_x86_64); - LibDesc[0].size = builtins_fma4_x86_64_size; - LibDesc[1].start = reinterpret_cast(builtins_avx_x86_64); - LibDesc[1].size = builtins_avx_x86_64_size; - LibDesc[2].start = reinterpret_cast(builtins_cpucommon_x86_64); - LibDesc[2].size = builtins_cpucommon_x86_64_size; - LibDesc[3].start = reinterpret_cast(builtins_cpugen_x86_64); - LibDesc[3].size = builtins_cpugen_x86_64_size; - LibDescSize = 4; - break; - - case CPU_Library_Generic: - LibDesc[0].start = reinterpret_cast(builtins_cpucommon_x86); - LibDesc[0].size = builtins_cpucommon_x86_size; - LibDesc[1].start = reinterpret_cast(builtins_cpugen_x86); - LibDesc[1].size = builtins_cpugen_x86_size; - LibDescSize = 2; - break; - - case CPU_Library_AVX: - LibDesc[0].start = reinterpret_cast(builtins_avx_x86); - LibDesc[0].size = builtins_avx_x86_size; - LibDesc[1].start = reinterpret_cast(builtins_cpucommon_x86); - LibDesc[1].size = builtins_cpucommon_x86_size; - LibDesc[2].start = reinterpret_cast(builtins_cpugen_x86); - LibDesc[2].size = builtins_cpugen_x86_size; - LibDescSize = 3; - break; - - case CPU_Library_FMA4: - LibDesc[0].start = reinterpret_cast(builtins_fma4_x86); - LibDesc[0].size = builtins_fma4_x86_size; - LibDesc[1].start = reinterpret_cast(builtins_avx_x86); - LibDesc[1].size = builtins_avx_x86_size; - LibDesc[2].start = reinterpret_cast(builtins_cpucommon_x86); - LibDesc[2].size = builtins_cpucommon_x86_size; - LibDesc[3].start = reinterpret_cast(builtins_cpugen_x86); - LibDesc[3].size = builtins_cpugen_x86_size; - LibDescSize = 4; - break; -#endif // WITH_TARGET_X86 - -#if defined(WITH_TARGET_ARM) - case CPU_Library_Generic: - LibDesc[0].start = reinterpret_cast(builtins_cpucommon_arm); - LibDesc[0].size = builtins_cpucommon_arm_size; - LibDesc[1].start = reinterpret_cast(builtins_cpugen_arm); - LibDesc[1].size = builtins_cpugen_arm_size; - LibDescSize = 2; - break; -#endif // WITH_TARGET_ARM - -#if defined(WITH_TARGET_HSAIL) - case GPU_Library_HSAIL: - // Library order is important! - LibDesc[0].start = reinterpret_cast(builtins_gcn); - LibDesc[0].size = builtins_gcn_size; - LibDesc[1].start = reinterpret_cast(builtins_hsail); - LibDesc[1].size = builtins_hsail_size; - LibDesc[2].start = reinterpret_cast(builtins_ocml); - LibDesc[2].size = builtins_ocml_size; - LibDesc[3].start = reinterpret_cast(builtins_spirv); - LibDesc[3].size = builtins_spirv_size; - LibDescSize = 4; - break; -#endif // WITH_TARGET_HSAIL - - default: - // Failed - return 1; // - } - return 0; -} - -} // namespace amd diff --git a/rocclr/compiler/lib/backends/common/linker.cpp b/rocclr/compiler/lib/backends/common/linker.cpp deleted file mode 100644 index bad7455318..0000000000 --- a/rocclr/compiler/lib/backends/common/linker.cpp +++ /dev/null @@ -1,753 +0,0 @@ -// -// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved. -// -// TODO: The entire linker implementation should be a pass in LLVM and -// the code in the compiler library should only call this pass. - -#include "top.hpp" -#include "library.hpp" -#include "linker.hpp" -#include "os/os.hpp" -#include "thread/monitor.hpp" -#include "utils/libUtils.h" -#include "utils/options.hpp" -#include "utils/target_mappings.h" - -#include "acl.h" -#if !defined(LEGACY_COMPLIB) -#define HAS_SPIRV -#endif - -#if defined(LEGACY_COMPLIB) -#include "llvm/Instructions.h" -#include "llvm/Linker.h" -#include "llvm/LLVMContext.h" -#include "llvm/GlobalValue.h" -#include "llvm/GlobalVariable.h" -#include "llvm/Analysis/Verifier.h" -#include "llvm/Support/CallSite.h" -#include "llvm/Support/system_error.h" -#include "llvm/DataLayout.h" -#include "llvm/ValueSymbolTable.h" -#ifdef _DEBUG -#include "llvm/Assembly/Writer.h" -#endif -#else -#include "llvm/Support/Debug.h" -#include "llvm/IR/DataLayout.h" -#include "llvm/IR/CallSite.h" -#include "llvm/IR/Instructions.h" -#include "llvm/IR/LLVMContext.h" -#include "llvm/IR/GlobalValue.h" -#include "llvm/IR/GlobalVariable.h" -#include "llvm/IR/ValueSymbolTable.h" -#include "llvm/IR/Verifier.h" -#include "llvm/Linker/Linker.h" -#endif - -#ifndef LEGACY_COMPLIB -#include "AMDFixupKernelModule.h" -#include "AMDResolveLinker.h" -#include "AMDPrelink.h" -#else -#include "llvm/AMDFixupKernelModule.h" -#include "llvm/AMDResolveLinker.h" -#include "llvm/AMDPrelink.h" -#endif - -#include "llvm/AMDUtils.h" -#include "llvm/ADT/Triple.h" -#include "llvm/ADT/StringMap.h" -#include "llvm/Analysis/AMDLocalArrayUsage.h" -#include "llvm/Analysis/LoopPass.h" -#include "llvm/Analysis/Passes.h" -#include "llvm/Bitcode/ReaderWriter.h" - -#include "llvm/CodeGen/LinkAllAsmWriterComponents.h" -#include "llvm/CodeGen/LinkAllCodegenComponents.h" -#include "llvm/Config/config.h" - -#include "llvm/MC/SubtargetFeature.h" - -#include "llvm/Support/FileSystem.h" -#include "llvm/Support/FileUtilities.h" -#include "llvm/Support/FormattedStream.h" -#include "llvm/Support/Host.h" -#include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/Path.h" -#include "llvm/Support/PluginLoader.h" -#include "llvm/Support/raw_ostream.h" -#include "llvm/Support/Signals.h" -#include "llvm/Support/TargetRegistry.h" -#include "llvm/Support/TargetSelect.h" -#include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetOptions.h" - -#include "llvm/Transforms/IPO.h" -#include "llvm/Transforms/Scalar.h" -#include "llvm/AMDLLVMContextHook.h" - -#if defined(LEGACY_COMPLIB) -#include "llvm/AMDILFuncSupport.h" -#endif - -#ifdef HAS_SPIRV -#include "llvm/Support/SPIRV.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _WIN32 -#include -#endif // _WIN32 - -#define DEBUG_TYPE "ocl_linker" - -namespace AMDSpir { - extern void replaceTrivialFunc(llvm::Module& M); -} -namespace amd { - -namespace { - -using namespace llvm; - -// LoadFile - Read the specified bitcode file in and return it. This routine -// searches the link path for the specified file to try to find it... -// -inline llvm::Module* - LoadFile(const std::string &Filename, LLVMContext& Context) - { - if (!sys::fs::exists(Filename)) { - // dbgs() << "Bitcode file: '" << Filename.c_str() << "' does not exist.\n"; - return 0; - } - -#if defined(LEGACY_COMPLIB) - llvm::Module* M; - std::string ErrorMessage; - OwningPtr Buffer; - if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, Buffer)) { - // Error - M = NULL; - } - else { - M = ParseBitcodeFile(Buffer.get(), Context, &ErrorMessage); - } - - return M; -#else - ErrorOr> FileOrErr = MemoryBuffer::getFileOrSTDIN(Filename); - if (!FileOrErr) { - auto ModuleOrErr = llvm::parseBitcodeFile(FileOrErr.get()->getMemBufferRef(), Context); - if (!ModuleOrErr.getError()) return ModuleOrErr.get().release(); - } - - return nullptr; -#endif - } - -#if defined(LEGACY_COMPLIB) -inline llvm::Module* - LoadLibrary(const std::string& libFile, LLVMContext& Context, MemoryBuffer** Buffer) { - if (!sys::fs::exists(libFile)) { - // dbgs() << "Bitcode file: '" << Filename.c_str() << "' does not exist.\n"; - return 0; - } - - llvm::Module* M = NULL; - std::string ErrorMessage; - - static Monitor mapLock; - static std::map FileMap; - MemoryBuffer* statBuffer; - { - ScopedLock sl(mapLock); - statBuffer = (MemoryBuffer*) FileMap[libFile]; - if (statBuffer == NULL) { - OwningPtr PtrBuffer; - if (error_code ec = MemoryBuffer::getFileOrSTDIN(libFile, PtrBuffer)) { - // Error - return NULL; - } - else - statBuffer = PtrBuffer.take(); - M = ParseBitcodeFile(statBuffer, Context, &ErrorMessage); - FileMap[libFile] = statBuffer; - } - } - *Buffer = MemoryBuffer::getMemBufferCopy(StringRef(statBuffer->getBufferStart(), statBuffer->getBufferSize()), ""); - if ( *Buffer ) { - M = getLazyBitcodeModule(*Buffer, Context, &ErrorMessage); - if (!M) { - delete *Buffer; - *Buffer = 0; - } - } - return M; - } -#endif - -// Load bitcode libary from an array of const char. This assumes that -// the array has a valid ending zero ! -#if defined(LEGACY_COMPLIB) -llvm::Module* - LoadLibrary(const char* libBC, size_t libBCSize, - LLVMContext& Context, MemoryBuffer** Buffer) - { - llvm::Module* M = 0; - std::string ErrorMessage; - - *Buffer = MemoryBuffer::getMemBuffer(StringRef(libBC, libBCSize), ""); - if ( *Buffer ) { - M = getLazyBitcodeModule(*Buffer, Context, &ErrorMessage); - if (!M) { - delete *Buffer; - *Buffer = 0; - } - } - return M; - } -#else -llvm::Module* - LoadLibrary(const char* libBC, size_t libBCSize, - LLVMContext& Context) - { - - auto Buffer = MemoryBuffer::getMemBuffer(StringRef(libBC, libBCSize), ""); - if ( Buffer ) { - auto ModuleOrErr = llvm::getLazyBitcodeModule(std::move(Buffer), Context); - if (!ModuleOrErr.getError()) return ModuleOrErr.get().release(); - } - return nullptr; - } -#endif - -static std::set *getAmdRtFunctions() -{ - std::set *result = new std::set(); - for (size_t i = 0; i < sizeof(amdRTFuns)/sizeof(amdRTFuns[0]); ++i) - result->insert(amdRTFuns[i]); - return result; -} - -} - - -} // namespace amd - - -bool -amdcl::OCLLinker::linkWithModule(llvm::Module* Dst, std::unique_ptr Src) -{ -#ifndef NDEBUG - if (Options()->oVariables->EnableDebugLinker) { - llvm::DebugFlag = true; - llvm::setCurrentDebugType(DEBUG_TYPE); - } -#endif - std::string ErrorMessage; - if (llvm::linkWithModule(Dst, std::move(Src), &ErrorMessage)) { - DEBUG(llvm::dbgs() << "Error: " << ErrorMessage << "\n"); - BuildLog() += "\nInternal Error: linking libraries failed!\n"; - LogError("linkWithModule(): linking bc libraries failed!"); - return true; - } - return false; -} - -bool -amdcl::OCLLinker::linkLLVMModules(std::vector> &libs) -{ - // Load input modules first - bool Failed = false; - for (size_t i = 0; i < libs.size(); ++i) { - std::string ErrorMsg; - if (!libs[i]) { - char ErrStr[128]; - sprintf(ErrStr, - "Error: cannot load input %d bc for linking: %s\n", - (int)i, ErrorMsg.c_str()); - BuildLog() += ErrStr; - Failed = true; - break; - } - - if (Options()->isDumpFlagSet(amd::option::DUMP_BC_ORIGINAL)) { - std::string MyErrorInfo; - char buf[128]; - sprintf(buf, "_original%d.bc", (int)i); - std::string fileName = Options()->getDumpFileName(buf); -#if defined(LEGACY_COMPLIB) - llvm::raw_fd_ostream outs(fileName.c_str(), MyErrorInfo, - llvm::raw_fd_ostream::F_Binary); - if (MyErrorInfo.empty()) - llvm::WriteBitcodeToFile(libs[i], outs); - else - printf(MyErrorInfo.c_str()); -#else - std::error_code EC; - llvm::raw_fd_ostream outs(fileName.c_str(), EC, llvm::sys::fs::F_None); - if (!EC) - llvm::WriteBitcodeToFile(libs[i].get(), outs); - else - printf(EC.message().c_str()); -#endif - } - } - - if (!Failed) { - // Link input modules together - for (size_t i = 0; i < libs.size(); ++i) { - DEBUG(llvm::dbgs() << "LinkWithModule " << i << ":\n"); - if (amdcl::OCLLinker::linkWithModule(LLVMBinary(), std::move(libs[i]))) { - Failed = true; - } - } - } - - if (Failed) { - delete LLVMBinary(); - } - libs.clear(); - return Failed; - -} - -void amdcl::OCLLinker::fixupOldTriple(llvm::Module *module) -{ - llvm::Triple triple(module->getTargetTriple()); - - // Bug 9357: "amdopencl" used to be a hacky "OS" that was Linux or Windows - // depending on the host. It only really matters for x86. If we are trying to - // use an old binary module still using the old triple, replace it with a new - // one. - if (triple.getOSName() == "amdopencl") { - if (triple.getArch() == llvm::Triple::amdil || - triple.getArch() == llvm::Triple::amdil64) { - triple.setOS(llvm::Triple::UnknownOS); - } else { - llvm::Triple hostTriple(llvm::sys::getDefaultTargetTriple()); - triple.setOS(hostTriple.getOS()); - } - - triple.setEnvironment(llvm::Triple::AMDOpenCL); - module->setTargetTriple(triple.str()); - } -} - -// On 64 bit device, aclBinary target is set to 64 bit by default. When 32 bit -// LLVM or SPIR binary is loaded, aclBinary target needs to be modified to -// match LLVM or SPIR bitness. -// Returns false on error. -static bool -checkAndFixAclBinaryTarget(llvm::Module* module, aclBinary* elf, - std::string& buildLog) { - if (module->getTargetTriple().empty()) { - LogWarning("Module has no target triple"); - return true; - } - - llvm::Triple triple(module->getTargetTriple()); - const char* newArch = NULL; - if (elf->target.arch_id == aclAMDIL64 && - (triple.getArch() == llvm::Triple::amdil || - triple.getArch() == llvm::Triple::spir)) - newArch = "amdil"; - else if (elf->target.arch_id == aclX64 && - (triple.getArch() == llvm::Triple::x86 || - triple.getArch() == llvm::Triple::spir)) - newArch = "x86"; - else if (elf->target.arch_id == aclHSAIL64 && - (triple.getArch() == llvm::Triple::hsail || - triple.getArch() == llvm::Triple::spir)) - newArch = "hsail"; - if (newArch != NULL) { - acl_error errorCode; - elf->target = aclGetTargetInfo(newArch, aclGetChip(elf->target), - &errorCode); - if (errorCode != ACL_SUCCESS) { - assert(0 && "Invalid arch id or chip id in elf target"); - buildLog += "Internal Error: failed to link modules correctlty.\n"; - return false; - } - } - - reinterpret_cast(elf->options)->libraryType_ = - getLibraryType(&elf->target); - - // Check consistency between module triple and aclBinary target - if (elf->target.arch_id == aclAMDIL64 && - (triple.getArch() == llvm::Triple::amdil64 || - triple.getArch() == llvm::Triple::spir64)) - return true; - if (elf->target.arch_id == aclAMDIL && - (triple.getArch() == llvm::Triple::amdil || - triple.getArch() == llvm::Triple::spir)) - return true; - if (elf->target.arch_id == aclHSAIL64 && - (triple.getArch() == llvm::Triple::hsail64 || - triple.getArch() == llvm::Triple::spir64)) - return true; - if (elf->target.arch_id == aclHSAIL && - (triple.getArch() == llvm::Triple::hsail || - triple.getArch() == llvm::Triple::spir)) - return true; - if (elf->target.arch_id == aclX64 && - (triple.getArch() == llvm::Triple::x86_64 || - triple.getArch() == llvm::Triple::spir64)) - return true; - if (elf->target.arch_id == aclX86 && - (triple.getArch() == llvm::Triple::x86 || - triple.getArch() == llvm::Triple::spir)) - return true; - DEBUG_WITH_TYPE("linkTriple", llvm::dbgs() << - "[checkAndFixAclBinaryTarget] " << - " aclBinary target: " << elf->target.arch_id << - " chipId: " << elf->target.chip_id << - " module triple: " << module->getTargetTriple() << - '\n'); - - //ToDo: There is bug 9996 in compiler library about converting BIF30 to BIF21 - //which causes regressions in ocltst if the following check is enabled. - //Fix the bugs then enable the following check -#if 0 - assert(0 && "Inconsistent LLVM target and elf target"); - buildLog += "Internal Error: failed to link modules correctlty.\n"; - return false; -#else - LogWarning("Inconsistent LLVM target and elf target"); - return true; -#endif -} - -#ifdef HAS_SPIRV -bool -translateSpirv(llvm::Module *&M, const std::string &DumpSpirv, - const std::string &DumpLlvm, bool Timing, std::string &TimeStr){ - uint64_t ReadTime = 0; - uint64_t WriteTime = 0; - std::string S; - llvm::raw_string_ostream RSS(S); - std::string Err; - - if (Timing) - WriteTime = amd::Os::timeNanos(); - if (!llvm::WriteSPIRV(M, RSS, Err)) { - llvm::errs() << "Fails to save LLVM as SPIR-V: " << Err << '\n'; - return false; - } - if (Timing) - WriteTime = amd::Os::timeNanos() - WriteTime; - - if (!DumpSpirv.empty()) { - std::ofstream OFS(DumpSpirv, std::ios::binary); - OFS << RSS.str(); - OFS.close(); - } - - RSS.flush(); - std::stringstream SS(S); - - auto &Ctx = M->getContext(); - delete M; - M = nullptr; - if (Timing) - ReadTime = amd::Os::timeNanos(); - if (!llvm::ReadSPIRV(Ctx, SS, M, Err)) { - llvm::errs() << "Fails to load SPIR-V as LLVM Module: " << Err << '\n'; - return false; - } - - if (Timing) { - ReadTime = amd::Os::timeNanos() - ReadTime; - std::stringstream tmp_ss; - tmp_ss << " LLVM/SPIRV translation time: " - << WriteTime/1000ULL << " us\n" - << " SPIRV/LLVM translation time: " - << ReadTime/1000ULL << " us\n"; - TimeStr = tmp_ss.str(); - } - - if (!DumpLlvm.empty()) { - std::error_code EC; - llvm::raw_fd_ostream outs(DumpLlvm.c_str(), EC, llvm::sys::fs::F_None); - if (!EC) - WriteBitcodeToFile(M, outs); - else { - llvm::errs() << EC.message(); - return false; - } - } - return true; -} -#endif - -int -amdcl::OCLLinker::link(llvm::Module* input, std::vector> &libs) -{ - bool IsGPUTarget = isGpuTarget(Elf()->target); - uint64_t start_time = 0ULL, time_link = 0ULL, time_prelinkopt = 0ULL; - if (Options()->oVariables->EnableBuildTiming) { - start_time = amd::Os::timeNanos(); - } - - fixupOldTriple(input); - - if (!checkAndFixAclBinaryTarget(input, Elf(), BuildLog())) - return 1; - - int ret = 0; - if (Options()->oVariables->UseJIT) { - delete hookup_.amdrtFunctions; - hookup_.amdrtFunctions = amd::getAmdRtFunctions(); - } else { - hookup_.amdrtFunctions = NULL; - } - if (Options()->isOptionSeen(amd::option::OID_LUThreshold) || !IsGPUTarget) { - setUnrollScratchThreshold(Options()->oVariables->LUThreshold); - } else { - setUnrollScratchThreshold(500); - } - - llvmbinary_ = input; - - if ( !LLVMBinary() ) { - BuildLog() += "Internal Error: cannot load bc application for linking\n"; - return 1; - } - - if (linkLLVMModules(libs)) { - BuildLog() += "Internal Error: failed to link modules correctlty.\n"; - return 1; - } - - // Don't link in built-in libraries if we are only creating the library. - if (Options()->oVariables->clCreateLibrary) { - return 0; - } - - if (Options()->isDumpFlagSet(amd::option::DUMP_BC_ORIGINAL)) { - std::string fileName = Options()->getDumpFileName("_original.bc"); - std::error_code EC; - llvm::raw_fd_ostream outs(fileName.c_str(), EC, llvm::sys::fs::F_None); - if (!EC) - WriteBitcodeToFile(LLVMBinary(), outs); - else - printf(EC.message().c_str()); - } - -#ifdef HAS_SPIRV - if (Options()->oVariables->RoundTripSPIRV && isAMDSPIRModule(*llvmbinary_)) { - std::string DumpSpirv; - std::string DumpLlvm; - if (Options()->isDumpFlagSet(amd::option::DUMP_BC_ORIGINAL)) { - DumpSpirv = Options()->getDumpFileName(".spv"); - DumpLlvm = Options()->getDumpFileName("_fromspv.bc"); - } - std::string TimeStr; - translateSpirv(llvmbinary_, DumpSpirv, DumpLlvm, - Options()->oVariables->EnableBuildTiming, TimeStr); - if (!TimeStr.empty()) - appendLogToCL(CL(), TimeStr); - } -#endif - - llvm::StringRef chip(aclGetChip(Elf()->target)); - setGPU(IsGPUTarget); - setFiniteMathOnly(Options()->oVariables->FiniteMathOnly); - setNoSignedZeros(Options()->oVariables->NoSignedZeros); - setFastRelaxedMath(Options()->oVariables->FastRelaxedMath); - setWholeProgram(true); - setOptSimplifyLibCall(Options()->oVariables->OptSimplifyLibCall); - setUnsafeMathOpt(Options()->oVariables->UnsafeMathOpt); - setIsPreLinkOpt(Options()->oVariables->OptLevel != amd::option::OPT_O0); - setFP32RoundDivideSqrt(Options()->oVariables->FP32RoundDivideSqrt); - setUseNative(Options()->oVariables->OptUseNative); - setDenormsAreZero(Options()->oVariables->DenormsAreZero); - setUniformWorkGroupSize(Options()->oVariables->UniformWorkGroupSize); - setHaveFastFMA32(chip == "Cypress" - || chip == "Cayman" - || chip == "Tahiti" - || chip == "Hawaii" - || chip == "Carrizo" - || chip == "gfx900" - || chip == "gfx901" - || chip == "gfx902" - || chip == "gfx903" - || chip == "gfx904" - || chip == "gfx905" - || chip == "gfx906" - || chip == "gfx907" - || chip == "gfx908" - || chip == "gfx1000" - || chip == "gfx1010" - || chip == "gfx1011" - || chip == "gfx1012"); - setISAVersion(getIsaType(aclutGetTargetInfo(Elf()))); - LLVMBinary()->getContext().setAMDLLVMContextHook(&hookup_); - - amd::LibraryDescriptor LibDescs[ - amd::LibraryDescriptor::MAX_NUM_LIBRARY_DESCS]; - int sz; - std::string LibTargetTriple; - std::string LibDataLayout; - if (amd::getLibDescs(Options()->libraryType_, LibDescs, sz) != 0) { - // FIXME: If we error here, we don't clean up, so we crash in debug build - // on compilerfini(). - BuildLog() += "Internal Error: finding libraries failed!\n"; - return 1; - } - - AMDSpir::replaceTrivialFunc(*LLVMBinary()); - - for (int i=0; i < sz; i++) { - std::unique_ptr Library( - amd::LoadLibrary(LibDescs[i].start, LibDescs[i].size, Context())); - - DEBUG(llvm::dbgs() << "Loaded library " << i << "\n"); - if ( !Library.get() ) { - BuildLog() += "Internal Error: cannot load library!\n"; - delete LLVMBinary(); - return 1; -#ifndef NDEBUG - } else { - if ( llvm::verifyModule( *Library.get() ) ) { - BuildLog() += "Internal Error: library verification failed!\n"; - exit(1); - } -#endif - } - DEBUG_WITH_TYPE("linkTriple", llvm::dbgs() << "Library[" << i << "] " << - Library->getTargetTriple() << ' ' << LibDataLayout << '\n'); - - if (LibTargetTriple.empty()) { - // The first member in the list of libraries is assumed to be - // representative of the target device. - LibTargetTriple = Library->getTargetTriple(); - LibDataLayout = Library->getDataLayoutStr(); - DEBUG_WITH_TYPE("linkTriple", llvm::dbgs() << "Library[" << i << "] " << - LibTargetTriple << ' ' << LibDataLayout << '\n'); - assert(!LibTargetTriple.empty() && !LibDataLayout.empty() && - "First library should have triple and datalayout"); - - if (!llvm::fixupKernelModule(LLVMBinary(), LibTargetTriple, LibDataLayout)) - return 1; - - // Before doing anything else, quickly optimize Module - if (Options()->oVariables->EnableBuildTiming) { - time_prelinkopt = amd::Os::timeNanos(); - } - - std::string clp_errmsg; - std::unique_ptr OnFlyLib(AMDPrelink(LLVMBinary(), clp_errmsg)); - - if (!clp_errmsg.empty()) { - delete LLVMBinary(); - BuildLog() += clp_errmsg; - BuildLog() += "Internal Error: on-fly library generation failed\n"; - return 1; - } - - if (OnFlyLib) { - // OnFlyLib must be the first! - std::string ErrorMsg; - if (resolveLink(LLVMBinary(), std::move(OnFlyLib), &ErrorMsg)) { - BuildLog() += ErrorMsg; - BuildLog() += "\nInternal Error: linking libraries failed!\n"; - return 1; - } - } - - if (Options()->oVariables->EnableBuildTiming) { - time_prelinkopt = amd::Os::timeNanos() - time_prelinkopt; - } - } - -#ifndef NDEBUG - // Check consistency of target and data layout - if (!Library->getTargetTriple().empty()) { - assert (Library->getTargetTriple() == LibTargetTriple && - "Library target triple should match"); - assert (Library->getDataLayoutStr() == LibDataLayout && - "Library data layout should match"); - } -#endif - - // Now, do linking by extracting from the builtins library only those - // functions that are used in the kernel(s). - uint64_t tm = Options()->oVariables->EnableBuildTiming ? amd::Os::timeNanos() : 0ULL; - - // Link libraries to get every functions that are referenced. - std::string ErrorMsg; - if (resolveLink(LLVMBinary(), std::move(Library), &ErrorMsg)) { - BuildLog() += ErrorMsg; - BuildLog() += "\nInternal Error: linking libraries failed!\n"; - return 1; - } - - if (Options()->oVariables->EnableBuildTiming) { - time_link += amd::Os::timeNanos() - tm; - } - } - - fixupModulePostLink(LLVMBinary()); - CreateOptControlFunctions(LLVMBinary()); - - if (Options()->oVariables->EnableBuildTiming) { - time_link = amd::Os::timeNanos() - time_link; - std::stringstream tmp_ss; - tmp_ss << " LLVM time (link+opt): " - << (amd::Os::timeNanos() - start_time)/1000ULL - << " us\n" - << " prelinkopt: " << time_prelinkopt/1000ULL << " us\n" - << " link: " << time_link/1000ULL << " us\n"; - appendLogToCL(CL(), tmp_ss.str()); - } - - if (Options()->isDumpFlagSet(amd::option::DUMP_BC_LINKED)) { - std::string MyErrorInfo; - std::string fileName = Options()->getDumpFileName("_linked.bc"); - std::error_code EC; - llvm::raw_fd_ostream outs(fileName.c_str(), EC, llvm::sys::fs::F_None); - // FIXME: Need to add this to the elf binary! - if (!EC) - WriteBitcodeToFile(LLVMBinary(), outs); - else - printf(EC.message().c_str()); - } - - // Check if kernels containing local arrays are called by other kernels. - std::string localArrayUsageError; - if (!llvm::AMDCheckLocalArrayUsage(*LLVMBinary(), &localArrayUsageError)) { - BuildLog() += "Error: " + localArrayUsageError + '\n'; - return 1; - } - - // check undefined function -#ifndef NDEBUG - { - auto M = LLVMBinary(); - for (auto I = M->begin(), E = M->end(); I != E; ++I) { - if (!I->isDeclaration() || I->use_empty() || (I->hasName() && - (I->getName().startswith("__") || - I->getName().startswith("llvm.")))) - continue; - llvm::errs() << "Warning: Undefined function: " << *I << '\n'; - } - } -#endif - - return 0; -} diff --git a/rocclr/compiler/lib/backends/common/linker.hpp b/rocclr/compiler/lib/backends/common/linker.hpp deleted file mode 100644 index f15e9a6123..0000000000 --- a/rocclr/compiler/lib/backends/common/linker.hpp +++ /dev/null @@ -1,92 +0,0 @@ -// -// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _BE_LINKER_HPP_ -#define _BE_LINKER_HPP_ -#include "compiler_stage.hpp" -#include "aclTypes.h" -#include -#include - - -namespace llvm { - class Module; - class Value; -}; // namespace llvm - -namespace amdcl -{ - /*! \addtogroup Compiler Library - * - * \copydoc amdcl::Linker - * - * @{ - */ - class Linker : public LLVMCompilerStage{ - Linker(Linker&); // DO NOT IMPLEMENT. - Linker(); // DO NOT IMPLEMENT. - - public: - Linker(aclCompiler *cl, aclBinary* elf, aclLogFunction log) - : LLVMCompilerStage(cl, elf, log) {} - - virtual ~Linker() {} - - - - /*! Function that takes as in a llvm::Module that contains LLVM-IR - * binary and links in a vector of libraries. - * Returns 0 on success, non-zero on failure. - */ - virtual int link(llvm::Module* input, std::vector> &libs) = 0; - - }; // class Linker - /*@}*/ - - /*! \addtogroup Compiler Library - * - * \copydoc amdcl::OCLLinker - * - * @{ - * \brief Linker that is unique to OpenCL. - */ - class OCLLinker : public Linker { - public: - OCLLinker(aclCompiler* cl, aclBinary* bin, aclLogFunction log) - : Linker(cl, bin, log) {} - - virtual ~OCLLinker() { - for (unsigned j = 0, i = (unsigned)mathLibs_.size(); j < i; ++j) { - if (mathLibs_[j]) { - delete mathLibs_[j]; - } - } - }; - void setPreLinkOpt(bool Val) { hookup_.amdoptions.IsPreLinkOpt = Val; } - void setUnrollScratchThreshold(uint32_t ust) { hookup_.amdoptions.UnrollScratchThreshold = ust; } - - bool getWholeProgram() { return hookup_.amdoptions.WholeProgram; } - uint32_t getUnrollScratchThreshold() { return hookup_.amdoptions.UnrollScratchThreshold; } - - - /*! Function that takes as input a std::string which - * contains LLVM-IR binary and links in a vector of libraries. - * This version also links in the OpenCL math libraries along with - * the list of libraries that are passed in. - */ - int link(llvm::Module* input, std::vector> &libs); - protected: - bool linkLLVMModules(std::vector> &libs); - bool linkWithModule(llvm::Module* Dst, std::unique_ptr Src); - - - private: - static void fixupOldTriple(llvm::Module* module); - /*! Vector of modules that stores the math libraries. - */ - std::vector mathLibs_; - }; // class OCLLinker - /*@}*/ - -}; // namespace amdcl -#endif // _BE_LINKER_HPP_ diff --git a/rocclr/compiler/lib/backends/common/opt_level.cpp b/rocclr/compiler/lib/backends/common/opt_level.cpp deleted file mode 100644 index a2d7c2b412..0000000000 --- a/rocclr/compiler/lib/backends/common/opt_level.cpp +++ /dev/null @@ -1,284 +0,0 @@ -// -// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved. -// -#include "top.hpp" -#include "opt_level.hpp" -#include "library.hpp" -#include "acl.h" -#include "utils/options.hpp" -#include "utils/target_mappings.h" -#include "utils/libUtils.h" -#include "llvm/Analysis/Passes.h" -#if defined(LEGACY_COMPLIB) -#include "llvm/DataLayout.h" -#include "llvm/Module.h" -#else -#include "llvm/Analysis/TargetTransformInfo.h" -#endif -#include "llvm/Transforms/IPO/PassManagerBuilder.h" -#include "llvm/LinkAllPasses.h" -#include "llvm/Support/TargetRegistry.h" -#include "llvm/Transforms/IPO/AMDOptOptions.h" -#include "compiler_stage.hpp" -using namespace amdcl; -using namespace llvm; - -void -OptLevel::setup(aclBinary *elf, bool isGPU, uint32_t OptLevel) -{ - // Add an appropriate DataLayout instance for this module. -#if defined(LEGACY_COMPLIB) - Passes().add(new DataLayout(module_)); - fpasses_ = new FunctionPassManager(module_); - fpasses_->add(new DataLayout(module_)); -#else - fpasses_ = new legacy::FunctionPassManager(module_); -#endif - - const aclTargetInfo* trg = aclutGetTargetInfo(elf); - if (trg) { - llvm::Triple TheTriple(getTriple(trg->arch_id)); - if (TheTriple.getArch()) { - std::string Error; - llvm::StringRef MArch(aclGetArchitecture(*trg)); - const Target *TheTarget = TargetRegistry::lookupTarget(MArch, TheTriple, - Error); - if (TheTarget) { - llvm::TargetOptions targetOptions; - targetOptions.StackAlignmentOverride = Options()->oVariables->CPUStackAlignment; -#ifdef WITH_TARGET_HSAIL - if (Options()->libraryType_ == amd::GPU_Library_HSAIL) - targetOptions.UnsafeFPMath = Options()->oVariables->UnsafeMathOpt; -#endif - targetOptions.LessPreciseFPMADOption = Options()->oVariables->MadEnable || - Options()->oVariables->EnableMAD; - targetOptions.NoInfsFPMath = targetOptions.NoNaNsFPMath - = Options()->oVariables->FiniteMathOnly; - for (auto &F : *module_) { - auto Attrs = F.getAttributes(); - Attrs = Attrs.addAttribute(F.getContext(), AttributeSet::FunctionIndex, - "no-frame-pointer-elim", "false"); - F.setAttributes(Attrs); - } - - llvm::CodeGenOpt::Level OLvl = CodeGenOpt::None; - switch (Options()->oVariables->OptLevel) { - case amd::option::OPT_O0: // -O0 - OLvl = CodeGenOpt::None; - break; - case amd::option::OPT_O1: // -O1 - OLvl = CodeGenOpt::Less; - break; - case amd::option::OPT_O2: // -O2 - case amd::option::OPT_O5: // -O5 - case amd::option::OPT_OG: // -Og - case amd::option::OPT_OS: // -Os - OLvl = CodeGenOpt::Default; - break; - case amd::option::OPT_O3: // -O3 - case amd::option::OPT_O4: // -O4 - OLvl = CodeGenOpt::Aggressive; - break; - default: - assert(!"Error with optimization level"); - }; - - TM = TheTarget->createTargetMachine(TheTriple.getTriple(), - aclutGetCodegenName(elf->target), - getFeatureString(elf->target, Options()), - targetOptions, - WINDOWS_SWITCH(Reloc::DynamicNoPIC, Reloc::PIC_), - CodeModel::Default, OLvl); - } - } - } - if (TM) { - passes_.add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis())); - fpasses_->add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis())); - } - - PassManagerBuilder Builder; - Builder.OptLevel = OptLevel; - - if (Options()->libraryType_ == amd::GPU_Library_HSAIL) { - if (OptLevel == 0) return; - } - - if (!Options()->oVariables->Inline) { - // No inlining pass - } else if (isGPU) { -#ifdef WITH_TARGET_HSAIL - if (Options()->libraryType_ == amd::GPU_Library_HSAIL) { - if (HLC_HSAIL_Enable_Calls) { - HLC_Disable_Amd_Inline_All = true; - } else { - HLC_Disable_Amd_Inline_All = false; - } - // Always create Inliner regardless of OptLevel - if (HLC_Force_Always_Inliner_Pass) { - Builder.Inliner = createAlwaysInlinerPass(); - } else { - Builder.Inliner = createAMDFunctionInliningPass(HLC_HSAIL_Inline_Threshold); - } - } else -#endif - { - HLC_Disable_Amd_Inline_All = false; - // Always create Inliner regardless of OptLevel - Builder.Inliner = createAMDFunctionInliningPass(500); - } - } else if (OptLevel > 1) { - unsigned Threshold = 225; - if (OptLevel > 2) - Threshold = 275; -#ifdef WITH_TARGET_HSAIL - if (Options()->libraryType_ == amd::GPU_Library_HSAIL) { - // Don't do inlining (including createAlwaysInlinerPass()) if OptimizationLevel - // is zero becaue we are generating code for -g - if (OptLevel > 0) { - Builder.Inliner = createAMDFunctionInliningPass(Threshold); - } - } else -#endif - { - Builder.Inliner = createAMDFunctionInliningPass(Threshold); - } - } - Builder.SizeLevel = 0; - Builder.DisableUnitAtATime = false; - Builder.DisableUnrollLoops = OptLevel == 0; -#if defined(LEGACY_COMPLIB) - if (Options()->libraryType_ != amd::GPU_Library_HSAIL) - Builder.DisableSimplifyLibCalls = true; -#endif - Builder.AMDpopulateFunctionPassManager(*fpasses_, &module_->getContext()); - Builder.AMDpopulateModulePassManager(passes_, &module_->getContext(), module_); -} - -void -OptLevel::run(aclBinary *elf) -{ - if (Options()->oVariables->OptPrintLiveness) { - Passes().add(createAMDLivenessPrinterPass()); - } - fpasses_->doInitialization(); - for (Module::iterator I = module_->begin(), E = module_->end(); I != E; ++I) - fpasses_->run(*I); - fpasses_->doFinalization(); - // Now that we have all of the passes ready, run them. - passes_.run(*module_); - - delete fpasses_; -} - -int -O0OptLevel::optimize(aclBinary *elf, Module *input, bool isGPU) -{ - // With -O0, we don't do anything - module_ = input; -#ifdef WITH_TARGET_HSAIL - if (Options()->libraryType_ == amd::GPU_Library_HSAIL) { - // Mark all non-kernel functions as having internal linkage - Passes().add(createAMDSymbolLinkagePass(true, NULL)); - } else -#endif - { - setup(elf, false, 0); - run(elf); - } - return 0; -} - -int -GPUO0OptLevel::optimize(aclBinary *elf, Module *input, bool isGPU) -{ - module_ = input; - assert(isGPU && "Only a GPU can use GPUO0OptLevel!\n"); - setup(elf, true, 0); -#ifdef WITH_TARGET_HSAIL - if (Options()->libraryType_ == amd::GPU_Library_HSAIL) { - // On the GPU, even with -O0, we must do some optimizations. One - // goal is to ensure that all functions are inlined. This requires - // three steps in that order: - // - // 1. Mark all non-kernel functions as having internal linkage. - // 2. Invoke the GlobalOptimizer to resolve function aliases. - // 3. Force inlining using our custom inliner pass. - if (Options()->oVariables->EnableDebug) { - HLC_HSAIL_Enable_Calls = false; - HLC_Disable_Amd_Inline_All = false; - } - else if (HLC_HSAIL_Enable_Calls) { - HLC_Disable_Amd_Inline_All = true; - } - else { - HLC_Disable_Amd_Inline_All = false; - } - Passes().add(createAMDSymbolLinkagePass(true, NULL)); - Passes().add(createGlobalOptimizerPass()); - if (!HLC_Disable_Amd_Inline_All && - !DisableInline && - !HLC_Force_Always_Inliner_Pass) { - Passes().add(createAMDInlineAllPass(true)); - } else { - Passes().add(createAlwaysInlinerPass()); - } - } -#endif - run(elf); - return 0; -} - -int -O1OptLevel::optimize(aclBinary *elf, Module *input, bool isGPU) -{ - module_ = input; - setup(elf, isGPU, 1); - run(elf); - return 0; -} - -int -O2OptLevel::optimize(aclBinary *elf, Module *input, bool isGPU) -{ - module_ = input; - setup(elf, isGPU, 2); - run(elf); - return 0; -} - -int -O3OptLevel::optimize(aclBinary *elf, Module *input, bool isGPU) -{ - module_ = input; - setup(elf, isGPU, 3); - run(elf); - return 0; -} - -int -O4OptLevel::optimize(aclBinary *elf, Module *input, bool isGPU) -{ - module_ = input; - setup(elf, isGPU, 4); - run(elf); - return 0; -} - -int -OsOptLevel::optimize(aclBinary *elf, Module *input, bool isGPU) -{ - module_ = input; - setup(elf, isGPU, 5); - run(elf); - return 0; -} - -int -OgOptLevel::optimize(aclBinary *elf, Module *input, bool isGPU) -{ - module_ = input; - setup(elf, isGPU, 2); - run(elf); - return 0; -} diff --git a/rocclr/compiler/lib/backends/common/opt_level.hpp b/rocclr/compiler/lib/backends/common/opt_level.hpp deleted file mode 100644 index 207b70c75e..0000000000 --- a/rocclr/compiler/lib/backends/common/opt_level.hpp +++ /dev/null @@ -1,218 +0,0 @@ -// -// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _BE_OPT_LEVEL_HPP_ -#define _BE_OPT_LEVEL_HPP_ -#include "top.hpp" -#include "utils/options.hpp" -#include "aclTypes.h" - -#if defined DEBUG -#undef DEBUG -#endif - -#include "llvm/Analysis/Passes.h" -#include "llvm/IR/LegacyPassManager.h" -#include "llvm/Target/TargetMachine.h" - -namespace llvm { - class Module; - -}; // llvm namespace - -#if defined(LEGACY_COMPLIB) -#define LLVM_LEGACY_NAMESPACE llvm -#else -#define LLVM_LEGACY_NAMESPACE llvm::legacy -#endif - -namespace amdcl -{ - /*! \addtogroup Compiler Library - * - * \copydoc amdcl::OptLevel - * - * @{ - */ - class OptLevel { - OptLevel(OptLevel&); // DO NOT IMPLEMENT. - OptLevel(); // DO NOT IMPLEMENT. - - public: - OptLevel(amd::option::Options *OptionsObj) - : opts_(OptionsObj), TM(nullptr) {} - - virtual ~OptLevel() { delete TM; } - - virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU) = 0; - protected: - void setup(aclBinary *elf, bool isGPU, uint32_t OptLevel); - void run(aclBinary *elf); - LLVM_LEGACY_NAMESPACE::PassManager& Passes() { return passes_; } - LLVM_LEGACY_NAMESPACE::FunctionPassManager& FPasses() { return (*fpasses_); } - amd::option::Options* Options() { return opts_; } - llvm::Module* module_; - private: - LLVM_LEGACY_NAMESPACE::FunctionPassManager *fpasses_; - LLVM_LEGACY_NAMESPACE::PassManager passes_; - amd::option::Options *opts_; - llvm::TargetMachine* TM; - }; // class OptLevel - /*@}*/ - - /*! \addtogroup Compiler Library - * - * \copydoc amdcl::O0OptLevel - * - * @{ - */ - class O0OptLevel : public OptLevel { - O0OptLevel(O0OptLevel&); // DO NOT IMPLEMENT. - O0OptLevel(); // DO NOT IMPLEMENT. - - public: - O0OptLevel(amd::option::Options *opts) - : OptLevel(opts) {} - - virtual ~O0OptLevel() {} - - virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU); - }; // class O0OptLevel - /*@}*/ - - /*! \addtogroup Compiler Library - * - * \copydoc amdcl::GPUO0OptLevel - * - * @{ - */ - class GPUO0OptLevel : public O0OptLevel { - GPUO0OptLevel(GPUO0OptLevel&); // DO NOT IMPLEMENT. - GPUO0OptLevel(); // DO NOT IMPLEMENT. - - public: - GPUO0OptLevel(amd::option::Options *opts) - : O0OptLevel(opts) {} - - virtual ~GPUO0OptLevel() {} - - virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU); - }; // class O0OptLevel - /*@}*/ - - /*! \addtogroup Compiler Library - * - * \copydoc amdcl::O1OptLevel - * - * @{ - */ - class O1OptLevel : public OptLevel { - O1OptLevel(O1OptLevel&); // DO NOT IMPLEMENT. - O1OptLevel(); // DO NOT IMPLEMENT. - - public: - O1OptLevel(amd::option::Options *opts) - : OptLevel(opts) {} - - virtual ~O1OptLevel() {} - - virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU); - }; // class O1OptLevel - /*@}*/ - - /*! \addtogroup Compiler Library - * - * \copydoc amdcl::O2OptLevel - * - * @{ - */ - class O2OptLevel : public OptLevel { - O2OptLevel(O2OptLevel&); // DO NOT IMPLEMENT. - O2OptLevel(); // DO NOT IMPLEMENT. - - public: - O2OptLevel(amd::option::Options *opts) - : OptLevel(opts) {} - - virtual ~O2OptLevel() {} - - virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU); - }; // class O2OptLevel - /*@}*/ - - /*! \addtogroup Compiler Library - * - * \copydoc amdcl::O3OptLevel - * - * @{ - */ - class O3OptLevel : public OptLevel { - O3OptLevel(O3OptLevel&); // DO NOT IMPLEMENT. - O3OptLevel(); // DO NOT IMPLEMENT. - - public: - O3OptLevel(amd::option::Options *opts) - : OptLevel(opts) {} - - virtual ~O3OptLevel() {} - - virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU); - }; // class O3OptLevel - /*@}*/ - - /*! \addtogroup Compiler Library - * - * \copydoc amdcl::O4OptLevel - * - * @{ - */ - class O4OptLevel : public OptLevel { - O4OptLevel(O4OptLevel&); // DO NOT IMPLEMENT. - O4OptLevel(); // DO NOT IMPLEMENT. - - public: - O4OptLevel(amd::option::Options *opts) - : OptLevel(opts) {} - - virtual ~O4OptLevel() {} - - virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU); - }; // class O4OptLevel - /*@}*/ - - /*! \addtogroup Compiler Library - * - * \copydoc amdcl::OsOptLevel - * - * @{ - */ - class OsOptLevel : public OptLevel { - OsOptLevel(OsOptLevel&); // DO NOT IMPLEMENT. - OsOptLevel(); // DO NOT IMPLEMENT. - - public: - OsOptLevel(amd::option::Options *opts) - : OptLevel(opts) {} - - virtual ~OsOptLevel() {} - - virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU); - }; // class OsOptLevel - /*@}*/ - - class OgOptLevel : public OptLevel { - OgOptLevel(OgOptLevel&); // DO NOT IMPLEMENT. - OgOptLevel(); // DO NOT IMPLEMENT. - - public: - OgOptLevel(amd::option::Options *opts) - : OptLevel(opts) {} - - virtual ~OgOptLevel() {} - - virtual int optimize(aclBinary *elf, llvm::Module *input, bool isGPU); - }; // class OgOptLevel - /*@}*/ - -}; // amdcl namespace -#endif // _BE_OPT_LEVEL_HPP_ diff --git a/rocclr/compiler/lib/backends/common/optimizer.cpp b/rocclr/compiler/lib/backends/common/optimizer.cpp deleted file mode 100644 index b162d69992..0000000000 --- a/rocclr/compiler/lib/backends/common/optimizer.cpp +++ /dev/null @@ -1,188 +0,0 @@ -// -// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved. -// -#include "top.hpp" -#include "optimizer.hpp" -#include "opt_level.hpp" -#include "os/os.hpp" -#include "utils/bif_section_labels.hpp" -#include "utils/libUtils.h" -#include "utils/options.hpp" - -#if defined(LEGACY_COMPLIB) -#include "llvm/DataLayout.h" -#else -#include "llvm/IR/DataLayout.h" -#include "llvm/Support/FileSystem.h" -#include "AMDPasses.h" -#endif -#include "llvm/Analysis/Passes.h" -#include "llvm/Support/raw_ostream.h" -#include "llvm/LinkAllPasses.h" -#include -#include -using namespace amdcl; -using namespace llvm; - -static OptLevel* getOptLevel(amd::option::Options* Options, bool isGPU) { - switch(Options->oVariables->OptLevel) { - case amd::option::OPT_O0: - return (isGPU) ? new GPUO0OptLevel(Options) : new O0OptLevel(Options); - case amd::option::OPT_O1: - return new O1OptLevel(Options); - default: - assert(!"Found an invalid optimization level!"); - case amd::option::OPT_O2: - return new O2OptLevel(Options); - case amd::option::OPT_OG: - return new OgOptLevel(Options); - case amd::option::OPT_O3: - return new O3OptLevel(Options); - case amd::option::OPT_O4: - return new O4OptLevel(Options); - case amd::option::OPT_O5: - case amd::option::OPT_OS: - return new OsOptLevel(Options); - } - assert(!"Unreachable!"); - return NULL; -} - -int -CPUOptimizer::preOptimizer(llvm::Module* M) -{ -#if defined(LEGACY_COMPLIB) - llvm::PassManager Passes; - Passes.add(new llvm::DataLayout(M)); -#else - llvm::legacy::PassManager Passes; -#endif - - Passes.add(createAMDExportKernelNaturePass()); - - Passes.run(*M); - - return 0; -} - - int -CPUOptimizer::optimize(llvm::Module *input) -{ - if (!input) { - return 1; - } - int ret = 0; - uint64_t start_time = 0ULL, time_opt = 0ULL; - llvmbinary_ = input; - setWholeProgram(true); - - setGPU(false); - if (Options()->oVariables->EnableBuildTiming) { - start_time = amd::Os::timeNanos(); - } - ret = preOptimizer(LLVMBinary()); - setUniformWorkGroupSize(Options()->oVariables->UniformWorkGroupSize); - OptLevel* cpuOpt = getOptLevel(Options(), false); - if (Options()->oVariables->EnableBuildTiming) { - time_opt = amd::Os::timeNanos(); - } - ret = cpuOpt->optimize(Elf(), LLVMBinary(), false); - if (Options()->oVariables->EnableBuildTiming) { - time_opt = amd::Os::timeNanos() - time_opt; - std::stringstream tmp_ss; - tmp_ss << " LLVM Opt time: " - << time_opt/1000ULL - << "us\n"; - appendLogToCL(CL(), tmp_ss.str()); - } - delete cpuOpt; - - if ( ret ) { - BuildLog() += "Internal Error: optimizer failed!\n"; - return 1; - } - if (Options()->isDumpFlagSet(amd::option::DUMP_BC_OPTIMIZED)) { - std::string fileName = Options()->getDumpFileName("_optimized.bc"); -#if defined(LEGACY_COMPLIB) - std::string MyErrorInfo; - raw_fd_ostream outs (fileName.c_str(), MyErrorInfo, raw_fd_ostream::F_Binary); - // FIXME: Need to add this to the elf binary! - if (MyErrorInfo.empty()) - WriteBitcodeToFile(LLVMBinary(), outs); - else - printf(MyErrorInfo.c_str()); -#else - std::error_code EC; - llvm::raw_fd_ostream outs(fileName.c_str(), EC, llvm::sys::fs::F_None); - // FIXME: Need to add this to the elf binary! - if (!EC) - WriteBitcodeToFile(LLVMBinary(), outs); - else - printf(EC.message().c_str()); -#endif - } - return ret; -} - - int -GPUOptimizer::optimize(llvm::Module *input) -{ - if (!input) { - return 1; - } - int ret = 0; - uint64_t start_time = 0ULL, time_opt = 0ULL; - llvmbinary_ = input; - - setGPU(true); - setWholeProgram(true); -#ifdef WITH_TARGET_HSAIL - if (isHSAILTarget(Elf()->target)) { - if (Options()->NumAvailGPRs == -1) - Options()->NumAvailGPRs = 128; // Default HSAIL number of GPRs - if (hookup_.amdoptions.NumAvailGPRs == ~0u) - hookup_.amdoptions.NumAvailGPRs = Options()->NumAvailGPRs; - } -#endif - setUniformWorkGroupSize(Options()->oVariables->UniformWorkGroupSize); - OptLevel* gpuOpt = getOptLevel(Options(), true); - if (Options()->oVariables->EnableBuildTiming) { - time_opt = amd::Os::timeNanos(); - } - ret = gpuOpt->optimize(Elf(), LLVMBinary(), true); - if (Options()->oVariables->EnableBuildTiming) { - time_opt = amd::Os::timeNanos() - time_opt; - std::stringstream tmp_ss; - tmp_ss << " LLVM Opt time: " - << time_opt/1000ULL - << "us\n"; - appendLogToCL(CL(), tmp_ss.str()); - } - delete gpuOpt; - - if ( ret ) { - BuildLog() += "Internal Error: optimizer failed!\n"; - return 1; - } - if (Options()->isDumpFlagSet(amd::option::DUMP_BC_OPTIMIZED)) { - std::string fileName = Options()->getDumpFileName("_optimized.bc"); -#if defined(LEGACY_COMPLIB) - std::string MyErrorInfo; - raw_fd_ostream outs (fileName.c_str(), MyErrorInfo, raw_fd_ostream::F_Binary); - // FIXME: Need to add this to the elf binary! - if (MyErrorInfo.empty()) - WriteBitcodeToFile(LLVMBinary(), outs); - else - printf(MyErrorInfo.c_str()); -#else - std::error_code EC; - llvm::raw_fd_ostream outs(fileName.c_str(), EC, llvm::sys::fs::F_None); - // FIXME: Need to add this to the elf binary! - if (!EC) - WriteBitcodeToFile(LLVMBinary(), outs); - else - printf(EC.message().c_str()); -#endif - } - return ret; -} diff --git a/rocclr/compiler/lib/backends/common/optimizer.hpp b/rocclr/compiler/lib/backends/common/optimizer.hpp deleted file mode 100644 index 0590d7f900..0000000000 --- a/rocclr/compiler/lib/backends/common/optimizer.hpp +++ /dev/null @@ -1,110 +0,0 @@ -// -// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _BE_OPTIMIZER_HPP_ -#define _BE_OPTIMIZER_HPP_ -#include "aclTypes.h" -#include "compiler_stage.hpp" - -namespace llvm -{ - class Module; -} - -namespace amdcl -{ - /*! \addtogroup Compiler Library - * - * \copydoc amdcl::Optimizer - * - * @{ - */ - class Optimizer : public LLVMCompilerStage { - Optimizer(Optimizer&); // DO NOT IMPLEMENT. - Optimizer(); // DO NOT IMPLEMENT. - public: - Optimizer(aclCompiler *cl, aclBinary* elf, aclLogFunction log) - : LLVMCompilerStage(cl, elf, log) { - // Expose some options to LLVM - llvm::AMDOptions *amdopts = &hookup_.amdoptions; - if (opts_) { - amdopts->OptLiveness = opts_->oVariables->OptLiveness; - amdopts->NumAvailGPRs = opts_->NumAvailGPRs; - } - } - - virtual ~Optimizer() {} - - /*! Function that takes in the LLVM module as input - * and optimizes it. - * Returns 0 on success and non-zero on failure. - */ - virtual int optimize(llvm::Module *input) = 0; - - }; // class Optimizer - /*@}*/ - - /*! \addtogroup Compiler Library - * - * \copydoc amdcl::CLOptimizer - * - * @{ - */ - class CLOptimizer : public Optimizer { - public: - CLOptimizer(aclCompiler *cl, aclBinary *elf, aclLogFunction log) - : Optimizer(cl, elf, log) {} - virtual ~CLOptimizer() {} - - /*! Function that takes in the LLVM module as input - * and optimizes it. - * Returns 0 on success and non-zero on failure. - */ - virtual int optimize(llvm::Module *input) = 0; - }; // class CLOptimizer - /*@}*/ - - /*! \addtogroup Compiler Library - * - * \copydoc amdcl::GPUOptimizer - * - * @{ - */ - class GPUOptimizer : public CLOptimizer { - public: - GPUOptimizer(aclCompiler *cl, aclBinary *elf, aclLogFunction log) - : CLOptimizer(cl, elf, log) {} - virtual ~GPUOptimizer() {} - - /*! Function that takes in the LLVM module as input - * and optimizes it. - * Returns 0 on success and non-zero on failure. - */ - virtual int optimize(llvm::Module *input); - }; // class GPUOptimizer - /*@}*/ - - /*! \addtogroup Compiler Library - * - * \copydoc amdcl::CPUOptimizer - * - * @{ - */ - class CPUOptimizer : public CLOptimizer { - public: - CPUOptimizer(aclCompiler *cl, aclBinary *elf, aclLogFunction log) - : CLOptimizer(cl, elf, log) {} - virtual ~CPUOptimizer() {} - - /*! Function that takes in the LLVM module as input - * and optimizes it. - * Returns 0 on success and non-zero on failure. - */ - virtual int optimize(llvm::Module *input); - protected: - int preOptimizer(llvm::Module *m); - }; // class CPUOptimizer - /*@}*/ - -}; // amdcl namespace -#endif // _BE_OPTIMIZER_HPP_ diff --git a/rocclr/compiler/lib/backends/common/spir.cpp b/rocclr/compiler/lib/backends/common/spir.cpp deleted file mode 100644 index 77569fc5d1..0000000000 --- a/rocclr/compiler/lib/backends/common/spir.cpp +++ /dev/null @@ -1,165 +0,0 @@ -// -// Copyright (c) 2011 Advanced Micro Devices, Inc. All rights reserved. -// -#include "top.hpp" -#include "spir.hpp" -#include "aclTypes.h" -#include "bif/bifbase.hpp" -#include "utils/libUtils.h" -#include "utils/options.hpp" -#include "utils/target_mappings.h" -#include "os/os.hpp" - -#include -#include -#include -#include -#include - -#if defined(LEGACY_COMPLIB) -#include "llvm/DataLayout.h" -#include "llvm/Module.h" -#include "llvm/Analysis/Verifier.h" -#include "llvm/Assembly/PrintModulePass.h" -#else -#include "llvm/IR/DataLayout.h" -#include "llvm/IR/Module.h" -#include "llvm/IR/Verifier.h" -#endif -#include "llvm/Pass.h" -#if defined(LEGACY_COMPLIB) -#include "llvm/PassManager.h" -#else -#include "llvm/IR/LegacyPassManager.h" -#endif -#include "llvm/ADT/SmallString.h" -#include "llvm/Analysis/SPIRVerifier.h" -#include "llvm/Bitcode/ReaderWriter.h" -#include "llvm/Bitcode/BitstreamWriter.h" -#include "llvm/Support/raw_ostream.h" -#include "llvm/Transforms/Scalar.h" - -#if defined(LEGACY_COMPLIB) -#define LLVMReturnStatusAction ReturnStatusAction -#endif - -using namespace llvm; -using namespace amdcl; - -Module* -amdcl::SPIR::loadSPIR(std::string &spirBinary) -{ - // Need to use the namespace here since a parent function is called Module(). - llvm::Module *bc = NULL; - std::string errors; - source_ = spirBinary; - SPIRState State = {"", "", 1, 0, 1, 2}; - bc = amdcl::LLVMCompilerStage::loadBitcode(source_); - if (!bc) - { - errors = "loadBitcode failed"; - log_ += errors; - return NULL; - } -#if defined(LEGACY_COMPLIB) - verifyModule(*bc, ReturnStatusAction, &errors); -#else - raw_string_ostream errorsOS(errors); - verifyModule(*bc, &errorsOS); -#endif - if (!errors.empty()) { - log_ += errors; - errors.clear(); - } -#if defined(LEGACY_COMPLIB) - FunctionPassManager FPM(bc); -#else - legacy::FunctionPassManager FPM(bc); -#endif - if (Options()->oVariables->verifyHWSpir) { - if (!isHSAILTarget(Elf()->target)) { - verifySPIRModule(*bc, LLVMReturnStatusAction, State, false, &errors); - } - if (!errors.empty()) { - log_ += errors; - errors.clear(); - delete bc; - return NULL; - } - } - if (Options()->oVariables->verifyLWSpir) { - if (!isHSAILTarget(Elf()->target)) { - verifySPIRModule(*bc, LLVMReturnStatusAction, State, true, &errors); - } - if (!errors.empty()) { - log_ += errors; - errors.clear(); - delete bc; - return NULL; - } - } - return bc; -} -Module* -amdcl::SPIR::loadBitcode(std::string &binary) -{ - llvm::Module *bc = loadSPIR(binary); - if (!bc) return NULL; - - // FIXME: It is not clear why SPIRLoader is invoked so early here. - // The current view is to keep SPIRLoader as a pure pre-link pass to - // be called only by the linker. - StringRef LayoutStr = is64BitTarget(Elf()->target) ? - DATA_LAYOUT_64BIT : DATA_LAYOUT_32BIT; - bc->setDataLayout(LayoutStr); - bc->setTargetTriple(familySet[Elf()->target.arch_id].triple); - -#if defined(LEGACY_COMPLIB) - llvm::PassManager SPIRPasses; - SPIRPasses.add(new llvm::DataLayout(bc)); -#else - llvm::legacy::PassManager SPIRPasses; -#endif - SPIRPasses.add(createSPIRLoader(/*demangleBuiltin=*/ true)); - SPIRPasses.run(*bc); - return bc; -} - -const void* -SPIR::toBinary(const void *text, size_t text_size, size_t *binary_size) -{ - std::string text_buf(reinterpret_cast(text), text_size); - // Need to use the namespace here since a parent function is called Module(). - llvm::Module *mod = loadSPIR(text_buf); - SmallString<256> char_buf; - raw_svector_ostream outstream(char_buf); - WriteBitcodeToFile(mod, outstream); - std::string str_buf(char_buf.begin(), char_buf.end()); - (*binary_size) = char_buf.size(); - void *ptr = aclutAlloc(CL())(*binary_size); - std::copy(char_buf.begin(), char_buf.end(), reinterpret_cast(ptr)); - return ptr; -} - -const void* -SPIR::toText(const void *binary, size_t binary_size, size_t *text_size) -{ - std::string text_buf(reinterpret_cast(binary), binary_size); - // Need to use the namespace here since a parent function is called Module(). - llvm::Module *mod = loadSPIR(text_buf); - std::string errors; - if (!mod) - { - errors = "loadSPIR failed"; - log_ += errors; - return NULL; - } - std::string bin_buf; - raw_string_ostream buf(bin_buf); - mod->print(buf, NULL); - (*text_size) = bin_buf.size(); - void *ptr = aclutAlloc(CL())(*text_size); - std::copy(bin_buf.begin(), bin_buf.end(), reinterpret_cast(ptr)); - return ptr; -} - diff --git a/rocclr/compiler/lib/backends/common/spir.hpp b/rocclr/compiler/lib/backends/common/spir.hpp deleted file mode 100644 index c877737970..0000000000 --- a/rocclr/compiler/lib/backends/common/spir.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// -// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _BE_SPIR_HPP_ -#define _BE_SPIR_HPP_ -#include -#include "aclTypes.h" -#include "compiler_stage.hpp" -namespace amdcl -{ - /*@}*/ - - /*! \addtogroup CompilerLibrary - * - * \copydoc amdcl::SPIR - * - * @{ - * \brief Implementation of the Frontend interface to compile - * from OpenCL C to LLVM-IR. - */ - class SPIR : public LLVMCompilerStage { - SPIR(SPIR&); // DO NOT IMPLEMENT. - SPIR(); // DO NOT IMPLEMENT. - - public: - SPIR(aclCompiler* cl, aclBinary* elf, aclLogFunction log) - : LLVMCompilerStage(cl, elf, log) {} - - virtual ~SPIR() {} - virtual llvm::Module* loadBitcode(std::string &spirBinary) override; - virtual llvm::Module* loadSPIR(std::string &spirBinary); - const void* - toBinary(const void *text, size_t text_size, size_t *binary_size); - const void* - toText(const void *binary, size_t binary_size, size_t *text_size); - - }; // class SPIR - /*@}*/ -} // namespac amdcl -#endif // _BE_SPIR_HPP_ diff --git a/rocclr/compiler/lib/backends/common/sync.cpp b/rocclr/compiler/lib/backends/common/sync.cpp deleted file mode 100644 index 45183fea6e..0000000000 --- a/rocclr/compiler/lib/backends/common/sync.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// -// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved. -// -#include "sync.hpp" -#include "llvm/Support/Mutex.h" -#include "llvm/Support/Threading.h" - - -static llvm::sys::MutexImpl mtx; - -namespace amdcl -{ - -void acquire_global_lock() { - if (llvm::llvm_is_multithreaded()) - mtx.acquire(); -} - -void release_global_lock() { - if (llvm::llvm_is_multithreaded()) - mtx.release(); -} - -} // namespace amdcl diff --git a/rocclr/compiler/lib/backends/common/sync.hpp b/rocclr/compiler/lib/backends/common/sync.hpp deleted file mode 100644 index 1d62a81934..0000000000 --- a/rocclr/compiler/lib/backends/common/sync.hpp +++ /dev/null @@ -1,13 +0,0 @@ -// -// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _BE_SYNC_HPP_ -#define _BE_SYNC_HPP_ - -namespace amdcl -{ - void acquire_global_lock(); - - void release_global_lock(); -} // namespace amdcl -#endif // _BE_SYNC_HPP_ diff --git a/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp b/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp deleted file mode 100644 index 26f144d86d..0000000000 --- a/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp +++ /dev/null @@ -1,3675 +0,0 @@ -// -// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved. -// -#ifdef WITH_TARGET_HSAIL -#include "HSAILBrigContainer.h" -#include "HSAILDisassembler.h" -#include "HSAILBrigObjectFile.h" - -//prevent macro redefinition in drivers\hsa\compiler\lib\promotions\oclutils\top.hpp -//as it's already defined in drivers\hsa\compiler\llvm\include\llvm\Support\Format.h -#undef snprintf -#endif - -#include "acl.h" -#include "aclTypes.h" -#include "compiler_stage.hpp" -#include "frontend.hpp" -#include "spir.hpp" - -#if defined DEBUG -#undef DEBUG -#endif - -#include "codegen.hpp" -#include "library.hpp" -#include "linker.hpp" -#include "optimizer.hpp" -#include "amdil_be.hpp" -#include "hsail_be.hpp" -#include "x86_be.hpp" -#include "os/os.hpp" -#include "utils/bif_section_labels.hpp" -#include "utils/libUtils.h" -#include "utils/options.hpp" -#include "utils/target_mappings.h" -#include "utils/versions.hpp" -#include "sync.hpp" - -#include "llvm/Analysis/Passes.h" -#if defined(LEGACY_COMPLIB) -#include "Disassembler.h" -#include "llvm/LLVMContext.h" -#include "llvm/MC/MCAsmInfo.h" -#include "llvm/MC/MCContext.h" -#include "llvm/MC/MCRegisterInfo.h" -#include "llvm/MC/MCStreamer.h" -#include "llvm/MC/MCInstrInfo.h" -#include "llvm/MC/MCSubtargetInfo.h" -#include "llvm/Support/IRReader.h" -#include "llvm/Support/raw_ostream.h" -#include "llvm/Support/ErrorHandling.h" -#include "llvm/ADT/OwningPtr.h" -#include "llvm/ExecutionEngine/ObjectImage.h" -#include "llvm/ExecutionEngine/ObjectBuffer.h" -#else -#include "llvm/ADT/DenseMap.h" -#include "llvm/IR/LLVMContext.h" -#include "llvm/Object/ObjectFile.h" -#include "llvm/Support/SPIRV.h" -#endif -#include "llvm/MC/MCObjectFileInfo.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/Compiler.h" -#include "llvm/Support/FormattedStream.h" -#include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/PrettyStackTrace.h" -#include "llvm/Support/Signals.h" -#include "llvm/Support/TargetSelect.h" -#include "llvm/Support/TargetRegistry.h" -#include "llvm/Support/Threading.h" -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/Bitcode/BitstreamWriter.h" -#include "llvm/Bitcode/ReaderWriter.h" -#include "llvm/Transforms/Scalar.h" -#include "llvm/ExecutionEngine/ExecutionEngine.h" -#include "llvm/ExecutionEngine/JITEventListener.h" -#include "llvm/ExecutionEngine/RuntimeDyld.h" - -#include "bif/bifbase.hpp" -#include -#include -#include -#include -#include -#include - -aclLoaderData * ACL_API_ENTRY -if_aclCompilerInit(aclCompiler *cl, aclBinary *bin, - aclLogFunction log, acl_error *error) -{ - amdcl::acquire_global_lock(); - char* timing = ::getenv("AMD_DEBUG_HLC_ENABLE_TIMING"); - if (timing && (timing[0] == '1')) - llvm::TimePassesIsEnabled = true; - else - llvm::TimePassesIsEnabled = false; - if (cl->llvm_shutdown == NULL) { - cl->llvm_shutdown = reinterpret_cast - (new llvm::llvm_shutdown_obj( -#if defined(LEGACY_COMPLIB) - false -#endif - )); - } - static const char *DumpStackTrace = getenv("AMD_DUMP_STACK_TRACE"); - if (DumpStackTrace) { - llvm::EnablePrettyStackTrace(); - llvm::sys::PrintStackTraceOnErrorSignal(); - } - // Initialize targets first. - llvm::InitializeAllTargets(); - - llvm::InitializeAllAsmPrinters(); - llvm::InitializeAllTargetMCs(); - // Initialize passes - llvm::PassRegistry &Registry = *llvm::PassRegistry::getPassRegistry(); - llvm::initializeCore(Registry); - llvm::initializeTransformUtils(Registry); - llvm::initializeScalarOpts(Registry); - llvm::initializeInstCombine(Registry); - llvm::initializeIPO(Registry); - llvm::initializeInstrumentation(Registry); - llvm::initializeAnalysis(Registry); - llvm::initializeCodeGen(Registry); - llvm::initializeTarget(Registry); -#if defined(LEGACY_COMPLIB) - llvm::initializeVerifierPass(Registry); - llvm::initializeDominatorTreePass(Registry); - llvm::initializePreVerifierPass(Registry); -#endif - amdcl::release_global_lock(); - if (error) (*error) = ACL_SUCCESS; - return reinterpret_cast(cl); -} -acl_error ACL_API_ENTRY -if_aclCompilerFini(aclLoaderData *ald) -{ - if (ald == NULL) return ACL_INVALID_ARG; - aclCompiler *cl = reinterpret_cast(ald); - return ACL_SUCCESS; -} - - -#define LOADER_FUNCS(NAME, TYPE) \ - aclLoaderData* ACL_API_ENTRY \ -NAME##Init(aclCompiler *cl,\ - aclBinary *bin, \ - aclLogFunction callback,\ - acl_error *error)\ -{\ - acl_error error_code = ACL_SUCCESS;\ - TYPE *acl = new TYPE(cl, bin, callback);\ - if (acl == NULL) {\ - error_code = ACL_OUT_OF_MEM;\ - }\ - if (error != NULL) (*error) = error_code;\ - return reinterpret_cast(acl);\ -}\ -acl_error ACL_API_ENTRY \ -NAME##Fini(aclLoaderData *ald)\ -{\ - acl_error error_code = ACL_SUCCESS;\ - TYPE *acl = reinterpret_cast(ald);\ - if (acl == NULL) {\ - error_code = ACL_INVALID_ARG;\ - } else {\ - delete acl;\ - }\ - return error_code;\ -} - -#define LOADER_FUNCS_ERROR(NAME, TYPE) \ - aclLoaderData* ACL_API_ENTRY \ -NAME##Init(aclCompiler *cl,\ - aclBinary *bin, \ - aclLogFunction callback,\ - acl_error *error)\ -{\ - assert(!"Cannot go down this path without enabling support!"); \ - if (error) (*error) = ACL_SYS_ERROR; \ - return NULL; \ -}\ -acl_error ACL_API_ENTRY \ -NAME##Fini(aclLoaderData *ald)\ -{\ - assert(!"Cannot go down this path without enabling support!"); \ - return ACL_SYS_ERROR; \ -} - -#if defined(WITH_TARGET_AMDIL) -LOADER_FUNCS(AMDIL, amdcl::AMDIL); -LOADER_FUNCS(AMDILOpt, amdcl::GPUOptimizer); -#else -LOADER_FUNCS_ERROR(AMDIL, amdcl::AMDIL); -LOADER_FUNCS_ERROR(AMDILOpt, amdcl::GPUOptimizer); -#endif - -#if defined(WITH_TARGET_HSAIL) -LOADER_FUNCS(HSAILAsm, amdcl::HSAIL); -LOADER_FUNCS(HSAILFE, amdcl::ClangOCLFrontend); -LOADER_FUNCS(HSAILOpt, amdcl::GPUOptimizer); -#else -LOADER_FUNCS_ERROR(HSAILAsm, amdcl::HSAIL); -LOADER_FUNCS_ERROR(HSAILFE, amdcl::ClangOCLFrontend); -LOADER_FUNCS_ERROR(HSAILOpt, amdcl::GPUOptimizer); -#endif - -#if defined(WITH_TARGET_X86) -LOADER_FUNCS(X86Asm, amdcl::X86); -LOADER_FUNCS(X86Opt, amdcl::CPUOptimizer); -#else -LOADER_FUNCS_ERROR(X86Asm, amdcl::X86); -LOADER_FUNCS_ERROR(X86Opt, amdcl::CPUOptimizer); -#endif - -#if defined(LEGACY_COMPLIB) -LOADER_FUNCS(OCL, amdcl::OCLFrontend); -#else -LOADER_FUNCS(OCL, amdcl::ClangOCLFrontend); -#endif -LOADER_FUNCS(Link, amdcl::OCLLinker); -LOADER_FUNCS(Codegen, amdcl::CLCodeGen); -LOADER_FUNCS(SPIR, amdcl::SPIR); -#undef LOADER_FUNCS - - -// CLC Frontend phase -aclModule* ACL_API_ENTRY -OCLFEToLLVMIR( - aclLoaderData *ald, - const char *source, - size_t data_size, - aclContext *ctx, - acl_error *error) -{ - if (error != NULL) (*error) = ACL_SUCCESS; - amdcl::Frontend *aclFE = reinterpret_cast(ald); - aclFE->setContext(ctx); - int ret; - std::string src_str(source, data_size); - ret = aclFE->compileCommand(src_str); - if (!aclFE->BuildLog().empty()) { - appendLogToCL(aclFE->CL(), aclFE->BuildLog()); - } - if (ret) { - if (error != NULL) (*error) = ACL_FRONTEND_FAILURE; - return NULL; - } - return aclFE->Module(); -} - -aclModule* ACL_API_ENTRY -OCLFEToSPIR( - aclLoaderData *ald, - const char *source, - size_t data_size, - aclContext *ctx, - acl_error *error) -{ - if (error != NULL) (*error) = ACL_SUCCESS; - amdcl::Frontend *aclFE = reinterpret_cast(ald); - aclFE->setContext(ctx); - int ret; - std::string src_str(source, data_size); - ret = aclFE->compileCommand(src_str); - if (!aclFE->BuildLog().empty()) { - appendLogToCL(aclFE->CL(), aclFE->BuildLog()); - } - if (ret) { - if (error != NULL) (*error) = ACL_FRONTEND_FAILURE; - return NULL; - } - return aclFE->Module(); -} -aclModule* ACL_API_ENTRY -SPIRToModule( - aclLoaderData *ald, - const char *source, - size_t data_size, - aclContext *ctx, - acl_error *error) -{ - if (error != NULL) (*error) = ACL_SUCCESS; - amdcl::SPIR *aclSPIR = reinterpret_cast(ald); - aclSPIR->setContext(ctx); - std::string dataStr(source, data_size); - aclModule *module = reinterpret_cast(aclSPIR->loadBitcode(dataStr)); - if (!aclSPIR->BuildLog().empty()) { - appendLogToCL(aclSPIR->CL(), aclSPIR->BuildLog()); - } - if (module == NULL) { - if (error != NULL) (*error) = ACL_FRONTEND_FAILURE; - return NULL; - } - return module; -} - -aclModule * ACL_API_ENTRY -RSLLVMIRToModule( - aclLoaderData *ald, - const char *source, - size_t data_size, - aclContext *ctx, - acl_error *error) -{ - if (error != NULL) (*error) = ACL_SUCCESS; - std::string llvmBinary(source, data_size); - std::string ErrorMessage; - llvm::LLVMContext * Context = reinterpret_cast(ctx); -#if defined(LEGACY_COMPLIB) - llvm::MemoryBuffer *Buffer = - llvm::MemoryBuffer::getMemBufferCopy( - llvm::StringRef(llvmBinary), "input.bc"); - llvm::Module *M = NULL; -#else - std::unique_ptr Buffer = - llvm::MemoryBuffer::getMemBufferCopy(llvm::StringRef(llvmBinary), "input.bc"); - llvm::ErrorOr> ErrOrM(nullptr); -#endif - - if (llvm::isBitcode((const unsigned char *)Buffer->getBufferStart(), - (const unsigned char *)Buffer->getBufferEnd())) { -#if defined(LEGACY_COMPLIB) - M = llvm::ParseBitcodeFile(Buffer, *Context, &ErrorMessage); -#else - ErrOrM = llvm::parseBitcodeFile(Buffer->getMemBufferRef(), *Context); -#endif - } - -#if defined(LEGACY_COMPLIB) - if (M == NULL) { -#else - if (ErrOrM.getError()) { -#endif - if (error != NULL) (*error) = ACL_INVALID_BINARY; - return NULL; - } -#if !defined(LEGACY_COMPLIB) - auto M = ErrOrM.get().release(); -#endif - amdcl::CompilerStage *cs = reinterpret_cast(ald); - aclDevType arch_id = cs->Elf()->target.arch_id; - if ((arch_id != aclAMDIL) && (arch_id != aclHSAIL)) { - assert("Unsupported architecture, expect amdil."); - return NULL; - } - - const char * NewTriple = familySet[aclAMDIL].triple; - std::string OldTriple = M->getTargetTriple(); - - if (OldTriple.compare("armv7-none-linux-gnueabi")) { - assert("Input target is unknown, expect armv7-none-linux-gnueabi."); - return NULL; - } - - M->setTargetTriple(NewTriple); - const char * LayoutStr = is64BitTarget(cs->Elf()->target) ? - DATA_LAYOUT_64BIT : DATA_LAYOUT_32BIT; - M->setDataLayout(LayoutStr); -#if defined(LEGACY_COMPLIB) - llvm::PassManager TransformPasses; -#else - llvm::legacy::PassManager TransformPasses; -#endif - TransformPasses.add(llvm::createOpenCLIRTransform()); - if (!TransformPasses.run(*M)) { - if (error != NULL) (*error) = ACL_FRONTEND_FAILURE; - return NULL; - } - - aclModule *module = reinterpret_cast(M); - return module; -} - -aclModule* ACL_API_ENTRY -OCLFEToModule( - aclLoaderData *ald, - const char *source, - size_t data_size, - aclContext *ctx, - acl_error *error) -{ - if (error != NULL) (*error) = ACL_SUCCESS; - amdcl::Frontend *aclFE = reinterpret_cast(ald); - aclFE->setContext(ctx); - std::string dataStr(source, data_size); - aclModule *module = reinterpret_cast(aclFE->loadBitcode(dataStr)); - if (!aclFE->BuildLog().empty()) { - appendLogToCL(aclFE->CL(), aclFE->BuildLog()); - } - if (module == NULL) { - if (error != NULL) (*error) = ACL_FRONTEND_FAILURE; - return NULL; - } - return module; -} - -/// Update elf e_rawfile buffer. -static acl_error -updateElfRawFile(aclBinary *bin) -{ - if (bin == NULL - || bin->bin == NULL) { - return ACL_INVALID_ARG; - } - bifbase *elfBin = reinterpret_cast(bin->bin); - return elfBin->updateRawFile() ? ACL_SUCCESS : ACL_ELF_ERROR; -} - -aclModule* ACL_API_ENTRY -SPIRVToModule( - aclLoaderData *ald, - const char *image, - size_t length, - aclContext *ctx, - acl_error *error) -{ - auto compiler = reinterpret_cast(ald); - auto cl = compiler->CL(); - auto bin = compiler->Elf(); -#ifdef LEGACY_COMPLIB - llvm::report_fatal_error("SPIR-V not supported on legacy compiler lib"); - appendLogToCL(cl, "SPIR-V not supported on legacy compiler lib"); - if (error != nullptr) (*error) = ACL_SPIRV_LOAD_FAIL; - return nullptr; -#else - std::string spvImg(image, length); - /// ToDo: When there are multiple binaries, compiler->Options() - /// cannot carry options specified by environment variables to here - /// but bin->options can. This seems to be related to how runtime - /// sets up aclCompiler options and BIF options. - auto opt = reinterpret_cast(bin->options); - if (opt->isDumpFlagSet(amd::option::DUMP_SPIRV)) { - std::ofstream ofs(opt->getDumpFileName(".spv"), std::ios::binary); - ofs << spvImg; - ofs.close(); - } - - std::stringstream ss(spvImg); - std::string errMsg; - auto llCtx = reinterpret_cast(ctx); - llvm::Module *llMod = nullptr; - if (opt->getLLVMArgc()) { - llvm::cl::ParseCommandLineOptions(opt->getLLVMArgc(), opt->getLLVMArgv(), - "SPIRV/LLVM converter"); - } - bool success = llvm::ReadSPIRV(*llCtx, ss, llMod, errMsg); - - if (success && llMod && opt->isDumpFlagSet(amd::option::DUMP_BC_SPIRV)) { - auto bcDump = opt->getDumpFileName("_fromspv.bc"); - std::error_code ec; - llvm::raw_fd_ostream outS(bcDump.c_str(), ec, llvm::sys::fs::F_None); - if (!ec) - WriteBitcodeToFile(llMod, outS); - else - errMsg = ec.message(); - } - - if (!errMsg.empty()) { - appendLogToCL(cl, errMsg); - } - if (!success || llMod == nullptr) { - if (error != nullptr) (*error) = ACL_SPIRV_LOAD_FAIL; - return nullptr; - } - - llvm::SmallVector array; - llvm::raw_svector_ostream outstream(array); - llvm::WriteBitcodeToFile(reinterpret_cast(llMod), outstream); - auto errCode = cl->clAPI.insSec(cl, bin, &array[0], array.size(), aclLLVMIR); - if (error != nullptr) (*error) = errCode; - if (errCode != ACL_SUCCESS) - return reinterpret_cast(llMod); - - errCode = updateElfRawFile(bin); - if (error != nullptr) (*error) = errCode; - return reinterpret_cast(llMod); -#endif // LEGACY_COMPLIB -} - -aclModule * ACL_API_ENTRY -LLVMToSPIRV( - aclLoaderData *ald, - const char *source, - size_t data_size, - aclContext *ctx, - acl_error *error) -{ - auto compiler = reinterpret_cast(ald); -#ifdef LEGACY_COMPLIB - llvm::report_fatal_error("SPIR-V not supported on legacy compiler lib"); - appendLogToCL(compiler->CL(), "SPIR-V not supported on legacy compiler lib"); - if (error != nullptr) (*error) = ACL_SPIRV_LOAD_FAIL; - return nullptr; -#else - - std::string errMsg; - auto opt = compiler->Options(); - llvm::Module *llMod = reinterpret_cast(OCLFEToModule( - ald, source, data_size, ctx, error)); - if (!llMod) - return nullptr; - - if (opt->isDumpFlagSet(amd::option::DUMP_BC_SPIRV)) { - auto bcDump = opt->getDumpFileName("_tospv.bc"); - std::error_code ec; - llvm::raw_fd_ostream outS(bcDump.c_str(), ec, llvm::sys::fs::F_None); - if (!ec) - WriteBitcodeToFile(llMod, outS); - else - errMsg = ec.message(); - } - - std::string spvImg; - llvm::raw_string_ostream ss(spvImg); - bool success = llvm::WriteSPIRV(llMod, ss, errMsg); - - if (opt->isDumpFlagSet(amd::option::DUMP_SPIRV)) { - std::ofstream ofs(opt->getDumpFileName(".spv"), std::ios::binary); - ofs << ss.str(); - ofs.close(); - } - - if (!errMsg.empty()) { - appendLogToCL(compiler->CL(), errMsg); - } - if (!success) { - if (error != nullptr) (*error) = ACL_SPIRV_SAVE_FAIL; - return nullptr; - } - - if (error != nullptr) (*error) = ACL_SUCCESS; - return reinterpret_cast(llMod); -#endif // LEGACY_COMPLIB -} - -acl_error ACL_API_ENTRY -AMDILFEToISA( - aclLoaderData *ald, - const char *source, - size_t data_size) -{ -#ifdef WITH_TARGET_AMDIL - acl_error error_code = ACL_SUCCESS; - amdcl::AMDIL *acl = reinterpret_cast(ald); - if (acl == NULL) { - error_code = ACL_FRONTEND_FAILURE; - } - else { - amd::option::Options* Opts = acl->Options(); - const char *kernel = Opts->getCurrKernelName(); - const char *name = (kernel == NULL) ? "main" : kernel; - if (acl->compile(source, name)) { - error_code = ACL_FRONTEND_FAILURE; - } - } - if (!acl->BuildLog().empty()) { - appendLogToCL(acl->CL(), acl->BuildLog()); - } - if (!checkFlag(aclutGetCaps(acl->Elf()), capSaveAMDIL)) { - acl->CL()->clAPI.remSec(acl->CL(), acl->Elf(), aclSOURCE); - } - return error_code; -#else - assert(!"Cannot go down this path without AMDIL support!"); - return ACL_SYS_ERROR; -#endif -} - -acl_error ACL_API_ENTRY -OCLFEToISA( - aclLoaderData *ald, - const char *source, - size_t data_size) -{ - assert(!"Not implemented!"); - return ACL_UNSUPPORTED; -} - -aclModule* ACL_API_ENTRY -OCLLinkToLLVMIR( - aclLoaderData *data, - aclModule *llvmBin, - aclContext *ctx, - acl_error *error) -{ - if (error != NULL) (*error) = ACL_UNSUPPORTED; - assert(!"Not implemented!"); - return NULL; -} -aclModule* ACL_API_ENTRY -OCLLinkToSPIR( - aclLoaderData *data, - aclModule *llvmBin, - aclContext *ctx, - acl_error *error) -{ - if (error != NULL) (*error) = ACL_UNSUPPORTED; - assert(!"Not implemented!"); - return NULL; -} - -// LLVM Link phase -aclModule* ACL_API_ENTRY -OCLLinkPhase( - aclLoaderData *data, - aclModule *llvmBin, - unsigned int numLibs, - aclModule **libs, - aclContext *ctx, - acl_error *error) -{ - if (error != NULL) (*error) = ACL_SUCCESS; - amdcl::OCLLinker *aclLink = reinterpret_cast(data); - if (aclLink == NULL || llvmBin == NULL || ctx == NULL) { - if (error != NULL) (*error) = ACL_INVALID_ARG; - return NULL; - } - const char* argv[] = { "", - "-loop-unswitch-threshold=0", - "-binomial-coefficient-limit-bitwidth=64", - "-hsail-max-wg-size=2048" - }; - - aclLink->setContext(ctx); - amd::option::Options* Opts = reinterpret_cast(aclLink->Elf()->options); - int args = sizeof(argv) / sizeof(argv[0]); - llvm::cl::ParseCommandLineOptions(args, (char**)argv, "OpenCL"); - - if (Opts->getLLVMArgc()) - llvm::cl::ParseCommandLineOptions(Opts->getLLVMArgc(), - Opts->getLLVMArgv(), "OpenCL"); - - // LLVM Link phase - std::vector> libvec; - for (unsigned x = 0; x < numLibs; ++x) { - if (libs[x] != NULL) { - libvec.push_back(std::unique_ptr(reinterpret_cast(libs[x]))); - } - } - int ret = aclLink->link(reinterpret_cast(llvmBin), libvec); - if (!aclLink->BuildLog().empty()) { - appendLogToCL(aclLink->CL(), aclLink->BuildLog()); - } - if (ret) { - if (error != NULL) (*error) = ACL_LINKER_ERROR; - return NULL; - } - return aclLink->Module(); -} - -aclModule* ACL_API_ENTRY -GPUOptPhase(aclLoaderData *data, - aclModule *llvmBin, - aclContext *ctx, - acl_error *error) -{ -#if defined(WITH_TARGET_AMDIL) || defined(WITH_TARGET_HSAIL) - amdcl::CompilerStage *cs = reinterpret_cast(data); - if (isGpuTarget(cs->Elf()->target)) { - if (error != NULL) (*error) = ACL_SUCCESS; - amdcl::GPUOptimizer *aclOpt = reinterpret_cast(data); - if (aclOpt == NULL || llvmBin == NULL || ctx == NULL) { - if (error != NULL) (*error) = ACL_INVALID_ARG; - return NULL; - } - // LLVM Optimize phase - aclOpt->setContext(ctx); - amd::option::Options* Opts = reinterpret_cast(aclOpt->Elf()->options); - if (Opts->getLLVMArgc()) - llvm::cl::ParseCommandLineOptions(Opts->getLLVMArgc(), - Opts->getLLVMArgv(), "OpenCL"); - - int ret = aclOpt->optimize(reinterpret_cast(llvmBin)); - if (!aclOpt->BuildLog().empty()) { - appendLogToCL(aclOpt->CL(), aclOpt->BuildLog()); - } - if (ret) { - if (error != NULL) (*error) = ACL_OPTIMIZER_ERROR; - return NULL; - } - return aclOpt->Module(); - } else { - assert(!"GPUOptPhase should be called only for AMDIL or HSAIL target."); - if (error) (*error) = ACL_SYS_ERROR; - return NULL; - } -#else - assert(!"Cannot go down this path without GPU support!"); - if (error) (*error) = ACL_SYS_ERROR; - return NULL; -#endif -} - -aclModule* ACL_API_ENTRY -X86OptPhase(aclLoaderData *data, - aclModule *llvmBin, - aclContext *ctx, - acl_error *error) -{ -#if defined(WITH_TARGET_X86) - if (error != NULL) (*error) = ACL_SUCCESS; - amdcl::CPUOptimizer *aclOpt = reinterpret_cast(data); - if (aclOpt == NULL || llvmBin == NULL || ctx == NULL) { - if (error != NULL) (*error) = ACL_INVALID_ARG; - return NULL; - } - // LLVM Optimize phase - aclOpt->setContext(ctx); - amd::option::Options* Opts = reinterpret_cast(aclOpt->Elf()->options); - if (Opts->getLLVMArgc()) - llvm::cl::ParseCommandLineOptions(Opts->getLLVMArgc(), - Opts->getLLVMArgv(), "OpenCL"); - int ret = aclOpt->optimize(reinterpret_cast(llvmBin)); - if (!aclOpt->BuildLog().empty()) { - appendLogToCL(aclOpt->CL(), aclOpt->BuildLog()); - } - if (ret) { - if (error != NULL) (*error) = ACL_OPTIMIZER_ERROR; - return NULL; - } - return aclOpt->Module(); -#else - assert(!"Cannot go down this path without X86 support!"); - if (error) (*error) = ACL_SYS_ERROR; - return NULL; -#endif -} - -const void* ACL_API_ENTRY -CodegenPhase(aclLoaderData *data, - aclModule *llvmBin, - aclContext *ctx, - acl_error *error) -{ - if (error != NULL) (*error) = ACL_SUCCESS; - amdcl::CLCodeGen *aclCG = reinterpret_cast(data); - if (aclCG == NULL || llvmBin == NULL || ctx == NULL) { - if (error != NULL) (*error) = ACL_INVALID_ARG; - return NULL; - } - aclCG->setContext(ctx); - amd::option::Options* Opts = reinterpret_cast(aclCG->Elf()->options); - if (Opts->getLLVMArgc()) - llvm::cl::ParseCommandLineOptions(Opts->getLLVMArgc(), - Opts->getLLVMArgv(), "OpenCL"); - // LLVM Codegen phase - int ret = aclCG->codegen(reinterpret_cast(llvmBin)); - if (!aclCG->BuildLog().empty()) { - appendLogToCL(aclCG->CL(), aclCG->BuildLog()); - } - if (ret) { - if (error != NULL) (*error) = ACL_CODEGEN_ERROR; - return NULL; - } - if (!isHSAILTarget(aclCG->Elf()->target)) { - if (checkFlag(aclutGetCaps(aclCG->Elf()), capSaveCG)) { - aclCG->CL()->clAPI.insSec(aclCG->CL(), aclCG->Elf(), - aclCG->Source().data(), - aclCG->Source().size(), aclCODEGEN); - } - } - return reinterpret_cast(&(aclCG->Source())); -} - -acl_error ACL_API_ENTRY -AMDILAsmPhase(aclLoaderData *data, - const char *source, - size_t data_size) -{ -#ifdef WITH_TARGET_AMDIL - acl_error error_code = ACL_SUCCESS; - if (source == NULL) { - return ACL_INVALID_BINARY; - } - amdcl::AMDIL *acl = reinterpret_cast(data); - if (acl == NULL || acl->jit(source)) { - error_code = ACL_CODEGEN_ERROR; - } - if (!acl->BuildLog().empty()) { - appendLogToCL(acl->CL(), acl->BuildLog()); - } - return error_code; -#else - assert(!"Cannot go down this path without AMDIL support!"); - return ACL_CODEGEN_ERROR; -#endif -} -acl_error ACL_API_ENTRY -AMDILDisassemble(aclLoaderData *data, - const char *kernel, - const void *isa_code, - size_t isa_size) -{ -#ifdef WITH_TARGET_AMDIL - std::string isaDump = ""; - std::string isaName = ""; - acl_error error_code = ACL_SUCCESS; - if (isa_code == NULL || isa_size == 0 || kernel == NULL) { - return ACL_INVALID_ARG; - } - amdcl::AMDIL *acl = reinterpret_cast(data); - if (acl == NULL) { - error_code = ACL_INVALID_ARG; - } - isaDump = acl->disassemble(isa_code, isa_size); - const oclBIFSymbolStruct* symbol = findBIF30SymStruct(symISAText); - assert(symbol && "symbol not found"); - isaName = symbol->str[PRE] + std::string(kernel) + symbol->str[POST]; - if (!isaDump.empty()) { - error_code = acl->CL()->clAPI.insSym(acl->CL(), acl->Elf(), - isaDump.data(), isaDump.size(), - symbol->sections[0], isaName.c_str()); - } - if (acl->Options()) { - std::string kernelFileName = acl->Options()->getDumpFileName("_" + std::string(kernel) + ".isa"); - amdcl::dumpISA(kernelFileName, isaDump, acl->Options()); - } - if (acl->Callback()) { - acl->Callback()(isaDump.data(), isaDump.size()); - } - return error_code; -#else - assert(!"Cannot go down this path without AMDIL support!"); - return ACL_SYS_ERROR; -#endif -} - -acl_error ACL_API_ENTRY -AMDILAssemble(aclLoaderData *data, - const char *source, - size_t data_size) -{ -#ifdef WITH_TARGET_AMDIL - assert(!"Not implemented!"); - return ACL_UNSUPPORTED; -#else - assert(!"Cannot go down this path without AMDIL support!"); - return ACL_SYS_ERROR; -#endif -} - -acl_error ACL_API_ENTRY -HSAILAsmPhase(aclLoaderData *data, - const char *source, - size_t data_size) -{ -#ifdef WITH_TARGET_HSAIL - acl_error error_code = ACL_SUCCESS; - if (source == NULL) { - return ACL_INVALID_BINARY; - } - amdcl::HSAIL *acl = reinterpret_cast(data); - if (acl == NULL) { - error_code = ACL_CODEGEN_ERROR; - } - if (acl->finalize()) { - error_code = ACL_CODEGEN_ERROR; - } - if (!acl->BuildLog().empty()) { - appendLogToCL(acl->CL(), acl->BuildLog()); - } - return error_code; -#else - assert(!"Cannot go down this path without HSAIL support!"); - return ACL_SYS_ERROR; -#endif -} - -acl_error ACL_API_ENTRY -HSAILAssemble(aclLoaderData *data, - const char *source, - size_t data_size) -{ -#ifdef WITH_TARGET_HSAIL - acl_error error_code = ACL_SUCCESS; - amdcl::HSAIL *acl = reinterpret_cast(data); - if (acl == NULL || !acl->assemble(source)) { - // TODO_HSA: Should this be tagged as an assembler error? - // needs ACL_ASSEMBLER_ERROR - error_code = ACL_CODEGEN_ERROR; - appendLogToCL(acl->CL(), "Error assembling HSAIL text."); - } - if (!acl->BuildLog().empty()) - appendLogToCL(acl->CL(), acl->BuildLog()); - return error_code; -#else - assert(!"Cannot go down this path without HSAIL support!"); - return ACL_SYS_ERROR; -#endif -} - -acl_error ACL_API_ENTRY -HSAILDisassemble(aclLoaderData *data, - const char *kernel, - const void *isa_code, - size_t isa_size) -{ -#ifdef WITH_TARGET_HSAIL - std::string isaDump = ""; - std::string isaName = ""; - acl_error error_code = ACL_SUCCESS; - if (isa_code == NULL || isa_size == 0 || kernel == NULL) { - return ACL_INVALID_ARG; - } - amdcl::HSAIL *acl = reinterpret_cast(data); - if (acl == NULL) { - return ACL_INVALID_ARG; - } - isaDump = acl->disassemble(isa_code, isa_size, kernel); - const oclBIFSymbolStruct* symbol = findBIF30SymStruct(symISAText); - assert(symbol && "symbol not found"); - isaName = symbol->str[PRE] + std::string(kernel) + symbol->str[POST]; - if (!isaDump.empty()) { - error_code = acl->CL()->clAPI.insSym(acl->CL(), acl->Elf(), - isaDump.c_str(), isaDump.size(), - aclINTERNAL, isaName.c_str()); - } - if (acl->Options()) { - std::string kernelFileName = acl->Options()->getDumpFileName("_" + std::string(kernel) + ".isa"); - acl->dumpISA(kernelFileName, isaDump, acl->Options()); - } - if (acl->Callback()) { - acl->Callback()(isaDump.c_str(), isaDump.size()); - } - return error_code; -#else - assert(!"Cannot go down this path without HSAIL support!"); - return ACL_SYS_ERROR; -#endif -} - -acl_error ACL_API_ENTRY -X86AsmPhase(aclLoaderData *data, - const char *source, - size_t data_size) -{ -#ifdef WITH_TARGET_X86 - acl_error error_code = ACL_SUCCESS; - if (source == NULL) { - return ACL_INVALID_BINARY; - } - amdcl::X86 *acl = reinterpret_cast(data); - if (acl == NULL || acl->jit(source)) { - error_code = ACL_CODEGEN_ERROR; - } - if (!acl->BuildLog().empty()) { - appendLogToCL(acl->CL(), acl->BuildLog()); - } - return error_code; -#else - assert(!"Cannot go down this path without X86 support!"); - return ACL_SYS_ERROR; -#endif -} - - acl_error ACL_API_ENTRY -X86Assemble(aclLoaderData *data, - const char *source, - size_t data_size) -{ -#ifdef WITH_TARGET_X86 - assert(!"Not implemented!"); - return ACL_UNSUPPORTED; -#else - assert(!"Cannot go down this path without X86 support!"); - return ACL_SYS_ERROR; -#endif -} - -acl_error ACL_API_ENTRY -X86Disassemble(aclLoaderData *data, - const char *kernel, - const void *isa_code, - size_t isa_size) -{ -#ifdef WITH_TARGET_X86 - assert(!"Not implemented!"); - return ACL_UNSUPPORTED; -#else - assert(!"Cannot go down this path without X86 support!"); - return ACL_SYS_ERROR; -#endif -} - -static void -saveOptionsToComments(aclCompiler *cl, aclBinary *curElf, const char *str, std::string &symbol) -{ - if (str != NULL && !checkFlag(aclutGetCaps(curElf), capEncrypted) - && strlen(str)) { - size_t test = 0; - const void* ptr = cl->clAPI.extSym(cl, curElf, &test, aclCOMMENT, symbol.c_str(), NULL); - if (ptr == NULL || (ptr != NULL && (test != strlen(str) - || strcmp(reinterpret_cast(ptr), str)))) { - if (ptr != NULL) { - cl->clAPI.remSym(cl, curElf, aclCOMMENT, symbol.c_str()); - } - cl->clAPI.insSym(cl, curElf, str, strlen(str), aclCOMMENT, symbol.c_str()); - } - } -} - -aclLoaderData* ACL_API_ENTRY -OptInit(aclCompiler *cl, - aclBinary *bin, - aclLogFunction log, - acl_error *err) -{ - if (!bin) return NULL; - switch(bin->target.arch_id) - { - default: - assert(!"Found an unhandled architecture!"); - case aclX64: - case aclX86: return X86OptInit(cl, bin, log, err); - case aclHSAIL64: - case aclHSAIL: return HSAILOptInit(cl, bin, log, err); - case aclAMDIL64: - case aclAMDIL: return AMDILOptInit(cl, bin, log, err); - } - return NULL; -} - -acl_error ACL_API_ENTRY -OptFini(aclLoaderData *ptr) { - if (!ptr) return ACL_ERROR; - amdcl::CompilerStage *cs = reinterpret_cast(ptr); - switch (cs->Elf()->target.arch_id) { - default: - assert(!"Found an unhandled architecture!"); - case aclX64: - case aclX86: return X86OptFini(ptr); - case aclHSAIL64: - case aclHSAIL: return HSAILOptFini(ptr); - case aclAMDIL64: - case aclAMDIL: return AMDILOptFini(ptr); - } - return ACL_ERROR; -} - -aclModule* ACL_API_ENTRY -OptOptimize(aclLoaderData *data, - aclModule *llvmBin, - aclContext *ctx, - acl_error *error) -{ - if (!data) return NULL; - amdcl::CompilerStage *cs = reinterpret_cast(data); - switch (cs->Elf()->target.arch_id) { - default: - assert(!"Found an unhandled architecture!"); - case aclX64: - case aclX86: return X86OptPhase(data, llvmBin, ctx, error); - case aclHSAIL64: - case aclHSAIL: return GPUOptPhase(data, llvmBin, ctx, error); - case aclAMDIL64: - case aclAMDIL: return GPUOptPhase(data, llvmBin, ctx, error); - } - return NULL; -} - -aclLoaderData* ACL_API_ENTRY -BEInit(aclCompiler *cl, - aclBinary *bin, - aclLogFunction log, - acl_error *err) -{ - if (!bin) return NULL; - switch(bin->target.arch_id) - { - default: - assert(!"Found an unhandled architecture!"); - case aclX64: - case aclX86: return X86AsmInit(cl, bin, log, err); - case aclHSAIL64: - case aclHSAIL: return HSAILAsmInit(cl, bin, log, err); - case aclAMDIL64: - case aclAMDIL: return AMDILInit(cl, bin, log, err); - } - return NULL; -} - -acl_error ACL_API_ENTRY -BEFini(aclLoaderData *ptr) -{ - if (!ptr) return ACL_ERROR; - amdcl::CompilerStage *cs = reinterpret_cast(ptr); - switch (cs->Elf()->target.arch_id) { - default: - assert(!"Found an unhandled architecture!"); - case aclX64: - case aclX86: return X86AsmFini(ptr); - case aclHSAIL64: - case aclHSAIL: return HSAILAsmFini(ptr); - case aclAMDIL64: - case aclAMDIL: return AMDILFini(ptr); - } - return ACL_ERROR; -} - -acl_error ACL_API_ENTRY -BEAsmPhase(aclLoaderData *data, - const char *source, - size_t data_size) -{ - if (!data) return ACL_ERROR; - amdcl::CompilerStage *cs = reinterpret_cast(data); - switch (cs->Elf()->target.arch_id) { - default: - assert(!"Found an unhandled architecture!"); - case aclX64: - case aclX86: return X86AsmPhase(data, source, data_size); - case aclHSAIL64: - case aclHSAIL: return HSAILAsmPhase(data, source, data_size); - case aclAMDIL64: - case aclAMDIL: return AMDILAsmPhase(data, source, data_size); - } - return ACL_ERROR; - -} - - -acl_error ACL_API_ENTRY -BEAssemble(aclLoaderData *data, - const char *source, - size_t data_size) -{ - if (!data) return ACL_ERROR; - amdcl::CompilerStage *cs = reinterpret_cast(data); - switch (cs->Elf()->target.arch_id) { - default: - assert(!"Found an unhandled architecture!"); - case aclX64: - case aclX86: return X86Assemble(data, source, data_size); - case aclHSAIL64: - case aclHSAIL: return HSAILAssemble(data, source, data_size); - case aclAMDIL64: - case aclAMDIL: return AMDILAssemble(data, source, data_size); - } - return ACL_ERROR; - -} - -acl_error ACL_API_ENTRY -BEDisassemble(aclLoaderData *data, - const char *kernel, - const void *isa_code, - size_t data_size) -{ - if (!data) return ACL_ERROR; - amdcl::CompilerStage *cs = reinterpret_cast(data); - switch (cs->Elf()->target.arch_id) { - default: - assert(!"Found an unhandled architecture!"); - case aclX64: - case aclX86: return X86Disassemble(data, kernel, isa_code, data_size); - case aclHSAIL64: - case aclHSAIL: return HSAILDisassemble(data, kernel, isa_code, data_size); - case aclAMDIL64: - case aclAMDIL: return AMDILDisassemble(data, kernel, isa_code, data_size); - } - return ACL_ERROR; - -} - -acl_error -finalizeBinary(aclCompiler *cl, aclBinary *bin) -{ - if (!bin || !bin->bin || !bin->options) return ACL_INVALID_ARG; - if (cl) { - size_t test = 0; - const void* ptr = cl->clAPI.extSym(cl, bin, &test, aclCOMMENT, "acl_version_string", NULL); - if (ptr == NULL || (ptr != NULL && (test != strlen(AMD_COMPILER_INFO) - || strcmp(reinterpret_cast(ptr), "acl_version_string")))) { - if (ptr != NULL) { - cl->clAPI.remSym(cl, bin, aclCOMMENT, "acl_version_string"); - } - cl->clAPI.insSym(cl, bin, - reinterpret_cast(AMD_COMPILER_INFO), - strlen(AMD_COMPILER_INFO), aclCOMMENT, - "acl_version_string"); - } -#ifdef WITH_TARGET_HSAIL - if (isHSAILTarget(bin->target)) { - // Dumping of BIF to file if needed - amd::option::Options* Opts = reinterpret_cast(bin->options); - if (Opts && Opts->isDumpFlagSet(amd::option::DUMP_BIF)) { - std::string fileName = Opts->getDumpFileName(".bif"); - if (aclWriteToFile(bin, fileName.c_str()) != ACL_SUCCESS) - printf("Error - Failure in saving BIF file %s.\n", fileName.c_str()); - } - } -#endif - } - return ACL_SUCCESS; -} - -acl_error ACL_API_ENTRY -HSAILFEToISA( - aclLoaderData *ald, - const char *source, - size_t data_size) -{ - acl_error error_code = HSAILAssemble(ald, source, data_size); - if (error_code != ACL_SUCCESS) - return error_code; - return BEAsmPhase(ald, source, data_size); -} - -static acl_error -aclCompileInternal( - aclCompiler *cl, - aclBinary *bin, - const char *data, - size_t data_size, - aclLogFunction compile_callback, - bool useFE, - bool useLinker, - bool useOpt, - bool useCG, - bool useISA) -{ - llvm::LLVMContext myCtx; - aclContext *context = reinterpret_cast(&myCtx); - aclModule *module = NULL; - std::string dataStr = std::string(data, data_size); - acl_error error_code = ACL_SUCCESS; - aclLoaderData *ald; - - // Load the frontend to convert from Source to LLVM-IR - if (useFE) { - ald = cl->feAPI.init(cl, bin, compile_callback, &error_code); - if (!useLinker && !useCG && !useOpt && !useISA && cl->feAPI.toISA != NULL) { - error_code = cl->feAPI.toISA(ald, data, data_size); - } else { - if (cl->feAPI.toIR == NULL) { - error_code = ACL_SYS_ERROR; - goto internal_compile_failure; - } - module = cl->feAPI.toIR(ald, data, data_size, context, &error_code); - } - cl->feAPI.fini(ald); - if (error_code != ACL_SUCCESS) { - goto internal_compile_failure; - } - } else if (useLinker || useOpt) { - // Load a temp frontend object to convert from string LLVM-IR to LLVM Module. - ald = cl->feAPI.init(cl, bin, compile_callback, &error_code); - module = cl->feAPI.toModule(ald, data, data_size, context, &error_code); - cl->feAPI.fini(ald); - if (error_code != ACL_SUCCESS) { - goto internal_compile_failure; - } - } - - // Use the linker to link in the libraries to the current module. - if (useLinker) { - ald = cl->linkAPI.init(cl, bin, compile_callback, &error_code); - module = cl->linkAPI.link(ald, module, 0, NULL, context, &error_code); - cl->linkAPI.fini(ald); - if (error_code != ACL_SUCCESS) { - goto internal_compile_failure; - } - } - - // Use the optimizer on the module at the given optimization level. - if (useOpt) { - ald = cl->optAPI.init(cl, bin, compile_callback, &error_code); - module = cl->optAPI.optimize(ald, module, context, &error_code); - cl->optAPI.fini(ald); - if (error_code != ACL_SUCCESS) { - goto internal_compile_failure; - } - } - - // Use the code generators to generate the ISA/IL string. - if (useCG) { - ald = cl->cgAPI.init(cl, bin, compile_callback, &error_code); - amdcl::CompilerStage *acs = reinterpret_cast(ald); - if (isHSAILTarget(acs->Elf()->target)) { - amdcl::HSAIL *acl = reinterpret_cast(ald); - bool bHsailTextInput = false; - const char *hsail_text_input = getenv("AMD_DEBUG_HSAIL_TEXT_INPUT"); - // Verify that the internal (blit) kernel is not being compiled - if (hsail_text_input && strcmp(hsail_text_input, "") != 0 && !acl->Options()->oVariables->clInternalKernel) { - bHsailTextInput = true; - } - if (!bHsailTextInput) { - // from ACL_TYPE_HSAIL_BINARY - if (!useFE && !useLinker && !useOpt) { - int result = 0; - HSAIL_ASM::BrigContainer c; - // BRIG is in aclSOURCE section - if (data) { - if (0 != HSAIL_ASM::BrigStreamer::load(c, data, data_size)) { - appendLogToCL(cl, "ERROR: BRIG loading failed."); - error_code = ACL_CODEGEN_ERROR; - goto internal_compile_failure; - } - if (!acl->insertBRIG(c)) { - appendLogToCL(cl, "ERROR: BRIG inserting failed."); - error_code = ACL_CODEGEN_ERROR; - goto internal_compile_failure; - } - // Only check that BRIG is in the binary - } else { - bool containsBRIG = false; - size_t boolSise = sizeof(bool); - error_code = aclQueryInfo(cl, bin, RT_CONTAINS_BRIG, NULL, &containsBRIG, &boolSise); - if (!containsBRIG || error_code != ACL_SUCCESS) { - appendLogToCL(cl, "ERROR: BRIG is absent or incomplete."); - error_code = ACL_CODEGEN_ERROR; - goto internal_compile_failure; - } - } - // from ACL_TYPE_LLVMIR_BINARY - } else { - std::string* cg = (std::string*) cl->cgAPI.codegen(ald, module, context, &error_code); - if (!cg || error_code != ACL_SUCCESS) { - goto internal_compile_failure; - } - if (!acl->insertBRIG(*cg)) { - appendLogToCL(cl, "ERROR: BRIG inserting failed."); - error_code = ACL_CODEGEN_ERROR; - goto internal_compile_failure; - } - } - } - // HSAIL substitution from AMD_DEBUG_HSAIL_TEXT_INPUT - else { - static std::string sHsailFileNames; - if (sHsailFileNames.empty()) - sHsailFileNames = hsail_text_input; - std::string sCurHsailFileName; - size_t iFind = sHsailFileNames.find_first_not_of(";"); - if (iFind == std::string::npos) { - sCurHsailFileName = sHsailFileNames; - sHsailFileNames.clear(); - } - else { - size_t iFindEnd = sHsailFileNames.find_first_of(";", iFind+1); - size_t iCount = sHsailFileNames.size(); - if (iFindEnd == std::string::npos) { - sCurHsailFileName = sHsailFileNames.substr(iFind, iCount-iFind); - sHsailFileNames.clear(); - } - else { - sCurHsailFileName = sHsailFileNames.substr(iFind, iFindEnd-iFind); - sHsailFileNames = sHsailFileNames.substr(iFindEnd+1, iCount-iFindEnd-1); - } - } - size_t size = 0; - char * str = readFile(sCurHsailFileName.c_str(), size); - dataStr = (str == NULL) ? "" : str; - if (size == 0 || dataStr.length() == 0) { - appendLogToCL(cl, "ERROR: AMD_DEBUG_HSAIL_TEXT_INPUT file does not exist."); - error_code = ACL_CODEGEN_ERROR; - goto internal_compile_failure; - } - if (!acl->insertHSAIL(dataStr)) { - appendLogToCL(cl, "ERROR: HSAIL inserting failed."); - error_code = ACL_CODEGEN_ERROR; - goto internal_compile_failure; - } - // Use the assembler to generate the binary format of the IL string. - if (HSAILAssemble(ald, dataStr.c_str(), dataStr.length()) != ACL_SUCCESS) { - appendLogToCL(cl, "ERROR: HSAIL assembling failed."); - error_code = ACL_CODEGEN_ERROR; - goto internal_compile_failure; - } - } - char* dumpFileName = ::getenv("AMD_DEBUG_DUMP_HSAIL_ALL_KERNELS"); - if (acl->Options()->isDumpFlagSet(amd::option::DUMP_CGIL) || dumpFileName) { - acl->dumpHSAIL(acl->disassembleBRIG(), ".hsail"); - } - bifbase *elfBin = reinterpret_cast(bin->bin); - elfBin->setType(ET_EXEC); - } else if(isCpuTarget(acs->Elf()->target)) { - std::string* cg = (std::string*) cl->cgAPI.codegen(ald, module, context, &error_code); - if (!cg || error_code != ACL_SUCCESS) { - goto internal_compile_failure; - } - dataStr = *cg; - } else { - assert("Unsupported architecture."); - } - if (!checkFlag(aclutGetCaps(bin), capSaveLLVMIR) || !acs->Options()->oVariables->BinLLVMIR) { - cl->clAPI.remSec(cl, bin, aclLLVMIR); - } - cl->cgAPI.fini(ald); - if (error_code != ACL_SUCCESS) { - goto internal_compile_failure; - } - } - - if (useISA) { - ald = cl->beAPI.init(cl, bin, compile_callback, &error_code); - error_code = cl->beAPI.finalize(ald, dataStr.data(), dataStr.length()); - if (isHSAILTarget(bin->target) && error_code == ACL_SUCCESS) { - amdcl::HSAIL *acl = reinterpret_cast(cl->cgAPI.init(cl, bin, compile_callback, &error_code)); - acl->deleteBRIG(); - cl->cgAPI.fini(reinterpret_cast(acl)); - } - cl->beAPI.fini(ald); - if (error_code != ACL_SUCCESS) { - goto internal_compile_failure; - } - } - -internal_compile_failure: - if (module) { - delete reinterpret_cast(module); - } - return error_code; -} -#define CONDITIONAL_ASSIGN(A, B) A = (A) ? (A) : (B) - -#define CONDITIONAL_CMP_ASSIGN(A, B, C) A = (A && B != A) ? (A) : (C) - -acl_error -IsValidCompilationOptions(aclCompiler *cl, aclBinary *bin, aclLogFunction compile_callback) -{ - acl_error error_code = ACL_SUCCESS; -#if defined(WITH_TARGET_HSAIL) - amd::option::Options* opts = reinterpret_cast(bin->options); - std::string error_msg; - if (isHSAILTarget(bin->target)) { - if (getFamilyEnum(&bin->target) == FAMILY_SI) { - std::string device = std::string(getDeviceName(bin->target)); - error_msg = "Error: HSAIL doesn't support device " + device + "."; - error_code = ACL_INVALID_TARGET; - } - if (opts->oVariables->Legacy) { - if (error_msg.empty()) { - error_code = ACL_INVALID_OPTION; - } - else { - error_msg += "\n"; - } - error_msg += "Error: AMDIL wasn't forced by -legacy option due to the following conflicting HSAIL only option(s):"; - if (opts->oVariables->Frontend) { - std::string frontend = std::string(opts->oVariables->Frontend); - if (frontend == "clang") { - error_msg += " -frontend=clang"; - } - } - if (opts->oVariables->CLStd) { - std::string sCL = std::string(opts->oVariables->CLStd); - std::string major = sCL.substr(2, 1); - if (std::stoul(major) >= 2) { - error_msg += " -cl-std=" + sCL; - } - } - if (opts->oVariables->BinaryIsSpirv) { - error_msg += " -binary_is_spirv"; - } - } - if (opts->oVariables->XLang) { - std::string ext = std::string(opts->oVariables->XLang); - if (ext == "clc++" || ext == "spir") { - if (error_msg.empty()) { - error_code = ACL_INVALID_OPTION; - } else { - error_msg += "\n"; - } - error_msg += "Error: HSAIL doesn't support OpenCL extension " + ext + "."; - } - } - } - if (ACL_SUCCESS != error_code) { - if (compile_callback) { - compile_callback(error_msg.c_str(), error_msg.size()); - } - if (cl != NULL) { - appendLogToCL(cl, error_msg.c_str()); - } - } -#endif - return error_code; -} - -acl_error ACL_API_ENTRY -if_aclCompile(aclCompiler *cl, - aclBinary *bin, - const char *options, - aclType from, - aclType to, - aclLogFunction compile_callback) -{ - if (!bin || !cl) { - return ACL_INVALID_ARG; - } - if (((from == ACL_TYPE_X86_TEXT || from == ACL_TYPE_X86_BINARY) && !isCpuTarget(bin->target)) || - ((from == ACL_TYPE_AMDIL_TEXT || from == ACL_TYPE_AMDIL_BINARY) && !isAMDILTarget(bin->target)) || - ((from == ACL_TYPE_HSAIL_TEXT || from == ACL_TYPE_HSAIL_BINARY) && !isHSAILTarget(bin->target))) { - return ACL_INVALID_BINARY; - } - acl_error error_code = IsValidCompilationOptions(cl, bin, compile_callback); - if (error_code != ACL_SUCCESS) { - return error_code; - } -#ifdef WITH_TARGET_HSAIL - if (isHSAILTarget(bin->target)) { - if (from == ACL_TYPE_SPIR_TEXT || from == ACL_TYPE_SPIR_BINARY) { - std::string error_msg = "Error: HSAIL doesn't support OpenCL extension spir."; - if (compile_callback) { - compile_callback(error_msg.c_str(), error_msg.size()); - } - appendLogToCL(cl, error_msg.c_str()); - return ACL_INVALID_BINARY; - } - } else -#endif - { - llvm::InitializeAllAsmParsers(); - llvm::PassRegistry &Registry = *llvm::PassRegistry::getPassRegistry(); - llvm::initializeSPIRVerifierPass(Registry); - } - amd::option::Options* Opts = reinterpret_cast(bin->options); - // Default 'to' is ACL_TYPE_ISA - if (to == ACL_TYPE_DEFAULT) { - to = ACL_TYPE_ISA; - } - if ((from == ACL_TYPE_HSAIL_TEXT && (to == ACL_TYPE_HSAIL_BINARY || - to == ACL_TYPE_CG || - to == ACL_TYPE_ISA)) || - (from == ACL_TYPE_HSAIL_BINARY && to == ACL_TYPE_HSAIL_TEXT) || - (from == ACL_TYPE_AMDIL_TEXT && to == ACL_TYPE_AMDIL_BINARY) || - (from == ACL_TYPE_AMDIL_BINARY && to == ACL_TYPE_AMDIL_TEXT) || - (from == ACL_TYPE_SPIR_TEXT && to == ACL_TYPE_SPIR_BINARY) || - (from == ACL_TYPE_SPIR_BINARY && to == ACL_TYPE_SPIR_TEXT) || - (from == ACL_TYPE_LLVMIR_TEXT && to == ACL_TYPE_LLVMIR_BINARY)|| - (from == ACL_TYPE_LLVMIR_BINARY && to == ACL_TYPE_LLVMIR_TEXT) || - (from == ACL_TYPE_X86_TEXT && to == ACL_TYPE_X86_BINARY) || - (from == ACL_TYPE_X86_BINARY && to == ACL_TYPE_X86_TEXT)) { - const char *kernel = Opts->oVariables->Kernel; - error_code = aclConvertType(cl, bin, kernel, from); - // if compilation to ACL_TYPE_ISA, then continue from ACL_TYPE_CG - if (to == ACL_TYPE_ISA && error_code == ACL_SUCCESS) { - from = ACL_TYPE_CG; - } else { - return error_code; - } - } - if (((from == ACL_TYPE_AMDIL_TEXT || from == ACL_TYPE_AMDIL_BINARY || - from == ACL_TYPE_X86_TEXT || from == ACL_TYPE_X86_BINARY || - from == ACL_TYPE_HSAIL_TEXT) && to != ACL_TYPE_ISA) || - (from == ACL_TYPE_HSAIL_BINARY && to != ACL_TYPE_ISA && to != ACL_TYPE_CG)) { - return ACL_INVALID_ARG; - } - if (to == ACL_TYPE_SPIRV_BINARY) { - if (from == ACL_TYPE_OPENCL) { - to = ACL_TYPE_LLVMIR_BINARY; - Opts->oVariables->FEGenSPIRV = true; - } else { - return ACL_INVALID_ARG; - } - } - uint8_t sectable[ACL_TYPE_LAST] = {0, 0, 1, 1, 1, 1, 0, 6, 0, 3, 4, 4, 4, 0, - 5, 0, 1, 1}; - aclSections d_section[7] = {aclSOURCE, aclLLVMIR, aclSPIR, aclSOURCE, - aclCODEGEN, aclTEXT, aclINTERNAL}; - uint8_t start = sectable[from]; - uint8_t stop = sectable[to]; - const void* data = NULL; - size_t data_size = 0; - switch (from) { - default: - data = cl->clAPI.extSec(cl, bin, &data_size, d_section[start], &error_code); - break; - case ACL_TYPE_DEFAULT: { - aclSections sections[] = {aclSOURCE, aclSPIR, aclLLVMIR, aclCODEGEN, aclTEXT}; - uint8_t table[] = {0, 1, 1, 4, 5}; - aclType type[] = {ACL_TYPE_SOURCE, ACL_TYPE_SPIR_BINARY, ACL_TYPE_LLVMIR_BINARY, ACL_TYPE_CG, ACL_TYPE_ISA}; - for (int y = 0, x = sizeof(sections) / sizeof(sections[0]) - 1; x >= y; --x) { - data = (const char*)cl->clAPI.extSec(cl, bin, &data_size, sections[x], &error_code); - if (data && data_size > 0 && error_code == ACL_SUCCESS) { - start = table[x]; - from = type[x]; - break; - } - } - break; - } - case ACL_TYPE_SPIRV_BINARY: - data = cl->clAPI.extSec(cl, bin, &data_size, aclSPIRV, &error_code); - break; - case ACL_TYPE_SPIR_BINARY: - case ACL_TYPE_SPIR_TEXT: - data = cl->clAPI.extSec(cl, bin, &data_size, aclSPIR, &error_code); - break; - case ACL_TYPE_RSLLVMIR_BINARY: - data = cl->clAPI.extSec(cl, bin, &data_size, aclLLVMIR, &error_code); - break; - case ACL_TYPE_HSAIL_BINARY: - data = cl->clAPI.extSec(cl, bin, &data_size, aclSOURCE, &error_code); - // if for ACL_TYPE_HSAIL_BINARY stage BRIG (data) is not presented in aclSOURCE (.source) section of BIF, - // then it should be in multiple corresponding .brig_ sections in BIF, so continue to compile (data might be NULL) - if (error_code == ACL_ELF_ERROR) { - error_code = ACL_SUCCESS; - } - break; - case ACL_TYPE_CG: - // there is no data for codegen phase (data might be NULL), - // BRIG should be in its multiple corresponding .brig_ sections in BIF - if (isHSAILTarget(bin->target)) { - from = ACL_TYPE_CG; - } else { - data = cl->clAPI.extSec(cl, bin, &data_size, d_section[start], &error_code); - } - break; - } - if (error_code != ACL_SUCCESS) { - return error_code; - } - // Based on our compiler options, we need to change the functors to use - // the correct pointers unless they are custom loaded, then we should - // not modify them. This code is ugly and needs to be designed better. - if (start == 0) { - if (from == ACL_TYPE_OPENCL || from == ACL_TYPE_SOURCE || from == ACL_TYPE_DEFAULT) { - const oclBIFSymbolStruct* sym = findBIF30SymStruct(symOpenclCompilerOptions); - assert(sym && "symbol not found"); - assert(sym->sections[0] == aclCOMMENT && sym->sections[0] == sym->sections[1] && - "not in comment section"); - std::string optSec = std::string(sym->str[PRE]) + std::string(sym->str[POST]); - saveOptionsToComments(cl, bin, options, optSec); - CONDITIONAL_CMP_ASSIGN(cl->feAPI.init, &SPIRInit, &OCLInit); - CONDITIONAL_CMP_ASSIGN(cl->feAPI.init, &AMDILInit, &OCLInit); - CONDITIONAL_CMP_ASSIGN(cl->feAPI.init, &HSAILFEInit, &OCLInit); - CONDITIONAL_CMP_ASSIGN(cl->feAPI.fini, &SPIRFini, &OCLFini); - CONDITIONAL_CMP_ASSIGN(cl->feAPI.fini, &AMDILFini, &OCLFini); - CONDITIONAL_CMP_ASSIGN(cl->feAPI.fini, &HSAILFEFini, &OCLFini); - CONDITIONAL_CMP_ASSIGN(cl->feAPI.toISA, &AMDILFEToISA, NULL); - CONDITIONAL_CMP_ASSIGN(cl->feAPI.toISA, &HSAILFEToISA, NULL); - if (to == ACL_TYPE_LLVMIR_BINARY || to == ACL_TYPE_LLVMIR_TEXT) { - cl->feAPI.toISA = NULL; - cl->feAPI.toIR = &OCLFEToLLVMIR; - } else if(to == ACL_TYPE_SPIR_BINARY || to == ACL_TYPE_SPIR_TEXT) { - cl->feAPI.toISA = NULL; - cl->feAPI.toIR = &OCLFEToSPIR; - } - } else if (from == ACL_TYPE_AMDIL_TEXT || from == ACL_TYPE_HSAIL_TEXT) { - const oclBIFSymbolStruct* sym = findBIF30SymStruct(symAMDILCompilerOptions); - assert(sym && "symbol not found"); - assert(sym->sections[0] == aclCOMMENT && "not in comment section"); - amd::option::Options* Opts = reinterpret_cast(bin->options); - const char *kernel = Opts->oVariables->Kernel; - std::string optSec = std::string(sym->str[PRE]) + - std::string((!kernel) ? "main" : kernel) + - std::string(sym->str[POST]); - saveOptionsToComments(cl, bin, options, optSec); - if (to == ACL_TYPE_ISA || to == ACL_TYPE_DEFAULT) { - stop = 1; - if (from == ACL_TYPE_AMDIL_TEXT) { - cl->feAPI.init = &AMDILInit; - cl->feAPI.fini = &AMDILFini; - cl->feAPI.toISA = &AMDILFEToISA; - } else { - CONDITIONAL_CMP_ASSIGN(cl->feAPI.init, &OCLInit, &HSAILFEInit); - CONDITIONAL_CMP_ASSIGN(cl->feAPI.fini, &OCLFini, &HSAILFEFini); - CONDITIONAL_CMP_ASSIGN(cl->feAPI.toISA, &OCLFEToISA, &HSAILFEToISA); - } - cl->feAPI.toIR = NULL; - cl->feAPI.toModule = NULL; - } else { - return ACL_UNSUPPORTED; - } - } - } else if (start == 1) { - if ((from == ACL_TYPE_SPIR_BINARY || from == ACL_TYPE_SPIR_TEXT) && - (to == ACL_TYPE_LLVMIR_BINARY || to == ACL_TYPE_LLVMIR_TEXT)) { - CONDITIONAL_CMP_ASSIGN(cl->feAPI.init, &OCLInit, &SPIRInit); - CONDITIONAL_CMP_ASSIGN(cl->feAPI.init, &AMDILInit, &SPIRInit); - CONDITIONAL_CMP_ASSIGN(cl->feAPI.init, &HSAILFEInit, &SPIRInit); - CONDITIONAL_CMP_ASSIGN(cl->feAPI.fini, &OCLFini, &SPIRFini); - CONDITIONAL_CMP_ASSIGN(cl->feAPI.fini, &AMDILFini, &SPIRFini); - CONDITIONAL_CMP_ASSIGN(cl->feAPI.fini, &HSAILFEFini, &SPIRFini); - CONDITIONAL_CMP_ASSIGN(cl->feAPI.toModule, &OCLFEToModule, &SPIRToModule); - } else if (from == ACL_TYPE_LLVMIR_BINARY || from == ACL_TYPE_LLVMIR_TEXT || - from == ACL_TYPE_SPIR_BINARY || from == ACL_TYPE_SPIR_TEXT || - from == ACL_TYPE_RSLLVMIR_BINARY || from == ACL_TYPE_SPIRV_BINARY) { - CONDITIONAL_CMP_ASSIGN(cl->feAPI.init, &SPIRInit, &OCLInit); - CONDITIONAL_CMP_ASSIGN(cl->feAPI.init, &AMDILInit, &OCLInit); - CONDITIONAL_CMP_ASSIGN(cl->feAPI.init, &HSAILFEInit, &OCLInit); - CONDITIONAL_CMP_ASSIGN(cl->feAPI.fini, &SPIRFini, &OCLFini); - CONDITIONAL_CMP_ASSIGN(cl->feAPI.fini, &AMDILFini, &OCLFini); - CONDITIONAL_CMP_ASSIGN(cl->feAPI.fini, &HSAILFEFini, &OCLFini); - if (from == ACL_TYPE_SPIRV_BINARY) { - if (to != ACL_TYPE_LLVMIR_BINARY) - cl->feAPI.toModule = &SPIRVToModule; - else { - cl->feAPI.toISA = NULL; - cl->feAPI.toIR = &SPIRVToModule; - start = 0; - stop = 1; - } - } else if (from == ACL_TYPE_RSLLVMIR_BINARY) { - cl->feAPI.toModule = &RSLLVMIRToModule; - } else { - cl->feAPI.toModule = &OCLFEToModule; - } - } - } - if (start > stop) { - return ACL_INVALID_ARG; - } - if (start == stop) { - return ACL_SUCCESS; - } - bool stages[5] = {false}; - for (uint8_t x = start; x < stop; ++x) { - stages[x] = true; - } - error_code = aclCompileInternal(cl, bin, - reinterpret_cast(data), - data_size, compile_callback, - stages[0], stages[1], stages[2], stages[3], stages[4]); - if (error_code == ACL_SUCCESS) { - return finalizeBinary(cl, bin); - } - return error_code; -} -#undef CONDITIONAL_ASSIGN -#undef CONDITIONAL_CMP_ASSIGN - -acl_error ACL_API_ENTRY -if_aclLink(aclCompiler *cl, - aclBinary *src_bin, - unsigned int num_libs, - aclBinary **libs, - aclType link_mode, - const char *options, - aclLogFunction link_callback) -{ - aclLoaderData *ald; - size_t data_size = 0; - aclModule *module = NULL, *dst_module = NULL; - llvm::LLVMContext myCtx; - aclContext *context = reinterpret_cast(&myCtx); - - acl_error error_code = ACL_SUCCESS; - aclModule **mod_libs = NULL; - if (num_libs > 0) { - mod_libs = new aclModule*[num_libs]; - memset(mod_libs, 0, num_libs * sizeof(*mod_libs)); - } - - switch(link_mode) { - default: error_code = ACL_UNSUPPORTED; break; - case ACL_TYPE_LLVMIR_BINARY: - case ACL_TYPE_RSLLVMIR_BINARY: - { - ald = cl->feAPI.init(cl, src_bin, link_callback, &error_code); - const void *ptr = cl->clAPI.extSec(cl, src_bin, &data_size, aclLLVMIR, &error_code); - if (ptr == NULL) - ptr = cl->clAPI.extSec(cl, src_bin, &data_size, aclSPIR, &error_code); - if (ptr == NULL) { - error_code = ACL_INVALID_FILE; - goto internal_link_failure; - } - char *mod = new char[data_size]; - memcpy(mod, ptr, data_size); - module = cl->feAPI.toModule(ald, mod, data_size, context, &error_code); - for (unsigned x = 0; x < num_libs; ++x) { - const void *ptr = cl->clAPI.extSec(cl, libs[x], &data_size, aclLLVMIR, NULL); - if (ptr == NULL) - ptr = cl->clAPI.extSec(cl, libs[x], &data_size, aclSPIR, NULL); - if (ptr == NULL) { - error_code = ACL_INVALID_FILE; - goto internal_link_failure; - } - mod = new char[data_size]; - memcpy(mod, ptr, data_size); - mod_libs[x] = cl->feAPI.toModule(ald, mod, data_size, context, &error_code); - } - cl->feAPI.fini(ald); - } - break; - } - if (error_code != ACL_SUCCESS) { - goto internal_link_failure; - } - ald = cl->linkAPI.init(cl, src_bin, link_callback, &error_code); - dst_module = cl->linkAPI.link(ald, module, num_libs, mod_libs, - context, &error_code); - cl->linkAPI.fini(ald); - if (error_code == ACL_SUCCESS) { - switch (link_mode) { - default: error_code = ACL_UNSUPPORTED; break; - case ACL_TYPE_LLVMIR_BINARY: - case ACL_TYPE_RSLLVMIR_BINARY: - { - llvm::SmallVector array; - llvm::raw_svector_ostream outstream(array); - llvm::WriteBitcodeToFile(reinterpret_cast(dst_module), outstream); - cl->clAPI.remSec(cl, src_bin, aclLLVMIR); - error_code = cl->clAPI.insSec(cl, src_bin, - &array[0], array.size(), aclLLVMIR); - if (dst_module != NULL && dst_module != module) { - delete reinterpret_cast(dst_module); - } - } - bifbase *elfBin = reinterpret_cast(src_bin->bin); - elfBin->setType(ET_DYN); - break; - } - return finalizeBinary(cl, src_bin); - } -internal_link_failure: - const char *error = aclGetErrorString(error_code); - appendLogToCL(cl, error); - if (link_callback) { - link_callback(cl->buildLog, cl->logSize); - } - if (!error && module) { - delete reinterpret_cast(module); - } - if (mod_libs) { - for (unsigned x = 0; x < num_libs; ++x) { - if (!error && mod_libs[x]) { - delete reinterpret_cast(mod_libs[x]); - } - } - delete [] mod_libs; - } - return error_code; -} - -const char* ACL_API_ENTRY -if_aclGetCompilerLog(aclCompiler *cl) -{ - return (cl->buildLog == 0) ? "" : cl->buildLog; -} - -static std::string getSymbolName(aclType type, const char *name, aclSections &id) -{ - const oclBIFSymbolStruct* symbol = NULL; - uint8_t targetType = 0; - std::string tmpname(name); - std::string prefix = ""; - std::string postfix = ""; - switch (type) { - default: - assert(!"Invalid type detected!"); - return tmpname; - case ACL_TYPE_AMDIL_TEXT: - symbol = findBIF30SymStruct(symAMDILText); - assert(symbol && "symbol not found"); - break; - case ACL_TYPE_HSAIL_TEXT: - symbol = findBIF30SymStruct(symHSAILText); - assert(symbol && "symbol not found"); - break; - case ACL_TYPE_LLVMIR_TEXT: - id = aclLLVMIR; - break; - case ACL_TYPE_SPIR_TEXT: - id = aclSPIR; - break; - case ACL_TYPE_X86_TEXT: - id = aclCODEGEN; - break; - case ACL_TYPE_AMDIL_BINARY: - symbol = findBIF30SymStruct(symAMDILBinary); - assert(symbol && "symbol not found"); - break; - case ACL_TYPE_HSAIL_BINARY: - symbol = findBIF30SymStruct(symBRIG); - assert(symbol && "symbol not found"); - break; - case ACL_TYPE_LLVMIR_BINARY: - id = aclLLVMIR; - break; - case ACL_TYPE_RSLLVMIR_BINARY: - id = aclLLVMIR; - break; - case ACL_TYPE_SPIR_BINARY: - id = aclSPIR; - break; - case ACL_TYPE_X86_BINARY: - id = aclCODEGEN; - break; - }; - if (symbol) { - prefix = symbol->str[PRE]; - postfix = symbol->str[POST]; - id = symbol->sections[0]; - } - return prefix + tmpname + postfix; -} - -const void* ACL_API_ENTRY -if_aclRetrieveType(aclCompiler *cl, - const aclBinary *bin, - const char *name, - size_t *data_size, - aclType type, - acl_error *error_code) -{ - aclSections sec_id; - std::string symbol_name = getSymbolName(type, name, sec_id); - return cl->clAPI.extSym(cl, bin, data_size, sec_id, symbol_name.c_str(), error_code); -} - -acl_error ACL_API_ENTRY -if_aclSetType(aclCompiler *cl, - aclBinary *bin, - const char *name, - aclType type, - const void *data, - size_t size) -{ - aclSections sec_id; - std::string symbol_name = getSymbolName(type, name, sec_id); - return cl->clAPI.insSym(cl, bin, data, size, sec_id, symbol_name.c_str()); -} - -acl_error ACL_API_ENTRY -if_aclConvertType(aclCompiler *cl, - aclBinary *bin, - const char *name, - aclType type) -{ - acl_error error_code = ACL_SUCCESS; - aclType to; - aclSections sec = aclSOURCE; - bool need_name = true; - size_t from_data_size = 0; - const void *from_data = NULL; - switch (type) { - default: - return ACL_UNSUPPORTED; - case ACL_TYPE_LLVMIR_TEXT: - to = ACL_TYPE_LLVMIR_BINARY; - need_name = false; - sec = aclLLVMIR; - break; - case ACL_TYPE_LLVMIR_BINARY: - to = ACL_TYPE_LLVMIR_TEXT; - need_name = false; - sec = aclLLVMIR; - break; - case ACL_TYPE_SPIR_TEXT: - to = ACL_TYPE_SPIR_BINARY; - need_name = false; - sec = aclSPIR; - break; - case ACL_TYPE_SPIR_BINARY: - to = ACL_TYPE_SPIR_TEXT; - need_name = false; - sec = aclSPIR; - break; - case ACL_TYPE_AMDIL_TEXT: - { - to = ACL_TYPE_AMDIL_BINARY; - // extract from symbol __debugil_text in .internal section - const oclBIFSymbolStruct* symbol = findBIF30SymStruct(symDebugilText); - assert(symbol && "symbol not found"); - std::string debugilSym - = std::string(symbol->str[PRE] + std::string(symbol->str[POST])); - from_data = cl->clAPI.extSym(cl, bin, &from_data_size, - symbol->sections[0], - debugilSym.c_str(), &error_code); - break; - } - case ACL_TYPE_AMDIL_BINARY: - { - to = ACL_TYPE_AMDIL_TEXT; - // extract from symbol __debugil_binary in .internal section - const oclBIFSymbolStruct* symbol = findBIF30SymStruct(symDebugilBinary); - assert(symbol && "symbol not found"); - std::string debugilSym - = std::string(symbol->str[PRE] + std::string(symbol->str[POST])); - from_data = cl->clAPI.extSym(cl, bin, &from_data_size, - symbol->sections[0], - debugilSym.c_str(), &error_code); - break; - } - case ACL_TYPE_HSAIL_TEXT: - { - to = ACL_TYPE_HSAIL_BINARY; - const oclBIFSymbolStruct* symbol = findBIF30SymStruct(symHSAILText); - assert(symbol && "symbol not found"); - std::string symbolName = symbol->str[PRE] + std::string("main") + symbol->str[POST]; - from_data = cl->clAPI.extSym(cl, bin, &from_data_size, - symbol->sections[0], - symbolName.c_str(), &error_code); - // HSAIL was inserted into bif as section only without corresponding symbol - if (!from_data) { - from_data = cl->clAPI.extSec(cl, bin, &from_data_size, - symbol->sections[0], &error_code); - } - // HSAIL is in aclSOURCE section (might be used while compiling from HSAIL by -hsail option) - if (!from_data) { - from_data = cl->clAPI.extSec(cl, bin, &from_data_size, aclSOURCE, &error_code); - } - break; - } - case ACL_TYPE_HSAIL_BINARY: - { -#if defined(WITH_TARGET_HSAIL) - // BRIG to HSAIL disassembling - if (isHSAILTarget(bin->target)) { - amdcl::HSAIL *acl = new amdcl::HSAIL(cl, bin, NULL); - if (acl == NULL) { - return ACL_OUT_OF_MEM; - } - std::string hsail = acl->disassembleBRIG(); - // If HSAIL was not disassembled from multiple .brig_ sections in BIF, then: - // 1. try to extract BRIG from aclSOURCE section - if (hsail.empty()) { - from_data = cl->clAPI.extSec(cl, bin, &from_data_size, aclSOURCE, &error_code); - HSAIL_ASM::BrigContainer c; - // 2. load BRIG in BrigContainer - int result = HSAIL_ASM::BrigStreamer::load(c, - reinterpret_cast(from_data), from_data_size); - if (result != 0) { - error_code = ACL_INVALID_BINARY; - delete acl; - return error_code; - } - // 3. insert BRIG into multiple .brig_ sections in BIF + - // insert matadata symbols for every kernel - if (!acl->insertBRIG(c)) { - assert(!"Inserting BRIG failed\n"); - error_code = ACL_INVALID_BINARY; - delete acl; - return error_code; - } - // 4. second attempt to disassemble BRIG - hsail = acl->disassembleBRIG(); - } - delete acl; - if (hsail.empty()) { - return ACL_ELF_ERROR; - } - const oclBIFSymbolStruct* symbol = findBIF30SymStruct(symHSAILText); - assert(symbol && "symbol not found"); - std::string symbolName = symbol->str[PRE] + std::string("main") + - symbol->str[POST]; - return cl->clAPI.insSym(cl, bin, hsail.data(), hsail.size(), - symbol->sections[0], symbolName.c_str()); - } else { - assert(!"Unsupported architecture, expect hsail."); - return ACL_SYS_ERROR; - } -#else - assert(!"Cannot go down this path without HSAIL support!"); - return ACL_SYS_ERROR; -#endif - break; - } - case ACL_TYPE_X86_TEXT: - to = ACL_TYPE_X86_BINARY; - break; - case ACL_TYPE_X86_BINARY: - to = ACL_TYPE_X86_TEXT; - break; - } - if (from_data == NULL) { - if (name == NULL || !need_name) { - if (need_name) { - return ACL_INVALID_ARG; - } - from_data = cl->clAPI.extSec(cl, bin, - &from_data_size, sec, &error_code); - } else { - from_data = cl->clAPI.retrieveType(cl, bin, name, - &from_data_size, type, &error_code); - } - } - if (error_code != ACL_SUCCESS) { - return error_code; - } - const void *to_data = from_data; - size_t to_data_size = from_data_size; - switch (to) { - default: - return ACL_UNSUPPORTED; - case ACL_TYPE_SPIR_TEXT: - { - amdcl::SPIR *spir = new amdcl::SPIR(cl, bin, NULL); - llvm::LLVMContext myCtx; - aclContext *context = reinterpret_cast(&myCtx); - spir->setContext(context); - if (spir == NULL) { - return ACL_OUT_OF_MEM; - } - to_data = spir->toText(from_data, from_data_size, &to_data_size); - if (!spir->BuildLog().empty()) { - appendLogToCL(cl, spir->BuildLog()); - } - if (to_data == NULL) { - return ACL_INVALID_SPIR; - } - delete spir; - } - break; - case ACL_TYPE_SPIR_BINARY: - { - amdcl::SPIR *spir = new amdcl::SPIR(cl, bin, NULL); - llvm::LLVMContext myCtx; - aclContext *context = reinterpret_cast(&myCtx); - spir->setContext(context); - if (spir == NULL) { - return ACL_OUT_OF_MEM; - } - to_data = spir->toBinary(from_data, from_data_size, &to_data_size); - if (!spir->BuildLog().empty()) { - appendLogToCL(cl, spir->BuildLog()); - } - if (to_data == NULL) { - return ACL_INVALID_SPIR; - } - delete spir; - } - break; - case ACL_TYPE_AMDIL_TEXT: - { -#if defined(WITH_TARGET_AMDIL) - if (isAMDILTarget(bin->target)) { - amdcl::AMDIL *acl = new amdcl::AMDIL(cl, bin, NULL); - if (acl == NULL) { - return ACL_OUT_OF_MEM; - } - to_data = acl->toText(from_data, from_data_size); - to_data_size = strlen(reinterpret_cast(to_data)); - delete acl; - // insert into .internal section under symbol __debugil_text - const oclBIFSymbolStruct* symbol = findBIF30SymStruct(symDebugilText); - assert(symbol && "symbol not found"); - std::string debugilSym - = std::string(symbol->str[PRE] + std::string(symbol->str[POST])); - return cl->clAPI.insSym(cl, bin, to_data, to_data_size, - symbol->sections[0], debugilSym.c_str()); - } else { - assert(!"Unsupported architecture, expect amdil."); - return ACL_SYS_ERROR; - } -#else - assert(!"Cannot go down this path without AMDIL support!"); - return ACL_SYS_ERROR; -#endif - } - break; - case ACL_TYPE_AMDIL_BINARY: - { -#if defined(WITH_TARGET_AMDIL) - if (isAMDILTarget(bin->target)) { - amdcl::AMDIL *acl = new amdcl::AMDIL(cl, bin, NULL); - if (acl == NULL) { - return ACL_OUT_OF_MEM; - } - to_data = acl->toBinary(reinterpret_cast(from_data), - &to_data_size); - delete acl; - // insert into .internal section under symbol __debugil_binary - const oclBIFSymbolStruct* symbol = findBIF30SymStruct(symDebugilBinary); - assert(symbol && "symbol not found"); - std::string debugilSym - = std::string(symbol->str[PRE] + std::string(symbol->str[POST])); - return cl->clAPI.insSym(cl, bin, to_data, to_data_size, - symbol->sections[0], debugilSym.c_str()); - } else { - assert(!"Unsupported architecture, expect amdil."); - return ACL_SYS_ERROR; - } -#else - assert(!"Cannot go down this path without AMDIL support!"); - return ACL_SYS_ERROR; -#endif - } - break; - case ACL_TYPE_HSAIL_BINARY: - { -#if defined(WITH_TARGET_HSAIL) - if (isHSAILTarget(bin->target)) { - amdcl::HSAIL *acl = new amdcl::HSAIL(cl, bin, NULL); - if (acl == NULL) { - return ACL_OUT_OF_MEM; - } - // while assembling BRIG insertion into BIF (bin) performs, - // so no need in any symbol/section insertion here - bool bRet = acl->assemble(std::string(reinterpret_cast(from_data))); - delete acl; - if (!bRet) { - return ACL_CODEGEN_ERROR; - } - return ACL_SUCCESS; - } else { - assert(!"Unsupported architecture, expect hsail."); - return ACL_SYS_ERROR; - } -#else - assert(!"Cannot go down this path without HSAIL support!"); - return ACL_SYS_ERROR; -#endif - } - break; - } - - if (name == NULL || !need_name) { - return cl->clAPI.insSec(cl, bin, to_data, to_data_size, sec); - } else { - return cl->clAPI.setType(cl, bin, name, to, to_data, to_data_size); - } -} - -acl_error ACL_API_ENTRY -if_aclDisassemble(aclCompiler *cl, - aclBinary *bin, - const char *kernel, - aclLogFunction disasm_callback) -{ - acl_error error_code = ACL_SUCCESS; - size_t size = 0; - const void *code = NULL; - aclLoaderData *data = cl->beAPI.init(cl, bin, disasm_callback, &error_code); - if (error_code != ACL_SUCCESS) { - goto internal_disasm_failure; - } - code = cl->clAPI.devBinary(cl, bin, kernel, &size, &error_code); - if (error_code != ACL_SUCCESS) { - goto internal_disasm_failure; - } - error_code = cl->beAPI.disassemble(data, kernel, code, size); - if (error_code != ACL_SUCCESS) { - goto internal_disasm_failure; - } -#ifdef WITH_TARGET_HSAIL - { - amdcl::CompilerStage *cs = reinterpret_cast(data); - if (isHSAILTarget(cs->Elf()->target)) { - amdcl::HSAIL *hsail_be = reinterpret_cast(data); - if (!hsail_be) { - goto internal_disasm_failure; - } - hsail_be->disassembleBRIG(); - } - } -#endif - error_code = cl->beAPI.fini(data); - if (error_code != ACL_SUCCESS) { - goto internal_disasm_failure; - } - return error_code; -internal_disasm_failure: - const char *error = aclGetErrorString(error_code); - appendLogToCL(cl, error); - if (disasm_callback) { - disasm_callback(cl->buildLog, cl->logSize); - } - return error_code; -} - -const void* ACL_API_ENTRY -if_aclGetDeviceBinary(aclCompiler *cl, - const aclBinary *bin, - const char *kernel, - size_t *size, - acl_error *error_code) -{ -#ifdef WITH_TARGET_HSAIL - if (isHSAILTarget(bin->target)) { - return cl->clAPI.extSec(cl, bin, size, aclTEXT, error_code); - } else -#endif - { - const oclBIFSymbolStruct* sym = findBIF30SymStruct(symISABinary); - assert(sym && "symbol not found"); - std::string name = sym->str[PRE] + std::string(kernel) + sym->str[POST]; - return cl->clAPI.extSym(cl, bin, size, sym->sections[0], name.c_str(), error_code); - } -} - -acl_error ACL_API_ENTRY -if_aclInsertSection(aclCompiler *cl, - aclBinary *binary, - const void *data, - size_t data_size, - aclSections id) -{ - bifbase *elfBin = reinterpret_cast(binary->bin); - if (!elfBin) { - return ACL_ELF_ERROR; - } - if (!elfBin->addSection(id, data, data_size)) { - return ACL_ELF_ERROR; - } - return ACL_SUCCESS; - -} - -acl_error ACL_API_ENTRY -if_aclInsertSymbol(aclCompiler *cl, - aclBinary *binary, - const void *data, - size_t data_size, - aclSections id, - const char *symbol) -{ - bifbase *elfBin = reinterpret_cast(binary->bin); - if (!elfBin) { - return ACL_ELF_ERROR; - } - if (!elfBin->addSymbol(id, symbol, - reinterpret_cast(data), data_size)) { - return ACL_ELF_ERROR; - } - return ACL_SUCCESS; - -} - -const void* ACL_API_ENTRY -if_aclExtractSection(aclCompiler *cl, - const aclBinary *binary, - size_t *size, - aclSections id, - acl_error *error_code) -{ - bifbase *elfBin = reinterpret_cast(binary->bin); - if (!elfBin) { - if (error_code) (*error_code) = ACL_ELF_ERROR; - return NULL; - } - const void* a = elfBin->getSection(id, size); - if (a == NULL) { - if (error_code) (*error_code) = ACL_ELF_ERROR; - return NULL; - } - if (error_code) (*error_code) = ACL_SUCCESS; - return a; - -} - -const void* ACL_API_ENTRY -if_aclExtractSymbol(aclCompiler *cl, - const aclBinary *binary, - size_t *size, - aclSections id, - const char *symbol, - acl_error *error_code) -{ - bifbase *elfBin = reinterpret_cast(binary->bin); - if (!elfBin) { - if (error_code) (*error_code) = ACL_ELF_ERROR; - return NULL; - } - const void* a = elfBin->getSymbol(id, symbol, size); - if (a == NULL) { - if (error_code) (*error_code) = ACL_ELF_ERROR; - return NULL; - } - if (error_code) (*error_code) = ACL_SUCCESS; - return a; - -} - -acl_error ACL_API_ENTRY -if_aclRemoveSection(aclCompiler *cl, - aclBinary *binary, - aclSections id) -{ - bifbase *elfBin = reinterpret_cast(binary->bin); - if (!elfBin) { - return ACL_ELF_ERROR; - } - return elfBin->removeSection(id) ? ACL_SUCCESS : ACL_ELF_ERROR; -} - -acl_error ACL_API_ENTRY -if_aclRemoveSymbol(aclCompiler *cl, - aclBinary *binary, - aclSections id, - const char *symbol) -{ - bifbase *elfBin = reinterpret_cast(binary->bin); - if (!elfBin) { - return ACL_ELF_ERROR; - } - return elfBin->removeSymbol(id, symbol) ? ACL_SUCCESS : ACL_ELF_ERROR; -} - -// Function performs deserialization of aclMetadata into *md -// instead of changing source .rodata section in memory pointed by *ptr. -// Deserialization includes restoring of pointers, whereas -// serialized .rodata has pointers set to NULL by serializeMetadata function. -// We should leave serialized metaData unchanged (e.g. w/o garbage pointers) -// due to obtain the same binary from one compilation to another. -// Otherwise, OpenCL conformance "binary_create" test would fail on comparison -// of OpenCL "binaries" (bifs in our case). -void deserializeCLMetadata(const char* ptr, aclMetadata * const md, const size_t size) -{ - memcpy(md,ptr,size); - char *tmp_ptr = reinterpret_cast(md); - tmp_ptr += md->struct_size; - // de-serialize the kernel name - md->kernelName = tmp_ptr; - tmp_ptr += md->kernelNameSize + 1; - - // de-serialize the device name - md->deviceName = tmp_ptr; - tmp_ptr += md->deviceNameSize + 1; - - // de-serialize the vec type hint - md->vth = tmp_ptr; - tmp_ptr += md->vecTypeHintSize + 1; - - // de-serailize the arguments - md->args = reinterpret_cast(tmp_ptr); - tmp_ptr += (md->numArgs + 1) * sizeof(aclArgData); - - for (unsigned x = 0; x < md->numArgs; ++x) { - // Get a pointer to the structure - aclArgData *argPtr = md->args + x; - - // de-serialize the argument name string - argPtr->argStr = tmp_ptr; - tmp_ptr += argPtr->argNameSize + 1; - - // de-serialize the argument type string - argPtr->typeStr = tmp_ptr; - tmp_ptr += argPtr->typeStrSize + 1; - } - - // de-serialize the printf strings - md->printf = reinterpret_cast(tmp_ptr); - tmp_ptr += sizeof(aclPrintfFmt) * (md->numPrintf + 1); - for (unsigned x = 0; x < md->numPrintf; ++x) { - // Get a pointer to the printf structure - aclPrintfFmt *fmtPtr = md->printf + x; - - // de-serialize the arguments - fmtPtr->argSizes = const_cast(reinterpret_cast(tmp_ptr)); - tmp_ptr += sizeof(uint32_t) * fmtPtr->numSizes; - - // de-serialize the format string - fmtPtr->fmtStr = tmp_ptr; - tmp_ptr += fmtPtr->fmtStrSize + 1; - } - assert(md->data_size == size && "The size and data size calculations are off!"); - assert((size_t)(tmp_ptr - reinterpret_cast(md)) - == size && "Size of data and calculated sizes differ!"); -} - -acl_error ACL_API_ENTRY -if_aclQueryInfo(aclCompiler *cl, - const aclBinary *binary, - aclQueryType query, - const char *kernel, - void *ptr, - size_t *size) -{ - if (!size) { - return ACL_ERROR; - } - bifbase *elfBin = reinterpret_cast(binary->bin); - if (!elfBin) { - return ACL_ELF_ERROR; - } - const oclBIFSymbolStruct* sym = findBIF30SymStruct(symOpenclMeta); - assert(sym && "symbol not found"); - aclSections secID = sym->sections[0]; - std::string pre = std::string(sym->str[PRE]); - std::string post = std::string(sym->str[POST]); - switch (query) { - default: - break; - case RT_CONTAINS_LLVMIR: - if (!ptr) { - *size = sizeof(bool); - return ACL_SUCCESS; - } else if (*size >= sizeof(bool)) { - bool contains = elfBin->isSection(aclLLVMIR); - memcpy(ptr, &contains, sizeof(bool)); - return ACL_SUCCESS; - } - return ACL_ERROR; - case RT_CONTAINS_SPIR: - if (!ptr) { - *size = sizeof(bool); - return ACL_SUCCESS; - } else if (*size >= sizeof(bool)) { - bool contains = elfBin->isSection(aclSPIR); - memcpy(ptr, &contains, sizeof(bool)); - return ACL_SUCCESS; - } - return ACL_ERROR; - case RT_CONTAINS_SPIRV: - if (!ptr) { - *size = sizeof(bool); - return ACL_SUCCESS; - } else if (*size >= sizeof(bool)) { - bool contains = elfBin->isSection(aclSPIRV); - memcpy(ptr, &contains, sizeof(bool)); - return ACL_SUCCESS; - } - return ACL_ERROR; - case RT_CONTAINS_OPTIONS: - if (!ptr) { - *size = sizeof(bool); - return ACL_SUCCESS; - } else if (*size >= sizeof(bool)) { - bool contains = elfBin->isSection(aclCOMMENT); - memcpy(ptr, &contains, sizeof(bool)); - return ACL_SUCCESS; - } - return ACL_ERROR; - case RT_CONTAINS_HSAIL: - if (!ptr) { - *size = sizeof(bool); - return ACL_SUCCESS; - } else if (*size >= sizeof(bool)) { - const oclBIFSymbolStruct* sym = findBIF30SymStruct(symHSAILText); - assert(sym && "symbol not found"); - std::string symbolName = sym->str[PRE] + std::string("main") + sym->str[POST]; - bool contains = elfBin->isSymbol(aclCODEGEN, symbolName.c_str()); - memcpy(ptr, &contains, sizeof(bool)); - return ACL_SUCCESS; - } - return ACL_ERROR; - case RT_CONTAINS_BRIG: - if (!ptr) { - *size = sizeof(bool); - return ACL_SUCCESS; - } else if (*size >= sizeof(bool)) { - bool contains = elfBin->isSection(aclBRIG); - memcpy(ptr, &contains, sizeof(bool)); - return ACL_SUCCESS; - } - return ACL_ERROR; - case RT_CONTAINS_LOADER_MAP: - if (!ptr) { - *size = sizeof(bool); - return ACL_SUCCESS; - } else if (*size >= sizeof(bool)) { - const oclBIFSymbolStruct* sym = findBIF30SymStruct(symBRIGLoaderMap); - assert(sym && "symbol not found"); - std::string symbolName = sym->str[PRE]; - bool contains = elfBin->isSymbol(aclCODEGEN, symbolName.c_str()); - memcpy(ptr, &contains, sizeof(bool)); - return ACL_SUCCESS; - } - return ACL_ERROR; - case RT_CONTAINS_ISA: - if (!ptr) { - *size = sizeof(bool); - return ACL_SUCCESS; - } else if (*size >= sizeof(bool)) { - bool contains = elfBin->isSection(aclTEXT); - memcpy(ptr, &contains, sizeof(bool)); - return ACL_SUCCESS; - } - return ACL_ERROR; - case RT_KERNEL_NAMES:{ - bifbase::SymbolVector symbols, kernels; - elfBin->getSectionSymbols(secID, symbols); - size_t totSize = 0; - if (!symbols.empty()) { - std::size_t beg = 0, begKernel = 0, end = 0, endKernel = 0, endSize = 0; - const oclBIFSymbolStruct* symKernel = findBIF30SymStruct(symOpenclKernel); - assert(symKernel && "symbol not found"); - std::string preKernel = std::string(symKernel->str[PRE]); - std::string postKernel = std::string(symKernel->str[POST]); - for (bifbase::SymbolVector::iterator it = symbols.begin(); it != symbols.end(); ++it) { - beg = (*it).find(pre); - if (std::string::npos == beg) continue; - beg += pre.size(); - begKernel = (*it).find(preKernel, beg); - if (std::string::npos != begKernel) { - beg = begKernel + preKernel.size(); - end = (*it).rfind(postKernel); - endSize = postKernel.size(); - } else { - end = (*it).rfind(post); - } - if (std::string::npos == end) continue; - endSize += post.size(); - if (end <= beg || end != (*it).size() - endSize) continue; - std::string kernel((*it).substr(beg, (*it).size() - beg - endSize) + " "); - totSize += kernel.size(); - kernels.push_back(kernel); - } - } - if (!ptr) { - *size = totSize > 0 ? totSize + 1 : 0; - return ACL_SUCCESS; - } else if (*size >= totSize && totSize > 0) { - char* tmp = reinterpret_cast(ptr); - for (bifbase::SymbolVector::iterator it = kernels.begin(); it != kernels.end(); ++it) { - memcpy(tmp, (*it).c_str(), (*it).size()); - tmp += (*it).size(); - } - *(tmp++) = '\0'; - return ACL_SUCCESS; - } - return ACL_ERROR; - } - } - size_t roSize; - acl_error error_code; - if (!kernel) { - return ACL_INVALID_ARG; - } - std::string symbol = pre + std::string(kernel) + post; - const void* roSec = cl->clAPI.extSym(cl, binary, &roSize, secID, symbol.c_str(), &error_code); - if (error_code != ACL_SUCCESS) return error_code; - if (roSec == NULL || roSize == 0) { - return ACL_ELF_ERROR; - } - const aclMetadata *md = reinterpret_cast(roSec); - bool success = false; - switch (query) { - default: break; - case RT_CPU_BARRIER_NAMES: - if (!ptr) { - *size = 0; - success = true; - } else { - assert(!"Not implemented"); - } - break; - case RT_ABI_VERSION: { - size_t majorSize = sizeof(md->major); - size_t minorSize = sizeof(md->minor); - size_t revisionSize = sizeof(md->revision); - size_t verSize = majorSize + minorSize + revisionSize; - if (!ptr) { - *size = verSize; - success = true; - } else if (*size >= verSize) { - char *tmp = reinterpret_cast(ptr); - memcpy(tmp, &md->major, majorSize); - tmp += majorSize; - memcpy(tmp, &md->minor, minorSize); - tmp += minorSize; - memcpy(tmp, &md->revision, revisionSize); - success = true; - } - break; - } - case RT_DEVICE_NAME: - if (!ptr) { - *size = md->deviceNameSize; - success = true; - } else if (*size >= md->deviceNameSize) { - // deviceName is a pointer, which is serialized by serializeMetadata() to NULL - // in binary; to get the data deserializeCLMetadata() is needed - aclMetadata *deserializedMd = static_cast(alloca(roSize)); - deserializeCLMetadata(reinterpret_cast(roSec), deserializedMd, roSize); - if (deserializedMd->deviceName && deserializedMd->deviceNameSize == md->deviceNameSize) { - strncpy(reinterpret_cast(ptr), deserializedMd->deviceName, deserializedMd->deviceNameSize); - success = true; - } - } - break; - case RT_KERNEL_NAME: - if (!ptr) { - *size = md->kernelNameSize; - success = true; - } else if (*size >= md->kernelNameSize) { - // kernelName is a pointer, which is serialized by serializeMetadata() to NULL - // in binary; to get the data deserializeCLMetadata() is needed - aclMetadata *deserializedMd = static_cast(alloca(roSize)); - deserializeCLMetadata(reinterpret_cast(roSec), deserializedMd, roSize); - if (deserializedMd->kernelName && deserializedMd->kernelNameSize == md->kernelNameSize) { - strncpy(reinterpret_cast(ptr), deserializedMd->kernelName, deserializedMd->kernelNameSize); - success = true; - } - } - break; - case RT_MEM_SIZES: { - size_t memSize = sizeof(md->mem); - if (!ptr) { - *size = memSize; - success = true; - } else if (*size >= memSize) { - memcpy(ptr, md->mem, memSize); - success = true; - } - break; - } - case RT_GPU_FUNC_CAPS: { - if (binary->target.arch_id == aclX86) { - break; - } - size_t gpuCapsSize = sizeof(md->gpuCaps); - if (!ptr) { - *size = gpuCapsSize; - success = true; - } else if (*size >= gpuCapsSize) { - memcpy(ptr, &md->gpuCaps, gpuCapsSize); - success = true; - } - break; - } - case RT_GPU_FUNC_ID: { - if (binary->target.arch_id == aclX86) { - break; - } - size_t funcIDSize = sizeof(md->funcID); - if (!ptr) { - *size = funcIDSize; - success = true; - } else if (*size >= funcIDSize) { - memcpy(ptr, &md->funcID, funcIDSize); - success = true; - } - break; - } - case RT_GPU_DEFAULT_ID: { - if (binary->target.arch_id == aclX86) { - break; - } - size_t gpuResSize = sizeof(md->gpuRes); - if (!ptr) { - *size = gpuResSize; - success = true; - } else if (*size >= gpuResSize) { - memcpy(ptr, &md->gpuRes, gpuResSize); - success = true; - } - break; - } - case RT_WORK_GROUP_SIZE: { - size_t wgsSize = sizeof(md->wgs); - if (!ptr) { - *size = wgsSize; - success = true; - } else if (md->wgs && *size >= wgsSize) { - memcpy(ptr, md->wgs, wgsSize); - success = true; - } - break; - } - case RT_WORK_REGION_SIZE: { - size_t wrsSize = sizeof(md->wrs); - if (!ptr) { - *size = wrsSize; - success = true; - } else if (md->wrs && *size >= wrsSize) { - memcpy(ptr, md->wrs, wrsSize); - success = true; - } - break; - } - case RT_ARGUMENT_ARRAY: { - // args is a pointer, which is serialized by serializeMetadata() to NULL - // in binary; to get the data deserializeCLMetadata() is needed - aclMetadata *deserializedMd = static_cast(alloca(roSize)); - deserializeCLMetadata(reinterpret_cast(roSec), deserializedMd, roSize); - size_t totSize = 0; - if (deserializedMd->numArgs > 0) { - // 1 additional elemet is the array's end marker, - // which points to the structure with struct_size == 0 - totSize = sizeof(aclArgData) * (deserializedMd->numArgs + 1); - for (unsigned x = 0; x < deserializedMd->numArgs; ++x) { - totSize += deserializedMd->args[x].typeStrSize + deserializedMd->args[x].argNameSize + 2; - } - } - if (!ptr) { - *size = totSize; - success = true; - } else if (*size >= totSize) { - char *tmp = reinterpret_cast(ptr); - size_t sizeToCopy = sizeof(aclArgData) * (deserializedMd->numArgs + 1); - memcpy(ptr, deserializedMd->args, sizeToCopy); - // shift pointer at the end of the POD struct aclArgData - tmp += sizeToCopy; - for (unsigned x = 0; x < deserializedMd->numArgs; ++x) { - sizeToCopy = deserializedMd->args[x].argNameSize; - // copying argStr data - memcpy(tmp, deserializedMd->args[x].argStr, sizeToCopy); - // copying pointer to argStr data - reinterpret_cast(ptr)[x].argStr = tmp; - tmp += sizeToCopy; - *(tmp++) = '\0'; - sizeToCopy = deserializedMd->args[x].typeStrSize; - // copying typeStr data - memcpy(tmp, deserializedMd->args[x].typeStr, sizeToCopy); - // copying pointer to typeStr data - reinterpret_cast(ptr)[x].typeStr = tmp; - tmp += sizeToCopy; - *(tmp++) = '\0'; - success = true; - } - } - break; - } - case RT_GPU_PRINTF_ARRAY: { - // Printf is a pointer, which is serialized by serializeMetadata() to NULL - // in binary; to get the data deserializeCLMetadata() is needed - aclMetadata *deserializedMd = static_cast(alloca(roSize)); - deserializeCLMetadata(reinterpret_cast(roSec), deserializedMd, roSize); - size_t totSize = 0; - if (deserializedMd->numPrintf > 0) { - // 1 additional elemet is the array's end marker, - // which points to the structure with struct_size == 0 - totSize = sizeof(aclPrintfFmt) * (deserializedMd->numPrintf + 1); - for (unsigned x = 0; x < deserializedMd->numPrintf; ++x) { - totSize += sizeof(*aclPrintfFmt().argSizes) * deserializedMd->printf[x].numSizes; - totSize += deserializedMd->printf[x].fmtStrSize + 1; - } - } - if (!ptr) { - *size = totSize; - success = true; - } else if (*size >= totSize) { - char *tmp = reinterpret_cast(ptr); - size_t sizeToCopy = sizeof(aclPrintfFmt) * (deserializedMd->numPrintf + 1); - memcpy(ptr, deserializedMd->printf, sizeToCopy); - // shift pointer at the end of the POD struct aclPrintfFmt - tmp += sizeToCopy; - for (unsigned x = 0; x < deserializedMd->numPrintf; ++x) { - sizeToCopy = sizeof(*aclPrintfFmt().argSizes) * deserializedMd->printf[x].numSizes; - // copying argSizes data - memcpy(tmp, deserializedMd->printf[x].argSizes, sizeToCopy); - // copying pointer to argSizes data - memcpy(&reinterpret_cast(ptr)[x].argSizes, &tmp, sizeof(void*)); - tmp += sizeToCopy; - sizeToCopy = deserializedMd->printf[x].fmtStrSize; - // copying fmtStr data - memcpy(tmp, deserializedMd->printf[x].fmtStr, sizeToCopy); - // copying pointer to fmtStr data - reinterpret_cast(ptr)[x].fmtStr = tmp; - tmp += sizeToCopy; - *(tmp++) = '\0'; - } - success = true; - } - break; - } - case RT_DEVICE_ENQUEUE: { - size_t enqueue_kernelSize = sizeof(md->enqueue_kernel); - if (!ptr) { - *size = enqueue_kernelSize; - success = true; - } else if (*size >= enqueue_kernelSize) { - memcpy(ptr, &md->enqueue_kernel, enqueue_kernelSize); - success = true; - } - break; - } - // Temporary approach till the "ldk" instruction is supported. - case RT_KERNEL_INDEX: { - size_t kernel_indexSize = sizeof(md->kernel_index); - if (!ptr) { - *size = kernel_indexSize; - success = true; - } else if (*size >= kernel_indexSize) { - memcpy(ptr, &md->kernel_index, kernel_indexSize); - success = true; - } - break; - } - case RT_NUM_KERNEL_HIDDEN_ARGS: { - size_t hidden_kernargs_size = sizeof(md->numHiddenKernelArgs); - if (!ptr) { - *size = hidden_kernargs_size; - success = true; - } else if (*size >= hidden_kernargs_size) { - memcpy(ptr, &md->numHiddenKernelArgs, hidden_kernargs_size); - success = true; - } - break; - } - case RT_WAVES_PER_SIMD_HINT: { - size_t waves_per_simd_hint_size = sizeof(md->wavesPerSimdHint); - if (!ptr) { - *size = waves_per_simd_hint_size; - success = true; - } else if (*size >= waves_per_simd_hint_size) { - memcpy(ptr, &md->wavesPerSimdHint, waves_per_simd_hint_size); - success = true; - } - break; - } - case RT_WORK_GROUP_SIZE_HINT: { - size_t work_group_size_hint_size = sizeof(md->wsh); - if (!ptr) { - *size = work_group_size_hint_size; - success = true; - } else if (*size >= work_group_size_hint_size) { - memcpy(ptr, md->wsh, work_group_size_hint_size); - success = true; - } - break; - } - case RT_VEC_TYPE_HINT: { - if (!ptr) { - *size = md->vecTypeHintSize; - success = true; - } else if (*size >= md->vecTypeHintSize) { - // vecTypeHint is a pointer, which is serialized by serializeMetadata() to NULL - // in binary; to get the data deserializeCLMetadata() is needed - aclMetadata *deserializedMd = static_cast(alloca(roSize)); - deserializeCLMetadata(reinterpret_cast(roSec), deserializedMd, roSize); - if (deserializedMd->vth && deserializedMd->vecTypeHintSize == md->vecTypeHintSize) { - strncpy(reinterpret_cast(ptr), deserializedMd->vth, deserializedMd->vecTypeHintSize); - success = true; - } - } - break; - } - } - return (success) ? ACL_SUCCESS : ACL_ERROR; -} -static unsigned getSize(aclArgDataType data) -{ - switch(data) { - default: - return 4; - case DATATYPE_i64: - case DATATYPE_u64: - case DATATYPE_f64: - return 8; - case DATATYPE_f80: - case DATATYPE_f128: - return 16; - } - return 4; -} -acl_error ACL_API_ENTRY -if_aclDbgAddArgument(aclCompiler *cl, - aclBinary *bin, - const char *kernel, - const char *name, - bool byVal) -{ - if (!isAMDILTarget(bin->target)) { - return ACL_UNSUPPORTED; - } - const oclBIFSymbolStruct* sym = findBIF30SymStruct(symOpenclMeta); - assert(sym && "symbol not found"); - std::string symbol = sym->str[PRE] + std::string(kernel) + sym->str[POST]; - size_t roSize; - acl_error error_code; - aclMetadata *md = NULL; - { - const char* roSec = reinterpret_cast(cl->clAPI.extSym( - cl, bin, &roSize, sym->sections[0], symbol.c_str(), &error_code)); - if (error_code != ACL_SUCCESS) return error_code; - if (roSec == NULL || roSize == 0) { - return ACL_ELF_ERROR; - } - md = static_cast(malloc(roSize)); - if (md == NULL) return ACL_OUT_OF_MEM; - deserializeCLMetadata(roSec, md, roSize); - } - std::string dbg_name = name; - size_t newSize = roSize + sizeof(aclArgData) + dbg_name.size() + 9; - char *newMDptr = new char[newSize]; - char *tmp_ptr = newMDptr; - memset(newMDptr, 0, newSize); - aclMetadata *newMD = reinterpret_cast(newMDptr); - memcpy(tmp_ptr, md, md->struct_size - + (md->kernelNameSize + 1) - + (md->deviceNameSize + 1) - + (md->vecTypeHintSize + 1)); - tmp_ptr += md->struct_size; - tmp_ptr += md->kernelNameSize + 1; - tmp_ptr[-1] = '\0'; - tmp_ptr += md->deviceNameSize + 1; - tmp_ptr[-1] = '\0'; - tmp_ptr += md->vecTypeHintSize + 1; - tmp_ptr[-1] = '\0'; - newMD->args = reinterpret_cast(tmp_ptr); - unsigned cb_offset = 0; - const aclArgData *c_argPtr = reinterpret_cast( - reinterpret_cast(md) + (tmp_ptr - newMDptr)); - for (unsigned x = 0; x < md->numArgs; ++x) { - switch (c_argPtr[x].type) { - default: - case ARG_TYPE_ERROR: - assert(!"Unknown type!"); - break; - case ARG_TYPE_SAMPLER: - break; - case ARG_TYPE_COUNTER: - if (c_argPtr[x].arg.counter.cbOffset >= cb_offset) { - cb_offset = c_argPtr[x].arg.counter.cbOffset + 16; - } - break; - case ARG_TYPE_POINTER: - if (c_argPtr[x].arg.pointer.cbOffset >= cb_offset) { - cb_offset = c_argPtr[x].arg.pointer.cbOffset + 16; - } - break; - case ARG_TYPE_SEMAPHORE: - if (c_argPtr[x].arg.sema.cbOffset >= cb_offset) { - cb_offset = c_argPtr[x].arg.sema.cbOffset + 16; - } - break; - case ARG_TYPE_IMAGE: - if (c_argPtr[x].arg.image.cbOffset >= cb_offset) { - cb_offset = c_argPtr[x].arg.image.cbOffset + 16; - } - break; - case ARG_TYPE_VALUE: - if (c_argPtr[x].arg.value.cbOffset >= cb_offset) { - unsigned offs = c_argPtr[x].arg.value.numElements * getSize(c_argPtr[x].arg.value.data); - cb_offset = c_argPtr[x].arg.value.cbOffset + (offs > 16 ? offs : 16); - } - break; - } - size_t arg_size = c_argPtr[x].struct_size; - memcpy(tmp_ptr, &c_argPtr[x], arg_size); - tmp_ptr += arg_size; - } - // Skip the new one and the sentinal one. - tmp_ptr += (sizeof(aclArgData) * 2); - // Copy all of the name/type strings. - for (unsigned x = 0; x < md->numArgs; ++x) { - memcpy(tmp_ptr, md->args[x].argStr, md->args[x].argNameSize); - tmp_ptr += md->args[x].argNameSize + 1; - tmp_ptr[-1] = '\0'; - memcpy(tmp_ptr, md->args[x].typeStr, md->args[x].typeStrSize); - tmp_ptr += md->args[x].typeStrSize + 1; - tmp_ptr[-1] = '\0'; - } - size_t printf_offset = reinterpret_cast(md->printf) - - reinterpret_cast(md); - aclArgData *argPtr = &newMD->args[newMD->numArgs]; - newMD->numArgs++; - if (byVal) { - argPtr->type = ARG_TYPE_VALUE; - argPtr->arg.value.data = DATATYPE_u32; - argPtr->arg.value.numElements = 4; - argPtr->arg.value.cbNum = 2; - argPtr->arg.value.cbOffset = cb_offset; - } else { - argPtr->type = ARG_TYPE_POINTER; - argPtr->arg.pointer.data = DATATYPE_u32; - argPtr->arg.pointer.numElements = 1; - argPtr->arg.pointer.cbNum = 2; - argPtr->arg.pointer.cbOffset = cb_offset; - argPtr->arg.pointer.memory = PTR_MT_GLOBAL; - argPtr->arg.pointer.bufNum = md->gpuRes[RT_RES_UAV]; - argPtr->arg.pointer.align = 4; - argPtr->arg.pointer.type = ACCESS_TYPE_RW; - argPtr->arg.pointer.isVolatile = false; - argPtr->arg.pointer.isRestrict = false; - } - argPtr->argNameSize = dbg_name.size() + 7; - argPtr->typeStrSize = 0; - argPtr->typeStr = ""; - argPtr->isConst = false; - argPtr->struct_size = sizeof(aclArgData); - argPtr->argStr = tmp_ptr; - memcpy(tmp_ptr, "_debug_", 7); - tmp_ptr += 7; - memcpy(tmp_ptr, dbg_name.data(), dbg_name.size()); - tmp_ptr += dbg_name.size() + 1; - tmp_ptr[-1] = '\0'; - memcpy(tmp_ptr, argPtr->typeStr, argPtr->typeStrSize); - tmp_ptr += argPtr->typeStrSize + 1; - tmp_ptr[-1] = '\0'; - newMD->printf = reinterpret_cast(tmp_ptr); - newMD->data_size = newSize; - memcpy(tmp_ptr, reinterpret_cast(md) + printf_offset, roSize - printf_offset); - tmp_ptr += (roSize - printf_offset); - cl->clAPI.remSym(cl, bin, aclRODATA, symbol.c_str()); - error_code = cl->clAPI.insSym(cl, bin, newMDptr, newSize, - aclRODATA, symbol.c_str()); - assert((size_t)(tmp_ptr - newMDptr) == newSize && "allocated memory does not equal the amount of memory copied!"); - free(md); - delete [] newMDptr; - return error_code; -} - -acl_error ACL_API_ENTRY -if_aclDbgRemoveArgument(aclCompiler *cl, - aclBinary *bin, - const char* kernel, - const char* name) -{ - if (!isAMDILTarget(bin->target)) { - return ACL_UNSUPPORTED; - } - const oclBIFSymbolStruct* sym = findBIF30SymStruct(symOpenclMeta); - assert(sym && "symbol not found"); - std::string symbol = sym->str[PRE] + std::string(kernel) + sym->str[POST]; - size_t roSize; - acl_error error_code; - aclMetadata *md = NULL; - { - const char* roSec = reinterpret_cast(cl->clAPI.extSym(cl, bin, &roSize, - sym->sections[0], symbol.c_str(), &error_code)); - if (error_code != ACL_SUCCESS) return error_code; - if (roSec == NULL || roSize == 0) { - return ACL_ELF_ERROR; - } - md = static_cast(malloc(roSize)); - if (md == NULL) return ACL_OUT_OF_MEM; - deserializeCLMetadata(roSec, md, roSize); - } - const char* ro_ptr = reinterpret_cast(md); - ro_ptr += md->struct_size; - ro_ptr += md->kernelNameSize + 1; - ro_ptr += md->deviceNameSize + 1; - ro_ptr += md->vecTypeHintSize + 1; - const aclArgData *argPtr = reinterpret_cast(ro_ptr); - const aclArgData *delArg = 0; - for (unsigned x = 0; x < md->numArgs; ++x) { - if (0 != argPtr[x].argStr - && !strncmp("_debug_", argPtr[x].argStr, 7) - && !strcmp(name, argPtr[x].argStr + 7)) { - delArg = &argPtr[x]; - break; - } - } - if (0 == delArg) { - return ACL_INVALID_ARG; - } - size_t newSize = roSize - (delArg->struct_size + delArg->argNameSize + delArg->typeStrSize + 2); - char *newMDptr = new char[newSize]; - memset(newMDptr, 0, newSize); - aclMetadata *newMD = reinterpret_cast(newMDptr); - char *tmp_ptr = newMDptr; - memcpy(tmp_ptr, reinterpret_cast(md), md->struct_size - + (md->kernelNameSize + 1) - + (md->deviceNameSize + 1) - + (md->vecTypeHintSize +1)); - tmp_ptr += md->struct_size; - tmp_ptr += md->kernelNameSize + 1; - tmp_ptr[-1] = '\0'; - tmp_ptr += md->deviceNameSize + 1; - tmp_ptr[-1] = '\0'; - tmp_ptr += md->vecTypeHintSize + 1; - tmp_ptr[-1] = '\0'; - unsigned cb_offset = ((delArg->type == ARG_TYPE_VALUE) - ? delArg->arg.value.cbOffset : delArg->arg.pointer.cbOffset); - size_t printf_offset = reinterpret_cast(md->printf) - - reinterpret_cast(md); - newMD->numArgs--; - for (unsigned x = 0; x < md->numArgs; ++x) { - size_t arg_size = argPtr[x].struct_size; - if (strcmp(argPtr[x].argStr, delArg->argStr)) { - memcpy(tmp_ptr, &argPtr[x], arg_size); - aclArgData *tmpArg = reinterpret_cast(tmp_ptr); - tmp_ptr += arg_size; - switch (argPtr[x].type) { - default: - case ARG_TYPE_ERROR: - assert(!"Unknown type!"); - break; - case ARG_TYPE_SAMPLER: - break; - case ARG_TYPE_COUNTER: - if (tmpArg->arg.counter.cbOffset >= cb_offset) { - tmpArg->arg.counter.cbOffset -= 16; - } - break; - case ARG_TYPE_POINTER: - if (tmpArg->arg.pointer.cbOffset >= cb_offset) { - tmpArg->arg.pointer.cbOffset -= 16; - } - break; - case ARG_TYPE_SEMAPHORE: - if (tmpArg->arg.sema.cbOffset >= cb_offset) { - tmpArg->arg.sema.cbOffset -= 16; - } - break; - case ARG_TYPE_IMAGE: - if (tmpArg->arg.image.cbOffset >= cb_offset) { - tmpArg->arg.image.cbOffset -= 16; - } - break; - case ARG_TYPE_VALUE: - if (tmpArg->arg.value.cbOffset >= cb_offset) { - tmpArg->arg.value.cbOffset -= 16; - } - break; - } - } - } - memset(tmp_ptr, 0, delArg->struct_size); - tmp_ptr += delArg->struct_size; - for (unsigned x = 0; x < md->numArgs; ++x) { - size_t arg_size = argPtr[x].struct_size; - if (strcmp(argPtr[x].argStr, delArg->argStr)) { - memcpy(tmp_ptr, argPtr[x].argStr, argPtr[x].argNameSize); - tmp_ptr += argPtr[x].argNameSize + 1; - tmp_ptr[-1] = '\0'; - memcpy(tmp_ptr, argPtr[x].typeStr, argPtr[x].typeStrSize); - tmp_ptr += argPtr[x].typeStrSize + 1; - tmp_ptr[-1] = '\0'; - } - } - - memcpy(tmp_ptr, reinterpret_cast(md) + printf_offset, roSize - printf_offset); - tmp_ptr += (roSize - printf_offset); - newMD->data_size = newSize; - cl->clAPI.remSym(cl, bin, aclRODATA, symbol.c_str()); - error_code = cl->clAPI.insSym(cl, bin, newMDptr, newSize, - aclRODATA, symbol.c_str()); - assert((size_t)(tmp_ptr - newMDptr) == newSize && "allocated memory does not equal the amount of memory copied!"); - free(md); - delete [] newMDptr; - return error_code; -} - -#if defined(LEGACY_COMPLIB) -static OCLMCJITMemoryManager* memMgr = NULL; - -OCLMCJITMemoryManager* createJITMemoryManager() { - if (!memMgr) { - memMgr = new OCLMCJITMemoryManager(); - } - return memMgr; -} -#else -typedef llvm::DenseMap MemMgrTableT; -typedef llvm::DenseMap DyLdTableT; -static MemMgrTableT MemMgrTable; -static DyLdTableT DyLdTable; - -static llvm::RuntimeDyld* GetOrCreateDyld(llvm::object::ObjectFile* obj) { - DyLdTableT::iterator DI = DyLdTable.find(obj); - if (DI != DyLdTable.end()) - return DI->second; - OCLMCJITMemoryManager *memMgr = new OCLMCJITMemoryManager(); - MemMgrTable.insert(std::make_pair(obj, memMgr)); - llvm::RuntimeDyld *rtdyld = new llvm::RuntimeDyld(*memMgr, *memMgr); - DyLdTable.insert(std::make_pair(obj, rtdyld)); - return rtdyld; -} - -static void ReleaseDyld(llvm::object::ObjectFile* obj) { - DyLdTableT::iterator DI = DyLdTable.find(obj); - if (DI != DyLdTable.end()) { - delete DI->second; - DyLdTable.erase(DI); - } - MemMgrTableT::iterator MI = MemMgrTable.find(obj); - if (MI != MemMgrTable.end()) { - delete MI->second; - MemMgrTable.erase(MI); - } -} -#endif - -aclJITObjectImage ACL_API_ENTRY -if_aclJITObjectImageCreate(const void* buffer, size_t length, - aclBinary* bin, acl_error* error_code) { - llvm::StringRef dataString((const char*)buffer, length); -#if defined(LEGACY_COMPLIB) - llvm::MemoryBuffer* memBuf = llvm::MemoryBuffer::getMemBufferCopy(dataString); - llvm::ObjectBuffer* objBuf = new llvm::ObjectBuffer(memBuf); - llvm::RuntimeDyld rtdyld(createJITMemoryManager()); - llvm::ObjectImage* objectImage = rtdyld.loadObject(objBuf); - rtdyld.resolveRelocations(); - amd::option::Options* options = reinterpret_cast(bin->options); - if (options && options->isDumpFlagSet(amd::option::DUMP_O)) { - llvm::StringRef finalData = objectImage->getData(); - std::string finalDataString = finalData.str(); - std::string objname = options->getDumpFileName(".elf"); - std::ofstream out(objname.c_str(), std::fstream::binary | std::fstream::trunc); - out << finalDataString; - out.close(); - } - return objectImage; -#else - std::unique_ptr memBuf = llvm::MemoryBuffer::getMemBufferCopy(dataString); - llvm::ErrorOr> objBuf = - llvm::object::ObjectFile::createObjectFile(memBuf->getMemBufferRef()); - llvm::RuntimeDyld *rtdyld = GetOrCreateDyld(objBuf->get()); - - auto objectImage = rtdyld->loadObject(*(objBuf.get())); - rtdyld->resolveRelocations(); - - amd::option::Options* options = (amd::option::Options*)bin->options; - if (options->isDumpFlagSet(amd::option::DUMP_O)) { - llvm::StringRef finalData = objBuf.get()->getData(); - std::string finalDataString = finalData.str(); - std::string objname = options->getDumpFileName(".elf"); - std::ofstream out(objname.c_str(), - (std::fstream::binary | std::fstream::trunc)); - out << finalDataString; - out.close(); - } - - memBuf.release(); - llvm::object::ObjectFile* result = objBuf.get().release(); - - return result; -#endif -} - -aclJITObjectImage ACL_API_ENTRY -if_aclJITObjectImageCopy(const void* buffer, size_t length, acl_error* error_code) { - llvm::StringRef dataString((const char*)buffer, length); -#if defined(LEGACY_COMPLIB) - llvm::MemoryBuffer* memBuf = llvm::MemoryBuffer::getMemBufferCopy(dataString); - llvm::ObjectBuffer* objBuf = new llvm::ObjectBuffer(memBuf); - llvm::RuntimeDyld rtdyld(createJITMemoryManager()); - llvm::ObjectImage* objectImage = rtdyld.loadObject(objBuf); - rtdyld.resolveRelocations(); - return objectImage; -#else - std::unique_ptr memBuf = llvm::MemoryBuffer::getMemBufferCopy(dataString); - auto objBuf = llvm::object::ObjectFile::createObjectFile(memBuf->getMemBufferRef()); - llvm::RuntimeDyld *rtdyld = GetOrCreateDyld(objBuf->get()); - auto objectImage = rtdyld->loadObject(*(objBuf.get())); - rtdyld->resolveRelocations(); - memBuf.release(); - llvm::object::ObjectFile* result = objBuf.get().release(); - - return result; -#endif -} - -acl_error ACL_API_ENTRY -if_aclJITObjectImageDestroy(aclJITObjectImage image) { -#if defined(LEGACY_COMPLIB) - llvm::ObjectImage* objectImage(reinterpret_cast(image)); - llvm::object::section_iterator end = objectImage->end_sections(); - llvm::error_code err; - for (llvm::object::section_iterator iter = objectImage->begin_sections(); - iter != end; iter.increment(err)) { - llvm::object::SectionRef sectionRef = *iter; - uint64_t address; - sectionRef.getAddress(address); - memMgr->deallocateSection((uint8_t*)address); - } -#else - llvm::object::ObjectFile* objectImage(reinterpret_cast(image)); - ReleaseDyld(objectImage); -#endif - delete objectImage; - return ACL_SUCCESS; -} - -size_t ACL_API_ENTRY -if_aclJITObjectImageSize(aclJITObjectImage image, acl_error* error_code) { -#if defined(LEGACY_COMPLIB) - return (reinterpret_cast(image))->getData().size(); -#else - return (reinterpret_cast(image))->getData().size(); -#endif -} - -const char* ACL_API_ENTRY -if_aclJITObjectImageData(aclJITObjectImage image, acl_error* error_code) { -#if defined(LEGACY_COMPLIB) - return (reinterpret_cast(image))->getData().data(); -#else - return (reinterpret_cast(image))->getData().data(); -#endif -} - -acl_error ACL_API_ENTRY -if_aclJITObjectImageFinalize(aclJITObjectImage image) { - return ACL_SUCCESS; -} - -size_t ACL_API_ENTRY -if_aclJITObjectImageGetGlobalsSize(aclJITObjectImage image, acl_error* error_code) { - size_t totalSize = 0; -#if defined(LEGACY_COMPLIB) - llvm::ObjectImage* objectImage(reinterpret_cast(image)); - llvm::object::section_iterator end = objectImage->end_sections(); - llvm::error_code err; - for (llvm::object::section_iterator iter = objectImage->begin_sections(); - iter != end; iter.increment(err)) { - llvm::object::SectionRef sectionRef = *iter; - llvm::StringRef name; - uint64_t size; - bool isBSS, isData, isText; - sectionRef.getName(name); - sectionRef.getSize(size); - sectionRef.isBSS(isBSS); - sectionRef.isData(isData); - sectionRef.isText(isText); - if ((isBSS || isData) && !isText) { - totalSize += (size_t)size; - } - } -#else - llvm::object::ObjectFile* objectImage(reinterpret_cast(image)); - for (auto iter: objectImage->sections()) { - uint64_t size = iter.getSize(); - if ((iter.isBSS() || iter.isData()) && !iter.isText()) { - totalSize += (size_t)iter.getSize(); - } - } -#endif - return totalSize; -} - -acl_error ACL_API_ENTRY -if_aclJITObjectImageIterateSymbols(aclJITObjectImage image, - JITSymbolCallback jit_callback, void* data) { -#if defined(LEGACY_COMPLIB) - llvm::ObjectImage* objectImage(reinterpret_cast(image)); - llvm::object::symbol_iterator end = objectImage->end_symbols(); - llvm::StringRef name; - uint64_t address; - llvm::error_code err; - for (llvm::object::symbol_iterator iter = objectImage->begin_symbols(); - iter != end; iter.increment(err)) { - llvm::object::SymbolRef symRef = *iter; - symRef.getName(name); - symRef.getAddress(address); - jit_callback(name.str().c_str(), (const void*)address, data); - } -#else - llvm::object::ObjectFile* objectImage = reinterpret_cast(image); - llvm::RuntimeDyld *rtdyld = GetOrCreateDyld(objectImage); - for (const auto &S: objectImage->symbols()) { - auto Ret = S.getName(); - if (!Ret) { - auto InternalSymbol = rtdyld->getSymbol(Ret.get()); - uint64_t address = (uint64_t)(InternalSymbol ? InternalSymbol.getAddress() : 0); - jit_callback(Ret.get().data(), (const void*)address, data); - } - } -#endif - return ACL_SUCCESS; -} - -#if defined(LEGACY_COMPLIB) -#if 0 -static std::string getFeaturesString(llvm::StringMap& Features) -{ - std::string FeatureString; - llvm::raw_string_ostream FeatureStream(FeatureString); - llvm::SubtargetFeatures TargetFeatures(""); - llvm::StringMapConstIterator iterEnd = Features.end(); - for(llvm::StringMapConstIterator I = Features.begin(); - I != iterEnd; ++I) { - const llvm::StringMapEntry entry = *I; - TargetFeatures.AddFeature(entry.getKey(), entry.getValue()); - } - TargetFeatures.print(FeatureStream); - return FeatureString; -} -#endif - -static std::string getTripleName() -{ -#ifdef _WIN32 - return LP64_SWITCH("i686-pc-mingw32-amdopencl", - "x86_64-pc-mingw32-amdopencl"); -#else - return LP64_SWITCH("i686-pc-linux-amdopencl", - "x86_64-pc-linux-amdopencl"); -#endif -} - -static std::string bytesToHexString(const char* data, size_t size) { - std::stringstream hexstring; - hexstring << std::hex << std::setfill('0'); - for(size_t i = 0; i < size; ++i) { - hexstring << "0x" << std::setw(2) << unsigned((unsigned char)data[i]) - << std::endl; - } - hexstring << std::endl; - return hexstring.str(); -} - -char* ACL_API_ENTRY -if_aclJITObjectImageDisassembleKernel(constAclJITObjectImage image, - const char* kernel, acl_error* error_code) { - const llvm::ObjectImage* objectImage(reinterpret_cast(image)); - llvm::object::symbol_iterator end = objectImage->end_symbols(); - llvm::error_code err; - llvm::StringRef name; - std::stringstream disas; - for (llvm::object::symbol_iterator iter = objectImage->begin_symbols(); - iter != end; iter.increment(err)) { - llvm::object::SymbolRef symRef = *iter; - symRef.getName(name); - std::string kernelStr(kernel); - if(name == kernelStr) { - uint64_t start; - uint64_t size; - symRef.getSize(size); - symRef.getAddress(start); - const char *bytes = (const char *)start; - const uint64_t extent = 0x10000; - uint64_t max_pc = 0; - - llvm::InitializeAllTargetInfos(); - llvm::InitializeAllTargetMCs(); - llvm::InitializeAllAsmParsers(); - llvm::InitializeAllDisassemblers(); - - std::string TripleName = getTripleName(); - std::string Error; - const llvm::Target *TheTarget = - llvm::TargetRegistry::lookupTarget(TripleName, Error); - - std::string hexstring = bytesToHexString(bytes, size); - llvm::StringRef kernelMem(hexstring); - llvm::MemoryBuffer *Buffer = - llvm::MemoryBuffer::getMemBuffer(kernelMem, "", false); - llvm::SourceMgr SrcMgr; - - SrcMgr.AddNewSourceBuffer(Buffer, llvm::SMLoc()); - - llvm::OwningPtr - MAI(TheTarget->createMCAsmInfo(TripleName)); - assert(MAI && "Unable to create target asm info!"); - - llvm::OwningPtr - MRI(TheTarget->createMCRegInfo(TripleName)); - assert(MRI && "Unable to create target register info!"); - - llvm::OwningPtr - MOFI(new llvm::MCObjectFileInfo()); - llvm::MCContext Ctx(*MAI, *MRI, MOFI.get(), &SrcMgr); - MOFI->InitMCObjectFileInfo(TripleName, llvm::Reloc::Default, - llvm::CodeModel::Default, Ctx); - - Ctx.setAllowTemporaryLabels(true); - Ctx.setGenDwarfForAssembly(true); - - std::string MCPU = "corei7-avx"; - std::string FeaturesStr; - - std::string DisasResultString; - llvm::raw_string_ostream OutputStream(DisasResultString); - OutputStream.SetUnbuffered(); - llvm::formatted_raw_ostream FOS(OutputStream); - llvm::OwningPtr Str; - llvm::OwningPtr MCII(TheTarget->createMCInstrInfo()); - llvm::OwningPtr - STI(TheTarget->createMCSubtargetInfo(TripleName, MCPU, FeaturesStr)); - llvm::MCInstPrinter *IP = - TheTarget->createMCInstPrinter(0 /* OutputAsmVariant */, *MAI, *MCII, *MRI, - *STI); - llvm::MCCodeEmitter *CE = 0; - llvm::MCAsmBackend *MAB = 0; - if (false) { - CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, *STI, Ctx); - MAB = TheTarget->createMCAsmBackend(TripleName, MCPU); - } - Str.reset(TheTarget->createAsmStreamer(Ctx, FOS, /*asmverbose*/true, - /*useLoc*/ true, - /*useCFI*/ true, - /*useDwarfDirectory*/ true, - IP, CE, MAB, false)); - // int Res = llvm::Disassembler::disassemble(*TheTarget, - // TripleName, *STI, *Str, - // *Buffer, SrcMgr, OutputStream); - - int Res = - llvm::Disassembler::disassembleEnhanced(TripleName, *Buffer, SrcMgr, - OutputStream); - const char* result = DisasResultString.c_str(); - return strdup(result); - } - } - return NULL; -} -#endif - -void myLogFunc(const char * msg, size_t size) -{ - printf("%s\n", msg); -} - -#define CONDITIONAL_ASSIGN(A, B) A = (A) ? (A) : (B) -acl_error ACL_API_ENTRY -if_aclSetupLoaderObject(aclCompiler *cl) { - /* setup the loader objects here now that we have parsed the - * options and know the target. */ - CONDITIONAL_ASSIGN(cl->cgAPI.init, &CodegenInit); - CONDITIONAL_ASSIGN(cl->cgAPI.fini, &CodegenFini); - CONDITIONAL_ASSIGN(cl->cgAPI.codegen, &CodegenPhase); - CONDITIONAL_ASSIGN(cl->linkAPI.init, &LinkInit); - CONDITIONAL_ASSIGN(cl->linkAPI.fini, &LinkFini); - CONDITIONAL_ASSIGN(cl->linkAPI.link, &OCLLinkPhase); - CONDITIONAL_ASSIGN(cl->linkAPI.toLLVMIR, &OCLLinkToLLVMIR); - CONDITIONAL_ASSIGN(cl->linkAPI.toSPIR, &OCLLinkToSPIR); - - CONDITIONAL_ASSIGN(cl->feAPI.init, &OCLInit); - CONDITIONAL_ASSIGN(cl->feAPI.fini, &OCLFini); -#if !defined(LEGACY_COMPLIB) - CONDITIONAL_ASSIGN(cl->feAPI.toIR, &OCLFEToSPIR); -#else - CONDITIONAL_ASSIGN(cl->feAPI.toIR, &OCLFEToLLVMIR); -#endif - - CONDITIONAL_ASSIGN(cl->feAPI.toModule, &OCLFEToModule); - CONDITIONAL_ASSIGN(cl->feAPI.toISA, &OCLFEToISA); - CONDITIONAL_ASSIGN(cl->optAPI.init, &OptInit); - CONDITIONAL_ASSIGN(cl->optAPI.fini, &OptFini); - CONDITIONAL_ASSIGN(cl->optAPI.optimize, &OptOptimize); - CONDITIONAL_ASSIGN(cl->beAPI.init, &BEInit); - CONDITIONAL_ASSIGN(cl->beAPI.fini, &BEFini); - CONDITIONAL_ASSIGN(cl->beAPI.finalize, &BEAsmPhase); - CONDITIONAL_ASSIGN(cl->beAPI.assemble, &BEAssemble); - CONDITIONAL_ASSIGN(cl->beAPI.disassemble, &BEDisassemble); - return ACL_SUCCESS; -} - -#undef CONDITIONAL_ASSIGN - -extern "C" { -bool aclRenderscriptCompile( - char * srcFile, - char ** outBuf, - size_t * outLen -) -{ -#if 0 - // Consider using code here if aoc2 is not used. - llvm::Module *bc = NULL; - llvm::LLVMContext &Context = llvm::getGlobalContext(); - llvm::SMDiagnostic Err; - std::string Str(srcFile); - - bc = llvm::ParseIRFile(Str, Err, Context); - if (!bc) - return false; - - llvm::PassManager TransformPasses; - TransformPasses.add(llvm::createOpenCLIRTransform()); - TransformPasses.run(*bc); -#endif - - size_t size = 0; - acl_error error_code; - char * source = readFile(srcFile, size); - if (!size) - return false; - - aclCompiler *aoc = aclCompilerInit(NULL, &error_code); - if ((aoc == NULL) || (error_code != ACL_SUCCESS)) - return false; - - aclTargetInfo target = aclGetTargetInfo("hsail", "Bonaire", &error_code); - if (error_code != ACL_SUCCESS) - return false; - - aclBinary *aoe = aclBinaryInit(sizeof(aclBinary), &target, NULL, &error_code); - if (error_code != ACL_SUCCESS) - return false; - - error_code = aclInsertSection(aoc, aoe, source, size, aclLLVMIR); - if (error_code != ACL_SUCCESS) - return false; - -#if 1 - // Dump HSAIL and ISA to a temporary file in the working directory. - error_code = aclCompile(aoc, aoe, "-save-temps=tmp", ACL_TYPE_RSLLVMIR_BINARY, ACL_TYPE_HSAIL_BINARY, myLogFunc); -#else - error_code = aclCompile(aoc, aoe, NULL, ACL_TYPE_RSLLVMIR_BINARY, ACL_TYPE_ISA, myLogFunc); -#endif - - if (error_code == ACL_FRONTEND_FAILURE) { - printf("ACL_FRONTEND_FAILURE.\n"); - return true; - } - - if (error_code != ACL_SUCCESS) - return false; - - if ((aoe == NULL) || (aoe->bin == NULL)) - return false; - - char *buffer = NULL; - size_t len; - acl_error errCode = aclWriteToMem(aoe, reinterpret_cast(&buffer), &len); - if (errCode != ACL_SUCCESS) - return false; - - *outLen = len; - *outBuf = buffer; - return true; -} - -} diff --git a/rocclr/compiler/lib/backends/common/v0_8/if_acl.h b/rocclr/compiler/lib/backends/common/v0_8/if_acl.h deleted file mode 100644 index fe44b05b49..0000000000 --- a/rocclr/compiler/lib/backends/common/v0_8/if_acl.h +++ /dev/null @@ -1,172 +0,0 @@ -// -// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _IF_ACL_0_8_H_ -#define _IF_ACL_0_8_H_ -#include "aclTypes.h" -aclLoaderData* ACL_API_ENTRY -if_aclCompilerInit(aclCompiler *cl, aclBinary *bin, aclLogFunction log, acl_error *error); -acl_error ACL_API_ENTRY -if_aclCompilerFini(aclLoaderData *ald); - -acl_error ACL_API_ENTRY -if_aclCompile(aclCompiler *cl, - aclBinary *bin, - const char *options, - aclType from, - aclType to, - aclLogFunction compile_callback) ACL_API_0_8; - -acl_error ACL_API_ENTRY -if_aclLink(aclCompiler *cl, - aclBinary *src_bin, - unsigned int num_libs, - aclBinary **libs, - aclType link_mode, - const char *options, - aclLogFunction link_callback) ACL_API_0_8; - -const char* ACL_API_ENTRY -if_aclGetCompilerLog(aclCompiler *cl) ACL_API_0_8; - -const void* ACL_API_ENTRY -if_aclRetrieveType(aclCompiler *cl, - const aclBinary *bin, - const char *name, - size_t *data_size, - aclType type, - acl_error *error_code) ACL_API_0_8; - -acl_error ACL_API_ENTRY -if_aclSetType(aclCompiler *cl, - aclBinary *bin, - const char *name, - aclType type, - const void *data, - size_t size) ACL_API_0_8; - -acl_error ACL_API_ENTRY -if_aclConvertType(aclCompiler *cl, - aclBinary *bin, - const char *name, - aclType type) ACL_API_0_8; - -acl_error ACL_API_ENTRY -if_aclDisassemble(aclCompiler *cl, - aclBinary *bin, - const char *kernel, - aclLogFunction disasm_callback) ACL_API_0_8; - -const void* ACL_API_ENTRY -if_aclGetDeviceBinary(aclCompiler *cl, - const aclBinary *bin, - const char *kernel, - size_t *size, - acl_error *error_code) ACL_API_0_8; - -acl_error ACL_API_ENTRY -if_aclInsertSection(aclCompiler *cl, - aclBinary *binary, - const void *data, - size_t data_size, - aclSections id) ACL_API_0_8; - -acl_error ACL_API_ENTRY -if_aclInsertSymbol(aclCompiler *cl, - aclBinary *binary, - const void *data, - size_t data_size, - aclSections id, - const char *symbol) ACL_API_0_8; - -const void* ACL_API_ENTRY -if_aclExtractSection(aclCompiler *cl, - const aclBinary *binary, - size_t *size, - aclSections id, - acl_error *error_code) ACL_API_0_8; - -const void* ACL_API_ENTRY -if_aclExtractSymbol(aclCompiler *cl, - const aclBinary *binary, - size_t *size, - aclSections id, - const char *symbol, - acl_error *error_code) ACL_API_0_8; - -acl_error ACL_API_ENTRY -if_aclRemoveSection(aclCompiler *cl, - aclBinary *binary, - aclSections id) ACL_API_0_8; - -acl_error ACL_API_ENTRY -if_aclRemoveSymbol(aclCompiler *cl, - aclBinary *binary, - aclSections id, - const char *symbol) ACL_API_0_8; - -acl_error ACL_API_ENTRY -if_aclQueryInfo(aclCompiler *cl, - const aclBinary *binary, - aclQueryType query, - const char *kernel, - void *data_ptr, - size_t *ptr_size) ACL_API_0_8; - -acl_error ACL_API_ENTRY -if_aclDbgAddArgument(aclCompiler *cl, - aclBinary *bin, - const char *kernel, - const char *name, - bool byVal) ACL_API_0_8; - -acl_error ACL_API_ENTRY -if_aclDbgRemoveArgument(aclCompiler *cl, - aclBinary *bin, - const char* kernel, - const char* name) ACL_API_0_8; - -acl_error ACL_API_ENTRY -if_aclSetupLoaderObject(aclCompiler *cl) ACL_API_0_8; - -void* ACL_API_ENTRY -if_aclJITObjectImageCreate(const void* buffer, - size_t length, - aclBinary* bin, - acl_error* error_code) ACL_API_0_8; - -void* ACL_API_ENTRY -if_aclJITObjectImageCopy(const void* buffer, - size_t length, - acl_error* error_code) ACL_API_0_8; - -acl_error ACL_API_ENTRY -if_aclJITObjectImageDestroy(aclJITObjectImage buffer) ACL_API_0_8; - -size_t ACL_API_ENTRY -if_aclJITObjectImageSize(aclJITObjectImage image, - acl_error* error_code) ACL_API_0_8; - -const char* ACL_API_ENTRY -if_aclJITObjectImageData(aclJITObjectImage image, - acl_error* error_code) ACL_API_0_8; - -acl_error ACL_API_ENTRY -if_aclJITObjectImageFinalize(aclJITObjectImage image) ACL_API_0_8; - -size_t ACL_API_ENTRY -if_aclJITObjectImageGetGlobalsSize(aclJITObjectImage image, - acl_error* error_code) ACL_API_0_8; - -acl_error ACL_API_ENTRY -if_aclJITObjectImageIterateSymbols(aclJITObjectImage image, - JITSymbolCallback jit_callback, void* data) ACL_API_0_8; - -#if defined(LEGACY_COMPLIB) -char* ACL_API_ENTRY -if_aclJITObjectImageDisassembleKernel(constAclJITObjectImage image, - const char* kernel, - acl_error* error_code) ACL_API_0_8; -#endif - -#endif // _IF_ACL_0_8_H_ diff --git a/rocclr/compiler/lib/complibdefs b/rocclr/compiler/lib/complibdefs deleted file mode 100644 index a7acce41e6..0000000000 --- a/rocclr/compiler/lib/complibdefs +++ /dev/null @@ -1,87 +0,0 @@ -OPENCL_DEPTH ?= $(COMPLIB_DEPTH)/../.. - -include $(OPENCL_DEPTH)/opencldefs - -# Set the #defines for sc/Interface like that used to build sc. -# For a non-default configuration (for instance adding GFX9), -# make GFX9_BUILD=1 wNow.dbg -# or change -# ../../opencldefs -# to make sure that the settings for sc and sc's uses match. -include $(OPENCL_DEPTH)/compiler/sc/Interface/scinterfacedefs -GCPPFLAGS += $(SC_LIB_DEFS) - -ELFTOOLCHAIN_DIR = $(COMPLIB_DEPTH)/loaders/elf/utils - -ifdef GONE_TO_BUILD_DIR -ifneq ($(BUILD_LEGACY_COMPLIB),yes) -override BUILD_LLVM_AMDIL_TARGET = no -endif -endif - -ifeq ($(BUILD_LLVM_HSAIL_TARGET),yes) -GCPPFLAGS += $(DEFSWITCH) WITH_TARGET_HSAIL -endif - -GCPPFLAGS += $(ASIC_REG_INCS) -GCPPFLAGS += $(INCSWITCH) "$(COMPLIB_DEPTH)" -GCPPFLAGS += $(INCSWITCH) "$(OPENCL_DEPTH)/runtime" -GCPPFLAGS += $(INCSWITCH) "$(OPENCL_DEPTH)/runtime/utils" -GCPPFLAGS += $(INCSWITCH) "$(COMPLIB_DEPTH)/utils" -GCPPFLAGS += $(INCSWITCH) "$(OPENCL_DEPTH)/api/opencl/khronos/headers/opencl2.0" - -# Do we build the 0.9 version? -ifeq ($(BUILD_VERSION_0_9), 1) -GCPPFLAGS += $(DEFSWITCH) WITH_VERSION_0_9 -CLVER_SUBDIR = v0_9 -else -# Otherwise we build v0.8 -GCPPFLAGS += $(DEFSWITCH) WITH_VERSION_0_8 -CLVER_SUBDIR = v0_8 -endif - -GCPPFLAGS += $(INCSWITCH) "$(COMPLIB_DEPTH)/utils/$(CLVER_SUBDIR)" -GCPPFLAGS += $(INCSWITCH) "$(COMPLIB_DEPTH)/include/$(CLVER_SUBDIR)" -GCPPFLAGS += $(DEFSWITCH) "BREAK_ON_LOG_WARNING=0" -GCPPFLAGS += $(DEFSWITCH) "BREAK_ON_LOG_ERROR=0" -GCPPFLAGS += $(DEFSWITCH) "LOG_LEVEL=2" - -GCPPFLAGS += $(INCSWITCH) "$(OPENCL_DEPTH)/runtime/device/gpu/gslbe/src/rt" -GCPPFLAGS += $(INCSWITCH) "$(UGL_DEPTH)/gl/gs/hwl/si/include/asic" - -export BRIG_ENABLE=1 - -ifdef ATI_OS_WINDOWS - GCPPFLAGS += $(INCSWITCH) "$(DK_ROOT)/$(DK_DX_SDK)/inc" - - ifeq ($(BUILD_TYPE),dbg) - GCXXOPTS += /Ob1 - endif - - GCXXOPTS += -wd4985 -wd4355 -wd4800 -wd4291 -wd4624 -wd4141 - - GCPPFLAGS += $(DEFSWITCH) _SCL_SECURE_NO_WARNINGS - - GCXXOPTS += /GR- # Disable Run-Time Type Information -endif - -ifdef ATI_OS_LINUX - GCPPFLAGS += $(DEFSWITCH) __STDC_LIMIT_MACROS - GCPPFLAGS += $(DEFSWITCH) __STDC_CONSTANT_MACROS - - GCXXOPTS += -fno-rtti -Wno-sign-compare - - ifneq ($(filter gcc/gcc-7.4%,$(DK_C)),) - GCXXOPTS += -Wno-deprecated-declarations - endif -endif - -ifeq ($(OPENCL_USE_ONE_SC),1) - GCPPFLAGS += $(DEFSWITCH) OPENCL_USE_ONE_SC -endif - -ifneq (,$(wildcard $(COMPLIB_DEPTH)/loaders/elf/utils/blowfish/blowfish.h)) - GCPPFLAGS += $(DEFSWITCH) HAVE_BLOWFISH_H -endif - -include $(OPENCL_DEPTH)/compiler/scinterfacedefs.opencl diff --git a/rocclr/compiler/lib/compliblinkerlibs b/rocclr/compiler/lib/compliblinkerlibs deleted file mode 100644 index eb4ae9be99..0000000000 --- a/rocclr/compiler/lib/compliblinkerlibs +++ /dev/null @@ -1,4 +0,0 @@ -COMPLIB_DEPTH = $(OPENCL_DEPTH)/compiler/lib - -#AMDOpenCLLLVMLinkerLIBS = $(COMPLIB_DEPTH)/linker/lib/$(FULL_BUILD_DIR)/AMDLLVMOpenCLLinker$(LIB_EXT) -AMDOpenCLLLVMLinkerLIBS = $(OPENCL_DEPTH)/compiler/lib/linker/lib/$(FULL_BUILD_DIR)/AMDOpenCLLLVMLinker$(LIB_EXT) diff --git a/rocclr/compiler/lib/complibrules b/rocclr/compiler/lib/complibrules deleted file mode 100644 index 495a6ed1e0..0000000000 --- a/rocclr/compiler/lib/complibrules +++ /dev/null @@ -1,16 +0,0 @@ -COMPLIB_DEPTH ?= $(OPENCL_DEPTH)/compiler/lib -ifdef GONE_TO_BUILD_DIR -ifdef ATI_OS_LINUX -*$(OBJ_EXT): $(COMPLIB_DEPTH)/complibdefs $(COMPLIB_DEPTH)/complibrules -endif -endif - -%.v08: - @$(MAKENOISE) "Setting BUILD_VERSION_0_8=1" - @$(MAKE) BUILD_VERSION_0_8=1 $* - -%.v09: - @$(MAKENOISE) "Setting BUILD_VERSION_0_9=1" - @$(MAKE) BUILD_VERSION_0_9=1 $* - -include $(OPENCL_DEPTH)/openclrules diff --git a/rocclr/compiler/lib/include/acl.h b/rocclr/compiler/lib/include/acl.h index 01a227fa62..4c44eb0fee 100644 --- a/rocclr/compiler/lib/include/acl.h +++ b/rocclr/compiler/lib/include/acl.h @@ -1,10 +1,305 @@ // // Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved. // -// This is a compatibility header file. Either define the version -// of the compiler library that is to be used or include the -// header file for that version directly. -#ifndef ACL_H_ -#define ACL_H_ -#include "v0_8/acl.h" -#endif // ACL_H_ +#ifndef _ACL_0_8_H_ +#define _ACL_0_8_H_ +#ifdef __cplusplus +extern "C" { +#endif +#include "aclTypes.h" +//!--------------------------------------------------------------------------!// +// Functions that deal with aclCompiler objects. +//!--------------------------------------------------------------------------!// +aclCompiler* ACL_API_ENTRY +aclCompilerInit(aclCompilerOptions *opts, acl_error *error_code) ACL_API_0_8; +acl_error ACL_API_ENTRY + aclCompilerFini(aclCompiler *cl) ACL_API_0_8; +aclCLVersion ACL_API_ENTRY + aclCompilerVersion(aclCompiler *cl, acl_error *error_code) ACL_API_0_8; +uint32_t ACL_API_ENTRY + aclVersionSize(aclCLVersion num, acl_error *error_code) ACL_API_0_8; +const char* ACL_API_ENTRY + aclGetErrorString(acl_error error_code) ACL_API_0_8; + +//!--------------------------------------------------------------------------!// +// Functions that deal with target specific information. +//!--------------------------------------------------------------------------!// +//! Returns in the names argument, if non-NULL, a pointer to each of the arch +// names that the compiler supports. If names is NULL and arch_size is +// non-NULL, returns the number of arch entries that are required. +acl_error ACL_API_ENTRY + aclGetArchInfo(const char** arch_names, + size_t *arch_size) ACL_API_0_8; + +//! Returns in the arch argument, if non-NULL, a pointer to each device +// name that the compiler supports. If device_size is non-NULL, +// returns the number of device entries that are used. +acl_error ACL_API_ENTRY + aclGetDeviceInfo(const char* arch, + const char **names, + size_t *device_size) ACL_API_0_8; + +//! Function that returns a correctly filled out aclTargetInfo structure based +// on the information passed into the kernel. +aclTargetInfo ACL_API_ENTRY +aclGetTargetInfo(const char *arch, + const char *device, + acl_error *error_code) ACL_API_0_8; + +//! Function that returns a correctly filled out aclTargetInfo structure based +// on the information passed into the kernel. +aclTargetInfo ACL_API_ENTRY +aclGetTargetInfoFromChipID(const char *arch, + const uint32_t chip_id, + acl_error *error_code) ACL_API_0_8; + +//! Function that returns a string representation of the target architecture. +const char* ACL_API_ENTRY + aclGetArchitecture(const aclTargetInfo &target) ACL_API_0_8; + +//! Function that returns a string representation of the target chip options. +const uint64_t ACL_API_ENTRY + aclGetChipOptions(const aclTargetInfo &target) ACL_API_0_8; + +//! Function that returns a string representation of the target family. +const char* ACL_API_ENTRY + aclGetFamily(const aclTargetInfo &target) ACL_API_0_8; + +//! Function that returns a string representation of the target chip. +const char* ACL_API_ENTRY + aclGetChip(const aclTargetInfo &target) ACL_API_0_8; + +//!--------------------------------------------------------------------------!// +// Functions that deal with aclBinary objects. +//!--------------------------------------------------------------------------!// +aclBinary* ACL_API_ENTRY + aclBinaryInit( + size_t struct_version, + const aclTargetInfo *target, + const aclBinaryOptions *options, + acl_error *error_code) ACL_API_0_8; + +acl_error ACL_API_ENTRY + aclBinaryFini(aclBinary *bin) ACL_API_0_8; + +aclBinary* ACL_API_ENTRY + aclReadFromFile(const char *str, + acl_error *error_code) ACL_API_0_8; + +aclBinary* ACL_API_ENTRY + aclReadFromMem(const void *mem, + size_t size, acl_error *error_code) ACL_API_0_8; + +acl_error ACL_API_ENTRY + aclWriteToFile(aclBinary *bin, + const char *str) ACL_API_0_8; + +acl_error ACL_API_ENTRY + aclWriteToMem(aclBinary *bin, + void **mem, size_t *size) ACL_API_0_8; + +aclBinary* ACL_API_ENTRY + aclCreateFromBinary(const aclBinary *binary, + aclBIFVersion version) ACL_API_0_8; + +aclBIFVersion ACL_API_ENTRY + aclBinaryVersion(const aclBinary *binary) ACL_API_0_8; + +acl_error ACL_API_ENTRY + aclInsertSection(aclCompiler *cl, + aclBinary *binary, + const void *data, + size_t data_size, + aclSections id) ACL_API_0_8; + +acl_error ACL_API_ENTRY + aclInsertSymbol(aclCompiler *cl, + aclBinary *binary, + const void *data, + size_t data_size, + aclSections id, + const char *symbol) ACL_API_0_8; + +const void* ACL_API_ENTRY + aclExtractSection(aclCompiler *cl, + const aclBinary *binary, + size_t *size, + aclSections id, + acl_error *error_code) ACL_API_0_8; + +const void* ACL_API_ENTRY + aclExtractSymbol(aclCompiler *cl, + const aclBinary *binary, + size_t *size, + aclSections id, + const char *symbol, + acl_error *error_code) ACL_API_0_8; + +acl_error ACL_API_ENTRY + aclRemoveSection(aclCompiler *cl, + aclBinary *binary, + aclSections id) ACL_API_0_8; + +acl_error ACL_API_ENTRY + aclRemoveSymbol(aclCompiler *cl, + aclBinary *binary, + aclSections id, + const char *symbol) ACL_API_0_8; + +//!--------------------------------------------------------------------------!// +// Functions that deal with debug/metdata. +//!--------------------------------------------------------------------------!// +acl_error ACL_API_ENTRY + aclQueryInfo(aclCompiler *cl, + const aclBinary *binary, + aclQueryType query, + const char *kernel, + void *data_ptr, + size_t *ptr_size) ACL_API_0_8; + +acl_error ACL_API_ENTRY + aclDbgAddArgument(aclCompiler *cl, + aclBinary *binary, + const char* kernel, + const char* name, + bool byVal) + ACL_API_0_8; + +acl_error ACL_API_ENTRY + aclDbgRemoveArgument(aclCompiler *cl, + aclBinary *binary, + const char* kernel, + const char* name) + ACL_API_0_8; + +//!--------------------------------------------------------------------------!// +// Functions that deal with various compilation phases. +//!--------------------------------------------------------------------------!// +acl_error ACL_API_ENTRY + aclCompile(aclCompiler *cl, + aclBinary *bin, + const char *options, + aclType from, + aclType to, + aclLogFunction compile_callback) ACL_API_0_8; + +acl_error ACL_API_ENTRY + aclLink(aclCompiler *cl, + aclBinary *src_bin, + unsigned int num_libs, + aclBinary **libs, + aclType link_mode, + const char *options, + aclLogFunction link_callback) ACL_API_0_8; + +const char* ACL_API_ENTRY + aclGetCompilerLog(aclCompiler *cl) ACL_API_0_8; + +const void* ACL_API_ENTRY + aclRetrieveType(aclCompiler *cl, + const aclBinary *bin, + const char *name, + size_t *data_size, + aclType type, + acl_error *error_code) ACL_API_0_8; + +acl_error ACL_API_ENTRY + aclSetType(aclCompiler *cl, + aclBinary *bin, + const char *name, + aclType type, + const void *data, + size_t size) ACL_API_0_8; + +acl_error ACL_API_ENTRY + aclConvertType(aclCompiler *cl, + aclBinary *bin, + const char *name, + aclType type) ACL_API_0_8; + +acl_error ACL_API_ENTRY + aclDisassemble(aclCompiler *cl, + aclBinary *bin, + const char *kernel, + aclLogFunction disasm_callback) ACL_API_0_8; + +const void* ACL_API_ENTRY + aclGetDeviceBinary(aclCompiler *cl, + const aclBinary *bin, + const char *kernel, + size_t *size, + acl_error *error_code) ACL_API_0_8; +//!--------------------------------------------------------------------------!// +// Functions that deal with binary image. +//!--------------------------------------------------------------------------!// +bool ACL_API_ENTRY + aclValidateBinaryImage(const void* binary, + size_t length, unsigned) ACL_API_0_8; +//!--------------------------------------------------------------------------!// +// Functions that deal with aclJITObjectImage objects. +//!--------------------------------------------------------------------------!// +aclJITObjectImage ACL_API_ENTRY +aclJITObjectImageCreate(aclCompiler *cl, const void* buffer, + size_t length, aclBinary* bin, acl_error* error_code); + +aclJITObjectImage ACL_API_ENTRY +aclJITObjectImageCopy(aclCompiler *cl, const void* buffer, + size_t length, acl_error* error_code); + +acl_error ACL_API_ENTRY +aclJITObjectImageDestroy(aclCompiler *cl, aclJITObjectImage buffer); + +acl_error ACL_API_ENTRY +aclJITObjectImageFinalize(aclCompiler *cl, aclJITObjectImage image); + +size_t ACL_API_ENTRY +aclJITObjectImageSize(aclCompiler *cl, aclJITObjectImage image, + acl_error* error_code); + +const char* ACL_API_ENTRY +aclJITObjectImageData(aclCompiler *cl, aclJITObjectImage image, + acl_error* error_code); + +size_t ACL_API_ENTRY +aclJITObjectImageGetGlobalsSize(aclCompiler *cl, aclJITObjectImage image, + acl_error* error_code); + +acl_error ACL_API_ENTRY +aclJITObjectImageIterateSymbols(aclCompiler *cl, aclJITObjectImage image, + aclJITSymbolCallback callback, void* data); + +#if defined(LEGACY_COMPLIB) +char* ACL_API_ENTRY +aclJITObjectImageDisassembleKernel(aclCompiler *cl, constAclJITObjectImage image, + const char* kernel, acl_error* error_code); +#endif + +//!--------------------------------------------------------------------------!// +// Debug functionality +//!--------------------------------------------------------------------------!// +void aclDumpBinary(const aclBinary *bin); + +//!--------------------------------------------------------------------------!// +// Functions that deal with kenel statistics. +//!--------------------------------------------------------------------------!// +void aclGetKstatsSI(const void* shader, + aclKernelStats &kstats); +acl_error ACL_API_ENTRY + aclInsertKernelStatistics(aclCompiler *cl, + aclBinary *bin); +//! Define hardware info constants for SI and above devices +const static unsigned SI_sgprs_avail = 102; +const static unsigned SI_vgprs_avail = 256; +const static unsigned SI_ldssize_avail = 32*1024; + +//!--------------------------------------------------------------------------!// +// Functions that deal with memory. +// Free memory allocated by aclWriteToMem +//!--------------------------------------------------------------------------!// +acl_error ACL_API_ENTRY +aclFreeMem(aclBinary *bin, + void *mem); +#ifdef __cplusplus +} +#endif +#endif // _ACL_0_8_H_ diff --git a/rocclr/compiler/lib/include/aclDefs.h b/rocclr/compiler/lib/include/aclDefs.h index 913aab8503..10da184217 100644 --- a/rocclr/compiler/lib/include/aclDefs.h +++ b/rocclr/compiler/lib/include/aclDefs.h @@ -1,10 +1,37 @@ // // Copyright (c) 2011 Advanced Micro Devices, Inc. All rights reserved. // -// This is a compatibility header file. Either define the version -// of the compiler library that is to be used or include the -// header file for that version directly. -#ifndef ACL_DEFS_H_ -#define ACL_DEFS_H_ -#include "v0_8/aclDefs.h" -#endif // ACL_DEFS_H_ +#ifndef _ACL_DEFS_0_8_H_ +#define _ACL_DEFS_0_8_H_ + +#ifndef ACL_API_ENTRY +#if defined(_WIN32) || defined(__CYGWIN__) +#define ACL_API_ENTRY __stdcall +#else +#define ACL_API_ENTRY +#endif +#endif + +#ifndef ACL_API_0_8 +#define ACL_API_0_8 +#endif + +#ifndef BIF_API_2_0 +#define BIF_API_2_0 +#endif + +#ifndef BIF_API_2_1 +#define BIF_API_2_1 +#endif + +#ifndef BIF_API_3_0 +#define BIF_API_3_0 +#endif + +#ifndef MAX_HIDDEN_KERNARGS_NUM +#define MAX_HIDDEN_KERNARGS_NUM 6 +#else +#error "MAX_HIDDEN_KERNARGS_NUM is already defined" +#endif + +#endif // _ACL_DEFS_0_8_H_ diff --git a/rocclr/compiler/lib/include/aclEnums.h b/rocclr/compiler/lib/include/aclEnums.h index 3d9d05406f..dd2774fe0c 100644 --- a/rocclr/compiler/lib/include/aclEnums.h +++ b/rocclr/compiler/lib/include/aclEnums.h @@ -1,10 +1,347 @@ // // Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved. // -// This is a compatibility header file. Either define the version -// of the compiler library that is to be used or include the -// header file for that version directly. -#ifndef ACL_ENUMS_H_ -#define ACL_ENUMS_H_ -#include "v0_8/aclEnums.h" -#endif // ACL_ENUMS_H_ +#ifndef _ACL_ENUMS_0_8_H_ +#define _ACL_ENUMS_0_8_H_ + +typedef enum _acl_error_enum_0_8 { + ACL_SUCCESS = 0, + ACL_ERROR = 1, + ACL_INVALID_ARG = 2, + ACL_OUT_OF_MEM = 3, + ACL_SYS_ERROR = 4, + ACL_UNSUPPORTED = 5, + ACL_ELF_ERROR = 6, + ACL_INVALID_FILE = 7, + ACL_INVALID_COMPILER= 8, + ACL_INVALID_TARGET = 9, + ACL_INVALID_BINARY = 10, + ACL_INVALID_OPTION = 11, + ACL_INVALID_TYPE = 12, + ACL_INVALID_SECTION = 13, + ACL_INVALID_SYMBOL = 14, + ACL_INVALID_QUERY = 15, + ACL_FRONTEND_FAILURE= 16, + ACL_INVALID_BITCODE = 17, + ACL_LINKER_ERROR = 18, + ACL_OPTIMIZER_ERROR = 19, + ACL_CODEGEN_ERROR = 20, + ACL_ISAGEN_ERROR = 21, + ACL_INVALID_SOURCE = 22, + ACL_LIBRARY_ERROR = 23, + ACL_INVALID_SPIR = 24, + ACL_LWVERIFY_FAIL = 25, + ACL_HWVERIFY_FAIL = 26, + ACL_SPIRV_LOAD_FAIL = 27, + ACL_SPIRV_SAVE_FAIL = 28, + ACL_LAST_ERROR = 29 +} acl_error_0_8; + +typedef enum _comp_device_caps_enum_0_8 { + capError = 0, + capFMA = 1, + capImageSupport = 2, + capSaveSOURCE = 3, // input source + capSaveLLVMIR = 4, // output LLVMIR from frontend + capSaveCG = 5, // output from LLVM-BE + capSaveEXE = 6, // output executable + capSaveAMDIL = 7, // Save per-kernel AMDIL + capSaveHSAIL = 8, // Save per-kernel HSAIL + capEncrypted = 9, + capSaveDISASM = 10, + capSaveAS = 11, + capSaveSPIR = 12, + capDumpLast = 13 +} compDeviceCaps_0_8; + +typedef enum _comp_opt_settings_enum_0_8 { + optO0 = 0, // No optimization setting. + optO1 = 1, + optO2 = 2, + optO3 = 3, + optO4 = 4, + optOs = 5, + optError = 6, // Invalid optimization set + optLast = 7 +} compOptSettings_0_8; + +#define FLAG_SHIFT_VALUE 5 +#define FLAG_MASK_VALUE ((1 << capDumpLast) - 1) +#define FLAG_BITLOC(A) (1 << ((A) & FLAG_MASK_VALUE)) +#define FLAG_ARRAY_SIZE 4 + +//! An enumeration that defines the possible valid device types that +// can be compiled for. +typedef enum _acl_dev_type_enum_0_8 { + aclError = 0, // aclDevType of 0 is an error. + aclX86 = 1, // Targeting a 32bit X86 CPU device. + aclAMDIL = 2, // Targeting an AMDIL GPU device. + aclHSAIL = 3, // Targeting an HSAIL GPU device. + aclX64 = 4, // Targeting a 64bit X86 CPU device. + aclHSAIL64= 5, // Targeting a 64bit HSAIL GPU device. + aclAMDIL64= 6, // Targeting a 64bit AMDIL GPU device + aclLast = 7 +} aclDevType_0_8; + +//! Enum that represents the versions of the compiler +typedef enum _acl_cl_version_enum_0_8 { + ACL_VERSION_ERROR = 0, + ACL_VERSION_0_7 = 1, + ACL_VERSION_0_8 = 2, + ACL_VERSION_0_8_1 = 3, + ACL_VERSION_0_9 = 4, + ACL_VERSION_1_0 = 5, + ACL_VERSION_LAST = 6 +} aclCLVersion_0_8; + +//! Enum of the various aclTypes that are supported +typedef enum _acl_type_enum_0_8 { + ACL_TYPE_DEFAULT = 0, + ACL_TYPE_OPENCL = 1, + ACL_TYPE_LLVMIR_TEXT = 2, + ACL_TYPE_LLVMIR_BINARY = 3, + ACL_TYPE_SPIR_TEXT = 4, + ACL_TYPE_SPIR_BINARY = 5, + ACL_TYPE_AMDIL_TEXT = 6, + ACL_TYPE_AMDIL_BINARY = 7, + ACL_TYPE_HSAIL_TEXT = 8, + ACL_TYPE_HSAIL_BINARY = 9, + ACL_TYPE_X86_TEXT = 10, + ACL_TYPE_X86_BINARY = 11, + ACL_TYPE_CG = 12, + ACL_TYPE_SOURCE = 13, + ACL_TYPE_ISA = 14, + ACL_TYPE_HEADER = 15, + ACL_TYPE_RSLLVMIR_BINARY = 16, + ACL_TYPE_SPIRV_BINARY = 17, + ACL_TYPE_ASM_TEXT = 18, + ACL_TYPE_LAST = 19 +} aclType_0_8; + +//! Enum of the various loader types that are supported. +typedef enum _acl_loader_type_enum_0_8 { + ACL_LOADER_COMPLIB = 0, + ACL_LOADER_FRONTEND = 1, + ACL_LOADER_LINKER = 2, + ACL_LOADER_OPTIMIZER= 3, + ACL_LOADER_CODEGEN = 4, + ACL_LOADER_BACKEND = 5, + ACL_LOADER_SC = 6, + ACL_LOADER_LAST = 7 +} aclLoaderType_0_8; + +// Enumeration for the various acl versions +typedef enum _bif_version_enum_0_8 { + aclBIFVersionError = 0, // Error + aclBIFVersion20 = 1, // Version 2.0 of the OpenCL BIF + aclBIFVersion21 = 2, // Version 2.1 of the OpenCL BIF + aclBIFVersion30 = 3, // Version 3.0 of the OpenCL BIF + aclBIFVersion31 = 4, // Version 3.1 of the OpenCL BIF + aclBIFVersionLatest = aclBIFVersion31, // Most recent version of the BIF + aclBIFVersionCAL = 5, + aclBIFVersionLast = 6 +} aclBIFVersion_0_8; + +// Enumeration for the various platform types +typedef enum _bif_platform_enum_0_8 { + aclPlatformCAL = 0, // For BIF 2.0 backward compatibility + aclPlatformCPU = 1, // For BIF 2.0 backward compatibility + aclPlatformCompLib = 2, + aclPlatformLast = 3 +} aclPlatform_0_8; + +// Enumeration for the various bif sections +typedef enum _bif_sections_enum_0_8 { + aclLLVMIR = 0, + aclSOURCE = 1, + aclILTEXT = 2, // For BIF 2.0 backward compatibility + aclASTEXT = 3, // For BIF 2.0 backward compatibility + aclCAL = 4, // For BIF 2.0 backward compatibility + aclDLL = 5, // For BIF 2.0 backward compatibility + aclSTRTAB = 6, + aclSYMTAB = 7, + aclRODATA = 8, + aclSHSTRTAB = 9, + aclNOTES = 10, + aclCOMMENT = 11, + aclILDEBUG = 12, // For BIF 2.0 backward compatibility + aclDEBUG_INFO = 13, + aclDEBUG_ABBREV = 14, + aclDEBUG_LINE = 15, + aclDEBUG_PUBNAMES = 16, + aclDEBUG_PUBTYPES = 17, + aclDEBUG_LOC = 18, + aclDEBUG_ARANGES = 19, + aclDEBUG_RANGES = 20, + aclDEBUG_MACINFO = 21, + aclDEBUG_STR = 22, + aclDEBUG_FRAME = 23, + aclJITBINARY = 24, // For BIF 2.0 backward compatibility + aclCODEGEN = 25, + aclTEXT = 26, + aclINTERNAL = 27, + aclSPIR = 28, + aclHEADER = 29, + aclBRIG = 30, + aclBRIGxxx1 = 31, + aclBRIGxxx2 = 32, + aclBRIGxxx3 = 33, + aclHSADEBUG = 34, + aclKSTATS = 35, // For storing kernel statistics + aclSPIRV = 36, + aclLAST = 37 +} aclSections_0_8; + +//! An enumeration that defines what are valid queries for aclQueryInfo. +typedef enum _rt_query_types_enum_0_8 { + RT_ABI_VERSION = 0, + RT_DEVICE_NAME = 1, + RT_MEM_SIZES = 2, + RT_GPU_FUNC_CAPS = 3, + RT_GPU_FUNC_ID = 4, + RT_GPU_DEFAULT_ID = 5, + RT_WORK_GROUP_SIZE = 6, + RT_WORK_REGION_SIZE = 7, + RT_ARGUMENT_ARRAY = 8, + RT_GPU_PRINTF_ARRAY = 9, + RT_CPU_BARRIER_NAMES = 10, + RT_DEVICE_ENQUEUE = 11, + RT_KERNEL_INDEX = 12, + RT_KERNEL_NAME = 13, + RT_KERNEL_NAMES = 14, + RT_CONTAINS_LLVMIR = 15, + RT_CONTAINS_OPTIONS = 16, + RT_CONTAINS_BRIG = 17, + RT_CONTAINS_HSAIL = 18, + RT_CONTAINS_ISA = 19, + RT_CONTAINS_LOADER_MAP = 20, + RT_CONTAINS_SPIR = 21, + RT_NUM_KERNEL_HIDDEN_ARGS = 22, + RT_CONTAINS_SPIRV = 23, + RT_WAVES_PER_SIMD_HINT = 24, + RT_WORK_GROUP_SIZE_HINT = 25, + RT_VEC_TYPE_HINT = 26, + RT_LAST_TYPE = 27 +} aclQueryType_0_8; + +//! An enumeration for the various GPU capabilities +typedef enum _rt_gpu_caps_enum_0_8 { + RT_COMPILER_WRITE = 1 << 0, + RT_DATA_SECTION = 1 << 1, + RT_WGS = 1 << 2, + RT_LIMIT_WGS = 1 << 3, + RT_PACKED_REGS = 1 << 4, + RT_64BIT_ABI = 1 << 5, + RT_PRINTF = 1 << 6, + RT_ARENA_UAV = 1 << 7, + RT_LRP_MEM = 1 << 8, // Local/Region/Private Memory + RT_INDEX_TEMPS = 1 << 9, + RT_WRS = 1 << 10, + RT_GWS = 1 << 11, + RT_SWGWS = 1 << 12, + RT_GPU_CAPS_MASK = 0xFFF +} aclGPUCaps_0_8; + +//! An enumeration for the various CPU capabilities. +typedef enum _rt_cpu_caps_enum_0_8 { + RT_KERNEL_BARRIER = 1 << 0, + RT_PROGRAM_BARRIER = 1 << 1, + RT_CPU_CAPS_MASK = 0x3 +} aclCPUCaps_0_8; + +//! An enumeration that maps Resource type to index values +typedef enum _rt_gpu_resource_enum_0_8 { + RT_RES_UAV = 0, // UAV resources + RT_RES_PRI = 1, // Private resources + RT_RES_LDS = 2, // LDS resources + RT_RES_GDS = 3, // GDS resources + RT_RES_CON = 4, // Constant resources + RT_RES_LAST = 5 +} aclGPUResource_0_8; + +//! An enumeration that maps memory types to index values +typedef enum _rt_gpu_mem_sizes_enum_0_8 { + RT_MEM_HW_LOCAL = 0, + RT_MEM_SW_LOCAL = 1, + RT_MEM_HW_PRIVATE = 2, + RT_MEM_SW_PRIVATE = 3, + RT_MEM_HW_REGION = 4, + RT_MEM_SW_REGION = 5, + RT_MEM_LAST = 6 +} aclGPUMemSizes_0_8; + +// Enumerations for the various argument types. +typedef enum _acl_arg_type_enum_0_8 { + ARG_TYPE_ERROR = 0, + ARG_TYPE_SAMPLER = 1, + ARG_TYPE_IMAGE = 2, + ARG_TYPE_COUNTER = 3, + ARG_TYPE_VALUE = 4, + ARG_TYPE_POINTER = 5, + ARG_TYPE_SEMAPHORE = 6, + ARG_TYPE_QUEUE = 7, // enum for device enqueue + ARG_TYPE_LAST = 8 +} aclArgType_0_8; + +// Enumerations of the valid data types for pass by value and +// pass by pointer kernel arguments. +typedef enum _acl_data_type_enum_0_8 { + DATATYPE_ERROR = 0, + DATATYPE_i1 = 1, + DATATYPE_i8 = 2, + DATATYPE_i16 = 3, + DATATYPE_i32 = 4, + DATATYPE_i64 = 5, + DATATYPE_u8 = 6, + DATATYPE_u16 = 7, + DATATYPE_u32 = 8, + DATATYPE_u64 = 9, + DATATYPE_f16 = 10, + DATATYPE_f32 = 11, + DATATYPE_f64 = 12, + DATATYPE_f80 = 13, + DATATYPE_f128 = 14, + DATATYPE_struct = 15, + DATATYPE_union = 16, + DATATYPE_event = 17, + DATATYPE_opaque = 18, + DATATYPE_unknown = 19, + DATATYPE_LAST = 20 +} aclArgDataType_0_8; + +// Enumerations of the valid memory types for pass by pointer +// kernel arguments +typedef enum _acl_memory_type_enum_0_8 { + PTR_MT_ERROR = 0, // Error + PTR_MT_GLOBAL = 1, // global buffer + PTR_MT_SCRATCH_EMU = 2, // SW emulated private memory + PTR_MT_LDS_EMU = 3, // SW emulated local memory + PTR_MT_UAV = 4, // uniformed access vector memory + PTR_MT_CONSTANT_EMU = 5, // SW emulated constant memory + PTR_MT_GDS_EMU = 6, // SW emulated region memory + PTR_MT_LDS = 7, // HW local memory + PTR_MT_SCRATCH = 8, // HW private memory + PTR_MT_CONSTANT = 9, // HW constant memory + PTR_MT_GDS = 10, // HW region memory + PTR_MT_UAV_SCRATCH = 11, // SI and later HW private memory + PTR_MT_UAV_CONSTANT = 12, // SI and later HW constant memory + PTR_MT_LAST = 13 +} aclMemoryType_0_8; + +// Enumeration that specifies the various access types for a pointer/image. +typedef enum _acl_access_type_enum_0_8 { + ACCESS_TYPE_ERROR = 0, + ACCESS_TYPE_RO = 1, + ACCESS_TYPE_WO = 2, + ACCESS_TYPE_RW = 3, + ACCESS_TYPE_LAST = 4 +} aclAccessType_0_8; + +// Enumeration that specifies the binary types. +typedef enum _acl_binary_image_type_enum_0_8 { + BINARY_TYPE_ELF = 1, + BINARY_TYPE_LLVM = 2, + BINARY_TYPE_SPIRV = 4, +} aclBinaryImageType_0_8; + +#endif // _ACL_ENUMS_0_8_H_ diff --git a/rocclr/compiler/lib/include/aclFunctors.h b/rocclr/compiler/lib/include/aclFunctors.h index 68ae79a6c0..382482d504 100644 --- a/rocclr/compiler/lib/include/aclFunctors.h +++ b/rocclr/compiler/lib/include/aclFunctors.h @@ -1,10 +1,230 @@ // // Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved. // -// This is a compatibility header file. Either define the version -// of the compiler library that is to be used or include the -// header file for that version directly. -#ifndef ACL_FUNCTORS_H_ -#define ACL_FUNCTORS_H_ -#include "v0_8/aclFunctors.h" -#endif // ACL_FUNCTORS_H_ +#ifndef _ACL_FUNCTORS_0_8_H_ +#define _ACL_FUNCTORS_0_8_H_ + +//! Callback for the log function function pointer that many +// API calls take to have the calling application receive +// information on what errors occur. +typedef void (*aclLogFunction_0_8)(const char *msg, size_t size); + +typedef bool (*aclJITSymbolCallback)(const char*, const void*, void*); +typedef void* aclJITObjectImage; +typedef const void* constAclJITObjectImage; + +typedef acl_error +(ACL_API_ENTRY *InsertSec_0_8)(aclCompiler *cl, + aclBinary *binary, + const void *data, + size_t data_size, + aclSections id) ACL_API_0_8; + +typedef acl_error +(ACL_API_ENTRY *InsertSym_0_8)(aclCompiler *cl, + aclBinary *binary, + const void *data, + size_t data_size, + aclSections id, + const char *symbol) ACL_API_0_8; + +typedef const void * +(ACL_API_ENTRY *ExtractSec_0_8)(aclCompiler *cl, + const aclBinary *binary, + size_t *size, + aclSections id, + acl_error *error_code) ACL_API_0_8; + +typedef const void * +(ACL_API_ENTRY *ExtractSym_0_8)(aclCompiler *cl, + const aclBinary *binary, + size_t *size, + aclSections id, + const char *symbol, + acl_error *error_code) ACL_API_0_8; + +typedef acl_error +(ACL_API_ENTRY *RemoveSec_0_8)(aclCompiler *cl, + aclBinary *binary, + aclSections id) ACL_API_0_8; + +typedef acl_error +(ACL_API_ENTRY *RemoveSym_0_8)(aclCompiler *cl, + aclBinary *binary, + aclSections id, + const char *symbol) ACL_API_0_8; + +typedef acl_error +(ACL_API_ENTRY *QueryInfo_0_8)(aclCompiler *cl, + const aclBinary *binary, + aclQueryType query, + const char *kernel, + void *data_ptr, + size_t *ptr_size) ACL_API_0_8; + +typedef acl_error +(ACL_API_ENTRY *AddDbgArg_0_8)(aclCompiler *cl, + aclBinary *bin, + const char *kernel, + const char *name, + bool byVal) ACL_API_0_8; + +typedef acl_error +(ACL_API_ENTRY *RemoveDbgArg_0_8)(aclCompiler *cl, + aclBinary *bin, + const char *kernel, + const char *name) ACL_API_0_8; + +typedef acl_error +(ACL_API_ENTRY *Compile_0_8)(aclCompiler *cl, + aclBinary *bin, + const char *options, + aclType from, + aclType to, + aclLogFunction_0_8 compile_callback) ACL_API_0_8; + +typedef acl_error +(ACL_API_ENTRY *Link_0_8)(aclCompiler *cl, + aclBinary *src_bin, + unsigned int num_libs, + aclBinary **libs, + aclType link_mode, + const char *options, + aclLogFunction_0_8 link_callback) ACL_API_0_8; + +typedef const char * +(ACL_API_ENTRY *CompLog_0_8)(aclCompiler *cl) ACL_API_0_8; + +typedef const void * +(ACL_API_ENTRY *RetrieveType_0_8)(aclCompiler *cl, + const aclBinary *bin, + const char *name, + size_t *data_size, + aclType type, + acl_error *error_code) ACL_API_0_8; + +typedef acl_error +(ACL_API_ENTRY *SetType_0_8)(aclCompiler *cl, + aclBinary *bin, + const char *name, + aclType type, + const void *data, + size_t size) ACL_API_0_8; + +typedef acl_error +(ACL_API_ENTRY *ConvertType_0_8)(aclCompiler *cl, + aclBinary *bin, + const char *name, + aclType type) ACL_API_0_8; + +typedef acl_error +(ACL_API_ENTRY *Disassemble_0_8)(aclCompiler *cl, + aclBinary *bin, + const char *kernel, + aclLogFunction_0_8 disasm_callback) ACL_API_0_8; + +typedef const void * +(ACL_API_ENTRY *GetDevBinary_0_8)(aclCompiler *cl, + const aclBinary *bin, + const char *kernel, + size_t *size, + acl_error *error_code) ACL_API_0_8; + +typedef aclLoaderData * +(ACL_API_ENTRY *LoaderInit_0_8)(aclCompiler *cl, + aclBinary *bin, + aclLogFunction_0_8 callback, + acl_error *error); + +typedef acl_error +(ACL_API_ENTRY *LoaderFini_0_8)(aclLoaderData *data); + +typedef aclModule * +(ACL_API_ENTRY *FEToIR_0_8)(aclLoaderData *ald, + const char *source, + size_t data_size, + aclContext *ctx, + acl_error *error) ACL_API_0_8; + +typedef acl_error +(ACL_API_ENTRY *SourceToISA_0_8)(aclLoaderData *ald, + const char *source, + size_t data_size) ACL_API_0_8; + +typedef aclModule * +(ACL_API_ENTRY *IRPhase_0_8)(aclLoaderData *data, + aclModule *ir, + aclContext *ctx, + acl_error *error) ACL_API_0_8; + +typedef aclModule * +(ACL_API_ENTRY *LinkPhase_0_8)(aclLoaderData *data, + aclModule *ir, + unsigned int num_libs, + aclModule **libs, + aclContext *ctx, + acl_error *error) ACL_API_0_8; + +typedef const void * +(ACL_API_ENTRY *CGPhase_0_8)(aclLoaderData *data, + aclModule *ir, + aclContext *ctx, + acl_error *error) ACL_API_0_8; + +typedef acl_error +(ACL_API_ENTRY *DisasmISA_0_8)(aclLoaderData *data, + const char *kernel, + const void *isa_code, + size_t isa_size) ACL_API_0_8; + +typedef acl_error +(ACL_API_ENTRY *SetupLoaderObject_0_8)(aclCompiler *cl) ACL_API_0_8; + +typedef aclJITObjectImage +(ACL_API_ENTRY *JITObjectImageCreate_0_8)(const void* buffer, + size_t length, + aclBinary* bin, + acl_error* error_code) ACL_API_0_8; + +typedef aclJITObjectImage +(ACL_API_ENTRY *JITObjectImageCopy_0_8)(const void* buffer, + size_t length, + acl_error* error_code) ACL_API_0_8; + +typedef acl_error +(ACL_API_ENTRY *JITObjectImageDestroy_0_8)(aclJITObjectImage image) ACL_API_0_8; + +typedef size_t +(ACL_API_ENTRY *JITObjectImageSize_0_8)(aclJITObjectImage image, + acl_error* error_code) ACL_API_0_8; + +typedef const char * +(ACL_API_ENTRY *JITObjectImageData_0_8)(aclJITObjectImage image, + acl_error* error_code) ACL_API_0_8; + +typedef acl_error +(ACL_API_ENTRY *JITObjectImageFinalize_0_8)(aclJITObjectImage image) ACL_API_0_8; + +typedef size_t +(ACL_API_ENTRY *JITObjectImageGetGlobalsSize_0_8)(aclJITObjectImage image, + acl_error* error_code) ACL_API_0_8; + +typedef bool (*JITSymbolCallback_0_8)(const char*, const void*, void*); + +typedef acl_error +(ACL_API_ENTRY *JITObjectImageIterateSymbols_0_8)(aclJITObjectImage image, + JITSymbolCallback_0_8 jit_callback, + void* data) ACL_API_0_8; + +typedef char* +(ACL_API_ENTRY *JITObjectImageDisassembleKernel_0_8)(constAclJITObjectImage image, + const char* kernel, + acl_error* error_code) ACL_API_0_8; + +typedef void* +(*AllocFunc_0_8)(size_t size) ACL_API_0_8; + +typedef void +(*FreeFunc_0_8)(void *ptr) ACL_API_0_8; + +#endif // _ACL_FUNCTORS_0_8_H_ diff --git a/rocclr/compiler/lib/include/aclStructs.h b/rocclr/compiler/lib/include/aclStructs.h index f099228ad1..479f3341b1 100644 --- a/rocclr/compiler/lib/include/aclStructs.h +++ b/rocclr/compiler/lib/include/aclStructs.h @@ -1,10 +1,349 @@ // // Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved. // -// This is a compatibility header file. Either define the version -// of the compiler library that is to be used or include the -// header file for that version directly. -#ifndef ACL_STRUCTS_H_ -#define ACL_STRUCTS_H_ -#include "v0_8/aclStructs.h" -#endif // ACL_STRUCTS_H_ +#ifndef _ACL_STRUCTS_0_8_H_ +#define _ACL_STRUCTS_0_8_H_ +#define ACL_STRUCT_HEADER \ + size_t struct_size +//! A structure that holds information on the various types of arguments +// The format in memory of this structure is +// ------------- +// | aclArgData | +// ------------- +// |->argStr | +// ------------- +// |->typeStr | +// ------------- +typedef struct _acl_md_arg_type_0_8 { + ACL_STRUCT_HEADER; + size_t argNameSize; + size_t typeStrSize; + const char *argStr; + const char *typeStr; + union { + struct { // Struct for sampler arguments + unsigned ID; + unsigned isKernelDefined; + unsigned value; + } sampler; + struct { // Struct for image arguments + unsigned resID; + unsigned cbNum; + unsigned cbOffset; + aclAccessType type; + bool is2D; + bool is1D; + bool isArray; + bool isBuffer; + } image; + struct { // struct for atomic counter arguments + unsigned is32bit; + unsigned resID; + unsigned cbNum; + unsigned cbOffset; + } counter; + struct { // struct for semaphore arguments + unsigned resID; + unsigned cbNum; + unsigned cbOffset; + } sema; + struct { // struct for pass by value arguments + unsigned numElements; + unsigned cbNum; + unsigned cbOffset; + aclArgDataType data; + } value; + struct { // struct for pass by pointer arguments + unsigned numElements; + unsigned cbNum; + unsigned cbOffset; + unsigned bufNum; + unsigned align; + aclArgDataType data; + aclMemoryType memory; + aclAccessType type; + bool isVolatile; + bool isRestrict; + bool isPipe; + } pointer; + struct { // Struct for queue arguments + unsigned numElements; + unsigned cbNum; + unsigned cbOffset; + aclArgDataType data; + aclMemoryType memory; + } queue; + } arg; + aclArgType type; + bool isConst; +} aclArgData_0_8; + +//! A structure that holds information for printf +// The format in memory of this structure is +// -------------- +// | aclPrintfFmt| +// -------------- +// |->argSizes | +// -------------- +// |->fmrStr | +// -------------- + +typedef struct _acl_md_printf_fmt_0_8 { + ACL_STRUCT_HEADER; + unsigned ID; + size_t numSizes; + size_t fmtStrSize; + uint32_t *argSizes; + const char *fmtStr; +} aclPrintfFmt_0_8; + +//! A structure that holds the metadata in the RODATA section. +typedef struct _acl_metadata_0_8 { + ACL_STRUCT_HEADER; // This holds the size of the structure itself for versioning. + size_t data_size; // This holds the size of all the memory allocated for this structure. + uint32_t major, minor, revision; // RT_ABI_VERSION + uint32_t gpuCaps; // RT_GPU_FUNC_CAPS + uint32_t funcID; // RT_GPU_FUNC_ID + uint32_t gpuRes[5]; // RT_GPU_DEFAULT_ID + size_t wgs[3]; // RT_WORK_GROUP_SIZE + uint32_t wrs[3]; // RT_WORK_REGION_SIZE + size_t kernelNameSize; + size_t deviceNameSize; + size_t mem[6]; // RT_MEM_SIZES + size_t numArgs; + size_t numPrintf; + + aclArgData_0_8 *args; // RT_ARGUMENT_ARRAY + aclPrintfFmt_0_8 *printf; // RT_GPU_PRINTF_ARRAY + const char *kernelName; // RT_KERNEL_NAME + const char *deviceName; // RT_DEVICE_NAME + bool enqueue_kernel; // RT_DEVICE_ENQUEUE + uint32_t kernel_index; // RT_KERNEL_INDEX + uint32_t numHiddenKernelArgs; // RT_NUM_KERNEL_HIDDEN_ARGS + size_t wavesPerSimdHint; // RT_WAVES_PER_SIMD_HINT + size_t wsh[3]; // RT_WORK_GROUP_SIZE_HINT + size_t vecTypeHintSize; + const char *vth; // RT_VEC_TYPE_HINT +} aclMetadata_0_8; + +//! An structure that holds information on the capabilities of the bif device. +typedef struct _acl_device_caps_rec_0_8 { + ACL_STRUCT_HEADER; + uint32_t flags[4]; + uint32_t encryptCode; +} aclDevCaps_0_8; + +//! Structure that holds information on the target that the source is +// being compiled for. +typedef struct _acl_target_info_rec_0_8 { + ACL_STRUCT_HEADER; + aclDevType arch_id; // An identifier for the architecture. + uint32_t chip_id; // A identifier for the chip. +} aclTargetInfo_0_8; + +// Structure for the version 0.8 of the structure. +typedef struct _acl_binary_opts_rec_0_8 { + ACL_STRUCT_HEADER; + uint32_t elfclass; + uint32_t bitness; + const char *temp_file; + uint32_t kernelArgAlign; +} aclBinaryOptions_0_8; + +// Structure for the version 0.8.1 of the structure. +// This versions addes in alloc/dealloc functions. +typedef struct _acl_binary_opts_rec_0_8_1 { + ACL_STRUCT_HEADER; + uint32_t elfclass; + uint32_t bitness; + const char *temp_file; + uint32_t kernelArgAlign; + AllocFunc_0_8 alloc; + FreeFunc_0_8 dealloc; +} aclBinaryOptions_0_8_1; + +//! Structure that holds the OpenCL binary information. +typedef struct _acl_bif_rec_0_8 { + ACL_STRUCT_HEADER; + aclTargetInfo_0_8 target; // Information about the target device. + aclBIF* bin; // Pointer to the acl. + aclOptions* options; // Pointer to acl options. + aclBinaryOptions_0_8 binOpts; // Pointer to the binary options. + aclDevCaps_0_8 caps; // Capabilities of the BIF. +} aclBinary_0_8; + +//! Version of the aclBinary that uses the 0_8_1 version of the aclBinaryOptions. +typedef struct _acl_bif_rec_0_8_1 { + ACL_STRUCT_HEADER; + aclTargetInfo_0_8 target; // Information about the target device. + aclBIF* bin; // Pointer to the acl. + aclOptions* options; // Pointer to acl options. + aclBinaryOptions_0_8_1 binOpts; // Pointer to the binary options. + aclDevCaps_0_8 caps; // Capabilities of the BIF. +} aclBinary_0_8_1; + +#define ACL_LOADER_COMMON\ + ACL_STRUCT_HEADER; \ +bool isBuiltin; \ +const char *libName; \ +void *handle; \ +LoaderInit init; \ +LoaderFini fini; + +// Struct that maps to the common structure between all loaders. +typedef struct _acl_common_loader_rec_0_8 { + ACL_LOADER_COMMON; +} aclCommonLoader_0_8; + +typedef struct _acl_cl_loader_rec_0_8 { + ACL_LOADER_COMMON; + Compile compile; + Link link; + CompLog getLog; + RetrieveType_0_8 retrieveType; + SetType_0_8 setType; + ConvertType_0_8 convertType; + Disassemble disassemble; + GetDevBinary_0_8 devBinary; + InsertSec insSec; + ExtractSec extSec; + RemoveSec remSec; + InsertSym insSym; + ExtractSym extSym; + RemoveSym remSym; + QueryInfo getInfo; + AddDbgArg addDbg; + RemoveDbgArg removeDbg; + SetupLoaderObject setupLoaderObject; + JITObjectImageCreate jitOICreate; + JITObjectImageCopy jitOICopy; + JITObjectImageDestroy jitOIDestroy; + JITObjectImageSize jitOISize; + JITObjectImageData jitOIData; + JITObjectImageFinalize jitOIFinalize; + JITObjectImageGetGlobalsSize jitOIGlobalSize; + JITObjectImageIterateSymbols jitOIIterateSymbols; + JITObjectImageDisassembleKernel jitOIDisassembleKernel; +} aclCLLoader_0_8; + +//! Structure that holds the required functions +// that sc exports for the SCDLL infrastructure. +typedef struct _acl_sc_loader_rec_0_8 { + ACL_LOADER_COMMON; + uint32_t /*SC_UINT32*/ sc_interface_version; + void /**SC_EXPORT_FUNCTIONS**/ *scef; + // Any version specific fields go here. +} aclSCLoader_0_8; + +typedef struct _acl_fe_loader_rec_0_8 { + ACL_LOADER_COMMON; + FEToIR toIR; // Used for Source to aclModule containing LLVMIR + FEToIR toModule; // Used to convert raw SPIR/LLVM-IR to aclModule + SourceToISA toISA; // Used for Source to ISA +} aclFELoader_0_8; + +typedef struct _acl_opt_loader_rec_0_8 { + ACL_LOADER_COMMON; + IRPhase optimize; // Used for IR to IR transformation +} aclOptLoader_0_8; + +typedef struct _acl_link_loader_rec_0_8 { + ACL_LOADER_COMMON; + LinkPhase link; // Used for Linking in IR modules + IRPhase toLLVMIR; // Used for converting SPIR to LLVMIR + IRPhase toSPIR; // Used for converting LLVMIR to SPIR +} aclLinkLoader_0_8; + +typedef struct _acl_cg_loader_rec_0_8 { + ACL_LOADER_COMMON; + CGPhase codegen; // Used for converting from LLVMIR to target ASM. +} aclCGLoader_0_8; + +typedef struct _acl_be_loader_rec_0_8 { + ACL_LOADER_COMMON; + SourceToISA finalize; // Used for converting from target source to target ISA. + SourceToISA assemble; // Used for converting from target text to target binary. + DisasmISA disassemble; // Used for converting from target binary to target ISA. +} aclBELoader_0_8; + +typedef struct _acl_compiler_opts_rec_0_8 { + ACL_STRUCT_HEADER; // Size of the structure for version checking. + const char *clLib; + const char *feLib; + const char *optLib; + const char *linkLib; + const char *cgLib; + const char *beLib; + const char *scLib; +} aclCompilerOptions_0_8; + +typedef struct _acl_compiler_opts_rec_0_8_1 { + ACL_STRUCT_HEADER; // Size of the structure for version checking. + const char* clLib; + const char *feLib; + const char *optLib; + const char *linkLib; + const char *cgLib; + const char *beLib; + const char *scLib; // Name or path to the shader compiler shared library + AllocFunc alloc; + FreeFunc dealloc; +} aclCompilerOptions_0_8_1; + +//! Structure that holds the OpenCL compiler and various loaders. +typedef struct _acl_compiler_rec_0_8 { + ACL_STRUCT_HEADER; // Size of structure for version checking. + aclCLLoader clAPI; // Pointer to the compiler API. + aclFELoader feAPI; // Pointer to the FE Loader API. + aclOptLoader optAPI; // Pointer to the Opt Loader API. + aclLinkLoader linkAPI; // Pointer to the Link Loader API. + aclCGLoader cgAPI; // Pointer to the CG Loader API. + aclBELoader beAPI; // Pointer to the BE Loader API. + aclSCLoader scAPI; // Pointer to the SC Loader API. + aclCompilerOptions *opts; // The options structure for the compiler. + void *llvm_shutdown; // Pointer to the llvm shutdown object. + char *buildLog; // Pointer to the current build log. + unsigned logSize; // Size of the current build log. + aclLoaderData *apiData; // pointer to data store for the compiler API loader. +} aclCompilerHandle_0_8; + +//! Structure that holds the OpenCL compiler and various loaders. +typedef struct _acl_compiler_rec_0_8_1 { + ACL_STRUCT_HEADER; + aclCLLoader clAPI; // Pointer to the compiler API. + aclFELoader feAPI; // Pointer to the FE Loader API. + aclOptLoader optAPI; // Pointer to the Opt Loader API. + aclLinkLoader linkAPI; // Pointer to the Link Loader API. + aclCGLoader cgAPI; // Pointer to the CG Loader API. + aclBELoader beAPI; // Pointer to the BE Loader API. + aclSCLoader scAPI; // Pointer to the SC Loader API. + AllocFunc alloc; + FreeFunc dealloc; + aclCompilerOptions *opts; // The options structure for the compiler. + void *llvm_shutdown; // Pointer to the llvm shutdown object. + char *buildLog; // Pointer to the current build log. + unsigned logSize; // Size of the current build log. + aclLoaderData *apiData; // pointer to data store for the compiler API loader. +} aclCompilerHandle_0_8_1; + +//! Structure to hold kernel statistics obtained from kernel +typedef struct _acl_kernel_stats_0_8_1 { + unsigned int scratchRegs; + unsigned int scratchSize; + unsigned int availablevgprs; + unsigned int availablesgprs; + unsigned int usedvgprs; + unsigned int usedsgprs; + unsigned int availableldssize; + unsigned int usedldssize; + unsigned int availablestacksize; + unsigned int usedstacksize; + unsigned int wavefrontsize; + unsigned int wavefrontpersimd; + unsigned int threadsperworkgroup; + unsigned int reqdworkgroup_x; + unsigned int reqdworkgroup_y; + unsigned int reqdworkgroup_z; +} aclKernelStats; + +#endif // _ACL_STRUCTS_0_8_H_ diff --git a/rocclr/compiler/lib/include/aclTypes.h b/rocclr/compiler/lib/include/aclTypes.h index a6013bb0ce..f6cb0f9598 100644 --- a/rocclr/compiler/lib/include/aclTypes.h +++ b/rocclr/compiler/lib/include/aclTypes.h @@ -1,10 +1,100 @@ // // Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved. // -// This is a compatibility header file. Either define the version -// of the compiler library that is to be used or include the -// header file for that version directly. -#ifndef ACL_TYPES_H_ -#define ACL_TYPES_H_ -#include "v0_8/aclTypes.h" -#endif // ACL_TYPES_H_ +#ifndef _ACL_API_TYPES_0_8_H_ +#define _ACL_API_TYPES_0_8_H_ +#include "aclDefs.h" +#include +#include + +// Typedefs that always point to the most recent versions of the objects. +typedef struct _acl_md_arg_type_0_8 aclArgData; +typedef struct _acl_md_printf_fmt_0_8 aclPrintfFmt; +typedef struct _acl_metadata_0_8 aclMetadata; +typedef struct _acl_device_caps_rec_0_8 aclDevCaps; +typedef struct _acl_target_info_rec_0_8 aclTargetInfo; +typedef struct _acl_bif_rec_0_8_1 aclBinary; +typedef struct _acl_binary_opts_rec_0_8_1 aclBinaryOptions; +typedef struct _acl_compiler_rec_0_8_1 aclCompiler; +typedef struct _acl_compiler_opts_rec_0_8_1 aclCompilerOptions; +typedef struct _acl_options_0_8* aclOptions; // Opaque pointer to amd::Options +typedef struct _acl_binary_0_8* aclBIF; // Opaque pointer to bifbase +typedef struct _acl_common_loader_rec_0_8 aclCommonLoader; +typedef struct _acl_cl_loader_rec_0_8 aclCLLoader; +typedef struct _acl_sc_loader_rec_0_8 aclSCLoader; +typedef struct _acl_fe_loader_rec_0_8 aclFELoader; +typedef struct _acl_link_loader_rec_0_8 aclLinkLoader; +typedef struct _acl_opt_loader_rec_0_8 aclOptLoader; +typedef struct _acl_cg_loader_rec_0_8 aclCGLoader; +typedef struct _acl_be_loader_rec_0_8 aclBELoader; +typedef struct _acl_llvm_module_0_8* aclModule; // Opaque pointer to llvm::Module +typedef struct _acl_llvm_context_0_8* aclContext; // Opaque pointer to llvm::Context +typedef struct _acl_loader_data_0_8* aclLoaderData; // Opaque pointer to loader data + +#include "aclEnums.h" +// Typedefs for enumerations +typedef enum _acl_error_enum_0_8 acl_error; +typedef enum _comp_device_caps_enum_0_8 compDeviceCaps; +typedef enum _comp_opt_settings_enum_0_8 compOptSettings; +typedef enum _acl_dev_type_enum_0_8 aclDevType; +typedef enum _acl_cl_version_enum_0_8 aclCLVersion; +typedef enum _acl_type_enum_0_8 aclType; +typedef enum _rt_query_types_enum_0_8 aclQueryType; +typedef enum _rt_gpu_caps_enum_0_8 aclGPUCaps; +typedef enum _rt_gpu_resource_enum_0_8 aclGPUResource; +typedef enum _rt_gpu_mem_sizes_enum_0_8 aclGPUMemSizes; +typedef enum _acl_arg_type_enum_0_8 aclArgType; +typedef enum _acl_data_type_enum_0_8 aclArgDataType; +typedef enum _acl_memory_type_enum_0_8 aclMemoryType; +typedef enum _acl_access_type_enum_0_8 aclAccessType; +typedef enum _bif_version_enum_0_8 aclBIFVersion; +typedef enum _bif_platform_enum_0_8 aclPlatform; +typedef enum _bif_sections_enum_0_8 aclSections; +typedef enum _acl_loader_type_enum_0_8 aclLoaderType; +typedef enum _acl_binary_image_type_enum_0_8 aclBinaryImageType; + +#include "aclFunctors.h" +// Typedefs for function pointers +typedef aclLogFunction_0_8 aclLogFunction; +typedef InsertSec_0_8 InsertSec; +typedef RemoveSec_0_8 RemoveSec; +typedef ExtractSec_0_8 ExtractSec; +typedef InsertSym_0_8 InsertSym; +typedef RemoveSym_0_8 RemoveSym; +typedef ExtractSym_0_8 ExtractSym; +typedef QueryInfo_0_8 QueryInfo; +typedef Compile_0_8 Compile; +typedef Link_0_8 Link; +typedef AddDbgArg_0_8 AddDbgArg; +typedef RemoveDbgArg_0_8 RemoveDbgArg; +typedef SetupLoaderObject_0_8 SetupLoaderObject; +typedef CompLog_0_8 CompLog; +typedef RetrieveType_0_8 RetrieveType; +typedef SetType_0_8 SetType; +typedef ConvertType_0_8 ConvertType; +typedef Disassemble_0_8 Disassemble; +typedef GetDevBinary_0_8 GetDevBinary; +typedef LoaderInit_0_8 LoaderInit; +typedef LoaderFini_0_8 LoaderFini; +typedef FEToIR_0_8 FEToIR; +typedef SourceToISA_0_8 SourceToISA; +typedef IRPhase_0_8 IRPhase; +typedef LinkPhase_0_8 LinkPhase; +typedef CGPhase_0_8 CGPhase; +typedef DisasmISA_0_8 DisasmISA; +typedef AllocFunc_0_8 AllocFunc; +typedef FreeFunc_0_8 FreeFunc; +typedef JITObjectImageCreate_0_8 JITObjectImageCreate; +typedef JITObjectImageCopy_0_8 JITObjectImageCopy; +typedef JITObjectImageDestroy_0_8 JITObjectImageDestroy; +typedef JITObjectImageSize_0_8 JITObjectImageSize; +typedef JITObjectImageData_0_8 JITObjectImageData; +typedef JITObjectImageFinalize_0_8 JITObjectImageFinalize; +typedef JITObjectImageGetGlobalsSize_0_8 JITObjectImageGetGlobalsSize; +typedef JITSymbolCallback_0_8 JITSymbolCallback; +typedef JITObjectImageIterateSymbols_0_8 JITObjectImageIterateSymbols; +typedef JITObjectImageDisassembleKernel_0_8 JITObjectImageDisassembleKernel; + +#include "aclStructs.h" + +#endif // _CL_API_TYPES_0_8_H_ diff --git a/rocclr/compiler/lib/include/v0_8/acl.h b/rocclr/compiler/lib/include/v0_8/acl.h deleted file mode 100644 index 4c44eb0fee..0000000000 --- a/rocclr/compiler/lib/include/v0_8/acl.h +++ /dev/null @@ -1,305 +0,0 @@ -// -// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _ACL_0_8_H_ -#define _ACL_0_8_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include "aclTypes.h" -//!--------------------------------------------------------------------------!// -// Functions that deal with aclCompiler objects. -//!--------------------------------------------------------------------------!// -aclCompiler* ACL_API_ENTRY -aclCompilerInit(aclCompilerOptions *opts, acl_error *error_code) ACL_API_0_8; -acl_error ACL_API_ENTRY - aclCompilerFini(aclCompiler *cl) ACL_API_0_8; -aclCLVersion ACL_API_ENTRY - aclCompilerVersion(aclCompiler *cl, acl_error *error_code) ACL_API_0_8; -uint32_t ACL_API_ENTRY - aclVersionSize(aclCLVersion num, acl_error *error_code) ACL_API_0_8; -const char* ACL_API_ENTRY - aclGetErrorString(acl_error error_code) ACL_API_0_8; - -//!--------------------------------------------------------------------------!// -// Functions that deal with target specific information. -//!--------------------------------------------------------------------------!// -//! Returns in the names argument, if non-NULL, a pointer to each of the arch -// names that the compiler supports. If names is NULL and arch_size is -// non-NULL, returns the number of arch entries that are required. -acl_error ACL_API_ENTRY - aclGetArchInfo(const char** arch_names, - size_t *arch_size) ACL_API_0_8; - -//! Returns in the arch argument, if non-NULL, a pointer to each device -// name that the compiler supports. If device_size is non-NULL, -// returns the number of device entries that are used. -acl_error ACL_API_ENTRY - aclGetDeviceInfo(const char* arch, - const char **names, - size_t *device_size) ACL_API_0_8; - -//! Function that returns a correctly filled out aclTargetInfo structure based -// on the information passed into the kernel. -aclTargetInfo ACL_API_ENTRY -aclGetTargetInfo(const char *arch, - const char *device, - acl_error *error_code) ACL_API_0_8; - -//! Function that returns a correctly filled out aclTargetInfo structure based -// on the information passed into the kernel. -aclTargetInfo ACL_API_ENTRY -aclGetTargetInfoFromChipID(const char *arch, - const uint32_t chip_id, - acl_error *error_code) ACL_API_0_8; - -//! Function that returns a string representation of the target architecture. -const char* ACL_API_ENTRY - aclGetArchitecture(const aclTargetInfo &target) ACL_API_0_8; - -//! Function that returns a string representation of the target chip options. -const uint64_t ACL_API_ENTRY - aclGetChipOptions(const aclTargetInfo &target) ACL_API_0_8; - -//! Function that returns a string representation of the target family. -const char* ACL_API_ENTRY - aclGetFamily(const aclTargetInfo &target) ACL_API_0_8; - -//! Function that returns a string representation of the target chip. -const char* ACL_API_ENTRY - aclGetChip(const aclTargetInfo &target) ACL_API_0_8; - -//!--------------------------------------------------------------------------!// -// Functions that deal with aclBinary objects. -//!--------------------------------------------------------------------------!// -aclBinary* ACL_API_ENTRY - aclBinaryInit( - size_t struct_version, - const aclTargetInfo *target, - const aclBinaryOptions *options, - acl_error *error_code) ACL_API_0_8; - -acl_error ACL_API_ENTRY - aclBinaryFini(aclBinary *bin) ACL_API_0_8; - -aclBinary* ACL_API_ENTRY - aclReadFromFile(const char *str, - acl_error *error_code) ACL_API_0_8; - -aclBinary* ACL_API_ENTRY - aclReadFromMem(const void *mem, - size_t size, acl_error *error_code) ACL_API_0_8; - -acl_error ACL_API_ENTRY - aclWriteToFile(aclBinary *bin, - const char *str) ACL_API_0_8; - -acl_error ACL_API_ENTRY - aclWriteToMem(aclBinary *bin, - void **mem, size_t *size) ACL_API_0_8; - -aclBinary* ACL_API_ENTRY - aclCreateFromBinary(const aclBinary *binary, - aclBIFVersion version) ACL_API_0_8; - -aclBIFVersion ACL_API_ENTRY - aclBinaryVersion(const aclBinary *binary) ACL_API_0_8; - -acl_error ACL_API_ENTRY - aclInsertSection(aclCompiler *cl, - aclBinary *binary, - const void *data, - size_t data_size, - aclSections id) ACL_API_0_8; - -acl_error ACL_API_ENTRY - aclInsertSymbol(aclCompiler *cl, - aclBinary *binary, - const void *data, - size_t data_size, - aclSections id, - const char *symbol) ACL_API_0_8; - -const void* ACL_API_ENTRY - aclExtractSection(aclCompiler *cl, - const aclBinary *binary, - size_t *size, - aclSections id, - acl_error *error_code) ACL_API_0_8; - -const void* ACL_API_ENTRY - aclExtractSymbol(aclCompiler *cl, - const aclBinary *binary, - size_t *size, - aclSections id, - const char *symbol, - acl_error *error_code) ACL_API_0_8; - -acl_error ACL_API_ENTRY - aclRemoveSection(aclCompiler *cl, - aclBinary *binary, - aclSections id) ACL_API_0_8; - -acl_error ACL_API_ENTRY - aclRemoveSymbol(aclCompiler *cl, - aclBinary *binary, - aclSections id, - const char *symbol) ACL_API_0_8; - -//!--------------------------------------------------------------------------!// -// Functions that deal with debug/metdata. -//!--------------------------------------------------------------------------!// -acl_error ACL_API_ENTRY - aclQueryInfo(aclCompiler *cl, - const aclBinary *binary, - aclQueryType query, - const char *kernel, - void *data_ptr, - size_t *ptr_size) ACL_API_0_8; - -acl_error ACL_API_ENTRY - aclDbgAddArgument(aclCompiler *cl, - aclBinary *binary, - const char* kernel, - const char* name, - bool byVal) - ACL_API_0_8; - -acl_error ACL_API_ENTRY - aclDbgRemoveArgument(aclCompiler *cl, - aclBinary *binary, - const char* kernel, - const char* name) - ACL_API_0_8; - -//!--------------------------------------------------------------------------!// -// Functions that deal with various compilation phases. -//!--------------------------------------------------------------------------!// -acl_error ACL_API_ENTRY - aclCompile(aclCompiler *cl, - aclBinary *bin, - const char *options, - aclType from, - aclType to, - aclLogFunction compile_callback) ACL_API_0_8; - -acl_error ACL_API_ENTRY - aclLink(aclCompiler *cl, - aclBinary *src_bin, - unsigned int num_libs, - aclBinary **libs, - aclType link_mode, - const char *options, - aclLogFunction link_callback) ACL_API_0_8; - -const char* ACL_API_ENTRY - aclGetCompilerLog(aclCompiler *cl) ACL_API_0_8; - -const void* ACL_API_ENTRY - aclRetrieveType(aclCompiler *cl, - const aclBinary *bin, - const char *name, - size_t *data_size, - aclType type, - acl_error *error_code) ACL_API_0_8; - -acl_error ACL_API_ENTRY - aclSetType(aclCompiler *cl, - aclBinary *bin, - const char *name, - aclType type, - const void *data, - size_t size) ACL_API_0_8; - -acl_error ACL_API_ENTRY - aclConvertType(aclCompiler *cl, - aclBinary *bin, - const char *name, - aclType type) ACL_API_0_8; - -acl_error ACL_API_ENTRY - aclDisassemble(aclCompiler *cl, - aclBinary *bin, - const char *kernel, - aclLogFunction disasm_callback) ACL_API_0_8; - -const void* ACL_API_ENTRY - aclGetDeviceBinary(aclCompiler *cl, - const aclBinary *bin, - const char *kernel, - size_t *size, - acl_error *error_code) ACL_API_0_8; -//!--------------------------------------------------------------------------!// -// Functions that deal with binary image. -//!--------------------------------------------------------------------------!// -bool ACL_API_ENTRY - aclValidateBinaryImage(const void* binary, - size_t length, unsigned) ACL_API_0_8; -//!--------------------------------------------------------------------------!// -// Functions that deal with aclJITObjectImage objects. -//!--------------------------------------------------------------------------!// -aclJITObjectImage ACL_API_ENTRY -aclJITObjectImageCreate(aclCompiler *cl, const void* buffer, - size_t length, aclBinary* bin, acl_error* error_code); - -aclJITObjectImage ACL_API_ENTRY -aclJITObjectImageCopy(aclCompiler *cl, const void* buffer, - size_t length, acl_error* error_code); - -acl_error ACL_API_ENTRY -aclJITObjectImageDestroy(aclCompiler *cl, aclJITObjectImage buffer); - -acl_error ACL_API_ENTRY -aclJITObjectImageFinalize(aclCompiler *cl, aclJITObjectImage image); - -size_t ACL_API_ENTRY -aclJITObjectImageSize(aclCompiler *cl, aclJITObjectImage image, - acl_error* error_code); - -const char* ACL_API_ENTRY -aclJITObjectImageData(aclCompiler *cl, aclJITObjectImage image, - acl_error* error_code); - -size_t ACL_API_ENTRY -aclJITObjectImageGetGlobalsSize(aclCompiler *cl, aclJITObjectImage image, - acl_error* error_code); - -acl_error ACL_API_ENTRY -aclJITObjectImageIterateSymbols(aclCompiler *cl, aclJITObjectImage image, - aclJITSymbolCallback callback, void* data); - -#if defined(LEGACY_COMPLIB) -char* ACL_API_ENTRY -aclJITObjectImageDisassembleKernel(aclCompiler *cl, constAclJITObjectImage image, - const char* kernel, acl_error* error_code); -#endif - -//!--------------------------------------------------------------------------!// -// Debug functionality -//!--------------------------------------------------------------------------!// -void aclDumpBinary(const aclBinary *bin); - -//!--------------------------------------------------------------------------!// -// Functions that deal with kenel statistics. -//!--------------------------------------------------------------------------!// -void aclGetKstatsSI(const void* shader, - aclKernelStats &kstats); -acl_error ACL_API_ENTRY - aclInsertKernelStatistics(aclCompiler *cl, - aclBinary *bin); -//! Define hardware info constants for SI and above devices -const static unsigned SI_sgprs_avail = 102; -const static unsigned SI_vgprs_avail = 256; -const static unsigned SI_ldssize_avail = 32*1024; - -//!--------------------------------------------------------------------------!// -// Functions that deal with memory. -// Free memory allocated by aclWriteToMem -//!--------------------------------------------------------------------------!// -acl_error ACL_API_ENTRY -aclFreeMem(aclBinary *bin, - void *mem); -#ifdef __cplusplus -} -#endif -#endif // _ACL_0_8_H_ diff --git a/rocclr/compiler/lib/include/v0_8/aclDefs.h b/rocclr/compiler/lib/include/v0_8/aclDefs.h deleted file mode 100644 index 10da184217..0000000000 --- a/rocclr/compiler/lib/include/v0_8/aclDefs.h +++ /dev/null @@ -1,37 +0,0 @@ -// -// Copyright (c) 2011 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _ACL_DEFS_0_8_H_ -#define _ACL_DEFS_0_8_H_ - -#ifndef ACL_API_ENTRY -#if defined(_WIN32) || defined(__CYGWIN__) -#define ACL_API_ENTRY __stdcall -#else -#define ACL_API_ENTRY -#endif -#endif - -#ifndef ACL_API_0_8 -#define ACL_API_0_8 -#endif - -#ifndef BIF_API_2_0 -#define BIF_API_2_0 -#endif - -#ifndef BIF_API_2_1 -#define BIF_API_2_1 -#endif - -#ifndef BIF_API_3_0 -#define BIF_API_3_0 -#endif - -#ifndef MAX_HIDDEN_KERNARGS_NUM -#define MAX_HIDDEN_KERNARGS_NUM 6 -#else -#error "MAX_HIDDEN_KERNARGS_NUM is already defined" -#endif - -#endif // _ACL_DEFS_0_8_H_ diff --git a/rocclr/compiler/lib/include/v0_8/aclEnums.h b/rocclr/compiler/lib/include/v0_8/aclEnums.h deleted file mode 100644 index dd2774fe0c..0000000000 --- a/rocclr/compiler/lib/include/v0_8/aclEnums.h +++ /dev/null @@ -1,347 +0,0 @@ -// -// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _ACL_ENUMS_0_8_H_ -#define _ACL_ENUMS_0_8_H_ - -typedef enum _acl_error_enum_0_8 { - ACL_SUCCESS = 0, - ACL_ERROR = 1, - ACL_INVALID_ARG = 2, - ACL_OUT_OF_MEM = 3, - ACL_SYS_ERROR = 4, - ACL_UNSUPPORTED = 5, - ACL_ELF_ERROR = 6, - ACL_INVALID_FILE = 7, - ACL_INVALID_COMPILER= 8, - ACL_INVALID_TARGET = 9, - ACL_INVALID_BINARY = 10, - ACL_INVALID_OPTION = 11, - ACL_INVALID_TYPE = 12, - ACL_INVALID_SECTION = 13, - ACL_INVALID_SYMBOL = 14, - ACL_INVALID_QUERY = 15, - ACL_FRONTEND_FAILURE= 16, - ACL_INVALID_BITCODE = 17, - ACL_LINKER_ERROR = 18, - ACL_OPTIMIZER_ERROR = 19, - ACL_CODEGEN_ERROR = 20, - ACL_ISAGEN_ERROR = 21, - ACL_INVALID_SOURCE = 22, - ACL_LIBRARY_ERROR = 23, - ACL_INVALID_SPIR = 24, - ACL_LWVERIFY_FAIL = 25, - ACL_HWVERIFY_FAIL = 26, - ACL_SPIRV_LOAD_FAIL = 27, - ACL_SPIRV_SAVE_FAIL = 28, - ACL_LAST_ERROR = 29 -} acl_error_0_8; - -typedef enum _comp_device_caps_enum_0_8 { - capError = 0, - capFMA = 1, - capImageSupport = 2, - capSaveSOURCE = 3, // input source - capSaveLLVMIR = 4, // output LLVMIR from frontend - capSaveCG = 5, // output from LLVM-BE - capSaveEXE = 6, // output executable - capSaveAMDIL = 7, // Save per-kernel AMDIL - capSaveHSAIL = 8, // Save per-kernel HSAIL - capEncrypted = 9, - capSaveDISASM = 10, - capSaveAS = 11, - capSaveSPIR = 12, - capDumpLast = 13 -} compDeviceCaps_0_8; - -typedef enum _comp_opt_settings_enum_0_8 { - optO0 = 0, // No optimization setting. - optO1 = 1, - optO2 = 2, - optO3 = 3, - optO4 = 4, - optOs = 5, - optError = 6, // Invalid optimization set - optLast = 7 -} compOptSettings_0_8; - -#define FLAG_SHIFT_VALUE 5 -#define FLAG_MASK_VALUE ((1 << capDumpLast) - 1) -#define FLAG_BITLOC(A) (1 << ((A) & FLAG_MASK_VALUE)) -#define FLAG_ARRAY_SIZE 4 - -//! An enumeration that defines the possible valid device types that -// can be compiled for. -typedef enum _acl_dev_type_enum_0_8 { - aclError = 0, // aclDevType of 0 is an error. - aclX86 = 1, // Targeting a 32bit X86 CPU device. - aclAMDIL = 2, // Targeting an AMDIL GPU device. - aclHSAIL = 3, // Targeting an HSAIL GPU device. - aclX64 = 4, // Targeting a 64bit X86 CPU device. - aclHSAIL64= 5, // Targeting a 64bit HSAIL GPU device. - aclAMDIL64= 6, // Targeting a 64bit AMDIL GPU device - aclLast = 7 -} aclDevType_0_8; - -//! Enum that represents the versions of the compiler -typedef enum _acl_cl_version_enum_0_8 { - ACL_VERSION_ERROR = 0, - ACL_VERSION_0_7 = 1, - ACL_VERSION_0_8 = 2, - ACL_VERSION_0_8_1 = 3, - ACL_VERSION_0_9 = 4, - ACL_VERSION_1_0 = 5, - ACL_VERSION_LAST = 6 -} aclCLVersion_0_8; - -//! Enum of the various aclTypes that are supported -typedef enum _acl_type_enum_0_8 { - ACL_TYPE_DEFAULT = 0, - ACL_TYPE_OPENCL = 1, - ACL_TYPE_LLVMIR_TEXT = 2, - ACL_TYPE_LLVMIR_BINARY = 3, - ACL_TYPE_SPIR_TEXT = 4, - ACL_TYPE_SPIR_BINARY = 5, - ACL_TYPE_AMDIL_TEXT = 6, - ACL_TYPE_AMDIL_BINARY = 7, - ACL_TYPE_HSAIL_TEXT = 8, - ACL_TYPE_HSAIL_BINARY = 9, - ACL_TYPE_X86_TEXT = 10, - ACL_TYPE_X86_BINARY = 11, - ACL_TYPE_CG = 12, - ACL_TYPE_SOURCE = 13, - ACL_TYPE_ISA = 14, - ACL_TYPE_HEADER = 15, - ACL_TYPE_RSLLVMIR_BINARY = 16, - ACL_TYPE_SPIRV_BINARY = 17, - ACL_TYPE_ASM_TEXT = 18, - ACL_TYPE_LAST = 19 -} aclType_0_8; - -//! Enum of the various loader types that are supported. -typedef enum _acl_loader_type_enum_0_8 { - ACL_LOADER_COMPLIB = 0, - ACL_LOADER_FRONTEND = 1, - ACL_LOADER_LINKER = 2, - ACL_LOADER_OPTIMIZER= 3, - ACL_LOADER_CODEGEN = 4, - ACL_LOADER_BACKEND = 5, - ACL_LOADER_SC = 6, - ACL_LOADER_LAST = 7 -} aclLoaderType_0_8; - -// Enumeration for the various acl versions -typedef enum _bif_version_enum_0_8 { - aclBIFVersionError = 0, // Error - aclBIFVersion20 = 1, // Version 2.0 of the OpenCL BIF - aclBIFVersion21 = 2, // Version 2.1 of the OpenCL BIF - aclBIFVersion30 = 3, // Version 3.0 of the OpenCL BIF - aclBIFVersion31 = 4, // Version 3.1 of the OpenCL BIF - aclBIFVersionLatest = aclBIFVersion31, // Most recent version of the BIF - aclBIFVersionCAL = 5, - aclBIFVersionLast = 6 -} aclBIFVersion_0_8; - -// Enumeration for the various platform types -typedef enum _bif_platform_enum_0_8 { - aclPlatformCAL = 0, // For BIF 2.0 backward compatibility - aclPlatformCPU = 1, // For BIF 2.0 backward compatibility - aclPlatformCompLib = 2, - aclPlatformLast = 3 -} aclPlatform_0_8; - -// Enumeration for the various bif sections -typedef enum _bif_sections_enum_0_8 { - aclLLVMIR = 0, - aclSOURCE = 1, - aclILTEXT = 2, // For BIF 2.0 backward compatibility - aclASTEXT = 3, // For BIF 2.0 backward compatibility - aclCAL = 4, // For BIF 2.0 backward compatibility - aclDLL = 5, // For BIF 2.0 backward compatibility - aclSTRTAB = 6, - aclSYMTAB = 7, - aclRODATA = 8, - aclSHSTRTAB = 9, - aclNOTES = 10, - aclCOMMENT = 11, - aclILDEBUG = 12, // For BIF 2.0 backward compatibility - aclDEBUG_INFO = 13, - aclDEBUG_ABBREV = 14, - aclDEBUG_LINE = 15, - aclDEBUG_PUBNAMES = 16, - aclDEBUG_PUBTYPES = 17, - aclDEBUG_LOC = 18, - aclDEBUG_ARANGES = 19, - aclDEBUG_RANGES = 20, - aclDEBUG_MACINFO = 21, - aclDEBUG_STR = 22, - aclDEBUG_FRAME = 23, - aclJITBINARY = 24, // For BIF 2.0 backward compatibility - aclCODEGEN = 25, - aclTEXT = 26, - aclINTERNAL = 27, - aclSPIR = 28, - aclHEADER = 29, - aclBRIG = 30, - aclBRIGxxx1 = 31, - aclBRIGxxx2 = 32, - aclBRIGxxx3 = 33, - aclHSADEBUG = 34, - aclKSTATS = 35, // For storing kernel statistics - aclSPIRV = 36, - aclLAST = 37 -} aclSections_0_8; - -//! An enumeration that defines what are valid queries for aclQueryInfo. -typedef enum _rt_query_types_enum_0_8 { - RT_ABI_VERSION = 0, - RT_DEVICE_NAME = 1, - RT_MEM_SIZES = 2, - RT_GPU_FUNC_CAPS = 3, - RT_GPU_FUNC_ID = 4, - RT_GPU_DEFAULT_ID = 5, - RT_WORK_GROUP_SIZE = 6, - RT_WORK_REGION_SIZE = 7, - RT_ARGUMENT_ARRAY = 8, - RT_GPU_PRINTF_ARRAY = 9, - RT_CPU_BARRIER_NAMES = 10, - RT_DEVICE_ENQUEUE = 11, - RT_KERNEL_INDEX = 12, - RT_KERNEL_NAME = 13, - RT_KERNEL_NAMES = 14, - RT_CONTAINS_LLVMIR = 15, - RT_CONTAINS_OPTIONS = 16, - RT_CONTAINS_BRIG = 17, - RT_CONTAINS_HSAIL = 18, - RT_CONTAINS_ISA = 19, - RT_CONTAINS_LOADER_MAP = 20, - RT_CONTAINS_SPIR = 21, - RT_NUM_KERNEL_HIDDEN_ARGS = 22, - RT_CONTAINS_SPIRV = 23, - RT_WAVES_PER_SIMD_HINT = 24, - RT_WORK_GROUP_SIZE_HINT = 25, - RT_VEC_TYPE_HINT = 26, - RT_LAST_TYPE = 27 -} aclQueryType_0_8; - -//! An enumeration for the various GPU capabilities -typedef enum _rt_gpu_caps_enum_0_8 { - RT_COMPILER_WRITE = 1 << 0, - RT_DATA_SECTION = 1 << 1, - RT_WGS = 1 << 2, - RT_LIMIT_WGS = 1 << 3, - RT_PACKED_REGS = 1 << 4, - RT_64BIT_ABI = 1 << 5, - RT_PRINTF = 1 << 6, - RT_ARENA_UAV = 1 << 7, - RT_LRP_MEM = 1 << 8, // Local/Region/Private Memory - RT_INDEX_TEMPS = 1 << 9, - RT_WRS = 1 << 10, - RT_GWS = 1 << 11, - RT_SWGWS = 1 << 12, - RT_GPU_CAPS_MASK = 0xFFF -} aclGPUCaps_0_8; - -//! An enumeration for the various CPU capabilities. -typedef enum _rt_cpu_caps_enum_0_8 { - RT_KERNEL_BARRIER = 1 << 0, - RT_PROGRAM_BARRIER = 1 << 1, - RT_CPU_CAPS_MASK = 0x3 -} aclCPUCaps_0_8; - -//! An enumeration that maps Resource type to index values -typedef enum _rt_gpu_resource_enum_0_8 { - RT_RES_UAV = 0, // UAV resources - RT_RES_PRI = 1, // Private resources - RT_RES_LDS = 2, // LDS resources - RT_RES_GDS = 3, // GDS resources - RT_RES_CON = 4, // Constant resources - RT_RES_LAST = 5 -} aclGPUResource_0_8; - -//! An enumeration that maps memory types to index values -typedef enum _rt_gpu_mem_sizes_enum_0_8 { - RT_MEM_HW_LOCAL = 0, - RT_MEM_SW_LOCAL = 1, - RT_MEM_HW_PRIVATE = 2, - RT_MEM_SW_PRIVATE = 3, - RT_MEM_HW_REGION = 4, - RT_MEM_SW_REGION = 5, - RT_MEM_LAST = 6 -} aclGPUMemSizes_0_8; - -// Enumerations for the various argument types. -typedef enum _acl_arg_type_enum_0_8 { - ARG_TYPE_ERROR = 0, - ARG_TYPE_SAMPLER = 1, - ARG_TYPE_IMAGE = 2, - ARG_TYPE_COUNTER = 3, - ARG_TYPE_VALUE = 4, - ARG_TYPE_POINTER = 5, - ARG_TYPE_SEMAPHORE = 6, - ARG_TYPE_QUEUE = 7, // enum for device enqueue - ARG_TYPE_LAST = 8 -} aclArgType_0_8; - -// Enumerations of the valid data types for pass by value and -// pass by pointer kernel arguments. -typedef enum _acl_data_type_enum_0_8 { - DATATYPE_ERROR = 0, - DATATYPE_i1 = 1, - DATATYPE_i8 = 2, - DATATYPE_i16 = 3, - DATATYPE_i32 = 4, - DATATYPE_i64 = 5, - DATATYPE_u8 = 6, - DATATYPE_u16 = 7, - DATATYPE_u32 = 8, - DATATYPE_u64 = 9, - DATATYPE_f16 = 10, - DATATYPE_f32 = 11, - DATATYPE_f64 = 12, - DATATYPE_f80 = 13, - DATATYPE_f128 = 14, - DATATYPE_struct = 15, - DATATYPE_union = 16, - DATATYPE_event = 17, - DATATYPE_opaque = 18, - DATATYPE_unknown = 19, - DATATYPE_LAST = 20 -} aclArgDataType_0_8; - -// Enumerations of the valid memory types for pass by pointer -// kernel arguments -typedef enum _acl_memory_type_enum_0_8 { - PTR_MT_ERROR = 0, // Error - PTR_MT_GLOBAL = 1, // global buffer - PTR_MT_SCRATCH_EMU = 2, // SW emulated private memory - PTR_MT_LDS_EMU = 3, // SW emulated local memory - PTR_MT_UAV = 4, // uniformed access vector memory - PTR_MT_CONSTANT_EMU = 5, // SW emulated constant memory - PTR_MT_GDS_EMU = 6, // SW emulated region memory - PTR_MT_LDS = 7, // HW local memory - PTR_MT_SCRATCH = 8, // HW private memory - PTR_MT_CONSTANT = 9, // HW constant memory - PTR_MT_GDS = 10, // HW region memory - PTR_MT_UAV_SCRATCH = 11, // SI and later HW private memory - PTR_MT_UAV_CONSTANT = 12, // SI and later HW constant memory - PTR_MT_LAST = 13 -} aclMemoryType_0_8; - -// Enumeration that specifies the various access types for a pointer/image. -typedef enum _acl_access_type_enum_0_8 { - ACCESS_TYPE_ERROR = 0, - ACCESS_TYPE_RO = 1, - ACCESS_TYPE_WO = 2, - ACCESS_TYPE_RW = 3, - ACCESS_TYPE_LAST = 4 -} aclAccessType_0_8; - -// Enumeration that specifies the binary types. -typedef enum _acl_binary_image_type_enum_0_8 { - BINARY_TYPE_ELF = 1, - BINARY_TYPE_LLVM = 2, - BINARY_TYPE_SPIRV = 4, -} aclBinaryImageType_0_8; - -#endif // _ACL_ENUMS_0_8_H_ diff --git a/rocclr/compiler/lib/include/v0_8/aclFunctors.h b/rocclr/compiler/lib/include/v0_8/aclFunctors.h deleted file mode 100644 index 382482d504..0000000000 --- a/rocclr/compiler/lib/include/v0_8/aclFunctors.h +++ /dev/null @@ -1,230 +0,0 @@ -// -// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _ACL_FUNCTORS_0_8_H_ -#define _ACL_FUNCTORS_0_8_H_ - -//! Callback for the log function function pointer that many -// API calls take to have the calling application receive -// information on what errors occur. -typedef void (*aclLogFunction_0_8)(const char *msg, size_t size); - -typedef bool (*aclJITSymbolCallback)(const char*, const void*, void*); -typedef void* aclJITObjectImage; -typedef const void* constAclJITObjectImage; - -typedef acl_error -(ACL_API_ENTRY *InsertSec_0_8)(aclCompiler *cl, - aclBinary *binary, - const void *data, - size_t data_size, - aclSections id) ACL_API_0_8; - -typedef acl_error -(ACL_API_ENTRY *InsertSym_0_8)(aclCompiler *cl, - aclBinary *binary, - const void *data, - size_t data_size, - aclSections id, - const char *symbol) ACL_API_0_8; - -typedef const void * -(ACL_API_ENTRY *ExtractSec_0_8)(aclCompiler *cl, - const aclBinary *binary, - size_t *size, - aclSections id, - acl_error *error_code) ACL_API_0_8; - -typedef const void * -(ACL_API_ENTRY *ExtractSym_0_8)(aclCompiler *cl, - const aclBinary *binary, - size_t *size, - aclSections id, - const char *symbol, - acl_error *error_code) ACL_API_0_8; - -typedef acl_error -(ACL_API_ENTRY *RemoveSec_0_8)(aclCompiler *cl, - aclBinary *binary, - aclSections id) ACL_API_0_8; - -typedef acl_error -(ACL_API_ENTRY *RemoveSym_0_8)(aclCompiler *cl, - aclBinary *binary, - aclSections id, - const char *symbol) ACL_API_0_8; - -typedef acl_error -(ACL_API_ENTRY *QueryInfo_0_8)(aclCompiler *cl, - const aclBinary *binary, - aclQueryType query, - const char *kernel, - void *data_ptr, - size_t *ptr_size) ACL_API_0_8; - -typedef acl_error -(ACL_API_ENTRY *AddDbgArg_0_8)(aclCompiler *cl, - aclBinary *bin, - const char *kernel, - const char *name, - bool byVal) ACL_API_0_8; - -typedef acl_error -(ACL_API_ENTRY *RemoveDbgArg_0_8)(aclCompiler *cl, - aclBinary *bin, - const char *kernel, - const char *name) ACL_API_0_8; - -typedef acl_error -(ACL_API_ENTRY *Compile_0_8)(aclCompiler *cl, - aclBinary *bin, - const char *options, - aclType from, - aclType to, - aclLogFunction_0_8 compile_callback) ACL_API_0_8; - -typedef acl_error -(ACL_API_ENTRY *Link_0_8)(aclCompiler *cl, - aclBinary *src_bin, - unsigned int num_libs, - aclBinary **libs, - aclType link_mode, - const char *options, - aclLogFunction_0_8 link_callback) ACL_API_0_8; - -typedef const char * -(ACL_API_ENTRY *CompLog_0_8)(aclCompiler *cl) ACL_API_0_8; - -typedef const void * -(ACL_API_ENTRY *RetrieveType_0_8)(aclCompiler *cl, - const aclBinary *bin, - const char *name, - size_t *data_size, - aclType type, - acl_error *error_code) ACL_API_0_8; - -typedef acl_error -(ACL_API_ENTRY *SetType_0_8)(aclCompiler *cl, - aclBinary *bin, - const char *name, - aclType type, - const void *data, - size_t size) ACL_API_0_8; - -typedef acl_error -(ACL_API_ENTRY *ConvertType_0_8)(aclCompiler *cl, - aclBinary *bin, - const char *name, - aclType type) ACL_API_0_8; - -typedef acl_error -(ACL_API_ENTRY *Disassemble_0_8)(aclCompiler *cl, - aclBinary *bin, - const char *kernel, - aclLogFunction_0_8 disasm_callback) ACL_API_0_8; - -typedef const void * -(ACL_API_ENTRY *GetDevBinary_0_8)(aclCompiler *cl, - const aclBinary *bin, - const char *kernel, - size_t *size, - acl_error *error_code) ACL_API_0_8; - -typedef aclLoaderData * -(ACL_API_ENTRY *LoaderInit_0_8)(aclCompiler *cl, - aclBinary *bin, - aclLogFunction_0_8 callback, - acl_error *error); - -typedef acl_error -(ACL_API_ENTRY *LoaderFini_0_8)(aclLoaderData *data); - -typedef aclModule * -(ACL_API_ENTRY *FEToIR_0_8)(aclLoaderData *ald, - const char *source, - size_t data_size, - aclContext *ctx, - acl_error *error) ACL_API_0_8; - -typedef acl_error -(ACL_API_ENTRY *SourceToISA_0_8)(aclLoaderData *ald, - const char *source, - size_t data_size) ACL_API_0_8; - -typedef aclModule * -(ACL_API_ENTRY *IRPhase_0_8)(aclLoaderData *data, - aclModule *ir, - aclContext *ctx, - acl_error *error) ACL_API_0_8; - -typedef aclModule * -(ACL_API_ENTRY *LinkPhase_0_8)(aclLoaderData *data, - aclModule *ir, - unsigned int num_libs, - aclModule **libs, - aclContext *ctx, - acl_error *error) ACL_API_0_8; - -typedef const void * -(ACL_API_ENTRY *CGPhase_0_8)(aclLoaderData *data, - aclModule *ir, - aclContext *ctx, - acl_error *error) ACL_API_0_8; - -typedef acl_error -(ACL_API_ENTRY *DisasmISA_0_8)(aclLoaderData *data, - const char *kernel, - const void *isa_code, - size_t isa_size) ACL_API_0_8; - -typedef acl_error -(ACL_API_ENTRY *SetupLoaderObject_0_8)(aclCompiler *cl) ACL_API_0_8; - -typedef aclJITObjectImage -(ACL_API_ENTRY *JITObjectImageCreate_0_8)(const void* buffer, - size_t length, - aclBinary* bin, - acl_error* error_code) ACL_API_0_8; - -typedef aclJITObjectImage -(ACL_API_ENTRY *JITObjectImageCopy_0_8)(const void* buffer, - size_t length, - acl_error* error_code) ACL_API_0_8; - -typedef acl_error -(ACL_API_ENTRY *JITObjectImageDestroy_0_8)(aclJITObjectImage image) ACL_API_0_8; - -typedef size_t -(ACL_API_ENTRY *JITObjectImageSize_0_8)(aclJITObjectImage image, - acl_error* error_code) ACL_API_0_8; - -typedef const char * -(ACL_API_ENTRY *JITObjectImageData_0_8)(aclJITObjectImage image, - acl_error* error_code) ACL_API_0_8; - -typedef acl_error -(ACL_API_ENTRY *JITObjectImageFinalize_0_8)(aclJITObjectImage image) ACL_API_0_8; - -typedef size_t -(ACL_API_ENTRY *JITObjectImageGetGlobalsSize_0_8)(aclJITObjectImage image, - acl_error* error_code) ACL_API_0_8; - -typedef bool (*JITSymbolCallback_0_8)(const char*, const void*, void*); - -typedef acl_error -(ACL_API_ENTRY *JITObjectImageIterateSymbols_0_8)(aclJITObjectImage image, - JITSymbolCallback_0_8 jit_callback, - void* data) ACL_API_0_8; - -typedef char* -(ACL_API_ENTRY *JITObjectImageDisassembleKernel_0_8)(constAclJITObjectImage image, - const char* kernel, - acl_error* error_code) ACL_API_0_8; - -typedef void* -(*AllocFunc_0_8)(size_t size) ACL_API_0_8; - -typedef void -(*FreeFunc_0_8)(void *ptr) ACL_API_0_8; - -#endif // _ACL_FUNCTORS_0_8_H_ diff --git a/rocclr/compiler/lib/include/v0_8/aclStructs.h b/rocclr/compiler/lib/include/v0_8/aclStructs.h deleted file mode 100644 index 479f3341b1..0000000000 --- a/rocclr/compiler/lib/include/v0_8/aclStructs.h +++ /dev/null @@ -1,349 +0,0 @@ -// -// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _ACL_STRUCTS_0_8_H_ -#define _ACL_STRUCTS_0_8_H_ -#define ACL_STRUCT_HEADER \ - size_t struct_size -//! A structure that holds information on the various types of arguments -// The format in memory of this structure is -// ------------- -// | aclArgData | -// ------------- -// |->argStr | -// ------------- -// |->typeStr | -// ------------- -typedef struct _acl_md_arg_type_0_8 { - ACL_STRUCT_HEADER; - size_t argNameSize; - size_t typeStrSize; - const char *argStr; - const char *typeStr; - union { - struct { // Struct for sampler arguments - unsigned ID; - unsigned isKernelDefined; - unsigned value; - } sampler; - struct { // Struct for image arguments - unsigned resID; - unsigned cbNum; - unsigned cbOffset; - aclAccessType type; - bool is2D; - bool is1D; - bool isArray; - bool isBuffer; - } image; - struct { // struct for atomic counter arguments - unsigned is32bit; - unsigned resID; - unsigned cbNum; - unsigned cbOffset; - } counter; - struct { // struct for semaphore arguments - unsigned resID; - unsigned cbNum; - unsigned cbOffset; - } sema; - struct { // struct for pass by value arguments - unsigned numElements; - unsigned cbNum; - unsigned cbOffset; - aclArgDataType data; - } value; - struct { // struct for pass by pointer arguments - unsigned numElements; - unsigned cbNum; - unsigned cbOffset; - unsigned bufNum; - unsigned align; - aclArgDataType data; - aclMemoryType memory; - aclAccessType type; - bool isVolatile; - bool isRestrict; - bool isPipe; - } pointer; - struct { // Struct for queue arguments - unsigned numElements; - unsigned cbNum; - unsigned cbOffset; - aclArgDataType data; - aclMemoryType memory; - } queue; - } arg; - aclArgType type; - bool isConst; -} aclArgData_0_8; - -//! A structure that holds information for printf -// The format in memory of this structure is -// -------------- -// | aclPrintfFmt| -// -------------- -// |->argSizes | -// -------------- -// |->fmrStr | -// -------------- - -typedef struct _acl_md_printf_fmt_0_8 { - ACL_STRUCT_HEADER; - unsigned ID; - size_t numSizes; - size_t fmtStrSize; - uint32_t *argSizes; - const char *fmtStr; -} aclPrintfFmt_0_8; - -//! A structure that holds the metadata in the RODATA section. -typedef struct _acl_metadata_0_8 { - ACL_STRUCT_HEADER; // This holds the size of the structure itself for versioning. - size_t data_size; // This holds the size of all the memory allocated for this structure. - uint32_t major, minor, revision; // RT_ABI_VERSION - uint32_t gpuCaps; // RT_GPU_FUNC_CAPS - uint32_t funcID; // RT_GPU_FUNC_ID - uint32_t gpuRes[5]; // RT_GPU_DEFAULT_ID - size_t wgs[3]; // RT_WORK_GROUP_SIZE - uint32_t wrs[3]; // RT_WORK_REGION_SIZE - size_t kernelNameSize; - size_t deviceNameSize; - size_t mem[6]; // RT_MEM_SIZES - size_t numArgs; - size_t numPrintf; - - aclArgData_0_8 *args; // RT_ARGUMENT_ARRAY - aclPrintfFmt_0_8 *printf; // RT_GPU_PRINTF_ARRAY - const char *kernelName; // RT_KERNEL_NAME - const char *deviceName; // RT_DEVICE_NAME - bool enqueue_kernel; // RT_DEVICE_ENQUEUE - uint32_t kernel_index; // RT_KERNEL_INDEX - uint32_t numHiddenKernelArgs; // RT_NUM_KERNEL_HIDDEN_ARGS - size_t wavesPerSimdHint; // RT_WAVES_PER_SIMD_HINT - size_t wsh[3]; // RT_WORK_GROUP_SIZE_HINT - size_t vecTypeHintSize; - const char *vth; // RT_VEC_TYPE_HINT -} aclMetadata_0_8; - -//! An structure that holds information on the capabilities of the bif device. -typedef struct _acl_device_caps_rec_0_8 { - ACL_STRUCT_HEADER; - uint32_t flags[4]; - uint32_t encryptCode; -} aclDevCaps_0_8; - -//! Structure that holds information on the target that the source is -// being compiled for. -typedef struct _acl_target_info_rec_0_8 { - ACL_STRUCT_HEADER; - aclDevType arch_id; // An identifier for the architecture. - uint32_t chip_id; // A identifier for the chip. -} aclTargetInfo_0_8; - -// Structure for the version 0.8 of the structure. -typedef struct _acl_binary_opts_rec_0_8 { - ACL_STRUCT_HEADER; - uint32_t elfclass; - uint32_t bitness; - const char *temp_file; - uint32_t kernelArgAlign; -} aclBinaryOptions_0_8; - -// Structure for the version 0.8.1 of the structure. -// This versions addes in alloc/dealloc functions. -typedef struct _acl_binary_opts_rec_0_8_1 { - ACL_STRUCT_HEADER; - uint32_t elfclass; - uint32_t bitness; - const char *temp_file; - uint32_t kernelArgAlign; - AllocFunc_0_8 alloc; - FreeFunc_0_8 dealloc; -} aclBinaryOptions_0_8_1; - -//! Structure that holds the OpenCL binary information. -typedef struct _acl_bif_rec_0_8 { - ACL_STRUCT_HEADER; - aclTargetInfo_0_8 target; // Information about the target device. - aclBIF* bin; // Pointer to the acl. - aclOptions* options; // Pointer to acl options. - aclBinaryOptions_0_8 binOpts; // Pointer to the binary options. - aclDevCaps_0_8 caps; // Capabilities of the BIF. -} aclBinary_0_8; - -//! Version of the aclBinary that uses the 0_8_1 version of the aclBinaryOptions. -typedef struct _acl_bif_rec_0_8_1 { - ACL_STRUCT_HEADER; - aclTargetInfo_0_8 target; // Information about the target device. - aclBIF* bin; // Pointer to the acl. - aclOptions* options; // Pointer to acl options. - aclBinaryOptions_0_8_1 binOpts; // Pointer to the binary options. - aclDevCaps_0_8 caps; // Capabilities of the BIF. -} aclBinary_0_8_1; - -#define ACL_LOADER_COMMON\ - ACL_STRUCT_HEADER; \ -bool isBuiltin; \ -const char *libName; \ -void *handle; \ -LoaderInit init; \ -LoaderFini fini; - -// Struct that maps to the common structure between all loaders. -typedef struct _acl_common_loader_rec_0_8 { - ACL_LOADER_COMMON; -} aclCommonLoader_0_8; - -typedef struct _acl_cl_loader_rec_0_8 { - ACL_LOADER_COMMON; - Compile compile; - Link link; - CompLog getLog; - RetrieveType_0_8 retrieveType; - SetType_0_8 setType; - ConvertType_0_8 convertType; - Disassemble disassemble; - GetDevBinary_0_8 devBinary; - InsertSec insSec; - ExtractSec extSec; - RemoveSec remSec; - InsertSym insSym; - ExtractSym extSym; - RemoveSym remSym; - QueryInfo getInfo; - AddDbgArg addDbg; - RemoveDbgArg removeDbg; - SetupLoaderObject setupLoaderObject; - JITObjectImageCreate jitOICreate; - JITObjectImageCopy jitOICopy; - JITObjectImageDestroy jitOIDestroy; - JITObjectImageSize jitOISize; - JITObjectImageData jitOIData; - JITObjectImageFinalize jitOIFinalize; - JITObjectImageGetGlobalsSize jitOIGlobalSize; - JITObjectImageIterateSymbols jitOIIterateSymbols; - JITObjectImageDisassembleKernel jitOIDisassembleKernel; -} aclCLLoader_0_8; - -//! Structure that holds the required functions -// that sc exports for the SCDLL infrastructure. -typedef struct _acl_sc_loader_rec_0_8 { - ACL_LOADER_COMMON; - uint32_t /*SC_UINT32*/ sc_interface_version; - void /**SC_EXPORT_FUNCTIONS**/ *scef; - // Any version specific fields go here. -} aclSCLoader_0_8; - -typedef struct _acl_fe_loader_rec_0_8 { - ACL_LOADER_COMMON; - FEToIR toIR; // Used for Source to aclModule containing LLVMIR - FEToIR toModule; // Used to convert raw SPIR/LLVM-IR to aclModule - SourceToISA toISA; // Used for Source to ISA -} aclFELoader_0_8; - -typedef struct _acl_opt_loader_rec_0_8 { - ACL_LOADER_COMMON; - IRPhase optimize; // Used for IR to IR transformation -} aclOptLoader_0_8; - -typedef struct _acl_link_loader_rec_0_8 { - ACL_LOADER_COMMON; - LinkPhase link; // Used for Linking in IR modules - IRPhase toLLVMIR; // Used for converting SPIR to LLVMIR - IRPhase toSPIR; // Used for converting LLVMIR to SPIR -} aclLinkLoader_0_8; - -typedef struct _acl_cg_loader_rec_0_8 { - ACL_LOADER_COMMON; - CGPhase codegen; // Used for converting from LLVMIR to target ASM. -} aclCGLoader_0_8; - -typedef struct _acl_be_loader_rec_0_8 { - ACL_LOADER_COMMON; - SourceToISA finalize; // Used for converting from target source to target ISA. - SourceToISA assemble; // Used for converting from target text to target binary. - DisasmISA disassemble; // Used for converting from target binary to target ISA. -} aclBELoader_0_8; - -typedef struct _acl_compiler_opts_rec_0_8 { - ACL_STRUCT_HEADER; // Size of the structure for version checking. - const char *clLib; - const char *feLib; - const char *optLib; - const char *linkLib; - const char *cgLib; - const char *beLib; - const char *scLib; -} aclCompilerOptions_0_8; - -typedef struct _acl_compiler_opts_rec_0_8_1 { - ACL_STRUCT_HEADER; // Size of the structure for version checking. - const char* clLib; - const char *feLib; - const char *optLib; - const char *linkLib; - const char *cgLib; - const char *beLib; - const char *scLib; // Name or path to the shader compiler shared library - AllocFunc alloc; - FreeFunc dealloc; -} aclCompilerOptions_0_8_1; - -//! Structure that holds the OpenCL compiler and various loaders. -typedef struct _acl_compiler_rec_0_8 { - ACL_STRUCT_HEADER; // Size of structure for version checking. - aclCLLoader clAPI; // Pointer to the compiler API. - aclFELoader feAPI; // Pointer to the FE Loader API. - aclOptLoader optAPI; // Pointer to the Opt Loader API. - aclLinkLoader linkAPI; // Pointer to the Link Loader API. - aclCGLoader cgAPI; // Pointer to the CG Loader API. - aclBELoader beAPI; // Pointer to the BE Loader API. - aclSCLoader scAPI; // Pointer to the SC Loader API. - aclCompilerOptions *opts; // The options structure for the compiler. - void *llvm_shutdown; // Pointer to the llvm shutdown object. - char *buildLog; // Pointer to the current build log. - unsigned logSize; // Size of the current build log. - aclLoaderData *apiData; // pointer to data store for the compiler API loader. -} aclCompilerHandle_0_8; - -//! Structure that holds the OpenCL compiler and various loaders. -typedef struct _acl_compiler_rec_0_8_1 { - ACL_STRUCT_HEADER; - aclCLLoader clAPI; // Pointer to the compiler API. - aclFELoader feAPI; // Pointer to the FE Loader API. - aclOptLoader optAPI; // Pointer to the Opt Loader API. - aclLinkLoader linkAPI; // Pointer to the Link Loader API. - aclCGLoader cgAPI; // Pointer to the CG Loader API. - aclBELoader beAPI; // Pointer to the BE Loader API. - aclSCLoader scAPI; // Pointer to the SC Loader API. - AllocFunc alloc; - FreeFunc dealloc; - aclCompilerOptions *opts; // The options structure for the compiler. - void *llvm_shutdown; // Pointer to the llvm shutdown object. - char *buildLog; // Pointer to the current build log. - unsigned logSize; // Size of the current build log. - aclLoaderData *apiData; // pointer to data store for the compiler API loader. -} aclCompilerHandle_0_8_1; - -//! Structure to hold kernel statistics obtained from kernel -typedef struct _acl_kernel_stats_0_8_1 { - unsigned int scratchRegs; - unsigned int scratchSize; - unsigned int availablevgprs; - unsigned int availablesgprs; - unsigned int usedvgprs; - unsigned int usedsgprs; - unsigned int availableldssize; - unsigned int usedldssize; - unsigned int availablestacksize; - unsigned int usedstacksize; - unsigned int wavefrontsize; - unsigned int wavefrontpersimd; - unsigned int threadsperworkgroup; - unsigned int reqdworkgroup_x; - unsigned int reqdworkgroup_y; - unsigned int reqdworkgroup_z; -} aclKernelStats; - -#endif // _ACL_STRUCTS_0_8_H_ diff --git a/rocclr/compiler/lib/include/v0_8/aclTypes.h b/rocclr/compiler/lib/include/v0_8/aclTypes.h deleted file mode 100644 index f6cb0f9598..0000000000 --- a/rocclr/compiler/lib/include/v0_8/aclTypes.h +++ /dev/null @@ -1,100 +0,0 @@ -// -// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _ACL_API_TYPES_0_8_H_ -#define _ACL_API_TYPES_0_8_H_ -#include "aclDefs.h" -#include -#include - -// Typedefs that always point to the most recent versions of the objects. -typedef struct _acl_md_arg_type_0_8 aclArgData; -typedef struct _acl_md_printf_fmt_0_8 aclPrintfFmt; -typedef struct _acl_metadata_0_8 aclMetadata; -typedef struct _acl_device_caps_rec_0_8 aclDevCaps; -typedef struct _acl_target_info_rec_0_8 aclTargetInfo; -typedef struct _acl_bif_rec_0_8_1 aclBinary; -typedef struct _acl_binary_opts_rec_0_8_1 aclBinaryOptions; -typedef struct _acl_compiler_rec_0_8_1 aclCompiler; -typedef struct _acl_compiler_opts_rec_0_8_1 aclCompilerOptions; -typedef struct _acl_options_0_8* aclOptions; // Opaque pointer to amd::Options -typedef struct _acl_binary_0_8* aclBIF; // Opaque pointer to bifbase -typedef struct _acl_common_loader_rec_0_8 aclCommonLoader; -typedef struct _acl_cl_loader_rec_0_8 aclCLLoader; -typedef struct _acl_sc_loader_rec_0_8 aclSCLoader; -typedef struct _acl_fe_loader_rec_0_8 aclFELoader; -typedef struct _acl_link_loader_rec_0_8 aclLinkLoader; -typedef struct _acl_opt_loader_rec_0_8 aclOptLoader; -typedef struct _acl_cg_loader_rec_0_8 aclCGLoader; -typedef struct _acl_be_loader_rec_0_8 aclBELoader; -typedef struct _acl_llvm_module_0_8* aclModule; // Opaque pointer to llvm::Module -typedef struct _acl_llvm_context_0_8* aclContext; // Opaque pointer to llvm::Context -typedef struct _acl_loader_data_0_8* aclLoaderData; // Opaque pointer to loader data - -#include "aclEnums.h" -// Typedefs for enumerations -typedef enum _acl_error_enum_0_8 acl_error; -typedef enum _comp_device_caps_enum_0_8 compDeviceCaps; -typedef enum _comp_opt_settings_enum_0_8 compOptSettings; -typedef enum _acl_dev_type_enum_0_8 aclDevType; -typedef enum _acl_cl_version_enum_0_8 aclCLVersion; -typedef enum _acl_type_enum_0_8 aclType; -typedef enum _rt_query_types_enum_0_8 aclQueryType; -typedef enum _rt_gpu_caps_enum_0_8 aclGPUCaps; -typedef enum _rt_gpu_resource_enum_0_8 aclGPUResource; -typedef enum _rt_gpu_mem_sizes_enum_0_8 aclGPUMemSizes; -typedef enum _acl_arg_type_enum_0_8 aclArgType; -typedef enum _acl_data_type_enum_0_8 aclArgDataType; -typedef enum _acl_memory_type_enum_0_8 aclMemoryType; -typedef enum _acl_access_type_enum_0_8 aclAccessType; -typedef enum _bif_version_enum_0_8 aclBIFVersion; -typedef enum _bif_platform_enum_0_8 aclPlatform; -typedef enum _bif_sections_enum_0_8 aclSections; -typedef enum _acl_loader_type_enum_0_8 aclLoaderType; -typedef enum _acl_binary_image_type_enum_0_8 aclBinaryImageType; - -#include "aclFunctors.h" -// Typedefs for function pointers -typedef aclLogFunction_0_8 aclLogFunction; -typedef InsertSec_0_8 InsertSec; -typedef RemoveSec_0_8 RemoveSec; -typedef ExtractSec_0_8 ExtractSec; -typedef InsertSym_0_8 InsertSym; -typedef RemoveSym_0_8 RemoveSym; -typedef ExtractSym_0_8 ExtractSym; -typedef QueryInfo_0_8 QueryInfo; -typedef Compile_0_8 Compile; -typedef Link_0_8 Link; -typedef AddDbgArg_0_8 AddDbgArg; -typedef RemoveDbgArg_0_8 RemoveDbgArg; -typedef SetupLoaderObject_0_8 SetupLoaderObject; -typedef CompLog_0_8 CompLog; -typedef RetrieveType_0_8 RetrieveType; -typedef SetType_0_8 SetType; -typedef ConvertType_0_8 ConvertType; -typedef Disassemble_0_8 Disassemble; -typedef GetDevBinary_0_8 GetDevBinary; -typedef LoaderInit_0_8 LoaderInit; -typedef LoaderFini_0_8 LoaderFini; -typedef FEToIR_0_8 FEToIR; -typedef SourceToISA_0_8 SourceToISA; -typedef IRPhase_0_8 IRPhase; -typedef LinkPhase_0_8 LinkPhase; -typedef CGPhase_0_8 CGPhase; -typedef DisasmISA_0_8 DisasmISA; -typedef AllocFunc_0_8 AllocFunc; -typedef FreeFunc_0_8 FreeFunc; -typedef JITObjectImageCreate_0_8 JITObjectImageCreate; -typedef JITObjectImageCopy_0_8 JITObjectImageCopy; -typedef JITObjectImageDestroy_0_8 JITObjectImageDestroy; -typedef JITObjectImageSize_0_8 JITObjectImageSize; -typedef JITObjectImageData_0_8 JITObjectImageData; -typedef JITObjectImageFinalize_0_8 JITObjectImageFinalize; -typedef JITObjectImageGetGlobalsSize_0_8 JITObjectImageGetGlobalsSize; -typedef JITSymbolCallback_0_8 JITSymbolCallback; -typedef JITObjectImageIterateSymbols_0_8 JITObjectImageIterateSymbols; -typedef JITObjectImageDisassembleKernel_0_8 JITObjectImageDisassembleKernel; - -#include "aclStructs.h" - -#endif // _CL_API_TYPES_0_8_H_ diff --git a/rocclr/compiler/lib/spirv/spirvUtils.cpp b/rocclr/compiler/lib/spirv/spirvUtils.cpp deleted file mode 100644 index 1244714578..0000000000 --- a/rocclr/compiler/lib/spirv/spirvUtils.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "spirvUtils.h" - -const unsigned SPRVMagicNumber = 0x07230203; - -bool isSPIRVMagic(const void* Image, size_t Length) { - if (Image == nullptr || Length < sizeof(unsigned)) - return false; - auto Magic = static_cast(Image); - return *Magic == SPRVMagicNumber; -} - -// ToDo: replace this with SPIR-V validator when it is available. -bool -validateSPIRV(const void *Image, size_t Length) { - return isSPIRVMagic(Image, Length); -} - - diff --git a/rocclr/compiler/lib/utils/amdilUtils.cpp b/rocclr/compiler/lib/utils/amdilUtils.cpp deleted file mode 100644 index c691bbbb2c..0000000000 --- a/rocclr/compiler/lib/utils/amdilUtils.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "amdilUtils.hpp" -#include -#include -#include - -// Change all private uav length in a kernel -void amdilUtils::changePrivateUAVLength(std::string& kernel, unsigned length) { - std::regex pattern("dcl_typeless_uav_id\\(([[:digit:]]+)\\)_stride" - "\\(([[:digit:]]+)\\)_length\\([[:digit:]]+\\)_access\\(private\\)"); - std::stringstream ss; - ss << "dcl_typeless_uav_id($1)_stride($2)_length(" << length << - ")_access(private)"; - kernel = std::regex_replace(kernel, pattern, ss.str()); -} - -bool amdilUtils::isKernelMemoryBound(const std::string& kernel) { - std::istringstream is(kernel); - std::regex pattern("\\s*;\\s*membound\\s*:\\s*1\\s*"); - while (is) { - std::string line; - is >> line; - if (std::regex_match(line, pattern)) - return true; - } - return false; -} diff --git a/rocclr/compiler/lib/utils/amdilUtils.hpp b/rocclr/compiler/lib/utils/amdilUtils.hpp deleted file mode 100644 index 9b49fa1bd7..0000000000 --- a/rocclr/compiler/lib/utils/amdilUtils.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef AMDILUTILS_H_ -#define AMDILUTILS_H_ - -#include - -namespace amdilUtils { -// Change all private uav length in a kernel -void changePrivateUAVLength(std::string& kernel, unsigned length); - -bool isKernelMemoryBound(const std::string& kernel); - -} -#endif /* AMDILUTILS_H_ */ diff --git a/rocclr/compiler/lib/utils/libUtils.h b/rocclr/compiler/lib/utils/libUtils.h index e5b7127f08..772cdb661d 100644 --- a/rocclr/compiler/lib/utils/libUtils.h +++ b/rocclr/compiler/lib/utils/libUtils.h @@ -1,10 +1,421 @@ // // Copyright (c) 2011 Advanced Micro Devices, Inc. All rights reserved. // -// This is a compatibility header file. Either define the version -// of the compiler library to use or include the version specific -// header file directly. -#ifndef _CL_LIB_UTILS_H_ -#define _CL_LIB_UTILS_H_ -#include "v0_8/libUtils.h" -#endif // _CL_LIB_UTILS_H_ +#ifndef _CL_LIB_UTILS_0_8_H_ +#define _CL_LIB_UTILS_0_8_H_ +#include "acl.h" +#include +#include +#include +#include +#include +#include +#include "library.hpp" +#include "utils/bif_section_labels.hpp" +#include "utils/options.hpp" +using namespace bif; + +// Utility function to set a flag in option structure +// of the aclDevCaps. +void +setFlag(aclDevCaps *elf, compDeviceCaps option); + +// Utility function to flip a flag in option structure +// of the aclDevCaps. +void +flipFlag(aclDevCaps *elf, compDeviceCaps option); + +// Utility function to clear a flag in option structure +// of the aclDevCaps. +void +clearFlag(aclDevCaps *elf, compDeviceCaps option); + +// Utility function to check that a flag in option structure +// of the aclDevCaps is set. +bool +checkFlag(aclDevCaps *elf, compDeviceCaps option); + +// Utility function to initialize and elf device capabilities +void +initElfDeviceCaps(aclBinary *elf); + +// Append the string to the aclCompiler log string. +void +appendLogToCL(aclCompiler *cl, const std::string &logStr); + +const char *getDeviceName(const aclTargetInfo &target); + +// Select the correct library from the target information. +amd::LibrarySelector getLibraryType(const aclTargetInfo *target); + +// get family_enum from the target information. +unsigned getFamilyEnum(const aclTargetInfo *target); + +// get chip_enum from the target information. +unsigned getChipEnum(const aclTargetInfo *target); + +// get isa type name (compute capability) from the target information. +const std::string &getIsaTypeName(const aclTargetInfo *target); + +// get isa type (compute capability) from the target information. +int getIsaType(const aclTargetInfo *target); + +// get Feature String for target. +std::string getFeatureString(const aclTargetInfo& target, amd::option::Options *OptionsObj); + +// Create a copy of an ELF and duplicate all sections/symbols +aclBinary* +createELFCopy(aclBinary *src); + +// Create a BIF2.1 elf from a BIF 2.0 elf +aclBinary* +convertBIF20ToBIF21(aclBinary *src); + +// Create a BIF3.0 elf from a BIF 2.0 elf +aclBinary* +convertBIF20ToBIF30(aclBinary *src); + +// Create a BIF3.1 elf from a BIF 2.0 elf +aclBinary* +convertBIF20ToBIF31(aclBinary *src); + +// Create a BIF2.0 elf from a BIF 2.1 elf +aclBinary* +convertBIF21ToBIF20(aclBinary *src); + +// Create a BIF3.0 elf from a BIF 2.1 elf +aclBinary* +convertBIF21ToBIF30(aclBinary *src); + +// Create a BIF3.1 elf from a BIF 2.1 elf +aclBinary* +convertBIF21ToBIF31(aclBinary *src); + +// Create a BIF2.0 elf from a BIF 3.0 elf +aclBinary* +convertBIF30ToBIF20(aclBinary *src); + +// Create a BIF2.1 elf from a BIF 3.0 elf +aclBinary* +convertBIF30ToBIF21(aclBinary *src); + +// Create a BIF3.1 elf from a BIF 3.0 elf +aclBinary* +convertBIF30ToBIF31(aclBinary *src); + +// Create a BIF2.0 elf from a BIF 3.1 elf +aclBinary* +convertBIF31ToBIF20(aclBinary *src); + +// Create a BIF2.1 elf from a BIF 3.1 elf +aclBinary* +convertBIF31ToBIF21(aclBinary *src); + +// Create a BIF3.0 elf from a BIF 3.1 elf +aclBinary* +convertBIF31ToBIF30(aclBinary *src); + +// get a pointer to the aclBIF irrespective of the +// binary version. +aclBIF* +aclutGetBIF(aclBinary*); + +// Get a pointer to the aclOptions irrespective of +// the binary version. +aclOptions* +aclutGetOptions(aclBinary*); + +// Get a pointer to the aclBinaryOptions struct +// irrespective of the binary version. +aclBinaryOptions* +aclutGetBinOpts(aclBinary*); + +// Get a pointer to the target info struct +// irrespective of the binary version. +aclTargetInfo* +aclutGetTargetInfo(aclBinary*); + +// Get a pointer to the device caps +// irrespective of the binary version. +aclDevCaps* +aclutGetCaps(aclBinary*); + +// Copy two binary option structures irrespective +// of the binary version and uses defaults when +// things don't match up. +void +aclutCopyBinOpts(aclBinaryOptions *dst, + const aclBinaryOptions *src, + bool is64bit); + +// Retrieve kernel statistics from binary +// and insert to elf as symbol +acl_error aclutInsertKernelStatistics(aclCompiler*, aclBinary*); + +// Returns target chip name. +std::string aclutGetCodegenName(const aclTargetInfo &tgtInfo); + +// Helper function that returns the +// allocation function from the binary. +AllocFunc +aclutAlloc(const aclBinary *bin); + +// Helper function that returns the +// de-allocation function from the binary. +FreeFunc +aclutFree(const aclBinary *bin); + + +// Helper function that returns the +// allocation function from the compiler. +AllocFunc +aclutAlloc(const aclCompiler *bin); + +// Helper function that returns the +// de-allocation function from the compiler. +FreeFunc +aclutFree(const aclCompiler *bin); + +// Helper function that returns the +// allocation function from the compiler options. +AllocFunc +aclutAlloc(const aclCompilerOptions *bin); + +// Helper function that returns the +// de-allocation function from the compiler options. +FreeFunc +aclutFree(const aclCompilerOptions *bin); + +inline std::vector splitSpaceSeparatedString(char *str) +{ + std::string s(str); + std::stringstream ss(s); + std::istream_iterator beg(ss), end; + std::vector vec(beg, end); + return vec; +} + +// Helper function that returns OpenCL mangled kernel name. +inline std::string +aclutOpenclMangledKernelName(const std::string& kernel_name) +{ + const oclBIFSymbolStruct* sym = findBIF30SymStruct(symOpenclKernel); + assert(sym && "symbol not found"); + return std::string("&") + sym->str[PRE] + kernel_name + sym->str[POST]; +} + +// Helper function that returns OpenCL mangled kernel metadata symbol name. +inline std::string +aclutOpenclMangledKernelMetadataName(const std::string& kernel_name) +{ + const oclBIFSymbolStruct* sym = findBIF30SymStruct(symOpenclMeta); + assert(sym && "symbol not found"); + return sym->str[PRE] + aclutOpenclMangledKernelName(kernel_name) + sym->str[POST]; +} + +#ifdef WITH_TARGET_HSAIL +// Helper function that updates metadata for all the kernels in binary; +// the updated attribute is the number of hidden kernel arguments. +inline acl_error +aclutUpdateMetadataWithHiddenKernargsNum(aclCompiler* cl, aclBinary* bin, uint32_t num) { + if (num == MAX_HIDDEN_KERNARGS_NUM) { + return ACL_SUCCESS; + } + const oclBIFSymbolStruct* sym = findBIF30SymStruct(symOpenclMeta); + assert(sym && "symbol not found"); + aclSections secID = sym->sections[0]; + size_t kernelNamesSize = 0; + acl_error error_code = aclQueryInfo(cl, bin, RT_KERNEL_NAMES, NULL, NULL, &kernelNamesSize); + if (error_code != ACL_SUCCESS) { + return error_code; + } + char* kernelNames = new char[kernelNamesSize]; + error_code = aclQueryInfo(cl, bin, RT_KERNEL_NAMES, NULL, kernelNames, &kernelNamesSize); + if (error_code != ACL_SUCCESS) { + delete[] kernelNames; + return error_code; + } + std::vector vKernels = splitSpaceSeparatedString(kernelNames); + delete[] kernelNames; + size_t roSize = 0; + for (auto it = vKernels.begin(); it != vKernels.end(); ++it) { + std::string symbol = aclutOpenclMangledKernelMetadataName(*it); + void* roSec = const_cast(aclExtractSymbol(cl, bin, &roSize, secID, symbol.c_str(), &error_code)); + if (error_code != ACL_SUCCESS) { + return error_code; + } + if (!roSec || roSize == 0) { + error_code = ACL_ELF_ERROR; + return error_code; + } + aclMetadata *md = reinterpret_cast(roSec); + md->numHiddenKernelArgs = num; + error_code = aclRemoveSymbol(cl, bin, secID, symbol.c_str()); + if (error_code != ACL_SUCCESS) { + return error_code; + } + error_code = aclInsertSymbol(cl, bin, md, roSize, secID, symbol.c_str()); + if (error_code != ACL_SUCCESS) { + return error_code; + } + } + return error_code; +} +#endif + +struct _target_mappings_rec; +typedef _target_mappings_rec TargetMapping; + +// Returns the TargetMapping for the specific target device. +const TargetMapping& getTargetMapping(const aclTargetInfo &target); + +inline bool is64BitTarget(const aclTargetInfo& target) +{ + return (target.arch_id == aclX64 || + target.arch_id == aclAMDIL64 || + target.arch_id == aclHSAIL64); +} + +inline bool isCpuTarget(const aclTargetInfo& target) +{ + return (target.arch_id == aclX64 || target.arch_id == aclX86); +} + +inline bool isGpuTarget(const aclTargetInfo& target) +{ + return (target.arch_id == aclAMDIL || target.arch_id == aclAMDIL64 || + target.arch_id == aclHSAIL || target.arch_id == aclHSAIL64); +} + +inline bool isAMDILTarget(const aclTargetInfo& target) +{ + return (target.arch_id == aclAMDIL || target.arch_id == aclAMDIL64); +} + +inline bool isHSAILTarget(const aclTargetInfo& target) +{ + return (target.arch_id == aclHSAIL || target.arch_id == aclHSAIL64); +} + +const std::string& getLegacyLibName(); + +inline bool isValidTarget(const aclTargetInfo& target) +{ + return (target.arch_id && target.chip_id); +} + +bool isChipSupported(const aclTargetInfo& target); + +enum scId { + SC_AMDIL = 0, + SC_HSAIL = 0, + SC_LAST, +}; + +// Helper function that allocates an aligned memory. +inline void* +alignedMalloc(size_t size, size_t alignment) +{ +#if defined(_WIN32) + return ::_aligned_malloc(size, alignment); +#else + void * ptr = NULL; + if (0 == ::posix_memalign(&ptr, alignment, size)) { + return ptr; + } + return NULL; +#endif +} + +// Helper function that frees an aligned memory. +inline void +alignedFree(void *ptr) +{ +#if defined(_WIN32) + ::_aligned_free(ptr); +#else + free(ptr); +#endif +} + +#if defined(_WIN32) +inline void convertLongAbsFilePathIfNeeded(std::string &filename) +{ + if (filename.empty()) { + return; + } + std::wstring ws(filename.begin(), filename.end()); + wchar_t abs_path[_MAX_ENV]; + _wfullpath(abs_path, ws.c_str(), _MAX_ENV); + std::wstring ws_abs = std::wstring(abs_path); + if (ws_abs.size() >= _MAX_PATH) { + std::string s(ws_abs.begin(), ws_abs.end()); + filename = "\\\\?\\" + s; + } +} +#endif + +inline char* readFile(std::string source_filename, size_t& size) +{ +#if defined(_WIN32) + convertLongAbsFilePathIfNeeded(source_filename); +#endif + FILE *fp = ::fopen( source_filename.c_str(), "rb" ); + unsigned int length; + size_t offset = 0; + char *ptr; + if (!fp) { + return NULL; + } + // obtain file size + ::fseek (fp , 0 , SEEK_END); + length = ::ftell (fp); + ::rewind (fp); + ptr = reinterpret_cast(::malloc(offset + length + 1)); + if (length != fread(&ptr[offset], 1, length, fp)) + { + ::free(ptr); + ::fclose(fp); + return NULL; + } + ptr[offset + length] = '\0'; + size = offset + length; + ::fclose(fp); + return ptr; +} + +inline bool writeFile(std::string source_filename, const char *source, size_t size) +{ +#if defined(_WIN32) + convertLongAbsFilePathIfNeeded(source_filename); +#endif + FILE *fp = ::fopen(source_filename.c_str(), "wb"); + if (!fp) { + return EXIT_FAILURE; + } + if (!::fwrite(source, size, 1, fp)) { + ::fclose(fp); + return EXIT_FAILURE; + } + ::fclose(fp); + return EXIT_SUCCESS; +} + +#if !defined(BCMAG) +#define BCMAG "BC" +#define SBCMAG 2 +#endif +// Helper predicate returns true if p starts with bit code signature. +// TODO: Move it into Compiler Lib back in new 1_0 API +inline static bool +isBcMagic(const char* p) +{ + if (p==NULL || strncmp(p, BCMAG, SBCMAG) != 0) { + return false; + } + return true; +} + +void dump(aclBinary *bin); + +#endif // _CL_LIB_UTILS_0_8_H_ diff --git a/rocclr/compiler/lib/utils/target_mappings.h b/rocclr/compiler/lib/utils/target_mappings.h deleted file mode 100644 index c57eea67a4..0000000000 --- a/rocclr/compiler/lib/utils/target_mappings.h +++ /dev/null @@ -1,18 +0,0 @@ -// -// Copyright (c) 2011 Advanced Micro Devices, Inc. All rights reserved. -// -// This is a compatibility header file. Either define the version -// of the compiler library to use or include the version specific -// header file directly. -#ifndef TARGET_MAPPINGS_H_ -#define TARGET_MAPPINGS_H_ - -#include "v0_8/target_mappings.h" - -#define X86TargetMapping X86TargetMapping_0_8 -#define X64TargetMapping X64TargetMapping_0_8 -#define AMDILTargetMapping AMDILTargetMapping_0_8 -#define HSAILTargetMapping HSAILTargetMapping_0_8 -#define AMDIL64TargetMapping AMDIL64TargetMapping_0_8 -#define HSAIL64TargetMapping HSAIL64TargetMapping_0_8 -#endif // TARGET_MAPPINGS_H_ diff --git a/rocclr/compiler/lib/utils/v0_8/libUtils.cpp b/rocclr/compiler/lib/utils/v0_8/libUtils.cpp deleted file mode 100644 index 9c871c2fee..0000000000 --- a/rocclr/compiler/lib/utils/v0_8/libUtils.cpp +++ /dev/null @@ -1,1161 +0,0 @@ -// -// Copyright (c) 2011 Advanced Micro Devices, Inc. All rights reserved. -// - -#include "api/v0_8/aclValidation.h" -#include "libUtils.h" -#include "bif/bifbase.hpp" -#include "utils/target_mappings.h" -#include "utils/versions.hpp" -#include "utils/options.hpp" -#include -#include "bif/bif.hpp" -extern aclBinary* constructBinary(size_t struct_version, - const aclTargetInfo *target, - const aclBinaryOptions *opts); - -static const std::string sgfx700 = "AMD:AMDGPU:7:0:0"; -static const std::string sgfx701 = "AMD:AMDGPU:7:0:1"; -static const std::string sgfx800 = "AMD:AMDGPU:8:0:0"; -static const std::string sgfx801 = "AMD:AMDGPU:8:0:1"; -static const std::string sgfx802 = "AMD:AMDGPU:8:0:2"; -static const std::string sgfx803 = "AMD:AMDGPU:8:0:3"; -static const std::string sgfx804 = "AMD:AMDGPU:8:0:4"; -static const std::string sgfx810 = "AMD:AMDGPU:8:1:0"; -static const std::string sgfx900 = "AMD:AMDGPU:9:0:0"; -static const std::string sgfx901 = "AMD:AMDGPU:9:0:1"; -static const std::string sgfx902 = "AMD:AMDGPU:9:0:2"; -static const std::string sgfx903 = "AMD:AMDGPU:9:0:3"; -static const std::string sgfx904 = "AMD:AMDGPU:9:0:4"; -static const std::string sgfx905 = "AMD:AMDGPU:9:0:5"; -static const std::string sgfx906 = "AMD:AMDGPU:9:0:6"; -static const std::string sgfx907 = "AMD:AMDGPU:9:0:7"; -static const std::string sgfx908 = "AMD:AMDGPU:9:0:8"; -static const std::string sgfx1000 = "AMD:AMDGPU:10:0:0"; -static const std::string sgfx1010 = "AMD:AMDGPU:10:1:0"; -static const std::string sgfx1011 = "AMD:AMDGPU:10:1:1"; -static const std::string sgfx1012 = "AMD:AMDGPU:10:1:2"; - -static const std::string legacyLibName = LINUX_ONLY("lib") "amdocl12cl" LP64_SWITCH(LINUX_SWITCH("32", ""), "64") LINUX_SWITCH(".so", ".dll"); - -// Utility function to set a flag in option structure -// of the aclDevCaps. -void -setFlag(aclDevCaps *caps, compDeviceCaps option) -{ - assert((uint32_t)option < ((1 << FLAG_SHIFT_VALUE) *FLAG_ARRAY_SIZE) - && "The index passed in is outside of the range of valid values!"); - caps->flags[option >> FLAG_SHIFT_VALUE] |= FLAG_BITLOC(option); -} - -// Utility function to flip a flag in option structure -// of the aclDevCaps. -void -flipFlag(aclDevCaps *caps, compDeviceCaps option) -{ - assert((uint32_t)option < ((1 << FLAG_SHIFT_VALUE) *FLAG_ARRAY_SIZE) - && "The index passed in is outside of the range of valid values!"); - caps->flags[option >> FLAG_SHIFT_VALUE] ^= FLAG_BITLOC(option); -} - -// Utility function to clear a flag in option structure -// of the aclDevCaps. -void -clearFlag(aclDevCaps *caps, compDeviceCaps option) -{ - assert((uint32_t)option < ((1 << FLAG_SHIFT_VALUE) *FLAG_ARRAY_SIZE) - && "The index passed in is outside of the range of valid values!"); - caps->flags[option >> FLAG_SHIFT_VALUE] &= ~FLAG_BITLOC(option); -} - -// Utility function to check that a flag in option structure -// of the aclDevCaps is set. -bool -checkFlag(aclDevCaps *caps, compDeviceCaps option) -{ - assert((uint32_t)option < ((1 << FLAG_SHIFT_VALUE) *FLAG_ARRAY_SIZE) - && "The index passed in is outside of the range of valid values!"); - return ((uint32_t)(caps->flags[option >> FLAG_SHIFT_VALUE] - & FLAG_BITLOC(option))) == (uint32_t)FLAG_BITLOC(option); -} -void setEncryptCaps(aclDevCaps_0_8 *ptr) -{ - clearFlag(ptr, capSaveSOURCE); - clearFlag(ptr, capSaveLLVMIR); - clearFlag(ptr, capSaveCG); - clearFlag(ptr, capSaveSPIR); - clearFlag(ptr, capSaveAMDIL); - clearFlag(ptr, capSaveHSAIL); - clearFlag(ptr, capSaveDISASM); - clearFlag(ptr, capSaveAS); - setFlag(ptr, capSaveEXE); - setFlag(ptr, capEncrypted); -} -void setOptionCaps(amd::option::Options *opts, aclDevCaps_0_8 *ptr) -{ -#define COND_SET_FLAG(A) \ - (((opts)->oVariables->Bin##A) ? setFlag(ptr, capSave##A) : clearFlag(ptr, capSave##A)) - COND_SET_FLAG(SOURCE); - COND_SET_FLAG(LLVMIR); - COND_SET_FLAG(CG); - COND_SET_FLAG(DISASM); - COND_SET_FLAG(AMDIL); - COND_SET_FLAG(HSAIL); - COND_SET_FLAG(AS); - COND_SET_FLAG(SPIR); - COND_SET_FLAG(EXE); - -#undef COND_SET_FLAG -} - -aclBIF *aclutGetBIF(aclBinary *binary) -{ - aclBIF *bif = NULL; - if (binary->struct_size == sizeof(aclBinary_0_8)) { - bif = reinterpret_cast(binary)->bin; - } else if (binary->struct_size == sizeof(aclBinary_0_8_1)) { - bif = reinterpret_cast(binary)->bin; - } else { - assert(!"Binary format not supported!"); - bif = reinterpret_cast(binary)->bin; - } - return bif; -} - -aclOptions *aclutGetOptions(aclBinary *binary) -{ - aclOptions *opt = NULL; - if (binary->struct_size == sizeof(aclBinary_0_8)) { - opt = reinterpret_cast(binary)->options; - } else if (binary->struct_size == sizeof(aclBinary_0_8_1)) { - opt = reinterpret_cast(binary)->options; - } else { - assert(!"Binary format not supported!"); - opt = binary->options; - } - return opt; -} - -aclBinaryOptions *aclutGetBinOpts(aclBinary *binary) -{ - aclBinaryOptions *opt = NULL; - if (binary->struct_size == sizeof(aclBinary_0_8)) { - opt = reinterpret_cast( - &reinterpret_cast(binary)->binOpts); - } else if (binary->struct_size == sizeof(aclBinary_0_8_1)) { - opt = &reinterpret_cast(binary)->binOpts; - } else { - assert(!"Binary format not supported!"); - opt = &binary->binOpts; - } - return opt; -} - -aclTargetInfo *aclutGetTargetInfo(aclBinary *binary) -{ - aclTargetInfo *tgt = NULL; - if (binary->struct_size == sizeof(aclBinary_0_8)) { - tgt = &reinterpret_cast(binary)->target; - } else if (binary->struct_size == sizeof(aclBinary_0_8_1)) { - tgt = &reinterpret_cast(binary)->target; - } else { - assert(!"Binary format not supported!"); - tgt = &binary->target; - } - return tgt; -} - -aclDevCaps* aclutGetCaps(aclBinary *binary) -{ - aclDevCaps *caps = NULL; - if (binary->struct_size == sizeof(aclBinary_0_8)) { - caps = &reinterpret_cast(binary)->caps; - } else if (binary->struct_size == sizeof(aclBinary_0_8_1)) { - caps = &reinterpret_cast(binary)->caps; - } else { - assert(!"Binary format not supported!"); - caps = &binary->caps; - } - return caps; -} -// Helper function that returns the -// allocation function from the binary. -AllocFunc -aclutAlloc(const aclBinary *bin) -{ - size_t size = (bin ? bin->struct_size : 0); - AllocFunc m = NULL; - switch(size) { - case 0: - case sizeof(aclBinary_0_8): - break; - case sizeof(aclBinary_0_8_1): - m = reinterpret_cast(bin)->binOpts.alloc; - break; - default: - assert(!"Found an unsupported binary!"); - m = bin->binOpts.alloc; - break; - } - return (m) ? m : &::malloc; -} - -// Helper function that returns the -// allocation function from the compiler. -AllocFunc -aclutAlloc(const aclCompiler *bin) -{ - size_t size = (bin ? bin->struct_size : 0); - AllocFunc m = NULL; - switch(size) { - case 0: - case sizeof(aclCompilerHandle_0_8): - break; - case sizeof(aclCompilerHandle_0_8_1): - m = reinterpret_cast(bin)->alloc; - break; - default: - assert(!"Found an unsupported compiler!"); - m = bin->alloc; - break; - } - return (m) ? m : &::malloc; -} - -AllocFunc -aclutAlloc(const aclCompilerOptions *opts) -{ - size_t size = (opts ? opts->struct_size : 0); - AllocFunc m = NULL; - switch (size) { - case 0: - case sizeof(aclCompilerOptions_0_8): - break; - case sizeof(aclCompilerOptions_0_8_1): - m = reinterpret_cast(opts)->alloc; - break; - default: - assert(!"Found an unsupported compiler options struct!"); - m = opts->alloc; - break; - } - return (m) ? m : &::malloc; -} - - -// Helper function that returns the -// de-allocation function from the compiler. -FreeFunc -aclutFree(const aclCompiler *bin) -{ - size_t size = (bin ? bin->struct_size : 0); - FreeFunc f = NULL; - switch(size) { - case 0: - case sizeof(aclCompilerHandle_0_8): - break; - case sizeof(aclCompilerHandle_0_8_1): - f = reinterpret_cast(bin)->dealloc; - break; - default: - assert(!"Found an unsupported compiler!"); - f = bin->dealloc; - break; - } - return (f) ? f : &::free; -} - -// Helper function that returns the -// de-allocation function from the binary. -FreeFunc -aclutFree(const aclBinary *bin) -{ - size_t size = (bin ? bin->struct_size : 0); - FreeFunc f = NULL; - switch(size) { - case 0: - case sizeof(aclBinary_0_8): - break; - case sizeof(aclBinary_0_8_1): - f = reinterpret_cast(bin)->binOpts.dealloc; - break; - default: - assert(!"Found an unsupported binary!"); - f = bin->binOpts.dealloc; - break; - } - return (f) ? f : &::free; -} - -FreeFunc -aclutFree(const aclCompilerOptions *opts) -{ - size_t size = (opts ? opts->struct_size : 0); - FreeFunc f = NULL; - switch (size) { - case 0: - case sizeof(aclCompilerOptions_0_8): - break; - case sizeof(aclCompilerOptions_0_8_1): - f = reinterpret_cast(opts)->dealloc; - break; - default: - assert(!"Found an unsupported compiler options struct!"); - f = opts->dealloc; - break; - } - return (f) ? f : &::free; -} - - -void -aclutCopyBinOpts(aclBinaryOptions *dst, const aclBinaryOptions *src, bool is64) -{ - if (dst == src) return; - aclBinaryOptions_0_8 *dst08; - aclBinaryOptions_0_8_1 *dst081; - const aclBinaryOptions_0_8 *src08; - const aclBinaryOptions_0_8_1 *src081; - dst08 = reinterpret_cast(dst); - dst081 = reinterpret_cast(dst); - src08 = reinterpret_cast(src); - src081 = reinterpret_cast(src); - unsigned size = (src ? src->struct_size : 0); - switch (size) { - case 0: - switch (dst->struct_size) { - case sizeof(aclBinary_0_8): - dst08->elfclass = (is64) ? ELFCLASS64 : ELFCLASS32; - dst08->bitness = ELFDATA2LSB; - dst08->temp_file = ""; - dst08->kernelArgAlign = 4; - break; - case sizeof(aclBinary_0_8_1): - dst081->elfclass = (is64) ? ELFCLASS64 : ELFCLASS32; - dst081->bitness = ELFDATA2LSB; - dst081->temp_file = ""; - dst081->kernelArgAlign = 4; - dst081->alloc = &::malloc; - dst081->dealloc = &::free; - break; - default: - dst->elfclass = (is64) ? ELFCLASS64 : ELFCLASS32; - dst->bitness = ELFDATA2LSB; - dst->temp_file = ""; - dst->kernelArgAlign = 4; - dst->alloc = &::malloc; - dst->dealloc = &::free; - break; - } - break; - case sizeof(aclBinaryOptions_0_8): - switch (dst->struct_size) { - case sizeof(aclBinaryOptions_0_8): - memcpy(dst08, src08, src08->struct_size); - break; - case sizeof(aclBinaryOptions_0_8_1): - dst081->elfclass = src08->elfclass; - dst081->bitness = src08->bitness; - dst081->temp_file = src08->temp_file; - dst081->kernelArgAlign = src08->kernelArgAlign; - dst081->alloc = &::malloc; - dst081->dealloc = &::free; - break; - default: - assert(!"aclBinary format is not supported!"); - memcpy(dst, src08, src08->struct_size); - if (!dst->alloc) dst->alloc = &::malloc; - if (!dst->dealloc) dst->dealloc = &::free; - } - break; - case sizeof(aclBinaryOptions_0_8_1): - switch (dst->struct_size) { - case sizeof(aclBinary_0_8): - dst08->elfclass = src081->elfclass; - dst08->bitness = src081->bitness; - dst08->temp_file = src081->temp_file; - dst08->kernelArgAlign = src081->kernelArgAlign; - break; - case sizeof(aclBinaryOptions_0_8_1): - memcpy(dst081, src081, src081->struct_size); - if (!dst->alloc) dst->alloc = &::malloc; - if (!dst->dealloc) dst->dealloc = &::free; - break; - default: - assert(!"aclBinary format is not supported!"); - memcpy(dst, src081, src081->struct_size); - if (!dst->alloc) dst->alloc = &::malloc; - if (!dst->dealloc) dst->dealloc = &::free; - } - break; - default: - assert(!"aclBinary format is not supported!"); - memcpy(dst, src, src->struct_size); - } -} - -acl_error -aclutInsertKernelStatistics(aclCompiler *cl, aclBinary *bin) -{ - if (!aclValidateCompiler(cl, true)) { - return ACL_INVALID_COMPILER; - } - if (!aclValidateBinary(bin)) { - return ACL_INVALID_BINARY; - } - size_t len = 0; - acl_error err = ACL_SUCCESS; - const void *isa = aclExtractSection(cl, bin, &len, aclTEXT, &err); - if (err != ACL_SUCCESS) - return err; - aclTargetInfo *tgtInfo = aclutGetTargetInfo(bin); - const char* chipName = aclGetChip(*tgtInfo); - unsigned family = getFamilyEnum(tgtInfo); - unsigned chip = getChipEnum(tgtInfo); - // Non-GPU devices have family_enum set to 1 and do not qualify. Need to update. - if (family >= FAMILY_R600 && - family <= FAMILY_CZ) { - aclKernelStats kstats = {0}; - aclGetKstatsSI(isa, kstats); - kstats.wavefrontsize = 64; // FIXME: Hardcoded for now. - const oclBIFSymbolStruct* symbol = findBIF30SymStruct(symKernelStats); - assert(symbol && "symbol not found"); - std::string symName = std::string(symbol->str[PRE]) + std::string(symbol->str[POST]); - err = aclInsertSymbol(cl, bin, reinterpret_cast(&kstats), sizeof(kstats), aclKSTATS, symName.c_str()); - } - return err; -} - -std::string aclutGetCodegenName(const aclTargetInfo &tgtInfo) -{ - assert(tgtInfo.arch_id <= aclLast && "Unknown device id!"); - const FamilyMapping *family = familySet + tgtInfo.arch_id; - if (!family) return ""; - - assert((tgtInfo.chip_id) < family->children_size && "Unknown family id!"); - const TargetMapping *target = &family->target[tgtInfo.chip_id]; - return (target) ? target->codegen_name : ""; -} - -void initElfDeviceCaps(aclBinary *elf) -{ - if (aclutGetCaps(elf)->encryptCode) { - setEncryptCaps(aclutGetCaps(elf)); - return; - } - if (aclutGetOptions(elf)) { - setOptionCaps(reinterpret_cast( - aclutGetOptions(elf)), aclutGetCaps(elf)); - } -} - -const char *getDeviceName(const aclTargetInfo &target) -{ - if (target.chip_id) { - return aclGetChip(target); - } else if (target.arch_id) { - return aclGetArchitecture(target); - } - return NULL; -} - -const TargetMapping& getTargetMapping(const aclTargetInfo &target) -{ - switch (target.arch_id) { - default: - break; - case aclX64: - return X64TargetMapping[target.chip_id]; - break; - case aclX86: - return X86TargetMapping[target.chip_id]; - break; - case aclHSAIL: - return HSAILTargetMapping[target.chip_id]; - break; - case aclHSAIL64: - return HSAIL64TargetMapping[target.chip_id]; - break; - case aclAMDIL: - return AMDILTargetMapping[target.chip_id]; - break; - case aclAMDIL64: - return AMDIL64TargetMapping[target.chip_id]; - break; - }; - return UnknownTarget; -} - -bool isChipSupported(const aclTargetInfo& target) -{ - if (!isValidTarget(target)) { - return false; - } - const TargetMapping& Mapping = getTargetMapping(target); - if (Mapping.family_enum == FAMILY_UNKNOWN) { - return false; - } - return Mapping.supported; -} - -/*! Function that returns the library type from the TargetMapping table for - *the specific target device id. - */ -amd::LibrarySelector getLibraryType(const aclTargetInfo *target) -{ - const TargetMapping& Mapping = getTargetMapping(*target); - return Mapping.lib; -} - -/*! Function that returns family_enum from the TargetMapping table for - *the specific target device id. - */ -unsigned getFamilyEnum(const aclTargetInfo *target) -{ - const TargetMapping& Mapping = getTargetMapping(*target); - return Mapping.family_enum; -} - -/*! Function that returns chip_enum from the TargetMapping table for - *the specific target device id. - */ -unsigned getChipEnum(const aclTargetInfo *target) -{ - const TargetMapping& Mapping = getTargetMapping(*target); - return Mapping.chip_enum; -} - -/*! Function that returns isa type name (compute capability) from - *the TargetMapping table for the specific target device id. - */ -const std::string &getIsaTypeName(const aclTargetInfo *target) -{ - switch (getIsaType(target)) { - default: return sgfx700; - case 700: return sgfx700; - case 701: return sgfx701; - case 800: return sgfx800; - case 801: return sgfx801; - case 802: return sgfx802; - case 803: return sgfx803; - case 804: return sgfx804; - case 810: return sgfx810; - case 900: return sgfx900; - case 901: return sgfx901; - case 902: return sgfx902; - case 903: return sgfx903; - case 904: return sgfx904; - case 905: return sgfx905; - case 906: return sgfx906; - case 907: return sgfx907; - case 908: return sgfx908; - case 1000: return sgfx1000; - case 1010: return sgfx1010; - case 1011: return sgfx1011; - case 1012: return sgfx1012; - } -} - -/*! Function that returns isa type (compute capability) from - *the TargetMapping table for the specific target device id. - */ -int getIsaType(const aclTargetInfo *target) -{ - const TargetMapping& Mapping = getTargetMapping(*target); - switch (Mapping.family_enum) { - default: return 700; - case FAMILY_KV: - switch (Mapping.chip_enum) { - default: return 700; - case KV_SPECTRE_A0: - case KV_SPOOKY_A0: - case KB_KALINDI_A0: - // ??? - case ML_GODAVARI_A0: return 700; - } - case FAMILY_CI: - switch (Mapping.chip_enum) { - default: return 700; - case CI_BONAIRE_M_A0: - case CI_BONAIRE_M_A1: return 700; - case CI_HAWAII_P_A0: return 701; - case CI_TIRAN_P_A0: - case CI_MAUI_P_A0: return 700; - } - case FAMILY_VI: - switch (Mapping.chip_enum) { - default: return 800; - case VI_TONGA_P_A0: -#if defined(BUILD_HSA_TARGET) - return 802; // Special case - Boltzmann Tonga - // Otherwise fall through -#endif - case VI_ICELAND_M_A0: return 800; - case VI_FIJI_P_A0: - case VI_BAFFIN_M_A0: - case VI_BAFFIN_M_A1: - case VI_ELLESMERE_P_A0: - case VI_ELLESMERE_P_A1: - case VI_LEXA_V_A0: - case VI_POLARIS22_P_A0: -#if defined(BUILD_HSA_TARGET) - return 803; // Special case - Boltzmann FIJI, BAFFIN, ELLESMERE, LEXA - // Otherwise fall through -#else - return 804; -#endif - } - case FAMILY_CZ: - switch (Mapping.chip_enum) { - default: return 801; - case CARRIZO_A0: return 801; - case STONEY_A0: return 810; - } - case FAMILY_AI: - switch (Mapping.chip_enum) { - default: return 900; - case AI_GREENLAND_P_A0: - case AI_GREENLAND_P_A1: return Mapping.xnack_supported ? 901 : 900; - case AI_VEGA12_P_A0: return Mapping.xnack_supported ? 905 : 904; - case AI_VEGA20_P_A0: return Mapping.xnack_supported ? 907 : 906; - case AI_MI100_P_A0: return 908; - } - case FAMILY_RV: - switch (Mapping.chip_enum) { - default: return 902; - case RAVEN_A0: - case RENOIR_A0: return Mapping.xnack_supported ? 903 : 902; - } - case FAMILY_NV: - switch (Mapping.chip_enum) { - default: return 1000; - case NV_NAVI10_LITE_P_A0: return 1000; - case NV_NAVI10_P_A0: return 1010; - case NV_NAVI12_P_A0: return 1011; - case NV_NAVI14_M_A0: return 1012; - } - } -} - -std::string getFeatureString(const aclTargetInfo& target, amd::option::Options *OptionsObj) -{ - std::string FeatureStr; - if (isHSAILTarget(target)) { - uint64_t y = aclGetChipOptions(target); - FeatureStr += ((y & F_FP32_DENORMS) && !OptionsObj->oVariables->DenormsAreZero) ? '+' : '-'; - FeatureStr += "fp32-denormals"; - - for (uint64_t x = 0; y != 0; y >>= 1, ++x) { - if ((1 << x) == F_FP32_DENORMS) { - continue; - } - if (!FeatureStr.empty()) { - FeatureStr += ','; - } - FeatureStr += ((y & 0x1) ? '+' : '-'); - FeatureStr += HSAILCodeGenFlagTable[x]; - } - } - return FeatureStr; -} - -void -appendLogToCL(aclCompiler *cl, const std::string &logStr) -{ - if (logStr.empty()) { - return; - } - std::string log = logStr; - if ('\n' != log[log.size()-1]) { - log.append("\n"); - } - unsigned size = cl->logSize + log.size(); - if (!size) { - return; - } - char *tmpBuildLog = reinterpret_cast(aclutAlloc(cl)(size + 2)); - memset(tmpBuildLog, 0, size + 2); - if (cl->logSize) { - std::copy(cl->buildLog, cl->buildLog + cl->logSize, tmpBuildLog); - std::copy(log.begin(), log.end(), tmpBuildLog + cl->logSize); - } else { - std::copy(log.begin(), log.end(), tmpBuildLog); - } - cl->logSize += (unsigned int)log.size(); - if (cl->buildLog) { - aclutFree(cl)(cl->buildLog); - } - cl->buildLog = tmpBuildLog; -} - -static void -setElfTarget(bifbase *elfBin, const aclTargetInfo *tgtInfo) -{ - uint16_t elf_target = 0; - switch (tgtInfo->arch_id) { - default: - assert(!"creating an elf for an invalid architecture!"); - case aclX86: - elfBin->setTarget(EM_386, aclPlatformCompLib); - break; - case aclX64: - elfBin->setTarget(EM_X86_64, aclPlatformCompLib); - break; - case aclHSAIL: - elfBin->setTarget(EM_HSAIL, aclPlatformCompLib); - break; - case aclHSAIL64: - elfBin->setTarget(EM_HSAIL_64, aclPlatformCompLib); - break; - case aclAMDIL: - elfBin->setTarget(EM_AMDIL, aclPlatformCompLib); - break; - case aclAMDIL64: - elfBin->setTarget(EM_AMDIL_64, aclPlatformCompLib); - break; - } -} -// FIXME: this needs to be moved into the BIF classes. -static void -convertBIF30MachineTo2X(bifbase *elfBin, const aclTargetInfo *tgtInfo) -{ - uint16_t machine = 0; - uint32_t flags = 0; - aclPlatform pform = aclPlatformLast; - if (elfBin == NULL) return; - elfBin->getTarget(machine, pform); - assert(pform == aclPlatformCompLib - && "Platform is specified incorrectly!"); - if (isCpuTarget(*tgtInfo)) { - assert(!"Not implemented/supported family detected!"); - pform = aclPlatformCPU; - } else if (isAMDILTarget(*tgtInfo)) { - const char* chip = aclGetChip(*tgtInfo); - for (unsigned x = 0, y = sizeof(calTargetMapping)/sizeof(calTargetMapping[0]); - x < y; ++x) { - if (!strcmp(chip, calTargetMapping[x])) { - machine = x; - break; - } - } - pform = aclPlatformCAL; - } else { - assert(!"Not implemented/supported family detected!"); - } - elfBin->setTarget(machine, pform); -} -// FIXME: This needs to be moved into the elf classes -static void -convertBIF2XMachineTo31(bifbase *elfBin) -{ - uint16_t machine = 0; - aclPlatform pform = aclPlatformLast; - if (elfBin == NULL) return; - elfBin->getTarget(machine, pform); - assert(pform != aclPlatformCompLib - && "Platform is specified incorrectly!"); - if (pform == aclPlatformCPU) { - uint16_t type; - elfBin->getType(type); - machine = (type == ELFCLASS32 ? EM_386 : EM_X86_64); - } else if (pform == aclPlatformCAL) { - machine = EM_AMDIL; - } else { - assert(!"Unknown platform found!"); - } - pform = aclPlatformCompLib; - elfBin->setTarget(machine, pform); -} - -static void -convertBIF2XMachineTo30(bifbase *elfBin) -{ - uint16_t machine = 0; - aclPlatform pform = aclPlatformLast; - if (elfBin == NULL) return; - elfBin->getTarget(machine, pform); - assert(pform != aclPlatformCompLib - && "Platform is specified incorrectly!"); - if (pform == aclPlatformCPU) { - uint16_t type; - elfBin->getType(type); - machine = (type == ELFCLASS32 ? EM_386 : EM_X86_64); - } else if (pform == aclPlatformCAL) { - machine = EM_AMDIL; - } else { - assert(!"Unknown platform found!"); - } - pform = aclPlatformCompLib; - elfBin->setTarget(machine, pform); -} - -static void -setElfFlags(bifbase *elfBin, const aclTargetInfo *tgtInfo) -{ - uint32_t flags = 0; - elfBin->getFlags(flags); - flags &= 0xFFFF0000; - const FamilyMapping *family = familySet + tgtInfo->arch_id; - flags = tgtInfo->chip_id & 0xFFFF; - elfBin->setFlags(flags); -} - -static aclBinary* -cloneOclElfNoBIF(const aclBinary *src) { - if (src == NULL) return NULL; - if (src->struct_size == sizeof(aclBinary_0_8_1)) { - aclBinary *dst = constructBinary(src->struct_size, - aclutGetTargetInfo(const_cast(src)), - aclutGetBinOpts(const_cast(src))); - if (dst == NULL) { - return NULL; - } - aclBinary_0_8_1 *dptr = reinterpret_cast(dst); - const aclBinary_0_8_1 *sptr = reinterpret_cast(src); - dptr->target.struct_size = sizeof(aclTargetInfo_0_8); - if (sptr->target.struct_size == sizeof(aclTargetInfo_0_8)) { - memcpy(&dptr->target, &sptr->target, sptr->target.struct_size); - } else { - assert(!"Unsupported target info detected!"); - } - - memcpy(&dptr->caps, &sptr->caps, sptr->caps.struct_size); - assert(sizeof(aclDevCaps_0_8) == dptr->caps.struct_size); - amd::option::Options *Opts = reinterpret_cast( - aclutAlloc(src)(sizeof(amd::option::Options))); - Opts = new (Opts) amd::option::Options; - amd::option::Options *sOpts = reinterpret_cast( - sptr->options); - if (sOpts) { - parseAllOptions(sOpts->origOptionStr, *Opts, false, false); - } - dptr->options = reinterpret_cast(Opts); - dptr->bin = NULL; - return dst; - } else if (src->struct_size == sizeof(aclBinary_0_8)) { - aclBinary *dst = constructBinary(src->struct_size, - &src->target, - &src->binOpts); - if (dst == NULL) { - return NULL; - } - aclBinary_0_8 *dptr = reinterpret_cast(dst); - const aclBinary_0_8 *sptr = reinterpret_cast(src); - dptr->target.struct_size = sizeof(aclTargetInfo_0_8); - if (sptr->target.struct_size == sizeof(aclTargetInfo_0_8)) { - memcpy(&dptr->target, &sptr->target, sptr->target.struct_size); - } else { - assert(!"Unsupported target info detected!"); - } - - memcpy(&dptr->caps, &sptr->caps, sptr->caps.struct_size); - assert(sizeof(aclDevCaps_0_8) == dptr->caps.struct_size - && "The caps struct is not version 0.7!"); - amd::option::Options *Opts = reinterpret_cast( - aclutAlloc(src)(sizeof(amd::option::Options))); - Opts = new (Opts) amd::option::Options; - amd::option::Options *sOpts = reinterpret_cast( - sptr->options); - if (sOpts) { - parseAllOptions(sOpts->origOptionStr, *Opts, false, false); - } - dptr->options = reinterpret_cast(Opts); - dptr->bin = NULL; - return dst; - } else { - assert(!"Elf version not supported!"); - } - return NULL; -} - -// Create a copy of an ELF and duplicate all sections/symbols -// All sections are copied verbatim. -aclBinary* -createELFCopy(aclBinary *src) { - aclBinary *dst = cloneOclElfNoBIF(src); - if (dst != NULL) { - bifbase *srcBin = reinterpret_cast(aclutGetBIF(src)); - bifbase* dstBin = NULL; - switch (srcBin->getVersion()) { - default: - assert(!"New/unknown version detected!"); - dstBin = reinterpret_cast(aclutAlloc(src)(sizeof(bifbase))); - dstBin = new (dstBin) bifbase(srcBin->getBase()); - break; - case aclBIFVersion20: - dstBin = reinterpret_cast(aclutAlloc(src)(sizeof(bif20))); - dstBin = new (dstBin) bif20(srcBin->get20()); break; - case aclBIFVersion21: - dstBin = reinterpret_cast(aclutAlloc(src)(sizeof(bif21))); - dstBin = new (dstBin) bif21(srcBin->get21()); break; - case aclBIFVersion30: - dstBin = reinterpret_cast(aclutAlloc(src)(sizeof(bif30))); - dstBin = new (dstBin) bif30(srcBin->get30()); break; - case aclBIFVersion31: - dstBin = reinterpret_cast(aclutAlloc(src)(sizeof(bif31))); - dstBin = new (dstBin) bif31(srcBin->get31()); break; - } - if (dstBin->hasError()) { - aclBinaryFini(dst); - return NULL; - } - dst->bin = reinterpret_cast(dstBin); - } - return dst; -} - -// Create a BIF2.1 elf from a BIF 2.0 elf. -// All sections are copied and then if -// CAL/DLL or JITBINARY sections are found, -// the type is set to EXEC. -aclBinary* -convertBIF20ToBIF21(aclBinary *src) { - aclBinary *dst = cloneOclElfNoBIF(src); - if (dst != NULL) { - bifbase *srcBin = reinterpret_cast(aclutGetBIF(src)); - assert(srcBin->get20() != NULL && "Passed in an invalid binary!"); - bif21 *dstBin = NULL; - dstBin = reinterpret_cast(aclutAlloc(src)(sizeof(bif21))); - dstBin = new (dstBin) bif21(srcBin->get20()); - if (dstBin->hasError()) { - aclBinaryFini(dst); - return NULL; - } - dst->bin = reinterpret_cast(dstBin); - } - return dst; -} - -// Create a BIF3.0 elf from a BIF 2.0 elf. -aclBinary* -convertBIF20ToBIF30(aclBinary *src) { - aclBinary *dst = cloneOclElfNoBIF(src); - if (dst != NULL) { - bifbase *srcBin = reinterpret_cast(aclutGetBIF(src)); - assert(srcBin->get20() != NULL && "Passed in an invalid binary!"); - bif30 *dstBin = NULL; - dstBin = reinterpret_cast(aclutAlloc(src)(sizeof(bif30))); - dstBin = new (dstBin) bif30(srcBin->get20()); - if (dstBin->hasError()) { - aclBinaryFini(dst); - return NULL; - } - dst->bin = reinterpret_cast(dstBin); - convertBIF2XMachineTo30(dstBin); - } - return dst; -} - -// Create a BIF3.1 elf from a BIF 2.0 elf. -aclBinary* -convertBIF20ToBIF31(aclBinary *src) { - aclBinary *dst = cloneOclElfNoBIF(src); - if (dst != NULL) { - bifbase *srcBin = reinterpret_cast(aclutGetBIF(src)); - assert(srcBin->get20() != NULL && "Passed in an invalid binary!"); - bif31 *dstBin = NULL; - dstBin = reinterpret_cast(aclutAlloc(src)(sizeof(bif31))); - dstBin = new (dstBin) bif31(srcBin->get20()); - if (dstBin->hasError()) { - aclBinaryFini(dst); - return NULL; - } - dst->bin = reinterpret_cast(dstBin); - convertBIF2XMachineTo31(dstBin); - } - return dst; -} - -// Create a BIF2.0 elf from a BIF 2.1 elf. -// All sections except for the COMMENT section is copied -// verbatim and the section is set to NONE. -aclBinary* -convertBIF21ToBIF20(aclBinary *src) { - aclBinary *dst = cloneOclElfNoBIF(src); - if (dst != NULL) { - bifbase *srcBin = reinterpret_cast(aclutGetBIF(src)); - assert(srcBin->get21() != NULL && "Passed in an invalid binary!"); - bif20 *dstBin = NULL; - dstBin = reinterpret_cast(aclutAlloc(src)(sizeof(bif20))); - dstBin = new (dstBin) bif20(srcBin->get21()); - if (dstBin->hasError()) { - aclBinaryFini(dst); - return NULL; - } - dst->bin = reinterpret_cast(dstBin); - } - return dst; -} - -// Create a BIF3.0 elf from a BIF 2.1 elf. -// See BIF spec for 2.1 to 3.0 conversion -// and also include the comment section. -aclBinary* -convertBIF21ToBIF30(aclBinary *src) { - aclBinary *dst = cloneOclElfNoBIF(src); - if (dst != NULL) { - bifbase *srcBin = reinterpret_cast(aclutGetBIF(src)); - assert(srcBin->get21() != NULL && "Passed in an invalid binary!"); - bif30 *dstBin = NULL; - dstBin = reinterpret_cast(aclutAlloc(src)(sizeof(bif30))); - dstBin = new (dstBin) bif30(srcBin->get21()); - if (dstBin->hasError()) { - aclBinaryFini(dst); - return NULL; - } - dst->bin = reinterpret_cast(dstBin); - convertBIF2XMachineTo30(dstBin); - } - return dst; -} - -// Create a BIF3.1 elf from a BIF 2.1 elf. -// See BIF spec for 3.1 to 2.1 conversion. -aclBinary* -convertBIF21ToBIF31(aclBinary *src) { - aclBinary *dst = cloneOclElfNoBIF(src); - if (dst != NULL) { - bifbase *srcBin = reinterpret_cast(aclutGetBIF(src)); - assert(srcBin->get21() != NULL && "Passed in an invalid binary!"); - bif31 *dstBin = NULL; - dstBin = reinterpret_cast(aclutAlloc(src)(sizeof(bif31))); - dstBin = new (dstBin) bif31(srcBin->get21()); - if (dstBin->hasError()) { - aclBinaryFini(dst); - return NULL; - } - dst->bin = reinterpret_cast(dstBin); - convertBIF2XMachineTo31(dstBin); - } - return dst; -} - -// Create a BIF2.0 elf from a BIF 3.0 elf. -// See BIF spec for 3.0 to 2.0 conversion. -aclBinary* -convertBIF30ToBIF20(aclBinary *src) { - aclBinary *dst = cloneOclElfNoBIF(src); - if (dst != NULL) { - bifbase *srcBin = reinterpret_cast(aclutGetBIF(src)); - assert(srcBin->get30() != NULL && "Passed in an invalid binary!"); - bif20 *dstBin = NULL; - dstBin = reinterpret_cast(aclutAlloc(src)(sizeof(bif20))); - dstBin = new (dstBin) bif20(srcBin->get30()); - if (dstBin->hasError()) { - aclBinaryFini(dst); - return NULL; - } - dst->bin = reinterpret_cast(dstBin); - } - return dst; -} - -// Create a BIF2.1 elf from a BIF 3.0 elf -// See BIF spec for 3.0 to 2.1 conversion -// but also include the COMMENT section. -aclBinary* -convertBIF30ToBIF21(aclBinary *src) { - aclBinary *dst = cloneOclElfNoBIF(src); - if (dst != NULL) { - bifbase *srcBin = reinterpret_cast(aclutGetBIF(src)); - assert(srcBin->get30() != NULL && "Passed in an invalid binary!"); - bif21 *dstBin = NULL; - dstBin = reinterpret_cast(aclutAlloc(src)(sizeof(bif21))); - dstBin = new (dstBin) bif21(srcBin->get30()); - if (dstBin->hasError()) { - aclBinaryFini(dst); - return NULL; - } - dst->bin = reinterpret_cast(dstBin); - } - return dst; -} - -// Create a BIF3.1 elf from a BIF 3.0 elf -// See BIF spec for 3.0 to 3.1 conversion. -aclBinary* -convertBIF30ToBIF31(aclBinary *src) { - aclBinary *dst = cloneOclElfNoBIF(src); - if (dst != NULL) { - bifbase *srcBin = reinterpret_cast(aclutGetBIF(src)); - assert(srcBin->get30() != NULL && "Passed in an invalid binary!"); - bif31 *dstBin = NULL; - dstBin = reinterpret_cast(aclutAlloc(src)(sizeof(bif31))); - dstBin = new (dstBin) bif31(srcBin->get30()); - if (dstBin->hasError()) { - aclBinaryFini(dst); - return NULL; - } - dst->bin = reinterpret_cast(dstBin); - } - return dst; -} - -// Create a BIF2.0 elf from a BIF 3.1 elf. -// See BIF spec for 3.1 to 2.0 conversion. -aclBinary* -convertBIF31ToBIF20(aclBinary *src) { - aclBinary *dst = cloneOclElfNoBIF(src); - if (dst != NULL) { - bifbase *srcBin = reinterpret_cast(aclutGetBIF(src)); - assert(srcBin->get31() != NULL && "Passed in an invalid binary!"); - bif20 *dstBin = NULL; - dstBin = reinterpret_cast(aclutAlloc(src)(sizeof(bif20))); - dstBin = new (dstBin) bif20(srcBin->get31()); - if (dstBin->hasError()) { - aclBinaryFini(dst); - return NULL; - } - dst->bin = reinterpret_cast(dstBin); - } - return dst; -} - -// Create a BIF2.1 elf from a BIF 3.1 elf -// See BIF spec for 3.1 to 2.1 conversion. -aclBinary* -convertBIF31ToBIF21(aclBinary *src) { - aclBinary *dst = cloneOclElfNoBIF(src); - if (dst != NULL) { - bifbase *srcBin = reinterpret_cast(aclutGetBIF(src)); - assert(srcBin->get31() != NULL && "Passed in an invalid binary!"); - bif21 *dstBin = NULL; - dstBin = reinterpret_cast(aclutAlloc(src)(sizeof(bif21))); - dstBin = new (dstBin) bif21(srcBin->get31()); - if (dstBin->hasError()) { - aclBinaryFini(dst); - return NULL; - } - dst->bin = reinterpret_cast(dstBin); - } - return dst; -} - -// Create a BIF3.1 elf from a BIF 3.0 elf -// See BIF spec for 3.0 to 3.1 conversion. -aclBinary* -convertBIF31ToBIF30(aclBinary *src) { - aclBinary *dst = cloneOclElfNoBIF(src); - if (dst != NULL) { - bifbase *srcBin = reinterpret_cast(aclutGetBIF(src)); - assert(srcBin->get31() != NULL && "Passed in an invalid binary!"); - bif30 *dstBin = NULL; - dstBin = reinterpret_cast(aclutAlloc(src)(sizeof(bif30))); - dstBin = new (dstBin) bif30(srcBin->get31()); - if (dstBin->hasError()) { - aclBinaryFini(dst); - return NULL; - } - dst->bin = reinterpret_cast(dstBin); - } - return dst; -} - -void dump(aclBinary *bin) { - bifbase *elfBin = reinterpret_cast(bin->bin); - elfBin->dump(); -} - -const std::string &getLegacyLibName() { - return legacyLibName; -} diff --git a/rocclr/compiler/lib/utils/v0_8/libUtils.h b/rocclr/compiler/lib/utils/v0_8/libUtils.h deleted file mode 100644 index 772cdb661d..0000000000 --- a/rocclr/compiler/lib/utils/v0_8/libUtils.h +++ /dev/null @@ -1,421 +0,0 @@ -// -// Copyright (c) 2011 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _CL_LIB_UTILS_0_8_H_ -#define _CL_LIB_UTILS_0_8_H_ -#include "acl.h" -#include -#include -#include -#include -#include -#include -#include "library.hpp" -#include "utils/bif_section_labels.hpp" -#include "utils/options.hpp" -using namespace bif; - -// Utility function to set a flag in option structure -// of the aclDevCaps. -void -setFlag(aclDevCaps *elf, compDeviceCaps option); - -// Utility function to flip a flag in option structure -// of the aclDevCaps. -void -flipFlag(aclDevCaps *elf, compDeviceCaps option); - -// Utility function to clear a flag in option structure -// of the aclDevCaps. -void -clearFlag(aclDevCaps *elf, compDeviceCaps option); - -// Utility function to check that a flag in option structure -// of the aclDevCaps is set. -bool -checkFlag(aclDevCaps *elf, compDeviceCaps option); - -// Utility function to initialize and elf device capabilities -void -initElfDeviceCaps(aclBinary *elf); - -// Append the string to the aclCompiler log string. -void -appendLogToCL(aclCompiler *cl, const std::string &logStr); - -const char *getDeviceName(const aclTargetInfo &target); - -// Select the correct library from the target information. -amd::LibrarySelector getLibraryType(const aclTargetInfo *target); - -// get family_enum from the target information. -unsigned getFamilyEnum(const aclTargetInfo *target); - -// get chip_enum from the target information. -unsigned getChipEnum(const aclTargetInfo *target); - -// get isa type name (compute capability) from the target information. -const std::string &getIsaTypeName(const aclTargetInfo *target); - -// get isa type (compute capability) from the target information. -int getIsaType(const aclTargetInfo *target); - -// get Feature String for target. -std::string getFeatureString(const aclTargetInfo& target, amd::option::Options *OptionsObj); - -// Create a copy of an ELF and duplicate all sections/symbols -aclBinary* -createELFCopy(aclBinary *src); - -// Create a BIF2.1 elf from a BIF 2.0 elf -aclBinary* -convertBIF20ToBIF21(aclBinary *src); - -// Create a BIF3.0 elf from a BIF 2.0 elf -aclBinary* -convertBIF20ToBIF30(aclBinary *src); - -// Create a BIF3.1 elf from a BIF 2.0 elf -aclBinary* -convertBIF20ToBIF31(aclBinary *src); - -// Create a BIF2.0 elf from a BIF 2.1 elf -aclBinary* -convertBIF21ToBIF20(aclBinary *src); - -// Create a BIF3.0 elf from a BIF 2.1 elf -aclBinary* -convertBIF21ToBIF30(aclBinary *src); - -// Create a BIF3.1 elf from a BIF 2.1 elf -aclBinary* -convertBIF21ToBIF31(aclBinary *src); - -// Create a BIF2.0 elf from a BIF 3.0 elf -aclBinary* -convertBIF30ToBIF20(aclBinary *src); - -// Create a BIF2.1 elf from a BIF 3.0 elf -aclBinary* -convertBIF30ToBIF21(aclBinary *src); - -// Create a BIF3.1 elf from a BIF 3.0 elf -aclBinary* -convertBIF30ToBIF31(aclBinary *src); - -// Create a BIF2.0 elf from a BIF 3.1 elf -aclBinary* -convertBIF31ToBIF20(aclBinary *src); - -// Create a BIF2.1 elf from a BIF 3.1 elf -aclBinary* -convertBIF31ToBIF21(aclBinary *src); - -// Create a BIF3.0 elf from a BIF 3.1 elf -aclBinary* -convertBIF31ToBIF30(aclBinary *src); - -// get a pointer to the aclBIF irrespective of the -// binary version. -aclBIF* -aclutGetBIF(aclBinary*); - -// Get a pointer to the aclOptions irrespective of -// the binary version. -aclOptions* -aclutGetOptions(aclBinary*); - -// Get a pointer to the aclBinaryOptions struct -// irrespective of the binary version. -aclBinaryOptions* -aclutGetBinOpts(aclBinary*); - -// Get a pointer to the target info struct -// irrespective of the binary version. -aclTargetInfo* -aclutGetTargetInfo(aclBinary*); - -// Get a pointer to the device caps -// irrespective of the binary version. -aclDevCaps* -aclutGetCaps(aclBinary*); - -// Copy two binary option structures irrespective -// of the binary version and uses defaults when -// things don't match up. -void -aclutCopyBinOpts(aclBinaryOptions *dst, - const aclBinaryOptions *src, - bool is64bit); - -// Retrieve kernel statistics from binary -// and insert to elf as symbol -acl_error aclutInsertKernelStatistics(aclCompiler*, aclBinary*); - -// Returns target chip name. -std::string aclutGetCodegenName(const aclTargetInfo &tgtInfo); - -// Helper function that returns the -// allocation function from the binary. -AllocFunc -aclutAlloc(const aclBinary *bin); - -// Helper function that returns the -// de-allocation function from the binary. -FreeFunc -aclutFree(const aclBinary *bin); - - -// Helper function that returns the -// allocation function from the compiler. -AllocFunc -aclutAlloc(const aclCompiler *bin); - -// Helper function that returns the -// de-allocation function from the compiler. -FreeFunc -aclutFree(const aclCompiler *bin); - -// Helper function that returns the -// allocation function from the compiler options. -AllocFunc -aclutAlloc(const aclCompilerOptions *bin); - -// Helper function that returns the -// de-allocation function from the compiler options. -FreeFunc -aclutFree(const aclCompilerOptions *bin); - -inline std::vector splitSpaceSeparatedString(char *str) -{ - std::string s(str); - std::stringstream ss(s); - std::istream_iterator beg(ss), end; - std::vector vec(beg, end); - return vec; -} - -// Helper function that returns OpenCL mangled kernel name. -inline std::string -aclutOpenclMangledKernelName(const std::string& kernel_name) -{ - const oclBIFSymbolStruct* sym = findBIF30SymStruct(symOpenclKernel); - assert(sym && "symbol not found"); - return std::string("&") + sym->str[PRE] + kernel_name + sym->str[POST]; -} - -// Helper function that returns OpenCL mangled kernel metadata symbol name. -inline std::string -aclutOpenclMangledKernelMetadataName(const std::string& kernel_name) -{ - const oclBIFSymbolStruct* sym = findBIF30SymStruct(symOpenclMeta); - assert(sym && "symbol not found"); - return sym->str[PRE] + aclutOpenclMangledKernelName(kernel_name) + sym->str[POST]; -} - -#ifdef WITH_TARGET_HSAIL -// Helper function that updates metadata for all the kernels in binary; -// the updated attribute is the number of hidden kernel arguments. -inline acl_error -aclutUpdateMetadataWithHiddenKernargsNum(aclCompiler* cl, aclBinary* bin, uint32_t num) { - if (num == MAX_HIDDEN_KERNARGS_NUM) { - return ACL_SUCCESS; - } - const oclBIFSymbolStruct* sym = findBIF30SymStruct(symOpenclMeta); - assert(sym && "symbol not found"); - aclSections secID = sym->sections[0]; - size_t kernelNamesSize = 0; - acl_error error_code = aclQueryInfo(cl, bin, RT_KERNEL_NAMES, NULL, NULL, &kernelNamesSize); - if (error_code != ACL_SUCCESS) { - return error_code; - } - char* kernelNames = new char[kernelNamesSize]; - error_code = aclQueryInfo(cl, bin, RT_KERNEL_NAMES, NULL, kernelNames, &kernelNamesSize); - if (error_code != ACL_SUCCESS) { - delete[] kernelNames; - return error_code; - } - std::vector vKernels = splitSpaceSeparatedString(kernelNames); - delete[] kernelNames; - size_t roSize = 0; - for (auto it = vKernels.begin(); it != vKernels.end(); ++it) { - std::string symbol = aclutOpenclMangledKernelMetadataName(*it); - void* roSec = const_cast(aclExtractSymbol(cl, bin, &roSize, secID, symbol.c_str(), &error_code)); - if (error_code != ACL_SUCCESS) { - return error_code; - } - if (!roSec || roSize == 0) { - error_code = ACL_ELF_ERROR; - return error_code; - } - aclMetadata *md = reinterpret_cast(roSec); - md->numHiddenKernelArgs = num; - error_code = aclRemoveSymbol(cl, bin, secID, symbol.c_str()); - if (error_code != ACL_SUCCESS) { - return error_code; - } - error_code = aclInsertSymbol(cl, bin, md, roSize, secID, symbol.c_str()); - if (error_code != ACL_SUCCESS) { - return error_code; - } - } - return error_code; -} -#endif - -struct _target_mappings_rec; -typedef _target_mappings_rec TargetMapping; - -// Returns the TargetMapping for the specific target device. -const TargetMapping& getTargetMapping(const aclTargetInfo &target); - -inline bool is64BitTarget(const aclTargetInfo& target) -{ - return (target.arch_id == aclX64 || - target.arch_id == aclAMDIL64 || - target.arch_id == aclHSAIL64); -} - -inline bool isCpuTarget(const aclTargetInfo& target) -{ - return (target.arch_id == aclX64 || target.arch_id == aclX86); -} - -inline bool isGpuTarget(const aclTargetInfo& target) -{ - return (target.arch_id == aclAMDIL || target.arch_id == aclAMDIL64 || - target.arch_id == aclHSAIL || target.arch_id == aclHSAIL64); -} - -inline bool isAMDILTarget(const aclTargetInfo& target) -{ - return (target.arch_id == aclAMDIL || target.arch_id == aclAMDIL64); -} - -inline bool isHSAILTarget(const aclTargetInfo& target) -{ - return (target.arch_id == aclHSAIL || target.arch_id == aclHSAIL64); -} - -const std::string& getLegacyLibName(); - -inline bool isValidTarget(const aclTargetInfo& target) -{ - return (target.arch_id && target.chip_id); -} - -bool isChipSupported(const aclTargetInfo& target); - -enum scId { - SC_AMDIL = 0, - SC_HSAIL = 0, - SC_LAST, -}; - -// Helper function that allocates an aligned memory. -inline void* -alignedMalloc(size_t size, size_t alignment) -{ -#if defined(_WIN32) - return ::_aligned_malloc(size, alignment); -#else - void * ptr = NULL; - if (0 == ::posix_memalign(&ptr, alignment, size)) { - return ptr; - } - return NULL; -#endif -} - -// Helper function that frees an aligned memory. -inline void -alignedFree(void *ptr) -{ -#if defined(_WIN32) - ::_aligned_free(ptr); -#else - free(ptr); -#endif -} - -#if defined(_WIN32) -inline void convertLongAbsFilePathIfNeeded(std::string &filename) -{ - if (filename.empty()) { - return; - } - std::wstring ws(filename.begin(), filename.end()); - wchar_t abs_path[_MAX_ENV]; - _wfullpath(abs_path, ws.c_str(), _MAX_ENV); - std::wstring ws_abs = std::wstring(abs_path); - if (ws_abs.size() >= _MAX_PATH) { - std::string s(ws_abs.begin(), ws_abs.end()); - filename = "\\\\?\\" + s; - } -} -#endif - -inline char* readFile(std::string source_filename, size_t& size) -{ -#if defined(_WIN32) - convertLongAbsFilePathIfNeeded(source_filename); -#endif - FILE *fp = ::fopen( source_filename.c_str(), "rb" ); - unsigned int length; - size_t offset = 0; - char *ptr; - if (!fp) { - return NULL; - } - // obtain file size - ::fseek (fp , 0 , SEEK_END); - length = ::ftell (fp); - ::rewind (fp); - ptr = reinterpret_cast(::malloc(offset + length + 1)); - if (length != fread(&ptr[offset], 1, length, fp)) - { - ::free(ptr); - ::fclose(fp); - return NULL; - } - ptr[offset + length] = '\0'; - size = offset + length; - ::fclose(fp); - return ptr; -} - -inline bool writeFile(std::string source_filename, const char *source, size_t size) -{ -#if defined(_WIN32) - convertLongAbsFilePathIfNeeded(source_filename); -#endif - FILE *fp = ::fopen(source_filename.c_str(), "wb"); - if (!fp) { - return EXIT_FAILURE; - } - if (!::fwrite(source, size, 1, fp)) { - ::fclose(fp); - return EXIT_FAILURE; - } - ::fclose(fp); - return EXIT_SUCCESS; -} - -#if !defined(BCMAG) -#define BCMAG "BC" -#define SBCMAG 2 -#endif -// Helper predicate returns true if p starts with bit code signature. -// TODO: Move it into Compiler Lib back in new 1_0 API -inline static bool -isBcMagic(const char* p) -{ - if (p==NULL || strncmp(p, BCMAG, SBCMAG) != 0) { - return false; - } - return true; -} - -void dump(aclBinary *bin); - -#endif // _CL_LIB_UTILS_0_8_H_ diff --git a/rocclr/compiler/lib/utils/v0_8/target_mappings.h b/rocclr/compiler/lib/utils/v0_8/target_mappings.h deleted file mode 100644 index 4271a59a77..0000000000 --- a/rocclr/compiler/lib/utils/v0_8/target_mappings.h +++ /dev/null @@ -1,311 +0,0 @@ -// -// Copyright (c) 2011 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _CL_UTILS_TARGET_MAPPINGS_0_8_H_ -#define _CL_UTILS_TARGET_MAPPINGS_0_8_H_ -#include "top.hpp" -#include "library.hpp" -#include "aclTypes.h" -#ifndef FAMILY_UNKNOWN -#define FAMILY_UNKNOWN 0 -#endif - -#ifndef FAMILY_X86 -#define FAMILY_X86 1 -#endif - -#ifndef FAMILY_X64 -#define FAMILY_X64 2 -#endif - -#define ARRAY_SIZEOF(A) (sizeof(A)/sizeof(A[0])) - -typedef struct _target_mappings_rec { - const char* family_name; - const char* chip_name; - const char* codegen_name; - amd::LibrarySelector lib; - unsigned chip_enum; - uint64_t chip_options; - bool supported; // a false value means this device is not supported. - bool default_chip; // Chip to select if multiple chips with the same name exist. - unsigned family_enum; // Only used for GPU devices currently, for CPU we should put features. - bool xnack_supported; // XNACK support as per http://confluence.amd.com/pages/viewpage.action?spaceKey=ASLC&title=AMDGPU+Target+Names -} TargetMapping; - -const TargetMapping UnknownTarget = { "UnknownFamily", "UnknownChip", "UnknownCodeGen", - amd::LibraryUndefined, 0, 0, false, false, FAMILY_UNKNOWN, false}; -const TargetMapping InvalidTarget = { NULL, NULL, NULL, - amd::LibraryUndefined, 0, 0, false, false, FAMILY_UNKNOWN, false}; - -typedef struct _family_map_rec { - const TargetMapping* target; - const char* architecture; - const char* triple; - unsigned children_size; -} FamilyMapping; -const FamilyMapping UnknownFamily = { NULL, "UnknownFamily", "unknown", 0 }; -const FamilyMapping InvalidFamily = { NULL, NULL, NULL, 0 }; -typedef enum { - F_CPU_CMOV = 1, - F_CPU_POPCNT = 2, - F_CPU_MMX = 3, - F_CPU_SSE1 = 4, - F_CPU_SSE2 = 5, - F_CPU_SSE3 = 6, - F_CPU_SSSE3 = 7, - F_CPU_SSE41 = 8, - F_CPU_SSE42 = 9, - F_CPU_SSE4A = 10, - F_CPU_3DNow = 11, - F_CPU_3DNowA = 12, - F_CPU_64Bit = 13, - F_CPU_SBTMem = 14, - F_CPU_FUAMem = 15, - F_CPU_AVX = 16, - F_CPU_CLMUL = 17, - F_CPU_VUAMem = 18, - F_CPU_AES = 19, - F_CPU_CXCHG16B = 20, - F_CPU_AVX2 = 21, - F_CPU_FMA3 = 22, - F_CPU_FMA4 = 23, - F_CPU_MOVBE = 24, - F_CPU_RDRAND = 25, - F_CPU_F16C = 26, - F_CPU_64BitMode = 27, - F_CPU_LZCNT = 28, - F_CPU_BMI = 29, - F_CPU_BMI2 = 30, // LLVM 3.1 only - F_CPU_LeaForSP = 31, // LLVM 3.1 only - F_CPU_FSGSBASE = 32, // LLVM 3.1 only - F_CPU_XOP = 33, // LLVM 3.1 only - F_CPU_ATOM = 34, // LLVM 3.1 only - F_CPU_LAST = 35 -} CPUCodeGenFlags; - -static const char* CPUCodeGenFlagTable[] = -{ - "cmov", - "popcnt", - "mmx", - "sse", - "sse2", - "sse3", - "ssse3", - "sse41", - "sse42", - "sse4a", - "3dnow", - "3dnowa", - "64bit", - "slow-bt-mem", - "fast-unaligned-mem", - "avx", - "clmul", - "vector-unaligned-mem", - "aes", - "cmpxchg16b", - "avx2", - "fma3", - "fma4", - "movbe", - "rdrand", - "f16c", - "fsgsbase", - "lzcnt", - "bmi", - "bmi2", - "lea-sp", - "64bit-mode", - "xop", - "atom" -}; - -typedef enum { - // Bits for each feature. - F_FP64 = 0x0001, - F_BYTE_ADDRESSABLE = 0x0002, - F_BARRIER_DETECT = 0x0004, - F_IMAGES = 0x0008, - F_MULTI_UAV = 0x0010, - F_MACRO_DB = 0x0020, - F_NO_ALIAS = 0x0040, - F_NO_INLINE = 0x0080, - F_64BIT_PTR = 0x0100, - F_32ON64BIT_PTR = 0x0200, - F_DEBUG = 0x0400, - F_MWGS_256 = 0x0800, - F_MWGS_128 = 0x1000, - F_MWGS_64 = 0x2000, - F_MWGS_32 = 0x4000, - F_MWGS_16 = 0x8000, - F_MD_30 = 0x10000, - F_STACK_UAV = 0x20000, - F_MACRO_CALL = 0x40000, - // Bitmasks for each device type. - F_RV7XX_BASE = F_MACRO_DB|F_BARRIER_DETECT|F_MD_30, - F_RV710 = F_RV7XX_BASE|F_MWGS_32, - F_RV730 = F_RV7XX_BASE|F_MWGS_16, - F_RV770 = F_RV7XX_BASE|F_MWGS_64|F_FP64, - F_EG_BASE = F_BYTE_ADDRESSABLE|F_IMAGES|F_MACRO_DB|F_MD_30, - F_EG_EXT = F_EG_BASE|F_FP64|F_MWGS_256, - F_CEDAR = F_EG_BASE|F_MWGS_128, - F_REDWOOD = F_EG_BASE|F_MWGS_256, - F_JUNIPER = F_EG_BASE|F_MWGS_256, - F_NI_BASE = F_EG_BASE|F_MWGS_256, - F_NI_EXT = F_NI_BASE|F_FP64, - F_SI_BASE = F_NI_EXT|F_STACK_UAV|F_MACRO_CALL, - F_SI_64BIT_PTR = F_SI_BASE|F_64BIT_PTR -} GPUCodeGenFlags; - -typedef enum { - // Bits for each feature. - F_FP32_DENORMS = 0x0001, - // Bitmasks for each device type. - F_CI_BASE = 0, - F_VI_BASE = F_CI_BASE | F_FP32_DENORMS, - F_AI_BASE = F_VI_BASE -} HSAILCodeGenFlags; - -static const char* GPUCodeGenFlagTable[] = { - "fp64", - "byte_addressable_store", - "barrier_detect", - "images", - "multi_uav", - "macrodb", - "noalias", - "no-inline", - "64bitptr", - "small-global-objects", - "debug", - "mwgs-3-256-1-1", - "mwgs-3-128-1-1", - "mwgs-3-64-1-1", - "mwgs-3-32-1-1", - "mwgs-3-16-1-1", - "metadata30", - "stack-uav", - "macro-call" -}; - -static const char* HSAILCodeGenFlagTable[] = { - "fp32-denormals" -}; - -static const char* calTargetMapping[] = { - "RV600", "RV610", "RV630", "RV670", - "RV770", "RV770", "RV710", "RV730", - "Cypress", "Juniper", "Redwood", "Cedar", - "WinterPark", "BeaverCreek", "Loveland", - "Cayman", "Kauai", "Barts", "Turks", "Caicos", - "Tahiti", "Pitcairn", "Capeverde", - "Devastator", "Scrapper", - "Oland", "Bonaire", - "Spectre", "Spooky", "Kalindi", - "Hainan", "Hawaii", - "Iceland", "Tonga", "Mullins", "Fiji", - "Carrizo", "Ellesmere", "Baffin", - IF(IS_BRAHMA,"","gfx900"), - "Stoney", - "gfx804", - IF(IS_BRAHMA,"","gfx901"), - IF(IS_BRAHMA,"","gfx902"), - IF(IS_BRAHMA,"","gfx903"), - IF(IS_BRAHMA,"","gfx904"), - IF(IS_BRAHMA,"","gfx905"), - IF(IS_BRAHMA,"","gfx906"), - IF(IS_BRAHMA,"","gfx907"), - IF(IS_BRAHMA,"","gfx908"), - IF(IS_BRAHMA,"","gfx1000"), - IF(IS_BRAHMA,"","gfx1010"), - IF(IS_BRAHMA,"","gfx1011"), - IF(IS_BRAHMA,"","gfx1012"), -}; - -#include "utils/v0_8/target_mappings_amdil.h" -#include "utils/v0_8/target_mappings_hsail.h" -#include "utils/v0_8/target_mappings_x86.h" -#include "utils/v0_8/target_mappings_x64.h" -#include "utils/v0_8/target_mappings_amdil64.h" -#include "utils/v0_8/target_mappings_hsail64.h" -// FIXME: Add static asserts to make sure that all of the arrays for TargetMapping match the enum table. - -#define DATA_LAYOUT_64BIT "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16" \ - "-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f80:32:32" \ - "-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64" \ - "-v96:128:128-v128:128:128-v192:256:256-v256:256:256" \ - "-v512:512:512-v1024:1024:1024-v2048:2048:2048-a0:0:64" \ - "-n32" - -#define DATA_LAYOUT_32BIT "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16" \ - "-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f80:32:32" \ - "-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64" \ - "-v96:128:128-v128:128:128-v192:256:256-v256:256:256" \ - "-v512:512:512-v1024:1024:1024-v2048:2048:2048-a0:0:64" \ - "-n32" - -inline const char* getArchitecture(aclDevType arch_id) -{ - switch (arch_id) { - case aclX86: - return "x86"; - case aclAMDIL: - return "amdil"; - case aclHSAIL: - return "hsail"; - case aclX64: - return "x86-64"; - case aclHSAIL64: - return "hsail64"; - case aclAMDIL64: - return "amdil64"; - default: - return NULL; - } -} - -inline const char* getTriple(aclDevType arch_id) -{ - switch (arch_id) { - case aclX86: -#ifdef _WIN32 - return "i686-pc-mingw32-amdopencl"; -#else - return "i686-pc-linux-amdopencl"; -#endif - case aclAMDIL: - return "amdil-pc-unknown-amdopencl"; - case aclHSAIL: - return "hsail-pc-unknown-amdopencl"; - case aclX64: -#ifdef _WIN32 - return "x86_64-pc-mingw32-amdopencl"; -#else - return "x86_64-pc-linux-amdopencl"; -#endif - case aclHSAIL64: - return "hsail64-pc-unknown-amdopencl"; - case aclAMDIL64: - return "amdil64-pc-unknown-amdopencl"; - default: - return NULL; - } -} - -// The contents of this array has to match the sequence defined in -// aclDevType_0_8 -static const FamilyMapping familySet[] = -{ - UnknownFamily, - { (const TargetMapping*)&X86TargetMapping_0_8, getArchitecture(aclX86), getTriple(aclX86), ARRAY_SIZEOF(X86TargetMapping_0_8) }, - { (const TargetMapping*)&AMDILTargetMapping_0_8, getArchitecture(aclAMDIL), getTriple(aclAMDIL), ARRAY_SIZEOF(AMDILTargetMapping_0_8) }, - { (const TargetMapping*)&HSAILTargetMapping_0_8, getArchitecture(aclHSAIL), getTriple(aclHSAIL), ARRAY_SIZEOF(HSAILTargetMapping_0_8) }, - { (const TargetMapping*)&X64TargetMapping_0_8, getArchitecture(aclX64), getTriple(aclX64), ARRAY_SIZEOF(X64TargetMapping_0_8) }, - { (const TargetMapping*)&HSAIL64TargetMapping_0_8, getArchitecture(aclHSAIL64), getTriple(aclHSAIL64), ARRAY_SIZEOF(HSAIL64TargetMapping_0_8) }, - { (const TargetMapping*)&AMDIL64TargetMapping_0_8, getArchitecture(aclAMDIL64), getTriple(aclAMDIL64), ARRAY_SIZEOF(AMDIL64TargetMapping_0_8) }, - InvalidFamily -}; - -#endif // _CL_UTILS_TARGET_MAPPINGS_0_8_H_ diff --git a/rocclr/compiler/lib/utils/v0_8/target_mappings_amdil.h b/rocclr/compiler/lib/utils/v0_8/target_mappings_amdil.h deleted file mode 100644 index c896cfe42f..0000000000 --- a/rocclr/compiler/lib/utils/v0_8/target_mappings_amdil.h +++ /dev/null @@ -1,109 +0,0 @@ -// -// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _CL_UTILS_TARGET_MAPPINGS_AMDIL_0_8_H_ -#define _CL_UTILS_TARGET_MAPPINGS_AMDIL_0_8_H_ - -#include "evergreen_id.h" -#include "r700id.h" -#include "tn_id.h" -#include "sumo_id.h" -#include "northernisland_id.h" -#include "si_id.h" -#include "kv_id.h" -#include "ci_id.h" -#include "vi_id.h" -#include "cz_id.h" -#include "ai_id.h" -#include "atiid.h" - -static const TargetMapping AMDILTargetMapping_0_8[] = { - UnknownTarget, - { "R7XX", "RV770", "rv770", amd::GPU_Library_7xx, WEKIVA_A11, F_RV770, false, false, FAMILY_RV7XX }, - { "R7XX", "RV770", "rv770", amd::GPU_Library_7xx, WEKIVA_A12, F_RV770, false, true , FAMILY_RV7XX }, - { "R7XX", "RV790", "rv770", amd::GPU_Library_7xx, WEKIVA_A21, F_RV770, false, true , FAMILY_RV7XX }, - { "R7XX", "RV730", "rv730", amd::GPU_Library_7xx, MARIO_A11, F_RV730, false, false, FAMILY_RV7XX }, - { "R7XX", "RV730", "rv730", amd::GPU_Library_7xx, MARIO_A12, F_RV730, false, false, FAMILY_RV7XX }, - { "R7XX", "RV730", "rv730", amd::GPU_Library_7xx, MARIO_A13, F_RV730, false, true , FAMILY_RV7XX }, - { "R7XX", "RV710", "rv710", amd::GPU_Library_7xx, LUIGI_A11, F_RV710, false, false, FAMILY_RV7XX }, - { "R7XX", "RV710", "rv710", amd::GPU_Library_7xx, LUIGI_A12, F_RV710, false, true , FAMILY_RV7XX }, - { "R7XX", "RV710", "rv710", amd::GPU_Library_7xx, LUIGI_APU_A11, F_RV710, false, false, FAMILY_RV7XX }, - { "R7XX", "RV740", "rv770", amd::GPU_Library_7xx, WALDEN_A11, F_RV770, false, false, FAMILY_RV7XX }, - { "R7XX", "RV740", "rv770", amd::GPU_Library_7xx, WALDEN_A12, F_RV770, false, true , FAMILY_RV7XX }, - { "Evergreen", "Cypress", "cypress", amd::GPU_Library_Evergreen, CYPRESS_A11, F_EG_EXT, false , false, FAMILY_EVERGREEN }, - { "Evergreen", "Cypress", "cypress", amd::GPU_Library_Evergreen, CYPRESS_A12, F_EG_EXT, false , true , FAMILY_EVERGREEN }, - { "Evergreen", "Juniper", "juniper", amd::GPU_Library_Evergreen, JUNIPER_A11, F_JUNIPER, false , false, FAMILY_EVERGREEN }, - { "Evergreen", "Juniper", "juniper", amd::GPU_Library_Evergreen, JUNIPER_A12, F_JUNIPER, false , true , FAMILY_EVERGREEN }, - { "Evergreen", "Redwood", "redwood", amd::GPU_Library_Evergreen, REDWOOD_A11, F_REDWOOD, false , false, FAMILY_EVERGREEN }, - { "Evergreen", "Redwood", "redwood", amd::GPU_Library_Evergreen, REDWOOD_A12, F_REDWOOD, false , true , FAMILY_EVERGREEN }, - { "Evergreen", "Cedar", "cedar", amd::GPU_Library_Evergreen, CEDAR_A11, F_CEDAR, false , false, FAMILY_EVERGREEN }, - { "Evergreen", "Cedar", "cedar", amd::GPU_Library_Evergreen, CEDAR_A12, F_CEDAR, false , true , FAMILY_EVERGREEN }, - { "NI", "Cayman", "cayman", amd::GPU_Library_Evergreen, NI_CAYMAN_P_A11, F_NI_EXT, false , true , FAMILY_NI }, - { "NI", "Barts", "barts", amd::GPU_Library_Evergreen, NI_BARTS_PM_A11, F_NI_BASE, false , true , FAMILY_NI }, - { "NI", "Turks", "turks", amd::GPU_Library_Evergreen, NI_TURKS_M_A11, F_NI_BASE, false , true , FAMILY_NI }, - { "NI", "Lombok", "turks", amd::GPU_Library_Evergreen, NI_TURKS_LOMBOK_M_A11, F_NI_BASE, false , true , FAMILY_NI }, - { "NI", "Caicos", "caicos", amd::GPU_Library_Evergreen, NI_CAICOS_V_A11, F_NI_BASE, false , true , FAMILY_NI }, - { "NI", "Kauai", "kauai", amd::GPU_Library_Evergreen, KAUAI_A11, F_NI_BASE, false, false, FAMILY_NI }, - { "Sumo", "BeaverCreek", "redwood", amd::GPU_Library_Evergreen, SUPERSUMO_A0, F_REDWOOD, false , false, FAMILY_SUMO }, - { "Sumo", "BeaverCreek", "redwood", amd::GPU_Library_Evergreen, SUPERSUMO_B0, F_REDWOOD, false , true , FAMILY_SUMO }, - { "Sumo", "WinterPark", "redwood", amd::GPU_Library_Evergreen, SUMO_A0, F_REDWOOD, false , false, FAMILY_SUMO }, - { "Sumo", "WinterPark", "redwood", amd::GPU_Library_Evergreen, SUMO_B0, F_REDWOOD, false , true , FAMILY_SUMO }, - { "Sumo", "Loveland", "cedar", amd::GPU_Library_Evergreen, WRESTLER_A0, F_REDWOOD, false , false, FAMILY_SUMO }, - { "Sumo", "Loveland", "cedar", amd::GPU_Library_Evergreen, WRESTLER_A1, F_REDWOOD, false , false, FAMILY_SUMO }, - { "Sumo", "Loveland", "cedar", amd::GPU_Library_Evergreen, WRESTLER_B0, F_REDWOOD, false , false, FAMILY_SUMO }, - { "Sumo", "Loveland", "cedar", amd::GPU_Library_Evergreen, WRESTLER_C0, F_REDWOOD, false , true , FAMILY_SUMO }, - { "Sumo", "Bheem", "cedar", amd::GPU_Library_Evergreen, BHEEM_A0, F_REDWOOD, false , true , FAMILY_SUMO }, - { "SI", "Tahiti", "tahiti", amd::GPU_Library_SI, SI_TAHITI_P_A11, F_SI_BASE, true ,false, FAMILY_SI }, - { "SI", "Tahiti", "tahiti", amd::GPU_Library_SI, SI_TAHITI_P_A0, F_SI_BASE, true ,false, FAMILY_SI }, - { "SI", "Tahiti", "tahiti", amd::GPU_Library_SI, SI_TAHITI_P_A21, F_SI_BASE, true ,false, FAMILY_SI }, - { "SI", "Tahiti", "tahiti", amd::GPU_Library_SI, SI_TAHITI_P_B0, F_SI_BASE, true ,false, FAMILY_SI }, - { "SI", "Tahiti", "tahiti", amd::GPU_Library_SI, SI_TAHITI_P_A22, F_SI_BASE, true ,false, FAMILY_SI }, - { "SI", "Tahiti", "tahiti", amd::GPU_Library_SI, SI_TAHITI_P_B1, F_SI_BASE, true , true, FAMILY_SI }, - { "SI", "Pitcairn", "pitcairn", amd::GPU_Library_SI, SI_PITCAIRN_PM_A11, F_SI_BASE, true ,false, FAMILY_SI }, - { "SI", "Pitcairn", "pitcairn", amd::GPU_Library_SI, SI_PITCAIRN_PM_A0, F_SI_BASE, true ,false, FAMILY_SI }, - { "SI", "Pitcairn", "pitcairn", amd::GPU_Library_SI, SI_PITCAIRN_PM_A12, F_SI_BASE, true ,false, FAMILY_SI }, - { "SI", "Pitcairn", "pitcairn", amd::GPU_Library_SI, SI_PITCAIRN_PM_A1, F_SI_BASE, true , true, FAMILY_SI }, - { "SI", "Capeverde", "capeverde", amd::GPU_Library_SI, SI_CAPEVERDE_M_A11, F_SI_BASE, true ,false, FAMILY_SI }, - { "SI", "Capeverde", "capeverde", amd::GPU_Library_SI, SI_CAPEVERDE_M_A0, F_SI_BASE, true ,false, FAMILY_SI }, - { "SI", "Capeverde", "capeverde", amd::GPU_Library_SI, SI_CAPEVERDE_M_A12, F_SI_BASE, true ,false, FAMILY_SI }, - { "SI", "Capeverde", "capeverde", amd::GPU_Library_SI, SI_CAPEVERDE_M_A1, F_SI_BASE, true , true, FAMILY_SI }, - { "TN", "Devastator", "trinity", amd::GPU_Library_Evergreen, TN_DEVASTATOR_M_A0, F_NI_EXT, false, false, FAMILY_TN }, - { "TN", "Devastator", "trinity", amd::GPU_Library_Evergreen, TN_DEVASTATOR_M_A1, F_NI_EXT, false, true, FAMILY_TN }, - { "TN", "Devastator", "trinity", amd::GPU_Library_Evergreen, TN_DEVASTATOR_LITE_MV_A0, F_NI_EXT, false, false, FAMILY_TN }, - { "TN", "Devastator", "trinity", amd::GPU_Library_Evergreen, TN_DEVASTATOR_LITE_MV_A1, F_NI_EXT, false, false, FAMILY_TN }, - { "TN", "Devastator", "trinity", amd::GPU_Library_Evergreen, TN_DEVASTATOR_V_A0, F_NI_EXT, false, false, FAMILY_TN }, - { "TN", "Devastator", "trinity", amd::GPU_Library_Evergreen, TN_DEVASTATOR_V_A1, F_NI_EXT, false, false, FAMILY_TN }, - { "TN", "Scrapper", "trinity", amd::GPU_Library_Evergreen, TN_SCRAPPER_V_A0, F_NI_EXT, false, false, FAMILY_TN }, - { "TN", "Scrapper", "trinity", amd::GPU_Library_Evergreen, TN_SCRAPPER_V_A1, F_NI_EXT, false, true, FAMILY_TN }, - { "TN", "Scrapper", "trinity", amd::GPU_Library_Evergreen, TN_DVST_DUO_V_A0, F_NI_EXT, false, false, FAMILY_TN }, - { "KV", "Spectre", "spectre", amd::GPU_Library_CI, KV_SPECTRE_A0, F_SI_BASE, false, true, FAMILY_KV }, - { "KV", "Spooky", "spooky", amd::GPU_Library_CI, KV_SPOOKY_A0, F_SI_BASE, false, true, FAMILY_KV }, - { "KV", "Kalindi", "kalindi", amd::GPU_Library_CI, KB_KALINDI_A0, F_SI_BASE, false, true, FAMILY_KV }, - { "CI", "Hawaii", "hawaii", amd::GPU_Library_CI, CI_HAWAII_P_A0, F_SI_BASE, false, true, FAMILY_CI }, - { "KV", "Mullins", "mullins", amd::GPU_Library_CI, ML_GODAVARI_A0, F_SI_BASE, false, true, FAMILY_KV }, - { "SI", "Oland", "oland", amd::GPU_Library_SI, SI_OLAND_M_A0, F_SI_BASE, true, true, FAMILY_SI }, - { "CI", "Bonaire", "bonaire", amd::GPU_Library_CI, CI_BONAIRE_M_A0, F_SI_BASE, false, false, FAMILY_CI }, - { "SI", "Hainan", "hainan", amd::GPU_Library_SI, SI_HAINAN_V_A0, F_SI_BASE, true, true, FAMILY_SI }, - - UnknownTarget, - UnknownTarget, - { "CZ", "Carrizo", "carrizo", amd::GPU_Library_CI, CARRIZO_A0, F_SI_BASE, false, true, FAMILY_CZ }, - { "TN", "Devastator", "trinity", amd::GPU_Library_Evergreen, TN_DEVASTATOR_W_A0, F_NI_EXT, false, false, FAMILY_TN }, - { "TN", "Devastator", "trinity", amd::GPU_Library_Evergreen, TN_DEVASTATOR_W_A1, F_NI_EXT, false, false, FAMILY_TN }, - { "TN", "Scrapper", "trinity", amd::GPU_Library_Evergreen, TN_SCRAPPER_LV_A0, F_NI_EXT, false, false, FAMILY_TN }, - { "TN", "Scrapper", "trinity", amd::GPU_Library_Evergreen, TN_SCRAPPER_LV_A1, F_NI_EXT, false, false, FAMILY_TN }, - - { "VI", "Iceland", "iceland", amd::GPU_Library_CI, VI_ICELAND_M_A0, F_SI_BASE, false, true, FAMILY_VI }, - { "VI", "Tonga", "tonga", amd::GPU_Library_CI, VI_TONGA_P_A0, F_SI_BASE, false, true, FAMILY_VI }, - { "CI", "Bonaire", "bonaire", amd::GPU_Library_CI, CI_BONAIRE_M_A1, F_SI_BASE, false, true, FAMILY_CI }, - { "VI", "Fiji", "fiji", amd::GPU_Library_CI, VI_FIJI_P_A0, F_SI_BASE, false, true, FAMILY_VI }, - { "CZ", "Stoney", "stoney", amd::GPU_Library_CI, STONEY_A0, F_SI_BASE, false, true, FAMILY_CZ }, - { "VI", "Baffin", "baffin", amd::GPU_Library_CI, VI_BAFFIN_M_A0, F_SI_BASE, false, false, FAMILY_VI }, - { "VI", "Baffin", "baffin", amd::GPU_Library_CI, VI_BAFFIN_M_A1, F_SI_BASE, false, true, FAMILY_VI }, - { "VI", "Ellesmere", "ellesmere", amd::GPU_Library_CI, VI_ELLESMERE_P_A0, F_SI_BASE, false, false, FAMILY_VI }, - { "VI", "Ellesmere", "ellesmere", amd::GPU_Library_CI, VI_ELLESMERE_P_A1, F_SI_BASE, false, true, FAMILY_VI }, - { "VI", "gfx804", "gfx804", amd::GPU_Library_CI, VI_LEXA_V_A0, F_SI_BASE, false, true, FAMILY_VI }, - InvalidTarget -}; - -#endif // _CL_UTILS_TARGET_MAPPINGS_AMDIL_0_8_H_ diff --git a/rocclr/compiler/lib/utils/v0_8/target_mappings_amdil64.h b/rocclr/compiler/lib/utils/v0_8/target_mappings_amdil64.h deleted file mode 100644 index 56abacc23a..0000000000 --- a/rocclr/compiler/lib/utils/v0_8/target_mappings_amdil64.h +++ /dev/null @@ -1,55 +0,0 @@ -// -// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _CL_UTILS_TARGET_MAPPINGS_AMDIL64_0_8_H_ -#define _CL_UTILS_TARGET_MAPPINGS_AMDIL64_0_8_H_ - -#include "si_id.h" -#include "kv_id.h" -#include "ci_id.h" -#include "vi_id.h" -#include "cz_id.h" -#include "atiid.h" - -static const TargetMapping AMDIL64TargetMapping_0_8[] = { - UnknownTarget, - { "SI", "Tahiti", "tahiti", amd::GPU64_Library_SI, SI_TAHITI_P_A11, F_SI_64BIT_PTR, true, false, FAMILY_SI }, - { "SI", "Tahiti", "tahiti", amd::GPU64_Library_SI, SI_TAHITI_P_A0, F_SI_64BIT_PTR, true, false, FAMILY_SI }, - { "SI", "Tahiti", "tahiti", amd::GPU64_Library_SI, SI_TAHITI_P_A21, F_SI_64BIT_PTR, true, false, FAMILY_SI }, - { "SI", "Tahiti", "tahiti", amd::GPU64_Library_SI, SI_TAHITI_P_B0, F_SI_64BIT_PTR, true, false, FAMILY_SI }, - { "SI", "Tahiti", "tahiti", amd::GPU64_Library_SI, SI_TAHITI_P_A22, F_SI_64BIT_PTR, true, false, FAMILY_SI }, - { "SI", "Tahiti", "tahiti", amd::GPU64_Library_SI, SI_TAHITI_P_B1, F_SI_64BIT_PTR, true, true, FAMILY_SI }, - { "SI", "Pitcairn", "pitcairn", amd::GPU64_Library_SI, SI_PITCAIRN_PM_A11, F_SI_64BIT_PTR, true, false, FAMILY_SI }, - { "SI", "Pitcairn", "pitcairn", amd::GPU64_Library_SI, SI_PITCAIRN_PM_A0, F_SI_64BIT_PTR, true, false, FAMILY_SI }, - { "SI", "Pitcairn", "pitcairn", amd::GPU64_Library_SI, SI_PITCAIRN_PM_A12, F_SI_64BIT_PTR, true, false, FAMILY_SI }, - { "SI", "Pitcairn", "pitcairn", amd::GPU64_Library_SI, SI_PITCAIRN_PM_A1, F_SI_64BIT_PTR, true, true, FAMILY_SI }, - { "SI", "Capeverde", "capeverde", amd::GPU64_Library_SI, SI_CAPEVERDE_M_A11, F_SI_64BIT_PTR, true, false, FAMILY_SI }, - { "SI", "Capeverde", "capeverde", amd::GPU64_Library_SI, SI_CAPEVERDE_M_A0, F_SI_64BIT_PTR, true, false, FAMILY_SI }, - { "SI", "Capeverde", "capeverde", amd::GPU64_Library_SI, SI_CAPEVERDE_M_A12, F_SI_64BIT_PTR, true, false, FAMILY_SI }, - { "SI", "Capeverde", "capeverde", amd::GPU64_Library_SI, SI_CAPEVERDE_M_A1, F_SI_64BIT_PTR, true, true, FAMILY_SI }, - { "KV", "Spectre", "spectre", amd::GPU64_Library_CI, KV_SPECTRE_A0, F_SI_64BIT_PTR, false, true, FAMILY_KV }, - { "KV", "Spooky", "spooky", amd::GPU64_Library_CI, KV_SPOOKY_A0, F_SI_64BIT_PTR, false, true, FAMILY_KV }, - { "KV", "Kalindi", "kalindi", amd::GPU64_Library_CI, KB_KALINDI_A0, F_SI_64BIT_PTR, false, true, FAMILY_KV }, - { "CI", "Hawaii", "hawaii", amd::GPU64_Library_CI, CI_HAWAII_P_A0, F_SI_64BIT_PTR, false, true, FAMILY_CI }, - { "KV", "Mullins", "mullins", amd::GPU64_Library_CI, ML_GODAVARI_A0, F_SI_64BIT_PTR, false, true, FAMILY_KV }, - { "SI", "Oland", "oland", amd::GPU64_Library_SI, SI_OLAND_M_A0, F_SI_64BIT_PTR, true, true, FAMILY_SI }, - { "CI", "Bonaire", "bonaire", amd::GPU64_Library_CI, CI_BONAIRE_M_A0, F_SI_64BIT_PTR, false, false, FAMILY_CI }, - { "SI", "Hainan", "hainan", amd::GPU64_Library_SI, SI_HAINAN_V_A0, F_SI_64BIT_PTR, true, true, FAMILY_SI }, - - UnknownTarget, - UnknownTarget, - { "CZ", "Carrizo", "carrizo", amd::GPU64_Library_CI, CARRIZO_A0, F_SI_64BIT_PTR, false, true, FAMILY_CZ }, - { "VI", "Iceland", "iceland", amd::GPU64_Library_CI, VI_ICELAND_M_A0, F_SI_64BIT_PTR, false, true, FAMILY_VI }, - { "VI", "Tonga", "tonga", amd::GPU64_Library_CI, VI_TONGA_P_A0, F_SI_64BIT_PTR, false, true, FAMILY_VI }, - { "CI", "Bonaire", "bonaire", amd::GPU64_Library_CI, CI_BONAIRE_M_A0, F_SI_64BIT_PTR, false, true, FAMILY_CI }, - { "VI", "Fiji", "fiji", amd::GPU64_Library_CI, VI_FIJI_P_A0, F_SI_64BIT_PTR, false, true, FAMILY_VI }, - { "CZ", "Stoney", "stoney", amd::GPU64_Library_CI, STONEY_A0, F_SI_64BIT_PTR, false, true, FAMILY_CZ }, - { "VI", "Baffin", "baffin", amd::GPU64_Library_CI, VI_BAFFIN_M_A0, F_SI_64BIT_PTR, false, false, FAMILY_VI }, - { "VI", "Baffin", "baffin", amd::GPU64_Library_CI, VI_BAFFIN_M_A1, F_SI_64BIT_PTR, false, true, FAMILY_VI }, - { "VI", "Ellesmere", "ellesmere", amd::GPU64_Library_CI, VI_ELLESMERE_P_A0, F_SI_64BIT_PTR, false, false, FAMILY_VI }, - { "VI", "Ellesmere", "ellesmere", amd::GPU64_Library_CI, VI_ELLESMERE_P_A1, F_SI_64BIT_PTR, false, true, FAMILY_VI }, - { "VI", "gfx804", "gfx804", amd::GPU64_Library_CI, VI_LEXA_V_A0, F_SI_64BIT_PTR, false, true, FAMILY_VI }, - InvalidTarget -}; - -#endif // _CL_UTILS_TARGET_MAPPINGS_AMDIL64_0_8_H_ diff --git a/rocclr/compiler/lib/utils/v0_8/target_mappings_hsail.h b/rocclr/compiler/lib/utils/v0_8/target_mappings_hsail.h deleted file mode 100644 index c906d50a55..0000000000 --- a/rocclr/compiler/lib/utils/v0_8/target_mappings_hsail.h +++ /dev/null @@ -1,82 +0,0 @@ -// -// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _CL_UTILS_TARGET_MAPPINGS_HSAIL_0_8_H_ -#define _CL_UTILS_TARGET_MAPPINGS_HSAIL_0_8_H_ - -#include "si_id.h" -#include "kv_id.h" -#include "ci_id.h" -#include "cz_id.h" -#include "ai_id.h" -#include "rv_id.h" -#include "nv_id.h" -#include "atiid.h" - -static const TargetMapping HSAILTargetMapping_0_8[] = { - UnknownTarget, - { "KV", "Spectre", "GFX7", amd::GPU_Library_HSAIL, KV_SPECTRE_A0, F_CI_BASE, true, true, FAMILY_KV, false }, - { "KV", "Spooky", "GFX7", amd::GPU_Library_HSAIL, KV_SPOOKY_A0, F_CI_BASE, true, true, FAMILY_KV, false }, - { "KV", "Kalindi", "GFX7", amd::GPU_Library_HSAIL, KB_KALINDI_A0, F_CI_BASE, true, true, FAMILY_KV, false }, - { "KV", "Mullins", "GFX7", amd::GPU_Library_HSAIL, ML_GODAVARI_A0, F_CI_BASE, true, true, FAMILY_KV, false }, - { "CI", "Bonaire", "GFX7", amd::GPU_Library_HSAIL, CI_BONAIRE_M_A0, F_CI_BASE, true, false, FAMILY_CI, false }, - { "CI", "Bonaire", "GFX7", amd::GPU_Library_HSAIL, CI_BONAIRE_M_A1, F_CI_BASE, true, true, FAMILY_CI, false }, - { "CI", "Hawaii", "GFX7", amd::GPU_Library_HSAIL, CI_HAWAII_P_A0, F_CI_BASE, true, true, FAMILY_CI, false }, - { "VI", "Iceland", "GFX8", amd::GPU_Library_HSAIL, VI_ICELAND_M_A0, F_VI_BASE, true, true, FAMILY_VI, false }, - { "VI", "Tonga", "GFX8", amd::GPU_Library_HSAIL, VI_TONGA_P_A0, F_VI_BASE, true, true, FAMILY_VI, false }, - - UnknownTarget, - UnknownTarget, - { "CZ", "Carrizo", "GFX8", amd::GPU_Library_HSAIL, CARRIZO_A0, F_VI_BASE, true, true, FAMILY_CZ, false }, - { "VI", "Fiji", "GFX8", amd::GPU_Library_HSAIL, VI_FIJI_P_A0, F_VI_BASE, true, true, FAMILY_VI, false }, - { "CZ", "Stoney", "GFX8", amd::GPU_Library_HSAIL, STONEY_A0, F_VI_BASE, true, true, FAMILY_CZ, false }, - { "VI", "Baffin", "GFX8", amd::GPU_Library_HSAIL, VI_BAFFIN_M_A0, F_VI_BASE, true, false, FAMILY_VI, false }, - { "VI", "Baffin", "GFX8", amd::GPU_Library_HSAIL, VI_BAFFIN_M_A1, F_VI_BASE, true, true, FAMILY_VI, false }, - { "VI", "Ellesmere", "GFX8", amd::GPU_Library_HSAIL, VI_ELLESMERE_P_A0, F_VI_BASE, true, false, FAMILY_VI, false }, - { "VI", "Ellesmere", "GFX8", amd::GPU_Library_HSAIL, VI_ELLESMERE_P_A1, F_VI_BASE, true, true, FAMILY_VI, false }, -#ifndef BRAHMA - { "AI", "gfx900", "GFX9", amd::GPU_Library_HSAIL, AI_GREENLAND_P_A0, F_AI_BASE, true, false, FAMILY_AI }, - { "AI", "gfx900", "GFX9", amd::GPU_Library_HSAIL, AI_GREENLAND_P_A1, F_AI_BASE, true, true, FAMILY_AI }, -#else - UnknownTarget, - UnknownTarget, -#endif - { "VI", "gfx804", "GFX8", amd::GPU_Library_HSAIL, VI_LEXA_V_A0, F_VI_BASE, true, true, FAMILY_VI }, -#ifndef BRAHMA - { "AI", "gfx901", "GFX9", amd::GPU_Library_HSAIL, AI_GREENLAND_P_A0, F_AI_BASE, true, false, FAMILY_AI ,true }, - { "AI", "gfx901", "GFX9", amd::GPU_Library_HSAIL, AI_GREENLAND_P_A1, F_AI_BASE, true, true, FAMILY_AI ,true }, - { "RV", "gfx902", "GFX9", amd::GPU_Library_HSAIL, RAVEN_A0, F_AI_BASE, true, true, FAMILY_RV, false }, - { "RV", "gfx902", "GFX9", amd::GPU_Library_HSAIL, RENOIR_A0, F_AI_BASE, true, true, FAMILY_RV, false }, - { "RV", "gfx903", "GFX9", amd::GPU_Library_HSAIL, RAVEN_A0, F_AI_BASE, true, true, FAMILY_RV, true }, - { "RV", "gfx903", "GFX9", amd::GPU_Library_HSAIL, RENOIR_A0, F_AI_BASE, true, true, FAMILY_RV, true }, - { "AI", "gfx904", "GFX9", amd::GPU_Library_HSAIL, AI_VEGA12_P_A0, F_AI_BASE, true, true, FAMILY_AI, false }, - { "AI", "gfx905", "GFX9", amd::GPU_Library_HSAIL, AI_VEGA12_P_A0, F_AI_BASE, true, true, FAMILY_AI, true }, - { "AI", "gfx906", "GFX9", amd::GPU_Library_HSAIL, AI_VEGA20_P_A0, F_AI_BASE, true, true, FAMILY_AI, false }, - { "AI", "gfx907", "GFX9", amd::GPU_Library_HSAIL, AI_VEGA20_P_A0, F_AI_BASE, true, true, FAMILY_AI, true }, - { "AI", "gfx908", "GFX9", amd::GPU_Library_HSAIL, AI_MI100_P_A0, F_AI_BASE, true, true, FAMILY_AI, true }, - { "NV", "gfx1000", "GFX10", amd::GPU_Library_HSAIL, NV_NAVI10_LITE_P_A0, F_AI_BASE, true, true, FAMILY_NV, false }, - { "NV", "gfx1010", "GFX10", amd::GPU_Library_HSAIL, NV_NAVI10_P_A0, F_AI_BASE, true, true, FAMILY_NV, false }, - { "NV", "gfx1011", "GFX10", amd::GPU_Library_HSAIL, NV_NAVI12_P_A0, F_AI_BASE, true, true, FAMILY_NV, false }, - { "NV", "gfx1012", "GFX10", amd::GPU_Library_HSAIL, NV_NAVI14_M_A0, F_AI_BASE, true, true, FAMILY_NV, false }, - -#else - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, -#endif - InvalidTarget -}; - -#endif // _CL_UTILS_TARGET_MAPPINGS_HSAIL_0_8_H_ diff --git a/rocclr/compiler/lib/utils/v0_8/target_mappings_hsail64.h b/rocclr/compiler/lib/utils/v0_8/target_mappings_hsail64.h deleted file mode 100644 index 6399885cd4..0000000000 --- a/rocclr/compiler/lib/utils/v0_8/target_mappings_hsail64.h +++ /dev/null @@ -1,80 +0,0 @@ -// -// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _CL_UTILS_TARGET_MAPPINGS_HSAIL64_0_8_H_ -#define _CL_UTILS_TARGET_MAPPINGS_HSAIL64_0_8_H_ - -#include "si_id.h" -#include "kv_id.h" -#include "ci_id.h" -#include "ai_id.h" -#include "rv_id.h" -#include "nv_id.h" -#include "atiid.h" - -static const TargetMapping HSAIL64TargetMapping_0_8[] = { - UnknownTarget, - { "KV", "Spectre", "GFX7", amd::GPU_Library_HSAIL, KV_SPECTRE_A0, F_CI_BASE, true, true, FAMILY_KV, false }, - { "KV", "Spooky", "GFX7", amd::GPU_Library_HSAIL, KV_SPOOKY_A0, F_CI_BASE, true, true, FAMILY_KV, false }, - { "KV", "Kalindi", "GFX7", amd::GPU_Library_HSAIL, KB_KALINDI_A0, F_CI_BASE, true, true, FAMILY_KV, false }, - { "KV", "Mullins", "GFX7", amd::GPU_Library_HSAIL, ML_GODAVARI_A0, F_CI_BASE, true, true, FAMILY_KV, false }, - { "CI", "Bonaire", "GFX7", amd::GPU_Library_HSAIL, CI_BONAIRE_M_A0, F_CI_BASE, true, false, FAMILY_CI, false }, - { "CI", "Bonaire", "GFX7", amd::GPU_Library_HSAIL, CI_BONAIRE_M_A1, F_CI_BASE, true, true, FAMILY_CI, false }, - { "CI", "Hawaii", "GFX7", amd::GPU_Library_HSAIL, CI_HAWAII_P_A0, F_CI_BASE, true, true, FAMILY_CI, false }, - { "VI", "Iceland", "GFX8", amd::GPU_Library_HSAIL, VI_ICELAND_M_A0, F_VI_BASE, true, true, FAMILY_VI, false }, - { "VI", "Tonga", "GFX8", amd::GPU_Library_HSAIL, VI_TONGA_P_A0, F_VI_BASE, true, true, FAMILY_VI, false }, - - UnknownTarget, - UnknownTarget, - { "CZ", "Carrizo", "GFX8", amd::GPU_Library_HSAIL, CARRIZO_A0, F_VI_BASE, true, true, FAMILY_CZ, false }, - { "VI", "Fiji", "GFX8", amd::GPU_Library_HSAIL, VI_FIJI_P_A0, F_VI_BASE, true, true, FAMILY_VI, false }, - { "CZ", "Stoney", "GFX8", amd::GPU_Library_HSAIL, STONEY_A0, F_VI_BASE, true, true, FAMILY_CZ, false }, - { "VI", "Baffin", "GFX8", amd::GPU_Library_HSAIL, VI_BAFFIN_M_A0, F_VI_BASE, true, false, FAMILY_VI, false }, - { "VI", "Baffin", "GFX8", amd::GPU_Library_HSAIL, VI_BAFFIN_M_A1, F_VI_BASE, true, true, FAMILY_VI, false }, - { "VI", "Ellesmere", "GFX8", amd::GPU_Library_HSAIL, VI_ELLESMERE_P_A0, F_VI_BASE, true, false, FAMILY_VI, false }, - { "VI", "Ellesmere", "GFX8", amd::GPU_Library_HSAIL, VI_ELLESMERE_P_A1, F_VI_BASE, true, true, FAMILY_VI, false }, -#ifndef BRAHMA - { "AI", "gfx900", "GFX9", amd::GPU_Library_HSAIL, AI_GREENLAND_P_A0, F_AI_BASE, true, false, FAMILY_AI, false }, - { "AI", "gfx900", "GFX9", amd::GPU_Library_HSAIL, AI_GREENLAND_P_A1, F_AI_BASE, true, true, FAMILY_AI, false }, -#else - UnknownTarget, - UnknownTarget, -#endif - { "VI", "gfx804", "GFX8", amd::GPU_Library_HSAIL, VI_LEXA_V_A0, F_VI_BASE, true, true, FAMILY_VI, false }, -#ifndef BRAHMA - { "AI", "gfx901", "GFX9", amd::GPU_Library_HSAIL, AI_GREENLAND_P_A0, F_AI_BASE, true, false, FAMILY_AI, true }, - { "AI", "gfx901", "GFX9", amd::GPU_Library_HSAIL, AI_GREENLAND_P_A1, F_AI_BASE, true, true, FAMILY_AI, true }, - { "RV", "gfx902", "GFX9", amd::GPU_Library_HSAIL, RAVEN_A0, F_AI_BASE, true, true, FAMILY_RV, false }, - { "RV", "gfx902", "GFX9", amd::GPU_Library_HSAIL, RENOIR_A0, F_AI_BASE, true, true, FAMILY_RV, false }, - { "RV", "gfx903", "GFX9", amd::GPU_Library_HSAIL, RAVEN_A0, F_AI_BASE, true, true, FAMILY_RV, true }, - { "RV", "gfx903", "GFX9", amd::GPU_Library_HSAIL, RENOIR_A0, F_AI_BASE, true, true, FAMILY_RV, true }, - { "AI", "gfx904", "GFX9", amd::GPU_Library_HSAIL, AI_VEGA12_P_A0, F_AI_BASE, true, true, FAMILY_AI, false }, - { "AI", "gfx905", "GFX9", amd::GPU_Library_HSAIL, AI_VEGA12_P_A0, F_AI_BASE, true, true, FAMILY_AI, true }, - { "AI", "gfx906", "GFX9", amd::GPU_Library_HSAIL, AI_VEGA20_P_A0, F_AI_BASE, true, true, FAMILY_AI, false }, - { "AI", "gfx907", "GFX9", amd::GPU_Library_HSAIL, AI_VEGA20_P_A0, F_AI_BASE, true, true, FAMILY_AI, true }, - { "AI", "gfx908", "GFX9", amd::GPU_Library_HSAIL, AI_MI100_P_A0, F_AI_BASE, true, true, FAMILY_AI, true }, - { "NV", "gfx1000", "GFX10", amd::GPU_Library_HSAIL, NV_NAVI10_LITE_P_A0, F_AI_BASE, true, true, FAMILY_NV, false }, - { "NV", "gfx1010", "GFX10", amd::GPU_Library_HSAIL, NV_NAVI10_P_A0, F_AI_BASE, true, true, FAMILY_NV, false }, - { "NV", "gfx1011", "GFX10", amd::GPU_Library_HSAIL, NV_NAVI12_P_A0, F_AI_BASE, true, true, FAMILY_NV, false }, - { "NV", "gfx1012", "GFX10", amd::GPU_Library_HSAIL, NV_NAVI14_M_A0, F_AI_BASE, true, true, FAMILY_NV, false }, -#else - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, - UnknownTarget, -#endif - InvalidTarget -}; - -#endif // _CL_UTILS_TARGET_MAPPINGS_HSAIL64_0_8_H_ diff --git a/rocclr/compiler/lib/utils/v0_8/target_mappings_x64.h b/rocclr/compiler/lib/utils/v0_8/target_mappings_x64.h deleted file mode 100644 index ebe5a83c4c..0000000000 --- a/rocclr/compiler/lib/utils/v0_8/target_mappings_x64.h +++ /dev/null @@ -1,46 +0,0 @@ -// -// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _CL_UTILS_TARGET_MAPPINGS_X64_0_8_H_ -#define _CL_UTILS_TARGET_MAPPINGS_X64_0_8_H_ - -#define CPU_MAPPING_LIB(A, B, C, D, E) { #A, #B, #C, D, 0, E, LP64_SWITCH(false, true), LP64_SWITCH(false, true), FAMILY_X64} -#define CPU_MAPPING(A, B, C, D) CPU_MAPPING_LIB(A, B, C, amd::CPU64_Library_Generic, D) -#define NCPU_MAPPING_LIB(A, B, C, D, E) { #A, #B, #C, D, 0, E, false, false, FAMILY_X64} -#define NCPU_MAPPING(A, B, C, D) { #A, #B, #C, amd::CPU64_Library_Generic, 0, D, false, false, FAMILY_X64} -static const TargetMapping X64TargetMapping_0_8[] = { - UnknownTarget, - CPU_MAPPING(X64, Generic, generic, 0x1), - CPU_MAPPING(NetBurst, Prescott, prescott, 0x1), - CPU_MAPPING(Xeon, Nocona, nocona, 0x1), - CPU_MAPPING(Core, Core2, core2, 0x1), - CPU_MAPPING(Core, Penryn, penryn, 0x1), - CPU_MAPPING(Nehalem, Corei7, corei7, 0x1), - CPU_MAPPING(Nehalem, Nehalem, nehalem, 0x1), - CPU_MAPPING(Nehalem, Westmere, westmere, 0x1), - NCPU_MAPPING_LIB(SandyBridge, Corei7_AVX, sandybridge, amd::CPU64_Library_AVX, 0x2 | 0x1), // LLVM 2.9 only - CPU_MAPPING_LIB(SandyBridge, Corei7_AVX, corei7-avx, amd::CPU64_Library_AVX, 0x2 | 0x1), - CPU_MAPPING(SandyBridge, IvyBridge, core-avx-i, 0x2 | 0x1), // LLVM 3.0 - CPU_MAPPING(Haswell, Haswell, core-avx2, 0x4 | 0x2 | 0x1), // LLVM 3.0 - CPU_MAPPING(K8, K8, k8, 0x1), - CPU_MAPPING(K8, Opteron, opteron, 0x1), - CPU_MAPPING(K8, Athlon64, athlon64, 0x1), - CPU_MAPPING(K8, AthlonFX, athlon-fx, 0x1), - CPU_MAPPING(K8, K8_SSE3, k8-sse3, 0x1), - CPU_MAPPING(K8, Opteron_SSE3,opteron-sse3, 0x1), - CPU_MAPPING(K8, Athlon64SSE3,athlon64-sse3, 0x1), - CPU_MAPPING(K10, AMDFAM10, amdfam10, 0x1), - NCPU_MAPPING(K10, Barcelona, barcelona, 0x1), - NCPU_MAPPING(K10, Istanbul, istanbul, 0x1), - NCPU_MAPPING(K10, Shanghai, shanghai, 0x1), - CPU_MAPPING(Family14h, Bobcat, btver1, 0x1), - CPU_MAPPING_LIB(Family15h, Bulldozer, bdver1, amd::CPU64_Library_FMA4, 0x8 | 0x1), - CPU_MAPPING_LIB(Family15h, Piledriver, bdver2, amd::CPU64_Library_FMA4, 0x8 | 0x4 | 0x1), - CPU_MAPPING(Atom, Atom, atom, 0x1), - InvalidTarget -}; -#undef CPU_MAPPING -#undef NCPU_MAPPING -#undef CPU_MAPPING_LIB -#undef NCPU_MAPPING_LIB -#endif // _CL_UTILS_TARGET_MAPPINGS_X64_0_8_H_ diff --git a/rocclr/compiler/lib/utils/v0_8/target_mappings_x86.h b/rocclr/compiler/lib/utils/v0_8/target_mappings_x86.h deleted file mode 100644 index 979c6e31a9..0000000000 --- a/rocclr/compiler/lib/utils/v0_8/target_mappings_x86.h +++ /dev/null @@ -1,73 +0,0 @@ -// -// Copyright (c) 2012 Advanced Micro Devices, Inc. All rights reserved. -// -#ifndef _CL_UTILS_TARGET_MAPPINGS_X86_0_8_H_ -#define _CL_UTILS_TARGET_MAPPINGS_X86_0_8_H_ -#define CPU_MAPPING_LIB(A, B, C, D, E) { #A, #B, #C, D, 0, E, true, true, FAMILY_X86} -#define CPU_MAPPING(A, B, C, D) CPU_MAPPING_LIB(A, B, C, amd::CPU_Library_Generic, D) -#define NCPU_MAPPING_LIB(A, B, C, D, E) { #A, #B, #C, D, 0, E, false, false, FAMILY_X86} -#define NCPU_MAPPING(A, B, C, D) { #A, #B, #C, amd::CPU_Library_Generic, 0, D, false, false, FAMILY_X86} -static const TargetMapping X86TargetMapping_0_8[] = { - UnknownTarget, - CPU_MAPPING(X86, Generic, generic, 0), - // This has to be specified manually since GCC defines i386 as a macro. - { "X86", "i386", "i386", amd::CPU_Library_Generic, 0, 0, true, true, FAMILY_X86 }, - CPU_MAPPING(X86, i486, i486, 0), - CPU_MAPPING(X86, i586, i586, 0), - CPU_MAPPING(Pentium, Pentium, pentium, 0), - CPU_MAPPING(Pentium_MMX, Pentium_MMX, pentium-mmx, 0), - CPU_MAPPING(X86, i686, i686, 0), - CPU_MAPPING(PentiumPro, PentiumPro, pentiumpro, 0), - CPU_MAPPING(Pentium2, Pentium2, pentium2, 0), - CPU_MAPPING(Pentium3, Pentium3, pentium3, 0), - CPU_MAPPING(Pentium3m, Pentium3m, pentium3m, 0), - CPU_MAPPING(Pentium_M, Pentium_M, pentium-m, 0x1), - CPU_MAPPING(NetBurst, Pentium4, pentium4, 0x1), - CPU_MAPPING(NetBurst, Pentium4m, pentium4m, 0x1), - CPU_MAPPING(Pentium_M, Yonah, yonah, 0x1), - CPU_MAPPING(Pentium4, Prescott, prescott, 0x1), - CPU_MAPPING(Xeon, Nocona, nocona, 0x1), - CPU_MAPPING(Core, Core2, core2, 0x1), - CPU_MAPPING(Core, Penryn, penryn, 0x1), - CPU_MAPPING(Nehalem, Corei7, corei7, 0x1), // Corei3 and Corei5 also - CPU_MAPPING(Nehalem, Nehalem, nehalem, 0x1), - CPU_MAPPING(Nehalem, Westmere, westmere, 0x1), - NCPU_MAPPING_LIB(SandyBridge, Corei7_AVX, sandybridge, amd::CPU64_Library_AVX, 0x2 | 0x1), // LLVM 2.9 only - CPU_MAPPING(SandyBridge, Corei7_AVX, corei7-avx, 0x2 | 0x1), // LLVM 3.0 only - CPU_MAPPING(SandyBridge, IvyBridge, core-avx-i, 0x2 | 0x1), // LLVM 3.0 only - CPU_MAPPING(Haswell, Haswell, core-avx2, 0x4 | 0x2 | 0x1), // LLVM 3.0 only - CPU_MAPPING(K6, K6, k6, 0), - CPU_MAPPING(K6, K6_2, k6-2, 0), - CPU_MAPPING(K6, K6_3, k6-3, 0), - CPU_MAPPING(K7, Athlon, athlon, 0), - CPU_MAPPING(K7, AthlonTBIRD, athlon-tbird, 0), - CPU_MAPPING(K7, Athlon4, athlon-4, 0), - CPU_MAPPING(K7, AthlonXP, athlon-xp, 0), - CPU_MAPPING(K7, AthlonMP, athlon-mp, 0), - CPU_MAPPING(K8, K8, k8, 0x1), - CPU_MAPPING(K8, Opteron, opteron, 0x1), - CPU_MAPPING(K8, Athlon64, athlon64, 0x1), - CPU_MAPPING(K8, AthlonFX, athlon-fx, 0x1), - CPU_MAPPING(K8, K8_SSE3, k8-sse3, 0x1), - CPU_MAPPING(K8, Opteron_SSE3,opteron-sse3, 0x1), - CPU_MAPPING(K8, Athlon64SSE3,athlon64-sse3, 0x1), - CPU_MAPPING(K10, AMDFAM10, amdfam10, 0x1), - NCPU_MAPPING(K10, Barcelona, barcelona, 0x1), - NCPU_MAPPING(K10, Istanbul, istanbul, 0x1), - NCPU_MAPPING(K10, Shanghai, shanghai, 0x1), - CPU_MAPPING(Winchip, Winchip_C6, winchip-c6, 0), - CPU_MAPPING(Winchip, Winchip2, winchip2, 0), - CPU_MAPPING(Via, C3, c3, 0), - CPU_MAPPING(Via, C3_2, c3-2, 0), - CPU_MAPPING(Family14h, Bobcat, btver1, 0x1), // LLVM 3.1 only - CPU_MAPPING_LIB(Family15h, Bulldozer, bdver1, amd::CPU_Library_FMA4, 0x8 | 0x1), // LLVM 3.1 only - CPU_MAPPING_LIB(Family15h, Piledriver, bdver2, amd::CPU_Library_FMA4, 0x8 | 0x4 | 0x1), // LLVM 3.1 only - CPU_MAPPING(Atom, Atom, atom, 0x1), // LLVM 3.1 only - InvalidTarget -}; -#undef CPU_MAPPING -#undef NCPU_MAPPING -#undef CPU_MAPPING_LIB -#undef NCPU_MAPPING_LIB - -#endif // _CL_UTILS_TARGET_MAPPINGS_X86_0_8_H_ diff --git a/rocclr/compiler/lib/utils/versions.hpp b/rocclr/compiler/lib/utils/versions.hpp deleted file mode 100644 index d38ebc2c5f..0000000000 --- a/rocclr/compiler/lib/utils/versions.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// -// Copyright (c) 2010 Advanced Micro Devices, Inc. All rights reserved. -// - -#ifndef _CL_VERSIONS_HPP_ -#define _CL_VERSIONS_HPP_ - -#include "utils/macros.hpp" - -#ifndef AMD_COMPILER_NAME -# define AMD_COMPILER_NAME "AMD COMPILER" -#endif // AMD_COMPILER_NAME - -#ifndef AMD_COMPILER_BUILD_NUMBER -# define AMD_COMPILER_BUILD_NUMBER 0 -#endif // AMD_COMPILER_BUILD_NUMBER - -#ifndef AMD_COMPILER_REVISION_NUMBER -# define AMD_COMPILER_REVISION_NUMBER 0 -#endif // AMD_COMPILER_REVISION_NUMBER - -#ifndef AMD_SC_COMPILER_REVISION_NUMBER -#define AMD_SC_COMPILER_REVISION_NUMBER SC_BUILD_NUMBER -#endif // AMD_SC_COMPILER_REVISION_NUMBER - -#ifndef AMD_COMPILER_MAJOR_VERSION -# define AMD_COMPILER_MAJOR_VERSION 0 -#endif // AMD_COMPILER_MAJOR_VERSION - -#ifndef AMD_COMPILER_MINOR_VERSION -# define AMD_COMPILER_MINOR_VERSION 8 -#endif // AMD_COMPILER_MINOR_VERSION - -#ifndef AMD_COMPILER_RELEASE_INFO -# define AMD_COMPILER_RELEASE_INFO -#endif // AMD_COMPILER_RELEASE_INFO - -#ifndef AMD_COMPILER_NAME -# define AMD_COMPILER_NAME "AMD Compiler Library" -#endif // AMD_COMPILER_NAME - -#define AMD_BUILD_STRING XSTR(AMD_COMPILER_BUILD_NUMBER) \ - "." XSTR(AMD_COMPILER_REVISION_NUMBER) "." XSTR(AMD_SC_COMPILER_REVISION_NUMBER) - -#ifndef AMD_COMPILER_INFO -# define AMD_COMPILER_INFO "AMD-COMP-LIB-" \ - "v" XSTR(AMD_COMPILER_MAJOR_VERSION) "." XSTR(AMD_COMPILER_MINOR_VERSION) \ - AMD_COMPILER_RELEASE_INFO DEBUG_ONLY(".dbg") " (" AMD_BUILD_STRING ")" -#endif // AMD_COMPILER_INFO - - -#endif // _CL_VERSIONS_HPP_ diff --git a/rocclr/configure b/rocclr/configure new file mode 100644 index 0000000000..e69de29bb2 diff --git a/rocclr/runtime/device/appprofile.cpp b/rocclr/device/appprofile.cpp similarity index 100% rename from rocclr/runtime/device/appprofile.cpp rename to rocclr/device/appprofile.cpp diff --git a/rocclr/runtime/device/appprofile.hpp b/rocclr/device/appprofile.hpp similarity index 100% rename from rocclr/runtime/device/appprofile.hpp rename to rocclr/device/appprofile.hpp diff --git a/rocclr/runtime/device/blit.cpp b/rocclr/device/blit.cpp similarity index 100% rename from rocclr/runtime/device/blit.cpp rename to rocclr/device/blit.cpp diff --git a/rocclr/runtime/device/blit.hpp b/rocclr/device/blit.hpp similarity index 100% rename from rocclr/runtime/device/blit.hpp rename to rocclr/device/blit.hpp diff --git a/rocclr/runtime/device/blitcl.cpp b/rocclr/device/blitcl.cpp similarity index 100% rename from rocclr/runtime/device/blitcl.cpp rename to rocclr/device/blitcl.cpp diff --git a/rocclr/runtime/device/comgrctx.cpp b/rocclr/device/comgrctx.cpp similarity index 100% rename from rocclr/runtime/device/comgrctx.cpp rename to rocclr/device/comgrctx.cpp diff --git a/rocclr/runtime/device/comgrctx.hpp b/rocclr/device/comgrctx.hpp similarity index 100% rename from rocclr/runtime/device/comgrctx.hpp rename to rocclr/device/comgrctx.hpp diff --git a/rocclr/runtime/device/device.cpp b/rocclr/device/device.cpp similarity index 100% rename from rocclr/runtime/device/device.cpp rename to rocclr/device/device.cpp diff --git a/rocclr/runtime/device/device.hpp b/rocclr/device/device.hpp similarity index 100% rename from rocclr/runtime/device/device.hpp rename to rocclr/device/device.hpp diff --git a/rocclr/runtime/device/devkernel.cpp b/rocclr/device/devkernel.cpp similarity index 100% rename from rocclr/runtime/device/devkernel.cpp rename to rocclr/device/devkernel.cpp diff --git a/rocclr/runtime/device/devkernel.hpp b/rocclr/device/devkernel.hpp similarity index 100% rename from rocclr/runtime/device/devkernel.hpp rename to rocclr/device/devkernel.hpp diff --git a/rocclr/runtime/device/devprogram.cpp b/rocclr/device/devprogram.cpp similarity index 100% rename from rocclr/runtime/device/devprogram.cpp rename to rocclr/device/devprogram.cpp diff --git a/rocclr/runtime/device/devprogram.hpp b/rocclr/device/devprogram.hpp similarity index 100% rename from rocclr/runtime/device/devprogram.hpp rename to rocclr/device/devprogram.hpp diff --git a/rocclr/runtime/device/devwavelimiter.cpp b/rocclr/device/devwavelimiter.cpp similarity index 100% rename from rocclr/runtime/device/devwavelimiter.cpp rename to rocclr/device/devwavelimiter.cpp diff --git a/rocclr/runtime/device/devwavelimiter.hpp b/rocclr/device/devwavelimiter.hpp similarity index 100% rename from rocclr/runtime/device/devwavelimiter.hpp rename to rocclr/device/devwavelimiter.hpp diff --git a/rocclr/runtime/device/gpu/gpuappprofile.cpp b/rocclr/device/gpu/gpuappprofile.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gpuappprofile.cpp rename to rocclr/device/gpu/gpuappprofile.cpp diff --git a/rocclr/runtime/device/gpu/gpuappprofile.hpp b/rocclr/device/gpu/gpuappprofile.hpp similarity index 100% rename from rocclr/runtime/device/gpu/gpuappprofile.hpp rename to rocclr/device/gpu/gpuappprofile.hpp diff --git a/rocclr/runtime/device/gpu/gpubinary.cpp b/rocclr/device/gpu/gpubinary.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gpubinary.cpp rename to rocclr/device/gpu/gpubinary.cpp diff --git a/rocclr/runtime/device/gpu/gpubinary.hpp b/rocclr/device/gpu/gpubinary.hpp similarity index 100% rename from rocclr/runtime/device/gpu/gpubinary.hpp rename to rocclr/device/gpu/gpubinary.hpp diff --git a/rocclr/runtime/device/gpu/gpublit.cpp b/rocclr/device/gpu/gpublit.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gpublit.cpp rename to rocclr/device/gpu/gpublit.cpp diff --git a/rocclr/runtime/device/gpu/gpublit.hpp b/rocclr/device/gpu/gpublit.hpp similarity index 100% rename from rocclr/runtime/device/gpu/gpublit.hpp rename to rocclr/device/gpu/gpublit.hpp diff --git a/rocclr/runtime/device/gpu/gpucompiler.cpp b/rocclr/device/gpu/gpucompiler.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gpucompiler.cpp rename to rocclr/device/gpu/gpucompiler.cpp diff --git a/rocclr/runtime/device/gpu/gpuconstbuf.cpp b/rocclr/device/gpu/gpuconstbuf.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gpuconstbuf.cpp rename to rocclr/device/gpu/gpuconstbuf.cpp diff --git a/rocclr/runtime/device/gpu/gpuconstbuf.hpp b/rocclr/device/gpu/gpuconstbuf.hpp similarity index 100% rename from rocclr/runtime/device/gpu/gpuconstbuf.hpp rename to rocclr/device/gpu/gpuconstbuf.hpp diff --git a/rocclr/runtime/device/gpu/gpucounters.cpp b/rocclr/device/gpu/gpucounters.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gpucounters.cpp rename to rocclr/device/gpu/gpucounters.cpp diff --git a/rocclr/runtime/device/gpu/gpucounters.hpp b/rocclr/device/gpu/gpucounters.hpp similarity index 100% rename from rocclr/runtime/device/gpu/gpucounters.hpp rename to rocclr/device/gpu/gpucounters.hpp diff --git a/rocclr/runtime/device/gpu/gpudebugger.hpp b/rocclr/device/gpu/gpudebugger.hpp similarity index 100% rename from rocclr/runtime/device/gpu/gpudebugger.hpp rename to rocclr/device/gpu/gpudebugger.hpp diff --git a/rocclr/runtime/device/gpu/gpudebugmanager.cpp b/rocclr/device/gpu/gpudebugmanager.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gpudebugmanager.cpp rename to rocclr/device/gpu/gpudebugmanager.cpp diff --git a/rocclr/runtime/device/gpu/gpudebugmanager.hpp b/rocclr/device/gpu/gpudebugmanager.hpp similarity index 100% rename from rocclr/runtime/device/gpu/gpudebugmanager.hpp rename to rocclr/device/gpu/gpudebugmanager.hpp diff --git a/rocclr/runtime/device/gpu/gpudefs.hpp b/rocclr/device/gpu/gpudefs.hpp similarity index 100% rename from rocclr/runtime/device/gpu/gpudefs.hpp rename to rocclr/device/gpu/gpudefs.hpp diff --git a/rocclr/runtime/device/gpu/gpudevice.cpp b/rocclr/device/gpu/gpudevice.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gpudevice.cpp rename to rocclr/device/gpu/gpudevice.cpp diff --git a/rocclr/runtime/device/gpu/gpudevice.hpp b/rocclr/device/gpu/gpudevice.hpp similarity index 100% rename from rocclr/runtime/device/gpu/gpudevice.hpp rename to rocclr/device/gpu/gpudevice.hpp diff --git a/rocclr/runtime/device/gpu/gpukernel.cpp b/rocclr/device/gpu/gpukernel.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gpukernel.cpp rename to rocclr/device/gpu/gpukernel.cpp diff --git a/rocclr/runtime/device/gpu/gpukernel.hpp b/rocclr/device/gpu/gpukernel.hpp similarity index 100% rename from rocclr/runtime/device/gpu/gpukernel.hpp rename to rocclr/device/gpu/gpukernel.hpp diff --git a/rocclr/runtime/device/gpu/gpumemory.cpp b/rocclr/device/gpu/gpumemory.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gpumemory.cpp rename to rocclr/device/gpu/gpumemory.cpp diff --git a/rocclr/runtime/device/gpu/gpumemory.hpp b/rocclr/device/gpu/gpumemory.hpp similarity index 100% rename from rocclr/runtime/device/gpu/gpumemory.hpp rename to rocclr/device/gpu/gpumemory.hpp diff --git a/rocclr/runtime/device/gpu/gpuprintf.cpp b/rocclr/device/gpu/gpuprintf.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gpuprintf.cpp rename to rocclr/device/gpu/gpuprintf.cpp diff --git a/rocclr/runtime/device/gpu/gpuprintf.hpp b/rocclr/device/gpu/gpuprintf.hpp similarity index 100% rename from rocclr/runtime/device/gpu/gpuprintf.hpp rename to rocclr/device/gpu/gpuprintf.hpp diff --git a/rocclr/runtime/device/gpu/gpuprogram.cpp b/rocclr/device/gpu/gpuprogram.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gpuprogram.cpp rename to rocclr/device/gpu/gpuprogram.cpp diff --git a/rocclr/runtime/device/gpu/gpuprogram.hpp b/rocclr/device/gpu/gpuprogram.hpp similarity index 100% rename from rocclr/runtime/device/gpu/gpuprogram.hpp rename to rocclr/device/gpu/gpuprogram.hpp diff --git a/rocclr/runtime/device/gpu/gpuresource.cpp b/rocclr/device/gpu/gpuresource.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gpuresource.cpp rename to rocclr/device/gpu/gpuresource.cpp diff --git a/rocclr/runtime/device/gpu/gpuresource.hpp b/rocclr/device/gpu/gpuresource.hpp similarity index 100% rename from rocclr/runtime/device/gpu/gpuresource.hpp rename to rocclr/device/gpu/gpuresource.hpp diff --git a/rocclr/runtime/device/gpu/gpusched.hpp b/rocclr/device/gpu/gpusched.hpp similarity index 100% rename from rocclr/runtime/device/gpu/gpusched.hpp rename to rocclr/device/gpu/gpusched.hpp diff --git a/rocclr/runtime/device/gpu/gpuschedcl.cpp b/rocclr/device/gpu/gpuschedcl.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gpuschedcl.cpp rename to rocclr/device/gpu/gpuschedcl.cpp diff --git a/rocclr/runtime/device/gpu/gpuscsi.cpp b/rocclr/device/gpu/gpuscsi.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gpuscsi.cpp rename to rocclr/device/gpu/gpuscsi.cpp diff --git a/rocclr/runtime/device/gpu/gpusettings.cpp b/rocclr/device/gpu/gpusettings.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gpusettings.cpp rename to rocclr/device/gpu/gpusettings.cpp diff --git a/rocclr/runtime/device/gpu/gpusettings.hpp b/rocclr/device/gpu/gpusettings.hpp similarity index 100% rename from rocclr/runtime/device/gpu/gpusettings.hpp rename to rocclr/device/gpu/gpusettings.hpp diff --git a/rocclr/runtime/device/gpu/gputhreadtrace.cpp b/rocclr/device/gpu/gputhreadtrace.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gputhreadtrace.cpp rename to rocclr/device/gpu/gputhreadtrace.cpp diff --git a/rocclr/runtime/device/gpu/gputhreadtrace.hpp b/rocclr/device/gpu/gputhreadtrace.hpp similarity index 100% rename from rocclr/runtime/device/gpu/gputhreadtrace.hpp rename to rocclr/device/gpu/gputhreadtrace.hpp diff --git a/rocclr/runtime/device/gpu/gputimestamp.cpp b/rocclr/device/gpu/gputimestamp.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gputimestamp.cpp rename to rocclr/device/gpu/gputimestamp.cpp diff --git a/rocclr/runtime/device/gpu/gputimestamp.hpp b/rocclr/device/gpu/gputimestamp.hpp similarity index 100% rename from rocclr/runtime/device/gpu/gputimestamp.hpp rename to rocclr/device/gpu/gputimestamp.hpp diff --git a/rocclr/runtime/device/gpu/gputrap.hpp b/rocclr/device/gpu/gputrap.hpp similarity index 100% rename from rocclr/runtime/device/gpu/gputrap.hpp rename to rocclr/device/gpu/gputrap.hpp diff --git a/rocclr/runtime/device/gpu/gpuvirtual.cpp b/rocclr/device/gpu/gpuvirtual.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gpuvirtual.cpp rename to rocclr/device/gpu/gpuvirtual.cpp diff --git a/rocclr/runtime/device/gpu/gpuvirtual.hpp b/rocclr/device/gpu/gpuvirtual.hpp similarity index 100% rename from rocclr/runtime/device/gpu/gpuvirtual.hpp rename to rocclr/device/gpu/gpuvirtual.hpp diff --git a/rocclr/runtime/device/gpu/gslbe/localdefs b/rocclr/device/gpu/gslbe/localdefs similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/localdefs rename to rocclr/device/gpu/gslbe/localdefs diff --git a/rocclr/runtime/device/gpu/gslbe/localrules b/rocclr/device/gpu/gslbe/localrules similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/localrules rename to rocclr/device/gpu/gslbe/localrules diff --git a/rocclr/runtime/device/gpu/gslbe/src/promotions/Readme.txt b/rocclr/device/gpu/gslbe/src/promotions/Readme.txt similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/src/promotions/Readme.txt rename to rocclr/device/gpu/gslbe/src/promotions/Readme.txt diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/DxxOpenCLInteropExt.h b/rocclr/device/gpu/gslbe/src/rt/DxxOpenCLInteropExt.h similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/src/rt/DxxOpenCLInteropExt.h rename to rocclr/device/gpu/gslbe/src/rt/DxxOpenCLInteropExt.h diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/EventQueue.cpp b/rocclr/device/gpu/gslbe/src/rt/EventQueue.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/src/rt/EventQueue.cpp rename to rocclr/device/gpu/gslbe/src/rt/EventQueue.cpp diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/EventQueue.h b/rocclr/device/gpu/gslbe/src/rt/EventQueue.h similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/src/rt/EventQueue.h rename to rocclr/device/gpu/gslbe/src/rt/EventQueue.h diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLContext.cpp b/rocclr/device/gpu/gslbe/src/rt/GSLContext.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/src/rt/GSLContext.cpp rename to rocclr/device/gpu/gslbe/src/rt/GSLContext.cpp diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLContext.h b/rocclr/device/gpu/gslbe/src/rt/GSLContext.h similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/src/rt/GSLContext.h rename to rocclr/device/gpu/gslbe/src/rt/GSLContext.h diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp b/rocclr/device/gpu/gslbe/src/rt/GSLDevice.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp rename to rocclr/device/gpu/gslbe/src/rt/GSLDevice.cpp diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.h b/rocclr/device/gpu/gslbe/src/rt/GSLDevice.h similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.h rename to rocclr/device/gpu/gslbe/src/rt/GSLDevice.h diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDeviceD3D10.cpp b/rocclr/device/gpu/gslbe/src/rt/GSLDeviceD3D10.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/src/rt/GSLDeviceD3D10.cpp rename to rocclr/device/gpu/gslbe/src/rt/GSLDeviceD3D10.cpp diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDeviceD3D11.cpp b/rocclr/device/gpu/gslbe/src/rt/GSLDeviceD3D11.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/src/rt/GSLDeviceD3D11.cpp rename to rocclr/device/gpu/gslbe/src/rt/GSLDeviceD3D11.cpp diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDeviceD3D9.cpp b/rocclr/device/gpu/gslbe/src/rt/GSLDeviceD3D9.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/src/rt/GSLDeviceD3D9.cpp rename to rocclr/device/gpu/gslbe/src/rt/GSLDeviceD3D9.cpp diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDeviceGL.cpp b/rocclr/device/gpu/gslbe/src/rt/GSLDeviceGL.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/src/rt/GSLDeviceGL.cpp rename to rocclr/device/gpu/gslbe/src/rt/GSLDeviceGL.cpp diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLStubs.cpp b/rocclr/device/gpu/gslbe/src/rt/GSLStubs.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/src/rt/GSLStubs.cpp rename to rocclr/device/gpu/gslbe/src/rt/GSLStubs.cpp diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/backend.cpp b/rocclr/device/gpu/gslbe/src/rt/backend.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/src/rt/backend.cpp rename to rocclr/device/gpu/gslbe/src/rt/backend.cpp diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/backend.h b/rocclr/device/gpu/gslbe/src/rt/backend.h similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/src/rt/backend.h rename to rocclr/device/gpu/gslbe/src/rt/backend.h diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/caltarget.h b/rocclr/device/gpu/gslbe/src/rt/caltarget.h similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/src/rt/caltarget.h rename to rocclr/device/gpu/gslbe/src/rt/caltarget.h diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/inifile/ini_export.cpp b/rocclr/device/gpu/gslbe/src/rt/inifile/ini_export.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/src/rt/inifile/ini_export.cpp rename to rocclr/device/gpu/gslbe/src/rt/inifile/ini_export.cpp diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/inifile/ini_export.h b/rocclr/device/gpu/gslbe/src/rt/inifile/ini_export.h similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/src/rt/inifile/ini_export.h rename to rocclr/device/gpu/gslbe/src/rt/inifile/ini_export.h diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/inifile/ini_values.h b/rocclr/device/gpu/gslbe/src/rt/inifile/ini_values.h similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/src/rt/inifile/ini_values.h rename to rocclr/device/gpu/gslbe/src/rt/inifile/ini_values.h diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/inifile/inifile.cpp b/rocclr/device/gpu/gslbe/src/rt/inifile/inifile.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/src/rt/inifile/inifile.cpp rename to rocclr/device/gpu/gslbe/src/rt/inifile/inifile.cpp diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/inifile/inifile.h b/rocclr/device/gpu/gslbe/src/rt/inifile/inifile.h similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/src/rt/inifile/inifile.h rename to rocclr/device/gpu/gslbe/src/rt/inifile/inifile.h diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/inifile/inifile_parser.cpp b/rocclr/device/gpu/gslbe/src/rt/inifile/inifile_parser.cpp similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/src/rt/inifile/inifile_parser.cpp rename to rocclr/device/gpu/gslbe/src/rt/inifile/inifile_parser.cpp diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/inifile/inifile_parser.h b/rocclr/device/gpu/gslbe/src/rt/inifile/inifile_parser.h similarity index 100% rename from rocclr/runtime/device/gpu/gslbe/src/rt/inifile/inifile_parser.h rename to rocclr/device/gpu/gslbe/src/rt/inifile/inifile_parser.h diff --git a/rocclr/runtime/device/hwdebug.cpp b/rocclr/device/hwdebug.cpp similarity index 100% rename from rocclr/runtime/device/hwdebug.cpp rename to rocclr/device/hwdebug.cpp diff --git a/rocclr/runtime/device/hwdebug.hpp b/rocclr/device/hwdebug.hpp similarity index 100% rename from rocclr/runtime/device/hwdebug.hpp rename to rocclr/device/hwdebug.hpp diff --git a/rocclr/runtime/device/pal/palappprofile.cpp b/rocclr/device/pal/palappprofile.cpp similarity index 100% rename from rocclr/runtime/device/pal/palappprofile.cpp rename to rocclr/device/pal/palappprofile.cpp diff --git a/rocclr/runtime/device/pal/palappprofile.hpp b/rocclr/device/pal/palappprofile.hpp similarity index 100% rename from rocclr/runtime/device/pal/palappprofile.hpp rename to rocclr/device/pal/palappprofile.hpp diff --git a/rocclr/runtime/device/pal/palblit.cpp b/rocclr/device/pal/palblit.cpp similarity index 100% rename from rocclr/runtime/device/pal/palblit.cpp rename to rocclr/device/pal/palblit.cpp diff --git a/rocclr/runtime/device/pal/palblit.hpp b/rocclr/device/pal/palblit.hpp similarity index 100% rename from rocclr/runtime/device/pal/palblit.hpp rename to rocclr/device/pal/palblit.hpp diff --git a/rocclr/runtime/device/pal/palconstbuf.cpp b/rocclr/device/pal/palconstbuf.cpp similarity index 100% rename from rocclr/runtime/device/pal/palconstbuf.cpp rename to rocclr/device/pal/palconstbuf.cpp diff --git a/rocclr/runtime/device/pal/palconstbuf.hpp b/rocclr/device/pal/palconstbuf.hpp similarity index 100% rename from rocclr/runtime/device/pal/palconstbuf.hpp rename to rocclr/device/pal/palconstbuf.hpp diff --git a/rocclr/runtime/device/pal/palcounters.cpp b/rocclr/device/pal/palcounters.cpp similarity index 100% rename from rocclr/runtime/device/pal/palcounters.cpp rename to rocclr/device/pal/palcounters.cpp diff --git a/rocclr/runtime/device/pal/palcounters.hpp b/rocclr/device/pal/palcounters.hpp similarity index 100% rename from rocclr/runtime/device/pal/palcounters.hpp rename to rocclr/device/pal/palcounters.hpp diff --git a/rocclr/runtime/device/pal/paldebugger.hpp b/rocclr/device/pal/paldebugger.hpp similarity index 100% rename from rocclr/runtime/device/pal/paldebugger.hpp rename to rocclr/device/pal/paldebugger.hpp diff --git a/rocclr/runtime/device/pal/paldebugmanager.cpp b/rocclr/device/pal/paldebugmanager.cpp similarity index 100% rename from rocclr/runtime/device/pal/paldebugmanager.cpp rename to rocclr/device/pal/paldebugmanager.cpp diff --git a/rocclr/runtime/device/pal/paldebugmanager.hpp b/rocclr/device/pal/paldebugmanager.hpp similarity index 100% rename from rocclr/runtime/device/pal/paldebugmanager.hpp rename to rocclr/device/pal/paldebugmanager.hpp diff --git a/rocclr/runtime/device/pal/paldefs.hpp b/rocclr/device/pal/paldefs.hpp similarity index 100% rename from rocclr/runtime/device/pal/paldefs.hpp rename to rocclr/device/pal/paldefs.hpp diff --git a/rocclr/runtime/device/pal/paldevice.cpp b/rocclr/device/pal/paldevice.cpp similarity index 100% rename from rocclr/runtime/device/pal/paldevice.cpp rename to rocclr/device/pal/paldevice.cpp diff --git a/rocclr/runtime/device/pal/paldevice.hpp b/rocclr/device/pal/paldevice.hpp similarity index 100% rename from rocclr/runtime/device/pal/paldevice.hpp rename to rocclr/device/pal/paldevice.hpp diff --git a/rocclr/runtime/device/pal/paldeviced3d10.cpp b/rocclr/device/pal/paldeviced3d10.cpp similarity index 100% rename from rocclr/runtime/device/pal/paldeviced3d10.cpp rename to rocclr/device/pal/paldeviced3d10.cpp diff --git a/rocclr/runtime/device/pal/paldeviced3d11.cpp b/rocclr/device/pal/paldeviced3d11.cpp similarity index 100% rename from rocclr/runtime/device/pal/paldeviced3d11.cpp rename to rocclr/device/pal/paldeviced3d11.cpp diff --git a/rocclr/runtime/device/pal/paldeviced3d9.cpp b/rocclr/device/pal/paldeviced3d9.cpp similarity index 100% rename from rocclr/runtime/device/pal/paldeviced3d9.cpp rename to rocclr/device/pal/paldeviced3d9.cpp diff --git a/rocclr/runtime/device/pal/paldevicegl.cpp b/rocclr/device/pal/paldevicegl.cpp similarity index 100% rename from rocclr/runtime/device/pal/paldevicegl.cpp rename to rocclr/device/pal/paldevicegl.cpp diff --git a/rocclr/runtime/device/pal/palgpuopen.cpp b/rocclr/device/pal/palgpuopen.cpp similarity index 100% rename from rocclr/runtime/device/pal/palgpuopen.cpp rename to rocclr/device/pal/palgpuopen.cpp diff --git a/rocclr/runtime/device/pal/palgpuopen.hpp b/rocclr/device/pal/palgpuopen.hpp similarity index 100% rename from rocclr/runtime/device/pal/palgpuopen.hpp rename to rocclr/device/pal/palgpuopen.hpp diff --git a/rocclr/runtime/device/pal/palkernel.cpp b/rocclr/device/pal/palkernel.cpp similarity index 100% rename from rocclr/runtime/device/pal/palkernel.cpp rename to rocclr/device/pal/palkernel.cpp diff --git a/rocclr/runtime/device/pal/palkernel.hpp b/rocclr/device/pal/palkernel.hpp similarity index 100% rename from rocclr/runtime/device/pal/palkernel.hpp rename to rocclr/device/pal/palkernel.hpp diff --git a/rocclr/runtime/device/pal/palmemory.cpp b/rocclr/device/pal/palmemory.cpp similarity index 100% rename from rocclr/runtime/device/pal/palmemory.cpp rename to rocclr/device/pal/palmemory.cpp diff --git a/rocclr/runtime/device/pal/palmemory.hpp b/rocclr/device/pal/palmemory.hpp similarity index 100% rename from rocclr/runtime/device/pal/palmemory.hpp rename to rocclr/device/pal/palmemory.hpp diff --git a/rocclr/runtime/device/pal/palprintf.cpp b/rocclr/device/pal/palprintf.cpp similarity index 100% rename from rocclr/runtime/device/pal/palprintf.cpp rename to rocclr/device/pal/palprintf.cpp diff --git a/rocclr/runtime/device/pal/palprintf.hpp b/rocclr/device/pal/palprintf.hpp similarity index 100% rename from rocclr/runtime/device/pal/palprintf.hpp rename to rocclr/device/pal/palprintf.hpp diff --git a/rocclr/runtime/device/pal/palprogram.cpp b/rocclr/device/pal/palprogram.cpp similarity index 100% rename from rocclr/runtime/device/pal/palprogram.cpp rename to rocclr/device/pal/palprogram.cpp diff --git a/rocclr/runtime/device/pal/palprogram.hpp b/rocclr/device/pal/palprogram.hpp similarity index 100% rename from rocclr/runtime/device/pal/palprogram.hpp rename to rocclr/device/pal/palprogram.hpp diff --git a/rocclr/runtime/device/pal/palresource.cpp b/rocclr/device/pal/palresource.cpp similarity index 100% rename from rocclr/runtime/device/pal/palresource.cpp rename to rocclr/device/pal/palresource.cpp diff --git a/rocclr/runtime/device/pal/palresource.hpp b/rocclr/device/pal/palresource.hpp similarity index 100% rename from rocclr/runtime/device/pal/palresource.hpp rename to rocclr/device/pal/palresource.hpp diff --git a/rocclr/runtime/device/pal/palsched.hpp b/rocclr/device/pal/palsched.hpp similarity index 100% rename from rocclr/runtime/device/pal/palsched.hpp rename to rocclr/device/pal/palsched.hpp diff --git a/rocclr/runtime/device/pal/palschedcl.cpp b/rocclr/device/pal/palschedcl.cpp similarity index 100% rename from rocclr/runtime/device/pal/palschedcl.cpp rename to rocclr/device/pal/palschedcl.cpp diff --git a/rocclr/runtime/device/pal/palsettings.cpp b/rocclr/device/pal/palsettings.cpp similarity index 100% rename from rocclr/runtime/device/pal/palsettings.cpp rename to rocclr/device/pal/palsettings.cpp diff --git a/rocclr/runtime/device/pal/palsettings.hpp b/rocclr/device/pal/palsettings.hpp similarity index 100% rename from rocclr/runtime/device/pal/palsettings.hpp rename to rocclr/device/pal/palsettings.hpp diff --git a/rocclr/runtime/device/pal/palthreadtrace.cpp b/rocclr/device/pal/palthreadtrace.cpp similarity index 100% rename from rocclr/runtime/device/pal/palthreadtrace.cpp rename to rocclr/device/pal/palthreadtrace.cpp diff --git a/rocclr/runtime/device/pal/palthreadtrace.hpp b/rocclr/device/pal/palthreadtrace.hpp similarity index 100% rename from rocclr/runtime/device/pal/palthreadtrace.hpp rename to rocclr/device/pal/palthreadtrace.hpp diff --git a/rocclr/runtime/device/pal/paltimestamp.cpp b/rocclr/device/pal/paltimestamp.cpp similarity index 100% rename from rocclr/runtime/device/pal/paltimestamp.cpp rename to rocclr/device/pal/paltimestamp.cpp diff --git a/rocclr/runtime/device/pal/paltimestamp.hpp b/rocclr/device/pal/paltimestamp.hpp similarity index 100% rename from rocclr/runtime/device/pal/paltimestamp.hpp rename to rocclr/device/pal/paltimestamp.hpp diff --git a/rocclr/runtime/device/pal/paltrap.hpp b/rocclr/device/pal/paltrap.hpp similarity index 100% rename from rocclr/runtime/device/pal/paltrap.hpp rename to rocclr/device/pal/paltrap.hpp diff --git a/rocclr/runtime/device/pal/palvirtual.cpp b/rocclr/device/pal/palvirtual.cpp similarity index 100% rename from rocclr/runtime/device/pal/palvirtual.cpp rename to rocclr/device/pal/palvirtual.cpp diff --git a/rocclr/runtime/device/pal/palvirtual.hpp b/rocclr/device/pal/palvirtual.hpp similarity index 100% rename from rocclr/runtime/device/pal/palvirtual.hpp rename to rocclr/device/pal/palvirtual.hpp diff --git a/rocclr/runtime/device/rocm/CMakeLists.txt b/rocclr/device/rocm/CMakeLists.txt similarity index 100% rename from rocclr/runtime/device/rocm/CMakeLists.txt rename to rocclr/device/rocm/CMakeLists.txt diff --git a/rocclr/runtime/device/rocm/mesa_glinterop.h b/rocclr/device/rocm/mesa_glinterop.h similarity index 100% rename from rocclr/runtime/device/rocm/mesa_glinterop.h rename to rocclr/device/rocm/mesa_glinterop.h diff --git a/rocclr/runtime/device/rocm/pro/lnxheaders.h b/rocclr/device/rocm/pro/lnxheaders.h similarity index 100% rename from rocclr/runtime/device/rocm/pro/lnxheaders.h rename to rocclr/device/rocm/pro/lnxheaders.h diff --git a/rocclr/runtime/device/rocm/pro/prodevice.cpp b/rocclr/device/rocm/pro/prodevice.cpp similarity index 100% rename from rocclr/runtime/device/rocm/pro/prodevice.cpp rename to rocclr/device/rocm/pro/prodevice.cpp diff --git a/rocclr/runtime/device/rocm/pro/prodevice.hpp b/rocclr/device/rocm/pro/prodevice.hpp similarity index 100% rename from rocclr/runtime/device/rocm/pro/prodevice.hpp rename to rocclr/device/rocm/pro/prodevice.hpp diff --git a/rocclr/runtime/device/rocm/pro/prodriver.hpp b/rocclr/device/rocm/pro/prodriver.hpp similarity index 100% rename from rocclr/runtime/device/rocm/pro/prodriver.hpp rename to rocclr/device/rocm/pro/prodriver.hpp diff --git a/rocclr/runtime/device/rocm/pro/profuncs.hpp b/rocclr/device/rocm/pro/profuncs.hpp similarity index 100% rename from rocclr/runtime/device/rocm/pro/profuncs.hpp rename to rocclr/device/rocm/pro/profuncs.hpp diff --git a/rocclr/runtime/device/rocm/rocappprofile.cpp b/rocclr/device/rocm/rocappprofile.cpp similarity index 100% rename from rocclr/runtime/device/rocm/rocappprofile.cpp rename to rocclr/device/rocm/rocappprofile.cpp diff --git a/rocclr/runtime/device/rocm/rocappprofile.hpp b/rocclr/device/rocm/rocappprofile.hpp similarity index 100% rename from rocclr/runtime/device/rocm/rocappprofile.hpp rename to rocclr/device/rocm/rocappprofile.hpp diff --git a/rocclr/runtime/device/rocm/rocblit.cpp b/rocclr/device/rocm/rocblit.cpp similarity index 100% rename from rocclr/runtime/device/rocm/rocblit.cpp rename to rocclr/device/rocm/rocblit.cpp diff --git a/rocclr/runtime/device/rocm/rocblit.hpp b/rocclr/device/rocm/rocblit.hpp similarity index 100% rename from rocclr/runtime/device/rocm/rocblit.hpp rename to rocclr/device/rocm/rocblit.hpp diff --git a/rocclr/runtime/device/rocm/roccounters.cpp b/rocclr/device/rocm/roccounters.cpp similarity index 100% rename from rocclr/runtime/device/rocm/roccounters.cpp rename to rocclr/device/rocm/roccounters.cpp diff --git a/rocclr/runtime/device/rocm/roccounters.hpp b/rocclr/device/rocm/roccounters.hpp similarity index 100% rename from rocclr/runtime/device/rocm/roccounters.hpp rename to rocclr/device/rocm/roccounters.hpp diff --git a/rocclr/runtime/device/rocm/rocdefs.hpp b/rocclr/device/rocm/rocdefs.hpp similarity index 100% rename from rocclr/runtime/device/rocm/rocdefs.hpp rename to rocclr/device/rocm/rocdefs.hpp diff --git a/rocclr/runtime/device/rocm/rocdevice.cpp b/rocclr/device/rocm/rocdevice.cpp similarity index 100% rename from rocclr/runtime/device/rocm/rocdevice.cpp rename to rocclr/device/rocm/rocdevice.cpp diff --git a/rocclr/runtime/device/rocm/rocdevice.hpp b/rocclr/device/rocm/rocdevice.hpp similarity index 100% rename from rocclr/runtime/device/rocm/rocdevice.hpp rename to rocclr/device/rocm/rocdevice.hpp diff --git a/rocclr/runtime/device/rocm/rocglinterop.cpp b/rocclr/device/rocm/rocglinterop.cpp similarity index 100% rename from rocclr/runtime/device/rocm/rocglinterop.cpp rename to rocclr/device/rocm/rocglinterop.cpp diff --git a/rocclr/runtime/device/rocm/rocglinterop.hpp b/rocclr/device/rocm/rocglinterop.hpp similarity index 100% rename from rocclr/runtime/device/rocm/rocglinterop.hpp rename to rocclr/device/rocm/rocglinterop.hpp diff --git a/rocclr/runtime/device/rocm/rochostcall.cpp b/rocclr/device/rocm/rochostcall.cpp similarity index 99% rename from rocclr/runtime/device/rocm/rochostcall.cpp rename to rocclr/device/rocm/rochostcall.cpp index d9245a03f5..b7d0566834 100644 --- a/rocclr/runtime/device/rocm/rochostcall.cpp +++ b/rocclr/device/rocm/rochostcall.cpp @@ -14,6 +14,7 @@ #include #include +#include #include namespace { // anonymous diff --git a/rocclr/runtime/device/rocm/rochostcall.hpp b/rocclr/device/rocm/rochostcall.hpp similarity index 100% rename from rocclr/runtime/device/rocm/rochostcall.hpp rename to rocclr/device/rocm/rochostcall.hpp diff --git a/rocclr/runtime/device/rocm/rockernel.cpp b/rocclr/device/rocm/rockernel.cpp similarity index 100% rename from rocclr/runtime/device/rocm/rockernel.cpp rename to rocclr/device/rocm/rockernel.cpp diff --git a/rocclr/runtime/device/rocm/rockernel.hpp b/rocclr/device/rocm/rockernel.hpp similarity index 100% rename from rocclr/runtime/device/rocm/rockernel.hpp rename to rocclr/device/rocm/rockernel.hpp diff --git a/rocclr/runtime/device/rocm/rocmemory.cpp b/rocclr/device/rocm/rocmemory.cpp similarity index 100% rename from rocclr/runtime/device/rocm/rocmemory.cpp rename to rocclr/device/rocm/rocmemory.cpp diff --git a/rocclr/runtime/device/rocm/rocmemory.hpp b/rocclr/device/rocm/rocmemory.hpp similarity index 100% rename from rocclr/runtime/device/rocm/rocmemory.hpp rename to rocclr/device/rocm/rocmemory.hpp diff --git a/rocclr/runtime/device/rocm/rocprintf.cpp b/rocclr/device/rocm/rocprintf.cpp similarity index 100% rename from rocclr/runtime/device/rocm/rocprintf.cpp rename to rocclr/device/rocm/rocprintf.cpp diff --git a/rocclr/runtime/device/rocm/rocprintf.hpp b/rocclr/device/rocm/rocprintf.hpp similarity index 100% rename from rocclr/runtime/device/rocm/rocprintf.hpp rename to rocclr/device/rocm/rocprintf.hpp diff --git a/rocclr/runtime/device/rocm/rocprogram.cpp b/rocclr/device/rocm/rocprogram.cpp similarity index 100% rename from rocclr/runtime/device/rocm/rocprogram.cpp rename to rocclr/device/rocm/rocprogram.cpp diff --git a/rocclr/runtime/device/rocm/rocprogram.hpp b/rocclr/device/rocm/rocprogram.hpp similarity index 100% rename from rocclr/runtime/device/rocm/rocprogram.hpp rename to rocclr/device/rocm/rocprogram.hpp diff --git a/rocclr/runtime/device/rocm/rocregisters.hpp b/rocclr/device/rocm/rocregisters.hpp similarity index 100% rename from rocclr/runtime/device/rocm/rocregisters.hpp rename to rocclr/device/rocm/rocregisters.hpp diff --git a/rocclr/runtime/device/rocm/rocsched.hpp b/rocclr/device/rocm/rocsched.hpp similarity index 100% rename from rocclr/runtime/device/rocm/rocsched.hpp rename to rocclr/device/rocm/rocsched.hpp diff --git a/rocclr/runtime/device/rocm/rocschedcl.cpp b/rocclr/device/rocm/rocschedcl.cpp similarity index 100% rename from rocclr/runtime/device/rocm/rocschedcl.cpp rename to rocclr/device/rocm/rocschedcl.cpp diff --git a/rocclr/runtime/device/rocm/rocsettings.cpp b/rocclr/device/rocm/rocsettings.cpp similarity index 100% rename from rocclr/runtime/device/rocm/rocsettings.cpp rename to rocclr/device/rocm/rocsettings.cpp diff --git a/rocclr/runtime/device/rocm/rocsettings.hpp b/rocclr/device/rocm/rocsettings.hpp similarity index 100% rename from rocclr/runtime/device/rocm/rocsettings.hpp rename to rocclr/device/rocm/rocsettings.hpp diff --git a/rocclr/runtime/device/rocm/rocvirtual.cpp b/rocclr/device/rocm/rocvirtual.cpp similarity index 100% rename from rocclr/runtime/device/rocm/rocvirtual.cpp rename to rocclr/device/rocm/rocvirtual.cpp diff --git a/rocclr/runtime/device/rocm/rocvirtual.hpp b/rocclr/device/rocm/rocvirtual.hpp similarity index 100% rename from rocclr/runtime/device/rocm/rocvirtual.hpp rename to rocclr/device/rocm/rocvirtual.hpp diff --git a/rocclr/compiler/lib/loaders/elf/elf.cpp b/rocclr/elf/elf.cpp similarity index 100% rename from rocclr/compiler/lib/loaders/elf/elf.cpp rename to rocclr/elf/elf.cpp diff --git a/rocclr/compiler/lib/loaders/elf/elf.hpp b/rocclr/elf/elf.hpp similarity index 100% rename from rocclr/compiler/lib/loaders/elf/elf.hpp rename to rocclr/elf/elf.hpp diff --git a/rocclr/compiler/lib/loaders/elf/elf_utils.cpp b/rocclr/elf/elf_utils.cpp similarity index 100% rename from rocclr/compiler/lib/loaders/elf/elf_utils.cpp rename to rocclr/elf/elf_utils.cpp diff --git a/rocclr/compiler/lib/loaders/elf/elf_utils.hpp b/rocclr/elf/elf_utils.hpp similarity index 100% rename from rocclr/compiler/lib/loaders/elf/elf_utils.hpp rename to rocclr/elf/elf_utils.hpp diff --git a/rocclr/compiler/lib/loaders/elf/utils/common/_elftc.h b/rocclr/elf/utils/common/_elftc.h similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/common/_elftc.h rename to rocclr/elf/utils/common/_elftc.h diff --git a/rocclr/compiler/lib/loaders/elf/utils/common/elfdefinitions.h b/rocclr/elf/utils/common/elfdefinitions.h similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/common/elfdefinitions.h rename to rocclr/elf/utils/common/elfdefinitions.h diff --git a/rocclr/compiler/lib/loaders/elf/utils/common/native-elf-format b/rocclr/elf/utils/common/native-elf-format similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/common/native-elf-format rename to rocclr/elf/utils/common/native-elf-format diff --git a/rocclr/compiler/lib/loaders/elf/utils/common/native-elf-format.h b/rocclr/elf/utils/common/native-elf-format.h similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/common/native-elf-format.h rename to rocclr/elf/utils/common/native-elf-format.h diff --git a/rocclr/compiler/lib/loaders/elf/utils/common/uthash.h b/rocclr/elf/utils/common/uthash.h similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/common/uthash.h rename to rocclr/elf/utils/common/uthash.h diff --git a/rocclr/elf/utils/common/win32/sys/cdefs.h b/rocclr/elf/utils/common/win32/sys/cdefs.h new file mode 100644 index 0000000000..674a8c923e --- /dev/null +++ b/rocclr/elf/utils/common/win32/sys/cdefs.h @@ -0,0 +1,12 @@ +#ifndef _SYS_CDEFS_H_ +#define _SYS_CDEFS_H_ 1 + +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS +# define __END_DECLS +#endif + +#endif \ No newline at end of file diff --git a/rocclr/elf/utils/common/win32/sys/elf32.h b/rocclr/elf/utils/common/win32/sys/elf32.h new file mode 100644 index 0000000000..70ff2ea6c4 --- /dev/null +++ b/rocclr/elf/utils/common/win32/sys/elf32.h @@ -0,0 +1,163 @@ +/*- + * Copyright (c) 1996-1998 John D. Polstra. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/sys/elf32.h,v 1.8.14.1 2005/12/30 22:13:58 marcel Exp $ + */ + +#ifndef _SYS_ELF32_H_ +#define _SYS_ELF32_H_ 1 + +#include "elf_common.h" + +/* + * ELF definitions common to all 32-bit architectures. + */ + +typedef uint32_t Elf32_Addr; +typedef uint16_t Elf32_Half; +typedef uint32_t Elf32_Off; +typedef int32_t Elf32_Sword; +typedef uint32_t Elf32_Word; + +typedef Elf32_Word Elf32_Hashelt; + +/* Non-standard class-dependent datatype used for abstraction. */ +typedef Elf32_Word Elf32_Size; +typedef Elf32_Sword Elf32_Ssize; + +/* + * ELF header. + */ + +typedef struct { + unsigned char e_ident[EI_NIDENT]; /* File identification. */ + Elf32_Half e_type; /* File type. */ + Elf32_Half e_machine; /* Machine architecture. */ + Elf32_Word e_version; /* ELF format version. */ + Elf32_Addr e_entry; /* Entry point. */ + Elf32_Off e_phoff; /* Program header file offset. */ + Elf32_Off e_shoff; /* Section header file offset. */ + Elf32_Word e_flags; /* Architecture-specific flags. */ + Elf32_Half e_ehsize; /* Size of ELF header in bytes. */ + Elf32_Half e_phentsize; /* Size of program header entry. */ + Elf32_Half e_phnum; /* Number of program header entries. */ + Elf32_Half e_shentsize; /* Size of section header entry. */ + Elf32_Half e_shnum; /* Number of section header entries. */ + Elf32_Half e_shstrndx; /* Section name strings section. */ +} Elf32_Ehdr; + +/* + * Section header. + */ + +typedef struct { + Elf32_Word sh_name; /* Section name (index into the + section header string table). */ + Elf32_Word sh_type; /* Section type. */ + Elf32_Word sh_flags; /* Section flags. */ + Elf32_Addr sh_addr; /* Address in memory image. */ + Elf32_Off sh_offset; /* Offset in file. */ + Elf32_Word sh_size; /* Size in bytes. */ + Elf32_Word sh_link; /* Index of a related section. */ + Elf32_Word sh_info; /* Depends on section type. */ + Elf32_Word sh_addralign; /* Alignment in bytes. */ + Elf32_Word sh_entsize; /* Size of each entry in section. */ +} Elf32_Shdr; + +/* + * Program header. + */ + +typedef struct { + Elf32_Word p_type; /* Entry type. */ + Elf32_Off p_offset; /* File offset of contents. */ + Elf32_Addr p_vaddr; /* Virtual address in memory image. */ + Elf32_Addr p_paddr; /* Physical address (not used). */ + Elf32_Word p_filesz; /* Size of contents in file. */ + Elf32_Word p_memsz; /* Size of contents in memory. */ + Elf32_Word p_flags; /* Access permission flags. */ + Elf32_Word p_align; /* Alignment in memory and file. */ +} Elf32_Phdr; + +/* + * Dynamic structure. The ".dynamic" section contains an array of them. + */ + +typedef struct { + Elf32_Sword d_tag; /* Entry type. */ + union { + Elf32_Word d_val; /* Integer value. */ + Elf32_Addr d_ptr; /* Address value. */ + } d_un; +} Elf32_Dyn; + +/* + * Relocation entries. + */ + +/* Relocations that don't need an addend field. */ +typedef struct { + Elf32_Addr r_offset; /* Location to be relocated. */ + Elf32_Word r_info; /* Relocation type and symbol index. */ +} Elf32_Rel; + +/* Relocations that need an addend field. */ +typedef struct { + Elf32_Addr r_offset; /* Location to be relocated. */ + Elf32_Word r_info; /* Relocation type and symbol index. */ + Elf32_Sword r_addend; /* Addend. */ +} Elf32_Rela; + +/* Macros for accessing the fields of r_info. */ +#define ELF32_R_SYM(info) ((info) >> 8) +#define ELF32_R_TYPE(info) ((unsigned char)(info)) + +/* Macro for constructing r_info from field values. */ +#define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type)) + +/* + * Symbol table entries. + */ + +typedef struct { + Elf32_Word st_name; /* String table index of name. */ + Elf32_Addr st_value; /* Symbol value. */ + Elf32_Word st_size; /* Size of associated object. */ + unsigned char st_info; /* Type and binding information. */ + unsigned char st_other; /* Reserved (not used). */ + Elf32_Half st_shndx; /* Section index of symbol. */ +} Elf32_Sym; + +/* Macros for accessing the fields of st_info. */ +#define ELF32_ST_BIND(info) ((info) >> 4) +#define ELF32_ST_TYPE(info) ((info) & 0xf) + +/* Macro for constructing st_info from field values. */ +#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) + +/* Macro for accessing the fields of st_other. */ +#define ELF32_ST_VISIBILITY(oth) ((oth) & 0x3) + +#endif /* !_SYS_ELF32_H_ */ \ No newline at end of file diff --git a/rocclr/elf/utils/common/win32/sys/elf64.h b/rocclr/elf/utils/common/win32/sys/elf64.h new file mode 100644 index 0000000000..749fae6b5d --- /dev/null +++ b/rocclr/elf/utils/common/win32/sys/elf64.h @@ -0,0 +1,176 @@ +/*- + * Copyright (c) 1996-1998 John D. Polstra. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/sys/elf64.h,v 1.10.14.1 2005/12/30 22:13:58 marcel Exp $ + */ + +#ifndef _SYS_ELF64_H_ +#define _SYS_ELF64_H_ 1 + +#include "elf_common.h" + +/* + * ELF definitions common to all 64-bit architectures. + */ + +typedef uint64_t Elf64_Addr; +typedef uint16_t Elf64_Half; +typedef uint64_t Elf64_Off; +typedef int32_t Elf64_Sword; +typedef int64_t Elf64_Sxword; +typedef uint32_t Elf64_Word; +typedef uint64_t Elf64_Xword; + +/* + * Types of dynamic symbol hash table bucket and chain elements. + * + * This is inconsistent among 64 bit architectures, so a machine dependent + * typedef is required. + */ + +#ifdef __alpha__ +typedef Elf64_Off Elf64_Hashelt; +#else +typedef Elf64_Word Elf64_Hashelt; +#endif + +/* Non-standard class-dependent datatype used for abstraction. */ +typedef Elf64_Xword Elf64_Size; +typedef Elf64_Sxword Elf64_Ssize; + +/* + * ELF header. + */ + +typedef struct { + unsigned char e_ident[EI_NIDENT]; /* File identification. */ + Elf64_Half e_type; /* File type. */ + Elf64_Half e_machine; /* Machine architecture. */ + Elf64_Word e_version; /* ELF format version. */ + Elf64_Addr e_entry; /* Entry point. */ + Elf64_Off e_phoff; /* Program header file offset. */ + Elf64_Off e_shoff; /* Section header file offset. */ + Elf64_Word e_flags; /* Architecture-specific flags. */ + Elf64_Half e_ehsize; /* Size of ELF header in bytes. */ + Elf64_Half e_phentsize; /* Size of program header entry. */ + Elf64_Half e_phnum; /* Number of program header entries. */ + Elf64_Half e_shentsize; /* Size of section header entry. */ + Elf64_Half e_shnum; /* Number of section header entries. */ + Elf64_Half e_shstrndx; /* Section name strings section. */ +} Elf64_Ehdr; + +/* + * Section header. + */ + +typedef struct { + Elf64_Word sh_name; /* Section name (index into the + section header string table). */ + Elf64_Word sh_type; /* Section type. */ + Elf64_Xword sh_flags; /* Section flags. */ + Elf64_Addr sh_addr; /* Address in memory image. */ + Elf64_Off sh_offset; /* Offset in file. */ + Elf64_Xword sh_size; /* Size in bytes. */ + Elf64_Word sh_link; /* Index of a related section. */ + Elf64_Word sh_info; /* Depends on section type. */ + Elf64_Xword sh_addralign; /* Alignment in bytes. */ + Elf64_Xword sh_entsize; /* Size of each entry in section. */ +} Elf64_Shdr; + +/* + * Program header. + */ + +typedef struct { + Elf64_Word p_type; /* Entry type. */ + Elf64_Word p_flags; /* Access permission flags. */ + Elf64_Off p_offset; /* File offset of contents. */ + Elf64_Addr p_vaddr; /* Virtual address in memory image. */ + Elf64_Addr p_paddr; /* Physical address (not used). */ + Elf64_Xword p_filesz; /* Size of contents in file. */ + Elf64_Xword p_memsz; /* Size of contents in memory. */ + Elf64_Xword p_align; /* Alignment in memory and file. */ +} Elf64_Phdr; + +/* + * Dynamic structure. The ".dynamic" section contains an array of them. + */ + +typedef struct { + Elf64_Sxword d_tag; /* Entry type. */ + union { + Elf64_Xword d_val; /* Integer value. */ + Elf64_Addr d_ptr; /* Address value. */ + } d_un; +} Elf64_Dyn; + +/* + * Relocation entries. + */ + +/* Relocations that don't need an addend field. */ +typedef struct { + Elf64_Addr r_offset; /* Location to be relocated. */ + Elf64_Xword r_info; /* Relocation type and symbol index. */ +} Elf64_Rel; + +/* Relocations that need an addend field. */ +typedef struct { + Elf64_Addr r_offset; /* Location to be relocated. */ + Elf64_Xword r_info; /* Relocation type and symbol index. */ + Elf64_Sxword r_addend; /* Addend. */ +} Elf64_Rela; + +/* Macros for accessing the fields of r_info. */ +#define ELF64_R_SYM(info) ((info) >> 32) +#define ELF64_R_TYPE(info) ((info) & 0xffffffffL) + +/* Macro for constructing r_info from field values. */ +#define ELF64_R_INFO(sym, type) (((sym) << 32) + ((type) & 0xffffffffL)) + +/* + * Symbol table entries. + */ + +typedef struct { + Elf64_Word st_name; /* String table index of name. */ + unsigned char st_info; /* Type and binding information. */ + unsigned char st_other; /* Reserved (not used). */ + Elf64_Half st_shndx; /* Section index of symbol. */ + Elf64_Addr st_value; /* Symbol value. */ + Elf64_Xword st_size; /* Size of associated object. */ +} Elf64_Sym; + +/* Macros for accessing the fields of st_info. */ +#define ELF64_ST_BIND(info) ((info) >> 4) +#define ELF64_ST_TYPE(info) ((info) & 0xf) + +/* Macro for constructing st_info from field values. */ +#define ELF64_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) + +/* Macro for accessing the fields of st_other. */ +#define ELF64_ST_VISIBILITY(oth) ((oth) & 0x3) + +#endif /* !_SYS_ELF64_H_ */ \ No newline at end of file diff --git a/rocclr/elf/utils/common/win32/sys/elf_common.h b/rocclr/elf/utils/common/win32/sys/elf_common.h new file mode 100644 index 0000000000..b11f1702f7 --- /dev/null +++ b/rocclr/elf/utils/common/win32/sys/elf_common.h @@ -0,0 +1,355 @@ +/*- + * Copyright (c) 1998 John D. Polstra. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/sys/elf_common.h,v 1.15.8.1 2005/12/30 22:13:58 marcel Exp $ + */ + +#ifndef _SYS_ELF_COMMON_H_ +#define _SYS_ELF_COMMON_H_ 1 + +/* + * ELF definitions that are independent of architecture or word size. + */ + +/* + * Note header. The ".note" section contains an array of notes. Each + * begins with this header, aligned to a word boundary. Immediately + * following the note header is n_namesz bytes of name, padded to the + * next word boundary. Then comes n_descsz bytes of descriptor, again + * padded to a word boundary. The values of n_namesz and n_descsz do + * not include the padding. + */ + +typedef struct { + u_int32_t n_namesz; /* Length of name. */ + u_int32_t n_descsz; /* Length of descriptor. */ + u_int32_t n_type; /* Type of this note. */ +} Elf_Note; + +/* Indexes into the e_ident array. Keep synced with + http://www.sco.com/developer/gabi/ch4.eheader.html */ +#define EI_MAG0 0 /* Magic number, byte 0. */ +#define EI_MAG1 1 /* Magic number, byte 1. */ +#define EI_MAG2 2 /* Magic number, byte 2. */ +#define EI_MAG3 3 /* Magic number, byte 3. */ +#define EI_CLASS 4 /* Class of machine. */ +#define EI_DATA 5 /* Data format. */ +#define EI_VERSION 6 /* ELF format version. */ +#define EI_OSABI 7 /* Operating system / ABI identification */ +#define EI_ABIVERSION 8 /* ABI version */ +#define OLD_EI_BRAND 8 /* Start of architecture identification. */ +#define EI_PAD 9 /* Start of padding (per SVR4 ABI). */ +#define EI_NIDENT 16 /* Size of e_ident array. */ + +/* Values for the magic number bytes. */ +#define ELFMAG0 0x7f +#define ELFMAG1 'E' +#define ELFMAG2 'L' +#define ELFMAG3 'F' +#define ELFMAG "\177ELF" /* magic string */ +#define SELFMAG 4 /* magic string size */ + +/* Values for e_ident[EI_VERSION] and e_version. */ +#define EV_NONE 0 +#define EV_CURRENT 1 + +/* Values for e_ident[EI_CLASS]. */ +#define ELFCLASSNONE 0 /* Unknown class. */ +#define ELFCLASS32 1 /* 32-bit architecture. */ +#define ELFCLASS64 2 /* 64-bit architecture. */ + +/* Values for e_ident[EI_DATA]. */ +#define ELFDATANONE 0 /* Unknown data format. */ +#define ELFDATA2LSB 1 /* 2's complement little-endian. */ +#define ELFDATA2MSB 2 /* 2's complement big-endian. */ + +/* Values for e_ident[EI_OSABI]. */ +#define ELFOSABI_NONE 0 /* UNIX System V ABI */ +#define ELFOSABI_HPUX 1 /* HP-UX operating system */ +#define ELFOSABI_NETBSD 2 /* NetBSD */ +#define ELFOSABI_LINUX 3 /* GNU/Linux */ +#define ELFOSABI_HURD 4 /* GNU/Hurd */ +#define ELFOSABI_86OPEN 5 /* 86Open common IA32 ABI */ +#define ELFOSABI_SOLARIS 6 /* Solaris */ +#define ELFOSABI_AIX 7 /* AIX */ +#define ELFOSABI_IRIX 8 /* IRIX */ +#define ELFOSABI_FREEBSD 9 /* FreeBSD */ +#define ELFOSABI_TRU64 10 /* TRU64 UNIX */ +#define ELFOSABI_MODESTO 11 /* Novell Modesto */ +#define ELFOSABI_OPENBSD 12 /* OpenBSD */ +#define ELFOSABI_OPENVMS 13 /* Open VMS */ +#define ELFOSABI_NSK 14 /* HP Non-Stop Kernel */ +#define ELFOSABI_ARM 97 /* ARM */ +#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ + +#define ELFOSABI_SYSV ELFOSABI_NONE /* symbol used in old spec */ +#define ELFOSABI_MONTEREY ELFOSABI_AIX /* Monterey */ + +/* e_ident */ +#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \ + (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \ + (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \ + (ehdr).e_ident[EI_MAG3] == ELFMAG3) + +/* Values for e_type. */ +#define ET_NONE 0 /* Unknown type. */ +#define ET_REL 1 /* Relocatable. */ +#define ET_EXEC 2 /* Executable. */ +#define ET_DYN 3 /* Shared object. */ +#define ET_CORE 4 /* Core file. */ +#define ET_LOOS 0xfe00 /* First operating system specific. */ +#define ET_HIOS 0xfeff /* Last operating system-specific. */ +#define ET_LOPROC 0xff00 /* First processor-specific. */ +#define ET_HIPROC 0xffff /* Last processor-specific. */ + +/* Values for e_machine. */ +#define EM_NONE 0 /* Unknown machine. */ +#define EM_M32 1 /* AT&T WE32100. */ +#define EM_SPARC 2 /* Sun SPARC. */ +#define EM_386 3 /* Intel i386. */ +#define EM_68K 4 /* Motorola 68000. */ +#define EM_88K 5 /* Motorola 88000. */ +#define EM_860 7 /* Intel i860. */ +#define EM_MIPS 8 /* MIPS R3000 Big-Endian only. */ +#define EM_S370 9 /* IBM System/370. */ +#define EM_MIPS_RS3_LE 10 /* MIPS R3000 Little-Endian. */ +#define EM_PARISC 15 /* HP PA-RISC. */ +#define EM_VPP500 17 /* Fujitsu VPP500. */ +#define EM_SPARC32PLUS 18 /* SPARC v8plus. */ +#define EM_960 19 /* Intel 80960. */ +#define EM_PPC 20 /* PowerPC 32-bit. */ +#define EM_PPC64 21 /* PowerPC 64-bit. */ +#define EM_S390 22 /* IBM System/390. */ +#define EM_V800 36 /* NEC V800. */ +#define EM_FR20 37 /* Fujitsu FR20. */ +#define EM_RH32 38 /* TRW RH-32. */ +#define EM_RCE 39 /* Motorola RCE. */ +#define EM_ARM 40 /* ARM. */ +#define EM_SH 42 /* Hitachi SH. */ +#define EM_SPARCV9 43 /* SPARC v9 64-bit. */ +#define EM_TRICORE 44 /* Siemens TriCore embedded processor. */ +#define EM_ARC 45 /* Argonaut RISC Core. */ +#define EM_H8_300 46 /* Hitachi H8/300. */ +#define EM_H8_300H 47 /* Hitachi H8/300H. */ +#define EM_H8S 48 /* Hitachi H8S. */ +#define EM_H8_500 49 /* Hitachi H8/500. */ +#define EM_IA_64 50 /* Intel IA-64 Processor. */ +#define EM_MIPS_X 51 /* Stanford MIPS-X. */ +#define EM_COLDFIRE 52 /* Motorola ColdFire. */ +#define EM_68HC12 53 /* Motorola M68HC12. */ +#define EM_MMA 54 /* Fujitsu MMA. */ +#define EM_PCP 55 /* Siemens PCP. */ +#define EM_NCPU 56 /* Sony nCPU. */ +#define EM_NDR1 57 /* Denso NDR1 microprocessor. */ +#define EM_STARCORE 58 /* Motorola Star*Core processor. */ +#define EM_ME16 59 /* Toyota ME16 processor. */ +#define EM_ST100 60 /* STMicroelectronics ST100 processor. */ +#define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ processor. */ +#define EM_X86_64 62 /* Advanced Micro Devices x86-64 */ + +/* Non-standard or deprecated. */ +#define EM_486 6 /* Intel i486. */ +#define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */ +#define EM_ALPHA_STD 41 /* Digital Alpha (standard value). */ +#define EM_ALPHA 0x9026 /* Alpha (written in the absence of an ABI) */ + +/* Special section indexes. */ +#define SHN_UNDEF 0 /* Undefined, missing, irrelevant. */ +#define SHN_LORESERVE 0xff00 /* First of reserved range. */ +#define SHN_LOPROC 0xff00 /* First processor-specific. */ +#define SHN_HIPROC 0xff1f /* Last processor-specific. */ +#define SHN_LOOS 0xff20 /* First operating system-specific. */ +#define SHN_HIOS 0xff3f /* Last operating system-specific. */ +#define SHN_ABS 0xfff1 /* Absolute values. */ +#define SHN_COMMON 0xfff2 /* Common data. */ +#define SHN_XINDEX 0xffff /* Escape -- index stored elsewhere. */ +#define SHN_HIRESERVE 0xffff /* Last of reserved range. */ + +/* sh_type */ +#define SHT_NULL 0 /* inactive */ +#define SHT_PROGBITS 1 /* program defined information */ +#define SHT_SYMTAB 2 /* symbol table section */ +#define SHT_STRTAB 3 /* string table section */ +#define SHT_RELA 4 /* relocation section with addends */ +#define SHT_HASH 5 /* symbol hash table section */ +#define SHT_DYNAMIC 6 /* dynamic section */ +#define SHT_NOTE 7 /* note section */ +#define SHT_NOBITS 8 /* no space section */ +#define SHT_REL 9 /* relocation section - no addends */ +#define SHT_SHLIB 10 /* reserved - purpose unknown */ +#define SHT_DYNSYM 11 /* dynamic symbol table section */ +#define SHT_INIT_ARRAY 14 /* Initialization function pointers. */ +#define SHT_FINI_ARRAY 15 /* Termination function pointers. */ +#define SHT_PREINIT_ARRAY 16 /* Pre-initialization function ptrs. */ +#define SHT_GROUP 17 /* Section group. */ +#define SHT_SYMTAB_SHNDX 18 /* Section indexes (see SHN_XINDEX). */ +#define SHT_LOOS 0x60000000 /* First of OS specific semantics */ +#define SHT_HIOS 0x6fffffff /* Last of OS specific semantics */ +#define SHT_LOPROC 0x70000000 /* reserved range for processor */ +#define SHT_HIPROC 0x7fffffff /* specific section header types */ +#define SHT_LOUSER 0x80000000 /* reserved range for application */ +#define SHT_HIUSER 0xffffffff /* specific indexes */ + +/* Flags for sh_flags. */ +#define SHF_WRITE 0x1 /* Section contains writable data. */ +#define SHF_ALLOC 0x2 /* Section occupies memory. */ +#define SHF_EXECINSTR 0x4 /* Section contains instructions. */ +#define SHF_MERGE 0x10 /* Section may be merged. */ +#define SHF_STRINGS 0x20 /* Section contains strings. */ +#define SHF_INFO_LINK 0x40 /* sh_info holds section index. */ +#define SHF_LINK_ORDER 0x80 /* Special ordering requirements. */ +#define SHF_OS_NONCONFORMING 0x100 /* OS-specific processing required. */ +#define SHF_GROUP 0x200 /* Member of section group. */ +#define SHF_TLS 0x400 /* Section contains TLS data. */ +#define SHF_MASKOS 0x0ff00000 /* OS-specific semantics. */ +#define SHF_MASKPROC 0xf0000000 /* Processor-specific semantics. */ + +/* Values for p_type. */ +#define PT_NULL 0 /* Unused entry. */ +#define PT_LOAD 1 /* Loadable segment. */ +#define PT_DYNAMIC 2 /* Dynamic linking information segment. */ +#define PT_INTERP 3 /* Pathname of interpreter. */ +#define PT_NOTE 4 /* Auxiliary information. */ +#define PT_SHLIB 5 /* Reserved (not used). */ +#define PT_PHDR 6 /* Location of program header itself. */ +#define PT_TLS 7 /* Thread local storage segment */ +#define PT_LOOS 0x60000000 /* First OS-specific. */ +#define PT_HIOS 0x6fffffff /* Last OS-specific. */ +#define PT_LOPROC 0x70000000 /* First processor-specific type. */ +#define PT_HIPROC 0x7fffffff /* Last processor-specific type. */ + +/* Values for p_flags. */ +#define PF_X 0x1 /* Executable. */ +#define PF_W 0x2 /* Writable. */ +#define PF_R 0x4 /* Readable. */ +#define PF_MASKOS 0x0ff00000 /* Operating system-specific. */ +#define PF_MASKPROC 0xf0000000 /* Processor-specific. */ + +/* Values for d_tag. */ +#define DT_NULL 0 /* Terminating entry. */ +#define DT_NEEDED 1 /* String table offset of a needed shared + library. */ +#define DT_PLTRELSZ 2 /* Total size in bytes of PLT relocations. */ +#define DT_PLTGOT 3 /* Processor-dependent address. */ +#define DT_HASH 4 /* Address of symbol hash table. */ +#define DT_STRTAB 5 /* Address of string table. */ +#define DT_SYMTAB 6 /* Address of symbol table. */ +#define DT_RELA 7 /* Address of ElfNN_Rela relocations. */ +#define DT_RELASZ 8 /* Total size of ElfNN_Rela relocations. */ +#define DT_RELAENT 9 /* Size of each ElfNN_Rela relocation entry. */ +#define DT_STRSZ 10 /* Size of string table. */ +#define DT_SYMENT 11 /* Size of each symbol table entry. */ +#define DT_INIT 12 /* Address of initialization function. */ +#define DT_FINI 13 /* Address of finalization function. */ +#define DT_SONAME 14 /* String table offset of shared object + name. */ +#define DT_RPATH 15 /* String table offset of library path. [sup] */ +#define DT_SYMBOLIC 16 /* Indicates "symbolic" linking. [sup] */ +#define DT_REL 17 /* Address of ElfNN_Rel relocations. */ +#define DT_RELSZ 18 /* Total size of ElfNN_Rel relocations. */ +#define DT_RELENT 19 /* Size of each ElfNN_Rel relocation. */ +#define DT_PLTREL 20 /* Type of relocation used for PLT. */ +#define DT_DEBUG 21 /* Reserved (not used). */ +#define DT_TEXTREL 22 /* Indicates there may be relocations in + non-writable segments. [sup] */ +#define DT_JMPREL 23 /* Address of PLT relocations. */ +#define DT_BIND_NOW 24 /* [sup] */ +#define DT_INIT_ARRAY 25 /* Address of the array of pointers to + initialization functions */ +#define DT_FINI_ARRAY 26 /* Address of the array of pointers to + termination functions */ +#define DT_INIT_ARRAYSZ 27 /* Size in bytes of the array of + initialization functions. */ +#define DT_FINI_ARRAYSZ 28 /* Size in bytes of the array of + terminationfunctions. */ +#define DT_RUNPATH 29 /* String table offset of a null-terminated + library search path string. */ +#define DT_FLAGS 30 /* Object specific flag values. */ +#define DT_ENCODING 32 /* Values greater than or equal to DT_ENCODING + and less than DT_LOOS follow the rules for + the interpretation of the d_un union + as follows: even == 'd_ptr', even == 'd_val' + or none */ +#define DT_PREINIT_ARRAY 32 /* Address of the array of pointers to + pre-initialization functions. */ +#define DT_PREINIT_ARRAYSZ 33 /* Size in bytes of the array of + pre-initialization functions. */ +#define DT_LOOS 0x6000000d /* First OS-specific */ +#define DT_HIOS 0x6ffff000 /* Last OS-specific */ +#define DT_LOPROC 0x70000000 /* First processor-specific type. */ +#define DT_HIPROC 0x7fffffff /* Last processor-specific type. */ + +/* Values for DT_FLAGS */ +#define DF_ORIGIN 0x0001 /* Indicates that the object being loaded may + make reference to the $ORIGIN substitution + string */ +#define DF_SYMBOLIC 0x0002 /* Indicates "symbolic" linking. */ +#define DF_TEXTREL 0x0004 /* Indicates there may be relocations in + non-writable segments. */ +#define DF_BIND_NOW 0x0008 /* Indicates that the dynamic linker should + process all relocations for the object + containing this entry before transferring + control to the program. */ +#define DF_STATIC_TLS 0x0010 /* Indicates that the shared object or + executable contains code using a static + thread-local storage scheme. */ + +/* Values for n_type. Used in core files. */ +#define NT_PRSTATUS 1 /* Process status. */ +#define NT_FPREGSET 2 /* Floating point registers. */ +#define NT_PRPSINFO 3 /* Process state info. */ + +/* Symbol Binding - ELFNN_ST_BIND - st_info */ +#define STB_LOCAL 0 /* Local symbol */ +#define STB_GLOBAL 1 /* Global symbol */ +#define STB_WEAK 2 /* like global - lower precedence */ +#define STB_LOOS 10 /* Reserved range for operating system */ +#define STB_HIOS 12 /* specific semantics. */ +#define STB_LOPROC 13 /* reserved range for processor */ +#define STB_HIPROC 15 /* specific semantics. */ + +/* Symbol type - ELFNN_ST_TYPE - st_info */ +#define STT_NOTYPE 0 /* Unspecified type. */ +#define STT_OBJECT 1 /* Data object. */ +#define STT_FUNC 2 /* Function. */ +#define STT_SECTION 3 /* Section. */ +#define STT_FILE 4 /* Source file. */ +#define STT_COMMON 5 /* Uninitialized common block. */ +#define STT_TLS 6 /* TLS object. */ +#define STT_LOOS 10 /* Reserved range for operating system */ +#define STT_HIOS 12 /* specific semantics. */ +#define STT_LOPROC 13 /* reserved range for processor */ +#define STT_HIPROC 15 /* specific semantics. */ + +/* Symbol visibility - ELFNN_ST_VISIBILITY - st_other */ +#define STV_DEFAULT 0x0 /* Default visibility (see binding). */ +#define STV_INTERNAL 0x1 /* Special meaning in relocatable objects. */ +#define STV_HIDDEN 0x2 /* Not visible. */ +#define STV_PROTECTED 0x3 /* Visible but not preemptible. */ + +/* Special symbol table indexes. */ +#define STN_UNDEF 0 /* Undefined symbol index. */ + +#endif /* !_SYS_ELF_COMMON_H_ */ \ No newline at end of file diff --git a/rocclr/elf/utils/common/win32/sys/mman.h b/rocclr/elf/utils/common/win32/sys/mman.h new file mode 100644 index 0000000000..0c5d544237 --- /dev/null +++ b/rocclr/elf/utils/common/win32/sys/mman.h @@ -0,0 +1,8 @@ +#ifndef _MMAN_H_ +#define _MMAN_H_ +#if defined(WIN32) + +void *mmap(void*, size_t, int, int, int, unsigned); +int munmap(void*, size_t); +#endif +#endif // _MMAN_H_ diff --git a/rocclr/elf/utils/common/win32/sys/param.h b/rocclr/elf/utils/common/win32/sys/param.h new file mode 100644 index 0000000000..ec709fd31d --- /dev/null +++ b/rocclr/elf/utils/common/win32/sys/param.h @@ -0,0 +1,6 @@ +#ifndef _SYS_PARAM_H_ +#define _SYS_PARAM_H_ 1 + +#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) + +#endif \ No newline at end of file diff --git a/rocclr/elf/utils/common/win32/sys/queue.h b/rocclr/elf/utils/common/win32/sys/queue.h new file mode 100644 index 0000000000..1929311786 --- /dev/null +++ b/rocclr/elf/utils/common/win32/sys/queue.h @@ -0,0 +1,673 @@ +/* $NetBSD: queue.h,v 1.45.14.2 2009/06/05 16:23:34 snj Exp $ */ + +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)queue.h 8.5 (Berkeley) 8/20/94 + */ + +#ifndef _ELF_SYS_QUEUE_H_ +#define _ELF_SYS_QUEUE_H_ + +/* + * This file defines five types of data structures: singly-linked lists, + * lists, simple queues, tail queues, and circular queues. + * + * A singly-linked list is headed by a single forward pointer. The + * elements are singly linked for minimum space and pointer manipulation + * overhead at the expense of O(n) removal for arbitrary elements. New + * elements can be added to the list after an existing element or at the + * head of the list. Elements being removed from the head of the list + * should use the explicit macro for this purpose for optimum + * efficiency. A singly-linked list may only be traversed in the forward + * direction. Singly-linked lists are ideal for applications with large + * datasets and few or no removals or for implementing a LIFO queue. + * + * A list is headed by a single forward pointer (or an array of forward + * pointers for a hash table header). The elements are doubly linked + * so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before + * or after an existing element or at the head of the list. A list + * may only be traversed in the forward direction. + * + * A simple queue is headed by a pair of pointers, one the head of the + * list and the other to the tail of the list. The elements are singly + * linked to save space, so elements can only be removed from the + * head of the list. New elements can be added to the list after + * an existing element, at the head of the list, or at the end of the + * list. A simple queue may only be traversed in the forward direction. + * + * A tail queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before or + * after an existing element, at the head of the list, or at the end of + * the list. A tail queue may be traversed in either direction. + * + * A circle queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before or after + * an existing element, at the head of the list, or at the end of the list. + * A circle queue may be traversed in either direction, but has a more + * complex end of list detection. + * + * For details on the use of these macros, see the queue(3) manual page. + */ + +/* + * List definitions. + */ +#define LIST_HEAD(name, type) \ +struct name { \ + struct type *lh_first; /* first element */ \ +} + +#define LIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define LIST_ENTRY(type) \ +struct { \ + struct type *le_next; /* next element */ \ + struct type **le_prev; /* address of previous next element */ \ +} + +/* + * List functions. + */ +#if defined(_KERNEL) && defined(QUEUEDEBUG) +#define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field) \ + if ((head)->lh_first && \ + (head)->lh_first->field.le_prev != &(head)->lh_first) \ + panic("LIST_INSERT_HEAD %p %s:%d", (head), __FILE__, __LINE__); +#define QUEUEDEBUG_LIST_OP(elm, field) \ + if ((elm)->field.le_next && \ + (elm)->field.le_next->field.le_prev != \ + &(elm)->field.le_next) \ + panic("LIST_* forw %p %s:%d", (elm), __FILE__, __LINE__);\ + if (*(elm)->field.le_prev != (elm)) \ + panic("LIST_* back %p %s:%d", (elm), __FILE__, __LINE__); +#define QUEUEDEBUG_LIST_POSTREMOVE(elm, field) \ + (elm)->field.le_next = (void *)1L; \ + (elm)->field.le_prev = (void *)1L; +#else +#define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field) +#define QUEUEDEBUG_LIST_OP(elm, field) +#define QUEUEDEBUG_LIST_POSTREMOVE(elm, field) +#endif + +#define LIST_INIT(head) do { \ + (head)->lh_first = NULL; \ +} while (/*CONSTCOND*/0) + +#define LIST_INSERT_AFTER(listelm, elm, field) do { \ + QUEUEDEBUG_LIST_OP((listelm), field) \ + if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ + (listelm)->field.le_next->field.le_prev = \ + &(elm)->field.le_next; \ + (listelm)->field.le_next = (elm); \ + (elm)->field.le_prev = &(listelm)->field.le_next; \ +} while (/*CONSTCOND*/0) + +#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ + QUEUEDEBUG_LIST_OP((listelm), field) \ + (elm)->field.le_prev = (listelm)->field.le_prev; \ + (elm)->field.le_next = (listelm); \ + *(listelm)->field.le_prev = (elm); \ + (listelm)->field.le_prev = &(elm)->field.le_next; \ +} while (/*CONSTCOND*/0) + +#define LIST_INSERT_HEAD(head, elm, field) do { \ + QUEUEDEBUG_LIST_INSERT_HEAD((head), (elm), field) \ + if (((elm)->field.le_next = (head)->lh_first) != NULL) \ + (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ + (head)->lh_first = (elm); \ + (elm)->field.le_prev = &(head)->lh_first; \ +} while (/*CONSTCOND*/0) + +#define LIST_REMOVE(elm, field) do { \ + QUEUEDEBUG_LIST_OP((elm), field) \ + if ((elm)->field.le_next != NULL) \ + (elm)->field.le_next->field.le_prev = \ + (elm)->field.le_prev; \ + *(elm)->field.le_prev = (elm)->field.le_next; \ + QUEUEDEBUG_LIST_POSTREMOVE((elm), field) \ +} while (/*CONSTCOND*/0) + +#define LIST_FOREACH(var, head, field) \ + for ((var) = ((head)->lh_first); \ + (var); \ + (var) = ((var)->field.le_next)) + +/* + * List access methods. + */ +#define LIST_EMPTY(head) ((head)->lh_first == NULL) +#define LIST_FIRST(head) ((head)->lh_first) +#define LIST_NEXT(elm, field) ((elm)->field.le_next) + +/* + * Singly-linked List definitions. + */ +#define ELF_SLIST_HEAD(name, type) \ +struct name { \ + struct type *slh_first; /* first element */ \ +} + +#define ELF_SLIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define ELF_SLIST_ENTRY(type) \ +struct { \ + struct type *sle_next; /* next element */ \ +} + +/* + * Singly-linked List functions. + */ +#define ELF_SLIST_INIT(head) do { \ + (head)->slh_first = NULL; \ +} while (/*CONSTCOND*/0) + +#define ELF_SLIST_INSERT_AFTER(slistelm, elm, field) do { \ + (elm)->field.sle_next = (slistelm)->field.sle_next; \ + (slistelm)->field.sle_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define ELF_SLIST_INSERT_HEAD(head, elm, field) do { \ + (elm)->field.sle_next = (head)->slh_first; \ + (head)->slh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define ELF_SLIST_REMOVE_HEAD(head, field) do { \ + (head)->slh_first = (head)->slh_first->field.sle_next; \ +} while (/*CONSTCOND*/0) + +#define ELF_SLIST_REMOVE(head, elm, type, field) do { \ + if ((head)->slh_first == (elm)) { \ + ELF_SLIST_REMOVE_HEAD((head), field); \ + } \ + else { \ + struct type *curelm = (head)->slh_first; \ + while(curelm->field.sle_next != (elm)) \ + curelm = curelm->field.sle_next; \ + curelm->field.sle_next = \ + curelm->field.sle_next->field.sle_next; \ + } \ +} while (/*CONSTCOND*/0) + +#define ELF_SLIST_FOREACH(var, head, field) \ + for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next) + +/* + * Singly-linked List access methods. + */ +#define ELF_SLIST_EMPTY(head) ((head)->slh_first == NULL) +#define ELF_SLIST_FIRST(head) ((head)->slh_first) +#define ELF_SLIST_NEXT(elm, field) ((elm)->field.sle_next) + +/* + * Singly-linked Tail queue declarations. + */ +#define STAILQ_HEAD(name, type) \ +struct name { \ + struct type *stqh_first; /* first element */ \ + struct type **stqh_last; /* addr of last next element */ \ +} + +#define STAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).stqh_first } + +#define STAILQ_ENTRY(type) \ +struct { \ + struct type *stqe_next; /* next element */ \ +} + +/* + * Singly-linked Tail queue functions. + */ +#define STAILQ_INIT(head) do { \ + (head)->stqh_first = NULL; \ + (head)->stqh_last = &(head)->stqh_first; \ +} while (/*CONSTCOND*/0) + +#define STAILQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \ + (head)->stqh_last = &(elm)->field.stqe_next; \ + (head)->stqh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define STAILQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.stqe_next = NULL; \ + *(head)->stqh_last = (elm); \ + (head)->stqh_last = &(elm)->field.stqe_next; \ +} while (/*CONSTCOND*/0) + +#define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\ + (head)->stqh_last = &(elm)->field.stqe_next; \ + (listelm)->field.stqe_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define STAILQ_REMOVE_HEAD(head, field) do { \ + if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \ + (head)->stqh_last = &(head)->stqh_first; \ +} while (/*CONSTCOND*/0) + +#define STAILQ_REMOVE(head, elm, type, field) do { \ + if ((head)->stqh_first == (elm)) { \ + STAILQ_REMOVE_HEAD((head), field); \ + } else { \ + struct type *curelm = (head)->stqh_first; \ + while (curelm->field.stqe_next != (elm)) \ + curelm = curelm->field.stqe_next; \ + if ((curelm->field.stqe_next = \ + curelm->field.stqe_next->field.stqe_next) == NULL) \ + (head)->stqh_last = &(curelm)->field.stqe_next; \ + } \ +} while (/*CONSTCOND*/0) + +#define STAILQ_FOREACH(var, head, field) \ + for ((var) = ((head)->stqh_first); \ + (var); \ + (var) = ((var)->field.stqe_next)) + +/* + * Singly-linked Tail queue access methods. + */ +#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL) +#define STAILQ_FIRST(head) ((head)->stqh_first) +#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) + +/* + * Simple queue definitions. + */ +#define SIMPLEQ_HEAD(name, type) \ +struct name { \ + struct type *sqh_first; /* first element */ \ + struct type **sqh_last; /* addr of last next element */ \ +} + +#define SIMPLEQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).sqh_first } + +#define SIMPLEQ_ENTRY(type) \ +struct { \ + struct type *sqe_next; /* next element */ \ +} + +/* + * Simple queue functions. + */ +#define SIMPLEQ_INIT(head) do { \ + (head)->sqh_first = NULL; \ + (head)->sqh_last = &(head)->sqh_first; \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (head)->sqh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.sqe_next = NULL; \ + *(head)->sqh_last = (elm); \ + (head)->sqh_last = &(elm)->field.sqe_next; \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (listelm)->field.sqe_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_REMOVE_HEAD(head, field) do { \ + if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \ + (head)->sqh_last = &(head)->sqh_first; \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_REMOVE(head, elm, type, field) do { \ + if ((head)->sqh_first == (elm)) { \ + SIMPLEQ_REMOVE_HEAD((head), field); \ + } else { \ + struct type *curelm = (head)->sqh_first; \ + while (curelm->field.sqe_next != (elm)) \ + curelm = curelm->field.sqe_next; \ + if ((curelm->field.sqe_next = \ + curelm->field.sqe_next->field.sqe_next) == NULL) \ + (head)->sqh_last = &(curelm)->field.sqe_next; \ + } \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_FOREACH(var, head, field) \ + for ((var) = ((head)->sqh_first); \ + (var); \ + (var) = ((var)->field.sqe_next)) + +/* + * Simple queue access methods. + */ +#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL) +#define SIMPLEQ_FIRST(head) ((head)->sqh_first) +#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) + + +/* + * Tail queue definitions. + */ +#define _TAILQ_HEAD(name, type, qual) \ +struct name { \ + qual type *tqh_first; /* first element */ \ + qual type *qual *tqh_last; /* addr of last next element */ \ +} +#define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type,) + +#define TAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).tqh_first } + +#define _TAILQ_ENTRY(type, qual) \ +struct { \ + qual type *tqe_next; /* next element */ \ + qual type *qual *tqe_prev; /* address of previous next element */\ +} +#define TAILQ_ENTRY(type) _TAILQ_ENTRY(struct type,) + +/* + * Tail queue functions. + */ +#if defined(_KERNEL) && defined(QUEUEDEBUG) +#define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field) \ + if ((head)->tqh_first && \ + (head)->tqh_first->field.tqe_prev != &(head)->tqh_first) \ + panic("TAILQ_INSERT_HEAD %p %s:%d", (head), __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field) \ + if (*(head)->tqh_last != NULL) \ + panic("TAILQ_INSERT_TAIL %p %s:%d", (head), __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_OP(elm, field) \ + if ((elm)->field.tqe_next && \ + (elm)->field.tqe_next->field.tqe_prev != \ + &(elm)->field.tqe_next) \ + panic("TAILQ_* forw %p %s:%d", (elm), __FILE__, __LINE__);\ + if (*(elm)->field.tqe_prev != (elm)) \ + panic("TAILQ_* back %p %s:%d", (elm), __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field) \ + if ((elm)->field.tqe_next == NULL && \ + (head)->tqh_last != &(elm)->field.tqe_next) \ + panic("TAILQ_PREREMOVE head %p elm %p %s:%d", \ + (head), (elm), __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) \ + (elm)->field.tqe_next = (void *)1L; \ + (elm)->field.tqe_prev = (void *)1L; +#else +#define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field) +#define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field) +#define QUEUEDEBUG_TAILQ_OP(elm, field) +#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field) +#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) +#endif + +#define TAILQ_INIT(head) do { \ + (head)->tqh_first = NULL; \ + (head)->tqh_last = &(head)->tqh_first; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_INSERT_HEAD(head, elm, field) do { \ + QUEUEDEBUG_TAILQ_INSERT_HEAD((head), (elm), field) \ + if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ + (head)->tqh_first->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (head)->tqh_first = (elm); \ + (elm)->field.tqe_prev = &(head)->tqh_first; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_INSERT_TAIL(head, elm, field) do { \ + QUEUEDEBUG_TAILQ_INSERT_TAIL((head), (elm), field) \ + (elm)->field.tqe_next = NULL; \ + (elm)->field.tqe_prev = (head)->tqh_last; \ + *(head)->tqh_last = (elm); \ + (head)->tqh_last = &(elm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ + QUEUEDEBUG_TAILQ_OP((listelm), field) \ + if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ + (elm)->field.tqe_next->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (listelm)->field.tqe_next = (elm); \ + (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ + QUEUEDEBUG_TAILQ_OP((listelm), field) \ + (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ + (elm)->field.tqe_next = (listelm); \ + *(listelm)->field.tqe_prev = (elm); \ + (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_REMOVE(head, elm, field) do { \ + QUEUEDEBUG_TAILQ_PREREMOVE((head), (elm), field) \ + QUEUEDEBUG_TAILQ_OP((elm), field) \ + if (((elm)->field.tqe_next) != NULL) \ + (elm)->field.tqe_next->field.tqe_prev = \ + (elm)->field.tqe_prev; \ + else \ + (head)->tqh_last = (elm)->field.tqe_prev; \ + *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ + QUEUEDEBUG_TAILQ_POSTREMOVE((elm), field); \ +} while (/*CONSTCOND*/0) + +#define TAILQ_FOREACH(var, head, field) \ + for ((var) = ((head)->tqh_first); \ + (var); \ + (var) = ((var)->field.tqe_next)) + +#define TAILQ_FOREACH_SAFE(var, head, field, next) \ + for ((var) = ((head)->tqh_first); \ + (var) != NULL && ((next) = TAILQ_NEXT(var, field), 1); \ + (var) = (next)) + +#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ + for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ + (var); \ + (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last))) + +/* + * Tail queue access methods. + */ +#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) +#define TAILQ_FIRST(head) ((head)->tqh_first) +#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) + +#define TAILQ_LAST(head, headname) \ + (*(((struct headname *)((head)->tqh_last))->tqh_last)) +#define TAILQ_PREV(elm, headname, field) \ + (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) + + +/* + * Circular queue definitions. + */ +#if defined(_KERNEL) && defined(QUEUEDEBUG) +#define QUEUEDEBUG_CIRCLEQ_HEAD(head, field) \ + if ((head)->cqh_first != (void *)(head) && \ + (head)->cqh_first->field.cqe_prev != (void *)(head)) \ + panic("CIRCLEQ head forw %p %s:%d", (head), \ + __FILE__, __LINE__); \ + if ((head)->cqh_last != (void *)(head) && \ + (head)->cqh_last->field.cqe_next != (void *)(head)) \ + panic("CIRCLEQ head back %p %s:%d", (head), \ + __FILE__, __LINE__); +#define QUEUEDEBUG_CIRCLEQ_ELM(head, elm, field) \ + if ((elm)->field.cqe_next == (void *)(head)) { \ + if ((head)->cqh_last != (elm)) \ + panic("CIRCLEQ elm last %p %s:%d", (elm), \ + __FILE__, __LINE__); \ + } else { \ + if ((elm)->field.cqe_next->field.cqe_prev != (elm)) \ + panic("CIRCLEQ elm forw %p %s:%d", (elm), \ + __FILE__, __LINE__); \ + } \ + if ((elm)->field.cqe_prev == (void *)(head)) { \ + if ((head)->cqh_first != (elm)) \ + panic("CIRCLEQ elm first %p %s:%d", (elm), \ + __FILE__, __LINE__); \ + } else { \ + if ((elm)->field.cqe_prev->field.cqe_next != (elm)) \ + panic("CIRCLEQ elm prev %p %s:%d", (elm), \ + __FILE__, __LINE__); \ + } +#define QUEUEDEBUG_CIRCLEQ_POSTREMOVE(elm, field) \ + (elm)->field.cqe_next = (void *)1L; \ + (elm)->field.cqe_prev = (void *)1L; +#else +#define QUEUEDEBUG_CIRCLEQ_HEAD(head, field) +#define QUEUEDEBUG_CIRCLEQ_ELM(head, elm, field) +#define QUEUEDEBUG_CIRCLEQ_POSTREMOVE(elm, field) +#endif + +#define CIRCLEQ_HEAD(name, type) \ +struct name { \ + struct type *cqh_first; /* first element */ \ + struct type *cqh_last; /* last element */ \ +} + +#define CIRCLEQ_HEAD_INITIALIZER(head) \ + { (void *)&head, (void *)&head } + +#define CIRCLEQ_ENTRY(type) \ +struct { \ + struct type *cqe_next; /* next element */ \ + struct type *cqe_prev; /* previous element */ \ +} + +/* + * Circular queue functions. + */ +#define CIRCLEQ_INIT(head) do { \ + (head)->cqh_first = (void *)(head); \ + (head)->cqh_last = (void *)(head); \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ + QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ + QUEUEDEBUG_CIRCLEQ_ELM((head), (listelm), field) \ + (elm)->field.cqe_next = (listelm)->field.cqe_next; \ + (elm)->field.cqe_prev = (listelm); \ + if ((listelm)->field.cqe_next == (void *)(head)) \ + (head)->cqh_last = (elm); \ + else \ + (listelm)->field.cqe_next->field.cqe_prev = (elm); \ + (listelm)->field.cqe_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \ + QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ + QUEUEDEBUG_CIRCLEQ_ELM((head), (listelm), field) \ + (elm)->field.cqe_next = (listelm); \ + (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \ + if ((listelm)->field.cqe_prev == (void *)(head)) \ + (head)->cqh_first = (elm); \ + else \ + (listelm)->field.cqe_prev->field.cqe_next = (elm); \ + (listelm)->field.cqe_prev = (elm); \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \ + QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ + (elm)->field.cqe_next = (head)->cqh_first; \ + (elm)->field.cqe_prev = (void *)(head); \ + if ((head)->cqh_last == (void *)(head)) \ + (head)->cqh_last = (elm); \ + else \ + (head)->cqh_first->field.cqe_prev = (elm); \ + (head)->cqh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \ + QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ + (elm)->field.cqe_next = (void *)(head); \ + (elm)->field.cqe_prev = (head)->cqh_last; \ + if ((head)->cqh_first == (void *)(head)) \ + (head)->cqh_first = (elm); \ + else \ + (head)->cqh_last->field.cqe_next = (elm); \ + (head)->cqh_last = (elm); \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_REMOVE(head, elm, field) do { \ + QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ + QUEUEDEBUG_CIRCLEQ_ELM((head), (elm), field) \ + if ((elm)->field.cqe_next == (void *)(head)) \ + (head)->cqh_last = (elm)->field.cqe_prev; \ + else \ + (elm)->field.cqe_next->field.cqe_prev = \ + (elm)->field.cqe_prev; \ + if ((elm)->field.cqe_prev == (void *)(head)) \ + (head)->cqh_first = (elm)->field.cqe_next; \ + else \ + (elm)->field.cqe_prev->field.cqe_next = \ + (elm)->field.cqe_next; \ + QUEUEDEBUG_CIRCLEQ_POSTREMOVE((elm), field) \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_FOREACH(var, head, field) \ + for ((var) = ((head)->cqh_first); \ + (var) != (const void *)(head); \ + (var) = ((var)->field.cqe_next)) + +#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \ + for ((var) = ((head)->cqh_last); \ + (var) != (const void *)(head); \ + (var) = ((var)->field.cqe_prev)) + +/* + * Circular queue access methods. + */ +#define CIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head)) +#define CIRCLEQ_FIRST(head) ((head)->cqh_first) +#define CIRCLEQ_LAST(head) ((head)->cqh_last) +#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next) +#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev) + +#define CIRCLEQ_LOOP_NEXT(head, elm, field) \ + (((elm)->field.cqe_next == (void *)(head)) \ + ? ((head)->cqh_first) \ + : (elm->field.cqe_next)) +#define CIRCLEQ_LOOP_PREV(head, elm, field) \ + (((elm)->field.cqe_prev == (void *)(head)) \ + ? ((head)->cqh_last) \ + : (elm->field.cqe_prev)) + +#endif /* !_ELF_SYS_QUEUE_H_ */ + diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/CMakeLists.txt b/rocclr/elf/utils/libelf/CMakeLists.txt similarity index 73% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/CMakeLists.txt rename to rocclr/elf/utils/libelf/CMakeLists.txt index d5460180e6..040b2520cc 100644 --- a/rocclr/compiler/lib/loaders/elf/utils/libelf/CMakeLists.txt +++ b/rocclr/elf/utils/libelf/CMakeLists.txt @@ -11,6 +11,8 @@ file(GLOB sources ${CMAKE_CURRENT_SOURCE_DIR}/*.c ${CMAKE_CURRENT_SOURCE_DIR}/*.h ) -add_library(oclelf STATIC ${sources}) +add_library(oclelf_obj OBJECT ${sources}) +add_library(oclelf STATIC $) +set_target_properties(oclelf_obj PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(oclelf PROPERTIES POSITION_INDEPENDENT_CODE ON) diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/README b/rocclr/elf/utils/libelf/README similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/README rename to rocclr/elf/utils/libelf/README diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/README.build b/rocclr/elf/utils/libelf/README.build similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/README.build rename to rocclr/elf/utils/libelf/README.build diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/Version.map b/rocclr/elf/utils/libelf/Version.map similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/Version.map rename to rocclr/elf/utils/libelf/Version.map diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/_libelf.h b/rocclr/elf/utils/libelf/_libelf.h similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/_libelf.h rename to rocclr/elf/utils/libelf/_libelf.h diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/_libelf_ar.h b/rocclr/elf/utils/libelf/_libelf_ar.h similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/_libelf_ar.h rename to rocclr/elf/utils/libelf/_libelf_ar.h diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/_libelf_config.h b/rocclr/elf/utils/libelf/_libelf_config.h similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/_libelf_config.h rename to rocclr/elf/utils/libelf/_libelf_config.h diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf.c b/rocclr/elf/utils/libelf/elf.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf.c rename to rocclr/elf/utils/libelf/elf.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_begin.c b/rocclr/elf/utils/libelf/elf_begin.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_begin.c rename to rocclr/elf/utils/libelf/elf_begin.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_cntl.c b/rocclr/elf/utils/libelf/elf_cntl.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_cntl.c rename to rocclr/elf/utils/libelf/elf_cntl.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_data.c b/rocclr/elf/utils/libelf/elf_data.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_data.c rename to rocclr/elf/utils/libelf/elf_data.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_end.c b/rocclr/elf/utils/libelf/elf_end.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_end.c rename to rocclr/elf/utils/libelf/elf_end.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c b/rocclr/elf/utils/libelf/elf_errmsg.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_errmsg.c rename to rocclr/elf/utils/libelf/elf_errmsg.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_errno.c b/rocclr/elf/utils/libelf/elf_errno.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_errno.c rename to rocclr/elf/utils/libelf/elf_errno.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_fill.c b/rocclr/elf/utils/libelf/elf_fill.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_fill.c rename to rocclr/elf/utils/libelf/elf_fill.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_flag.c b/rocclr/elf/utils/libelf/elf_flag.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_flag.c rename to rocclr/elf/utils/libelf/elf_flag.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c b/rocclr/elf/utils/libelf/elf_getarhdr.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_getarhdr.c rename to rocclr/elf/utils/libelf/elf_getarhdr.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c b/rocclr/elf/utils/libelf/elf_getarsym.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_getarsym.c rename to rocclr/elf/utils/libelf/elf_getarsym.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_getbase.c b/rocclr/elf/utils/libelf/elf_getbase.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_getbase.c rename to rocclr/elf/utils/libelf/elf_getbase.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_getident.c b/rocclr/elf/utils/libelf/elf_getident.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_getident.c rename to rocclr/elf/utils/libelf/elf_getident.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_hash.c b/rocclr/elf/utils/libelf/elf_hash.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_hash.c rename to rocclr/elf/utils/libelf/elf_hash.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_kind.c b/rocclr/elf/utils/libelf/elf_kind.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_kind.c rename to rocclr/elf/utils/libelf/elf_kind.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_memory.c b/rocclr/elf/utils/libelf/elf_memory.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_memory.c rename to rocclr/elf/utils/libelf/elf_memory.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_next.c b/rocclr/elf/utils/libelf/elf_next.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_next.c rename to rocclr/elf/utils/libelf/elf_next.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_phnum.c b/rocclr/elf/utils/libelf/elf_phnum.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_phnum.c rename to rocclr/elf/utils/libelf/elf_phnum.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_rand.c b/rocclr/elf/utils/libelf/elf_rand.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_rand.c rename to rocclr/elf/utils/libelf/elf_rand.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c b/rocclr/elf/utils/libelf/elf_rawfile.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_rawfile.c rename to rocclr/elf/utils/libelf/elf_rawfile.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_scn.c b/rocclr/elf/utils/libelf/elf_scn.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_scn.c rename to rocclr/elf/utils/libelf/elf_scn.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_shnum.c b/rocclr/elf/utils/libelf/elf_shnum.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_shnum.c rename to rocclr/elf/utils/libelf/elf_shnum.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c b/rocclr/elf/utils/libelf/elf_shstrndx.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_shstrndx.c rename to rocclr/elf/utils/libelf/elf_shstrndx.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_strptr.c b/rocclr/elf/utils/libelf/elf_strptr.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_strptr.c rename to rocclr/elf/utils/libelf/elf_strptr.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_update.c b/rocclr/elf/utils/libelf/elf_update.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_update.c rename to rocclr/elf/utils/libelf/elf_update.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/elf_version.c b/rocclr/elf/utils/libelf/elf_version.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/elf_version.c rename to rocclr/elf/utils/libelf/elf_version.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/gelf.h b/rocclr/elf/utils/libelf/gelf.h similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/gelf.h rename to rocclr/elf/utils/libelf/gelf.h diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_cap.c b/rocclr/elf/utils/libelf/gelf_cap.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_cap.c rename to rocclr/elf/utils/libelf/gelf_cap.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c b/rocclr/elf/utils/libelf/gelf_checksum.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_checksum.c rename to rocclr/elf/utils/libelf/gelf_checksum.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c b/rocclr/elf/utils/libelf/gelf_dyn.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_dyn.c rename to rocclr/elf/utils/libelf/gelf_dyn.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c b/rocclr/elf/utils/libelf/gelf_ehdr.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_ehdr.c rename to rocclr/elf/utils/libelf/gelf_ehdr.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c b/rocclr/elf/utils/libelf/gelf_fsize.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_fsize.c rename to rocclr/elf/utils/libelf/gelf_fsize.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c b/rocclr/elf/utils/libelf/gelf_getclass.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_getclass.c rename to rocclr/elf/utils/libelf/gelf_getclass.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_move.c b/rocclr/elf/utils/libelf/gelf_move.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_move.c rename to rocclr/elf/utils/libelf/gelf_move.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c b/rocclr/elf/utils/libelf/gelf_phdr.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_phdr.c rename to rocclr/elf/utils/libelf/gelf_phdr.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_rel.c b/rocclr/elf/utils/libelf/gelf_rel.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_rel.c rename to rocclr/elf/utils/libelf/gelf_rel.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_rela.c b/rocclr/elf/utils/libelf/gelf_rela.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_rela.c rename to rocclr/elf/utils/libelf/gelf_rela.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c b/rocclr/elf/utils/libelf/gelf_shdr.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_shdr.c rename to rocclr/elf/utils/libelf/gelf_shdr.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_sym.c b/rocclr/elf/utils/libelf/gelf_sym.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_sym.c rename to rocclr/elf/utils/libelf/gelf_sym.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c b/rocclr/elf/utils/libelf/gelf_syminfo.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_syminfo.c rename to rocclr/elf/utils/libelf/gelf_syminfo.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c b/rocclr/elf/utils/libelf/gelf_symshndx.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_symshndx.c rename to rocclr/elf/utils/libelf/gelf_symshndx.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c b/rocclr/elf/utils/libelf/gelf_xlate.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/gelf_xlate.c rename to rocclr/elf/utils/libelf/gelf_xlate.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/libelf.h b/rocclr/elf/utils/libelf/libelf.h similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/libelf.h rename to rocclr/elf/utils/libelf/libelf.h diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_align.c b/rocclr/elf/utils/libelf/libelf_align.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_align.c rename to rocclr/elf/utils/libelf/libelf_align.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c b/rocclr/elf/utils/libelf/libelf_allocate.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_allocate.c rename to rocclr/elf/utils/libelf/libelf_allocate.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_ar.c b/rocclr/elf/utils/libelf/libelf_ar.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_ar.c rename to rocclr/elf/utils/libelf/libelf_ar.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c b/rocclr/elf/utils/libelf/libelf_ar_util.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_ar_util.c rename to rocclr/elf/utils/libelf/libelf_ar_util.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c b/rocclr/elf/utils/libelf/libelf_checksum.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_checksum.c rename to rocclr/elf/utils/libelf/libelf_checksum.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_convert.c b/rocclr/elf/utils/libelf/libelf_convert.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_convert.c rename to rocclr/elf/utils/libelf/libelf_convert.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_data.c b/rocclr/elf/utils/libelf/libelf_data.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_data.c rename to rocclr/elf/utils/libelf/libelf_data.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c b/rocclr/elf/utils/libelf/libelf_ehdr.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_ehdr.c rename to rocclr/elf/utils/libelf/libelf_ehdr.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_extended.c b/rocclr/elf/utils/libelf/libelf_extended.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_extended.c rename to rocclr/elf/utils/libelf/libelf_extended.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_fsize.c b/rocclr/elf/utils/libelf/libelf_fsize.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_fsize.c rename to rocclr/elf/utils/libelf/libelf_fsize.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_msize.c b/rocclr/elf/utils/libelf/libelf_msize.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_msize.c rename to rocclr/elf/utils/libelf/libelf_msize.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c b/rocclr/elf/utils/libelf/libelf_phdr.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_phdr.c rename to rocclr/elf/utils/libelf/libelf_phdr.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c b/rocclr/elf/utils/libelf/libelf_shdr.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_shdr.c rename to rocclr/elf/utils/libelf/libelf_shdr.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c b/rocclr/elf/utils/libelf/libelf_xlate.c similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/libelf_xlate.c rename to rocclr/elf/utils/libelf/libelf_xlate.c diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/memfile.cpp b/rocclr/elf/utils/libelf/memfile.cpp similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/memfile.cpp rename to rocclr/elf/utils/libelf/memfile.cpp diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/memfile.h b/rocclr/elf/utils/libelf/memfile.h similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/memfile.h rename to rocclr/elf/utils/libelf/memfile.h diff --git a/rocclr/compiler/lib/loaders/elf/utils/libelf/roundup.h b/rocclr/elf/utils/libelf/roundup.h similarity index 100% rename from rocclr/compiler/lib/loaders/elf/utils/libelf/roundup.h rename to rocclr/elf/utils/libelf/roundup.h diff --git a/rocclr/runtime/include/vdi_agent_amd.h b/rocclr/include/vdi_agent_amd.h similarity index 100% rename from rocclr/runtime/include/vdi_agent_amd.h rename to rocclr/include/vdi_agent_amd.h diff --git a/rocclr/runtime/include/vdi_common.hpp b/rocclr/include/vdi_common.hpp similarity index 100% rename from rocclr/runtime/include/vdi_common.hpp rename to rocclr/include/vdi_common.hpp diff --git a/rocclr/runtime/os/alloc.cpp b/rocclr/os/alloc.cpp similarity index 100% rename from rocclr/runtime/os/alloc.cpp rename to rocclr/os/alloc.cpp diff --git a/rocclr/runtime/os/alloc.hpp b/rocclr/os/alloc.hpp similarity index 100% rename from rocclr/runtime/os/alloc.hpp rename to rocclr/os/alloc.hpp diff --git a/rocclr/runtime/os/os.cpp b/rocclr/os/os.cpp similarity index 100% rename from rocclr/runtime/os/os.cpp rename to rocclr/os/os.cpp diff --git a/rocclr/runtime/os/os.hpp b/rocclr/os/os.hpp similarity index 100% rename from rocclr/runtime/os/os.hpp rename to rocclr/os/os.hpp diff --git a/rocclr/runtime/os/os_posix.cpp b/rocclr/os/os_posix.cpp similarity index 100% rename from rocclr/runtime/os/os_posix.cpp rename to rocclr/os/os_posix.cpp diff --git a/rocclr/runtime/os/os_win32.cpp b/rocclr/os/os_win32.cpp similarity index 100% rename from rocclr/runtime/os/os_win32.cpp rename to rocclr/os/os_win32.cpp diff --git a/rocclr/runtime/os/setjmp.S b/rocclr/os/setjmp.S similarity index 100% rename from rocclr/runtime/os/setjmp.S rename to rocclr/os/setjmp.S diff --git a/rocclr/runtime/os/setjmp.asm b/rocclr/os/setjmp.asm similarity index 100% rename from rocclr/runtime/os/setjmp.asm rename to rocclr/os/setjmp.asm diff --git a/rocclr/runtime/platform/activity.cpp b/rocclr/platform/activity.cpp similarity index 100% rename from rocclr/runtime/platform/activity.cpp rename to rocclr/platform/activity.cpp diff --git a/rocclr/runtime/platform/activity.hpp b/rocclr/platform/activity.hpp similarity index 100% rename from rocclr/runtime/platform/activity.hpp rename to rocclr/platform/activity.hpp diff --git a/rocclr/runtime/platform/agent.cpp b/rocclr/platform/agent.cpp similarity index 100% rename from rocclr/runtime/platform/agent.cpp rename to rocclr/platform/agent.cpp diff --git a/rocclr/runtime/platform/agent.hpp b/rocclr/platform/agent.hpp similarity index 100% rename from rocclr/runtime/platform/agent.hpp rename to rocclr/platform/agent.hpp diff --git a/rocclr/runtime/platform/command.cpp b/rocclr/platform/command.cpp similarity index 100% rename from rocclr/runtime/platform/command.cpp rename to rocclr/platform/command.cpp diff --git a/rocclr/runtime/platform/command.hpp b/rocclr/platform/command.hpp similarity index 100% rename from rocclr/runtime/platform/command.hpp rename to rocclr/platform/command.hpp diff --git a/rocclr/runtime/platform/commandqueue.cpp b/rocclr/platform/commandqueue.cpp similarity index 100% rename from rocclr/runtime/platform/commandqueue.cpp rename to rocclr/platform/commandqueue.cpp diff --git a/rocclr/runtime/platform/commandqueue.hpp b/rocclr/platform/commandqueue.hpp similarity index 100% rename from rocclr/runtime/platform/commandqueue.hpp rename to rocclr/platform/commandqueue.hpp diff --git a/rocclr/runtime/platform/context.cpp b/rocclr/platform/context.cpp similarity index 100% rename from rocclr/runtime/platform/context.cpp rename to rocclr/platform/context.cpp diff --git a/rocclr/runtime/platform/context.hpp b/rocclr/platform/context.hpp similarity index 100% rename from rocclr/runtime/platform/context.hpp rename to rocclr/platform/context.hpp diff --git a/rocclr/runtime/platform/counter.hpp b/rocclr/platform/counter.hpp similarity index 100% rename from rocclr/runtime/platform/counter.hpp rename to rocclr/platform/counter.hpp diff --git a/rocclr/runtime/platform/interop.hpp b/rocclr/platform/interop.hpp similarity index 100% rename from rocclr/runtime/platform/interop.hpp rename to rocclr/platform/interop.hpp diff --git a/rocclr/runtime/platform/kernel.cpp b/rocclr/platform/kernel.cpp similarity index 100% rename from rocclr/runtime/platform/kernel.cpp rename to rocclr/platform/kernel.cpp diff --git a/rocclr/runtime/platform/kernel.hpp b/rocclr/platform/kernel.hpp similarity index 100% rename from rocclr/runtime/platform/kernel.hpp rename to rocclr/platform/kernel.hpp diff --git a/rocclr/runtime/platform/memory.cpp b/rocclr/platform/memory.cpp similarity index 100% rename from rocclr/runtime/platform/memory.cpp rename to rocclr/platform/memory.cpp diff --git a/rocclr/runtime/platform/memory.hpp b/rocclr/platform/memory.hpp similarity index 100% rename from rocclr/runtime/platform/memory.hpp rename to rocclr/platform/memory.hpp diff --git a/rocclr/runtime/platform/ndrange.cpp b/rocclr/platform/ndrange.cpp similarity index 100% rename from rocclr/runtime/platform/ndrange.cpp rename to rocclr/platform/ndrange.cpp diff --git a/rocclr/runtime/platform/ndrange.hpp b/rocclr/platform/ndrange.hpp similarity index 100% rename from rocclr/runtime/platform/ndrange.hpp rename to rocclr/platform/ndrange.hpp diff --git a/rocclr/runtime/platform/object.cpp b/rocclr/platform/object.cpp similarity index 100% rename from rocclr/runtime/platform/object.cpp rename to rocclr/platform/object.cpp diff --git a/rocclr/runtime/platform/object.hpp b/rocclr/platform/object.hpp similarity index 100% rename from rocclr/runtime/platform/object.hpp rename to rocclr/platform/object.hpp diff --git a/rocclr/runtime/platform/perfctr.hpp b/rocclr/platform/perfctr.hpp similarity index 100% rename from rocclr/runtime/platform/perfctr.hpp rename to rocclr/platform/perfctr.hpp diff --git a/rocclr/runtime/platform/prof_protocol.h b/rocclr/platform/prof_protocol.h similarity index 100% rename from rocclr/runtime/platform/prof_protocol.h rename to rocclr/platform/prof_protocol.h diff --git a/rocclr/runtime/platform/program.cpp b/rocclr/platform/program.cpp similarity index 100% rename from rocclr/runtime/platform/program.cpp rename to rocclr/platform/program.cpp diff --git a/rocclr/runtime/platform/program.hpp b/rocclr/platform/program.hpp similarity index 100% rename from rocclr/runtime/platform/program.hpp rename to rocclr/platform/program.hpp diff --git a/rocclr/runtime/platform/runtime.cpp b/rocclr/platform/runtime.cpp similarity index 100% rename from rocclr/runtime/platform/runtime.cpp rename to rocclr/platform/runtime.cpp diff --git a/rocclr/runtime/platform/runtime.hpp b/rocclr/platform/runtime.hpp similarity index 100% rename from rocclr/runtime/platform/runtime.hpp rename to rocclr/platform/runtime.hpp diff --git a/rocclr/runtime/platform/sampler.hpp b/rocclr/platform/sampler.hpp similarity index 100% rename from rocclr/runtime/platform/sampler.hpp rename to rocclr/platform/sampler.hpp diff --git a/rocclr/runtime/platform/threadtrace.hpp b/rocclr/platform/threadtrace.hpp similarity index 100% rename from rocclr/runtime/platform/threadtrace.hpp rename to rocclr/platform/threadtrace.hpp diff --git a/rocclr/runtime/CMakeLists.txt b/rocclr/runtime/CMakeLists.txt deleted file mode 100644 index 2edd70fbab..0000000000 --- a/rocclr/runtime/CMakeLists.txt +++ /dev/null @@ -1,91 +0,0 @@ -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - -add_definitions(-DLINUX -D__x86_64__ -D__AMD64__ -DUNIX_OS -DqLittleEndian -DOPENCL_MAJOR=2 -DOPENCL_MINOR=1 -DWITH_AQL -DWITH_ONLINE_COMPILER -DATI_OS_LINUX -DATI_ARCH_X86 -DLITTLEENDIAN_CPU -DATI_BITS_64 -DATI_COMP_GCC -DWITH_HSA_DEVICE -DWITH_TARGET_AMDGCN -DOPENCL_EXPORTS -DCL_USE_DEPRECATED_OPENCL_1_0_APIS -DCL_USE_DEPRECATED_OPENCL_1_1_APIS -DCL_USE_DEPRECATED_OPENCL_1_2_APIS -DCL_USE_DEPRECATED_OPENCL_2_0_APIS -DVEGA10_ONLY=false -DWITH_LIGHTNING_COMPILER) -add_definitions(-DOPENCL_C_MAJOR=2 -DOPENCL_C_MINOR=0) - -if(CMAKE_BUILD_TYPE MATCHES "^Debug$") - add_definitions(-DDEBUG) -endif() - -include_directories(${ROCR_INCLUDES}) -if (DEFINED LLVM_INCLUDES AND NOT ${LLVM_INCLUDES} STREQUAL "") - include_directories(${LLVM_INCLUDES}) -endif() # if (DEFINED LLVM_INCLUDES AND NOT ${LLVM_INCLUDES} STREQUAL "") - -include_directories(${CMAKE_SOURCE_DIR}/runtime) -include_directories(${CMAKE_SOURCE_DIR}/api/opencl) -include_directories(${CMAKE_SOURCE_DIR}/api/opencl/khronos) -include_directories(${CMAKE_SOURCE_DIR}/api/opencl/khronos/headers) -include_directories(${CMAKE_SOURCE_DIR}/api/opencl/khronos/headers/opencl2.2) - -# FIXME: Remove following if block after enabling COMGR by default -if (${USE_COMGR_LIBRARY} STREQUAL "no") - include_directories(${CMAKE_SOURCE_DIR}/compiler/llvm/include) -endif() # if (${USE_COMGR_LIBRARY} STREQUAL "no") - -include_directories(${CMAKE_SOURCE_DIR}/compiler/driver/src) -include_directories(${CMAKE_SOURCE_DIR}/compiler/lib) -include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/include) -include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/backends/common) -include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/loaders) -include_directories(${CMAKE_SOURCE_DIR}/compiler/tools) -include_directories(${CMAKE_BINARY_DIR}/runtime/device/rocm) - -add_definitions(-DBSD_LIBELF) -include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/loaders/elf/utils/common) -include_directories(${CMAKE_SOURCE_DIR}/compiler/lib/loaders/elf/utils/libelf) - -add_subdirectory(device/rocm) - -if(${USE_COMGR_LIBRARY} MATCHES "yes") - add_definitions(-DUSE_COMGR_LIBRARY -DCOMGR_DYN_DLL) - find_package(amd_comgr REQUIRED CONFIG) - include_directories("$") - set(COMGR_CPP device/comgrctx.cpp) -endif() - -add_library(oclruntime OBJECT - thread/thread.cpp - thread/monitor.cpp - thread/semaphore.cpp - utils/flags.cpp - utils/debug.cpp - device/appprofile.cpp - device/device.cpp - device/hwdebug.cpp - device/blitcl.cpp - device/blit.cpp - device/devkernel.cpp - device/devwavelimiter.cpp - device/devprogram.cpp - platform/activity.cpp - platform/kernel.cpp - platform/context.cpp - platform/command.cpp - platform/ndrange.cpp - platform/runtime.cpp - platform/object.cpp - platform/memory.cpp - platform/program.cpp - platform/commandqueue.cpp - platform/agent.cpp - os/os_win32.cpp - os/alloc.cpp - os/os.cpp - os/os_posix.cpp - ${CMAKE_SOURCE_DIR}/compiler/lib/utils/options.cpp - ${CMAKE_SOURCE_DIR}/compiler/lib/loaders/elf/elf.cpp - ${CMAKE_SOURCE_DIR}/compiler/lib/loaders/elf/elf_utils.cpp - ${CMAKE_SOURCE_DIR}/compiler/tools/caching/cache.cpp - ${COMGR_CPP} -) -set_target_properties(oclruntime PROPERTIES POSITION_INDEPENDENT_CODE ON) - -set(AMDGCN_DEP_LIST) -if(AMDGCN_TARGETS_LIB_DEPS) - set(${AMDGCN_TARGETS_LIB_DEPS} ${AMDGCN_DEP_LIST} PARENT_SCOPE) -endif() - -foreach(AMDGCN_DEP_TARGET ${AMDGCN_DEP_TARGETS}) - add_dependencies(oclruntime ${AMDGCN_DEP_TARGET}) -endforeach() diff --git a/rocclr/runtime/thread/atomic.hpp b/rocclr/thread/atomic.hpp similarity index 100% rename from rocclr/runtime/thread/atomic.hpp rename to rocclr/thread/atomic.hpp diff --git a/rocclr/runtime/thread/monitor.cpp b/rocclr/thread/monitor.cpp similarity index 100% rename from rocclr/runtime/thread/monitor.cpp rename to rocclr/thread/monitor.cpp diff --git a/rocclr/runtime/thread/monitor.hpp b/rocclr/thread/monitor.hpp similarity index 100% rename from rocclr/runtime/thread/monitor.hpp rename to rocclr/thread/monitor.hpp diff --git a/rocclr/runtime/thread/semaphore.cpp b/rocclr/thread/semaphore.cpp similarity index 100% rename from rocclr/runtime/thread/semaphore.cpp rename to rocclr/thread/semaphore.cpp diff --git a/rocclr/runtime/thread/semaphore.hpp b/rocclr/thread/semaphore.hpp similarity index 100% rename from rocclr/runtime/thread/semaphore.hpp rename to rocclr/thread/semaphore.hpp diff --git a/rocclr/runtime/thread/thread.cpp b/rocclr/thread/thread.cpp similarity index 100% rename from rocclr/runtime/thread/thread.cpp rename to rocclr/thread/thread.cpp diff --git a/rocclr/runtime/thread/thread.hpp b/rocclr/thread/thread.hpp similarity index 100% rename from rocclr/runtime/thread/thread.hpp rename to rocclr/thread/thread.hpp diff --git a/rocclr/runtime/top.hpp b/rocclr/top.hpp similarity index 100% rename from rocclr/runtime/top.hpp rename to rocclr/top.hpp diff --git a/rocclr/runtime/utils/concurrent.hpp b/rocclr/utils/concurrent.hpp similarity index 100% rename from rocclr/runtime/utils/concurrent.hpp rename to rocclr/utils/concurrent.hpp diff --git a/rocclr/runtime/utils/debug.cpp b/rocclr/utils/debug.cpp similarity index 100% rename from rocclr/runtime/utils/debug.cpp rename to rocclr/utils/debug.cpp diff --git a/rocclr/runtime/utils/debug.hpp b/rocclr/utils/debug.hpp similarity index 100% rename from rocclr/runtime/utils/debug.hpp rename to rocclr/utils/debug.hpp diff --git a/rocclr/runtime/utils/flags.cpp b/rocclr/utils/flags.cpp similarity index 100% rename from rocclr/runtime/utils/flags.cpp rename to rocclr/utils/flags.cpp diff --git a/rocclr/runtime/utils/flags.hpp b/rocclr/utils/flags.hpp similarity index 100% rename from rocclr/runtime/utils/flags.hpp rename to rocclr/utils/flags.hpp diff --git a/rocclr/runtime/utils/macros.hpp b/rocclr/utils/macros.hpp similarity index 100% rename from rocclr/runtime/utils/macros.hpp rename to rocclr/utils/macros.hpp diff --git a/rocclr/runtime/utils/util.hpp b/rocclr/utils/util.hpp similarity index 100% rename from rocclr/runtime/utils/util.hpp rename to rocclr/utils/util.hpp diff --git a/rocclr/runtime/utils/versions.hpp b/rocclr/utils/versions.hpp similarity index 100% rename from rocclr/runtime/utils/versions.hpp rename to rocclr/utils/versions.hpp