Skip to content

Commit 507111d

Browse files
author
Amit Ben-Moshe
committed
Updates for v1.2 release.
1 parent 46192e6 commit 507111d

30 files changed

Lines changed: 2145 additions & 803 deletions

CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ endif ()
2626
# and provides interface for decoding of instructions or data retrieval
2727
# for specific instructions in the architecture.
2828
add_subdirectory(./source/isa_decoder)
29+
# ISA explorer API
30+
add_subdirectory(./source/isa_explorer)
2931

3032
if (EXCLUDE_ISA_CLI_EXAMPLES_TESTS)
3133
message("-- Excluding CLI, examples and tests.")
@@ -37,9 +39,6 @@ else()
3739
# for generation of various CLI programs.
3840
add_subdirectory(./source/isa_spec_cli)
3941

40-
# ISA explorer API
41-
add_subdirectory(./source/isa_explorer)
42-
4342
# Unit testing suite
4443
add_subdirectory(./test/source)
4544
endif ()

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The `explorer::Spec` experimental API lets you iterate over the elements of a gi
88
For usage examples, see the [examples subfolder](https://github.com/GPUOpen-Tools/isa_spec_manager/tree/main/source/examples).
99

1010
## Building isa_spec_manager
11-
To build the project, use the build scripts located in the ./build subfolder. Please note that the build process requires CMake with minimum version of 3.0.
11+
To build the project, use the build scripts located in the ./build subfolder. Please note that the build process requires CMake with minimum version of 3.10.
1212

1313
### Building on Linux
1414
```

RELEASE_NOTES.md

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
AMD's machine-readable GPU Instruction Set Architecture specifications is a set of XML files that describe AMD's latest GPU ISA: instructions, encodings, operands, data formats and even human-readable description strings.
66

7-
The first release includes the specification XML files for the following GPU architectures:
8-
* AMD CDNA™ 3 (Instinct™ MI300)
9-
* AMD CDNA™ 2 (Instinct™ MI200)
10-
* AMD CDNA™ 1 (Instinct™ MI100)
7+
The release includes the specification XML files for the following GPU architectures:
8+
* AMD CDNA™ 4 (AMD MI350 Instinct™)
9+
* AMD CDNA™ 3 (AMD MI300 Instinct™)
10+
* AMD CDNA™ 2 (AMD MI200 Instinct™)
11+
* AMD CDNA™ 1 (AMD MI100 Instinct™)
1112
* AMD RDNA™ 3
1213
* AMD RDNA™ 2
1314
* AMD RDNA™ 1
@@ -24,21 +25,17 @@ For usage examples and instructions on how to build the project, please see [sou
2425
**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).
2526

2627
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.
28+
* Fixed decoding of `MIMG` instructions (such as `IMAGE_STORE` and `IMAGE_LOAD`)
29+
* Fixed decoding of `MUBUF` and `MTBUF` instructions of RDNA™2 targets in binary representation.
30+
* Fixed an issue where `DS` instructions returned the wrong operands when decoded via `IsaDecoder::DecodeInstruction()` with an `uint64_t` argument.
31+
* The `explorer` API now supports Functional Groups.
32+
* Added basic test for the `explorer` API.
33+
* Documentation updates.
34+
3235

3336
## Known issues ##
3437

3538
### Specification ###
3639
* Information about encoding modifiers is not provided in the specification.
37-
* `S_ATOMIC_*` instructions have a `VMEM` functional group (instead of `SMEM`).
38-
39-
### API and tools ###
40-
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.
4440

41+
### API and tools ###

documentation/isa_decoder/api_documentation.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ bool DecodeInstructionStream(
7171
std::vector<InstructionInfoBundle>& instruction_info_stream,
7272
std::string& err_message) const;
7373
```
74-
Decodes a sequence of binary instructions.
74+
Decodes a sequence of binary instructions.
75+
76+
> [!NOTE]
77+
> Branch resolution will not be performed when decoding a single instruction. If branch resolution is required, use DecodeShaderDisassemblyText() or DecodeShaderDisassemblyFile() with the flag for branch target resolution set to `true`.
7578
7679
### Parameters
7780
parameter name | type | description | input/output
@@ -129,6 +132,9 @@ bool DecodeInstruction(uint64_t machine_code,
129132
```
130133
Decodes a single instruction encoded in binary format. This API is limited to a 64-bit instruction. If the instruction of interest is longer than 64 bits, `amdisa::IsaDecoder::DecodeInstructionStream` should be used instead.
131134
135+
> [!NOTE]
136+
> Branch resolution will not be performed when decoding a single instruction. If branch resolution is required, use DecodeShaderDisassemblyText() or DecodeShaderDisassemblyFile() with the flag for branch target resolution set to `true`.
137+
132138
### Parameters
133139
parameter name | type | description | input/output
134140
-|-|-|-

documentation/isa_explorer/api_tutorial.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ std::advance(it, dist(gen));
6262
print_instruction(it->second);
6363
```
6464

65-
- **Random Device and Generator:** Creates a random number generator seeded with a hardware-based random device.
66-
- **Uniform Distribution:** Ensures the random number falls within the valid range of instruction indices.
67-
- **Iterator Advancement:** Randomly selects an instruction by advancing the iterator to the generated index.
68-
6965
The selected instruction is printed using the `print_instruction` function.
7066

7167
As an exmple, you can use the following print function:
@@ -82,4 +78,4 @@ static void print_instruction(const amdisa::explorer::Instruction& instruction)
8278
std::cout << "\t\t Description: " << instruction.FuncGroup()->Description() << std::endl << std::endl;
8379
std::cout << "\tFunctionalSubgroup: " << instruction.FuncSubgroup()->Name() << std::endl;
8480
}
85-
```
81+
```

documentation/spec_documentation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ List of child elements:
156156
| -- | ---------------- | ---------------- | - |
157157
| 1. | Field name | \<FieldName\> | Encoding field name. Should match one of the fields in [\<BitMap\>](#bitmap-microcodeformat). |
158158
| 2. | Data format name | \<DataFormatName\> | Data format of the operand. Should match one of the formats in [\<DataFormats\>](#dataformats). |
159-
| 3. | Operand type | \<OperantType\> | Type of the operand. Should match one of the types in [\<OperandTypes\>](#operandtypes)|
159+
| 3. | Operand type | \<OperandType\> | Type of the operand. Should match one of the types in [\<OperandTypes\>](#operandtypes)|
160160
| 4. | Operand size | \<OperandSize\> | The size of this operand in bits. |
161161

162162

include/amdisa/api_version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
2+
* Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
33
*/
44
#ifndef API_VERSION_H_
55
#define API_VERSION_H_
@@ -10,7 +10,7 @@
1010

1111
// IsaDecoder version.
1212
#define AMDISA_DECODE_API_VERSION_MAJOR 1
13-
#define AMDISA_DECODE_API_VERSION_MINOR 1
13+
#define AMDISA_DECODE_API_VERSION_MINOR 2
1414
#define AMDISA_DECODE_API_VERSION_PATCH 0
1515

1616
// IsaExplorer version.

include/amdisa/isa_decoder.h

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ namespace amdisa
2929
// Constants.
3030
static const uint32_t kBranchOffsetOutOfRange = (1 << 16);
3131
static const uint64_t kInvalidBranchTarget = UINT64_MAX;
32+
static const uint64_t kSrcNull = 0x7c;
3233

3334
// Instruction's functional group.
34-
enum class kFunctionalGroup
35+
enum class FunctionalGroups
3536
{
3637
kFunctionalGroupUnknown, // Unknown
3738
kFunctionalGroupSalu, // Scalar ALU
@@ -45,7 +46,7 @@ namespace amdisa
4546
kFunctionalGroupTrap // Trap
4647
};
4748

48-
static constexpr const char* kFunctionalGroupName[] = {
49+
constexpr const char* FunctionalGroupNames[] = {
4950
"Unknown", // Unknown
5051
"Scalar ALU", // Scalar ALU
5152
"Scalar Memory", // Scalar Memory
@@ -59,7 +60,7 @@ namespace amdisa
5960
};
6061

6162
// Instruction's functional group's subgroup.
62-
enum class kFunctionalSubgroup
63+
enum class FunctionalSubgroups
6364
{
6465
kFunctionalSubgroupUnknown, // Unknown
6566
kFunctionalSubgroupFloatingPoint, // Floating Point
@@ -78,7 +79,7 @@ namespace amdisa
7879
kFunctionalSubgroupTranscendental // Transcendental
7980
};
8081

81-
static constexpr const char* kFunctionalSubgroupName[] = {
82+
constexpr const char* FunctionalSubgroupNames[] = {
8283
"Unknown", // Unknown
8384
"Floating Point", // Floating Point
8485
"Buffer", // Buffer
@@ -90,7 +91,7 @@ namespace amdisa
9091
"Atomic", // Atomic
9192
"Flat", // Flat
9293
"Data Share", // Data Share
93-
"Static" // Static
94+
"Static", // Static
9495
"MFMA", // MFMA
9596
"WMMA", // WMMA
9697
"Transcendental" // Transcendental
@@ -130,6 +131,12 @@ namespace amdisa
130131
// Size of the operand.
131132
uint32_t operand_size = 0;
132133

134+
// Data Format of the operand.
135+
std::string data_format;
136+
137+
// The name of the encoded field that corresponds to this operand.
138+
std::string encoding_field_name;
139+
133140
// True if the operand is an input to an instruction (source).
134141
bool is_input = false;
135142

@@ -181,11 +188,20 @@ namespace amdisa
181188
bool is_immediately_executed = false;
182189
};
183190

191+
// Describes an instruction's primary functional group and any more specific
192+
// subgroups it belongs to within an instruction set architecture.
184193
struct FunctionalGroupSubgroupInfo
185194
{
186-
std::string description;
187-
kFunctionalGroup IsaFunctionalGroup = kFunctionalGroup::kFunctionalGroupUnknown;
188-
kFunctionalSubgroup IsaFunctionalSubgroup = kFunctionalSubgroup::kFunctionalSubgroupUnknown;
195+
// Functional group description.
196+
std::string description;
197+
198+
// Functional group.
199+
FunctionalGroups isa_functional_group = FunctionalGroups::kFunctionalGroupUnknown;
200+
201+
// The subgroups of this instruction, where each subgroup forms
202+
// a pair with the group in the form of { <fg, sub_fg1>,
203+
// <fg, sub_fg2>, <fg, sub_fg3>, ... }.
204+
std::vector<FunctionalSubgroups> isa_functional_subgroups;
189205
};
190206

191207
// InstructionInfo is a structure that gets populated as a result of API
@@ -251,6 +267,16 @@ namespace amdisa
251267
*/
252268
bool Initialize(const std::string& input_xml_file_path, std::string& err_message);
253269

270+
/*
271+
* Initialize --
272+
*
273+
* Reads in XML ISA specification from memory and populates the internal structures.
274+
*
275+
* Returns true if the spec was successfully read, or false otherwise
276+
* with the error message in err_message.
277+
*/
278+
bool Initialize(const char *input_xml_data, const size_t datalen, std::string& err_message);
279+
254280
/*
255281
* GetVersion --
256282
*
@@ -277,6 +303,9 @@ namespace amdisa
277303
* instruction) was decoded successfully and populates instruction_info with
278304
* corresponding information about the decoded instruction.
279305
* Returns false otherwise with the error string output.
306+
*
307+
* Note: branch resolution will not be performed when decoding a single instruction.
308+
* If branch resolution is required, use DecodeShaderDisassemblyText() or DecodeShaderDisassemblyFile().
280309
*/
281310
bool DecodeInstruction(uint64_t machine_code, InstructionInfoBundle& instruction_info, std::string& err_message) const;
282311

@@ -301,6 +330,9 @@ namespace amdisa
301330
* successful decode, the function outputs a vector of InstructionInfoGroup.
302331
* Each of the objects in the vector correspond to a decoded instruction in
303332
* the input instruction stream.
333+
*
334+
* Note: branch resolution will not be performed when decoding a single instruction.
335+
* If branch resolution is required, use DecodeShaderDisassemblyText() or DecodeShaderDisassemblyFile().
304336
*/
305337
bool DecodeInstructionStream(const std::vector<uint32_t>& machine_code_stream,
306338
std::vector<InstructionInfoBundle>& instruction_info_stream,

include/amdisa/isa_explorer.h

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ namespace amdisa
302302
///@brief Get the subgroups in the functional group
303303
///
304304
/// @returns Subgroups in the functional group
305-
const std::vector<FunctionalSubgroup>& FuncSubgroups() const noexcept;
305+
const std::vector<FunctionalSubgroup> FuncSubgroups() const noexcept;
306306

307307
private:
308308
/// @brief Add the instruction to the functional group
@@ -495,7 +495,7 @@ namespace amdisa
495495
bool is_immediately_executed,
496496
bool is_program_terminator,
497497
FunctionalGroup& functional_group,
498-
FunctionalSubgroup& functional_subgroup,
498+
const std::vector<FunctionalSubgroup>& functional_subgroups,
499499
const std::vector<InstructionEncoding>& encodings);
500500
/// @brief Get the name of the instruction
501501
///
@@ -540,7 +540,7 @@ namespace amdisa
540540
/// @brief Get the functional subgroup to which the instruction belongs
541541
///
542542
/// @returns Functional subgroup to which the instruction belongs
543-
const FunctionalSubgroup* const FuncSubgroup() const noexcept;
543+
const std::vector<FunctionalSubgroup> FuncSubgroups() const noexcept;
544544

545545
/// @brief Get the encodings of the instruction
546546
///
@@ -556,7 +556,7 @@ namespace amdisa
556556
const bool is_immediately_executed_; ///< Whether the instruction is immediately executed
557557
const bool is_program_terminator_; ///< Whether the instruction is a program terminator
558558
FunctionalGroup* const functional_group_; ///< Functional group to which the instruction belongs
559-
FunctionalSubgroup* const functional_subgroup_; ///< Functional subgroup to which the instruction belongs
559+
const std::vector<FunctionalSubgroup> functional_subgroups_; ///< Functional subgroup to which the instruction belongs
560560
const std::vector<InstructionEncoding> encodings_; ///< Encodings of the instruction
561561
};
562562

@@ -589,6 +589,21 @@ namespace amdisa
589589
*/
590590
bool Init(const std::string& input_xml_file_path, std::string& err_message) noexcept;
591591

592+
/*
593+
* Init --
594+
*
595+
* Reads in an XML file containing the ISA specification from memory and populates the
596+
* internal data structures.
597+
*
598+
* @param input_xml_file_path Path to the XML file containing the ISA specification.
599+
* @param err_message Reference to a string that will be populated with
600+
* an error message if initialization fails.
601+
*
602+
* @return True if the XML file was successfully parsed and the internal
603+
* structures were initialized, false otherwise.
604+
*/
605+
bool Init(const char *input_xml_data, const size_t datalen, std::string& err_message) noexcept;
606+
592607
/*
593608
* GetArchitecture --
594609
*
@@ -628,6 +643,16 @@ namespace amdisa
628643
*/
629644
const std::map<std::string, OperandType>& GetOperandTypes() const noexcept;
630645

646+
/*
647+
* GetFunctionalGroups --
648+
*
649+
* Returns the functional groups defined in this ISA.
650+
*
651+
* @return A const reference to a map where the key is the name of the functional group
652+
* type and the value is the corresponding FunctionalGroup object.
653+
*/
654+
const std::map<std::string, FunctionalGroup>& GetFunctionalGroups() const noexcept;
655+
631656
// Constructor control.
632657
Spec();
633658
~Spec();

source/common/amdisa_expression_tree_consts.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
2+
* Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
33
*/
44
#ifndef AMDISA_EXPRESSION_TREE_CONSTS_H_
55
#define AMDISA_EXPRESSION_TREE_CONSTS_H_
@@ -28,6 +28,7 @@ namespace amdisa
2828
kBaseType,
2929
kArrayType,
3030
kLambdaType,
31+
kRecordType,
3132
kUndefined
3233
};
3334

@@ -68,20 +69,24 @@ namespace amdisa
6869
static const char* kJsonBaseTypeName = "!base";
6970
static const char* kJsonArrayTypeName = "!array";
7071
static const char* kJsonLambdaTypeName = "!lambda";
72+
static const char* kJsonRecordTypeName = "!record";
7173

7274
// XML type names.
7375
static const char* kXmlBaseTypeName = "Base";
7476
static const char* kXmlArrayTypeName = "Array";
7577
static const char* kXmlLambdaTypeName = "Lambda";
78+
static const char* kXmlRecordTypeName = "Record";
7679

7780
// Map from JSON type tree string names to enum.
7881
static const std::map<std::string, TypeTreeNodes> kMapJsonTypeTreeNodeNamesToEnum = {{kJsonBaseTypeName, TypeTreeNodes::kBaseType},
7982
{kJsonArrayTypeName, TypeTreeNodes::kArrayType},
80-
{kJsonLambdaTypeName, TypeTreeNodes::kLambdaType}};
83+
{kJsonLambdaTypeName, TypeTreeNodes::kLambdaType},
84+
{kJsonRecordTypeName, TypeTreeNodes::kRecordType}};
8185

8286
// Map from XML type tree string names to enum.
8387
static const std::map<std::string, TypeTreeNodes> kMapXmlTypeTreeNodeNamesToEnum = {{kXmlBaseTypeName, TypeTreeNodes::kBaseType},
8488
{kXmlArrayTypeName, TypeTreeNodes::kArrayType},
85-
{kXmlLambdaTypeName, TypeTreeNodes::kLambdaType}};
89+
{kXmlLambdaTypeName, TypeTreeNodes::kLambdaType},
90+
{kXmlRecordTypeName, TypeTreeNodes::kRecordType}};
8691
} // namespace amdisa
8792
#endif // AMDISA_EXPRESSION_TREE_CONSTANTS_H_

0 commit comments

Comments
 (0)