Skip to content

Commit

Permalink
[lit][SPIRV] convert runCodeTest to lit and remove dependence on effc…
Browse files Browse the repository at this point in the history
…ee (microsoft#6077)

Convert runCodeTest to lit FileCheck test and remove all the code
related to runCodeTest.

Remove effcee and re2 from git submodule since nothing is dependent on
them after the change.
  • Loading branch information
python3kgae authored Dec 14, 2023
1 parent ad3958c commit 5f7834d
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 891 deletions.
6 changes: 0 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
[submodule "external/googletest"]
path = external/googletest
url = https://github.com/google/googletest
[submodule "external/re2"]
path = external/re2
url = https://github.com/google/re2
[submodule "external/effcee"]
path = external/effcee
url = https://github.com/google/effcee
[submodule "external/DirectX-Headers"]
path = external/DirectX-Headers
url = https://github.com/microsoft/DirectX-Headers.git
45 changes: 0 additions & 45 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,49 +72,4 @@ if (${ENABLE_SPIRV_CODEGEN})
set_property(TARGET ${target} PROPERTY FOLDER "External dependencies")
endforeach()

# We need Effcee for SPIR-V codegen testing.
if (${SPIRV_BUILD_TESTS})
# re2 is needed since it's required by effcee.
set(DXC_RE2_DIR "${DXC_EXTERNAL_ROOT_DIR}/re2" CACHE STRING "Location of RE2 source")
set(DXC_EFFCEE_DIR "${DXC_EXTERNAL_ROOT_DIR}/effcee" CACHE STRING "Location of Effcee source")

if (NOT TARGET re2)
if (IS_DIRECTORY ${DXC_RE2_DIR})
# Avoid exception handling warning from MSVC.
# This add_compile_options() will only affect the current directory and its subdirectories.
if (WIN32)
add_compile_options(/EHs)
else(WIN32)
# Disable all warnings in subproject RE2
add_compile_options(-w)
endif(WIN32)
# Don't build/run re2's tests.
set(RE2_BUILD_TESTING OFF CACHE BOOL "Skip RE2 tests")
add_subdirectory(${DXC_RE2_DIR} EXCLUDE_FROM_ALL)
endif()
endif()

if (NOT TARGET effcee)
if (IS_DIRECTORY ${DXC_EFFCEE_DIR})
# Configure effcee
set(EFFCEE_RE2_DIR "${DXC_RE2_DIR}" CACHE STRING "Location of RE2 for effcee")
set(EFFCEE_ENABLE_SHARED_CRT ON CACHE BOOL "Enable using shared C Runtime")
# Don't build/run effcee's tests.
set(EFFCEE_BUILD_TESTING OFF CACHE BOOL "Skip effcee tests")
set(EFFCEE_BUILD_SAMPLES OFF CACHE BOOL "Skip building effcee examples")
add_subdirectory(${DXC_EFFCEE_DIR} EXCLUDE_FROM_ALL)
endif()
endif()

# Organize these targets better in Visual Studio
set(SPIRV_TEST_DEP_TARGETS
effcee
re2
)
foreach(target ${SPIRV_TEST_DEP_TARGETS})
set_property(TARGET ${target} PROPERTY FOLDER "External dependencies")
endforeach()

endif()

endif()
1 change: 0 additions & 1 deletion external/effcee
Submodule effcee deleted from 66edef
1 change: 0 additions & 1 deletion external/re2
Submodule re2 deleted from b76a3e
12 changes: 12 additions & 0 deletions tools/clang/test/CodeGenSPIRV/InlinedCodeTest.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: %dxc -T ps_6_0 -E PSMain -fcgl %s -spirv | FileCheck %s

struct PSInput
{
float4 color : COLOR;
};

// CHECK: OpFunctionCall %v4float %src_PSMain
float4 PSMain(PSInput input) : SV_TARGET
{
return input.color;
}
12 changes: 12 additions & 0 deletions tools/clang/test/CodeGenSPIRV/InlinedCodeWithErrorTest.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: not %dxc -T ps_6_0 -E PSMain -fcgl %s -spirv 2>&1 | FileCheck %s

struct PSInput
{
float4 color : COLOR;
};

// CHECK: error: cannot initialize return object of type 'float4' with an lvalue of type 'PSInput'
float4 PSMain(PSInput input) : SV_TARGET
{
return input;
}
53 changes: 53 additions & 0 deletions tools/clang/test/CodeGenSPIRV/PositionInVSTests.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// RUN: not %dxc -T vs_6_2 -E main -DTY=float -DARRAY=[4] -fcgl %s -spirv 2>&1 | FileCheck %s
// RUN: not %dxc -T vs_6_2 -E main -DTY=double4 -fcgl %s -spirv 2>&1 | FileCheck %s
// RUN: not %dxc -T vs_6_2 -E main -DTY=int4 -fcgl %s -spirv 2>&1 | FileCheck %s
// RUN: not %dxc -T vs_6_2 -E main -DTY=float1x4 -fcgl %s -spirv 2>&1 | FileCheck %s
// RUN: not %dxc -T vs_6_2 -E main -DTY=float3 -fcgl %s -spirv 2>&1 | FileCheck %s
// RUN: not %dxc -T vs_6_2 -E main -DTY=InvalidType -fcgl %s -spirv 2>&1 | FileCheck %s

// RUN: %dxc -T vs_6_2 -E main -DTY=ValidType -fcgl %s -spirv | FileCheck %s --check-prefix=VALID_TY

// RUN: %dxc -T vs_6_2 -E main -DTY=float4 -fcgl %s -spirv | FileCheck %s --check-prefix=VALID_FLOAT
// RUN: %dxc -T vs_6_2 -E main -DTY=min10float4 -fcgl %s -spirv | FileCheck %s --check-prefix=VALID_FLOAT
// RUN: %dxc -T vs_6_2 -E main -DTY=min16float4 -fcgl %s -spirv | FileCheck %s --check-prefix=VALID_FLOAT
// RUN: %dxc -T vs_6_2 -E main -DTY=half4 -fcgl %s -spirv | FileCheck %s --check-prefix=VALID_FLOAT

// RUN: not %dxc -T vs_6_2 -E main -enable-16bit-types -DTY=half4 -fcgl %s -spirv 2>&1 | FileCheck %s
// RUN: not %dxc -T vs_6_2 -E main -enable-16bit-types -DTY=min10float4 -fcgl %s -spirv 2>&1 | FileCheck %s


// CHECK: error: SV_Position must be a 4-component 32-bit float vector or a composite which recursively contains only such a vector

// VALID_TY: %ValidType = OpTypeStruct %v4float
// VALID_TY: %output = OpTypeStruct %ValidType

// VALID_FLOAT: %output = OpTypeStruct %v4float




struct InvalidType {
float3 x;
};

struct ValidType {
float4 x;
};

#ifndef ARRAY
#define ARRAY
#endif

#define POSITION TY x ARRAY

struct output {
POSITION;
};



output main() : SV_Position
{
output result;
return result;
}
4 changes: 4 additions & 0 deletions tools/clang/test/CodeGenSPIRV/SourceCodeWithoutFilePath.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// RUN: %dxc -T ps_6_0 -E PSMain -Zi -fcgl %s -spirv | FileCheck %s

float4 PSMain(float4 color : COLOR) : SV_TARGET { return color; }
// CHECK: float4 PSMain(float4 color : COLOR) : SV_TARGET { return color; }
6 changes: 1 addition & 5 deletions tools/clang/unittests/SPIRV/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ set(LLVM_LINK_COMPONENTS
)

add_clang_unittest(ClangSPIRVTests
CodeGenSpirvTest.cpp
FileTestFixture.cpp
FileTestUtils.cpp
SpirvBasicBlockTest.cpp
SpirvContextTest.cpp
SpirvTestOptions.cpp
Expand All @@ -28,7 +25,6 @@ target_link_libraries(ClangSPIRVTests
clangSPIRV
clangTooling
dxcompiler
effcee
SPIRV-Tools
)

Expand All @@ -38,7 +34,7 @@ target_link_libraries(ClangSPIRVTests
add_dependencies(ClangSPIRVTests dxcompiler)

target_include_directories(ClangSPIRVTests
PRIVATE ${SPIRV_TOOLS_INCLUDE_DIR} ${DXC_EFFCEE_DIR})
PRIVATE ${SPIRV_TOOLS_INCLUDE_DIR})

if (NOT CLANG_INCLUDE_TESTS)
set_output_directory(ClangSPIRVTests
Expand Down
167 changes: 0 additions & 167 deletions tools/clang/unittests/SPIRV/CodeGenSpirvTest.cpp

This file was deleted.

Loading

0 comments on commit 5f7834d

Please sign in to comment.