├── .gitignore ├── .gitlab-ci.yml ├── CMakeLists.txt ├── HSAILAsm ├── CMakeLists.txt └── HSAILAsm.cpp ├── README.md ├── bin ├── cmake_lnx_amd.sh └── cmake_win_amd.bat ├── cmake_modules ├── FindLibDwarf.cmake ├── FindLibElf.cmake └── FindRE2C.cmake ├── docs ├── HSA-PRM-1.02.pdf ├── hsail_lex.txt └── hsail_syntax.txt ├── libHSAIL-AMD ├── Brig_amd.h ├── CMakeLists.txt ├── HSAILAmdExt.cpp ├── HSAILAmdExt.h ├── dg.cpp ├── dg.hdl ├── gcn.cpp ├── gcn.hdl ├── generate.pl ├── mipmap.cpp └── mipmap.hdl ├── libHSAIL ├── Brig.h ├── BrigDwarfGenerator.cpp ├── BrigDwarfGenerator.h ├── BrigMeta.info ├── CMakeLists.txt ├── HDLProcessor.pl ├── HSAILBrigContainer.cpp ├── HSAILBrigContainer.h ├── HSAILBrigObjectFile.cpp ├── HSAILBrigObjectFile.h ├── HSAILBrigantine.cpp ├── HSAILBrigantine.h ├── HSAILConvertors.h ├── HSAILCore.hdl ├── HSAILDefs.hdl ├── HSAILDisassembler.cpp ├── HSAILDisassembler.h ├── HSAILDump.cpp ├── HSAILDump.h ├── HSAILExtManager.cpp ├── HSAILExtManager.h ├── HSAILExtension.h ├── HSAILFloats.cpp ├── HSAILFloats.h ├── HSAILGenericExtension.h ├── HSAILImage.hdl ├── HSAILImageExt.cpp ├── HSAILImageExt.h ├── HSAILInstProps.cpp ├── HSAILInstProps.h ├── HSAILItemBase.h ├── HSAILItems.cpp ├── HSAILItems.h ├── HSAILParser.cpp ├── HSAILParser.h ├── HSAILSRef.h ├── HSAILScanner.cpp ├── HSAILScanner.h ├── HSAILScannerRules.cpp ├── HSAILScannerRules.re2c ├── HSAILScope.h ├── HSAILTool.cpp ├── HSAILTool.h ├── HSAILTypeUtilities.h ├── HSAILUtilities.cpp ├── HSAILUtilities.h ├── HSAILValidator.cpp ├── HSAILValidator.h ├── HSAILValidatorBase.cpp ├── HSAILValidatorBase.h ├── HSAILb128_t.h ├── SectionHeaderTable.h ├── doxy.cfg ├── generate.pl ├── hsa_dwarf.h ├── hsail_c.cpp └── hsail_c.h └── tests └── 1.0 ├── instruction ├── CMakeLists.txt ├── CORE-base-large.hsail ├── CORE-base-small.hsail ├── CORE-full-large.hsail ├── CORE-full-small.hsail ├── IMAGE-base-large.hsail ├── IMAGE-base-small.hsail ├── IMAGE-full-large.hsail ├── IMAGE-full-small.hsail ├── amd_gcn-base-large.hsail ├── amd_gcn-base-small.hsail ├── amd_gcn-full-large.hsail ├── amd_gcn-full-small.hsail ├── amd_mipmap-base-large.hsail ├── amd_mipmap-base-small.hsail ├── amd_mipmap-full-large.hsail ├── amd_mipmap-full-small.hsail ├── generate.sh ├── run_test └── run_test.cmd ├── simple.hsail ├── syntax ├── 000_empty_1.hsail ├── 000_inst_image_large.hsail ├── 000_inst_image_small.hsail ├── 000_inst_large.hsail ├── 000_inst_large_base.hsail ├── 000_inst_small.hsail ├── 001_delimiters.hsail ├── 001_order_1.hsail ├── 001_order_2.hsail ├── 001_order_3.hsail ├── 002_version_large.hsail ├── 002_version_small.hsail ├── 003_pragma.hsail ├── 004_extension.hsail ├── 004_extension_CORE.hsail ├── 004_extension_CORE_0.hsail ├── 005_control_00.hsail ├── 005_control_01.hsail ├── 005_control_02.hsail ├── 005_control_03.hsail ├── 005_control_04.hsail ├── 005_control_05.hsail ├── 005_control_06.hsail ├── 005_control_07.hsail ├── 005_control_08.hsail ├── 005_control_09.hsail ├── 005_control_10.hsail ├── 005_control_enablebreakexceptions_1.hsail ├── 005_control_enablebreakexceptions_2.hsail ├── 005_control_enabledetectexceptions_1.hsail ├── 005_control_enabledetectexceptions_2.hsail ├── 005_control_maxdynamicgroupsize.hsail ├── 005_control_maxflatgridsize_1.hsail ├── 005_control_maxflatgridsize_2.hsail ├── 005_control_maxflatworkgroupsize_1.hsail ├── 005_control_maxflatworkgroupsize_2.hsail ├── 005_control_requireddim.hsail ├── 005_control_requiredgridsize_1.hsail ├── 005_control_requiredgridsize_2.hsail ├── 005_control_requiredworkgroupsize_1.hsail ├── 005_control_requiredworkgroupsize_2.hsail ├── 006_loc.hsail ├── 009_function_arg_align.hsail ├── 009_function_arg_array.hsail ├── 009_function_arg_flexible_array.hsail ├── 009_function_arg_generic.hsail ├── 009_function_arg_generic_base.hsail ├── 009_function_arg_passing.hsail ├── 009_function_decl.hsail ├── 009_function_forw_decl.hsail ├── 009_function_generic.hsail ├── 009_function_indirect.hsail ├── 009_function_indirect_small.hsail ├── 009_function_module.hsail ├── 009_function_signature_0.hsail ├── 009_function_signature_1.hsail ├── 009_function_width.hsail ├── 010_kernel_args.hsail ├── 010_kernel_decl.hsail ├── 010_kernel_generic.hsail ├── 010_kernel_module.hsail ├── 011_argscope_generic.hsail ├── 011_argscope_jumps_01.hsail ├── 011_argscope_jumps_02.hsail ├── 011_argscope_jumps_03.hsail ├── 011_argscope_jumps_04.hsail ├── 011_argscope_jumps_05.hsail ├── 011_argscope_special.hsail ├── 012_var_align.hsail ├── 012_var_alloc.hsail ├── 012_var_array.hsail ├── 012_var_array_init.hsail ├── 012_var_base.hsail ├── 012_var_decl.hsail ├── 012_var_generic.hsail ├── 012_var_img.hsail ├── 012_var_module.hsail ├── 012_var_sampler.hsail ├── 013_name_1.hsail ├── 013_name_2.hsail ├── 013_name_3.hsail ├── 013_name_4.hsail ├── 014_branch.hsail ├── 015_large_memory_model.hsail ├── 015_small_memory_model.hsail ├── 016_literal_conversion.hsail ├── 016_literal_conversions_1_0.hsail ├── 017_addressing.hsail ├── 018_aggregate_const.hsail ├── 019_reg_limit.hsail ├── CMakeLists.txt ├── run_test └── run_test.cmd └── syntax_validation ├── CMakeLists.txt ├── golden.zip ├── hsail_negative_tests.txt ├── run_test ├── run_test.cmd └── testgen.pl /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.s 3 | *.lo 4 | *.o 5 | *.d 6 | 7 | # Compiled Dynamic libraries 8 | *.so 9 | *.dylib 10 | 11 | # Compiled Static libraries 12 | *.lai 13 | *.la 14 | *.a 15 | 16 | *.bak 17 | *.orig 18 | 19 | vsvars.inc 20 | build_*/ 21 | build/ 22 | 23 | cmake_lnx_local.sh 24 | cmake_win_local.bat 25 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | before_script: 2 | - uname -a 3 | - cat /etc/*release 4 | - dpkg --add-architecture i386 5 | - apt-get -yy update 6 | - dpkg --print-architecture 7 | - dpkg --print-foreign-architectures 8 | - apt-get install -yy cmake openssh-client re2c perl 9 | - cmake --version 10 | 11 | lnx64-debug: 12 | script: 13 | - apt-get install -yy libelf-dev libdwarf-dev llvm-dev ncurses-dev re2c perl 14 | - mkdir -p build/$CI_BUILD_NAME 15 | - cd build/$CI_BUILD_NAME 16 | - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-m64 -DCMAKE_CXX_FLAGS=-m64 -DCMAKE_SHARED_LINKER_FLAGS=-m64 -DCMAKE_INSTALL_PREFIX=../../$CI_BUILD_NAME ../.. 17 | - make -j 4 18 | - make install 19 | - make test 20 | - cd ../.. 21 | artifacts: 22 | name: "hsail-tools-${CI_BUILD_NAME}-${CI_BUILD_ID}" 23 | expire_in: 4 weeks 24 | paths: 25 | - ${CI_BUILD_NAME} 26 | 27 | lnx64-release: 28 | script: 29 | - apt-get install -yy libelf-dev libdwarf-dev llvm-dev ncurses-dev re2c perl 30 | - mkdir -p build/$CI_BUILD_NAME 31 | - cd build/$CI_BUILD_NAME 32 | - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-m64 -DCMAKE_CXX_FLAGS=-m64 -DCMAKE_SHARED_LINKER_FLAGS=-m64 -DCMAKE_INSTALL_PREFIX=../../$CI_BUILD_NAME ../.. 33 | - make -j 4 34 | - make install 35 | - make test 36 | - cd ../.. 37 | artifacts: 38 | name: "hsail-tools-${CI_BUILD_NAME}-${CI_BUILD_ID}" 39 | expire_in: 4 weeks 40 | paths: 41 | - ${CI_BUILD_NAME} 42 | 43 | lnx32-debug: 44 | script: 45 | - apt-get install -yy libelf-dev:i386 libdwarf-dev:i386 llvm-dev:i386 ncurses-dev:i386 gcc-multilib g++-multilib 46 | - mkdir -p build/$CI_BUILD_NAME 47 | - cd build/$CI_BUILD_NAME 48 | - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 -DCMAKE_SHARED_LINKER_FLAGS=-m32 -DCMAKE_INSTALL_PREFIX=../../$CI_BUILD_NAME ../.. 49 | - make -j 4 50 | - make install 51 | - make test 52 | - cd ../.. 53 | artifacts: 54 | name: "hsail-tools-${CI_BUILD_NAME}-${CI_BUILD_ID}" 55 | expire_in: 4 weeks 56 | paths: 57 | - ${CI_BUILD_NAME} 58 | 59 | lnx32-release: 60 | script: 61 | - apt-get install -yy libelf-dev:i386 libdwarf-dev:i386 llvm-dev:i386 ncurses-dev:i386 gcc-multilib g++-multilib 62 | - mkdir -p build/$CI_BUILD_NAME 63 | - cd build/$CI_BUILD_NAME 64 | - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 -DCMAKE_SHARED_LINKER_FLAGS=-m32 -DCMAKE_INSTALL_PREFIX=../../$CI_BUILD_NAME ../.. 65 | - make -j 4 66 | - make install 67 | - make test 68 | - cd ../.. 69 | artifacts: 70 | name: "hsail-tools-${CI_BUILD_NAME}-${CI_BUILD_ID}" 71 | expire_in: 4 weeks 72 | paths: 73 | - ${CI_BUILD_NAME} 74 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.6) 2 | 3 | project(HSAIL-Tools) 4 | 5 | if(MSVC) 6 | add_compile_options(/W3 /WX) 7 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) 8 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") 9 | set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") 10 | endif() 11 | 12 | if(UNIX) 13 | add_compile_options(-fpic -Wall -Werror -std=c++11 -pthread -fno-rtti -fvisibility-inlines-hidden) 14 | add_definitions(-D__STDC_LIMIT_MACROS) 15 | add_definitions(-D__STDC_CONSTANT_MACROS) 16 | add_definitions(-D__STDC_FORMAT_MACROS) 17 | endif() 18 | 19 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules") 20 | 21 | include(CMakeDependentOption) 22 | 23 | find_package(RE2C REQUIRED) 24 | 25 | option(VENDOR_EXTENSIONS "Enable vendor extensions" ON) 26 | message(STATUS "Vendor extensions: ${VENDOR_EXTENSIONS}") 27 | 28 | cmake_dependent_option(AMD_EXTENSIONS "Enable AMD HSAIL extensions" ON "VENDOR_EXTENSIONS" OFF) 29 | message(STATUS "AMD extensions: ${AMD_EXTENSIONS}") 30 | 31 | option(BUILD_HSAILASM "Build HSAILAsm" ON) 32 | message(STATUS "Building HSAILAsm: ${BUILD_HSAILASM}") 33 | 34 | enable_testing() 35 | 36 | add_subdirectory(libHSAIL) 37 | 38 | if(AMD_EXTENSIONS) 39 | add_subdirectory(libHSAIL-AMD) 40 | add_definitions(-DAMD_EXTENSIONS) 41 | endif() 42 | 43 | # FIXME: We should check for a usable version of libelf / libdwarf. 44 | if(BUILD_HSAILASM) 45 | add_subdirectory(HSAILAsm) 46 | add_subdirectory(tests/1.0/instruction) 47 | add_subdirectory(tests/1.0/syntax) 48 | add_subdirectory(tests/1.0/syntax_validation) 49 | endif() 50 | 51 | if(BUILD_HSAILTESTGEN) 52 | add_subdirectory(libTestGen) 53 | add_subdirectory(HSAILTestGen) 54 | endif() 55 | -------------------------------------------------------------------------------- /HSAILAsm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(HSAILasm HSAILAsm.cpp) 2 | 3 | target_link_libraries(HSAILasm hsail) 4 | 5 | if(AMD_EXTENSIONS) 6 | target_link_libraries(HSAILasm hsail-amd) 7 | endif() 8 | 9 | find_library(CURSES_LIB curses) 10 | 11 | if(BUILD_LIBBRIGDWARF) 12 | include_directories(${LIBELF_INCLUDE_DIRS}) 13 | 14 | target_link_libraries(HSAILasm ${LIBELF_LIBRARIES}) 15 | target_link_libraries(HSAILasm ${LIBDWARF_LIBRARIES}) 16 | endif() 17 | 18 | if(CURSES_LIB) 19 | target_link_libraries(HSAILasm ${CURSES_LIB}) 20 | endif() 21 | if(UNIX) 22 | target_link_libraries(HSAILasm tinfo pthread) 23 | endif() 24 | 25 | install(TARGETS HSAILasm 26 | RUNTIME DESTINATION bin COMPONENT libhsail 27 | ) 28 | 29 | set(HSAILASM $) 30 | set(test "${PROJECT_SOURCE_DIR}/tests/1.0/simple.hsail") 31 | 32 | add_test(NAME HSAILAsm-help 33 | COMMAND ${HSAILASM} -help 34 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) 35 | 36 | add_test(NAME HSAILAsm-version 37 | COMMAND ${HSAILASM} -version 38 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) 39 | 40 | add_test(NAME HSAILAsm-assemble 41 | COMMAND ${HSAILASM} -assemble ${test} -o test.brig 42 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) 43 | 44 | add_test(NAME HSAILAsm-disassemble 45 | COMMAND ${HSAILASM} -disassemble test.brig 46 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) 47 | 48 | add_test(NAME HSAILAsm-decode 49 | COMMAND ${HSAILASM} -decode test.brig -o test.yaml 50 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) 51 | 52 | if(BUILD_LIBBRIGDWARF) 53 | add_test(NAME HSAILAsm-assemble-g 54 | COMMAND ${HSAILASM} -assemble -g ${test} -o test-g.brig 55 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) 56 | 57 | add_test(NAME HSAILAsm-disassemble-g 58 | COMMAND ${HSAILASM} -disassemble test-g.brig 59 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) 60 | 61 | add_test(NAME HSAILAsm-assemble-g-odebug 62 | COMMAND ${HSAILASM} -assemble -g ${test} -odebug test-g.dbg -o test-g.brig 63 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) 64 | 65 | add_test(NAME HSAILAsm-assemble-g-include-source 66 | COMMAND ${HSAILASM} -assemble -g -include-source ${test} -o test-g.brig 67 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) 68 | 69 | endif() 70 | -------------------------------------------------------------------------------- /HSAILAsm/HSAILAsm.cpp: -------------------------------------------------------------------------------- 1 | // University of Illinois/NCSA 2 | // Open Source License 3 | // 4 | // Copyright (c) 2013-2015, Advanced Micro Devices, Inc. 5 | // All rights reserved. 6 | // 7 | // Developed by: 8 | // 9 | // HSA Team 10 | // 11 | // Advanced Micro Devices, Inc 12 | // 13 | // www.amd.com 14 | // 15 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | // this software and associated documentation files (the "Software"), to deal with 17 | // the Software without restriction, including without limitation the rights to 18 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | // of the Software, and to permit persons to whom the Software is furnished to do 20 | // so, subject to the following conditions: 21 | // 22 | // * Redistributions of source code must retain the above copyright notice, 23 | // this list of conditions and the following disclaimers. 24 | // 25 | // * Redistributions in binary form must reproduce the above copyright notice, 26 | // this list of conditions and the following disclaimers in the 27 | // documentation and/or other materials provided with the distribution. 28 | // 29 | // * Neither the names of the LLVM Team, University of Illinois at 30 | // Urbana-Champaign, nor the names of its contributors may be used to 31 | // endorse or promote products derived from this Software without specific 32 | // prior written permission. 33 | // 34 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 36 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 | // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 40 | // SOFTWARE. 41 | 42 | //===----------------------------------------------------------------------===// 43 | // 44 | // HSAIL Assembler/disassembler 45 | // 46 | //===----------------------------------------------------------------------===// 47 | 48 | #include "HSAILTool.h" 49 | #include "HSAILExtManager.h" 50 | #include "HSAILImageExt.h" 51 | #ifdef AMD_EXTENSIONS 52 | #include "HSAILAmdExt.h" 53 | #endif // AMD_EXTENSIONS 54 | 55 | #ifdef _MSC_VER 56 | #include 57 | #endif // _MSC_VER 58 | 59 | using namespace HSAIL_ASM; 60 | 61 | #ifdef _MSC_VER 62 | /// AvoidMessageBoxHook - Emulates hitting "retry" from an "abort, retry, 63 | /// ignore" CRT debug report dialog. "retry" raises an exception which 64 | /// ultimately triggers our stack dumper. 65 | static int 66 | AvoidMessageBoxHook(int ReportType, char *Message, int *Return) { 67 | // Set *Return to the retry code for the return value of _CrtDbgReport: 68 | // http://msdn.microsoft.com/en-us/library/8hyw4sy7(v=vs.71).aspx 69 | // This may also trigger just-in-time debugging via DebugBreak(). 70 | if (Return) 71 | *Return = 1; 72 | // Don't call _CrtDbgReport. 73 | return TRUE; 74 | } 75 | #endif 76 | 77 | void DisableSystemDialogsOnCrash() { 78 | #ifdef _MSC_VER 79 | // We're already handling writing a "something went wrong" message. 80 | _set_abort_behavior(0, _WRITE_ABORT_MSG); 81 | // Disable Dr. Watson. 82 | _set_abort_behavior(0, _CALL_REPORTFAULT); 83 | _CrtSetReportHook(AvoidMessageBoxHook); 84 | 85 | // Disable standard error dialog box. 86 | SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | 87 | SEM_NOOPENFILEERRORBOX); 88 | _set_error_mode(_OUT_TO_STDERR); 89 | #endif 90 | } 91 | 92 | int main(int argc, char **argv) { 93 | 94 | // Enable this to enable finegrained heap checks 95 | // _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF ); 96 | 97 | DisableSystemDialogsOnCrash(); 98 | 99 | #ifdef AMD_EXTENSIONS 100 | amd::hsail::registerExtensions(); 101 | #endif // AMD_EXTENSIONS 102 | 103 | Tool tool; 104 | 105 | #if defined(DEBUG) || defined(_DEBUG) || defined(NDEBUG) 106 | tool.SetEnableComments(true); 107 | #endif 108 | 109 | return tool.execute(argc, argv) ? 0 : 1; 110 | } 111 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | HSAIL-Tools 2 | =========== 3 | 4 | [![build status](https://gitlab.com/hsafoundation-spb/HSAIL-Tools/badges/master/build.svg)](https://gitlab.com/hsafoundation-spb/HSAIL-Tools/commits/master) 5 | 6 | 7 | ### OVERVIEW 8 | 9 | HSAIL-Tools are used for parsing, assembling, and disassembling HSAIL. 10 | 11 | The following components are provided: 12 | 13 | * **libHSAIL** is the main library. 14 | * **libHSAIL-AMD** is the library with AMD HSAIL extensions. 15 | * **HSAILAsm** is command-line interface to libHSAIL. 16 | 17 | This version of libHSAIL supports HSA PRM 1.02 (Final) specification. 18 | 19 | 20 | ### BUILD PREREQUISITES 21 | 22 | libHSAIL requires the following components: 23 | 24 | * CMake 25 | * libelf (if `BUILD_WITH_LIBBRIGDWARF=1`) 26 | * libdwarf (if `BUILD_WITH_LIBBRIGDWARF=1`) 27 | * perl 28 | * re2c 29 | 30 | libHSAIL CMake build will automatically find these dependencies if installed. 31 | 32 | libHSAIL can be built without debug support and does not require libelf/libdwarf 33 | in this case. 34 | 35 | 36 | ### BUILD (general) 37 | 38 | We recommend to use out-of-source CMake build and create separate directory to run CMake. 39 | 40 | To build libHSAIL without BRIG DWARF (no debug support), specify 41 | `-DBUILD_WITH_LIBBRIGDWARF=OFF` option to CMake. 42 | 43 | To avoid building HSAILAsm, specify `-DBUILD_HSAILASM=OFF` option to CMake. 44 | 45 | To avoid building all vendor extensions, specify `-DVENDOR_EXTENSIONS=OFF` option to CMake. 46 | 47 | To avoid building AMD extensions, specify `-DAMD_EXTENSIONS=OFF` option to CMake. 48 | 49 | A set of tests is included and can be run with 'make test' (requires HSAILAsm to be built). 50 | 51 | To enable additional syntax validation tests, specify `-DSYNTAX_VALIDATION_TESTS=ON` option to CMake. 52 | 53 | 54 | ### BUILD (Linux) 55 | 56 | mkdir -p build/lnx64 57 | cd build/lnx64 58 | cmake ../.. 59 | make -j 60 | 61 | On modern Linux distributions libHSAIL dependencies are typically provided 62 | by the distribution. For example, the following command can be used to install 63 | them on Ubuntu 14.04 system: 64 | 65 | sudo apt-get install cmake libdwarf-dev libelf-dev llvm-dev ncurses-dev re2c perl 66 | 67 | Building on Linux requires GCC 4.8+. 68 | 69 | On Linux, CMake normally finds all dependencies automatically. However, it is also 70 | possible to override it (see, for example, scripts in `bin/` subdirectory). 71 | 72 | 73 | ### BUILD (Windows) 74 | 75 | Building on Windows requires MSVC (Visual Studio 2012 Update 4 or later). 76 | 77 | CMake command line should specify compiler configuration: 78 | 79 | md build/win64 80 | cd build/win64 81 | cmake -G "Visual Studio 12 2013 Win64" ... 82 | 83 | CMake will attempt to locate corresponding compiler and generate Visual Studio 84 | solution file which can be opened and built in Visual Studio. 85 | 86 | For Windows, it is possible to obtain dependencies from corresponding software sources: 87 | 88 | * re2c source, Windows binaries and some linux packages can be donwloaded from 89 | http://sourceforge.net/projects/re2c/. 90 | * Perl for Windows can be obtained from any of the following sources: 91 | * Activestate ActivePerl : http://www.activestate.com/activeperl 92 | * Strawberry Perl : http://strawberryperl.com/ 93 | * as a part of Cygwin: http://www.cygwin.com/ 94 | 95 | On Windows, cmake command line additionally might need to include the location 96 | of dependencies. Refer to scripts in `bin/` subdirectory for an example how to specify them. 97 | -------------------------------------------------------------------------------- /bin/cmake_lnx_amd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | export BUILD_HSAILASM=1 5 | export BUILD_LIBBRIGDWARF=1 6 | export ELFTOOLCHAIN_PATH=/srv/hsa/drivers/hsa/contrib/elftoolchain 7 | export LIBELF_PATH=$ELFTOOLCHAIN_PATH/libelf 8 | export LIBDWARF_PATH=/srv/hsa/drivers/sc/HSAIL/hsail-tools/libdwarf 9 | export RE2C_EXECUTABLE=/srv/dk/lnx/re2c/re2c 10 | 11 | cd .. 12 | 13 | mkdir -p build/lnx32 14 | cd build/lnx32 15 | export BUILD_SUBDIR=build/lnx/B_dbg 16 | cmake -DCMAKE_BUILD_TYPE=Debug -G "Unix Makefiles" -DBUILD_HSAILASM=$BUILD_HSAILASM -DBUILD_LIBBRIGDWARF=$BUILD_LIBBRIGDWARF -DLIBELF_INCLUDE_DIRS="$LIBELF_PATH;$LIBELF_PATH/../common" -DLIBDWARF_INCLUDE_DIRS=$LIBDWARF_PATH/src -DLIBELF_LIBRARIES=$LIBELF_PATH/$BUILD_SUBDIR/libelf.a -DLIBDWARF_LIBRARIES=$LIBDWARF_PATH/$BUILD_SUBDIR/libdwarf.a -DRE2C_EXECUTABLE=$RE2C_EXECUTABLE -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 -DCMAKE_SHARED_LINKER_FLAGS=-m32 -DCMAKE_INSTALL_PREFIX=dist "$@" ../.. 17 | cd ../.. 18 | 19 | mkdir -p build/lnx64 20 | cd build/lnx64 21 | export BUILD_SUBDIR=build/lnx64a/B_dbg 22 | cmake -DCMAKE_BUILD_TYPE=Debug -G "Unix Makefiles" -DBUILD_HSAILASM=$BUILD_HSAILASM -DBUILD_LIBBRIGDWARF=$BUILD_LIBBRIGDWARF -DLIBELF_INCLUDE_DIRS="$LIBELF_PATH;$LIBELF_PATH/../common;$LIBDWARF_PATH/src" -DLIBDWARF_INCLUDE_DIRS=$LIBDWARF_PATH/src -DLIBELF_LIBRARIES=$LIBELF_PATH/$BUILD_SUBDIR/libelf.a -DLIBDWARF_LIBRARIES=$LIBDWARF_PATH/$BUILD_SUBDIR/libdwarf.a -DRE2C_EXECUTABLE=$RE2C_EXECUTABLE -DCMAKE_C_FLAGS=-m64 -DCMAKE_CXX_FLAGS=-m64 -DCMAKE_SHARED_LINKER_FLAGS=-m64 -DCMAKE_INSTALL_PREFIX=dist "$@" ../.. 23 | cd ../.. 24 | -------------------------------------------------------------------------------- /bin/cmake_win_amd.bat: -------------------------------------------------------------------------------- 1 | set BUILD_HSAILASM=1 2 | set BUILD_LIBBRIGDWARF=1 3 | set ELFTOOLCHAIN_PATH=C:\ws\sc\drivers\hsa\contrib\elftoolchain 4 | set LIBELF_PATH=%ELFTOOLCHAIN_PATH%\libelf 5 | set LIBDWARF_PATH=C:\ws\sc\drivers\sc\HSAIL\hsail-tools\libdwarf 6 | set RE2C_EXECUTABLE=C:\ws\dk\win\re2c\re2c.exe 7 | 8 | cd .. 9 | 10 | md build\win32 11 | cd build\win32 12 | set BUILD_SUBDIR=build\wNow\B_dbg 13 | cmake -G "Visual Studio 12 2013" -DBUILD_HSAILASM=%BUILD_HSAILASM% -DBUILD_LIBBRIGDWARF=%BUILD_LIBBRIGDWARF% "-DLIBELF_INCLUDE_DIRS=%LIBELF_PATH%;%LIBELF_PATH%/../common;%LIBELF_PATH%/../common/win32" -DLIBDWARF_INCLUDE_DIRS=%LIBDWARF_PATH%\src -DLIBELF_LIBRARIES=%LIBELF_PATH%\%BUILD_SUBDIR%\libelf.lib -DLIBDWARF_LIBRARIES=%LIBDWARF_PATH%\%BUILD_SUBDIR%\libdwarf.lib -DRE2C_EXECUTABLE=%RE2C_EXECUTABLE% -DCMAKE_INSTALL_PREFIX=dist %* ..\.. 14 | cd ..\.. 15 | 16 | md build\win64 17 | cd build\win64 18 | set BUILD_SUBDIR=build\wNow64a\B_dbg 19 | cmake -G "Visual Studio 12 2013 Win64" -DBUILD_HSAILASM=%BUILD_HSAILASM% -DBUILD_LIBBRIGDWARF=%BUILD_LIBBRIGDWARF% "-DLIBELF_INCLUDE_DIRS=%LIBELF_PATH%;%LIBELF_PATH%/../common;%LIBELF_PATH%/../common/win32" -DLIBDWARF_INCLUDE_DIRS=%LIBDWARF_PATH%\src -DLIBELF_LIBRARIES=%LIBELF_PATH%\%BUILD_SUBDIR%\libelf.lib -DLIBDWARF_LIBRARIES=%LIBDWARF_PATH%\%BUILD_SUBDIR%\libdwarf.lib -DRE2C_EXECUTABLE=%RE2C_EXECUTABLE% -DCMAKE_INSTALL_PREFIX=dist %* ..\.. 20 | cd ..\.. 21 | -------------------------------------------------------------------------------- /cmake_modules/FindLibDwarf.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find libdwarf 2 | # Once done this will define 3 | # 4 | # LIBDWARF_FOUND - system has libdwarf 5 | # LIBDWARF_INCLUDE_DIRS - the libdwarf include directory 6 | # LIBDWARF_LIBRARIES - Link these to use libdwarf 7 | # LIBDWARF_DEFINITIONS - Compiler switches required for using libdwarf 8 | # 9 | 10 | if(LIBDWARF_FOUND) 11 | return() 12 | endif(LIBDWARF_FOUND) 13 | 14 | # Locate libelf library at first 15 | find_package (LibElf REQUIRED) 16 | 17 | if (LIBDWARF_LIBRARIES AND LIBDWARF_INCLUDE_DIRS) 18 | set (LibDwarf_FIND_QUIETLY TRUE) 19 | endif (LIBDWARF_LIBRARIES AND LIBDWARF_INCLUDE_DIRS) 20 | 21 | find_path (DWARF_INCLUDE_DIR 22 | NAMES 23 | libdwarf.h dwarf.h 24 | PATHS 25 | /usr/include 26 | /usr/include/libdwarf 27 | /usr/local/include 28 | /usr/local/include/libdwarf 29 | /opt/local/include 30 | /sw/include 31 | ENV CPATH) # PATH and INCLUDE will also work 32 | 33 | if (DWARF_INCLUDE_DIR) 34 | set (LIBDWARF_INCLUDE_DIRS ${DWARF_INCLUDE_DIR}) 35 | endif () 36 | 37 | find_library (LIBDWARF_LIBRARIES 38 | NAMES 39 | dwarf libdwarf 40 | PATHS 41 | /usr/lib 42 | /usr/local/lib 43 | /opt/local/lib 44 | /sw/lib 45 | ENV LIBRARY_PATH # PATH and LIB will also work 46 | ENV LD_LIBRARY_PATH) 47 | include (FindPackageHandleStandardArgs) 48 | 49 | 50 | # handle the QUIETLY and REQUIRED arguments and set LIBDWARF_FOUND to TRUE 51 | # if all listed variables are TRUE 52 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibDwarf DEFAULT_MSG 53 | LIBDWARF_LIBRARIES 54 | LIBDWARF_INCLUDE_DIRS) 55 | 56 | if (LIBDWARF_LIBRARIES AND LIBDWARF_INCLUDE_DIRS) 57 | set(CMAKE_REQUIRED_INCLUDES ${LIBDWARF_INCLUDE_DIRS}) 58 | set(CMAKE_REQUIRED_LIBRARIES ${LIBDWARF_LIBRARIES} ${LIBELF_LIBRARIES}) 59 | 60 | # libdwarf makes breaking changes occasionally and doesn't provide an easy 61 | # way to test for them. The following checks should detect the changes and 62 | # pass that information on accordingly. 63 | INCLUDE(CheckCXXSourceCompiles) 64 | INCLUDE(CheckFunctionExists) 65 | 66 | MACRO(CHECK_LIBDWARF_INIT init params var) 67 | # Check for the existence of this particular init function. 68 | unset(INIT_EXISTS CACHE) 69 | CHECK_FUNCTION_EXISTS(${init} INIT_EXISTS) 70 | if (INIT_EXISTS) 71 | set(LIBDWARF_USE_INIT_C ${var}) 72 | 73 | # Check to see if we can use a const name. 74 | unset(DW_CONST CACHE) 75 | 76 | if (NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") 77 | # -std=c++11 is already set in HPHPCompiler.cmake, don't 78 | # add -std=c++0x on top of that or clang will give errors 79 | set(CMAKE_REQUIRED_FLAGS "-std=c++0x") 80 | endif() 81 | 82 | CHECK_CXX_SOURCE_COMPILES(" 83 | #include 84 | #include 85 | int dwarfCallback(const char * a, int b, Dwarf_Unsigned c, 86 | Dwarf_Unsigned d, Dwarf_Unsigned e, Dwarf_Unsigned f, 87 | Dwarf_Unsigned * g, Dwarf_Ptr h, int * i) {} 88 | int main() { ${init}(${params}); return 0; }" DW_CONST) 89 | if (DW_CONST) 90 | set(LIBDWARF_CONST_NAME 1) 91 | else() 92 | set(LIBDWARF_CONST_NAME 0) 93 | endif() 94 | endif() 95 | ENDMACRO(CHECK_LIBDWARF_INIT) 96 | 97 | # Order is important, last one is used. 98 | CHECK_LIBDWARF_INIT("dwarf_producer_init" 99 | "0, dwarfCallback, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr" 0) 100 | CHECK_LIBDWARF_INIT("dwarf_producer_init_c" "0, dwarfCallback, nullptr, nullptr, nullptr, nullptr" 1) 101 | endif() 102 | 103 | mark_as_advanced(LIBDW_INCLUDE_DIR DWARF_INCLUDE_DIR) 104 | mark_as_advanced(LIBDWARF_INCLUDE_DIRS LIBDWARF_LIBRARIES) 105 | mark_as_advanced(LIBDWARF_CONST_NAME LIBDWARF_USE_INIT_C) 106 | 107 | if(LIBDWARF_FOUND) 108 | if(LIBDWARF_CONST_NAME) 109 | message(STATUS "libdwarf uses const char* type") 110 | else() 111 | message(STATUS "libdwarf uses char* type") 112 | endif() 113 | if(LIBDWARF_USE_INIT_C) 114 | message(STATUS "libdwarf has dwarf_producer_init_c") 115 | else() 116 | message(STATUS "libdwarf does not have dwarf_producer_init_c, using dwarf_producer_init") 117 | endif() 118 | 119 | add_library(dwarf UNKNOWN IMPORTED) 120 | set_property(TARGET dwarf PROPERTY IMPORTED_LOCATION ${LIBDWARF_LIBRARIES}) 121 | set_property(TARGET dwarf PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${LIBDWARF_INCLUDE_DIRS}) 122 | endif() 123 | -------------------------------------------------------------------------------- /cmake_modules/FindLibElf.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find libelf 2 | # Once done this will define 3 | # 4 | # LIBELF_FOUND - system has libelf 5 | # LIBELF_INCLUDE_DIRS - the libelf include directory 6 | # LIBELF_LIBRARIES - Link these to use libelf 7 | # LIBELF_DEFINITIONS - Compiler switches required for using libelf 8 | # 9 | # Copyright (c) 2008 Bernhard Walle 10 | # 11 | # Redistribution and use is allowed according to the terms of the New 12 | # BSD license. 13 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 14 | # 15 | 16 | if (LIBELF_FOUND) 17 | return() 18 | endif (LIBELF_FOUND) 19 | 20 | find_path (LIBELF_INCLUDE_DIRS 21 | NAMES 22 | libelf.h 23 | PATHS 24 | /usr/include 25 | /usr/include/libelf 26 | /usr/local/include 27 | /usr/local/include/libelf 28 | /opt/local/include 29 | /opt/local/include/libelf 30 | /sw/include 31 | /sw/include/libelf 32 | ENV CPATH) 33 | 34 | find_library (LIBELF_LIBRARIES 35 | NAMES 36 | elf 37 | PATHS 38 | /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} 39 | /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE} 40 | /opt/local/lib 41 | /sw/lib 42 | ENV LIBRARY_PATH 43 | ENV LD_LIBRARY_PATH) 44 | 45 | include (FindPackageHandleStandardArgs) 46 | 47 | 48 | # handle the QUIETLY and REQUIRED arguments and set LIBELF_FOUND to TRUE if all listed variables are TRUE 49 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibElf DEFAULT_MSG 50 | LIBELF_LIBRARIES 51 | LIBELF_INCLUDE_DIRS) 52 | 53 | SET(CMAKE_REQUIRED_LIBRARIES elf) 54 | INCLUDE(CheckCXXSourceCompiles) 55 | CHECK_CXX_SOURCE_COMPILES("#include 56 | int main() { 57 | Elf *e = (Elf*)0; 58 | size_t sz; 59 | elf_getshdrstrndx(e, &sz); 60 | return 0; 61 | }" ELF_GETSHDRSTRNDX) 62 | 63 | mark_as_advanced(LIBELF_INCLUDE_DIRS LIBELF_LIBRARIES ELF_GETSHDRSTRNDX) 64 | 65 | if(LIBELF_FOUND) 66 | add_library(elf UNKNOWN IMPORTED) 67 | set_property(TARGET elf PROPERTY IMPORTED_LOCATION ${LIBELF_LIBRARIES}) 68 | set_property(TARGET elf PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${LIBELF_INCLUDE_DIRS}) 69 | endif() 70 | -------------------------------------------------------------------------------- /cmake_modules/FindRE2C.cmake: -------------------------------------------------------------------------------- 1 | # - Find re2c executable and provides macros to generate custom build rules 2 | # The module defines the following variables: 3 | # 4 | # RE2C_EXECUTABLE - path to the bison program 5 | # RE2C_VERSION - version of bison 6 | # RE2C_FOUND - true if the program was found 7 | # 8 | find_program(RE2C_EXECUTABLE NAMES re2c DOC "path to re2c executable") 9 | mark_as_advanced(RE2C_EXECUTABLE) 10 | 11 | if(RE2C_EXECUTABLE) 12 | 13 | execute_process(COMMAND ${RE2C_EXECUTABLE} --vernum 14 | RESULT_VARIABLE RE2C_version_result 15 | OUTPUT_VARIABLE RE2C_version_output 16 | ERROR_VARIABLE RE2C_version_error 17 | OUTPUT_STRIP_TRAILING_WHITESPACE) 18 | 19 | set(RE2C_VERSION ${RE2C_version_output}) 20 | 21 | macro(RE2C_TARGET Re2cInput Re2cOutput Args) 22 | set(RE2C_EXECUTABLE_opts ${Args}) 23 | 24 | ADD_CUSTOM_COMMAND(OUTPUT ${Re2cOutput} 25 | COMMAND ${RE2C_EXECUTABLE} 26 | ARGS ${RE2C_EXECUTABLE_opts} -o ${Re2cOutput} ${Re2cInput} 27 | DEPENDS ${Re2cInput} 28 | COMMENT "[RE2C] Building re2c scanner with re2c ${RE2C_VERSION}" 29 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) 30 | 31 | endmacro(RE2C_TARGET) 32 | endif(RE2C_EXECUTABLE) 33 | 34 | include(FindPackageHandleStandardArgs) 35 | find_package_handle_standard_args(RE2C DEFAULT_MSG RE2C_EXECUTABLE) 36 | -------------------------------------------------------------------------------- /docs/HSA-PRM-1.02.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HSAFoundation/HSAIL-Tools/6514deb6bcb13930aaba2c5d380621cf685f37d2/docs/HSA-PRM-1.02.pdf -------------------------------------------------------------------------------- /docs/hsail_lex.txt: -------------------------------------------------------------------------------- 1 | TOKEN_COMMENT ::= ( "/*" { 'not [*]' | "*" 'not [/]' } "*/" ) 2 | | ( "//" { 'not new-line' } 3 | ) 4 | 5 | TOKEN_GLOBAL_IDENTIFIER ::= "&" identifier 6 | 7 | TOKEN_LOCAL_IDENTIFIER ::= "%" identifier 8 | 9 | TOKEN_LABEL_IDENTIFIER ::= "@" identifier 10 | 11 | identifier ::= '[a-zA-Z_]' { '[a-zA-Z0-9_]' } 12 | 13 | TOKEN_CREGISTER ::= "$c" registerNumber 14 | 15 | TOKEN_SREGISTER ::= "$s" registerNumber 16 | 17 | TOKEN_DREGISTER ::= "$d" registerNumber 18 | 19 | TOKEN_QREGISTER ::= "$q" registerNumber 20 | 21 | registerNumber ::= "0" 22 | | '[1-9]' { '[0-9]' } 23 | 24 | TOKEN_PROPERTY ::= "normalized" 25 | | "unnormalized" 26 | | "nearest" 27 | | "linear" 28 | | "wrap" 29 | | "clamp" 30 | | "mirror" 31 | | "mirroronce" 32 | | "border" 33 | | "snorm_int8" 34 | | "snorm_int16" 35 | | "unorm_int8" 36 | | "unorm_int16" 37 | | "unorm_int24" 38 | | "unorm_short_565" 39 | | "unorm_short_555" 40 | | "unorm_short_101010" 41 | | "signed_int8" 42 | | "signed_int16" 43 | | "signed_int32" 44 | | "unsigned_int8" 45 | | "unsigned_int16" 46 | | "unsigned_int32" 47 | | "half_float" 48 | | "float" 49 | | "r" 50 | | "rx" 51 | | "a" 52 | | "rg" 53 | | "rgx" 54 | | "ra" 55 | | "rgb" 56 | | "srgb" 57 | | "srgbx" 58 | | "rgbx" 59 | | "rgba" 60 | | "bgra" 61 | | "argb" 62 | | "srgba" 63 | | "sbgra" 64 | | "intensity" 65 | | "luminance" 66 | 67 | TOKEN_INTEGER_CONSTANT ::= decimalIntegerConstant 68 | | hexIntegerConstant 69 | | octalIntegerConstant 70 | 71 | decimalIntegerConstant ::= "0" | ( '[1-9]' { ['[0-9]'] } ) 72 | 73 | hexIntegerConstant ::= "0" ( "x" | "X" ) '[0-9a-fA-F]' { '[0-9a-fA-F]' } 74 | 75 | octalIntegerConstant ::= "0" '[0-7]' { '[0-7]' } 76 | 77 | TOKEN_HALF_CONSTANT ::= decimalFloatConstant ( "h" | "H" ) 78 | | hexFloatConstant ( "h" | "H" ) 79 | | ieeeHalfConstant 80 | 81 | TOKEN_SINGLE_CONSTANT ::= decimalFloatConstant ( "f" | "F" ) 82 | | hexFloatConstant ( "f" | "F" ) 83 | | ieeeSingleConstant 84 | 85 | TOKEN_DOUBLE_CONSTANT ::= decimalFloatConstant [ "d" | "D" ] 86 | | hexFloatConstant [ "d" | "D" ] 87 | | ieeeDoubleConstant 88 | 89 | decimal_float_constant ::= ( ( '[0-9]' { '[0-9]' } "." 90 | | { '[0-9]' } "." '[0-9]' { '[0-9]' } 91 | ) 92 | [ ( "e" | "E" ) [ "+" | "-" ] '[0-9]' { '[0-9]' } ] 93 | ) 94 | | '[0-9]' { '[0-9]' } ( "e" | "E" ) [ "+" | "-" ] '[0-9]' { '[0-9]' } 95 | 96 | hexFloatConstant ::= "0" ( "x" | "X" ) 97 | ( '[0-9a-fA-F]' { '[0-9a-fA-F]' } [ "." ] 98 | | { '[0-9a-fA-F]' } "." '[0-9a-fA-F]' { '[0-9a-fA-F]' } 99 | ) 100 | ( "p" | "P" ) [ "+" | "-" ] '[0-9]' { '[0-9]' } 101 | 102 | ieeeHalfConstant ::= "0" ( "h" | "H" ) '[0-9a-fA-F]{4}' 103 | 104 | ieeeSingleConstant ::= "0" ( "f" | "F" ) '[0-9a-fA-F]{8}' 105 | 106 | ieeeDoubleConstant ::= "0" ( "d" | "D" ) '[0-9a-fA-F]{16}' 107 | 108 | TOKEN_WAVESIZE ::= "WAVESIZE" 109 | 110 | TOKEN_STRING ::= '"' 111 | { 'not ([\"] or new-line)' 112 | | "\" 113 | ( '"' 114 | | "[\'?abfnrtv]" 115 | | '[0-7]{1,3}' 116 | | "x" '[0-9a-fA-F]' { '[0-9a-fA-F]' } 117 | ) 118 | } 119 | '"' 120 | -------------------------------------------------------------------------------- /libHSAIL-AMD/Brig_amd.h: -------------------------------------------------------------------------------- 1 | // University of Illinois/NCSA 2 | // Open Source License 3 | // 4 | // Copyright (c) 2013-2015, Advanced Micro Devices, Inc. 5 | // All rights reserved. 6 | // 7 | // Developed by: 8 | // 9 | // HSA Team 10 | // 11 | // Advanced Micro Devices, Inc 12 | // 13 | // www.amd.com 14 | // 15 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | // this software and associated documentation files (the "Software"), to deal with 17 | // the Software without restriction, including without limitation the rights to 18 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | // of the Software, and to permit persons to whom the Software is furnished to do 20 | // so, subject to the following conditions: 21 | // 22 | // * Redistributions of source code must retain the above copyright notice, 23 | // this list of conditions and the following disclaimers. 24 | // 25 | // * Redistributions in binary form must reproduce the above copyright notice, 26 | // this list of conditions and the following disclaimers in the 27 | // documentation and/or other materials provided with the distribution. 28 | // 29 | // * Neither the names of the LLVM Team, University of Illinois at 30 | // Urbana-Champaign, nor the names of its contributors may be used to 31 | // endorse or promote products derived from this Software without specific 32 | // prior written permission. 33 | // 34 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 36 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 | // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 40 | // SOFTWARE. 41 | 42 | //.ignore{ 43 | 44 | #ifndef INCLUDED_BRIG_AMD_H 45 | #define INCLUDED_BRIG_AMD_H 46 | 47 | #include "Brig.h" 48 | 49 | #define AMD_GCN_EXTENSION_NAME "amd:gcn" 50 | #define AMD_GCN_EXTENSION_OPCODE_PREFIX "amd_gcn" 51 | 52 | #define AMD_MIPMAP_EXTENSION_NAME "amd:mipmap" 53 | #define AMD_MIPMAP_EXTENSION_OPCODE_PREFIX "amd_mipmap" 54 | 55 | #define AMD_DG_EXTENSION_NAME "amd:dg" 56 | #define AMD_DG_EXTENSION_OPCODE_PREFIX "amd_dg" 57 | 58 | #define AMD_GCN_SEGMENT_NAME "region" 59 | #define AMD_MIPMAP_QUERY "nummiplevels" 60 | 61 | //} 62 | 63 | enum BrigOpcodeAmdGcn { 64 | BRIG_OPCODE_AMD_GCN_MADU = BRIG_OPCODE_FIRST_USER_DEFINED, 65 | BRIG_OPCODE_AMD_GCN_MADS, 66 | BRIG_OPCODE_AMD_GCN_MAX3, 67 | BRIG_OPCODE_AMD_GCN_MIN3, 68 | BRIG_OPCODE_AMD_GCN_MED3, 69 | BRIG_OPCODE_AMD_GCN_FLDEXP, 70 | BRIG_OPCODE_AMD_GCN_FREXP_EXP, 71 | BRIG_OPCODE_AMD_GCN_FREXP_MANT, 72 | BRIG_OPCODE_AMD_GCN_TRIG_PREOP, 73 | BRIG_OPCODE_AMD_GCN_BFM, 74 | BRIG_OPCODE_AMD_GCN_LD, 75 | BRIG_OPCODE_AMD_GCN_ST, 76 | BRIG_OPCODE_AMD_GCN_ATOMIC, 77 | BRIG_OPCODE_AMD_GCN_ATOMICNORET, 78 | BRIG_OPCODE_AMD_GCN_SLEEP, 79 | BRIG_OPCODE_AMD_GCN_PRIORITY, 80 | BRIG_OPCODE_AMD_GCN_REGIONALLOC, 81 | BRIG_OPCODE_AMD_GCN_MSAD, 82 | BRIG_OPCODE_AMD_GCN_QSAD, 83 | BRIG_OPCODE_AMD_GCN_MQSAD, 84 | BRIG_OPCODE_AMD_GCN_MQSAD4, 85 | BRIG_OPCODE_AMD_GCN_SADW, 86 | BRIG_OPCODE_AMD_GCN_SADD, 87 | BRIG_OPCODE_AMD_GCN_CONSUME, 88 | BRIG_OPCODE_AMD_GCN_APPEND, 89 | BRIG_OPCODE_AMD_GCN_B4XCHG, 90 | BRIG_OPCODE_AMD_GCN_B32XCHG, 91 | BRIG_OPCODE_AMD_GCN_MAX, 92 | BRIG_OPCODE_AMD_GCN_MIN, 93 | BRIG_OPCODE_AMD_GCN_DIVRELAXED, 94 | BRIG_OPCODE_AMD_GCN_DIVRELAXEDNARROW, 95 | 96 | BRIG_OPCODE_AMD_GCN_FIRST_UNUSED 97 | }; 98 | 99 | enum BrigOpcodeAmdMipmap { 100 | BRIG_OPCODE_AMD_MIPMAP_RDIMAGELOD = BRIG_OPCODE_AMD_GCN_FIRST_UNUSED, 101 | BRIG_OPCODE_AMD_MIPMAP_RDIMAGEGRAD, 102 | BRIG_OPCODE_AMD_MIPMAP_LDIMAGEMIP, 103 | BRIG_OPCODE_AMD_MIPMAP_STIMAGEMIP, 104 | BRIG_OPCODE_AMD_MIPMAP_QUERYIMAGE, 105 | 106 | BRIG_OPCODE_AMD_MIPMAP_FIRST_UNUSED 107 | }; 108 | 109 | enum BrigOpcodeAmdDg { 110 | BRIG_OPCODE_AMD_DG_GROUPSTATICSIZE = BRIG_OPCODE_AMD_MIPMAP_FIRST_UNUSED, 111 | BRIG_OPCODE_AMD_DG_GROUPTOTALSIZE, 112 | 113 | BRIG_OPCODE_AMD_DG_FIRST_UNUSED 114 | }; 115 | 116 | enum BrigSegmentAmdGcn { 117 | BRIG_SEGMENT_AMD_GCN = BRIG_SEGMENT_FIRST_USER_DEFINED, 118 | }; 119 | 120 | enum BrigImageQueryAmdMipmap { 121 | BRIG_IMAGE_QUERY_AMD_MIPMAP_NUMMIPLEVELS = BRIG_IMAGE_QUERY_FIRST_USER_DEFINED, 122 | }; 123 | 124 | //.ignore{ 125 | 126 | #endif 127 | 128 | //} 129 | -------------------------------------------------------------------------------- /libHSAIL-AMD/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(Perl REQUIRED) 2 | 3 | set(libhsail_amd_public_headers 4 | Brig_amd.h 5 | HSAILAmdExt.h 6 | ) 7 | 8 | set(libhsail_amd_srcs 9 | gcn.cpp 10 | mipmap.cpp 11 | HSAILAmdExt.cpp 12 | dg.cpp 13 | gcn.hdl 14 | mipmap.hdl 15 | dg.hdl 16 | ) 17 | 18 | set(generated_dir ${CMAKE_CURRENT_BINARY_DIR}/generated) 19 | file(MAKE_DIRECTORY ${generated_dir}) 20 | 21 | set(amd_generated_headers 22 | ${generated_dir}/InstValidation_gcn_gen.hpp 23 | ${generated_dir}/InstValidation_mipmap_gen.hpp 24 | ${generated_dir}/InstValidation_dg_gen.hpp 25 | ) 26 | 27 | set(amd_generated_srcs 28 | ${amd_generated_headers} 29 | ) 30 | 31 | set(libHSAIL-PATH ${CMAKE_CURRENT_SOURCE_DIR}/../libHSAIL) 32 | 33 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 34 | include_directories(${generated_dir}) 35 | 36 | add_custom_command( 37 | OUTPUT ${amd_generated_srcs} 38 | PRE_BUILD 39 | COMMAND ${PERL_EXECUTABLE} ${libHSAIL-PATH}/HDLProcessor.pl -target=validator ${libHSAIL-PATH}/HSAILDefs.hdl ${CMAKE_CURRENT_SOURCE_DIR}/gcn.hdl > ${generated_dir}/InstValidation_gcn_gen.hpp 40 | COMMAND ${PERL_EXECUTABLE} ${libHSAIL-PATH}/HDLProcessor.pl -target=validator ${libHSAIL-PATH}/HSAILDefs.hdl ${CMAKE_CURRENT_SOURCE_DIR}/mipmap.hdl > ${generated_dir}/InstValidation_mipmap_gen.hpp 41 | COMMAND ${PERL_EXECUTABLE} ${libHSAIL-PATH}/HDLProcessor.pl -target=validator ${libHSAIL-PATH}/HSAILDefs.hdl ${CMAKE_CURRENT_SOURCE_DIR}/dg.hdl > ${generated_dir}/InstValidation_dg_gen.hpp 42 | DEPENDS 43 | ${libHSAIL-PATH}/Brig.h 44 | gcn.hdl mipmap.hdl dg.hdl 45 | COMMENT "Generating libHSAIL-AMD sources" 46 | ) 47 | 48 | add_library(hsail-amd ${libhsail_amd_srcs} ${libhsail_amd_public_headers} ${amd_generated_headers}) 49 | 50 | add_dependencies(hsail-amd libhsail-includes) 51 | 52 | target_include_directories(hsail-amd PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${generated_dir}) 53 | target_link_libraries(hsail-amd hsail) 54 | 55 | install(TARGETS hsail-amd 56 | ARCHIVE DESTINATION lib 57 | LIBRARY DESTINATION lib 58 | ) 59 | 60 | install(FILES ${libhsail_amd_public_headers} DESTINATION include/libHSAIL-AMD) 61 | -------------------------------------------------------------------------------- /libHSAIL-AMD/HSAILAmdExt.cpp: -------------------------------------------------------------------------------- 1 | // University of Illinois/NCSA 2 | // Open Source License 3 | // 4 | // Copyright (c) 2013-2015, Advanced Micro Devices, Inc. 5 | // All rights reserved. 6 | // 7 | // Developed by: 8 | // 9 | // HSA Team 10 | // 11 | // Advanced Micro Devices, Inc 12 | // 13 | // www.amd.com 14 | // 15 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | // this software and associated documentation files (the "Software"), to deal with 17 | // the Software without restriction, including without limitation the rights to 18 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | // of the Software, and to permit persons to whom the Software is furnished to do 20 | // so, subject to the following conditions: 21 | // 22 | // * Redistributions of source code must retain the above copyright notice, 23 | // this list of conditions and the following disclaimers. 24 | // 25 | // * Redistributions in binary form must reproduce the above copyright notice, 26 | // this list of conditions and the following disclaimers in the 27 | // documentation and/or other materials provided with the distribution. 28 | // 29 | // * Neither the names of the LLVM Team, University of Illinois at 30 | // Urbana-Champaign, nor the names of its contributors may be used to 31 | // endorse or promote products derived from this Software without specific 32 | // prior written permission. 33 | // 34 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 36 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 | // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 40 | // SOFTWARE. 41 | 42 | #include "HSAILAmdExt.h" 43 | #include "HSAILImageExt.h" 44 | 45 | namespace amd { namespace hsail { 46 | 47 | #define AMD_EXTENSIONS_NUM (3) 48 | 49 | static const Extension* amdExtensions[AMD_EXTENSIONS_NUM + 1]; 50 | 51 | const Extension** getExtensions() 52 | { 53 | const Extension** e = amdExtensions; 54 | if (!*e) 55 | { 56 | *e++ = gcn::getExtension(); 57 | *e++ = mipmap::getExtension(); 58 | *e++ = dg::getExtension(); 59 | *e++ = 0; 60 | 61 | assert(amdExtensions + AMD_EXTENSIONS_NUM + 1 == e); 62 | } 63 | return amdExtensions; 64 | } 65 | 66 | class AmdExtManager : public ExtManager 67 | { 68 | public: 69 | AmdExtManager() 70 | { 71 | registerExtension(gcn::getExtension()); 72 | registerExtension(mipmap::getExtension()); 73 | registerExtension(dg::getExtension()); 74 | } 75 | }; 76 | 77 | const ExtManager& extensions() 78 | { 79 | static const AmdExtManager amdExtMgr; 80 | return amdExtMgr; 81 | } 82 | 83 | class AmdExtensionsRegistration 84 | { 85 | public: 86 | AmdExtensionsRegistration() 87 | { 88 | if (!registerExtension(gcn::getExtension())) { assert(false); } 89 | if (!registerExtension(mipmap::getExtension())) { assert(false); } 90 | if (!registerExtension(dg::getExtension())) { assert(false); } 91 | } 92 | }; 93 | 94 | // Automatic registration of AMD extensions 95 | // NB: does not work on Windows 96 | const AmdExtensionsRegistration amdExtRegistration; 97 | 98 | void registerExtensions() 99 | { 100 | extensions(); 101 | } 102 | 103 | }} // end of namespaces 104 | 105 | -------------------------------------------------------------------------------- /libHSAIL-AMD/HSAILAmdExt.h: -------------------------------------------------------------------------------- 1 | // University of Illinois/NCSA 2 | // Open Source License 3 | // 4 | // Copyright (c) 2013-2015, Advanced Micro Devices, Inc. 5 | // All rights reserved. 6 | // 7 | // Developed by: 8 | // 9 | // HSA Team 10 | // 11 | // Advanced Micro Devices, Inc 12 | // 13 | // www.amd.com 14 | // 15 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | // this software and associated documentation files (the "Software"), to deal with 17 | // the Software without restriction, including without limitation the rights to 18 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | // of the Software, and to permit persons to whom the Software is furnished to do 20 | // so, subject to the following conditions: 21 | // 22 | // * Redistributions of source code must retain the above copyright notice, 23 | // this list of conditions and the following disclaimers. 24 | // 25 | // * Redistributions in binary form must reproduce the above copyright notice, 26 | // this list of conditions and the following disclaimers in the 27 | // documentation and/or other materials provided with the distribution. 28 | // 29 | // * Neither the names of the LLVM Team, University of Illinois at 30 | // Urbana-Champaign, nor the names of its contributors may be used to 31 | // endorse or promote products derived from this Software without specific 32 | // prior written permission. 33 | // 34 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 36 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 | // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 40 | // SOFTWARE. 41 | 42 | 43 | #ifndef INCLUDED_HSAIL_AMD_EXT_H 44 | #define INCLUDED_HSAIL_AMD_EXT_H 45 | 46 | #include "HSAILExtension.h" 47 | #include "HSAILExtManager.h" 48 | 49 | namespace amd { 50 | namespace hsail { 51 | 52 | using namespace HSAIL_ASM; 53 | 54 | namespace gcn { const Extension* getExtension(); } 55 | namespace mipmap { const Extension* getExtension(); } 56 | namespace dg { const Extension* getExtension(); } 57 | 58 | const Extension** getExtensions(); 59 | 60 | const ExtManager& extensions(); 61 | 62 | void registerExtensions(); 63 | 64 | } // hsail namespace 65 | } // amd namespace 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /libHSAIL-AMD/dg.cpp: -------------------------------------------------------------------------------- 1 | // University of Illinois/NCSA 2 | // Open Source License 3 | // 4 | // Copyright (c) 2013-2015, Advanced Micro Devices, Inc. 5 | // All rights reserved. 6 | // 7 | // Developed by: 8 | // 9 | // HSA Team 10 | // 11 | // Advanced Micro Devices, Inc 12 | // 13 | // www.amd.com 14 | // 15 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | // this software and associated documentation files (the "Software"), to deal with 17 | // the Software without restriction, including without limitation the rights to 18 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | // of the Software, and to permit persons to whom the Software is furnished to do 20 | // so, subject to the following conditions: 21 | // 22 | // * Redistributions of source code must retain the above copyright notice, 23 | // this list of conditions and the following disclaimers. 24 | // 25 | // * Redistributions in binary form must reproduce the above copyright notice, 26 | // this list of conditions and the following disclaimers in the 27 | // documentation and/or other materials provided with the distribution. 28 | // 29 | // * Neither the names of the LLVM Team, University of Illinois at 30 | // Urbana-Champaign, nor the names of its contributors may be used to 31 | // endorse or promote products derived from this Software without specific 32 | // prior written permission. 33 | // 34 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 36 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 | // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 40 | // SOFTWARE. 41 | 42 | #include "Brig_amd.h" 43 | 44 | #include "HSAILScanner.h" 45 | #include "HSAILParser.h" 46 | #include "HSAILItems.h" 47 | #include "HSAILBrigantine.h" 48 | #include "HSAILInstProps.h" 49 | #include "HSAILGenericExtension.h" 50 | 51 | #include "HSAILValidatorBase.h" 52 | 53 | #include 54 | 55 | using namespace HSAIL_ASM; 56 | using namespace HSAIL_PROPS; 57 | 58 | using std::ostringstream; 59 | 60 | namespace amd { namespace hsail { namespace dg { 61 | 62 | //============================================================================= 63 | //============================================================================= 64 | //============================================================================= 65 | 66 | #include "InstValidation_dg_gen.hpp" 67 | 68 | //============================================================================= 69 | //============================================================================= 70 | //============================================================================= 71 | 72 | const ExtInstDesc dgDescTab[] = 73 | { 74 | {"amd_dg_groupstaticsize", BRIG_OPCODE_AMD_DG_GROUPSTATICSIZE, parseMnemoBasic, -1}, 75 | {"amd_dg_grouptotalsize", BRIG_OPCODE_AMD_DG_GROUPTOTALSIZE, parseMnemoBasic, -1}, 76 | }; 77 | 78 | #define DG_DESC_SIZE (sizeof(dgDescTab) / sizeof(ExtInstDesc)) 79 | 80 | class DgExtension : public GenericExtension 81 | { 82 | //============================================================================= 83 | //============================================================================= 84 | //============================================================================= 85 | public: 86 | 87 | virtual const char* getName() const 88 | { 89 | return AMD_DG_EXTENSION_NAME; 90 | } 91 | 92 | virtual bool isMnemoPrefix(const string& prefix) const 93 | { 94 | return (prefix == AMD_DG_EXTENSION_OPCODE_PREFIX); 95 | } 96 | 97 | //============================================================================= 98 | //============================================================================= 99 | //============================================================================= 100 | protected: 101 | virtual const char* getMnemoSuffix(const char* name) const { return name + strlen(AMD_DG_EXTENSION_OPCODE_PREFIX); } 102 | virtual const ExtInstDesc* getInstDescByIdx(unsigned idx) const { return dgDescTab + idx; } 103 | virtual unsigned getInstNum() const { return DG_DESC_SIZE; } 104 | }; 105 | 106 | //============================================================================= 107 | //============================================================================= 108 | //============================================================================= 109 | 110 | const Extension* getExtension() 111 | { 112 | static const DgExtension dg; 113 | return &dg; 114 | } 115 | 116 | //============================================================================= 117 | //============================================================================= 118 | //============================================================================= 119 | 120 | }}} // end of namespaces 121 | 122 | -------------------------------------------------------------------------------- /libHSAIL-AMD/dg.hdl: -------------------------------------------------------------------------------- 1 | // University of Illinois/NCSA 2 | // Open Source License 3 | // 4 | // Copyright (c) 2013-2015, Advanced Micro Devices, Inc. 5 | // All rights reserved. 6 | // 7 | // Developed by: 8 | // 9 | // HSA Team 10 | // 11 | // Advanced Micro Devices, Inc 12 | // 13 | // www.amd.com 14 | // 15 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | // this software and associated documentation files (the "Software"), to deal with 17 | // the Software without restriction, including without limitation the rights to 18 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | // of the Software, and to permit persons to whom the Software is furnished to do 20 | // so, subject to the following conditions: 21 | // 22 | // * Redistributions of source code must retain the above copyright notice, 23 | // this list of conditions and the following disclaimers. 24 | // 25 | // * Redistributions in binary form must reproduce the above copyright notice, 26 | // this list of conditions and the following disclaimers in the 27 | // documentation and/or other materials provided with the distribution. 28 | // 29 | // * Neither the names of the LLVM Team, University of Illinois at 30 | // Urbana-Champaign, nor the names of its contributors may be used to 31 | // endorse or promote products derived from this Software without specific 32 | // prior written permission. 33 | // 34 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 36 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 | // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 40 | // SOFTWARE. 41 | 42 | // ============================================================================ 43 | // ============================================================================ 44 | // DESCRIPTION OF DYNAMIC GROUP INSTRUCTIONS 45 | // ============================================================================ 46 | // ============================================================================ 47 | 48 | // ============================================================================ 49 | // DG static and total size 50 | 51 | Req dg_group 52 | { 53 | type = u32; 54 | 55 | d0 = reg; 56 | s1 = null; 57 | s2 = null; 58 | s3 = null; 59 | s4 = null; 60 | s5 = null; 61 | } 62 | 63 | Inst amd_dg_groupstaticsize (Basic, misc, dg_group) 64 | Inst amd_dg_grouptotalsize (Basic, misc, dg_group) 65 | 66 | // ============================================================================ 67 | -------------------------------------------------------------------------------- /libHSAIL/BrigDwarfGenerator.h: -------------------------------------------------------------------------------- 1 | // University of Illinois/NCSA 2 | // Open Source License 3 | // 4 | // Copyright (c) 2013-2015, Advanced Micro Devices, Inc. 5 | // All rights reserved. 6 | // 7 | // Developed by: 8 | // 9 | // HSA Team 10 | // 11 | // Advanced Micro Devices, Inc 12 | // 13 | // www.amd.com 14 | // 15 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | // this software and associated documentation files (the "Software"), to deal with 17 | // the Software without restriction, including without limitation the rights to 18 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | // of the Software, and to permit persons to whom the Software is furnished to do 20 | // so, subject to the following conditions: 21 | // 22 | // * Redistributions of source code must retain the above copyright notice, 23 | // this list of conditions and the following disclaimers. 24 | // 25 | // * Redistributions in binary form must reproduce the above copyright notice, 26 | // this list of conditions and the following disclaimers in the 27 | // documentation and/or other materials provided with the distribution. 28 | // 29 | // * Neither the names of the LLVM Team, University of Illinois at 30 | // Urbana-Champaign, nor the names of its contributors may be used to 31 | // endorse or promote products derived from this Software without specific 32 | // prior written permission. 33 | // 34 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 36 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 | // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 40 | // SOFTWARE. 41 | #ifndef BRIG_DWARF_GENERATOR_H__ 42 | #define BRIG_DWARF_GENERATOR_H__ 43 | 44 | #include 45 | #include 46 | 47 | namespace HSAIL_ASM 48 | { 49 | class BrigContainer; 50 | } 51 | 52 | 53 | namespace BrigDebug 54 | { 55 | 56 | // BrigDwarfGenerator generates debugging information from an existing 57 | // BRIG container, and can store that generated information into a BRIG 58 | // container 59 | // 60 | 61 | class BrigDwarfGenerator 62 | { 63 | public: 64 | virtual ~BrigDwarfGenerator() {} 65 | 66 | static BrigDwarfGenerator * Create( const std::string & producer, 67 | const std::string & compilationDirectory, 68 | const std::string & fileName, 69 | bool includeSource = false, const std::string& source = "", 70 | const std::string& producerOptions = ""); 71 | 72 | virtual void log(std::ostream* out) = 0; 73 | 74 | // generate debug info for a BRIG container 75 | // 76 | virtual bool generate( /*const*/ HSAIL_ASM::BrigContainer & c ) = 0; 77 | 78 | // store the generated debug info into a BRIG container 79 | // 80 | virtual bool storeInBrig( HSAIL_ASM::BrigContainer & c ) const = 0; 81 | 82 | protected: 83 | explicit BrigDwarfGenerator() {} 84 | 85 | }; 86 | 87 | } // end namespace BrigDebug 88 | 89 | #endif // BRIG_DWARF_GENERATOR_H__ 90 | -------------------------------------------------------------------------------- /libHSAIL/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(Perl REQUIRED) 2 | 3 | find_package(LibElf) 4 | 5 | if(LIBELF_FOUND) 6 | find_package(LibDwarf) 7 | endif() 8 | 9 | # Only try to build libbrigdwarf if we have both libelf and libdwarf. 10 | 11 | # TODO: The checks for libdwarf and libelf need to be refined. There 12 | # are several versions of each, and not all of them work here. 13 | # e.g. This does not build with the versions in macports. 14 | 15 | cmake_dependent_option(BUILD_LIBBRIGDWARF "Build libbrigdwarf" ON 16 | "LIBELF_FOUND;LIBDWARF_FOUND" OFF) 17 | 18 | message(STATUS "Building with BRIG DWARF support: ${BUILD_LIBBRIGDWARF}") 19 | 20 | if (LIBDWARF_USE_INIT_C) 21 | add_definitions("-DLIBDWARF_USE_INIT_C") 22 | endif() 23 | 24 | set(libhsail_public_headers 25 | Brig.h 26 | HSAILBrigContainer.h 27 | HSAILBrigObjectFile.h 28 | HSAILBrigantine.h 29 | HSAILConvertors.h 30 | HSAILDisassembler.h 31 | HSAILDump.h 32 | HSAILFloats.h 33 | HSAILInstProps.h 34 | HSAILItemBase.h 35 | HSAILItems.h 36 | HSAILParser.h 37 | HSAILSRef.h 38 | HSAILScanner.h 39 | HSAILScope.h 40 | HSAILTool.h 41 | HSAILTypeUtilities.h 42 | HSAILUtilities.h 43 | HSAILValidator.h 44 | HSAILValidatorBase.h 45 | HSAILb128_t.h 46 | hsail_c.h 47 | HSAILExtension.h 48 | HSAILGenericExtension.h 49 | HSAILExtManager.h 50 | HSAILImageExt.h 51 | ) 52 | 53 | set(libhsail_srcs 54 | HSAILBrigContainer.cpp 55 | HSAILBrigObjectFile.cpp 56 | HSAILBrigantine.cpp 57 | HSAILDisassembler.cpp 58 | HSAILDump.cpp 59 | HSAILFloats.cpp 60 | HSAILItems.cpp 61 | HSAILParser.cpp 62 | HSAILScanner.cpp 63 | HSAILScannerRules.cpp 64 | HSAILScannerRules.re2c 65 | HSAILTool.cpp 66 | HSAILUtilities.cpp 67 | HSAILValidator.cpp 68 | HSAILValidatorBase.cpp 69 | hsail_c.cpp 70 | HSAILExtManager.cpp 71 | HSAILInstProps.cpp 72 | HSAILImageExt.cpp 73 | generate.pl 74 | HDLProcessor.pl 75 | HSAILCore.hdl 76 | HSAILImage.hdl 77 | HSAILDefs.hdl 78 | BrigMeta.info 79 | ) 80 | 81 | set(generated_dir ${CMAKE_CURRENT_BINARY_DIR}/generated) 82 | 83 | set(generated_headers 84 | ${generated_dir}/HSAILBrigInstUtils_gen.hpp 85 | ${generated_dir}/HSAILBrigPropsName_gen.hpp 86 | ${generated_dir}/HSAILBrigValidation_gen.hpp 87 | ${generated_dir}/HSAILItems_gen.hpp 88 | ${generated_dir}/HSAILBrigPropsAcc_gen.hpp 89 | ${generated_dir}/HSAILBrigPropsVisitor_gen.hpp 90 | ${generated_dir}/HSAILInitBrig_gen.hpp 91 | ${generated_dir}/HSAILScannerRules_gen_re2c.hpp 92 | ${generated_dir}/HSAILBrigPropsFastAcc_gen.hpp 93 | ${generated_dir}/HSAILBrigStaticChecks_gen.hpp 94 | ${generated_dir}/HSAILInstValidation_core_gen.hpp 95 | ${generated_dir}/HSAILInstValidation_image_gen.hpp 96 | ${generated_dir}/HSAILParserUtilities_gen.hpp 97 | ${generated_dir}/HSAILTemplateUtilities_gen.hpp 98 | ${generated_dir}/HSAILBrigProps_gen.hpp 99 | ${generated_dir}/HSAILBrigUtilities_gen.hpp 100 | ${generated_dir}/HSAILItemImpls_gen.hpp 101 | ${generated_dir}/HSAILPropAccessors_gen.hpp 102 | ${generated_dir}/HSAILBrigEnum2str_gen.hpp 103 | ${generated_dir}/HSAILVisitItems_gen.hpp 104 | ) 105 | 106 | set(generated_srcs 107 | ${generated_headers} 108 | ${generated_dir}/HSAILScannerRules_gen.re2c 109 | ) 110 | 111 | set(libHSAIL-PATH ${CMAKE_CURRENT_SOURCE_DIR}) 112 | 113 | include_directories(${libHSAIL-PATH}) 114 | include_directories(${generated_dir}) 115 | 116 | add_custom_command( 117 | OUTPUT ${generated_srcs} 118 | PRE_BUILD 119 | COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generate.pl 120 | -re2c ${RE2C_EXECUTABLE} 121 | ${CMAKE_CURRENT_SOURCE_DIR} 122 | ${generated_dir} 123 | DEPENDS 124 | Brig.h 125 | HSAILCore.hdl 126 | HSAILImage.hdl 127 | HSAILDefs.hdl 128 | BrigMeta.info 129 | COMMENT "Generating libHSAIL sources" 130 | ) 131 | 132 | if(BUILD_LIBBRIGDWARF) 133 | set(libbrigdwarf_srcs 134 | BrigDwarfGenerator.cpp 135 | hsa_dwarf.h 136 | BrigDwarfGenerator.h 137 | SectionHeaderTable.h 138 | ) 139 | 140 | list(APPEND libhsail_public_headers 141 | BrigDwarfGenerator.h 142 | hsa_dwarf.h 143 | ) 144 | 145 | include_directories(${LIBELF_INCLUDE_DIRS}) 146 | include_directories(${LIBDWARF_INCLUDE_DIRS}) 147 | else() 148 | set(libbrigdwarf_srcs) 149 | endif() 150 | 151 | add_custom_target(libhsail-includes ALL DEPENDS ${generated_srcs}) 152 | add_library(hsail ${libhsail_srcs} ${libhsail_public_headers} ${libbrigdwarf_srcs} ${generated_headers}) 153 | if(BUILD_LIBBRIGDWARF) 154 | add_definitions(-DWITH_LIBBRIGDWARF=1) 155 | endif() 156 | add_dependencies(hsail libhsail-includes) 157 | 158 | target_include_directories(hsail PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${generated_dir}) 159 | 160 | if(BUILD_LIBBRIGDWARF) 161 | target_link_libraries(hsail dwarf) 162 | target_link_libraries(hsail elf) 163 | endif() 164 | if(UNIX) 165 | target_link_libraries(hsail dl) 166 | endif() 167 | 168 | install(TARGETS hsail 169 | ARCHIVE DESTINATION lib COMPONENT libhsail 170 | LIBRARY DESTINATION lib COMPONENT libhsail 171 | ) 172 | 173 | install(FILES ${libhsail_public_headers} ${generated_headers} DESTINATION include/libHSAIL COMPONENT libhsail) 174 | -------------------------------------------------------------------------------- /libHSAIL/HSAILDump.h: -------------------------------------------------------------------------------- 1 | // University of Illinois/NCSA 2 | // Open Source License 3 | // 4 | // Copyright (c) 2013-2015, Advanced Micro Devices, Inc. 5 | // All rights reserved. 6 | // 7 | // Developed by: 8 | // 9 | // HSA Team 10 | // 11 | // Advanced Micro Devices, Inc 12 | // 13 | // www.amd.com 14 | // 15 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | // this software and associated documentation files (the "Software"), to deal with 17 | // the Software without restriction, including without limitation the rights to 18 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | // of the Software, and to permit persons to whom the Software is furnished to do 20 | // so, subject to the following conditions: 21 | // 22 | // * Redistributions of source code must retain the above copyright notice, 23 | // this list of conditions and the following disclaimers. 24 | // 25 | // * Redistributions in binary form must reproduce the above copyright notice, 26 | // this list of conditions and the following disclaimers in the 27 | // documentation and/or other materials provided with the distribution. 28 | // 29 | // * Neither the names of the LLVM Team, University of Illinois at 30 | // Urbana-Champaign, nor the names of its contributors may be used to 31 | // endorse or promote products derived from this Software without specific 32 | // prior written permission. 33 | // 34 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 36 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 | // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 40 | // SOFTWARE. 41 | #pragma once 42 | #ifndef INCLUDED_HSAIL_DUMP_H 43 | #define INCLUDED_HSAIL_DUMP_H 44 | 45 | #include 46 | 47 | #include "HSAILBrigContainer.h" 48 | #include "HSAILExtManager.h" 49 | 50 | namespace HSAIL_ASM { 51 | 52 | void dump(BrigContainer &c, std::ostream& out, const ExtManager& extMgr = registeredExtensions()); 53 | void dumpItem(std::ostream& out, Code item, const ExtManager& extMgr = registeredExtensions()); 54 | void dumpItem(std::ostream& out, Operand item, const ExtManager& extMgr = registeredExtensions()); 55 | void dumpItem(std::ostream& out, Offset offset, BrigSectionImpl* section, BrigSectionIndex id, const ExtManager& extMgr = registeredExtensions()); 56 | 57 | } 58 | 59 | #endif -------------------------------------------------------------------------------- /libHSAIL/HSAILImage.hdl: -------------------------------------------------------------------------------- 1 | // University of Illinois/NCSA 2 | // Open Source License 3 | // 4 | // Copyright (c) 2013-2015, Advanced Micro Devices, Inc. 5 | // All rights reserved. 6 | // 7 | // Developed by: 8 | // 9 | // HSA Team 10 | // 11 | // Advanced Micro Devices, Inc 12 | // 13 | // www.amd.com 14 | // 15 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | // this software and associated documentation files (the "Software"), to deal with 17 | // the Software without restriction, including without limitation the rights to 18 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | // of the Software, and to permit persons to whom the Software is furnished to do 20 | // so, subject to the following conditions: 21 | // 22 | // * Redistributions of source code must retain the above copyright notice, 23 | // this list of conditions and the following disclaimers. 24 | // 25 | // * Redistributions in binary form must reproduce the above copyright notice, 26 | // this list of conditions and the following disclaimers in the 27 | // documentation and/or other materials provided with the distribution. 28 | // 29 | // * Neither the names of the LLVM Team, University of Illinois at 30 | // Urbana-Champaign, nor the names of its contributors may be used to 31 | // endorse or promote products derived from this Software without specific 32 | // prior written permission. 33 | // 34 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 36 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 | // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 40 | // SOFTWARE. 41 | 42 | // ============================================================================ 43 | // ============================================================================ 44 | // DESCRIPTION OF IMAGE EXTENSION 45 | // ============================================================================ 46 | // ============================================================================ 47 | 48 | // ============================================================================ 49 | // RD_IMAGE 50 | 51 | Req rdimage 52 | { 53 | type = (s, u, f)32, f16; 54 | itype = roimg; 55 | ctype = (s, f)32; 56 | geometry = 1d, 2d, 3d, 1da, 2da, 2ddepth, 2dadepth; 57 | eqclass = any; 58 | 59 | s1 = reg.itype; 60 | s2 = reg.samp; 61 | s4 = null; 62 | s5 = null; 63 | 64 | { geometry = 1d ? d0 = vec.4; s3 = (reg, imm).ctype } 65 | { geometry = 2d, 1da ? d0 = vec.4; s3 = vec.2.ctype } 66 | { geometry = 3d, 2da ? d0 = vec.4; s3 = vec.3.ctype } 67 | { geometry = 2ddepth ? d0 = reg; s3 = vec.2.ctype } 68 | { geometry = 2dadepth ? d0 = reg; s3 = vec.3.ctype } 69 | ; 70 | } 71 | 72 | Inst rdimage(Image, image, rdimage) 73 | 74 | // ============================================================================ 75 | // LDIMAGE, STIMAGE 76 | 77 | Req ld.st.image 78 | { 79 | type = (s, u, f)32, f16; 80 | ctype = u32; 81 | geometry = any; 82 | eqclass = any; 83 | } 84 | 85 | Req ld.image 86 | { 87 | ld.st.image; 88 | itype = roimg, rwimg; 89 | 90 | { geometry = 1d, 1db ? d0 = vec.4; s2 = (reg, imm).ctype } 91 | { geometry = 2d, 1da ? d0 = vec.4; s2 = vec.2.ctype } 92 | { geometry = 3d, 2da ? d0 = vec.4; s2 = vec.3.ctype } 93 | { geometry = 2ddepth ? d0 = reg; s2 = vec.2.ctype } 94 | { geometry = 2dadepth ? d0 = reg; s2 = vec.3.ctype } 95 | ; 96 | 97 | s1 = reg.itype; 98 | s3 = null; 99 | s4 = null; 100 | s5 = null; 101 | } 102 | 103 | Req st.image 104 | { 105 | ld.st.image; 106 | itype = woimg, rwimg; 107 | 108 | { geometry = 1d, 1db ? s0 = vec.4; s2 = (reg, imm).ctype } 109 | { geometry = 2d, 1da ? s0 = vec.4; s2 = vec.2.ctype } 110 | { geometry = 3d, 2da ? s0 = vec.4; s2 = vec.3.ctype } 111 | { geometry = 2ddepth ? s0 = reg; s2 = vec.2.ctype } 112 | { geometry = 2dadepth ? s0 = reg; s2 = vec.3.ctype } 113 | ; 114 | 115 | s1 = reg.itype; 116 | s3 = null; 117 | s4 = null; 118 | s5 = null; 119 | } 120 | 121 | Inst ldimage(Image, image, ld.image) 122 | Inst stimage(Image, image, st.image) 123 | 124 | // ============================================================================ 125 | // QUERY 126 | 127 | Req queryimage 128 | { 129 | type = u32; 130 | itype = roimg, rwimg, woimg; 131 | geometry = any; 132 | iprop = any; 133 | 134 | { iprop = width, channeltype, channelorder ? geometry = any } 135 | { iprop = depth ? geometry = 3d } 136 | { iprop = array ? geometry = 1da, 2da, 2dadepth } 137 | { iprop = height ? geometry = 2d, 3d, 2da, 2ddepth, 2dadepth } 138 | ; 139 | 140 | d0 = reg; 141 | s1 = reg.itype; 142 | s2 = null; 143 | s3 = null; 144 | s4 = null; 145 | s5 = null; 146 | } 147 | 148 | Req querysampler 149 | { 150 | type = u32; 151 | sprop = any; 152 | 153 | d0 = reg; 154 | s1 = reg.samp; 155 | s2 = null; 156 | s3 = null; 157 | s4 = null; 158 | s5 = null; 159 | } 160 | 161 | Inst queryimage (Query.Image, image, queryimage) 162 | Inst querysampler(Query.Sampler, image, querysampler) 163 | 164 | // ============================================================================ 165 | // IMAGEFENCE 166 | 167 | Req imagefence 168 | { 169 | type = none; 170 | 171 | s0 = null; 172 | s1 = null; 173 | s2 = null; 174 | s3 = null; 175 | s4 = null; 176 | s5 = null; 177 | } 178 | 179 | Inst imagefence(Basic, image, imagefence) 180 | 181 | // ============================================================================ 182 | -------------------------------------------------------------------------------- /libHSAIL/HSAILImageExt.h: -------------------------------------------------------------------------------- 1 | // University of Illinois/NCSA 2 | // Open Source License 3 | // 4 | // Copyright (c) 2013-2015, Advanced Micro Devices, Inc. 5 | // All rights reserved. 6 | // 7 | // Developed by: 8 | // 9 | // HSA Team 10 | // 11 | // Advanced Micro Devices, Inc 12 | // 13 | // www.amd.com 14 | // 15 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | // this software and associated documentation files (the "Software"), to deal with 17 | // the Software without restriction, including without limitation the rights to 18 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | // of the Software, and to permit persons to whom the Software is furnished to do 20 | // so, subject to the following conditions: 21 | // 22 | // * Redistributions of source code must retain the above copyright notice, 23 | // this list of conditions and the following disclaimers. 24 | // 25 | // * Redistributions in binary form must reproduce the above copyright notice, 26 | // this list of conditions and the following disclaimers in the 27 | // documentation and/or other materials provided with the distribution. 28 | // 29 | // * Neither the names of the LLVM Team, University of Illinois at 30 | // Urbana-Champaign, nor the names of its contributors may be used to 31 | // endorse or promote products derived from this Software without specific 32 | // prior written permission. 33 | // 34 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 36 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 | // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 40 | // SOFTWARE. 41 | 42 | #ifndef INCLUDED_HSAIL_IMAGE_EXT_H 43 | #define INCLUDED_HSAIL_IMAGE_EXT_H 44 | 45 | #include "HSAILExtension.h" 46 | 47 | namespace hsail { namespace image { 48 | 49 | using namespace HSAIL_ASM; 50 | 51 | const Extension* getExtension(); 52 | 53 | }} 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /libHSAIL/HSAILItems.cpp: -------------------------------------------------------------------------------- 1 | // University of Illinois/NCSA 2 | // Open Source License 3 | // 4 | // Copyright (c) 2013-2015, Advanced Micro Devices, Inc. 5 | // All rights reserved. 6 | // 7 | // Developed by: 8 | // 9 | // HSA Team 10 | // 11 | // Advanced Micro Devices, Inc 12 | // 13 | // www.amd.com 14 | // 15 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | // this software and associated documentation files (the "Software"), to deal with 17 | // the Software without restriction, includ ing without limitation the rights to 18 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | // of the Software, and to permit persons to whom the Software is furnished to do 20 | // so, subject to the following conditions: 21 | // 22 | // * Redistributions of source code must retain the above copyright notice, 23 | // this list of conditions and the following disclaimers. 24 | // 25 | // * Redistributions in binary form must reproduce the above copyright notice, 26 | // this list of conditions and the following disclaimers in the 27 | // documentation and/or other materials provided with the distribution. 28 | // 29 | // * Neither the names of the LLVM Team, University of Illinois at 30 | // Urbana-Champaign, nor the names of its contributors may be used to 31 | // endorse or promote products derived from this Software without specific 32 | // prior written permission. 33 | // 34 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 36 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 | // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 40 | // SOFTWARE. 41 | #include "HSAILItems.h" 42 | 43 | // #include "HSAILBrigStaticChecks_gen.hpp" 44 | 45 | namespace HSAIL_ASM 46 | { 47 | 48 | //#include "HSAILBrigStaticChecks_gen.hpp" 49 | #include "HSAILBrigUtilities_gen.hpp" 50 | #include "HSAILInitBrig_gen.hpp" 51 | 52 | } 53 | -------------------------------------------------------------------------------- /libHSAIL/HSAILItems.h: -------------------------------------------------------------------------------- 1 | // University of Illinois/NCSA 2 | // Open Source License 3 | // 4 | // Copyright (c) 2013-2015, Advanced Micro Devices, Inc. 5 | // All rights reserved. 6 | // 7 | // Developed by: 8 | // 9 | // HSA Team 10 | // 11 | // Advanced Micro Devices, Inc 12 | // 13 | // www.amd.com 14 | // 15 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | // this software and associated documentation files (the "Software"), to deal with 17 | // the Software without restriction, including without limitation the rights to 18 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | // of the Software, and to permit persons to whom the Software is furnished to do 20 | // so, subject to the following conditions: 21 | // 22 | // * Redistributions of source code must retain the above copyright notice, 23 | // this list of conditions and the following disclaimers. 24 | // 25 | // * Redistributions in binary form must reproduce the above copyright notice, 26 | // this list of conditions and the following disclaimers in the 27 | // documentation and/or other materials provided with the distribution. 28 | // 29 | // * Neither the names of the LLVM Team, University of Illinois at 30 | // Urbana-Champaign, nor the names of its contributors may be used to 31 | // endorse or promote products derived from this Software without specific 32 | // prior written permission. 33 | // 34 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 36 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 | // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 40 | // SOFTWARE. 41 | #pragma once 42 | #ifndef INCLUDED_HSAIL_ITEMS_H 43 | #define INCLUDED_HSAIL_ITEMS_H 44 | 45 | #include "HSAILItemBase.h" 46 | #include "HSAILFloats.h" 47 | 48 | namespace HSAIL_ASM { 49 | 50 | class Code; 51 | class Operand; 52 | typedef ListRef CodeListRef; 53 | typedef ListRef OperandListRef; 54 | 55 | #include "HSAILItems_gen.hpp" 56 | 57 | #include "HSAILItemImpls_gen.hpp" 58 | 59 | #include "HSAILVisitItems_gen.hpp" 60 | 61 | // shortcut for "final" classes 62 | template 63 | inline RetType dispatchByItemKind_gen(Item item, Visitor& vis) { 64 | return vis(item); // just self visit 65 | } 66 | 67 | template 68 | inline RetType dispatchByItemKind(Item item, Visitor& vis) { 69 | return dispatchByItemKind_gen(item,vis); 70 | } 71 | 72 | template 73 | inline RetType dispatchByItemKind(Item item, const Visitor& vis) { 74 | return dispatchByItemKind_gen(item,vis); 75 | } 76 | 77 | template 78 | inline void dispatchByItemKind(Item item, Visitor& vis) { 79 | dispatchByItemKind_gen(item,vis); 80 | } 81 | 82 | template 83 | inline void dispatchByItemKind(Item item, const Visitor& vis) { 84 | dispatchByItemKind_gen(item,vis); 85 | } 86 | 87 | 88 | // enumerateFieldsImpl is a level of indirection between 89 | // enumerateFields and enumerateFields_gen to allow 90 | // customized behaviour for specific items 91 | 92 | // by default - just call enumerateFields_gen version 93 | template 94 | inline void enumerateFieldsImpl(Item item, Visitor& vis) { 95 | enumerateFields_gen(item, vis); 96 | } 97 | 98 | 99 | template 100 | class FieldEnumerator { 101 | Visitor& vis; 102 | public: 103 | FieldEnumerator(Visitor& vis_) : vis(vis_) { } 104 | template 105 | void operator()(Item obj) { 106 | enumerateFieldsImpl(obj, vis); 107 | } 108 | }; 109 | 110 | // enumerateFields dispatches visitor to the actual item kind (like a dynamic_cast) 111 | template 112 | inline void enumerateFields(Item item, Visitor& vis) { 113 | FieldEnumerator fieldEnum(vis); 114 | dispatchByItemKind(item,fieldEnum); 115 | } 116 | 117 | // version for const Visitor 118 | template 119 | inline void enumerateFields(Item item, const Visitor& vis) { 120 | FieldEnumerator fieldEnum(vis); 121 | dispatchByItemKind(item,fieldEnum); 122 | } 123 | 124 | } // namespace HSAIL_ASM 125 | 126 | #endif // INCLUDED_HSAIL_ITEMS_H 127 | 128 | -------------------------------------------------------------------------------- /libHSAIL/HSAILScannerRules.cpp: -------------------------------------------------------------------------------- 1 | // University of Illinois/NCSA 2 | // Open Source License 3 | // 4 | // Copyright (c) 2013-2015, Advanced Micro Devices, Inc. 5 | // All rights reserved. 6 | // 7 | // Developed by: 8 | // 9 | // HSA Team 10 | // 11 | // Advanced Micro Devices, Inc 12 | // 13 | // www.amd.com 14 | // 15 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | // this software and associated documentation files (the "Software"), to deal with 17 | // the Software without restriction, including without limitation the rights to 18 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | // of the Software, and to permit persons to whom the Software is furnished to do 20 | // so, subject to the following conditions: 21 | // 22 | // * Redistributions of source code must retain the above copyright notice, 23 | // this list of conditions and the following disclaimers. 24 | // 25 | // * Redistributions in binary form must reproduce the above copyright notice, 26 | // this list of conditions and the following disclaimers in the 27 | // documentation and/or other materials provided with the distribution. 28 | // 29 | // * Neither the names of the LLVM Team, University of Illinois at 30 | // Urbana-Champaign, nor the names of its contributors may be used to 31 | // endorse or promote products derived from this Software without specific 32 | // prior written permission. 33 | // 34 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 36 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 | // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 40 | // SOFTWARE. 41 | #include "HSAILScanner.h" 42 | #include "Brig.h" 43 | #include 44 | #include 45 | 46 | #include "HSAILScannerRules_gen_re2c.hpp" 47 | -------------------------------------------------------------------------------- /libHSAIL/HSAILScope.h: -------------------------------------------------------------------------------- 1 | // University of Illinois/NCSA 2 | // Open Source License 3 | // 4 | // Copyright (c) 2013-2015, Advanced Micro Devices, Inc. 5 | // All rights reserved. 6 | // 7 | // Developed by: 8 | // 9 | // HSA Team 10 | // 11 | // Advanced Micro Devices, Inc 12 | // 13 | // www.amd.com 14 | // 15 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | // this software and associated documentation files (the "Software"), to deal with 17 | // the Software without restriction, including without limitation the rights to 18 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | // of the Software, and to permit persons to whom the Software is furnished to do 20 | // so, subject to the following conditions: 21 | // 22 | // * Redistributions of source code must retain the above copyright notice, 23 | // this list of conditions and the following disclaimers. 24 | // 25 | // * Redistributions in binary form must reproduce the above copyright notice, 26 | // this list of conditions and the following disclaimers in the 27 | // documentation and/or other materials provided with the distribution. 28 | // 29 | // * Neither the names of the LLVM Team, University of Illinois at 30 | // Urbana-Champaign, nor the names of its contributors may be used to 31 | // endorse or promote products derived from this Software without specific 32 | // prior written permission. 33 | // 34 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 36 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 | // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 40 | // SOFTWARE. 41 | #pragma once 42 | #ifndef INCLUDED_HSAIL_SCOPE_H 43 | #define INCLUDED_HSAIL_SCOPE_H 44 | 45 | namespace HSAIL_ASM { 46 | 47 | class Scope { 48 | typedef std::map Map; 49 | Map d_map; 50 | BrigContainer* d_container_p; 51 | 52 | public: 53 | // TBD READING FUNCTIONALITY (LOAD KERN/FUNC/GLOBAL INTO THIS) 54 | Scope(BrigContainer* container) 55 | : d_container_p(container) 56 | { 57 | } 58 | 59 | BrigContainer* container() const { return d_container_p; } 60 | 61 | template 62 | Item get(const SRef& name); 63 | 64 | template 65 | bool add(const SRef& name, const Item& item); 66 | 67 | template 68 | bool replaceOtherwiseAdd(const SRef& name, const Item& item); 69 | }; 70 | 71 | template 72 | Item Scope::get(const SRef& name) { 73 | Map::iterator p = d_map.find(std::string(name.begin, name.end)); 74 | if (p != d_map.end()) { 75 | return typename Item::Kind(d_container_p, p->second); 76 | } 77 | else { 78 | return Item(); 79 | } 80 | } 81 | 82 | template 83 | bool Scope::add(const SRef& name, const Item& item) { 84 | std::pair res = 85 | d_map.insert(std::make_pair(std::string(name.begin,name.end), item.brigOffset())); 86 | return res.second; 87 | } 88 | 89 | template 90 | bool Scope::replaceOtherwiseAdd(const SRef& name, const Item& item) { 91 | std::pair res = 92 | d_map.insert(std::make_pair(std::string(name.begin,name.end), item.brigOffset())); 93 | if (res.second==false) { 94 | (*res.first).second = item.brigOffset(); 95 | } 96 | return res.second; 97 | } 98 | 99 | } // namespace HSAIL_ASM 100 | 101 | #endif // INCLUDED_HSAIL_SCOPE_H 102 | 103 | -------------------------------------------------------------------------------- /libHSAIL/HSAILValidator.h: -------------------------------------------------------------------------------- 1 | // University of Illinois/NCSA 2 | // Open Source License 3 | // 4 | // Copyright (c) 2013-2015, Advanced Micro Devices, Inc. 5 | // All rights reserved. 6 | // 7 | // Developed by: 8 | // 9 | // HSA Team 10 | // 11 | // Advanced Micro Devices, Inc 12 | // 13 | // www.amd.com 14 | // 15 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | // this software and associated documentation files (the "Software"), to deal with 17 | // the Software without restriction, including without limitation the rights to 18 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | // of the Software, and to permit persons to whom the Software is furnished to do 20 | // so, subject to the following conditions: 21 | // 22 | // * Redistributions of source code must retain the above copyright notice, 23 | // this list of conditions and the following disclaimers. 24 | // 25 | // * Redistributions in binary form must reproduce the above copyright notice, 26 | // this list of conditions and the following disclaimers in the 27 | // documentation and/or other materials provided with the distribution. 28 | // 29 | // * Neither the names of the LLVM Team, University of Illinois at 30 | // Urbana-Champaign, nor the names of its contributors may be used to 31 | // endorse or promote products derived from this Software without specific 32 | // prior written permission. 33 | // 34 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 36 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 | // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 40 | // SOFTWARE. 41 | //===-- HSAILValidator.cpp - HSAIL Validator ----------------------===// 42 | 43 | #ifndef INCLUDED_HSAIL_VALIDATOR_H 44 | #define INCLUDED_HSAIL_VALIDATOR_H 45 | 46 | #include "HSAILBrigContainer.h" 47 | #include "HSAILExtManager.h" 48 | #include "HSAILItemBase.h" 49 | #include "HSAILItems.h" 50 | #include 51 | #include 52 | 53 | using std::istream; 54 | using std::ostream; 55 | 56 | namespace HSAIL_ASM { 57 | 58 | //============================================================================ 59 | 60 | class ValidatorImpl; 61 | 62 | class Validator 63 | { 64 | ValidatorImpl *impl; 65 | 66 | Validator(const Validator&); // non-copyable 67 | const Validator &operator=(const Validator &); // not assignable 68 | 69 | //========================================================================== 70 | // Public Validator API 71 | public: 72 | Validator(BrigContainer &c, const ExtManager& extMgr = registeredExtensions()); 73 | ~Validator(); 74 | 75 | bool validate(bool disasmOnError = false) const; 76 | 77 | std::string getErrorMsg(istream *is) const; 78 | void dumpError(ostream* os) const; 79 | int getErrorCode() const; 80 | }; 81 | 82 | } // namespace HSAIL_ASM 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /libHSAIL/HSAILb128_t.h: -------------------------------------------------------------------------------- 1 | // University of Illinois/NCSA 2 | // Open Source License 3 | // 4 | // Copyright (c) 2013-2015, Advanced Micro Devices, Inc. 5 | // All rights reserved. 6 | // 7 | // Developed by: 8 | // 9 | // HSA Team 10 | // 11 | // Advanced Micro Devices, Inc 12 | // 13 | // www.amd.com 14 | // 15 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | // this software and associated documentation files (the "Software"), to deal with 17 | // the Software without restriction, including without limitation the rights to 18 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | // of the Software, and to permit persons to whom the Software is furnished to do 20 | // so, subject to the following conditions: 21 | // 22 | // * Redistributions of source code must retain the above copyright notice, 23 | // this list of conditions and the following disclaimers. 24 | // 25 | // * Redistributions in binary form must reproduce the above copyright notice, 26 | // this list of conditions and the following disclaimers in the 27 | // documentation and/or other materials provided with the distribution. 28 | // 29 | // * Neither the names of the LLVM Team, University of Illinois at 30 | // Urbana-Champaign, nor the names of its contributors may be used to 31 | // endorse or promote products derived from this Software without specific 32 | // prior written permission. 33 | // 34 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 36 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 | // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 40 | // SOFTWARE. 41 | #pragma once 42 | #ifndef INCLUDED_HSAIL_b128_t_H 43 | #define INCLUDED_HSAIL_b128_t_H 44 | 45 | #include "HSAILTypeUtilities.h" 46 | #include 47 | #include 48 | 49 | namespace HSAIL_ASM 50 | { 51 | 52 | class b128_t 53 | { 54 | uint64_t m_value[2]; 55 | 56 | template 57 | void uset(UnsT v ) { 58 | m_value[0] = v; 59 | m_value[1] = 0; 60 | } 61 | 62 | template 63 | void sset(SignT v) { 64 | m_value[0] = static_cast(v); 65 | m_value[1] = v < 0 ? -1LL : 0; 66 | } 67 | 68 | public: 69 | 70 | b128_t() { 71 | m_value[0] = 0; 72 | m_value[1] = 0; 73 | } 74 | 75 | b128_t(uint64_t lowPart, uint64_t highPart) { 76 | m_value[0] = lowPart; 77 | m_value[1] = highPart; 78 | } 79 | 80 | explicit b128_t(uint64_t (&v)[2]) { 81 | m_value[0] = v[0]; 82 | m_value[1] = v[1]; 83 | } 84 | 85 | explicit b128_t(uint8_t v) { uset(v); } 86 | explicit b128_t(uint16_t v) { uset(v); } 87 | explicit b128_t(uint32_t v) { uset(v); } 88 | explicit b128_t(uint64_t v) { uset(v); } 89 | explicit b128_t(int8_t v) { sset(v); } 90 | explicit b128_t(int16_t v) { sset(v); } 91 | explicit b128_t(int32_t v) { sset(v); } 92 | explicit b128_t(int64_t v) { sset(v); } 93 | 94 | void operator=(uint8_t v) { uset(v); } 95 | void operator=(uint16_t v) { uset(v); } 96 | void operator=(uint32_t v) { uset(v); } 97 | void operator=(uint64_t v) { uset(v); } 98 | void operator=(int8_t v) { sset(v); } 99 | void operator=(int16_t v) { sset(v); } 100 | void operator=(int32_t v) { sset(v); } 101 | void operator=(int64_t v) { sset(v); } 102 | 103 | friend uint64_t lowPart(const b128_t& v); 104 | friend uint64_t hiPart(const b128_t& v); 105 | 106 | operator uint8_t() const { return static_cast(m_value[0]); } 107 | operator uint16_t() const { return static_cast(m_value[0]); } 108 | operator uint32_t() const { return static_cast(m_value[0]); } 109 | operator uint64_t() const { return static_cast(m_value[0]); } 110 | }; 111 | 112 | template <> struct value_class : unsigned_int_class {}; 113 | 114 | inline uint64_t lowPart(const b128_t& v) { return v.m_value[0]; } 115 | inline uint64_t hiPart(const b128_t& v) { return v.m_value[1]; } 116 | 117 | template 118 | inline OS& operator << (OS& os,const b128_t& v) { 119 | os << hiPart(v); 120 | os << lowPart(v); 121 | return os; 122 | } 123 | 124 | } 125 | 126 | #endif -------------------------------------------------------------------------------- /libHSAIL/SectionHeaderTable.h: -------------------------------------------------------------------------------- 1 | // University of Illinois/NCSA 2 | // Open Source License 3 | // 4 | // Copyright (c) 2013-2015, Advanced Micro Devices, Inc. 5 | // All rights reserved. 6 | // 7 | // Developed by: 8 | // 9 | // HSA Team 10 | // 11 | // Advanced Micro Devices, Inc 12 | // 13 | // www.amd.com 14 | // 15 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | // this software and associated documentation files (the "Software"), to deal with 17 | // the Software without restriction, including without limitation the rights to 18 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | // of the Software, and to permit persons to whom the Software is furnished to do 20 | // so, subject to the following conditions: 21 | // 22 | // * Redistributions of source code must retain the above copyright notice, 23 | // this list of conditions and the following disclaimers. 24 | // 25 | // * Redistributions in binary form must reproduce the above copyright notice, 26 | // this list of conditions and the following disclaimers in the 27 | // documentation and/or other materials provided with the distribution. 28 | // 29 | // * Neither the names of the LLVM Team, University of Illinois at 30 | // Urbana-Champaign, nor the names of its contributors may be used to 31 | // endorse or promote products derived from this Software without specific 32 | // prior written permission. 33 | // 34 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 36 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 | // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 40 | // SOFTWARE. 41 | #ifndef SECTION_HEADER_H__ 42 | #define SECTION_HEADER_H__ 43 | 44 | #include 45 | 46 | namespace BrigDebug 47 | { 48 | 49 | class SectionHeaderTable 50 | { 51 | public: 52 | SectionHeaderTable() 53 | { 54 | m_data.push_back( '\0' ); 55 | } 56 | 57 | virtual ~SectionHeaderTable() {} 58 | 59 | size_t addHeaderName( const std::string & headerName ) 60 | { 61 | size_t newOffset = m_data.size(); 62 | m_data.insert( m_data.end(), headerName.begin(), headerName.end() ); 63 | m_data.push_back( '\0' ); 64 | return newOffset; 65 | } 66 | 67 | const char * rawHeaderData() 68 | { 69 | return &m_data[0]; 70 | } 71 | 72 | size_t rawHeaderSize() 73 | { 74 | return m_data.size(); 75 | } 76 | 77 | private: 78 | std::vector m_data; 79 | }; 80 | 81 | } // end namespace BrigDebug 82 | 83 | #endif // #ifndef SECTION_HEADER_H__ 84 | -------------------------------------------------------------------------------- /libHSAIL/hsa_dwarf.h: -------------------------------------------------------------------------------- 1 | // University of Illinois/NCSA 2 | // Open Source License 3 | // 4 | // Copyright (c) 2013-2015, Advanced Micro Devices, Inc. 5 | // All rights reserved. 6 | // 7 | // Developed by: 8 | // 9 | // HSA Team 10 | // 11 | // Advanced Micro Devices, Inc 12 | // 13 | // www.amd.com 14 | // 15 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | // this software and associated documentation files (the "Software"), to deal with 17 | // the Software without restriction, including without limitation the rights to 18 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | // of the Software, and to permit persons to whom the Software is furnished to do 20 | // so, subject to the following conditions: 21 | // 22 | // * Redistributions of source code must retain the above copyright notice, 23 | // this list of conditions and the following disclaimers. 24 | // 25 | // * Redistributions in binary form must reproduce the above copyright notice, 26 | // this list of conditions and the following disclaimers in the 27 | // documentation and/or other materials provided with the distribution. 28 | // 29 | // * Neither the names of the LLVM Team, University of Illinois at 30 | // Urbana-Champaign, nor the names of its contributors may be used to 31 | // endorse or promote products derived from this Software without specific 32 | // prior written permission. 33 | // 34 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 36 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 | // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 40 | // SOFTWARE. 41 | #ifndef HSA_DWARF_H_INCLUDED__ 42 | #define HSA_DWARF_H_INCLUDED__ 43 | 44 | #define DW_TAG_HSA_argument_scope 0x8000 /* HSA */ 45 | 46 | #define DW_AT_HSA_is_kernel 0x3000 /* HSA. flag, constant, boolean. Is this DW_TAG_subprogram a kernel (if not, it's a plain function)? */ 47 | #define DW_AT_HSA_is_outParam 0x3001 /* HSA. flag, constant, boolean. Is this DW_TAG_formal_parameter an output parameter? */ 48 | #define DW_AT_HSA_workitemid_offset 0x3002 /* Used for ISA DWARF only */ 49 | #define DW_AT_HSA_isa_memory_region 0x3003 /* Used for ISA DWARF only */ 50 | #define DW_AT_HSA_brig_offset 0x3004 /* Used for ISA DWARF only */ 51 | 52 | #define DW_LANG_HSA_Assembly 0x9000 53 | #define DW_LANG_BRIG 0x9001 54 | 55 | enum { 56 | RR_HSA_NONE = 0, 57 | RR_HSA_DWARF_32 = 3, 58 | RR_HSA_DWARF_TO_BRIG_CODE32 = 4, 59 | RR_HSA_DWARF_TO_BRIG_DIRECTIVES32 = 5, 60 | RR_HSA_DWARF_64 = 6, 61 | RR_HSA_DWARF_TO_BRIG_CODE64 = 7, 62 | RR_HSA_DWARF_TO_BRIG_DIRECTIVES64 = 8, 63 | }; 64 | 65 | #ifndef EM_HSAIL 66 | #define EM_HSAIL 0xAF5A 67 | #endif 68 | 69 | #define NT_AMDGPU_HSA_PRODUCER 4 70 | #define NT_AMDGPU_HSA_PRODUCER_OPTIONS 5 71 | #define NT_AMDGPU_HSA_HLDEBUG_DEBUG 101 72 | 73 | #endif // #ifndef HSA_DWARF_H_INCLUDED__ 74 | -------------------------------------------------------------------------------- /libHSAIL/hsail_c.cpp: -------------------------------------------------------------------------------- 1 | // University of Illinois/NCSA 2 | // Open Source License 3 | // 4 | // Copyright (c) 2013-2015, Advanced Micro Devices, Inc. 5 | // All rights reserved. 6 | // 7 | // Developed by: 8 | // 9 | // HSA Team 10 | // 11 | // Advanced Micro Devices, Inc 12 | // 13 | // www.amd.com 14 | // 15 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | // this software and associated documentation files (the "Software"), to deal with 17 | // the Software without restriction, including without limitation the rights to 18 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | // of the Software, and to permit persons to whom the Software is furnished to do 20 | // so, subject to the following conditions: 21 | // 22 | // * Redistributions of source code must retain the above copyright notice, 23 | // this list of conditions and the following disclaimers. 24 | // 25 | // * Redistributions in binary form must reproduce the above copyright notice, 26 | // this list of conditions and the following disclaimers in the 27 | // documentation and/or other materials provided with the distribution. 28 | // 29 | // * Neither the names of the LLVM Team, University of Illinois at 30 | // Urbana-Champaign, nor the names of its contributors may be used to 31 | // endorse or promote products derived from this Software without specific 32 | // prior written permission. 33 | // 34 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 35 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 36 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 37 | // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 38 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 39 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 40 | // SOFTWARE. 41 | 42 | #include "hsail_c.h" 43 | #include "HSAILTool.h" 44 | 45 | using namespace HSAIL_ASM; 46 | 47 | extern "C" { 48 | 49 | HSAIL_C_API brig_container_t brig_container_create_empty() 50 | { 51 | return (brig_container_t) new Tool(); 52 | } 53 | 54 | HSAIL_C_API brig_container_t brig_container_create_view(const void *brig_module, size_t size) 55 | { 56 | return (brig_container_t) new Tool(brig_module, size); 57 | } 58 | 59 | HSAIL_C_API brig_container_t brig_container_create_copy(const void *brig_module, size_t size) 60 | { 61 | return (brig_container_t) new Tool(brig_module, size, true); 62 | } 63 | 64 | static Tool* T(brig_container_t handle) { return (Tool*) handle; } 65 | 66 | static int resultFrom(bool result) { return !result; } 67 | 68 | HSAIL_C_API void* brig_container_get_brig_module(brig_container_t handle) 69 | { 70 | return T(handle)->brigModule(); 71 | } 72 | 73 | HSAIL_C_API unsigned brig_container_get_section_count(brig_container_t handle) 74 | { 75 | return T(handle)->numSections(); 76 | } 77 | 78 | HSAIL_C_API const char* brig_container_get_section_bytes(brig_container_t handle, int section_id) 79 | { 80 | return T(handle)->sectionBytesById(section_id); 81 | } 82 | 83 | HSAIL_C_API size_t brig_container_get_section_size(brig_container_t handle, int section_id) 84 | { 85 | return T(handle)->sectionSizeById(section_id); 86 | } 87 | 88 | HSAIL_C_API int brig_container_assemble_from_memory(brig_container_t handle, const char* text, size_t text_length, const char *options) 89 | { 90 | return resultFrom(T(handle)->assembleFromMemory(text, text_length, options)); 91 | } 92 | 93 | HSAIL_C_API int brig_container_assemble_from_file(brig_container_t handle, const char* filename, const char *options) 94 | { 95 | return resultFrom(T(handle)->assembleFromFile(filename, options)); 96 | } 97 | 98 | HSAIL_C_API int brig_container_disassemble_to_file(brig_container_t handle, const char* filename) 99 | { 100 | return resultFrom(T(handle)->disassembleToFile(filename)); 101 | } 102 | 103 | HSAIL_C_API int brig_container_load_from_mem(brig_container_t handle, const char* buf, size_t buf_length) 104 | { 105 | return resultFrom(T(handle)->loadFromMem(buf, buf_length)); 106 | } 107 | 108 | HSAIL_C_API int brig_container_load_from_file(brig_container_t handle, const char* filename) 109 | { 110 | return resultFrom(T(handle)->loadFromFile(filename)); 111 | } 112 | 113 | HSAIL_C_API int brig_container_save_to_file(brig_container_t handle, const char* filename) 114 | { 115 | return resultFrom(T(handle)->saveToFile(filename)); 116 | } 117 | 118 | HSAIL_C_API int brig_container_validate(brig_container_t handle) 119 | { 120 | return resultFrom(T(handle)->validate()); 121 | } 122 | 123 | HSAIL_C_API brig_code_section_offset brig_container_find_code_module_symbol_offset(brig_container_t handle, const char *symbol_name) 124 | { 125 | return T(handle)->findCodeModuleSymbolOffset(symbol_name); 126 | } 127 | 128 | HSAIL_C_API const char* brig_container_get_error_text(brig_container_t handle) 129 | { 130 | return T(handle)->output().c_str(); 131 | } 132 | 133 | HSAIL_C_API void brig_container_destroy(brig_container_t handle) 134 | { 135 | delete T(handle); 136 | } 137 | 138 | } 139 | -------------------------------------------------------------------------------- /tests/1.0/instruction/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(HSAILASM $) 2 | if (MSVC) 3 | set(RUNTEST ${CMAKE_CURRENT_SOURCE_DIR}/run_test.cmd) 4 | else() 5 | set(RUNTEST ${CMAKE_CURRENT_SOURCE_DIR}/run_test) 6 | endif() 7 | 8 | macro(instruction_test name) 9 | add_test(NAME 1.0/instruction/${name} 10 | COMMAND ${RUNTEST} ${HSAILASM} ${name} ${CMAKE_CURRENT_SOURCE_DIR} 11 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) 12 | endmacro() 13 | 14 | instruction_test(CORE-base-large) 15 | instruction_test(CORE-base-small) 16 | instruction_test(CORE-full-large) 17 | instruction_test(CORE-full-small) 18 | instruction_test(IMAGE-base-large) 19 | instruction_test(IMAGE-base-small) 20 | instruction_test(IMAGE-full-large) 21 | instruction_test(IMAGE-full-small) 22 | if(AMD_EXTENSIONS) 23 | instruction_test(amd_gcn-base-large) 24 | instruction_test(amd_gcn-base-small) 25 | instruction_test(amd_gcn-full-large) 26 | instruction_test(amd_gcn-full-small) 27 | instruction_test(amd_mipmap-base-large) 28 | instruction_test(amd_mipmap-base-small) 29 | instruction_test(amd_mipmap-full-large) 30 | instruction_test(amd_mipmap-full-small) 31 | endif() 32 | -------------------------------------------------------------------------------- /tests/1.0/instruction/generate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | mkdir -p tmp 6 | 7 | generate() { 8 | local name=$1; 9 | local iset=$2; 10 | local profile=$3; 11 | local model=$4; 12 | 13 | echo "Generating $name: $iset $profile $model" 14 | HSAILTestGen -package=single -iset=$iset -model=$model -profile=$profile tmp 15 | HSAILasm -disassemble tmp/hsail_tests_p.brig 16 | mv tmp/hsail_tests_p.hsail $name.hsail 17 | } 18 | 19 | generate_all() { 20 | local name=$1 21 | local iset=$2 22 | 23 | for profile in full base; do 24 | for model in large small; do 25 | generate ${name}-${profile}-${model} $iset $profile $model 26 | done 27 | done 28 | } 29 | 30 | generate_all CORE CORE 31 | generate_all IMAGE IMAGE 32 | generate_all amd_gcn amd:gcn 33 | generate_all amd_mipmap amd:mipmap 34 | -------------------------------------------------------------------------------- /tests/1.0/instruction/run_test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -ne 3 ]; then 4 | echo "Usage: $0 HSAILASM NAME DIR" 5 | echo "Error: expected 3 arguments." 6 | exit 1 7 | fi 8 | 9 | set -e 10 | 11 | HSAILASM=$1 12 | NAME=$2 13 | DIR=$3 14 | 15 | echo "Assembling" 16 | $HSAILASM -assemble $DIR/$NAME.hsail -o ${NAME}_1.brig 17 | 18 | echo "Disassembling" 19 | $HSAILASM -disassemble ${NAME}_1.brig -o ${NAME}_2.hsail 20 | 21 | echo "Comparing with disassembly" 22 | diff -u $DIR/$NAME.hsail ${NAME}_2.hsail 23 | 24 | echo "Decoding" 25 | $HSAILASM -decode ${NAME}_1.brig -o ${NAME}_3.yml 26 | -------------------------------------------------------------------------------- /tests/1.0/instruction/run_test.cmd: -------------------------------------------------------------------------------- 1 | @echo on 2 | 3 | set HSAILASM=%1 4 | set NAME=%2 5 | set DIR=%3 6 | 7 | echo "Assembling" 8 | %HSAILASM% -assemble %DIR%/%NAME%.hsail -o %NAME%_1.brig 9 | if errorlevel 1 goto :error 10 | 11 | echo "Disassembling" 12 | %HSAILASM% -disassemble %NAME%_1.brig -o %NAME%_2.hsail 13 | if errorlevel 1 goto :error 14 | 15 | echo "Comparing with disassembly" 16 | diff -u %DIR%/%NAME%.hsail %NAME%_2.hsail 17 | if errorlevel 1 goto :error 18 | 19 | echo "Decoding" 20 | %HSAILASM% -decode %NAME%_1.brig -o %NAME%_3.yml 21 | if errorlevel 1 goto :error 22 | 23 | exit 0 24 | 25 | :error 26 | exit 1 27 | -------------------------------------------------------------------------------- /tests/1.0/simple.hsail: -------------------------------------------------------------------------------- 1 | module &module:1:0:$full:$large:$default; 2 | 3 | kernel &Test() 4 | { 5 | ret; 6 | }; 7 | -------------------------------------------------------------------------------- /tests/1.0/syntax/000_empty_1.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | -------------------------------------------------------------------------------- /tests/1.0/syntax/000_inst_image_small.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$small:$near; 2 | extension "IMAGE"; 3 | global_u32 &x; 4 | group_u32 &g; 5 | alloc(agent) global_roimg &roimage_1d = roimg(geometry = 1d, width = 5, channel_type = unorm_int_101010, channel_order = rgbx); 6 | alloc(agent) global_roimg &roimage_2d = roimg(geometry = 2d, width = 5, height = 4, channel_type = unorm_int_101010, channel_order = rgbx); 7 | alloc(agent) global_roimg &roimage_3d = roimg(geometry = 3d, width = 5, height = 4, depth = 6, channel_type = unorm_int_101010, channel_order = rgbx); 8 | alloc(agent) global_roimg &roimage_1da = roimg(geometry = 1da, width = 5, array = 4, channel_type = unorm_int_101010, channel_order = rgbx); 9 | alloc(agent) global_roimg &roimage_2da = roimg(geometry = 2da, width = 5, height = 4, array = 4, channel_type = unorm_int_101010, channel_order = rgbx); 10 | alloc(agent) global_roimg &roimage_1db = roimg(geometry = 1db, width = 5, channel_type = unorm_int_101010, channel_order = rgbx); 11 | alloc(agent) global_roimg &roimage = roimg(geometry = 3d, width = 5, height = 4, depth = 6, channel_type = unorm_int_101010, channel_order = rgbx); 12 | alloc(agent) global_rwimg &rwimage = rwimg(geometry = 3d, width = 5, height = 4, depth = 6, channel_type = unorm_int_101010, channel_order = rgbx); 13 | alloc(agent) global_samp &samp = samp(coord = normalized, filter = nearest, addressing = clamp_to_edge); 14 | readonly_roimg &roimageRO = roimg(geometry = 3d, width = 5, height = 4, depth = 6, channel_type = unorm_int_101010, channel_order = rgbx); 15 | readonly_rwimg &rwimageRO = rwimg(geometry = 3d, width = 5, height = 4, depth = 6, channel_type = unorm_int_101010, channel_order = rgbx); 16 | readonly_samp &sampRO = samp(coord = normalized, filter = nearest, addressing = clamp_to_edge); 17 | 18 | kernel &TestKernelOpaque( 19 | kernarg_rwimg %x1, 20 | kernarg_samp %x2) 21 | { 22 | lda_kernarg_u32 $s1, [%x1]; 23 | ld_kernarg_rwimg $d2, [$s1]; 24 | ld_kernarg_samp $d2, [%x2]; 25 | }; 26 | 27 | function &tt()( 28 | arg_roimg %x11, 29 | arg_rwimg %x12, 30 | arg_samp %x13) 31 | { 32 | }; 33 | 34 | function &TestFuncOpaque()( 35 | arg_rwimg %x1, 36 | arg_samp %x2) 37 | { 38 | // opaque refs 39 | ld_global_roimg $d1, [&roimage]; 40 | ld_global_rwimg $d1, [&rwimage]; 41 | ld_global_samp $d1, [&samp]; 42 | { 43 | arg_roimg %x11; 44 | arg_rwimg %x12; 45 | arg_samp %x13; 46 | st_arg_roimg $d1, [%x11]; 47 | st_arg_rwimg $d1, [%x12]; 48 | st_arg_samp $d1, [%x13]; 49 | call &tt () (%x11, %x12, %x13); 50 | } 51 | lda_group_u32 $s1, [&g]; 52 | ld_arg_rwimg $d2, [%x1][$s1]; 53 | ld_arg_samp $d2, [%x2]; 54 | }; 55 | -------------------------------------------------------------------------------- /tests/1.0/syntax/001_delimiters.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | kernel &Test() 4 | { 5 | // 6 | // Next sample 7 | // 8 | add_pp_u8x4 $s0, $s0, $s0; 9 | add_ps_u8x4 $s0, $s0, $s0; 10 | add_sp_u8x4 $s0, $s0, $s0; 11 | add_ss_u8x4 $s0, $s0, $s0; 12 | // abc 13 | add_pp_sat_u8x4 $s0, $s0, $s0; 14 | add_ps_sat_u8x4 $s0, $s0, $s0; 15 | add_sp_sat_u8x4 $s0, $s0, $s0; 16 | //.add_ss_sat_u8x4.$s0, 17 | add_ps_sat_u8x4 $s0, $s0, $s0; 18 | }; 19 | -------------------------------------------------------------------------------- /tests/1.0/syntax/001_order_1.hsail: -------------------------------------------------------------------------------- 1 | // Testing order of directives at toplevel 2 | // 3 | loc 20 "this is a file"; 4 | loc 4 "this is a file"; 5 | // comment 6 | pragma "123", 0x1f000000ffffffff; 7 | //---------------------------------------------------- 8 | module &moduleName:1:0:$full:$large:$default; 9 | //---------------------------------------------------- 10 | pragma "123", 0x1f000000ffffffff; 11 | loc 20 "this is a file"; 12 | loc 4 "this is a file"; 13 | //---------------------------------------------------- 14 | extension "CORE"; 15 | //---------------------------------------------------- 16 | loc 20 "this is a file"; 17 | loc 4 "this is a file"; 18 | pragma "123", 0x1f000000ffffffff; 19 | //---------------------------------------------------- 20 | extension "CORE"; 21 | //---------------------------------------------------- 22 | loc 20 "this is a file"; 23 | loc 4 "this is a file"; 24 | pragma "123", 0x1f000000ffffffff; 25 | //---------------------------------------------------- 26 | // declarations and definitions 27 | // 28 | decl global_s32 &v1; 29 | fbarrier &b1; 30 | //---------------------------------------------------- 31 | loc 4 "this is a file"; 32 | pragma &v1, &b1; 33 | pragma "123", 0x1f000000ffffffff; 34 | //---------------------------------------------------- 35 | // more declarations and definitions 36 | // 37 | 38 | kernel &k() 39 | { 40 | }; 41 | global_s32 &v1; 42 | //---------------------------------------------------- 43 | loc 4 "this is a file"; 44 | pragma &k, &v1, &b1; 45 | pragma "123", 0x1f000000ffffffff; 46 | -------------------------------------------------------------------------------- /tests/1.0/syntax/001_order_2.hsail: -------------------------------------------------------------------------------- 1 | loc 20 "this is a file"; 2 | pragma "123", 0x1f000000ffffffff; 3 | //---------------------------------------------------- 4 | module &moduleName:1:0:$full:$large:$default; 5 | //---------------------------------------------------- 6 | loc 4 "this is a file"; 7 | pragma "123", 0x1f000000ffffffff; 8 | //---------------------------------------------------- 9 | 10 | decl prog function &f()(); 11 | 12 | kernel &k1() 13 | { 14 | loc 4 "this is a file"; 15 | pragma "123", 0x1f000000ffffffff; 16 | //---------------------------------------------------- 17 | // Control directives 18 | // 19 | enablebreakexceptions 0x70000001; 20 | //---------------------------------------------------- 21 | loc 4 "this is a file"; 22 | pragma "123", 0x1f000000ffffffff; 23 | //---------------------------------------------------- 24 | // Control directives 25 | // 26 | requirenopartialworkgroups; 27 | //---------------------------------------------------- 28 | loc 4 "this is a file"; 29 | pragma "123", 0x1f000000ffffffff; 30 | //---------------------------------------------------- 31 | // Definitions 32 | global_s32 %v1; 33 | fbarrier %b1; 34 | //---------------------------------------------------- 35 | loc 4 "this is a file"; 36 | pragma %v1, %b1; 37 | //---------------------------------------------------- 38 | // Definitions 39 | global_s32 %v2; 40 | fbarrier %b2; 41 | //---------------------------------------------------- 42 | loc 4 "this is a file"; 43 | pragma "123", 0x1f000000ffffffff; 44 | //---------------------------------------------------- 45 | // Statements (labels, instructions, arg blocks) 46 | 47 | @lab1: 48 | add_s32 $s0, $s0, $s0; 49 | //---------------------------------------------------- 50 | loc 4 "this is a file"; 51 | pragma "123", 0x1f000000ffffffff; 52 | //---------------------------------------------------- 53 | // Statements (labels, instructions, arg blocks) 54 | add_s32 $s0, $s0, $s0; 55 | //---------------------------------------------------- 56 | loc 4 "this is a file"; 57 | pragma "123", 0x1f000000ffffffff; 58 | //---------------------------------------------------- 59 | // Statements (labels, instructions, arg blocks) 60 | 61 | @lab2: 62 | //---------------------------------------------------- 63 | loc 4 "this is a file"; 64 | pragma %v2, %b2; 65 | //---------------------------------------------------- 66 | // Statements (labels, instructions, arg blocks) 67 | { 68 | call &f () (); 69 | } 70 | //---------------------------------------------------- 71 | loc 4 "this is a file"; 72 | pragma "123", 0x1f000000ffffffff; 73 | }; 74 | //---------------------------------------------------- 75 | 76 | kernel &k2() 77 | { 78 | pragma "123", 0x1f000000ffffffff; 79 | loc 4 "this is a file"; 80 | //---------------------------------------------------- 81 | // Control directives 82 | // 83 | enablebreakexceptions 0x70000001; 84 | //---------------------------------------------------- 85 | pragma "123", 0x1f000000ffffffff; 86 | loc 4 "this is a file"; 87 | //---------------------------------------------------- 88 | // Control directives 89 | // 90 | requirenopartialworkgroups; 91 | //---------------------------------------------------- 92 | pragma "123", 0x1f000000ffffffff; 93 | loc 4 "this is a file"; 94 | //---------------------------------------------------- 95 | // Definitions 96 | global_s32 %v1; 97 | fbarrier %b1; 98 | //---------------------------------------------------- 99 | pragma %v1, %b1; 100 | loc 4 "this is a file"; 101 | //---------------------------------------------------- 102 | // Definitions 103 | global_s32 %v2; 104 | fbarrier %b2; 105 | //---------------------------------------------------- 106 | pragma "123", 0x1f000000ffffffff; 107 | loc 4 "this is a file"; 108 | //---------------------------------------------------- 109 | // Statements (labels, instructions, arg blocks) 110 | { 111 | call &f () (); 112 | } 113 | //---------------------------------------------------- 114 | pragma "123", 0x1f000000ffffffff; 115 | loc 4 "this is a file"; 116 | //---------------------------------------------------- 117 | // Statements (labels, instructions, arg blocks) 118 | add_s32 $s0, $s0, $s0; 119 | //---------------------------------------------------- 120 | pragma %v2, %b2; 121 | loc 4 "this is a file"; 122 | //---------------------------------------------------- 123 | // Statements (labels, instructions, arg blocks) 124 | 125 | @lab2: 126 | //---------------------------------------------------- 127 | pragma "123", 0x1f000000ffffffff; 128 | loc 4 "this is a file"; 129 | }; 130 | //---------------------------------------------------- 131 | pragma "123", 0x1f000000ffffffff; 132 | loc 4 "this is a file"; 133 | -------------------------------------------------------------------------------- /tests/1.0/syntax/001_order_3.hsail: -------------------------------------------------------------------------------- 1 | pragma "123", 0x1f000000ffffffff; 2 | //---------------------------------------------------- 3 | module &moduleName:1:0:$full:$large:$default; 4 | //---------------------------------------------------- 5 | pragma "123", 0x1f000000ffffffff; 6 | loc 4 ""; 7 | //---------------------------------------------------- 8 | 9 | decl prog function &f(arg_u32 %x)(arg_u32 %y); 10 | 11 | kernel &k1() 12 | { 13 | pragma "123", 0x1f000000ffffffff; 14 | loc 4 ""; 15 | //---------------------------------------------------- 16 | { 17 | pragma "123", 0x1f000000ffffffff; 18 | loc 4 ""; 19 | //---------------------------------------------------- 20 | // Definitions of arg variables 21 | arg_u32 %x; 22 | //---------------------------------------------------- 23 | pragma "123", 0x1f000000ffffffff; 24 | loc 4 ""; 25 | //---------------------------------------------------- 26 | // Definitions of arg variables 27 | arg_u32 %y; 28 | //---------------------------------------------------- 29 | pragma "123", 0x1f000000ffffffff; 30 | loc 4 ""; 31 | //---------------------------------------------------- 32 | // Statements (labels and instructions) 33 | 34 | @lab1: 35 | //---------------------------------------------------- 36 | pragma "123", 0x1f000000ffffffff; 37 | loc 4 ""; 38 | //---------------------------------------------------- 39 | // Statements (labels and instructions) 40 | add_s32 $s0, $s0, $s0; 41 | //---------------------------------------------------- 42 | pragma "123", 0x1f000000ffffffff; 43 | loc 4 ""; 44 | //---------------------------------------------------- 45 | // Statements (labels and instructions) 46 | call &f (%x) (%y); 47 | //---------------------------------------------------- 48 | pragma "123", 0x1f000000ffffffff; 49 | loc 4 ""; 50 | } 51 | //---------------------------------------------------- 52 | pragma "123", 0x1f000000ffffffff; 53 | loc 4 ""; 54 | //---------------------------------------------------- 55 | { 56 | loc 4 ""; 57 | pragma "123", 0x1f000000ffffffff; 58 | //---------------------------------------------------- 59 | // Definitions of arg variables 60 | arg_u32 %x; 61 | //---------------------------------------------------- 62 | loc 4 ""; 63 | pragma "123", 0x1f000000ffffffff; 64 | //---------------------------------------------------- 65 | // Definitions of arg variables 66 | arg_u32 %y; 67 | //---------------------------------------------------- 68 | loc 4 ""; 69 | pragma "123", 0x1f000000ffffffff; 70 | //---------------------------------------------------- 71 | // Statements (labels and instructions) 72 | add_s32 $s0, $s0, $s0; 73 | //---------------------------------------------------- 74 | loc 4 ""; 75 | pragma "123", 0x1f000000ffffffff; 76 | //---------------------------------------------------- 77 | // Statements (labels and instructions) 78 | 79 | @lab2: 80 | //---------------------------------------------------- 81 | loc 4 ""; 82 | pragma "123", 0x1f000000ffffffff; 83 | //---------------------------------------------------- 84 | // Statements (labels and instructions) 85 | call &f (%x) (%y); 86 | //---------------------------------------------------- 87 | loc 4 ""; 88 | pragma "123", 0x1f000000ffffffff; 89 | } 90 | //---------------------------------------------------- 91 | pragma "123", 0x1f000000ffffffff; 92 | loc 4 ""; 93 | //---------------------------------------------------- 94 | { 95 | loc 4 ""; 96 | pragma "123", 0x1f000000ffffffff; 97 | //---------------------------------------------------- 98 | // Definitions of arg variables 99 | arg_u32 %x; 100 | //---------------------------------------------------- 101 | loc 4 ""; 102 | pragma "123", 0x1f000000ffffffff; 103 | //---------------------------------------------------- 104 | // Definitions of arg variables 105 | arg_u32 %y; 106 | //---------------------------------------------------- 107 | loc 4 ""; 108 | pragma "123", 0x1f000000ffffffff; 109 | //---------------------------------------------------- 110 | // Statements (labels and instructions) 111 | call &f (%x) (%y); 112 | //---------------------------------------------------- 113 | loc 4 ""; 114 | pragma "123", 0x1f000000ffffffff; 115 | //---------------------------------------------------- 116 | // Statements (labels and instructions) 117 | 118 | @lab3: 119 | //---------------------------------------------------- 120 | loc 4 ""; 121 | pragma "123", 0x1f000000ffffffff; 122 | //---------------------------------------------------- 123 | // Statements (labels and instructions) 124 | add_s32 $s0, $s0, $s0; 125 | //---------------------------------------------------- 126 | loc 4 ""; 127 | pragma "123", 0x1f000000ffffffff; 128 | } 129 | //---------------------------------------------------- 130 | loc 4 ""; 131 | pragma "123", 0x1f000000ffffffff; 132 | }; 133 | //---------------------------------------------------- 134 | pragma "123", 0x1f000000ffffffff; 135 | loc 4 ""; 136 | -------------------------------------------------------------------------------- /tests/1.0/syntax/002_version_large.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc1()() 4 | { 5 | ret; 6 | }; 7 | -------------------------------------------------------------------------------- /tests/1.0/syntax/002_version_small.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$small:$near; 2 | 3 | function &TestFunc1()() 4 | { 5 | ret; 6 | }; 7 | -------------------------------------------------------------------------------- /tests/1.0/syntax/004_extension.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | // 3 | // This directive is allowed before extension 4 | // 5 | loc 1 "SomeFileName"; 6 | // 7 | extension "abc"; 8 | // 9 | // This directive is allowed before extension 10 | // 11 | loc 2 "SomeOtherFileName"; 12 | // 13 | extension "def"; 14 | extension ""; 15 | extension ""; 16 | extension "\""; 17 | extension ""; 18 | //*pragma"";*/"" 19 | extension ""; 20 | //extension""; 21 | extension ""; 22 | extension "?"; 23 | extension "\t\n\n"; 24 | 25 | function &TestFunc()() 26 | { 27 | ret; 28 | }; 29 | -------------------------------------------------------------------------------- /tests/1.0/syntax/004_extension_CORE.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | extension "CORE"; 3 | extension "CORE"; 4 | 5 | function &TestFunc()() 6 | { 7 | ret; 8 | }; 9 | -------------------------------------------------------------------------------- /tests/1.0/syntax/004_extension_CORE_0.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | extension "CORE"; 3 | extension "CORE"; 4 | extension "CORE"; 5 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_00.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | loc 1 "name"; 3 | 4 | function &TestFunc()() 5 | { 6 | loc 1 20 "name"; 7 | // allowed before control directives 8 | //----------------------------------------------------------------------------------------------------------------------- 9 | // NO REQ 10 | //----------------------------------------------------------------------------------------------------------------------- 11 | enablebreakexceptions 7; 12 | enabledetectexceptions 7; 13 | loc 1 20 "name"; 14 | // allowed before control directives 15 | //----------------------------------------------------------------------------------------------------------------------- 16 | // NO REQ 17 | //----------------------------------------------------------------------------------------------------------------------- 18 | maxdynamicgroupsize 0; 19 | maxdynamicgroupsize 1; 20 | //----------------------------------------------------------------------------------------------------------------------- 21 | // Must be an immediate value greater than 0, or WAVESIZE. 22 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 23 | // The value specified must be greater than or equal to the product of the values specified by requiredgridsize 24 | //----------------------------------------------------------------------------------------------------------------------- 25 | maxflatgridsize WAVESIZE; 26 | maxflatgridsize WAVESIZE; 27 | //----------------------------------------------------------------------------------------------------------------------- 28 | // Must be an immediate value greater than 0, or WAVESIZE. 29 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 30 | // The value specified must also be greater than or equal to the product of the values specified by requiredworkgroupsize. 31 | //----------------------------------------------------------------------------------------------------------------------- 32 | maxflatworkgroupsize WAVESIZE; 33 | maxflatworkgroupsize WAVESIZE; 34 | //----------------------------------------------------------------------------------------------------------------------- 35 | // Must be an immediate value with the value 1, 2, or 3. 36 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 37 | // must be consistent with requiredgridsize and requiredworkgroupsize: 38 | // if requireddim = 1, => requiredgridsize X, 1, 1; requiredworkgroupsize X, 1, 1; 39 | // if requireddim = 2, => requiredgridsize X, Y, 1; requiredworkgroupsize X, Y, 1; 40 | //----------------------------------------------------------------------------------------------------------------------- 41 | requireddim 3; 42 | requireddim 3; 43 | //----------------------------------------------------------------------------------------------------------------------- 44 | // Must be an immediate value greater than 0, or WAVESIZE. 45 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 46 | // The product of the values must be less than or equal to value specified by maxflatgridsize 47 | // Must be consistent with requireddim 48 | //----------------------------------------------------------------------------------------------------------------------- 49 | requiredgridsize 7, 8, 9; 50 | requiredgridsize 7, 8, 9; 51 | //----------------------------------------------------------------------------------------------------------------------- 52 | // Must be an immediate value greater than 0, or WAVESIZE. 53 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 54 | // The product of the values must be less than or equal to any value specified by maxflatworkgroupsize . 55 | // Must be consistent with requireddim 56 | //----------------------------------------------------------------------------------------------------------------------- 57 | requiredworkgroupsize 2, 2, 2; 58 | requiredworkgroupsize 2, 2, 2; 59 | //----------------------------------------------------------------------------------------------------------------------- 60 | // NO REQ 61 | //----------------------------------------------------------------------------------------------------------------------- 62 | requirenopartialworkgroups; 63 | requirenopartialworkgroups; 64 | }; 65 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_01.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc()() 4 | { 5 | //----------------------------------------------------------------------------------------------------------------------- 6 | // Must be an immediate value greater than 0, or WAVESIZE. 7 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 8 | // The value specified must be greater than or equal to the product of the values specified by requiredgridsize 9 | //----------------------------------------------------------------------------------------------------------------------- 10 | maxflatgridsize 1000; 11 | maxflatgridsize 1000; 12 | //----------------------------------------------------------------------------------------------------------------------- 13 | // Must be an immediate value greater than 0, or WAVESIZE. 14 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 15 | // The value specified must also be greater than or equal to the product of the values specified by requiredworkgroupsize. 16 | //----------------------------------------------------------------------------------------------------------------------- 17 | maxflatworkgroupsize 100; 18 | maxflatworkgroupsize 100; 19 | //----------------------------------------------------------------------------------------------------------------------- 20 | // Must be an immediate value with the value 1, 2, or 3. 21 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 22 | // must be consistent with requiredgridsize and requiredworkgroupsize: 23 | // if requireddim = 1, => requiredgridsize X, 1, 1; requiredworkgroupsize X, 1, 1; 24 | // if requireddim = 2, => requiredgridsize X, Y, 1; requiredworkgroupsize X, Y, 1; 25 | //----------------------------------------------------------------------------------------------------------------------- 26 | requireddim 3; 27 | requireddim 3; 28 | //----------------------------------------------------------------------------------------------------------------------- 29 | // Must be an immediate value greater than 0, or WAVESIZE. 30 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 31 | // The product of the values must be less than or equal to value specified by maxflatgridsize 32 | // Must be consistent with requireddim 33 | //----------------------------------------------------------------------------------------------------------------------- 34 | requiredgridsize WAVESIZE, WAVESIZE, WAVESIZE; 35 | requiredgridsize WAVESIZE, WAVESIZE, WAVESIZE; 36 | //----------------------------------------------------------------------------------------------------------------------- 37 | // Must be an immediate value greater than 0, or WAVESIZE. 38 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 39 | // The product of the values must be less than or equal to any value specified by maxflatworkgroupsize . 40 | // Must be consistent with requireddim 41 | //----------------------------------------------------------------------------------------------------------------------- 42 | requiredworkgroupsize WAVESIZE, WAVESIZE, WAVESIZE; 43 | requiredworkgroupsize WAVESIZE, WAVESIZE, WAVESIZE; 44 | //----------------------------------------------------------------------------------------------------------------------- 45 | }; 46 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_02.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc()() 4 | { 5 | //----------------------------------------------------------------------------------------------------------------------- 6 | // Must be an immediate value greater than 0, or WAVESIZE. 7 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 8 | // The value specified must be greater than or equal to the product of the values specified by requiredgridsize 9 | //----------------------------------------------------------------------------------------------------------------------- 10 | maxflatgridsize 100; 11 | //----------------------------------------------------------------------------------------------------------------------- 12 | // Must be an immediate value greater than 0, or WAVESIZE. 13 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 14 | // The value specified must also be greater than or equal to the product of the values specified by requiredworkgroupsize. 15 | //----------------------------------------------------------------------------------------------------------------------- 16 | maxflatworkgroupsize 9; 17 | //----------------------------------------------------------------------------------------------------------------------- 18 | // Must be an immediate value with the value 1, 2, or 3. 19 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 20 | // must be consistent with requiredgridsize and requiredworkgroupsize: 21 | // if requireddim = 1, => requiredgridsize X, 1, 1; requiredworkgroupsize X, 1, 1; 22 | // if requireddim = 2, => requiredgridsize X, Y, 1; requiredworkgroupsize X, Y, 1; 23 | //----------------------------------------------------------------------------------------------------------------------- 24 | requireddim 2; 25 | //----------------------------------------------------------------------------------------------------------------------- 26 | // Must be an immediate value greater than 0, or WAVESIZE. 27 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 28 | // The product of the values must be less than or equal to value specified by maxflatgridsize 29 | // Must be consistent with requireddim 30 | //----------------------------------------------------------------------------------------------------------------------- 31 | requiredgridsize 10, 10, 1; 32 | requiredgridsize 10, 10, 1; 33 | //----------------------------------------------------------------------------------------------------------------------- 34 | // Must be an immediate value greater than 0, or WAVESIZE. 35 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 36 | // The product of the values must be less than or equal to any value specified by maxflatworkgroupsize . 37 | // Must be consistent with requireddim 38 | //----------------------------------------------------------------------------------------------------------------------- 39 | requiredworkgroupsize 3, 3, 1; 40 | requiredworkgroupsize 3, 3, 1; 41 | //----------------------------------------------------------------------------------------------------------------------- 42 | }; 43 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_03.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc()() 4 | { 5 | //----------------------------------------------------------------------------------------------------------------------- 6 | // Must be an immediate value greater than 0, or WAVESIZE. 7 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 8 | // The value specified must be greater than or equal to the product of the values specified by requiredgridsize 9 | //----------------------------------------------------------------------------------------------------------------------- 10 | maxflatgridsize 10; 11 | //----------------------------------------------------------------------------------------------------------------------- 12 | // Must be an immediate value greater than 0, or WAVESIZE. 13 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 14 | // The value specified must also be greater than or equal to the product of the values specified by requiredworkgroupsize. 15 | //----------------------------------------------------------------------------------------------------------------------- 16 | maxflatworkgroupsize 3; 17 | //----------------------------------------------------------------------------------------------------------------------- 18 | // Must be an immediate value with the value 1, 2, or 3. 19 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 20 | // must be consistent with requiredgridsize and requiredworkgroupsize: 21 | // if requireddim = 1, => requiredgridsize X, 1, 1; requiredworkgroupsize X, 1, 1; 22 | // if requireddim = 2, => requiredgridsize X, Y, 1; requiredworkgroupsize X, Y, 1; 23 | //----------------------------------------------------------------------------------------------------------------------- 24 | requireddim 1; 25 | //----------------------------------------------------------------------------------------------------------------------- 26 | // Must be an immediate value greater than 0, or WAVESIZE. 27 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 28 | // The product of the values must be less than or equal to value specified by maxflatgridsize 29 | // Must be consistent with requireddim 30 | //----------------------------------------------------------------------------------------------------------------------- 31 | requiredgridsize 10, 1, 1; 32 | //----------------------------------------------------------------------------------------------------------------------- 33 | // Must be an immediate value greater than 0, or WAVESIZE. 34 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 35 | // The product of the values must be less than or equal to any value specified by maxflatworkgroupsize . 36 | // Must be consistent with requireddim 37 | //----------------------------------------------------------------------------------------------------------------------- 38 | requiredworkgroupsize 3, 1, 1; 39 | //----------------------------------------------------------------------------------------------------------------------- 40 | }; 41 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_04.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc()() 4 | { 5 | //----------------------------------------------------------------------------------------------------------------------- 6 | // Must be an immediate value greater than 0, or WAVESIZE. 7 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 8 | // The value specified must also be greater than or equal to the product of the values specified by requiredworkgroupsize. 9 | //----------------------------------------------------------------------------------------------------------------------- 10 | requiredgridsize WAVESIZE, 1, 1; 11 | maxflatgridsize WAVESIZE; 12 | // The value specified must be greater than or equal to the product of the values specified by requiredgridsize 13 | }; 14 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_05.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc()() 4 | { 5 | //----------------------------------------------------------------------------------------------------------------------- 6 | // Must be an immediate value greater than 0, or WAVESIZE. 7 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 8 | // The value specified must also be greater than or equal to the product of the values specified by requiredworkgroupsize. 9 | //----------------------------------------------------------------------------------------------------------------------- 10 | requiredgridsize 1, 1, WAVESIZE; 11 | maxflatgridsize WAVESIZE; 12 | // The value specified must be greater than or equal to the product of the values specified by requiredgridsize 13 | }; 14 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_06.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc()() 4 | { 5 | //----------------------------------------------------------------------------------------------------------------------- 6 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 7 | //----------------------------------------------------------------------------------------------------------------------- 8 | maxflatgridsize 10; 9 | maxflatgridsize WAVESIZE; 10 | // WAVESIZE value is not known, so it might be equal to 10 11 | }; 12 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_07.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc()() 4 | { 5 | //----------------------------------------------------------------------------------------------------------------------- 6 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 7 | //----------------------------------------------------------------------------------------------------------------------- 8 | maxflatgridsize WAVESIZE; 9 | maxflatgridsize 10; 10 | // WAVESIZE value is not known, so it might be equal to 10 11 | }; 12 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_08.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc()() 4 | { 5 | //----------------------------------------------------------------------------------------------------------------------- 6 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 7 | //----------------------------------------------------------------------------------------------------------------------- 8 | requiredworkgroupsize 1, 2, WAVESIZE; 9 | requireddim 2; 10 | // WAVESIZE may be 1, so this code is formally correct 11 | }; 12 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_09.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc()() 4 | { 5 | //----------------------------------------------------------------------------------------------------------------------- 6 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 7 | //----------------------------------------------------------------------------------------------------------------------- 8 | requiredworkgroupsize 10, WAVESIZE, WAVESIZE; 9 | requireddim 1; 10 | // WAVESIZE may be 1, so this code is formally correct 11 | }; 12 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_10.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc()() 4 | { 5 | //----------------------------------------------------------------------------------------------------------------------- 6 | // If multiple control directives are present in the kernel or the functions it calls, they must all have the same values. 7 | //----------------------------------------------------------------------------------------------------------------------- 8 | requiredworkgroupsize 10, WAVESIZE, 1; 9 | requireddim 1; 10 | // WAVESIZE may be 1, so this code is formally correct 11 | }; 12 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_enablebreakexceptions_1.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc0()() 4 | { 5 | enablebreakexceptions 0x700000e0; 6 | }; 7 | 8 | function &TestFunc1()() 9 | { 10 | enablebreakexceptions 0x70000001; 11 | }; 12 | 13 | function &TestFunc2()() 14 | { 15 | enablebreakexceptions 0x70000002; 16 | }; 17 | 18 | function &TestFunc3()() 19 | { 20 | enablebreakexceptions 0x70000004; 21 | }; 22 | 23 | function &TestFunc4()() 24 | { 25 | enablebreakexceptions 0x70000008; 26 | }; 27 | 28 | function &TestFunc5()() 29 | { 30 | enablebreakexceptions 0x70000010; 31 | }; 32 | 33 | function &TestFunc6()() 34 | { 35 | enablebreakexceptions 0x7000001f; 36 | }; 37 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_enablebreakexceptions_2.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$base:$large:$zero; 2 | 3 | function &TestFunc0()() 4 | { 5 | enablebreakexceptions 0x700000e0; 6 | }; 7 | 8 | function &TestFunc1()() 9 | { 10 | enablebreakexceptions 0x70000001; 11 | }; 12 | 13 | function &TestFunc2()() 14 | { 15 | enablebreakexceptions 0x70000002; 16 | }; 17 | 18 | function &TestFunc3()() 19 | { 20 | enablebreakexceptions 0x70000004; 21 | }; 22 | 23 | function &TestFunc4()() 24 | { 25 | enablebreakexceptions 0x70000008; 26 | }; 27 | 28 | function &TestFunc5()() 29 | { 30 | enablebreakexceptions 0x70000010; 31 | }; 32 | 33 | function &TestFunc6()() 34 | { 35 | enablebreakexceptions 0x7000001f; 36 | }; 37 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_enabledetectexceptions_1.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc0()() 4 | { 5 | enabledetectexceptions 0x700000e0; 6 | }; 7 | 8 | function &TestFunc1()() 9 | { 10 | enabledetectexceptions 0x70000001; 11 | }; 12 | 13 | function &TestFunc2()() 14 | { 15 | enabledetectexceptions 0x70000002; 16 | }; 17 | 18 | function &TestFunc3()() 19 | { 20 | enabledetectexceptions 0x70000004; 21 | }; 22 | 23 | function &TestFunc4()() 24 | { 25 | enabledetectexceptions 0x70000008; 26 | }; 27 | 28 | function &TestFunc5()() 29 | { 30 | enabledetectexceptions 0x70000010; 31 | }; 32 | 33 | function &TestFunc6()() 34 | { 35 | enabledetectexceptions 0x7000001f; 36 | }; 37 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_enabledetectexceptions_2.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$base:$large:$zero; 2 | 3 | function &TestFunc0()() 4 | { 5 | enabledetectexceptions 0x700000e0; 6 | }; 7 | 8 | function &TestFunc1()() 9 | { 10 | enabledetectexceptions 0x70000001; 11 | }; 12 | 13 | function &TestFunc2()() 14 | { 15 | enabledetectexceptions 0x70000002; 16 | }; 17 | 18 | function &TestFunc3()() 19 | { 20 | enabledetectexceptions 0x70000004; 21 | }; 22 | 23 | function &TestFunc4()() 24 | { 25 | enabledetectexceptions 0x70000008; 26 | }; 27 | 28 | function &TestFunc5()() 29 | { 30 | enabledetectexceptions 0x70000010; 31 | }; 32 | 33 | function &TestFunc6()() 34 | { 35 | enabledetectexceptions 0x7000001f; 36 | }; 37 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_maxdynamicgroupsize.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc()() 4 | { 5 | maxdynamicgroupsize 0x70000001; 6 | }; 7 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_maxflatgridsize_1.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc()() 4 | { 5 | maxflatgridsize 0x7fffffff70000001; 6 | }; 7 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_maxflatgridsize_2.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc()() 4 | { 5 | maxflatgridsize WAVESIZE; 6 | }; 7 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_maxflatworkgroupsize_1.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc()() 4 | { 5 | maxflatworkgroupsize 0x70000001; 6 | }; 7 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_maxflatworkgroupsize_2.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc()() 4 | { 5 | maxflatworkgroupsize WAVESIZE; 6 | }; 7 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_requireddim.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc()() 4 | { 5 | requireddim 3; 6 | }; 7 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_requiredgridsize_1.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc()() 4 | { 5 | requiredgridsize 0x7fffffff10000003, 0x7fffffff20000003, 0x7fffffff30000003; 6 | }; 7 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_requiredgridsize_2.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc()() 4 | { 5 | requiredgridsize WAVESIZE, WAVESIZE, WAVESIZE; 6 | }; 7 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_requiredworkgroupsize_1.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc()() 4 | { 5 | requiredworkgroupsize 0x10000003, 0x20000003, 0x30000003; 6 | }; 7 | -------------------------------------------------------------------------------- /tests/1.0/syntax/005_control_requiredworkgroupsize_2.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc()() 4 | { 5 | requiredworkgroupsize WAVESIZE, WAVESIZE, WAVESIZE; 6 | }; 7 | -------------------------------------------------------------------------------- /tests/1.0/syntax/006_loc.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | loc 10 ""; 3 | //3 4 | loc 30 "this is a file"; 5 | loc 20 "this is a file"; 6 | loc 4 "this is a file"; 7 | loc 5 6 "this is a file"; 8 | loc 4294967290 ""; 9 | 10 | function &TestFunc()() 11 | { 12 | ret; 13 | loc 1 ""; 14 | loc 1 19 ""; 15 | loc 1 10 "file"; 16 | loc 4294967295 4294967295 "file"; 17 | loc 3 "file"; 18 | ///**/ /**/10/**/loc 3; 19 | ///**/,/**/3//; 20 | //; 21 | loc 2 11 "file"; 22 | loc 1 10 ""; 23 | loc 1 10 "some file name"; 24 | }; 25 | loc 5 6 "some file name"; 26 | -------------------------------------------------------------------------------- /tests/1.0/syntax/009_function_arg_array.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc100()(arg_s8 %in_arg0[1]) 4 | { 5 | ret; 6 | }; 7 | 8 | function &TestFunc104()(arg_u8 %in_arg0[10]) 9 | { 10 | ret; 11 | }; 12 | 13 | function &TestFunc112(align(256) arg_b8 %in_arg0[20])() 14 | { 15 | ret; 16 | }; 17 | -------------------------------------------------------------------------------- /tests/1.0/syntax/009_function_arg_flexible_array.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc100()(arg_s8 %in_arg0[]) 4 | { 5 | ret; 6 | }; 7 | 8 | function &TestFunc104()(arg_u8 %in_arg0[]) 9 | { 10 | ret; 11 | }; 12 | 13 | function &TestFunc112()(align(2) arg_b8 %in_arg0[]) 14 | { 15 | ret; 16 | }; 17 | -------------------------------------------------------------------------------- /tests/1.0/syntax/009_function_arg_generic.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc100()(arg_s8 %in_arg0) 4 | { 5 | ret; 6 | }; 7 | 8 | function &TestFunc101()(arg_s16 %in_arg0) 9 | { 10 | ret; 11 | }; 12 | 13 | function &TestFunc102()(arg_s32 %in_arg0) 14 | { 15 | ret; 16 | }; 17 | 18 | function &TestFunc103()(arg_s64 %in_arg0) 19 | { 20 | ret; 21 | }; 22 | 23 | function &TestFunc104()(arg_u8 %in_arg0) 24 | { 25 | ret; 26 | }; 27 | 28 | function &TestFunc105()(arg_u16 %in_arg0) 29 | { 30 | ret; 31 | }; 32 | 33 | function &TestFunc106()(arg_u32 %in_arg0) 34 | { 35 | ret; 36 | }; 37 | 38 | function &TestFunc107()(arg_u64 %in_arg0) 39 | { 40 | ret; 41 | }; 42 | 43 | function &TestFunc108()(arg_f16 %in_arg0) 44 | { 45 | ret; 46 | }; 47 | 48 | function &TestFunc109()(arg_f32 %in_arg0) 49 | { 50 | ret; 51 | }; 52 | 53 | function &TestFunc110()(arg_f64 %in_arg0) 54 | { 55 | ret; 56 | }; 57 | 58 | function &TestFunc112()(arg_b8 %in_arg0) 59 | { 60 | ret; 61 | }; 62 | 63 | function &TestFunc113()(arg_b16 %in_arg0) 64 | { 65 | ret; 66 | }; 67 | 68 | function &TestFunc114()(arg_b32 %in_arg0) 69 | { 70 | ret; 71 | }; 72 | 73 | function &TestFunc115()(arg_b64 %in_arg0) 74 | { 75 | ret; 76 | }; 77 | 78 | function &TestFunc116()(arg_b128 %in_arg0) 79 | { 80 | ret; 81 | }; 82 | 83 | function &TestFunc199()(arg_u8x4 %in_arg0) 84 | { 85 | ret; 86 | }; 87 | 88 | function &TestFunc121()(arg_s8x4 %in_arg0) 89 | { 90 | ret; 91 | }; 92 | 93 | function &TestFunc122()(arg_u8x8 %in_arg0) 94 | { 95 | ret; 96 | }; 97 | 98 | function &TestFunc123()(arg_s8x8 %in_arg0) 99 | { 100 | ret; 101 | }; 102 | 103 | function &TestFunc124()(arg_u8x16 %in_arg0) 104 | { 105 | ret; 106 | }; 107 | 108 | function &TestFunc125()(arg_s8x16 %in_arg0) 109 | { 110 | ret; 111 | }; 112 | 113 | function &TestFunc126()(arg_u16x2 %in_arg0) 114 | { 115 | ret; 116 | }; 117 | 118 | function &TestFunc127()(arg_s16x2 %in_arg0) 119 | { 120 | ret; 121 | }; 122 | 123 | function &TestFunc128()(arg_f16x2 %in_arg0) 124 | { 125 | ret; 126 | }; 127 | 128 | function &TestFunc129()(arg_u16x4 %in_arg0) 129 | { 130 | ret; 131 | }; 132 | 133 | function &TestFunc120()(arg_s16x4 %in_arg0) 134 | { 135 | ret; 136 | }; 137 | 138 | function &TestFunc131()(arg_f16x4 %in_arg0) 139 | { 140 | ret; 141 | }; 142 | 143 | function &TestFunc132()(arg_u16x8 %in_arg0) 144 | { 145 | ret; 146 | }; 147 | 148 | function &TestFunc133()(arg_s16x8 %in_arg0) 149 | { 150 | ret; 151 | }; 152 | 153 | function &TestFunc134()(arg_f16x8 %in_arg0) 154 | { 155 | ret; 156 | }; 157 | 158 | function &TestFunc135()(arg_u32x2 %in_arg0) 159 | { 160 | ret; 161 | }; 162 | 163 | function &TestFunc136()(arg_s32x2 %in_arg0) 164 | { 165 | ret; 166 | }; 167 | 168 | function &TestFunc137()(arg_f32x2 %in_arg0) 169 | { 170 | ret; 171 | }; 172 | 173 | function &TestFunc138()(arg_u32x4 %in_arg0) 174 | { 175 | ret; 176 | }; 177 | 178 | function &TestFunc139()(arg_s32x4 %in_arg0) 179 | { 180 | ret; 181 | }; 182 | 183 | function &TestFunc130()(arg_f32x4 %in_arg0) 184 | { 185 | ret; 186 | }; 187 | 188 | function &TestFunc141()(arg_u64x2 %in_arg0) 189 | { 190 | ret; 191 | }; 192 | 193 | function &TestFunc142()(arg_s64x2 %in_arg0) 194 | { 195 | ret; 196 | }; 197 | 198 | function &TestFunc143()(arg_f64x2 %in_arg0) 199 | { 200 | ret; 201 | }; 202 | -------------------------------------------------------------------------------- /tests/1.0/syntax/009_function_arg_generic_base.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$base:$large:$zero; 2 | 3 | function &TestFunc100()(arg_s8 %in_arg0) 4 | { 5 | ret; 6 | }; 7 | 8 | function &TestFunc101()(arg_s16 %in_arg0) 9 | { 10 | ret; 11 | }; 12 | 13 | function &TestFunc102()(arg_s32 %in_arg0) 14 | { 15 | ret; 16 | }; 17 | 18 | function &TestFunc103()(arg_s64 %in_arg0) 19 | { 20 | ret; 21 | }; 22 | 23 | function &TestFunc104()(arg_u8 %in_arg0) 24 | { 25 | ret; 26 | }; 27 | 28 | function &TestFunc105()(arg_u16 %in_arg0) 29 | { 30 | ret; 31 | }; 32 | 33 | function &TestFunc106()(arg_u32 %in_arg0) 34 | { 35 | ret; 36 | }; 37 | 38 | function &TestFunc107()(arg_u64 %in_arg0) 39 | { 40 | ret; 41 | }; 42 | 43 | function &TestFunc108()(arg_f16 %in_arg0) 44 | { 45 | ret; 46 | }; 47 | 48 | function &TestFunc109()(arg_f32 %in_arg0) 49 | { 50 | ret; 51 | }; 52 | 53 | function &TestFunc112()(arg_b8 %in_arg0) 54 | { 55 | ret; 56 | }; 57 | 58 | function &TestFunc113()(arg_b16 %in_arg0) 59 | { 60 | ret; 61 | }; 62 | 63 | function &TestFunc114()(arg_b32 %in_arg0) 64 | { 65 | ret; 66 | }; 67 | 68 | function &TestFunc115()(arg_b64 %in_arg0) 69 | { 70 | ret; 71 | }; 72 | 73 | function &TestFunc116()(arg_b128 %in_arg0) 74 | { 75 | ret; 76 | }; 77 | 78 | function &TestFunc199()(arg_u8x4 %in_arg0) 79 | { 80 | ret; 81 | }; 82 | 83 | function &TestFunc121()(arg_s8x4 %in_arg0) 84 | { 85 | ret; 86 | }; 87 | 88 | function &TestFunc122()(arg_u8x8 %in_arg0) 89 | { 90 | ret; 91 | }; 92 | 93 | function &TestFunc123()(arg_s8x8 %in_arg0) 94 | { 95 | ret; 96 | }; 97 | 98 | function &TestFunc124()(arg_u8x16 %in_arg0) 99 | { 100 | ret; 101 | }; 102 | 103 | function &TestFunc125()(arg_s8x16 %in_arg0) 104 | { 105 | ret; 106 | }; 107 | 108 | function &TestFunc126()(arg_u16x2 %in_arg0) 109 | { 110 | ret; 111 | }; 112 | 113 | function &TestFunc127()(arg_s16x2 %in_arg0) 114 | { 115 | ret; 116 | }; 117 | 118 | function &TestFunc128()(arg_f16x2 %in_arg0) 119 | { 120 | ret; 121 | }; 122 | 123 | function &TestFunc129()(arg_u16x4 %in_arg0) 124 | { 125 | ret; 126 | }; 127 | 128 | function &TestFunc120()(arg_s16x4 %in_arg0) 129 | { 130 | ret; 131 | }; 132 | 133 | function &TestFunc131()(arg_f16x4 %in_arg0) 134 | { 135 | ret; 136 | }; 137 | 138 | function &TestFunc132()(arg_u16x8 %in_arg0) 139 | { 140 | ret; 141 | }; 142 | 143 | function &TestFunc133()(arg_s16x8 %in_arg0) 144 | { 145 | ret; 146 | }; 147 | 148 | function &TestFunc134()(arg_f16x8 %in_arg0) 149 | { 150 | ret; 151 | }; 152 | 153 | function &TestFunc135()(arg_u32x2 %in_arg0) 154 | { 155 | ret; 156 | }; 157 | 158 | function &TestFunc136()(arg_s32x2 %in_arg0) 159 | { 160 | ret; 161 | }; 162 | 163 | function &TestFunc137()(arg_f32x2 %in_arg0) 164 | { 165 | ret; 166 | }; 167 | 168 | function &TestFunc138()(arg_u32x4 %in_arg0) 169 | { 170 | ret; 171 | }; 172 | 173 | function &TestFunc139()(arg_s32x4 %in_arg0) 174 | { 175 | ret; 176 | }; 177 | 178 | function &TestFunc130()(arg_f32x4 %in_arg0) 179 | { 180 | ret; 181 | }; 182 | 183 | function &TestFunc141()(arg_u64x2 %in_arg0) 184 | { 185 | ret; 186 | }; 187 | 188 | function &TestFunc142()(arg_s64x2 %in_arg0) 189 | { 190 | ret; 191 | }; 192 | -------------------------------------------------------------------------------- /tests/1.0/syntax/009_function_arg_passing.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc1(arg_s64x2 %out_arg0)( 4 | arg_u32 %in_arg0, 5 | align(4) arg_s8 %in_arg1) 6 | { 7 | ret; 8 | }; 9 | 10 | function &TestFunc2(arg_s64x2 %out_arg0)(align(4) arg_s8 %in_arg[]) 11 | { 12 | ret; 13 | }; 14 | 15 | function &TestFunc3()(align(8) arg_s8 %in_arg[2]) 16 | { 17 | ret; 18 | }; 19 | // natural align = no align 20 | 21 | function &TestFunc4()( 22 | arg_u32 %in_arg0, 23 | arg_s16 %in_arg1) 24 | { 25 | ret; 26 | }; 27 | 28 | function &TestCalls()() 29 | { 30 | { 31 | arg_s64x2 %oarg; 32 | arg_u32 %iarg0; 33 | align(4) arg_s8 %iarg1; 34 | st_arg_u32 0, [%iarg0]; 35 | st_arg_s8 0, [%iarg1]; 36 | call &TestFunc1 (%oarg) (%iarg0, %iarg1); 37 | } 38 | { 39 | arg_s64x2 %oarg; 40 | align(4) arg_s8 %iarg[3]; 41 | st_arg_s8 0, [%iarg]; 42 | st_arg_s8 1, [%iarg][1]; 43 | st_arg_s8 2, [%iarg][2]; 44 | call &TestFunc2 (%oarg) (%iarg); 45 | } 46 | { 47 | align(8) arg_s8 %iarg[2]; 48 | st_arg_s8 0, [%iarg]; 49 | st_arg_s8 1, [%iarg][1]; 50 | call &TestFunc3 () (%iarg); 51 | } 52 | { 53 | arg_u32 %iarg0; 54 | // 55 | // natural align = no align 56 | // 57 | arg_s16 %iarg1; 58 | st_arg_u32 0, [%iarg0]; 59 | st_arg_s16 0, [%iarg1]; 60 | call &TestFunc4 () (%iarg0, %iarg1); 61 | } 62 | ret; 63 | }; 64 | -------------------------------------------------------------------------------- /tests/1.0/syntax/009_function_decl.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | // ----------------- 3 | // A name can be both defined in a module and also declared in the 4 | // same module. 5 | // ----------------- 6 | 7 | decl function &f1()(); 8 | 9 | function &tst1()() 10 | { 11 | { 12 | call &f1 () (); 13 | } 14 | }; 15 | 16 | function &f1()() 17 | { 18 | }; 19 | // ----------------- 20 | 21 | function &f2()() 22 | { 23 | }; 24 | 25 | function &tst2()() 26 | { 27 | { 28 | call &f2 () (); 29 | } 30 | }; 31 | 32 | decl function &f2()(); 33 | // ----------------- 34 | 35 | decl prog function &f3()(); 36 | 37 | function &tst3()() 38 | { 39 | { 40 | call &f3 () (); 41 | } 42 | }; 43 | // ----------------- 44 | 45 | prog function &f4()() 46 | { 47 | }; 48 | 49 | function &tst4()() 50 | { 51 | { 52 | call &f4 () (); 53 | } 54 | }; 55 | 56 | decl prog function &f4()(); 57 | // ----------------- 58 | // align 4 = natural alignment for u32 59 | 60 | decl function &TestFunc1()(arg_u32 %a); 61 | 62 | function &TestFunc1()(arg_u32 %a) 63 | { 64 | ret; 65 | }; 66 | -------------------------------------------------------------------------------- /tests/1.0/syntax/009_function_forw_decl.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | decl function &TestFunc01()(arg_u32 %in_arg0); 4 | 5 | decl function &TestFunc12()( 6 | arg_u32 %in_arg0, 7 | arg_u32 %in_arg1); 8 | 9 | function &TestFunc()() 10 | { 11 | { 12 | arg_u32 %iarg0; 13 | st_arg_u32 0, [%iarg0]; 14 | call &TestFunc01 () (%iarg0); 15 | } 16 | { 17 | arg_u32 %iarg0; 18 | arg_u32 %iarg1; 19 | st_arg_u32 0, [%iarg0]; 20 | st_arg_u32 0, [%iarg1]; 21 | call &TestFunc12 () (%iarg0, %iarg1); 22 | } 23 | ret; 24 | }; 25 | 26 | function &TestFunc01()(arg_u32 %in_arg0) 27 | { 28 | { 29 | arg_u32 %iarg0; 30 | arg_u32 %iarg1; 31 | st_arg_u32 0, [%iarg0]; 32 | st_arg_u32 0, [%iarg1]; 33 | call &TestFunc12 () (%iarg0, %iarg1); 34 | } 35 | { 36 | call &TestFunc () (); 37 | } 38 | ret; 39 | }; 40 | 41 | function &TestFunc12()( 42 | arg_u32 %in_arg0, 43 | arg_u32 %in_arg1) 44 | { 45 | ret; 46 | }; 47 | -------------------------------------------------------------------------------- /tests/1.0/syntax/009_function_generic.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc()() 4 | { 5 | ret; 6 | }; 7 | 8 | function &TestFunc01()(arg_u8x8 %in_arg0) 9 | { 10 | 11 | @lab1: 12 | ret; 13 | }; 14 | 15 | function &TestFunc12(arg_s32x2 %out_arg0)( 16 | arg_u32 %in_arg0, 17 | arg_u32 %in_arg1) 18 | { 19 | 20 | @lab1: 21 | ret; 22 | }; 23 | 24 | function &TestCalls()() 25 | { 26 | 27 | @lab1: 28 | { 29 | call &TestFunc () (); 30 | } 31 | { 32 | call &TestFunc () (); 33 | } 34 | { 35 | call &TestFunc () (); 36 | } 37 | { 38 | arg_u8x8 %iarg0; 39 | st_arg_u64 0, [%iarg0]; 40 | call &TestFunc01 () (%iarg0); 41 | } 42 | { 43 | arg_s32x2 %oarg; 44 | arg_u32 %iarg0; 45 | arg_u32 %iarg1; 46 | st_arg_u32 0, [%iarg0]; 47 | st_arg_u32 0, [%iarg1]; 48 | call &TestFunc12 (%oarg) (%iarg0, %iarg1); 49 | ld_arg_u64 $d0, [%oarg]; 50 | } 51 | ret; 52 | }; 53 | indirect function &indirect_func()() 54 | { 55 | ret; 56 | }; 57 | 58 | function &TestStaticCalls()(arg_u32 %in_arg0) 59 | { 60 | // 61 | { 62 | call &indirect_func () (); 63 | } 64 | }; 65 | 66 | function &f(arg_u32 %a)( 67 | arg_u32 %in_arg0, 68 | arg_u32 %in_arg1) 69 | { 70 | ret; 71 | }; 72 | //--------------------------------------------------------------------------- 73 | // Several Identical Decl are possible 74 | 75 | decl function &TestFunc01()(arg_u8x8 %in_arg000); 76 | 77 | decl function &TestFunc01()(arg_u8x8 %in_arg0); 78 | 79 | decl function &TestFunc01()(arg_u8x8 %in_arg111); 80 | -------------------------------------------------------------------------------- /tests/1.0/syntax/009_function_indirect.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc12a(arg_b32 %out_arg0)( 4 | arg_s32 %in_arg0, 5 | arg_u32 %in_arg1) 6 | { 7 | ret; 8 | }; 9 | 10 | decl function &TestFunc12b(arg_b32 %out_arg0)( 11 | arg_s32 %in_arg0, 12 | arg_u32 %in_arg1); 13 | signature &TestFuncSign12(arg_b32)( 14 | arg_s32, 15 | arg_u32); 16 | signature &TestFuncSign02()( 17 | arg_s32, 18 | arg_u32); 19 | signature &TestFuncSign10(arg_b32)(); 20 | signature &TestFuncSign00()(); 21 | indirect function &foo1()() 22 | { 23 | }; 24 | decl prog indirect function &foo2()(); 25 | 26 | function &TestCalls()(arg_u32 %in_arg0) 27 | { 28 | { 29 | arg_b32 %oarg0; 30 | arg_s32 %iarg0; 31 | arg_u32 %iarg1; 32 | st_arg_s32 0, [%iarg0]; 33 | st_arg_u32 0, [%iarg1]; 34 | scall_width(2147483648)_u64 WAVESIZE (%oarg0) (%iarg0, %iarg1) [&TestFunc12a]; 35 | } 36 | { 37 | arg_b32 %oarg0; 38 | arg_s32 %iarg0; 39 | arg_u32 %iarg1; 40 | st_arg_s32 0, [%iarg0]; 41 | st_arg_u32 0, [%iarg1]; 42 | scall_u32 $s1 (%oarg0) (%iarg0, %iarg1) [&TestFunc12a]; 43 | } 44 | { 45 | arg_b32 %oarg0; 46 | arg_s32 %iarg0; 47 | arg_u32 %iarg1; 48 | st_arg_s32 0, [%iarg0]; 49 | st_arg_u32 0, [%iarg1]; 50 | scall_u64 $d1 (%oarg0) (%iarg0, %iarg1) [&TestFunc12a, &TestFunc12b]; 51 | } 52 | { 53 | arg_b32 %oarg0; 54 | arg_s32 %iarg0; 55 | arg_u32 %iarg1; 56 | st_arg_s32 0, [%iarg0]; 57 | st_arg_u32 0, [%iarg1]; 58 | scall_u64 $d1 (%oarg0) (%iarg0, %iarg1) [&TestFunc12a, &TestFunc12b]; 59 | } 60 | { 61 | arg_b32 %oarg0; 62 | arg_s32 %iarg0; 63 | arg_u32 %iarg1; 64 | st_arg_s32 0, [%iarg0]; 65 | st_arg_u32 0, [%iarg1]; 66 | scall_u64 1 (%oarg0) (%iarg0, %iarg1) [&TestFunc12a, &TestFunc12b]; 67 | } 68 | { 69 | arg_b32 %oarg0; 70 | arg_s32 %iarg0; 71 | arg_u32 %iarg1; 72 | st_arg_s32 0, [%iarg0]; 73 | st_arg_u32 0, [%iarg1]; 74 | icall_u64 $d1 (%oarg0) (%iarg0, %iarg1) &TestFuncSign12; 75 | } 76 | { 77 | arg_b32 %oarg0; 78 | arg_s32 %iarg0; 79 | arg_u32 %iarg1; 80 | st_arg_s32 0, [%iarg0]; 81 | st_arg_u32 0, [%iarg1]; 82 | icall_u64 $d1 (%oarg0) (%iarg0, %iarg1) &TestFuncSign12; 83 | } 84 | { 85 | arg_s32 %iarg0; 86 | arg_u32 %iarg1; 87 | st_arg_s32 0, [%iarg0]; 88 | st_arg_u32 0, [%iarg1]; 89 | icall_width(2)_u64 $d1 () (%iarg0, %iarg1) &TestFuncSign02; 90 | } 91 | { 92 | arg_s32 %iarg0; 93 | arg_u32 %iarg1; 94 | st_arg_s32 0, [%iarg0]; 95 | st_arg_u32 0, [%iarg1]; 96 | icall_width(WAVESIZE)_u64 $d1 () (%iarg0, %iarg1) &TestFuncSign02; 97 | } 98 | { 99 | arg_b32 %oarg0; 100 | icall_width(all)_u64 $d1 (%oarg0) () &TestFuncSign10; 101 | } 102 | { 103 | icall_width(all)_u64 $d1 () () &TestFuncSign00; 104 | } 105 | ret; 106 | }; 107 | 108 | function &TestFunc12b(arg_b32 %out_arg0)( 109 | arg_s32 %in_arg0, 110 | arg_u32 %in_arg1) 111 | { 112 | ret; 113 | }; 114 | //================================================================== 115 | signature &TestSignatureNoRet()(); 116 | 117 | function &TestCallsNoRet()( 118 | arg_b64 %addr0, 119 | arg_b64 %addr1, 120 | arg_b64 %addr2) 121 | { 122 | ld_arg_u64 $d1, [%addr0]; 123 | { 124 | icall_width(all)_u64 $d1 () () &TestSignatureNoRet; 125 | } 126 | }; 127 | //================================================================== 128 | // Call Targets may be defined, not declared. It is ok 129 | 130 | decl function &TestFuncX()(arg_s32 %in_arg0); 131 | 132 | decl prog function &TestFuncUndef()(arg_s32 %in_arg0); 133 | // defined elsewhere 134 | 135 | function &TestCallUndefTarget()(arg_u32 %in_arg0) 136 | { 137 | { 138 | arg_s32 %arg0; 139 | st_arg_s32 0, [%arg0]; 140 | scall_u32 $s1 () (%arg0) [&TestFuncX, &TestFuncUndef]; 141 | } 142 | }; 143 | 144 | function &TestFuncX()(arg_s32 %in_arg0) 145 | { 146 | ret; 147 | }; 148 | signature &bar_or_foo_t(arg_u32 %r)(arg_f32 %a); 149 | decl indirect function &bar(arg_u32 %r)(arg_f32 %a); 150 | decl indirect function &foo(arg_u32 %r)(arg_f32 %a); 151 | global_u64 &i; 152 | 153 | kernel &example_icall(kernarg_u64 %res) 154 | { 155 | ld_global_u64 $d1, [&i]; 156 | { 157 | arg_f32 %a; 158 | arg_u32 %r; 159 | st_arg_f32 0F40000000, [%a]; 160 | icall_width(all)_u64 $d1 (%r) (%a) &bar_or_foo_t; 161 | ld_arg_u32 $s1, [%r]; 162 | ld_kernarg_u64 $d1, [%res]; 163 | st_global_u32 $s1, [$d1]; 164 | } 165 | }; 166 | indirect function &bar(arg_u32 %r)(arg_f32 %a) 167 | { 168 | }; 169 | indirect function &foo(arg_u32 %r)(arg_f32 %a) 170 | { 171 | }; 172 | -------------------------------------------------------------------------------- /tests/1.0/syntax/009_function_indirect_small.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$small:$near; 2 | signature &TestFuncSign12(arg_b32)( 3 | arg_s32, 4 | arg_u32); 5 | signature &TestFuncSign02()( 6 | arg_s32, 7 | arg_u32); 8 | signature &TestFuncSign10(arg_b32)(); 9 | signature &TestFuncSign00()(); 10 | indirect function &foo1()() 11 | { 12 | }; 13 | decl prog indirect function &foo2()(); 14 | 15 | function &TestCalls()(arg_u32 %in_arg0) 16 | { 17 | { 18 | arg_b32 %oarg0; 19 | arg_s32 %iarg0; 20 | arg_u32 %iarg1; 21 | st_arg_s32 0, [%iarg0]; 22 | st_arg_u32 0, [%iarg1]; 23 | icall_u32 $s1 (%oarg0) (%iarg0, %iarg1) &TestFuncSign12; 24 | } 25 | { 26 | arg_b32 %oarg0; 27 | arg_s32 %iarg0; 28 | arg_u32 %iarg1; 29 | st_arg_s32 0, [%iarg0]; 30 | st_arg_u32 0, [%iarg1]; 31 | icall_u32 $s1 (%oarg0) (%iarg0, %iarg1) &TestFuncSign12; 32 | } 33 | { 34 | arg_s32 %iarg0; 35 | arg_u32 %iarg1; 36 | st_arg_s32 0, [%iarg0]; 37 | st_arg_u32 0, [%iarg1]; 38 | icall_width(2)_u32 $s1 () (%iarg0, %iarg1) &TestFuncSign02; 39 | } 40 | { 41 | arg_s32 %iarg0; 42 | arg_u32 %iarg1; 43 | st_arg_s32 0, [%iarg0]; 44 | st_arg_u32 0, [%iarg1]; 45 | icall_width(WAVESIZE)_u32 $s1 () (%iarg0, %iarg1) &TestFuncSign02; 46 | } 47 | { 48 | arg_b32 %oarg0; 49 | icall_width(all)_u32 $s1 (%oarg0) () &TestFuncSign10; 50 | } 51 | { 52 | icall_width(all)_u32 $s1 () () &TestFuncSign00; 53 | } 54 | }; 55 | -------------------------------------------------------------------------------- /tests/1.0/syntax/009_function_module.hsail: -------------------------------------------------------------------------------- 1 | // Module-scope functions must be defined 2 | // 3 | module &moduleName:1:0:$full:$large:$default; 4 | // 5 | decl indirect function &f1()(); 6 | 7 | decl function &f2()(); 8 | // 9 | 10 | function &Test()() 11 | { 12 | { 13 | call &f1 () (); 14 | } 15 | }; 16 | // 17 | indirect function &f1()() 18 | { 19 | }; 20 | 21 | function &f2()() 22 | { 23 | }; 24 | // 25 | // 26 | -------------------------------------------------------------------------------- /tests/1.0/syntax/009_function_signature_0.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | extension "IMAGE"; 3 | signature &TestSignature0()(arg_b32 %x[]); 4 | signature &TestSignature00()(arg_b32 %y[]); 5 | signature &TestSignature1(arg_b32 %x[4])(); 6 | signature &TestSignature11(arg_b32 %y[4])(); 7 | signature &TestSignature2(arg_b32)( 8 | arg_s32, 9 | arg_u32); 10 | signature &TestSignature22(arg_b32)( 11 | arg_s32, 12 | arg_u32); 13 | signature &TestSignature3(arg_b32 %out_arg0)( 14 | arg_s32, 15 | arg_u32); 16 | signature &TestSignature33(arg_b32)( 17 | arg_s32 %in_arg0, 18 | arg_u32 %in_arg1); 19 | signature &TestSignature4(align(4) arg_b8)( 20 | align(8) arg_s32, 21 | align(8) arg_u32 %in_arg111); 22 | signature &TestSignature44(align(4) arg_b8)( 23 | align(8) arg_s32, 24 | align(8) arg_u32 %in_arg222); 25 | signature &TestSignature5()( 26 | align(8) arg_s32, 27 | align(8) arg_u32 %in_arg111); 28 | signature &TestSignature55()( 29 | align(8) arg_s32, 30 | align(8) arg_u32 %in_arg111); 31 | signature &TestSignature77()( 32 | align(16) arg_samp, 33 | align(16) arg_rwimg); 34 | signature &TestSignature6()(); 35 | signature &TestSignature7()(); 36 | signature &TestSignature8()(); 37 | signature &TestSignature9()( 38 | align(256) arg_samp, 39 | align(256) arg_b128); 40 | 41 | function &TestCalls()( 42 | arg_b64 %addr0, 43 | arg_b64 %addr1, 44 | arg_b64 %addr2) 45 | { 46 | { 47 | arg_b32 %arg[4]; 48 | icall_u64 $d1 () (%arg) &TestSignature0; 49 | } 50 | { 51 | arg_b32 %oarg0[4]; 52 | ld_arg_u64 $d1, [%addr0]; 53 | icall_u64 $d1 (%oarg0) () &TestSignature1; 54 | } 55 | { 56 | arg_b32 %oarg0; 57 | arg_s32 %iarg0; 58 | arg_u32 %iarg1; 59 | st_arg_s32 0, [%iarg0]; 60 | st_arg_u32 0, [%iarg1]; 61 | ld_arg_u64 $d1, [%addr1]; 62 | icall_u64 $d1 (%oarg0) (%iarg0, %iarg1) &TestSignature2; 63 | } 64 | { 65 | arg_b32 %oarg0; 66 | arg_s32 %iarg0; 67 | arg_u32 %iarg1; 68 | st_arg_s32 0, [%iarg0]; 69 | st_arg_u32 0, [%iarg1]; 70 | ld_arg_u64 $d1, [%addr2]; 71 | icall_u64 $d1 (%oarg0) (%iarg0, %iarg1) &TestSignature3; 72 | } 73 | { 74 | align(4) arg_b8 %oarg0; 75 | align(8) arg_s32 %iarg0; 76 | align(8) arg_u32 %iarg1; 77 | st_arg_s32 0, [%iarg0]; 78 | st_arg_u32 0, [%iarg1]; 79 | icall_width(all)_u64 $d1 (%oarg0) (%iarg0, %iarg1) &TestSignature4; 80 | } 81 | { 82 | align(8) arg_s32 %iarg0; 83 | align(8) arg_u32 %iarg1; 84 | st_arg_s32 0, [%iarg0]; 85 | st_arg_u32 0, [%iarg1]; 86 | icall_width(all)_u64 $d1 () (%iarg0, %iarg1) &TestSignature5; 87 | } 88 | { 89 | icall_width(all)_u64 $d1 () () &TestSignature6; 90 | } 91 | { 92 | icall_width(all)_u64 $d1 () () &TestSignature7; 93 | } 94 | { 95 | icall_width(all)_u64 $d1 () () &TestSignature8; 96 | } 97 | { 98 | align(16) arg_samp %arg0; 99 | align(16) arg_rwimg %arg1; 100 | icall_u64 $d1 () (%arg0, %arg1) &TestSignature77; 101 | } 102 | ret; 103 | }; 104 | -------------------------------------------------------------------------------- /tests/1.0/syntax/009_function_signature_1.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | signature &TestSignature0()(arg_b32 %y[]); 3 | signature &TestSignature2a(arg_b32)( 4 | arg_s32 %x[1], 5 | arg_u32 %y[]); 6 | 7 | function &TestCalls()( 8 | arg_b64 %addr0, 9 | arg_b64 %addr1, 10 | arg_b64 %addr2) 11 | { 12 | { 13 | arg_b32 %oarg0[3]; 14 | ld_arg_u64 $d1, [%addr0]; 15 | icall_u64 $d1 () (%oarg0) &TestSignature0; 16 | } 17 | { 18 | arg_b32 %oarg0; 19 | arg_s32 %iarg0[1]; 20 | arg_u32 %iarg1[1]; 21 | st_arg_s32 0, [%iarg0]; 22 | st_arg_u32 0, [%iarg1]; 23 | ld_arg_u64 $d1, [%addr1]; 24 | icall_u64 $d1 (%oarg0) (%iarg0, %iarg1) &TestSignature2a; 25 | } 26 | ret; 27 | }; 28 | -------------------------------------------------------------------------------- /tests/1.0/syntax/009_function_width.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc12a(arg_b32 %out_arg0)( 4 | arg_s32 %in_arg0, 5 | arg_u32 %in_arg1) 6 | { 7 | ret; 8 | }; 9 | 10 | decl function &TestFunc12b(arg_b32 %out_arg0)( 11 | arg_s32 %in_arg0, 12 | arg_u32 %in_arg1); 13 | signature &TestSig(arg_b32)( 14 | arg_s32, 15 | arg_u32); 16 | 17 | function &TestCalls()(arg_u32 %in_arg0) 18 | { 19 | { 20 | arg_b32 %oarg0; 21 | arg_s32 %iarg0; 22 | arg_u32 %iarg1; 23 | st_arg_s32 0, [%iarg0]; 24 | st_arg_u32 0, [%iarg1]; 25 | scall_u64 $d1 (%oarg0) (%iarg0, %iarg1) [&TestFunc12a]; 26 | } 27 | { 28 | arg_b32 %oarg0; 29 | arg_s32 %iarg0; 30 | arg_u32 %iarg1; 31 | st_arg_s32 0, [%iarg0]; 32 | st_arg_u32 0, [%iarg1]; 33 | scall_u64 $d1 (%oarg0) (%iarg0, %iarg1) [&TestFunc12a, &TestFunc12b]; 34 | } 35 | { 36 | arg_b32 %oarg0; 37 | arg_s32 %iarg0; 38 | arg_u32 %iarg1; 39 | st_arg_s32 0, [%iarg0]; 40 | st_arg_u32 0, [%iarg1]; 41 | scall_width(1024)_u64 $d1 (%oarg0) (%iarg0, %iarg1) [&TestFunc12a, &TestFunc12b]; 42 | } 43 | { 44 | arg_b32 %oarg0; 45 | arg_s32 %iarg0; 46 | arg_u32 %iarg1; 47 | st_arg_s32 0, [%iarg0]; 48 | st_arg_u32 0, [%iarg1]; 49 | icall_width(all)_u64 $d1 (%oarg0) (%iarg0, %iarg1) &TestSig; 50 | } 51 | { 52 | arg_b32 %oarg0; 53 | arg_s32 %iarg0; 54 | arg_u32 %iarg1; 55 | st_arg_s32 0, [%iarg0]; 56 | st_arg_u32 0, [%iarg1]; 57 | icall_width(WAVESIZE)_u64 $d1 (%oarg0) (%iarg0, %iarg1) &TestSig; 58 | } 59 | ret; 60 | }; 61 | 62 | function &TestFunc12b(arg_b32 %out_arg0)( 63 | arg_s32 %in_arg0, 64 | arg_u32 %in_arg1) 65 | { 66 | ret; 67 | }; 68 | -------------------------------------------------------------------------------- /tests/1.0/syntax/010_kernel_args.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | extension "IMAGE"; 3 | 4 | kernel &Kernel_02() 5 | { 6 | ret; 7 | }; 8 | 9 | kernel &Kernel_01(kernarg_u8x8 %in_arg0) 10 | { 11 | ret; 12 | }; 13 | 14 | kernel &Kernel_03( 15 | kernarg_samp %in_arg0, 16 | kernarg_rwimg %in_arg1, 17 | kernarg_roimg %in_arg2) 18 | { 19 | ret; 20 | }; 21 | 22 | kernel &Kernel_05( 23 | kernarg_samp %in_arg0[3], 24 | kernarg_rwimg %in_arg1[4], 25 | kernarg_roimg %in_arg2[5]) 26 | { 27 | ret; 28 | }; 29 | -------------------------------------------------------------------------------- /tests/1.0/syntax/010_kernel_decl.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | // ----------------- 3 | // A name can be both defined in a module and also declared in the 4 | // same module. 5 | // ----------------- 6 | 7 | decl kernel &k1(); 8 | 9 | kernel &k1() 10 | { 11 | }; 12 | // ----------------- 13 | 14 | kernel &k2() 15 | { 16 | }; 17 | 18 | decl kernel &k2(); 19 | // ----------------- 20 | -------------------------------------------------------------------------------- /tests/1.0/syntax/010_kernel_generic.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | decl prog kernel &Kernel_00(); 4 | 5 | decl kernel &Kernel_02( 6 | align(256) kernarg_u8 %in_arg0, 7 | kernarg_s16x2 %in_arg1, 8 | kernarg_f64 %in_arg2); 9 | 10 | kernel &Kernel_01(kernarg_u8x8 %in_arg0) 11 | { 12 | ret; 13 | }; 14 | 15 | kernel &Kernel_02( 16 | align(256) kernarg_u8 %in_arg0, 17 | kernarg_s16x2 %in_arg1, 18 | kernarg_f64 %in_arg2) 19 | { 20 | ret; 21 | }; 22 | 23 | decl prog kernel &Kernel_04(); 24 | 25 | prog kernel &Kernel_04() 26 | { 27 | }; 28 | -------------------------------------------------------------------------------- /tests/1.0/syntax/010_kernel_module.hsail: -------------------------------------------------------------------------------- 1 | // Module-scope kernels must be defined 2 | // 3 | module &moduleName:1:0:$full:$large:$default; 4 | // 5 | 6 | decl kernel &k1(); 7 | 8 | kernel &k2() 9 | { 10 | }; 11 | // 12 | 13 | function &TestCalls()() 14 | { 15 | }; 16 | // 17 | 18 | kernel &k1() 19 | { 20 | }; 21 | // 22 | // 23 | -------------------------------------------------------------------------------- /tests/1.0/syntax/011_argscope_generic.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc12(arg_s32x2 %out_arg0)( 4 | arg_u32 %in_arg0, 5 | arg_u32 %in_arg1) 6 | { 7 | ret; 8 | }; 9 | 10 | function &TestFunc()(arg_u32 %z) 11 | { 12 | { 13 | arg_s32x2 %oarg; 14 | arg_u32 %iarg0; 15 | arg_u32 %iarg1; 16 | st_arg_u32 $s0, [%iarg0]; 17 | st_arg_u32 0, [%iarg1]; 18 | call &TestFunc12 (%oarg) (%iarg0, %iarg1); 19 | ld_arg_u64 $d0, [%oarg]; 20 | } 21 | ret; 22 | }; 23 | 24 | kernel &Kernel_03( 25 | kernarg_u8 %in_arg0, 26 | kernarg_s16x2 %in_arg1, 27 | kernarg_f64 %in_arg2) 28 | { 29 | { 30 | pragma ""; 31 | loc 1 2 ""; 32 | // 33 | arg_u32 %iarg0; 34 | pragma ""; 35 | loc 1 2 ""; 36 | // 37 | 38 | @lab: 39 | pragma ""; 40 | loc 1 2 ""; 41 | // 42 | st_arg_u32 0, [%iarg0]; 43 | // 44 | pragma ""; 45 | loc 1 2 ""; 46 | // 47 | call &TestFunc () (%iarg0); 48 | // 49 | pragma ""; 50 | loc 1 2 ""; 51 | } 52 | // 53 | { 54 | arg_u32 %iarg0; 55 | st_arg_u32 0, [%iarg0]; 56 | call &TestFunc () (%iarg0); 57 | } 58 | }; 59 | -------------------------------------------------------------------------------- /tests/1.0/syntax/011_argscope_jumps_01.hsail: -------------------------------------------------------------------------------- 1 | // It is not valid to branch into or out of an argument scope. 2 | module &moduleName:1:0:$full:$large:$default; 3 | 4 | function &TestFunc12(arg_s32x2 %out_arg0)( 5 | arg_u32 %in_arg0, 6 | arg_u32 %in_arg1) 7 | { 8 | ret; 9 | }; 10 | 11 | function &TestFunc()() 12 | { 13 | global_u32 %x1; 14 | global_u32 %x2 = 1; 15 | global_u32 %y1 = 1; 16 | global_u32 %y2; 17 | cbr_b1 $c1, @lab_out2x; 18 | cbr_b1 $c1, @lab_out; 19 | 20 | @l01: 21 | add_s32 $s0, 1, 1; 22 | 23 | @lab_out1x: 24 | add_s32 $s0, 1, 1; 25 | 26 | @l02: 27 | { 28 | arg_s32x2 %oarg; 29 | arg_u32 %iarg0; 30 | arg_u32 %iarg1; 31 | 32 | @lab_in1x: 33 | add_s32 $s0, 1, 1; 34 | 35 | @lab_in1: 36 | st_arg_u32 0, [%iarg0]; 37 | st_arg_u32 0, [%iarg1]; 38 | call &TestFunc12 (%oarg) (%iarg0, %iarg1); 39 | ld_arg_u64 $d0, [%oarg]; 40 | cbr_b1 $c0, @lab_in1; 41 | cbr_b1 $c1, @lab_in1x; 42 | } 43 | 44 | @lab_out2x: 45 | { 46 | arg_s32x2 %oarg; 47 | arg_u32 %x; 48 | // hidden 49 | arg_u32 %y; 50 | 51 | @l03: 52 | add_s32 $s0, 1, 1; 53 | 54 | @lab_in2x: 55 | add_s32 $s0, 1, 1; 56 | 57 | @l04: 58 | add_s32 $s0, 1, 1; 59 | 60 | @lab_in2: 61 | st_arg_u32 0, [%x]; 62 | call &TestFunc12 (%oarg) (%x, %y); 63 | cbr_b1 $c0, @lab_in2; 64 | cbr_b1 $c1, @lab_in2x; 65 | } 66 | ret; 67 | 68 | @lab_out: 69 | cbr_b1 $c1, @lab_out1x; 70 | ret; 71 | }; 72 | -------------------------------------------------------------------------------- /tests/1.0/syntax/011_argscope_jumps_02.hsail: -------------------------------------------------------------------------------- 1 | // It is not valid to branch into or out of an argument scope. 2 | module &moduleName:1:0:$full:$large:$default; 3 | 4 | function &TestFunc12(arg_s32x2 %out_arg0)( 5 | arg_u32 %in_arg0, 6 | arg_u32 %in_arg1) 7 | { 8 | ret; 9 | }; 10 | 11 | function &TestFunc()() 12 | { 13 | // hidden in second arg block 14 | global_u32 %x; 15 | // 16 | // 17 | global_u32 %x1; 18 | global_u32 %x2 = 1; 19 | global_u32 %y1 = 1; 20 | global_u32 %y2; 21 | // 22 | cbr_b1 $c1, @lab_out2x; 23 | cbr_b1 $c1, @lab_out; 24 | { 25 | arg_s32x2 %oarg; 26 | arg_u32 %iarg0; 27 | arg_u32 %iarg1; 28 | 29 | @lab_in1: 30 | st_arg_u32 0, [%iarg0]; 31 | st_arg_u32 0, [%iarg1]; 32 | call &TestFunc12 (%oarg) (%iarg0, %iarg1); 33 | ld_arg_u64 $d0, [%oarg]; 34 | cbr_b1 $c1, @lab_in1x; 35 | cbr_b1 $c0, @lab_in1; 36 | 37 | @l01: 38 | add_s32 $s0, 1, 1; 39 | 40 | @lab_in1x: 41 | add_s32 $s0, 1, 1; 42 | 43 | @l02: 44 | } 45 | 46 | @lab_out1x: 47 | cbr_b1 $c1, @lab_out2x; 48 | { 49 | arg_s32x2 %oarg; 50 | arg_u32 %x; 51 | arg_u32 %y; 52 | 53 | @lab_in2: 54 | st_arg_u32 0, [%x]; 55 | call &TestFunc12 (%oarg) (%x, %y); 56 | cbr_b1 $c1, @lab_in2x; 57 | cbr_b1 $c0, @lab_in2; 58 | 59 | @l03: 60 | add_s32 $s0, 1, 1; 61 | 62 | @lab_in2x: 63 | add_s32 $s0, 1, 1; 64 | 65 | @l04: 66 | } 67 | 68 | @lab_out2x: 69 | ret; 70 | 71 | @lab_out: 72 | cbr_b1 $c1, @lab_out1x; 73 | ret; 74 | }; 75 | -------------------------------------------------------------------------------- /tests/1.0/syntax/011_argscope_jumps_03.hsail: -------------------------------------------------------------------------------- 1 | // It is not valid to branch into or out of an argument scope. 2 | module &moduleName:1:0:$full:$large:$default; 3 | 4 | function &TestFunc12(arg_s32x2 %out_arg0)( 5 | arg_u32 %in_arg0, 6 | arg_u32 %in_arg1) 7 | { 8 | ret; 9 | }; 10 | 11 | function &TestFunc()() 12 | { 13 | global_u32 %y1 = 1; 14 | global_u32 %y2; 15 | cbr_b1 $c1, @lab_out1x; 16 | cbr_b1 $c1, @lab_out; 17 | { 18 | arg_s32x2 %oarg; 19 | arg_u32 %iarg0; 20 | arg_u32 %iarg1; 21 | 22 | @lab_in1: 23 | st_arg_u32 0, [%iarg0]; 24 | st_arg_u32 0, [%iarg1]; 25 | call &TestFunc12 (%oarg) (%iarg0, %iarg1); 26 | ld_arg_u64 $d0, [%oarg]; 27 | cbr_b1 $c1, @lab_in1x; 28 | cbr_b1 $c0, @lab_in1; 29 | 30 | @l01: 31 | add_s32 $s0, 1, 1; 32 | 33 | @lab_in1x: 34 | add_s32 $s0, 1, 1; 35 | 36 | @l02: 37 | } 38 | 39 | @lab_out1x: 40 | { 41 | arg_s32x2 %oarg; 42 | arg_u32 %x; 43 | arg_u32 %y; 44 | 45 | @lab_in1y: 46 | add_s32 $s0, 1, 1; 47 | 48 | @lab_in2: 49 | st_arg_u32 0, [%x]; 50 | call &TestFunc12 (%oarg) (%x, %y); 51 | cbr_b1 $c1, @lab_in1y; 52 | cbr_b1 $c0, @lab_in2; 53 | } 54 | ret; 55 | 56 | @lab_out: 57 | cbr_b1 $c1, @lab_out1x; 58 | ret; 59 | }; 60 | -------------------------------------------------------------------------------- /tests/1.0/syntax/011_argscope_jumps_04.hsail: -------------------------------------------------------------------------------- 1 | // It is not valid to branch into or out of an argument scope. 2 | module &moduleName:1:0:$full:$large:$default; 3 | 4 | function &TestFunc12(arg_s32x2 %out_arg0)( 5 | arg_u32 %in_arg0, 6 | arg_u32 %in_arg1) 7 | { 8 | ret; 9 | }; 10 | 11 | function &TestFunc()() 12 | { 13 | global_u32 %y1 = 1; 14 | global_u32 %y2; 15 | cbr_b1 $c1, @lab_out1x; 16 | cbr_b1 $c1, @lab_out; 17 | { 18 | arg_s32x2 %oarg; 19 | arg_u32 %iarg0; 20 | arg_u32 %iarg1; 21 | 22 | @lab_in1: 23 | st_arg_u32 0, [%iarg0]; 24 | st_arg_u32 0, [%iarg1]; 25 | call &TestFunc12 (%oarg) (%iarg0, %iarg1); 26 | ld_arg_u64 $d0, [%oarg]; 27 | cbr_b1 $c1, @lab_in1x; 28 | cbr_b1 $c0, @lab_in1; 29 | 30 | @lab_in1x: 31 | } 32 | 33 | @l01: 34 | add_s32 $s0, 1, 1; 35 | 36 | @lab_out1x: 37 | add_s32 $s0, 1, 1; 38 | 39 | @l02: 40 | { 41 | arg_s32x2 %oarg; 42 | arg_u32 %x; 43 | // hidden 44 | arg_u32 %y; 45 | 46 | @lab_in1y: 47 | add_s32 $s0, 1, 1; 48 | 49 | @lab_in2: 50 | st_arg_u32 0, [%x]; 51 | call &TestFunc12 (%oarg) (%x, %y); 52 | cbr_b1 $c1, @lab_in1y; 53 | cbr_b1 $c0, @lab_in2; 54 | } 55 | ret; 56 | 57 | @lab_out: 58 | cbr_b1 $c1, @lab_out1x; 59 | ret; 60 | }; 61 | -------------------------------------------------------------------------------- /tests/1.0/syntax/011_argscope_jumps_05.hsail: -------------------------------------------------------------------------------- 1 | // It is not valid to branch into or out of an argument scope. 2 | module &moduleName:1:0:$full:$large:$default; 3 | 4 | function &TestFunc12(arg_s32x2 %out_arg0)( 5 | arg_u32 %in_arg0, 6 | arg_u32 %in_arg1) 7 | { 8 | ret; 9 | }; 10 | 11 | function &TestFunc()() 12 | { 13 | global_u32 %y1 = 1; 14 | global_u32 %y2; 15 | cbr_b1 $c1, @lab_out1x; 16 | cbr_b1 $c1, @lab_out; 17 | cbr_b1 $c1, @lab_out2x; 18 | { 19 | arg_s32x2 %oarg; 20 | arg_u32 %iarg0; 21 | arg_u32 %iarg1; 22 | 23 | @lab_in1: 24 | st_arg_u32 0, [%iarg0]; 25 | st_arg_u32 0, [%iarg1]; 26 | call &TestFunc12 (%oarg) (%iarg0, %iarg1); 27 | ld_arg_u64 $d0, [%oarg]; 28 | cbr_b1 $c1, @lab_in1x; 29 | cbr_b1 $c0, @lab_in1; 30 | cbr_b1 $c1, @lab_in2x; 31 | 32 | @lab_in1x: 33 | 34 | @lab_in2x: 35 | } 36 | 37 | @lab_out1x: 38 | 39 | @lab_out2x: 40 | { 41 | arg_s32x2 %oarg; 42 | arg_u32 %x; 43 | arg_u32 %y; 44 | 45 | @l01: 46 | add_s32 $s0, 1, 1; 47 | 48 | @lab_in1y: 49 | 50 | @lab_in2y: 51 | add_s32 $s0, 1, 1; 52 | 53 | @l02: 54 | 55 | @lab_in2: 56 | st_arg_u32 0, [%x]; 57 | call &TestFunc12 (%oarg) (%x, %y); 58 | cbr_b1 $c1, @lab_in1y; 59 | cbr_b1 $c0, @lab_in2; 60 | cbr_b1 $c1, @lab_in2y; 61 | } 62 | ret; 63 | 64 | @lab_out: 65 | cbr_b1 $c1, @lab_out1x; 66 | ret; 67 | }; 68 | -------------------------------------------------------------------------------- /tests/1.0/syntax/011_argscope_special.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFunc11()( 4 | arg_u32 %in_arg0, 5 | arg_u32 %in_arg1) 6 | { 7 | ret; 8 | }; 9 | 10 | function &TestFunc12(arg_u32 %out_arg0)( 11 | arg_u32 %in_arg0, 12 | arg_u32 %in_arg1) 13 | { 14 | ret; 15 | }; 16 | 17 | function &TestFunc()() 18 | { 19 | private_u32 %x; 20 | // live till the end of function 21 | { 22 | // Argument scope does not affect variables that are not arguments. If a non-argument 23 | // variable is defined inside an argument scope, its lifetime extends to the end of the 24 | // function. 25 | arg_u32 %x; 26 | // live till the end of function 27 | arg_u32 %iarg0; 28 | arg_u32 %iarg1; 29 | st_arg_u32 0, [%iarg0]; 30 | st_arg_u32 0, [%iarg1]; 31 | call &TestFunc12 (%x) (%iarg0, %iarg1); 32 | ld_arg_u32 $s0, [%x]; 33 | } 34 | st_private_u32 0, [%x]; 35 | // must be visible 36 | { 37 | arg_u32 %x; 38 | // hides %x defined in outer scope 39 | arg_u32 %y; 40 | st_arg_u32 0, [%x]; 41 | call &TestFunc11 () (%x, %y); 42 | } 43 | { 44 | arg_u32 %y; 45 | arg_u32 %z; 46 | st_private_u32 0, [%x]; 47 | // %x is visible 48 | st_arg_u32 0, [%y]; 49 | call &TestFunc11 () (%y, %z); 50 | } 51 | st_private_u32 0, [%x]; 52 | // visible again 53 | ret; 54 | }; 55 | -------------------------------------------------------------------------------- /tests/1.0/syntax/012_var_align.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | extension "IMAGE"; 3 | // Natural alignment 4 | global_s8 &x1001; 5 | global_u8 &x1002; 6 | global_b8 &x1003; 7 | global_s16 &x2001; 8 | global_u16 &x2002; 9 | global_f16 &x2003; 10 | global_b16 &x2004; 11 | global_s32 &x3001; 12 | global_u32 &x3002; 13 | global_f32 &x3003; 14 | global_b32 &x3004; 15 | global_u8x4 &x3005; 16 | global_s8x4 &x3006; 17 | global_u16x2 &x3007; 18 | global_s16x2 &x3008; 19 | global_f16x2 &x3009; 20 | global_s64 &x4001; 21 | global_u64 &x4002; 22 | global_f64 &x4003; 23 | global_b64 &x4004; 24 | global_u8x8 &x4005; 25 | global_s8x8 &x4006; 26 | global_u16x4 &x4007; 27 | global_s16x4 &x4008; 28 | global_f16x4 &x4009; 29 | global_u32x2 &x4010; 30 | global_s32x2 &x4011; 31 | global_f32x2 &x4012; 32 | global_rwimg &x5001; 33 | global_roimg &x5002; 34 | global_samp &x5003; 35 | global_b128 &x6001; 36 | global_u16x8 &x6002; 37 | global_s16x8 &x6003; 38 | global_f16x8 &x6004; 39 | global_u32x4 &x6005; 40 | global_s32x4 &x6006; 41 | global_f32x4 &x6007; 42 | // Greater alignment 43 | align(2) global_s8 &x0101; 44 | align(2) global_u8 &x0102; 45 | align(2) global_b8 &x0103; 46 | align(4) global_s8 &x0201; 47 | align(4) global_u8 &x0202; 48 | align(4) global_b8 &x0203; 49 | align(8) global_s8 &x0301; 50 | align(8) global_u8 &x0302; 51 | align(8) global_b8 &x0303; 52 | align(4) global_s16 &x0401; 53 | align(4) global_u16 &x0402; 54 | align(4) global_f16 &x0403; 55 | align(4) global_b16 &x0404; 56 | align(8) global_s16 &x0501; 57 | align(8) global_u16 &x0502; 58 | align(8) global_f16 &x0503; 59 | align(8) global_b16 &x0504; 60 | align(8) global_s32 &x0601; 61 | align(8) global_u32 &x0602; 62 | align(8) global_f32 &x0603; 63 | align(8) global_b32 &x0604; 64 | align(8) global_u8x4 &x0605; 65 | align(8) global_s8x4 &x0606; 66 | align(8) global_u16x2 &x0607; 67 | align(8) global_s16x2 &x0608; 68 | align(8) global_f16x2 &x0609; 69 | align(16) global_s32 &x0701; 70 | align(16) global_u32 &x0702; 71 | align(16) global_f32 &x0703; 72 | align(16) global_b32 &x0704; 73 | align(16) global_u8x4 &x0705; 74 | align(16) global_s8x4 &x0706; 75 | align(16) global_u16x2 &x0707; 76 | align(16) global_s16x2 &x0708; 77 | align(16) global_f16x2 &x0709; 78 | align(16) global_rwimg &x0801; 79 | align(16) global_roimg &x0802; 80 | align(16) global_samp &x0803; 81 | align(32) global_s32 &x0901; 82 | align(32) global_u32 &x0902; 83 | align(64) global_f32 &x0903; 84 | align(64) global_b32 &x0904; 85 | align(128) global_u8x4 &x0905; 86 | align(128) global_s8x4 &x0906; 87 | align(32) global_u16x2 &x0907; 88 | align(64) global_s16x2 &x0908; 89 | align(128) global_f16x2 &x0909; 90 | align(32) global_rwimg &x0911; 91 | align(64) global_roimg &x0912; 92 | align(128) global_samp &x0913; 93 | align(256) global_s32 &x10901; 94 | align(256) global_u32 &x10902; 95 | align(256) global_f32 &x10903; 96 | align(256) global_b32 &x10904; 97 | align(256) global_u8x4 &x10905; 98 | align(256) global_s8x4 &x10906; 99 | align(256) global_u16x2 &x10907; 100 | align(256) global_s16x2 &x10908; 101 | align(256) global_f16x2 &x10909; 102 | align(256) global_samp &x10914; 103 | -------------------------------------------------------------------------------- /tests/1.0/syntax/012_var_alloc.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | // 3 | // alloc(agent) is only available for global segment variables, in both module and function scopes. 4 | // The definition of the variable may have an initializer 5 | // 6 | decl alloc(agent) global_s32 &k1; 7 | alloc(agent) global_s32 &k1; 8 | decl prog alloc(agent) global_s32 &k2; 9 | prog alloc(agent) global_s32 &k2 = 123; 10 | decl prog alloc(agent) const global_s32 &k3; 11 | prog alloc(agent) const global_s32 &k3 = 123; 12 | 13 | function &TestFunc12a()() 14 | { 15 | alloc(agent) global_s64 %k30; 16 | alloc(agent) global_s64 %k31 = 4; 17 | alloc(agent) const global_s64 %k32 = 0x1c8; 18 | }; 19 | -------------------------------------------------------------------------------- /tests/1.0/syntax/012_var_array.hsail: -------------------------------------------------------------------------------- 1 | // If the object is an array, the size of the array must be specified in the 2 | // definition but can be omitted in the declaration. 3 | // 4 | module &moduleName:1:0:$full:$large:$default; 5 | decl prog global_u32 ¬_flexible1[]; 6 | decl prog const global_u32 ¬_flexible2[]; 7 | decl global_u32 ¬_flexible3[]; 8 | global_u32 ¬_flexible3[4]; 9 | prog global_u32 ¬_flexible1[3]; 10 | prog const global_u32 ¬_flexible2[3] = u32[](1, 2, 3); 11 | // Max array size 12 | global_s8 &x1[18446744073709551615]; 13 | global_s16 &x2[9223372036854775807]; 14 | global_s32 &x3[4611686018427387903]; 15 | -------------------------------------------------------------------------------- /tests/1.0/syntax/012_var_array_init.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | // 3 | // HSAIL spec has the following req: 4 | // If there is an initialization (d_init not zero), the value of dim must be the same as the length of the initializer. 5 | // So 3d element must be initialized by 0 6 | // 7 | const global_u32 &global_const33[2] = u32[](1, 2); 8 | const global_u32 &global_const34[3] = u32[](1, 2, 3); 9 | align(8) const global_u32 &globalConst0[3] = u32[](1, 2, 3); 10 | global_u8 &t1[4] = u8[](255, 208, 184, 255); 11 | global_u8 &t2[12] = u8[](255, 28, 31, 30, 31, 30, 31, 31, 30, 31, 255, 255); 12 | global_u8 &t3[8] = u8[](255, 16, 0, 0, 0, 0, 255, 255); 13 | global_s8 &t4[8] = s8[](-1, 16, 1, 2, -72, 0, -1, -1); 14 | global_u16 &t5[4] = u16[](1, 2, 3, 4); 15 | global_u16 &t6[7] = u16[](1, 2, 3, 4, -1, 0, -1); 16 | global_s16 &t7[7] = s16[](1, 2, 3, 4, -1, 0, -1); 17 | global_f16 &t8[3] = f16[](0H3ccd, 0H4200, 0H0000); 18 | global_s32 &b1[3] = s32[](-1, 0, 123); 19 | global_u32 &b2[3] = u32[](-1, 0, -1); 20 | global_f32 &b3[2] = f32[](0Fbf800000, 0F3f800000); 21 | global_s64 &b4[3] = s64[](-1, 0, 123); 22 | global_u64 &b5[3] = u64[](-1, 0, -1); 23 | global_f64 &b6[2] = f64[](0Dbff0000000000000, 0D3ff0000000000000); 24 | global_u8x8 &b7[2] = u8x8[](u8x8(255,255,255,255,255,255,255,255), u8x8(0,0,0,0,0,0,0,0)); 25 | global_f16x4 &b8[2] = f16x4[](f16x4(0H0000,0H2e66,0H3266,0H34cd), f16x4(0H0000,0H2e66,0H3266,0H34cd)); 26 | global_sig64 &s0 = sig64(0); 27 | global_sig64 &s1[1] = sig64[](sig64(0)); 28 | global_sig64 &s2[2] = sig64[](sig64(0), sig64(0)); 29 | global_sig64 &s3[3] = sig64[](sig64(0), sig64(0), sig64(0)); 30 | 31 | kernel &TestKernel() 32 | { 33 | align(8) const global_u32 %globalConst0[3] = u32[](1, 2, 3); 34 | global_sig64 %s1 = sig64(0); 35 | global_sig64 %s2[2] = sig64[](sig64(0), sig64(0)); 36 | global_sig64 %s3[3] = sig64[](sig64(0), sig64(0), sig64(0)); 37 | global_sig64 %s4[3] = sig64[](sig64(0), sig64(0), sig64(0)); 38 | }; 39 | -------------------------------------------------------------------------------- /tests/1.0/syntax/012_var_base.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$base:$large:$zero; 2 | global_s8 &x1001; 3 | global_u8 &x1002; 4 | global_b8 &x1003; 5 | global_s16 &x2001; 6 | global_u16 &x2002; 7 | global_f16 &x2003; 8 | global_b16 &x2004; 9 | global_s32 &x3001; 10 | global_u32 &x3002; 11 | global_f32 &x3003; 12 | global_b32 &x3004; 13 | global_u8x4 &x3005; 14 | global_s8x4 &x3006; 15 | global_u16x2 &x3007; 16 | global_s16x2 &x3008; 17 | global_f16x2 &x3009; 18 | global_s64 &x4001; 19 | global_u64 &x4002; 20 | global_b64 &x4004; 21 | global_u8x8 &x4005; 22 | global_s8x8 &x4006; 23 | global_u16x4 &x4007; 24 | global_s16x4 &x4008; 25 | global_f16x4 &x4009; 26 | global_u32x2 &x4010; 27 | global_s32x2 &x4011; 28 | global_f32x2 &x4012; 29 | global_b128 &x6001; 30 | global_u16x8 &x6002; 31 | global_s16x8 &x6003; 32 | global_f16x8 &x6004; 33 | global_u32x4 &x6005; 34 | global_s32x4 &x6006; 35 | global_f32x4 &x6007; 36 | -------------------------------------------------------------------------------- /tests/1.0/syntax/012_var_decl.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | // ----------------- 3 | // A name can be both defined in a module and also declared in the 4 | // same module. 5 | // ----------------- 6 | decl global_s32 &k1; 7 | decl fbarrier &fb1; 8 | 9 | function &f1()() 10 | { 11 | lda_global_u64 $d4, [&k1]; 12 | ldf_u32 $s0, &fb1; 13 | }; 14 | decl global_s32 &k1; 15 | decl fbarrier &fb1; 16 | global_s32 &k1; 17 | fbarrier &fb1; 18 | decl global_s32 &k1; 19 | decl fbarrier &fb1; 20 | // ----------------- 21 | global_s32 &k2; 22 | fbarrier &fb2; 23 | 24 | function &f2()() 25 | { 26 | lda_global_u64 $d4, [&k2]; 27 | ldf_u32 $s0, &fb2; 28 | }; 29 | decl global_s32 &k2; 30 | decl fbarrier &fb2; 31 | // ----------------- 32 | decl prog global_s32 &k3; 33 | decl prog fbarrier &fb3; 34 | 35 | function &f3()() 36 | { 37 | lda_global_u64 $d4, [&k3]; 38 | ldf_u32 $s0, &fb3; 39 | }; 40 | prog global_s32 &k3; 41 | prog fbarrier &fb3; 42 | // ----------------- 43 | prog global_s32 &k4; 44 | prog fbarrier &fb4; 45 | 46 | function &f4()() 47 | { 48 | lda_global_u64 $d4, [&k4]; 49 | ldf_u32 $s0, &fb4; 50 | }; 51 | decl prog global_s32 &k4; 52 | decl prog fbarrier &fb4; 53 | // ----------------- 54 | -------------------------------------------------------------------------------- /tests/1.0/syntax/012_var_generic.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | extension "IMAGE"; 3 | global_u8 &t1 = 0; 4 | global_s8 &t2 = 0; 5 | global_u16 &t6 = 8; 6 | global_s16 &t7 = -16; 7 | global_f16 &t8 = 0H0000; 8 | global_s32 &b1 = 83; 9 | global_u32 &b2 = 1; 10 | global_f32 &b3 = 0F3f800000; 11 | global_s64 &b4 = 123; 12 | global_u64 &b5 = -123; 13 | global_f64 &b6 = 0D3ff0000000000000; 14 | global_f64 &c7 = 0Dbff0000000000000; 15 | global_f64 &c8 = 0D3ff0000000000000; 16 | global_f64 &c9 = 0D4024000000000000; 17 | global_f64 &c0 = 0D4028b0a3d70a3d71; 18 | global_f64 &c1 = 0D4028b0a3d70a3d71; 19 | global_u8x8 &d2 = u8x8(255,255,255,255,255,255,255,255); 20 | global_f16x4 &d3 = f16x4(0H0000,0H2e66,0H3266,0H34cd); 21 | 22 | function &TestFunc12(arg_s32x2 %out_arg0)( 23 | arg_u32 %in_arg0, 24 | arg_u32 %in_arg1) 25 | { 26 | ret; 27 | }; 28 | 29 | function &TestFunc()(arg_s32 %out_arg0[]) 30 | { 31 | ret; 32 | }; 33 | global_u32 &global_var[3] = u32[](1, 2, 3); 34 | readonly_u32 &readonly_var[1] = u32[](1); 35 | const readonly_u32 &readonly_const[4] = u32[](1, 31, 28, 31); 36 | const global_u32 &global_const[3] = u32[](1, 2, 3); 37 | // not necessary flexible because array size may be omitted in decl 38 | // 39 | decl prog const global_u32 &extern_global_const0[]; 40 | // 41 | // definition => migh have initializer 42 | // 43 | global_u32 &global_var1; 44 | global_u32 &global_var2 = 1; 45 | // 46 | // const definition => must have initializer 47 | // 48 | const global_u32 &global_const_var = 1; 49 | // 50 | // declaration => cannot have initializer 51 | // 52 | decl prog const global_u32 &global_const_var2; 53 | decl prog global_u32 &global_const_var3; 54 | // 55 | // 56 | readonly_u32 &x21; 57 | readonly_u32 &x22[10]; 58 | readonly_roimg &x23; 59 | readonly_samp &x24; 60 | // 61 | 62 | kernel &TestKernel(kernarg_samp %x) 63 | { 64 | const global_u32 %globalConst0 = 1; 65 | align(8) const global_u32 %globalConst1 = 1; 66 | align(8) const global_u32 %globalConst2 = 1; 67 | align(8) const global_u32 %globalConst3 = 1; 68 | align(8) const global_u32 %globalConst4 = 1; 69 | align(8) const global_u32 %globalConst5 = 1; 70 | align(256) const global_u32 %globalConst9 = 1; 71 | const readonly_u32 %readonlyConst = 1; 72 | global_u32 %globalVar1 = 1; 73 | readonly_u32 %readonlyVar1 = 1; 74 | group_u32 %groupVar1; 75 | private_u32 %privateVar1; 76 | spill_u32 %spillVar1; 77 | 78 | @lab: 79 | { 80 | arg_s32x2 %oarg; 81 | arg_u32 %iarg0; 82 | arg_u32 %iarg1; 83 | st_arg_u32 0, [%iarg0]; 84 | st_arg_u32 0, [%iarg1]; 85 | call &TestFunc12 (%oarg) (%iarg0, %iarg1); 86 | ld_arg_u64 $d0, [%oarg]; 87 | } 88 | ret; 89 | }; 90 | -------------------------------------------------------------------------------- /tests/1.0/syntax/012_var_module.hsail: -------------------------------------------------------------------------------- 1 | // Module-scope variables must be defined 2 | module &moduleName:1:0:$full:$large:$default; 3 | decl global_u32 &var1; 4 | decl fbarrier &fb1; 5 | fbarrier &fb2; 6 | global_u32 &var2; 7 | 8 | function &TestCalls()() 9 | { 10 | lda_global_u64 $d1, [&var1]; 11 | ldf_u32 $s0, &fb1; 12 | }; 13 | global_u32 &var1; 14 | fbarrier &fb1; 15 | -------------------------------------------------------------------------------- /tests/1.0/syntax/012_var_sampler.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | extension "IMAGE"; 3 | // All values specified in the initializer are required and cannot be omitted 4 | alloc(agent) global_samp &y1 = samp(coord = unnormalized, filter = nearest, addressing = clamp_to_edge); 5 | alloc(agent) align(256) global_samp &y2 = samp(coord = normalized, filter = linear, addressing = repeat); 6 | readonly_samp &y3 = samp(coord = normalized, filter = linear, addressing = mirrored_repeat); 7 | alloc(agent) global_samp &y5 = samp(coord = unnormalized, filter = nearest, addressing = clamp_to_border); 8 | alloc(agent) global_samp &arr1[1] = samp[](samp(coord = unnormalized, filter = nearest, addressing = clamp_to_edge)); 9 | alloc(agent) global_samp &arr2[1] = samp[](samp(coord = unnormalized, filter = nearest, addressing = clamp_to_border)); 10 | alloc(agent) global_samp &arr3[1] = samp[](samp(coord = unnormalized, filter = nearest, addressing = undefined)); 11 | alloc(agent) global_samp &arr10[2] = samp[]( 12 | samp(coord = normalized, filter = linear, addressing = clamp_to_border), 13 | samp(coord = unnormalized, filter = nearest, addressing = clamp_to_edge) 14 | ); 15 | alloc(agent) global_samp &arr11[2] = samp[]( 16 | samp(coord = normalized, filter = linear, addressing = clamp_to_border), 17 | samp(coord = unnormalized, filter = nearest, addressing = clamp_to_edge) 18 | ); 19 | alloc(agent) global_samp &arr12[2] = samp[]( 20 | samp(coord = normalized, filter = linear, addressing = clamp_to_border), 21 | samp(coord = unnormalized, filter = nearest, addressing = clamp_to_edge) 22 | ); 23 | 24 | kernel &TestKernel( 25 | kernarg_samp %x, 26 | kernarg_samp %y[3]) 27 | { 28 | ret; 29 | }; 30 | -------------------------------------------------------------------------------- /tests/1.0/syntax/013_name_1.hsail: -------------------------------------------------------------------------------- 1 | // Names may have "_" as the second symbol 2 | // 3 | module &moduleName:1:0:$full:$large:$default; 4 | 5 | decl prog function &_()(); 6 | // this is a valid name! 7 | 8 | function &_a()() 9 | { 10 | }; 11 | // this is a valid name! 12 | 13 | function &_0()() 14 | { 15 | }; 16 | // this is a valid name! 17 | -------------------------------------------------------------------------------- /tests/1.0/syntax/013_name_2.hsail: -------------------------------------------------------------------------------- 1 | // Names may have "_" as the second symbol 2 | // 3 | module &moduleName:1:0:$full:$large:$default; 4 | prog global_u32 &_[3] = u32[](1, 2, 3); 5 | global_u32 &_a[3] = u32[](1, 2, 3); 6 | global_u32 &_0[3] = u32[](1, 2, 3); 7 | -------------------------------------------------------------------------------- /tests/1.0/syntax/013_name_3.hsail: -------------------------------------------------------------------------------- 1 | // Names may have "_" as the second symbol 2 | // 3 | module &moduleName:1:0:$full:$large:$default; 4 | extension "IMAGE"; 5 | 6 | kernel &_(kernarg_samp %x) 7 | { 8 | ret; 9 | }; 10 | 11 | kernel &_a(kernarg_samp %x) 12 | { 13 | ret; 14 | }; 15 | 16 | kernel &_0(kernarg_samp %x) 17 | { 18 | ret; 19 | }; 20 | -------------------------------------------------------------------------------- /tests/1.0/syntax/013_name_4.hsail: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////////////////////////////// 2 | ///////////////////////////////////////////////////////////////////////////////////////////////////////// 3 | ///////////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Identifiers 5 | module &m...:1:0:$full:$large:$default; 6 | extension "IMAGE"; 7 | pragma &m...; 8 | prog global_b128 &x12345.; 9 | decl prog global_b8 &x......; 10 | global_b8 &x.12345.; 11 | decl global_b8 &x...; 12 | decl fbarrier &b...; 13 | pragma &x12345., &x......, &x.12345., &x..., &b...; 14 | 15 | kernel &T.est.( 16 | kernarg_u64 %s., 17 | kernarg_u64 %s.., 18 | kernarg_u64 %s...) 19 | { 20 | pragma &T.est., %s., %s.., %s...; 21 | initfbar &b...; 22 | ldf_u32 $s0, &b...; 23 | lda_kernarg_u64 $d4, [%s.]; 24 | lda_kernarg_u64 $d4, [%s..]; 25 | lda_kernarg_u64 $d4, [%s...]; 26 | lda_global_u64 $d4, [&x12345.]; 27 | lda_global_u64 $d4, [&x......]; 28 | lda_global_u64 $d4, [&x.12345.]; 29 | lda_global_u64 $d4, [&x...]; 30 | // lda_group_u32 $s4, [&x...]; 31 | }; 32 | 33 | kernel &T...() 34 | { 35 | global_s32 %s......; 36 | global_s32 %x...; 37 | global_s32 %x.1.2.3.4.5.; 38 | fbarrier %b...; 39 | initfbar %b...; 40 | ldf_u32 $s0, %b...; 41 | pragma %s......, %x..., %x.1.2.3.4.5., %b..., @l...; 42 | 43 | @l...: 44 | sub_s32 $s1, $s2, $s3; 45 | cbr_b1 0, @l...; 46 | ret; 47 | }; 48 | 49 | function &_...()() 50 | { 51 | }; 52 | 53 | function &f...()(arg_u64 %s...) 54 | { 55 | pragma &f...; 56 | { 57 | call &_... () (); 58 | } 59 | }; 60 | global_b8 &x...; 61 | fbarrier &b...; 62 | -------------------------------------------------------------------------------- /tests/1.0/syntax/014_branch.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &test1()() 4 | { 5 | cbr_b1 $c0, @k1; 6 | cbr_width(4)_b1 $c0, @k2; 7 | cbr_width(WAVESIZE)_b1 $c0, @k3; 8 | cbr_width(all)_b1 $c0, @k4; 9 | add_s32 $s1, $s2, $s3; 10 | br @join; 11 | 12 | @k1: 13 | sub_s32 $s1, $s2, $s3; 14 | 15 | @k2: 16 | sub_s32 $s1, $s2, $s3; 17 | cbr_b1 1, @k1; 18 | 19 | @k3: 20 | sub_s32 $s1, $s2, $s3; 21 | br @k1; 22 | 23 | @k4: 24 | sub_s32 $s1, $s2, $s3; 25 | 26 | @join: 27 | ret; 28 | }; 29 | 30 | function &test2()() 31 | { 32 | { 33 | cbr_b1 $c0, @k1; 34 | cbr_width(4)_b1 $c0, @k2; 35 | cbr_width(WAVESIZE)_b1 $c0, @k3; 36 | cbr_width(all)_b1 $c0, @k4; 37 | add_s32 $s1, $s2, $s3; 38 | br @join; 39 | 40 | @k1: 41 | sub_s32 $s1, $s2, $s3; 42 | 43 | @k2: 44 | sub_s32 $s1, $s2, $s3; 45 | cbr_b1 WAVESIZE, @k1; 46 | 47 | @k3: 48 | sub_s32 $s1, $s2, $s3; 49 | br @k1; 50 | 51 | @k4: 52 | sub_s32 $s1, $s2, $s3; 53 | cbr_b1 0, @k1; 54 | 55 | @join: 56 | call &test1 () (); 57 | } 58 | }; 59 | 60 | function &test3()() 61 | { 62 | br @label1; 63 | cbr_b1 $c0, @label1; 64 | cbr_width(2)_b1 $c0, @label2; 65 | cbr_width(all)_b1 $c0, @label3; 66 | sbr_u32 $s1 [@label1]; 67 | sbr_width(2)_u32 $s1 [@label1, @label2]; 68 | sbr_width(all)_u32 $s1 [@label1, @label2, @label3]; 69 | sub_s32 $s1, $s2, $s3; 70 | 71 | @label1: 72 | sub_s32 $s1, $s2, $s3; 73 | 74 | @label2: 75 | sub_s32 $s1, $s2, $s3; 76 | 77 | @label3: 78 | sub_s32 $s1, $s2, $s3; 79 | ret; 80 | }; 81 | 82 | function &test4()() 83 | { 84 | sub_s32 $s1, $s2, $s3; 85 | 86 | @label1: 87 | sub_s32 $s1, $s2, $s3; 88 | 89 | @label2: 90 | sub_s32 $s1, $s2, $s3; 91 | 92 | @label3: 93 | sub_s32 $s1, $s2, $s3; 94 | cbr_b1 $c0, @label1; 95 | cbr_width(2)_b1 $c0, @label2; 96 | cbr_width(all)_b1 $c0, @label3; 97 | sbr_u32 $s1 [@label1]; 98 | sbr_width(2)_u32 $s1 [@label1, @label4]; 99 | sbr_width(2)_u32 -1 [@label1, @label4]; 100 | sbr_width(all)_u64 $d1 [@label1, @label2, @label3]; 101 | sbr_width(all)_u64 1 [@label1, @label2, @label3]; 102 | sbr_width(all)_u64 WAVESIZE [@label1, @label2, @label3]; 103 | 104 | @label4: 105 | sub_s32 $s1, $s2, $s3; 106 | ret; 107 | }; 108 | -------------------------------------------------------------------------------- /tests/1.0/syntax/015_large_memory_model.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$default; 2 | 3 | function &TestFuncX()(arg_s32 %in_arg0) 4 | { 5 | ret; 6 | }; 7 | 8 | decl prog function &TestFuncUndef()(arg_s32 %in_arg0); 9 | global_u32 &global_var[12]; 10 | readonly_u32 &readonly_var[12]; 11 | group_u32 &group_var[12]; 12 | 13 | kernel &testKernel(kernarg_u32 %in_arg0) 14 | { 15 | lda_kernarg_u64 $d1, [%in_arg0]; 16 | ld_kernarg_u32 $s0, [%in_arg0]; 17 | ld_kernarg_u32 $s0, [%in_arg0][12]; 18 | ld_kernarg_u32 $s0, [%in_arg0][$d0+12]; 19 | ret; 20 | }; 21 | 22 | function &TestCallUndefTarget()(arg_u32 %in_arg0[12]) 23 | { 24 | ld_arg_u32 $s0, [%in_arg0]; 25 | ld_arg_u32 $s0, [%in_arg0][12]; 26 | ld_arg_u32 $s0, [%in_arg0][$s0+12]; 27 | ld_global_u32 $s0, [&global_var]; 28 | ld_global_u32 $s0, [&global_var][12]; 29 | ld_global_u32 $s0, [&global_var][$d0+12]; 30 | atomic_and_global_scar_system_b32 $s1, [&global_var], 23; 31 | lda_group_u32 $s1, [&group_var]; 32 | lda_group_u32 $s1, [&group_var][12]; 33 | lda_group_u32 $s1, [&group_var][$s0+12]; 34 | lda_global_u64 $d2, [&global_var]; 35 | lda_global_u64 $d2, [&global_var][12]; 36 | lda_global_u64 $d2, [&global_var][$d0+12]; 37 | lda_readonly_u64 $d2, [&readonly_var]; 38 | lda_readonly_u64 $d2, [&readonly_var][12]; 39 | lda_readonly_u64 $d2, [&readonly_var][$d0+12]; 40 | // Flat address 41 | lda_u64 $d2, [0]; 42 | lda_u64 $d2, [$d0+12]; 43 | lda_u64 $d2, [$d0+12]; 44 | stof_private_u64_u32 $d1, $s0; 45 | stof_group_u64_u32 $d1, $s0; 46 | ftos_private_u32_u64 $s1, $d0; 47 | ftos_group_u32_u64 $s1, $d0; 48 | segmentp_private_b1_u64 $c1, $d1; 49 | }; 50 | 51 | function &test_indirect()() 52 | { 53 | ret; 54 | }; 55 | -------------------------------------------------------------------------------- /tests/1.0/syntax/015_small_memory_model.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$small:$near; 2 | 3 | function &TestFuncX()(arg_s32 %in_arg0) 4 | { 5 | ret; 6 | }; 7 | 8 | decl prog function &TestFuncUndef()(arg_s32 %in_arg0); 9 | global_u32 &global_var[12]; 10 | readonly_u32 &readonly_var[12]; 11 | group_u32 &group_var[12]; 12 | 13 | kernel &testKernel(kernarg_u32 %in_arg0) 14 | { 15 | lda_kernarg_u32 $s1, [%in_arg0]; 16 | ld_kernarg_u32 $s0, [%in_arg0]; 17 | ld_kernarg_u32 $s0, [%in_arg0][12]; 18 | ld_kernarg_u32 $s0, [%in_arg0][$s0+12]; 19 | ret; 20 | }; 21 | 22 | function &TestCallUndefTarget()(arg_u32 %in_arg0[12]) 23 | { 24 | ld_arg_u32 $s0, [%in_arg0]; 25 | ld_arg_u32 $s0, [%in_arg0][12]; 26 | ld_arg_u32 $s0, [%in_arg0][$s0+12]; 27 | ld_global_u32 $s0, [&global_var]; 28 | ld_global_u32 $s0, [&global_var][12]; 29 | ld_global_u32 $s0, [&global_var][$s0+12]; 30 | atomic_and_global_scar_system_b32 $s1, [&global_var], 23; 31 | lda_group_u32 $s1, [&group_var]; 32 | lda_group_u32 $s1, [&group_var][12]; 33 | lda_group_u32 $s1, [&group_var][$s0+12]; 34 | lda_global_u32 $s2, [&global_var]; 35 | lda_global_u32 $s2, [&global_var][12]; 36 | lda_global_u32 $s2, [&global_var][$s0+12]; 37 | lda_readonly_u32 $s2, [&readonly_var]; 38 | lda_readonly_u32 $s2, [&readonly_var][12]; 39 | lda_readonly_u32 $s2, [&readonly_var][$s0+12]; 40 | // Flat address 41 | lda_u32 $s2, [0]; 42 | lda_u32 $s2, [$s0+12]; 43 | lda_u32 $s2, [$s0+12]; 44 | stof_private_u32_u32 $s1, $s0; 45 | stof_group_u32_u32 $s1, $s0; 46 | ftos_private_u32_u32 $s1, $s0; 47 | ftos_group_u32_u32 $s1, $s0; 48 | segmentp_private_b1_u32 $c1, $s1; 49 | }; 50 | 51 | function &test_indirect()() 52 | { 53 | ret; 54 | }; 55 | -------------------------------------------------------------------------------- /tests/1.0/syntax/017_addressing.hsail: -------------------------------------------------------------------------------- 1 | module &moduleName:1:0:$full:$large:$near; 2 | 3 | prog function &foo()() 4 | { 5 | global_f32 %g1[10]; 6 | group_f32 %x[10]; 7 | ld_global_f32 $s2, [%g1][2]; 8 | ld_global_f32 $s1, [%g1]; 9 | ld_global_f32 $s2, [%g1][4]; 10 | lda_global_u64 $d0, [%g1][-4]; 11 | ld_global_u32 $s3, [%g1][$d2]; 12 | ld_global_u32 $s4, [%g1][$d2+4]; 13 | ld_global_u32 $s4, [%g1][$d2-4]; 14 | ld_global_u32 $s5, [100]; 15 | ld_group_f32 $s3, [%x][$s2]; 16 | ld_group_f16 $s5, [100]; 17 | }; 18 | global_s32 &z1[4611686018427387903]; 19 | group_s32 &z2[1073741823]; 20 | 21 | kernel &Test32bitAddr() 22 | { 23 | st_global_s32 -1, [18446744073709551615]; 24 | st_global_s32 -1, [$d0-4]; 25 | st_global_s32 -1, [&z1][-8]; 26 | st_global_s64 -1, [&z1][-12]; 27 | st_global_b128 $q0, [&z1][-20]; 28 | st_group_s32 -1, [4294967295]; 29 | st_group_s32 -1, [$s0-4]; 30 | st_group_s32 -1, [&z2][-8]; 31 | }; 32 | -------------------------------------------------------------------------------- /tests/1.0/syntax/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(HSAILASM $) 2 | if (MSVC) 3 | set(RUNTEST ${CMAKE_CURRENT_SOURCE_DIR}/run_test.cmd) 4 | else() 5 | set(RUNTEST ${CMAKE_CURRENT_SOURCE_DIR}/run_test) 6 | endif() 7 | 8 | macro(syntax_test name) 9 | add_test(NAME 1.0/syntax/${name} 10 | COMMAND ${RUNTEST} ${HSAILASM} ${name} ${CMAKE_CURRENT_SOURCE_DIR} 11 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) 12 | endmacro() 13 | 14 | syntax_test(000_empty_1) 15 | syntax_test(000_inst_image_large) 16 | syntax_test(000_inst_image_small) 17 | syntax_test(000_inst_large) 18 | syntax_test(000_inst_large_base) 19 | syntax_test(000_inst_small) 20 | syntax_test(001_delimiters) 21 | syntax_test(001_order_1) 22 | syntax_test(001_order_2) 23 | syntax_test(001_order_3) 24 | syntax_test(002_version_large) 25 | syntax_test(002_version_small) 26 | syntax_test(003_pragma) 27 | syntax_test(004_extension) 28 | syntax_test(004_extension_CORE) 29 | syntax_test(004_extension_CORE_0) 30 | syntax_test(005_control_00) 31 | syntax_test(005_control_01) 32 | syntax_test(005_control_02) 33 | syntax_test(005_control_03) 34 | syntax_test(005_control_04) 35 | syntax_test(005_control_05) 36 | syntax_test(005_control_06) 37 | syntax_test(005_control_07) 38 | syntax_test(005_control_08) 39 | syntax_test(005_control_09) 40 | syntax_test(005_control_10) 41 | syntax_test(005_control_enablebreakexceptions_1) 42 | syntax_test(005_control_enablebreakexceptions_2) 43 | syntax_test(005_control_enabledetectexceptions_1) 44 | syntax_test(005_control_enabledetectexceptions_2) 45 | syntax_test(005_control_maxdynamicgroupsize) 46 | syntax_test(005_control_maxflatgridsize_1) 47 | syntax_test(005_control_maxflatgridsize_2) 48 | syntax_test(005_control_maxflatworkgroupsize_1) 49 | syntax_test(005_control_maxflatworkgroupsize_2) 50 | syntax_test(005_control_requireddim) 51 | syntax_test(005_control_requiredgridsize_1) 52 | syntax_test(005_control_requiredgridsize_2) 53 | syntax_test(005_control_requiredworkgroupsize_1) 54 | syntax_test(005_control_requiredworkgroupsize_2) 55 | syntax_test(006_loc) 56 | syntax_test(009_function_arg_align) 57 | syntax_test(009_function_arg_array) 58 | syntax_test(009_function_arg_flexible_array) 59 | syntax_test(009_function_arg_generic) 60 | syntax_test(009_function_arg_generic_base) 61 | syntax_test(009_function_arg_passing) 62 | syntax_test(009_function_decl) 63 | syntax_test(009_function_forw_decl) 64 | syntax_test(009_function_generic) 65 | syntax_test(009_function_indirect) 66 | syntax_test(009_function_indirect_small) 67 | syntax_test(009_function_module) 68 | syntax_test(009_function_signature_0) 69 | syntax_test(009_function_signature_1) 70 | syntax_test(009_function_width) 71 | syntax_test(010_kernel_args) 72 | syntax_test(010_kernel_decl) 73 | syntax_test(010_kernel_generic) 74 | syntax_test(010_kernel_module) 75 | syntax_test(011_argscope_generic) 76 | syntax_test(011_argscope_jumps_01) 77 | syntax_test(011_argscope_jumps_02) 78 | syntax_test(011_argscope_jumps_03) 79 | syntax_test(011_argscope_jumps_04) 80 | syntax_test(011_argscope_jumps_05) 81 | syntax_test(011_argscope_special) 82 | syntax_test(012_var_align) 83 | syntax_test(012_var_alloc) 84 | syntax_test(012_var_array) 85 | syntax_test(012_var_array_init) 86 | syntax_test(012_var_base) 87 | syntax_test(012_var_decl) 88 | syntax_test(012_var_generic) 89 | syntax_test(012_var_img) 90 | syntax_test(012_var_module) 91 | syntax_test(012_var_sampler) 92 | syntax_test(013_name_1) 93 | syntax_test(013_name_2) 94 | syntax_test(013_name_3) 95 | syntax_test(013_name_4) 96 | syntax_test(014_branch) 97 | syntax_test(015_large_memory_model) 98 | syntax_test(015_small_memory_model) 99 | syntax_test(016_literal_conversion) 100 | syntax_test(016_literal_conversions_1_0) 101 | syntax_test(017_addressing) 102 | syntax_test(018_aggregate_const) 103 | syntax_test(019_reg_limit) 104 | -------------------------------------------------------------------------------- /tests/1.0/syntax/run_test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -ne 3 ]; then 4 | echo "Usage: $0 HSAILASM NAME DIR" 5 | echo "Error: expected 3 arguments." 6 | exit 1 7 | fi 8 | 9 | set -e 10 | 11 | HSAILASM=$1 12 | NAME=$2 13 | DIR=$3 14 | 15 | echo "Assembling" 16 | $HSAILASM -assemble $DIR/$NAME.hsail -o ${NAME}_1.brig 17 | 18 | echo "Disassembling" 19 | $HSAILASM -disassemble ${NAME}_1.brig -o ${NAME}_2.hsail 20 | 21 | echo "Comparing with disassembly" 22 | diff -u $DIR/$NAME.hsail ${NAME}_2.hsail 23 | 24 | echo "Decoding" 25 | $HSAILASM -decode ${NAME}_1.brig -o ${NAME}_3.yml 26 | -------------------------------------------------------------------------------- /tests/1.0/syntax/run_test.cmd: -------------------------------------------------------------------------------- 1 | @echo on 2 | 3 | set HSAILASM=%1 4 | set NAME=%2 5 | set DIR=%3 6 | 7 | echo "Assembling" 8 | %HSAILASM% -assemble %DIR%/%NAME%.hsail -o %NAME%_1.brig 9 | if errorlevel 1 goto :error 10 | 11 | echo "Disassembling" 12 | %HSAILASM% -disassemble %NAME%_1.brig -o %NAME%_2.hsail 13 | if errorlevel 1 goto :error 14 | 15 | echo "Comparing with disassembly" 16 | diff -u %DIR%/%NAME%.hsail %NAME%_2.hsail 17 | if errorlevel 1 goto :error 18 | 19 | echo "Decoding" 20 | %HSAILASM% -decode %NAME%_1.brig -o %NAME%_3.yml 21 | if errorlevel 1 goto :error 22 | 23 | exit 0 24 | 25 | :error 26 | exit 1 27 | -------------------------------------------------------------------------------- /tests/1.0/syntax_validation/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (SYNTAX_VALIDATION_TESTS) 2 | 3 | set(HSAILASM $) 4 | if (MSVC) 5 | set(RUNTEST ${CMAKE_CURRENT_SOURCE_DIR}/run_test.cmd) 6 | else() 7 | set(RUNTEST ${CMAKE_CURRENT_SOURCE_DIR}/run_test) 8 | endif() 9 | 10 | set(test_dir ${CMAKE_CURRENT_BINARY_DIR}/tests) 11 | file(MAKE_DIRECTORY ${test_dir}) 12 | 13 | add_custom_command( 14 | OUTPUT 15 | ${test_dir}/_testinfo.txt 16 | PRE_BUILD 17 | COMMAND ${PERL_EXECUTABLE} 18 | ${CMAKE_CURRENT_SOURCE_DIR}/testgen.pl 19 | ${CMAKE_CURRENT_SOURCE_DIR}/hsail_negative_tests.txt 20 | ${test_dir} 21 | DEPENDS 22 | ${CMAKE_CURRENT_SOURCE_DIR}/hsail_negative_tests.txt 23 | COMMENT "Generating syntax validation tests" 24 | ) 25 | 26 | add_custom_target(generate-syntax-validation-tests ALL DEPENDS ${test_dir}/_testinfo.txt) 27 | 28 | set(golden_dir ${CMAKE_CURRENT_BINARY_DIR}/golden) 29 | file(MAKE_DIRECTORY ${golden_dir}) 30 | 31 | message("Extracting golden files for syntax validation tests") 32 | execute_process( 33 | COMMAND unzip -u ${CMAKE_CURRENT_SOURCE_DIR}/golden.zip 34 | OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/golden.out 35 | ERROR_FILE ${CMAKE_CURRENT_BINARY_DIR}/golden.err 36 | WORKING_DIRECTORY ${golden_dir} 37 | ) 38 | 39 | macro(syntax_validation_test name) 40 | add_test(NAME 1.0/syntax_validation/${name} 41 | COMMAND ${RUNTEST} ${HSAILASM} ${name} 42 | ${test_dir} ${golden_dir} 43 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) 44 | endmacro() 45 | 46 | macro(syntax_validation_test_f fname) 47 | get_filename_component(fext ${fname} EXT) 48 | get_filename_component(name ${fname} NAME_WE) 49 | get_filename_component(fdir ${fname} DIRECTORY) 50 | syntax_validation_test(${name}) 51 | endmacro() 52 | 53 | file(GLOB files ${golden_dir}/*.log) 54 | foreach(file ${files}) 55 | file(RELATIVE_PATH fname ${golden_dir} ${file}) 56 | syntax_validation_test_f(${fname}) 57 | endforeach() 58 | 59 | endif() 60 | -------------------------------------------------------------------------------- /tests/1.0/syntax_validation/golden.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HSAFoundation/HSAIL-Tools/6514deb6bcb13930aaba2c5d380621cf685f37d2/tests/1.0/syntax_validation/golden.zip -------------------------------------------------------------------------------- /tests/1.0/syntax_validation/hsail_negative_tests.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HSAFoundation/HSAIL-Tools/6514deb6bcb13930aaba2c5d380621cf685f37d2/tests/1.0/syntax_validation/hsail_negative_tests.txt -------------------------------------------------------------------------------- /tests/1.0/syntax_validation/run_test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -ne 4 ]; then 4 | echo "Usage: $0 HSAILASM NAME TEST_DIR GOLDEN_DIR" 5 | echo "Error: expected 4 arguments." 6 | exit 1 7 | fi 8 | 9 | set -e 10 | 11 | HSAILASM=$1 12 | NAME=$2 13 | TEST_DIR=$3 14 | GOLDEN_DIR=$4 15 | 16 | echo "Assembling" 17 | set +e 18 | $HSAILASM -enable-comments -assemble $TEST_DIR/$NAME.hsail -o ${NAME}_1.brig > ${NAME}_2.log 19 | res=$? 20 | set -e 21 | if [ $res -eq 0 ]; then 22 | echo "Assembly passed unexpectedly." 23 | exit 1 24 | fi 25 | 26 | echo "Comparing assembly log with golden" 27 | diff -u ${NAME}_2.log $GOLDEN_DIR/${NAME}.log 28 | -------------------------------------------------------------------------------- /tests/1.0/syntax_validation/run_test.cmd: -------------------------------------------------------------------------------- 1 | @echo on 2 | 3 | set HSAILASM=%1 4 | set NAME=%2 5 | set DIR=%3 6 | 7 | echo "Assembling" 8 | %HSAILASM% -assemble %DIR%/%NAME%.hsail -o %NAME%_1.brig 9 | if errorlevel 1 goto :error 10 | 11 | echo "Disassembling" 12 | %HSAILASM% -disassemble %NAME%_1.brig -o %NAME%_2.hsail 13 | if errorlevel 1 goto :error 14 | 15 | echo "Comparing with disassembly" 16 | diff -u %DIR%/%NAME%.hsail %NAME%_2.hsail 17 | if errorlevel 1 goto :error 18 | 19 | echo "Decoding" 20 | %HSAILASM% -decode %NAME%_1.brig -o %NAME%_3.yml 21 | if errorlevel 1 goto :error 22 | 23 | exit 0 24 | 25 | :error 26 | exit 1 27 | --------------------------------------------------------------------------------