blob: 9d011661c6c588e99c17fc012347a74977f9653f [file] [log] [blame]
// GENERATED FILE - DO NOT EDIT.
// Generated by generate_tests.py
//
// Copyright (c) 2022 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "../diff_test_utils.h"
#include "gtest/gtest.h"
namespace spvtools {
namespace diff {
namespace {
// Test for multiple entry points with the same execution model.
constexpr char kSrc[] = R"( OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %4 "main1" %8 %10
OpEntryPoint Vertex %12 "main2" %13 %14 %15
OpSource ESSL 310
OpName %4 "main1"
OpName %12 "main2"
OpName %8 "v"
OpName %10 "a"
OpName %13 "v"
OpName %14 "a"
OpName %15 "b"
OpDecorate %8 Location 0
OpDecorate %10 Location 0
OpDecorate %13 Location 0
OpDecorate %14 Location 0
OpDecorate %15 Location 1
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeFloat 32
%7 = OpTypePointer Output %6
%9 = OpTypePointer Input %6
%8 = OpVariable %7 Output
%10 = OpVariable %9 Input
%13 = OpVariable %7 Output
%14 = OpVariable %9 Input
%15 = OpVariable %9 Input
%4 = OpFunction %2 None %3
%5 = OpLabel
%11 = OpLoad %6 %10
OpStore %8 %11
OpReturn
OpFunctionEnd
%12 = OpFunction %2 None %3
%16 = OpLabel
%17 = OpLoad %6 %14
%18 = OpLoad %6 %15
%19 = OpFAdd %6 %17 %18
OpStore %13 %19
OpReturn
OpFunctionEnd)";
constexpr char kDst[] = R"( OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %4 "main2" %13 %14 %15
OpEntryPoint Vertex %12 "main1" %8 %10
OpSource ESSL 310
OpName %12 "main1"
OpName %4 "main2"
OpName %8 "v"
OpName %10 "a"
OpName %13 "v"
OpName %14 "a"
OpName %15 "b"
OpDecorate %8 Location 0
OpDecorate %10 Location 0
OpDecorate %13 Location 0
OpDecorate %14 Location 0
OpDecorate %15 Location 1
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeFloat 32
%7 = OpTypePointer Output %6
%9 = OpTypePointer Input %6
%8 = OpVariable %7 Output
%10 = OpVariable %9 Input
%13 = OpVariable %7 Output
%14 = OpVariable %9 Input
%15 = OpVariable %9 Input
%4 = OpFunction %2 None %3
%16 = OpLabel
%17 = OpLoad %6 %14
%18 = OpLoad %6 %15
%19 = OpFAdd %6 %17 %18
OpStore %13 %19
OpReturn
OpFunctionEnd
%12 = OpFunction %2 None %3
%5 = OpLabel
%11 = OpLoad %6 %10
OpStore %8 %11
OpReturn
OpFunctionEnd
)";
TEST(DiffTest, MultipleSameEntryPoints) {
constexpr char kDiff[] = R"( ; SPIR-V
; Version: 1.6
; Generator: Khronos SPIR-V Tools Assembler; 0
; Bound: 20
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
+OpEntryPoint Vertex %12 "main2" %13 %14 %15
OpEntryPoint Vertex %4 "main1" %8 %10
-OpEntryPoint Vertex %12 "main2" %13 %14 %15
OpSource ESSL 310
OpName %4 "main1"
OpName %12 "main2"
OpName %8 "v"
OpName %10 "a"
OpName %13 "v"
OpName %14 "a"
OpName %15 "b"
OpDecorate %8 Location 0
OpDecorate %10 Location 0
OpDecorate %13 Location 0
OpDecorate %14 Location 0
OpDecorate %15 Location 1
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeFloat 32
%7 = OpTypePointer Output %6
%9 = OpTypePointer Input %6
%8 = OpVariable %7 Output
%10 = OpVariable %9 Input
%13 = OpVariable %7 Output
%14 = OpVariable %9 Input
%15 = OpVariable %9 Input
%4 = OpFunction %2 None %3
%5 = OpLabel
%11 = OpLoad %6 %10
OpStore %8 %11
OpReturn
OpFunctionEnd
%12 = OpFunction %2 None %3
%16 = OpLabel
%17 = OpLoad %6 %14
%18 = OpLoad %6 %15
%19 = OpFAdd %6 %17 %18
OpStore %13 %19
OpReturn
OpFunctionEnd
)";
Options options;
DoStringDiffTest(kSrc, kDst, kDiff, options);
}
TEST(DiffTest, MultipleSameEntryPointsNoDebug) {
constexpr char kSrcNoDebug[] = R"( OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %4 "main1" %8 %10
OpEntryPoint Vertex %12 "main2" %13 %14 %15
OpSource ESSL 310
OpDecorate %8 Location 0
OpDecorate %10 Location 0
OpDecorate %13 Location 0
OpDecorate %14 Location 0
OpDecorate %15 Location 1
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeFloat 32
%7 = OpTypePointer Output %6
%9 = OpTypePointer Input %6
%8 = OpVariable %7 Output
%10 = OpVariable %9 Input
%13 = OpVariable %7 Output
%14 = OpVariable %9 Input
%15 = OpVariable %9 Input
%4 = OpFunction %2 None %3
%5 = OpLabel
%11 = OpLoad %6 %10
OpStore %8 %11
OpReturn
OpFunctionEnd
%12 = OpFunction %2 None %3
%16 = OpLabel
%17 = OpLoad %6 %14
%18 = OpLoad %6 %15
%19 = OpFAdd %6 %17 %18
OpStore %13 %19
OpReturn
OpFunctionEnd
)";
constexpr char kDstNoDebug[] = R"( OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %4 "main2" %13 %14 %15
OpEntryPoint Vertex %12 "main1" %8 %10
OpSource ESSL 310
OpDecorate %8 Location 0
OpDecorate %10 Location 0
OpDecorate %13 Location 0
OpDecorate %14 Location 0
OpDecorate %15 Location 1
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeFloat 32
%7 = OpTypePointer Output %6
%9 = OpTypePointer Input %6
%8 = OpVariable %7 Output
%10 = OpVariable %9 Input
%13 = OpVariable %7 Output
%14 = OpVariable %9 Input
%15 = OpVariable %9 Input
%4 = OpFunction %2 None %3
%16 = OpLabel
%17 = OpLoad %6 %14
%18 = OpLoad %6 %15
%19 = OpFAdd %6 %17 %18
OpStore %13 %19
OpReturn
OpFunctionEnd
%12 = OpFunction %2 None %3
%5 = OpLabel
%11 = OpLoad %6 %10
OpStore %8 %11
OpReturn
OpFunctionEnd
)";
constexpr char kDiff[] = R"( ; SPIR-V
; Version: 1.6
; Generator: Khronos SPIR-V Tools Assembler; 0
; Bound: 20
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
+OpEntryPoint Vertex %12 "main2" %13 %14 %15
OpEntryPoint Vertex %4 "main1" %8 %10
-OpEntryPoint Vertex %12 "main2" %13 %14 %15
OpSource ESSL 310
OpDecorate %8 Location 0
OpDecorate %10 Location 0
OpDecorate %13 Location 0
OpDecorate %14 Location 0
OpDecorate %15 Location 1
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeFloat 32
%7 = OpTypePointer Output %6
%9 = OpTypePointer Input %6
%8 = OpVariable %7 Output
%10 = OpVariable %9 Input
%13 = OpVariable %7 Output
%14 = OpVariable %9 Input
%15 = OpVariable %9 Input
%4 = OpFunction %2 None %3
%5 = OpLabel
%11 = OpLoad %6 %10
OpStore %8 %11
OpReturn
OpFunctionEnd
%12 = OpFunction %2 None %3
%16 = OpLabel
%17 = OpLoad %6 %14
%18 = OpLoad %6 %15
%19 = OpFAdd %6 %17 %18
OpStore %13 %19
OpReturn
OpFunctionEnd
)";
Options options;
DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options);
}
TEST(DiffTest, MultipleSameEntryPointsDumpIds) {
constexpr char kDiff[] = R"( ; SPIR-V
; Version: 1.6
; Generator: Khronos SPIR-V Tools Assembler; 0
; Bound: 20
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
+OpEntryPoint Vertex %12 "main2" %13 %14 %15
OpEntryPoint Vertex %4 "main1" %8 %10
-OpEntryPoint Vertex %12 "main2" %13 %14 %15
OpSource ESSL 310
OpName %4 "main1"
OpName %12 "main2"
OpName %8 "v"
OpName %10 "a"
OpName %13 "v"
OpName %14 "a"
OpName %15 "b"
OpDecorate %8 Location 0
OpDecorate %10 Location 0
OpDecorate %13 Location 0
OpDecorate %14 Location 0
OpDecorate %15 Location 1
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeFloat 32
%7 = OpTypePointer Output %6
%9 = OpTypePointer Input %6
%8 = OpVariable %7 Output
%10 = OpVariable %9 Input
%13 = OpVariable %7 Output
%14 = OpVariable %9 Input
%15 = OpVariable %9 Input
%4 = OpFunction %2 None %3
%5 = OpLabel
%11 = OpLoad %6 %10
OpStore %8 %11
OpReturn
OpFunctionEnd
%12 = OpFunction %2 None %3
%16 = OpLabel
%17 = OpLoad %6 %14
%18 = OpLoad %6 %15
%19 = OpFAdd %6 %17 %18
OpStore %13 %19
OpReturn
OpFunctionEnd
Src -> Dst
1 -> 1 [ExtInstImport]
2 -> 2 [TypeVoid]
3 -> 3 [TypeFunction]
4 -> 12 [Function]
5 -> 5 [Label]
6 -> 6 [TypeFloat]
7 -> 7 [TypePointer]
8 -> 8 [Variable]
9 -> 9 [TypePointer]
10 -> 10 [Variable]
11 -> 11 [Load]
12 -> 4 [Function]
13 -> 13 [Variable]
14 -> 14 [Variable]
15 -> 15 [Variable]
16 -> 16 [Label]
17 -> 17 [Load]
18 -> 18 [Load]
19 -> 19 [FAdd]
)";
Options options;
options.dump_id_map = true;
DoStringDiffTest(kSrc, kDst, kDiff, options);
}
} // namespace
} // namespace diff
} // namespace spvtools