Skip to content

Commit 361a887

Browse files
committed
Updates for v1.1 release.
1 parent 1c6fcc8 commit 361a887

37 files changed

Lines changed: 21561 additions & 600 deletions

CMakeLists.txt

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ cmake_minimum_required(VERSION 3.0)
55
project(isa_spec_manager)
66

77
# Setting compiler flags.
8-
set (CMAKE_CXX_COMPILER g++)
9-
set (CMAKE_CXX_STANDARD 14)
10-
set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${FLAGS})
8+
if (LINUX)
9+
set(CMAKE_CXX_COMPILER g++)
10+
endif ()
11+
set(CMAKE_CXX_STANDARD 14)
12+
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${FLAGS})
1113

1214
# Enable using folders to group projects on Windows (Visual Studio solution).
1315
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
@@ -17,17 +19,27 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1719
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
1820
# Visual Studio
1921
set(CMAKE_CONFIGURATION_TYPES "Release;Debug")
20-
endif()
22+
endif ()
2123

2224
# Setting project directories.
2325
# XML ISA Spec Decoder API: accepts ISA Spec for specific architecture
2426
# and provides interface for decoding of instructions or data retrieval
2527
# for specific instructions in the architecture.
2628
add_subdirectory(./source/isa_decoder)
2729

28-
# Examples: demonstrates utilities and API features using example apps
29-
add_subdirectory(./source/examples)
30+
if (EXCLUDE_ISA_CLI_EXAMPLES_TESTS)
31+
message("-- Excluding CLI, examples and tests.")
32+
else()
33+
# Examples: demonstrates utilities and API features using example apps
34+
add_subdirectory(./source/examples)
3035

31-
# CLI commands: provides command line interface implementation
32-
# for generation of various CLI programs.
33-
add_subdirectory(./source/isa_spec_cli)
36+
# CLI commands: provides command line interface implementation
37+
# for generation of various CLI programs.
38+
add_subdirectory(./source/isa_spec_cli)
39+
40+
# ISA explorer API
41+
add_subdirectory(./source/isa_explorer)
42+
43+
# Unit testing suite
44+
add_subdirectory(./test/source)
45+
endif ()

README.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ A set of tools for parsing and using AMD's machine-readable GPU ISA specificatio
33

44
The `IsaDecoder` API makes it easy to parse the specification XML files, decode instructions and even decode whole shaders.
55

