Commit Graph

94 Commits

Author SHA1 Message Date
dong-ja
c4c6f2ba5c
spirv-opt: Add dataflow analysis framework (#4402)
This PR adds a generic dataflow analysis framework to SPIRV-opt, with the intent of being used in SPIRV-lint. This may also be useful for SPIRV-opt, as existing ad-hoc analyses can be rewritten to use a common framework, but this is not the target of this PR.
2021-08-09 16:43:36 -04:00
dong-ja
7dadcf9c76
Add control dependence analysis to opt (#4380)
Control dependence analysis constructs a control dependence graph,
representing the conditions for a block's execution relative to the
results of other blocks with conditional branches, etc.
This is an analysis pass that will be useful for the linter and
potentially also useful in opt. Currently it is unused except for the
added unit tests.
2021-07-28 12:44:32 -04:00
krockot
4376a10c1d
Fix public deps on generated headers (#4386)
Some generated headers are exposed by headers in the spvtools_opt
target, but its dependency on them is private. This can result in build
flake, since the headers don't need to be generated before compiling
any spvtools_opt dependents.

This fixes the build flake by correctly expressing these as public
dependencies.
2021-07-26 14:27:25 -04:00
Corentin Wallez
b2db20a7e8
BUILD.gn: introduce finer grained internal targets for Tint (#4399)
Tint reaches out into SPIRV-Tools BUILD.gn file for some targets:

 - Adds spvtools_include_gen_dirs so that Tint can add $target_gen_dir
   and find autogenerated files.
 - Adds spvtools_language_headers that Tint can reference so it
   automatically picks up new language headers that are added.
2021-07-25 18:23:16 +01:00
Shiyu Liu
033768c24b
spirv-fuzz: TransformationWrapVectorSynonym that rewrites scalar operations using vectors (#4376)
Adds a new transformation that rewrites a scalar operation (like
OpFAdd, opISub) as an equivalent vector operation, adding a synonym
between the scalar result and an appropriate component of the vector
result.

Fixes #4195.
2021-07-20 11:01:20 +01:00
Greg Fischer
8966cc2b27
Add common enum for debug info instructions from either opencl or vulkan (#4377)
Co-authored-by: baldurk <baldurk@baldurk.org>
2021-07-16 16:28:14 -04:00
Jamie Madill
2685c9a687
Add missing fuzzer header dependency. (#4381)
Should fix the failing GN header check where the reduce header
was not visible to the fuzzer target.

Also reformats the GN file using 'gn format'.
2021-07-15 12:56:13 -04:00
Alastair Donaldson
feb05446bb
Fix BUILD.gn (#4378)
This change restricts BUILD.gn so that spirv-fuzz-related targets
are only built when in a Chromium checkout. This is due to their
dependence on protobuf, which is available in gn-friendly form in
Chromium only.

Fixes https://crbug.com/tint/987
2021-07-14 10:04:50 +01:00
Alastair Donaldson
2299b710de
spirv-fuzz: support building using gn (#4365)
Adds support for building spirv-fuzz using gn. Updates the protobuf
dependency to the version used by Chromium.

Fixes #4372.
2021-07-13 19:45:01 +01:00
Greg Fischer
d432bebb11
Fix vendor table build in BUILD.gn for nonsemantic.vulkan.debuginfo.100 (#4375)
Fixes #4374
2021-07-13 02:20:32 -04:00
Greg Fischer
3b6abf41cc
Add non-semantic vulkan extended instruction set (#4362)
This is based on a legacy commit which installs a local grammar. A
followup commit will change to the grammar in SPIRV-Headers.

Co-authored-by: baldurk <baldurk@baldurk.org>
2021-07-12 05:51:08 -04:00
Alastair Donaldson
9ce7a2fb62
spirv-reduce: Eliminate skeletal structured control flow construct (#4360)
This change allows spriv-reduce to get rid of a selection, switch or
loop construct if none of the instructions defined in the construct
are used outside the construct.
2021-07-06 07:14:36 +01:00
Steven Perron
a95bc460f9
Add remove_unused_interface_variable_pass.* to BUILD.gn (#4363) 2021-07-02 10:18:19 -04:00
Shahbaz Youssefi
ae6a1e1d2f
Fix UWP build (#4235)
UWP doesn't support system(), so skip building spirv-reduce on it
similarly to iOS.
2021-04-12 13:17:44 -04:00
Greg Fischer
48007a5c7f
Add interpolate legalization pass (#4220)
This pass converts an internal form of GLSLstd450 Interpolate ops
to the externally valid form. The external form takes the lvalue
of the interpolant. The internal form can do a load of the interpolant.
The pass replaces the load with its pointer. The internal form is
generated by glslang and possibly other frontends for HLSL shaders.
The new pass is called as part of HLSL legalization after all
propagation is complete.

Also adds internal interpolate form to pre-legalization validation
2021-03-31 14:26:36 -04:00
Corentin Wallez
5d8c40399e
BUILD.gn: fix typo for 'cflags' (#4169) 2021-03-11 10:08:33 +00:00
Corentin Wallez
77eb2b608e
Suppress warning (#4168)
* GN: Format BUILD.gn using 'gn format'

* GN: Suppress -Wformat-truncation on GCC for a Skia builder
2021-03-10 15:19:24 -05:00
Ryan Harrison
9150cd441f
Remove WebGPU support (#4108)
Leaves SPV_ENV_WEBGPU_0 enum in place, but marked deprecated, so users
of the library are not broken by an API enum being removed.

Fixes #4101
2021-01-14 16:45:18 -05:00
Jaebaek Seo
f7da527757
Temporarily add EmptyPass to prevent glslang from failing (#4004)
Removing PropagateLineInfoPass and RedundantLineInfoElimPass from
56d0f5035 makes unit tests of many open source projects fail.
It will happen before submitting this glslang PR
https://github.com/KhronosGroup/glslang/pull/2440. This commit will be
git-reverted after merging the glslang PR.
2020-10-30 18:03:56 -04:00
Jaebaek Seo
56d0f50357
Propagate OpLine to all applied instructions in spirv-opt (#3951)
Based on the OpLine spec, an OpLine instruction must be applied to
the instructions physically following it up to the first occurrence
of the next end of block, the next OpLine instruction, or the next
OpNoLine instruction.

```
OpLine %file 0 0
OpNoLine
OpLine %file 1 1
OpStore %foo %int_1
%value = OpLoad %int %foo
OpLine %file 2 2
```

For the above code, the current spirv-opt keeps three line
instructions `OpLine %file 0 0`, `OpNoLine`, and `OpLine %file 1 1`
in `std::vector<Instruction> dbg_line_insts_` of Instruction class
for `OpStore %foo %int_1`. It does not put any line instruction to
`std::vector<Instruction> dbg_line_insts_` of
`%value = OpLoad %int %foo` even though `OpLine %file 1 1` must be
applied to `%value = OpLoad %int %foo` based on the spec.

This results in the missing line information for
`%value = OpLoad %int %foo` while each spirv-opt pass optimizes the
code. We have to put `OpLine %file 1 1` to
`std::vector<Instruction> dbg_line_insts_` of
both `%value = OpLoad %int %foo` and `OpStore %foo %int_1`.

This commit conducts the line instruction propagation and skips
emitting the eliminated line instructions at the end, which are the same
with PropagateLineInfoPass and RedundantLineInfoElimPass. This
commit removes PropagateLineInfoPass and RedundantLineInfoElimPass.

KhronosGroup/glslang#2440 is a related PR that stop using
PropagateLineInfoPass and RedundantLineInfoElimPass from glslang.
When the code in this PR applied, the glslang tests will pass.
2020-10-29 13:06:30 -04:00
Alastair Donaldson
726af6f78f
Add missing file to BUILD.gn (#3798)
Fixes #3797.
2020-09-11 22:20:58 +01:00
alan-baker
50300450af
Validator support for non-semantic clspv reflection (#3618)
* Generate ext inst table for reflection
* Change build to use grammar files from SPIRV-Headers instead of
  SPIRV-Tools
* Add enum for clspv reflection extended instruction set
  * count it as non-semantic
* validate clspv reflection extended instruction set
* Remove local extended inst sets
* update headers deps
* Update nbuilds to use grammars from SPIRV-Headers instead of
  local duplicates
2020-07-30 12:08:53 -04:00
Ryan Harrison
95df4c9643
Add in a bunch of missed files to the BUILD.gn (#3360)
Fixes #3357
2020-05-19 15:17:58 -04:00
Ryan Harrison
90930cb311
Remove stale entries from BUILD.gn (#3358)
Fixes #3357
2020-05-19 13:25:45 -04:00
Jaebaek Seo
42268740c9
Add debug information analysis (#3305)
We need an analysis for OpenCL.DebugInfo.100 extension instructions such
as a map between function id and its DebugFunction. This commit add an
analysis for it.
2020-04-27 15:18:55 -04:00
greg-lunarg
1fe9bcc108
Instrument: Debug Printf support (#3215)
Create a pass to instrument OpDebugPrintf instructions.  This pass replaces all OpDebugPrintf instructions with instructions to write a record containing the string id and the all specified values into a special printf output buffer (if space allows). This pass is designed to support the printf validation in the Vulkan validation layers.

Fixes #3210
2020-03-12 09:19:52 -04:00
Geoff Lang
fb6e3e48d5
Combine extinst-name and extinst-output-base into one arg. (#3200)
* Combine the extinst-name and extinst-output-base into one arg.

Some build systems such as Android blueprints require that the inputs
and outputs of generator scripts are all provided as arguments.  These
two arguments to generate_language_headers.py are combined to form the
output path in the script.  This change simply lets the user provide the
whole output path as an argument.

* Fix typo in build_defs.bzl and update Android.mk
2020-02-25 00:46:52 -05:00
Geoff Lang
c316fb15fb
Add missing dependencies when generating spvtools_core_tables (#3199) 2020-02-21 17:23:42 -05:00
Shahbaz Youssefi
1b3441036a Fix chromium build (#3152)
Signed-off-by: Shahbaz Youssefi <syoussefi@google.com>
2020-01-24 17:14:16 -05:00
Shahbaz Youssefi
b97057e7f7 Use spirv-headers' BUILD.gn (#3148)
* Roll external/spirv-headers/ af64a9e82..dc77030ac (4 commits)

$ git log af64a9e82..dc77030ac --date=short --no-merges --format='%ad %ae %s'
2020-01-20 dneto Fix the license to match LICENSE
2020-01-20 syoussefi Add BUILD.gn
2019-11-20 Tobias.Hector Off-by-one errors
2019-11-20 Tobias.Hector Reserve a new block of 64 opcodes

Created with:
  roll-dep external/spirv-headers

* Use BUILD.gn from spirv-headers
2020-01-23 13:40:12 -05:00
David Neto
fb2e819819
Fix GN build for OpenCL.DebugInfo.100 update (#3134)
The utils/generate_grammar_tables.py vendor-operand-kind-prefix
can now take a value of "...nil..." to signify the empty string.
That's needed because GN doesn't quote empty string arguments
correctly down into its action commands.

Fixes #3120
2020-01-08 17:27:38 -05:00
David Neto
64f36ea529
Support OpenCL.DebugInfo.100 extended instruction set (#3080)
* Clone opencl.debuginfo.100 grammar from debuginfo grammar

Update version number to 200 revision 2

* Apply content from OpenCL.DebugInfo.100 extension text

* Rename grammar file

* Support OpenCL.DebugInfo.100 extended instructions

Add support for prefixing operand type names, to disambiguate
them between different instruction sets.

* Add tests for OpenCL.DebugInfo.100

* Support lookup of OpenCL.DebugInfo.100 extinst

* Add tests for enum values

* Recognize 2017-2019 as copyright date range

* Android.mk: support OpenCL.DebugInfo.100 extended instruction set

Also, stop generating core instruction tables for non-unified1 versions
of the grammar.

* Imported entity operand type is concrete

* Bazel: Suppoort OpenCL.DebugInfo.100

* BUILD.gn: Support OpenCL.DebugInfo.100
2019-12-19 17:16:26 -05:00
Jamie Madill
e0d5544c98 Add missing headers to GN. (#3009)
Detected via ANGLE's export_targets.py.

Fixes #3008
2019-11-04 21:01:57 -05:00
Ryan Harrison
c705032b2b
Remove non-existent files from BUILD.gn (#2955)
Fixes #2954
2019-10-09 15:46:36 -04:00
alan-baker
527a689307
Remove validate_datarules.cpp (#2911)
* Checks moved into individual opcode validation
  * removes duplicated checks
* Add check that forward pointer points to struct
2019-09-24 17:55:12 -04:00
dan sinclair
3a762d54f6
Add missing GN dependency (#2899) 2019-09-23 12:56:29 -04:00
David Turner
36c1c0e22f Fix Fuchsia build. (#2868)
Most auto-generated files included by the SPIRV-Tools sources
do not have a proper newline at the end of file, creating a
hundred of compiler warnings, and even some build failures
when BUILD.gn is used for the Fuchsia build.

This fixes the issue by disabling the warning entirely.
2019-09-17 15:57:15 -04:00
Steven Perron
35c9518c4e
Handle id overflow in the ssa rewriter. (#2845)
* Handle id overflow in the ssa rewriter.

Remove LocalSSAElim pass at the same time.  It does the same thing as the SSARewrite pass. Then even share almost all of the same code.

Fixes crbug.com/997246
2019-09-10 09:38:23 -04:00
Jamie Madill
635b583cf1 GN: Add Chromium GoogleTest deps. (#2832)
This fixes a GN header check in the Chromium integration.
2019-09-04 12:43:26 -04:00
greg-lunarg
d11725b1d4 Add --relax-float-ops and --convert-relaxed-to-half (#2808)
The first pass applies the RelaxedPrecision decoration to all executable
instructions with float32 based type results. The second pass converts
all executable instructions with RelaxedPrecision result to the equivalent
float16 type, inserting converts where necessary.
2019-09-03 13:22:13 -04:00
Jamie Madill
1c9ca422dd GN: Make SPIRV-Tools target use public_deps. (#2828)
Should prevent invalid header usage warnings in dependent targets.

See http://anglebug.com/3876 for context.
2019-09-03 12:57:32 -04:00
Corentin Wallez
4ae9b71651 Fix gn check (#2821)
spriv-opt was missing a dependency on the AMD ballot extension that was
needed because it uses a header in the AMD ext to KHR ext pass.
2019-08-30 09:09:34 -04:00
Steven Perron
35d98be3bc
Amd ext to khr (#2811)
Add the first steps to removing the AMD extension VK_AMD_shader_ballot.
Splitting up to make the PRs smaller.

Adding utilities to add capabilities and change the version of the
module.

Replaces the instructions:

OpGroupIAddNonUniformAMD = 5000
OpGroupFAddNonUniformAMD = 5001
OpGroupFMinNonUniformAMD = 5002
OpGroupUMinNonUniformAMD = 5003
OpGroupSMinNonUniformAMD = 5004
OpGroupFMaxNonUniformAMD = 5005
OpGroupUMaxNonUniformAMD = 5006
OpGroupSMaxNonUniformAMD = 5007

and extentend instructions

WriteInvocationAMD = 3
MbcntAMD = 4

Part of #2814
2019-08-29 12:48:17 -04:00
jonahryandavis
1eb89172a8 Add missing files to BUILD.gn (#2809)
New files missing from BUILD.gn caused build failures in Chromium and
ANGLE:
remove_relaxed_precision_decoration_opportunity_finder.cpp
remove_relaxed_precision_decoration_opportunity_finder.h
2019-08-23 13:14:34 -04:00
greg-lunarg
06407250a1 Instrument: Add support for Buffer Device Address extension (#2792) 2019-08-16 09:18:34 -04:00
Steven Perron
60043edfa1
Replace OpKill With function call. (#2790)
We are no able to inline OpKill instructions into a continue construct.
See #2433.  However, we have to be able to inline to correctly do
legalization.  This commit creates a pass that will wrap OpKill
instructions into a function of its own.  That way we are able to inline
the rest of the code.

The follow up to this will be to not inline any function that contains
an OpKill.

Fixes #2726
2019-08-14 09:27:12 -04:00
Steven Perron
4b64beb1ae
Add descriptor array scalar replacement (#2742)
Creates a pass that will replace a descriptor array with individual variables.  See #2740 for details.

Fixes #2740.
2019-08-08 10:53:19 -04:00
David Neto
31590104ec
Add pass to inject code for robust-buffer-access semantics (#2771)
spirv-opt: Add --graphics-robust-access

Clamps access chain indices so they are always
in bounds.

Assumes:
- Logical addressing mode
- No runtime-array-descriptor-indexing
- No variable pointers

Adds stub code for clamping coordinate and samples
for OpImageTexelPointer.

Adds SinglePassRunAndFail optimizer test fixture.

Android.mk: add source/opt/graphics_robust_access_pass.cpp

Adds Constant::GetSignExtendedValue, Constant::GetZeroExtendedValue
2019-07-30 19:52:46 -04:00
greg-lunarg
92c41ff1e7 Remove Common Uniform Elimination Pass (#2731)
Remove Common Uniform Elimination Pass

Fixes #2520.
2019-07-12 11:02:10 -04:00
Corentin Wallez
59de04ad68 BUILD.gn: Add deps and move files for gn check (#2735)
This makes SPIRV-Tools produce no GN check errors when used in Dawn and
ANGLE.
2019-07-12 10:35:59 -04:00