Skip to content

Commit 5b6d1ff

Browse files
authored
Add as/dis support for Arm.MotionEngine.100 extended instruction set (KhronosGroup#6284)
Change-Id: I9971a0c3f7edbdbd9be9ecab25797f0ee67cf720 --------- Signed-off-by: Kevin Petit <[email protected]>
1 parent 7f2d9ee commit 5b6d1ff

File tree

6 files changed

+104
-1
lines changed

6 files changed

+104
-1
lines changed

BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ create_grammar_tables_target(
5353
ExtInst("opencl.debuginfo.100", prefix="CLDEBUG100_"),
5454
ExtInst("nonsemantic.shader.debuginfo.100", prefix="SHDEBUG100_"),
5555
ExtInst("tosa.001000.1", target="spirv_ext_inst_tosa_001000_1", prefix="TOSA_"),
56+
ExtInst("arm.motion-engine.100", target="spirv_ext_inst_arm_motion_engine_100"),
5657
] + [ExtInst(e) for e in [
5758
"spv-amd-shader-explicit-vertex-parameter",
5859
"spv-amd-shader-trinary-minmax",

include/spirv-tools/libspirv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ typedef enum spv_ext_inst_type_t {
364364
SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100,
365365
SPV_EXT_INST_TYPE_NONSEMANTIC_VKSPREFLECTION,
366366
SPV_EXT_INST_TYPE_TOSA_001000_1,
367+
SPV_EXT_INST_TYPE_ARM_MOTION_ENGINE_100,
367368

368369
// Multiple distinct extended instruction set types could return this
369370
// value, if they are prefixed with NonSemantic. and are otherwise

source/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ set(EI_ns_debuginfo "${GRAMMAR_DIR}/extinst.nonsemantic.shader.debuginfo.100.gra
3232
set(EI_ns_clspvreflect "${GRAMMAR_DIR}/extinst.nonsemantic.clspvreflection.grammar.json")
3333
set(EI_ns_vkspreflect "${GRAMMAR_DIR}/extinst.nonsemantic.vkspreflection.grammar.json")
3434
set(EI_tosa_001000_1 "${GRAMMAR_DIR}/extinst.tosa.001000.1.grammar.json")
35+
set(EI_arm_motion_engine_100 "${GRAMMAR_DIR}/extinst.arm.motion-engine.100.grammar.json")
3536

3637
set(CORE_TABLES_BODY_INC_FILE ${spirv-tools_BINARY_DIR}/core_tables_body.inc)
3738
set(CORE_TABLES_HEADER_INC_FILE ${spirv-tools_BINARY_DIR}/core_tables_header.inc)
@@ -52,6 +53,7 @@ add_custom_command(OUTPUT ${CORE_TABLES_BODY_INC_FILE} ${CORE_TABLES_HEADER_INC_
5253
--extinst=,${EI_ns_clspvreflect}
5354
--extinst=,${EI_ns_vkspreflect}
5455
--extinst=TOSA_,${EI_tosa_001000_1}
56+
--extinst=,${EI_arm_motion_engine_100}
5557
DEPENDS ${GGT_SCRIPT}
5658
${SPIRV_CORE_GRAMMAR_JSON_FILE}
5759
${EI_glsl}
@@ -65,7 +67,8 @@ add_custom_command(OUTPUT ${CORE_TABLES_BODY_INC_FILE} ${CORE_TABLES_HEADER_INC_
6567
${EI_debuginfo}
6668
${EI_ns_clspvreflect}
6769
${EI_ns_vkspreflect}
68-
${EI_tosa_001000_1}
70+
${EI_tosa_001000_1}
71+
${EI_arm_motion_engine_100}
6972
COMMENT "Generate grammar tables")
7073
add_custom_target(spirv-tools-tables DEPENDS ${CORE_TABLES_BODY_INC_FILE} ${CORE_TABLES_HEADER_INC_FILE})
7174

source/ext_inst.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ spv_ext_inst_type_t spvExtInstImportTypeGet(const char* name) {
5858
if (!strcmp("TOSA.001000.1", name)) {
5959
return SPV_EXT_INST_TYPE_TOSA_001000_1;
6060
}
61+
if (!strcmp("Arm.MotionEngine.100", name)) {
62+
return SPV_EXT_INST_TYPE_ARM_MOTION_ENGINE_100;
63+
}
6164
// ensure to add any known non-semantic extended instruction sets
6265
// above this point, and update spvExtInstIsNonSemantic()
6366
if (!strncmp("NonSemantic.", name, 12)) {

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ set(TEST_SOURCES
103103
diagnostic_test.cpp
104104
enum_string_mapping_test.cpp
105105
enum_set_test.cpp
106+
ext_inst.arm_motion_engine_test.cpp
106107
ext_inst.cldebug100_test.cpp
107108
ext_inst.debuginfo_test.cpp
108109
ext_inst.glsl_test.cpp
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// Copyright (c) 2024-2025 Arm Ltd.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include <string>
16+
17+
#include "gmock/gmock.h"
18+
#include "source/util/string_utils.h"
19+
#include "spirv/unified1/ArmMotionEngine.100.h"
20+
#include "test/test_fixture.h"
21+
#include "test/unit_spirv.h"
22+
23+
namespace spvtools {
24+
namespace {
25+
26+
using spvtest::Concatenate;
27+
using spvtest::MakeInstruction;
28+
using spvtest::TextToBinaryTest;
29+
using testing::Eq;
30+
using utils::MakeVector;
31+
32+
TEST_F(TextToBinaryTest, ArmMotionEngineImportTest) {
33+
const std::string src = "%1 = OpExtInstImport \"Arm.MotionEngine.100\"";
34+
EXPECT_THAT(CompiledInstructions(src),
35+
Eq(MakeInstruction(spv::Op::OpExtInstImport, {1},
36+
MakeVector("Arm.MotionEngine.100"))));
37+
}
38+
39+
TEST_F(TextToBinaryTest, ArmMotionEngineInstructionMIN_SAD) {
40+
const std::string src =
41+
"%1 = OpExtInstImport \"Arm.MotionEngine.100\"\n"
42+
"%3 = OpExtInst %2 %1 MIN_SAD %4 %5 %6 %7 %8 %9 %10 %11 %12\n";
43+
44+
// First make sure it assembles correctly.
45+
EXPECT_THAT(
46+
CompiledInstructions(src),
47+
Eq(Concatenate({MakeInstruction(spv::Op::OpExtInstImport, {1},
48+
MakeVector("Arm.MotionEngine.100")),
49+
MakeInstruction(spv::Op::OpExtInst,
50+
{2, 3, 1, ArmMotionEngineMIN_SAD, 4, 5, 6,
51+
7, 8, 9, 10, 11, 12})})))
52+
<< src;
53+
// Now check the round trip through the disassembler.
54+
EXPECT_THAT(EncodeAndDecodeSuccessfully(src), src) << src;
55+
}
56+
57+
TEST_F(TextToBinaryTest, ArmMotionEngineInstructionMIN_SAD_COST) {
58+
const std::string src =
59+
"%1 = OpExtInstImport \"Arm.MotionEngine.100\"\n"
60+
"%3 = OpExtInst %2 %1 MIN_SAD_COST %4 %5 %6 %7 %8 %9 %10 %11 %12\n";
61+
62+
// First make sure it assembles correctly.
63+
EXPECT_THAT(
64+
CompiledInstructions(src),
65+
Eq(Concatenate({MakeInstruction(spv::Op::OpExtInstImport, {1},
66+
MakeVector("Arm.MotionEngine.100")),
67+
MakeInstruction(spv::Op::OpExtInst,
68+
{2, 3, 1, ArmMotionEngineMIN_SAD_COST, 4,
69+
5, 6, 7, 8, 9, 10, 11, 12})})))
70+
<< src;
71+
// Now check the round trip through the disassembler.
72+
EXPECT_THAT(EncodeAndDecodeSuccessfully(src), src) << src;
73+
}
74+
75+
TEST_F(TextToBinaryTest, ArmMotionEngineInstructionRAW_SAD) {
76+
const std::string src =
77+
"%1 = OpExtInstImport \"Arm.MotionEngine.100\"\n"
78+
"%3 = OpExtInst %2 %1 RAW_SAD %4 %5 %6 %7 %8 %9 %10 %11\n";
79+
80+
// First make sure it assembles correctly.
81+
EXPECT_THAT(
82+
CompiledInstructions(src),
83+
Eq(Concatenate(
84+
{MakeInstruction(spv::Op::OpExtInstImport, {1},
85+
MakeVector("Arm.MotionEngine.100")),
86+
MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, ArmMotionEngineRAW_SAD,
87+
4, 5, 6, 7, 8, 9, 10, 11})})))
88+
<< src;
89+
// Now check the round trip through the disassembler.
90+
EXPECT_THAT(EncodeAndDecodeSuccessfully(src), src) << src;
91+
}
92+
93+
} // namespace
94+
} // namespace spvtools

0 commit comments

Comments
 (0)