6+
The `explorer::Spec` experimental API lets you iterate over the elements of a given specification file.
7+
68
For usage examples, see the [examples subfolder](https://github.com/GPUOpen-Tools/isa_spec_manager/tree/main/source/examples).
79

810
## Building isa_spec_manager
@@ -26,10 +28,25 @@ cd ./isa_spec_manager/build
2628

2729
The above script will create a windows directory and generate a solution for Visual Studio.
2830

31+
By default, a solution is generated for VS 2022. To generate a solution for a different VS version or to use a different MSVC toolchain use the `--vs` argument.
32+
For example, to generate the solution for VS 2019 with the VS 2019 toolchain, run:
33+
34+
``
35+
./prebuild_windows.bat --vs 2019
36+
``
37+
2938
## Using the API
39+
For the API and specification documentation, please see the [documentation subfolder](https://github.com/GPUOpen-Tools/isa_spec_manager/tree/main/documentation).
40+
3041
The following example files can give you a quick overview of how to start using the XML ISA spec in your project:
31-
* Basic usage example: [./source/examples/basic_decoder.cpp](./source/examples/basic_decoder.cpp)
32-
* Usage example with multiple architectures in flight: [./source/examples/multi_arch_decoder.cpp](./source/examples/multi_arch_decoder.cpp)
42+
43+
### IsaDecoder
44+
* Basic usage example: [./source/examples/basic_decoder.cpp](./source/examples/basic_decoder.cpp). This sample requires a single command line argument which is a full path to the XML specification file.
45+
* Usage example with multiple architectures in flight: [./source/examples/multi_arch_decoder.cpp](./source/examples/multi_arch_decoder.cpp). This sample requires one or more command line arguments which are the full paths to the XML specification files.
46+
47+
### explorer::Spec
48+
* Basic usage example: [./source/examples/basic_explorer.cpp](./source/examples/basic_explorer.cpp). This sample requires a single command line argument which is a full path to the XML specification file.
49+
3350

3451
## Getting the ISA specification files
35-
The Machine-Readable GPU ISA specification files can be downloaded from [AMD's Machine-Readable GPU ISA Specification page on GPUOpen.com](https://gpuopen.com/machine-readable-isa/).
52+
The Machine-Readable GPU ISA specification files can be downloaded from [AMD's Machine-Readable GPU ISA Specification page on GPUOpen.com](https://gpuopen.com/machine-readable-isa).

RELEASE_NOTES.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,22 @@ For usage examples and instructions on how to build the project, please see [sou
2323

2424
**Note:** while the `IsaDecoder` API is a good way to get started with parsing the XML files, nothing prevents you from parsing the files yourself and building your own custom workflow. To do that please refer to the XML schema documentation [XML schema documentation](https://github.com/GPUOpen-Tools/isa_spec_manager/blob/main/documentation/spec_documentation.md).
2525

26+
New in this release:
27+
* Added support for operand subtypes (requires XML schema version `v1.1.0`).
28+
* Introducing the experimental `explorer::Spec` API for iterating over the elements of a given specification file. See the [documentation](https://github.com/GPUOpen-Tools/isa_spec_manager/tree/main/documentation) and [examples](https://github.com/GPUOpen-Tools/isa_spec_manager/tree/main/source/examples) subfolders for more details.
29+
* On Windows, the solution is now generated for the VS2022 toolchain by default.
30+
* Unit tests are now part of the repository.
31+
* Bug fixes and performance improvements.
32+
2633
## Known issues ##
2734

2835
### Specification ###
2936
* Information about encoding modifiers is not provided in the specification.
37+
* `S_ATOMIC_*` instructions have a `VMEM` functional group (instead of `SMEM`).
3038

3139
### API and tools ###
3240

33-
* Decoding of MIMG instructions (such as IMAGE_STORE and IMAGE_LOAD) may produce the wrong register indices for source vector register operands.
41+
* Decoding of `MIMG` instructions (such as `IMAGE_STORE` and `IMAGE_LOAD`) may produce the wrong register indices for source vector register operands.
42+
* Decoding binary representation of certain RDNA™2 `MIMG`, `MUBUF` and `MTBUF` instructions may produce the wrong results.
43+
* Decoding `DS` instructions may return the wrong operands when decoded via `IsaDecoder::DecodeInstruction()` with an `uint64_t` argument.
3444

build/prebuild_linux.sh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,29 @@ if [ ! -d $BUILD_DIR ]; then
77
mkdir $BUILD_DIR
88
fi
99

10-
# Run cmake.
10+
# Read the custom path for tinyxml.
11+
for arg in "$@"; do
12+
case $arg in
13+
--tinyxml2_src_path=*)
14+
TINYXML_SRC_PATH="${arg#*=}" # Extract the value after '='
15+
shift # Remove the argument from the list
16+
;;
17+
*)
18+
echo "Unknown option: $arg"
19+
exit 1
20+
;;
21+
esac
22+
done
23+
24+
# Go to the build directory.
1125
cd $BUILD_DIR
12-
cmake ../../
26+
27+
# Check if tinyxml2 needs to be overwritten.
28+
if [ -z "$TINYXML_SRC_PATH" ]; then
29+
# Use default tinyxml2.
30+
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ../../
31+
else
32+
# Use the custom tinyxml2.
33+
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DTINYXML_SRC_PATH=$TINYXML_SRC_PATH ../../
34+
fi
1335

build/prebuild_windows.bat

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@echo off
2-
:: prebuild.bat --vs 2019
2+
:: prebuild.bat --vs 2022
33
SETLOCAL
44

55
rem Print help message
@@ -19,11 +19,14 @@ echo Usage: prebuild.bat ^[options^]
1919
echo:
2020
echo Options:
2121
echo --cmake Path to cmake executable to use. If not specified, the cmake from PATH env variable will be used.
22-
echo --vs Microsoft Visual Studio version. Currently supported values are: "2015", "2017", "2019" and "2022". The default is "2019".
22+
echo --tinyxml2_src_path Path to TinyXML2 source. If not specified, the default TinyXML2 bundled with the isa_decoder will be used.
23+
echo --vs Microsoft Visual Studio version. Currently supported values are: "2015", "2017", "2019" and "2022". The default is "2022".
24+
echo --decoder_only Only include the decoder library for this project; skip the command line interface, examples and tests.
2325
echo:
2426
echo Examples:
25-
echo prebuild.bat
26-
echo prebuild.bat --vs 2017
27+
echo prebuild_windows.bat
28+
echo prebuild_windows.bat --vs 2022
29+
echo prebuild_windows.bat --vs 2022 --tinyxml2_src_path [path to custom tinyxml2]
2730

2831
goto :exit
2932

@@ -33,25 +36,18 @@ set CURRENT_DIR=%CD%
3336

3437
rem Default values
3538
set CMAKE_PATH=cmake
36-
set VS_VER=2019
37-
set TEST=-DTEST_PROJECT=ON
38-
set BUILD_INTERNAL=-DBuildInternal=OFF
39+
set VS_VER=2022
40+
set DECODER_ONLY=
41+
set TINYXML=
3942

4043
:begin
4144
if [%1]==[] goto :start_cmake
42-
if "%1"=="--no-test" goto :set_notest_flag
43-
if "%1"=="--public-only" goto :set_public_build_flag
4445
if "%1"=="--cmake" goto :set_cmake
4546
if "%1"=="--vs" goto :set_vs
46-
if "%1"=="--internal" goto :set_internal_build_flag
47+
if "%1"=="--tinyxml2_src_path" goto :set_tinyxml2_src_path
48+
if "%1"=="--decoder_only" goto :set_decoder_only
4749
goto :bad_arg
4850

49-
:set_notest_flag
50-
goto :start_cmake
51-
52-
:set_internal_build_flag
53-
goto :start_cmake
54-
5551
:set_cmake
5652
set CMAKE_PATH=%2
5753
goto :shift_2args
@@ -60,10 +56,18 @@ goto :shift_2args
6056
set VS_VER=%2
6157
goto :shift_2args
6258

59+
:set_tinyxml2_src_path
60+
set TINYXML=-DTINYXML_SRC_PATH=%2
61+
goto :shift_2args
62+
6363
:set_verbose
6464
@echo on
6565
goto :shift_arg
6666

67+
:set_decoder_only
68+
set DECODER_ONLY="-DEXCLUDE_ISA_CLI_EXAMPLES_TESTS=ON"
69+
goto :shift_arg
70+
6771
:shift_2args
6872
rem Shift to the next pair of arguments
6973
shift
@@ -109,7 +113,7 @@ rem Invoke cmake with required arguments.
109113
echo:
110114
echo Running cmake to generate a VisualStudio solution...
111115
cd %OUTPUT_FOLDER%
112-
%CMAKE_PATH% -G %CMAKE_VS% %CMAKE_VSARCH% ..\..\..
116+
%CMAKE_PATH% %DECODER_ONLY% %TINYXML% -G %CMAKE_VS% %CMAKE_VSARCH% ..\..\..
113117
if not %ERRORLEVEL%==0 (
114118
echo "ERROR: cmake failed. Aborting..."
115119
exit /b 1

documentation/cli_documentation.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ ISA Spec Manager CLI program is an example program that leverages IsaSpecApi. Th
55
To decode an instruction that is represented in the binary (machine code) format using CLI, run the commands below.
66

77
```bash
8-
cd isa_spec_manager-Win64/cli
9-
./isa_spec_cli.exe -x ../../Specification/xml/gfx11.xml -d BE804814
8+
cd IsaSpecManager-Win64/cli
9+
./IsaSpecCli.exe -x ../../Specification/xml/gfx11.xml -d BE804814
1010
```
1111
As can be seen from the command, `-x` flag should be followed by the path to the machine-readable XML specification. Next, `-d` flag should be followed by the instruction in the binary form. Note that the provided instruction should be encoded in the specified architecture. After running the command, the CLI outputs the following:
1212

@@ -33,8 +33,8 @@ If decoded successfully, CLI outputs the instruction in an assembly form, descri
3333
To retrieve information about a specific instruction from the spec, the name of the instruction could be provided to the CLI. Refer to the commands below.
3434

3535
```bash
36-
cd isa_spec_manager-Win64/cli
37-
./isa_spec_cli.exe -x ../../Specification/xml/gfx11.xml -i s_setpc_b64
36+
cd IsaSpecManager-Win64/cli
37+
./IsaSpecCli.exe -x ../../Specification/xml/gfx11.xml -i s_setpc_b64
3838
```
3939
As can be seen from the command, `-x` flag should be followed by the path to the machine-readable XML specification. Next, `-i` flag should be followed by the name of the instruction which we are interested in. Note, that the requested instruction should be present in the specified architecture. After running the command, CLI outputs the following:
4040

documentation/api_documentation.md renamed to documentation/isa_decoder/api_documentation.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,38 @@ int main ()
225225
226226
return (is_init && is_decoded) ? 0 : -1;
227227
}
228+
```
229+
230+
## `amdisa::IsaDecoder::GetDebugLog`
231+
```c++
232+
std::vector<std::string> GetDebugLog() const;
233+
```
234+
Retrieves a log of error and warning messages generated by the `IsaDecoder` instance. It can be used for debugging purposes to review any issues encountered during the lifetime of the instance.
235+
236+
### Return value
237+
A `std::vector` of `std::string` containing error and warning messages. If no messages are logged, the vector will be empty.
238+
239+
### Example
240+
```c++
241+
#include "isa_decoder.h"
242+
#include <iostream>
228243

244+
int main ()
245+
{
246+
amdisa::IsaDecoder spec_api;
247+
// Assume `Initialize` or other operations have been performed.
248+
249+
// Retrieve and print internal messages or warnings if present.
250+
for (const std::string& message : spec_api.GetDebugLog())
251+
{
252+
std::cout << message << std::endl;
253+
}
254+
255+
return 0;
256+
}
229257
```
258+
---
259+
230260
# API structures
231261
API defines various struct in `isa_decoder.h`.
232262

0 commit comments

Comments
 (0)