SPIRV-Tools/test/opt/CMakeLists.txt
qining 380f36eae1 Fold spec constants to normal constants (values fixed)
For the spec constants defined by OpSpecConstantOp and
OpSpecContantComposite, if all of their operands are constants with
determined values (normal constants whose values are fixed), calculate
the correct values of the spec constants and re-define them as normal
constants.

In short, this pass replaces all the spec constants defined by
OpSpecContantOp and OpSpecConstantComposite with normal constants when
possible. So far not all valid operations of OpSpecConstantOp are
supported, we have several constriction here:

1) Only 32-bit integer and boolean (both scalar and vector) are
supported for any arithmetic operations. Integers in other width (like
64-bit) are not supported.
2) OpSConvert, OpFConvert, OpQuantizeToF16, and all the
operations under Kernel capability, are not supported.
3) OpCompositeInsert is not supported.

Note that this pass does not unify normal constants. This means it is
possible to have new generatd constants defining the same values.
2016-08-29 08:58:53 -04:00

97 lines
3.0 KiB
CMake

# Copyright (c) 2016 Google Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and/or associated documentation files (the
# "Materials"), to deal in the Materials without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Materials, and to
# permit persons to whom the Materials are furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Materials.
#
# MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
# KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
# SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
# https://www.khronos.org/registry/
#
# THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
add_spvtools_unittest(TARGET instruction
SRCS test_instruction.cpp
LIBS SPIRV-Tools-opt ${SPIRV_TOOLS}
)
add_spvtools_unittest(TARGET ir_loader
SRCS test_ir_loader.cpp
LIBS SPIRV-Tools-opt ${SPIRV_TOOLS}
)
add_spvtools_unittest(TARGET pass_manager
SRCS module_utils.h
test_pass_manager.cpp
LIBS SPIRV-Tools-opt ${SPIRV_TOOLS}
)
add_spvtools_unittest(TARGET pass_strip_debug_info
SRCS test_strip_debug_info.cpp pass_utils.cpp
LIBS SPIRV-Tools-opt ${SPIRV_TOOLS}
)
add_spvtools_unittest(TARGET pass_freeze_spec_const
SRCS test_freeze_spec_const.cpp pass_utils.cpp
LIBS SPIRV-Tools-opt ${SPIRV_TOOLS}
)
add_spvtools_unittest(TARGET pass_eliminate_dead_const
SRCS test_eliminate_dead_const.cpp pass_utils.cpp
LIBS SPIRV-Tools-opt ${SPIRV_TOOLS}
)
add_spvtools_unittest(TARGET pass_utils
SRCS test_utils.cpp pass_utils.cpp
LIBS SPIRV-Tools-opt ${SPIRV_TOOLS}
)
add_spvtools_unittest(TARGET def_use
SRCS test_def_use.cpp pass_utils.cpp
LIBS SPIRV-Tools-opt ${SPIRV_TOOLS}
)
add_spvtools_unittest(TARGET assembly_builder
SRCS test_assembly_builder.cpp pass_utils.cpp
LIBS SPIRV-Tools-opt ${SPIRV_TOOLS}
)
add_spvtools_unittest(TARGET types
SRCS test_types.cpp
LIBS SPIRV-Tools-opt
)
add_spvtools_unittest(TARGET type_manager
SRCS test_type_manager.cpp
LIBS SPIRV-Tools-opt ${SPIRV_TOOLS}
)
add_spvtools_unittest(TARGET iterator
SRCS test_iterator.cpp
LIBS SPIRV-Tools-opt ${SPIRV_TOOLS}
)
add_spvtools_unittest(TARGET module
SRCS module_utils.h
test_module.cpp
LIBS SPIRV-Tools-opt ${SPIRV_TOOLS}
)
add_spvtools_unittest(TARGET pass_fold_spec_const_op_composite
SRCS test_fold_spec_const_op_composite.cpp pass_utils.cpp
LIBS SPIRV-Tools-opt ${SPIRV_TOOLS}
)