Commit Graph

859 Commits

Author SHA1 Message Date
David Neto
dec3f5e231 Update spirv-opt to use spvtools::Optimizer
Exercises our public APIs more, and avoid including most
internal headers.  It also shortens the processing part
of the code, but does make adding passes look more complex.

Doing this exposed issue 611, a bug in spvtools::Optimizer.
2017-04-03 15:50:25 -04:00
David Neto
afc60bbebf Fix optimizer on when to write the binary
The spvtools::Optimizer::Run method should also write the output binary
if optimization succeeds without changes but the output binary vector
does not have exactly the same contents as the input binary.
We have to check both the base pointer of the storage and the size of
the vector

Added a test for this too.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/611
2017-04-03 15:48:50 -04:00
Lei Zhang
ad3b08280d Add /EHs for targets for MSVC 2017-04-03 15:41:01 -04:00
David Neto
4be6abe30d Fix spelling in SPV_AMD_gcn_shader support 2017-04-03 14:59:18 -04:00
David Neto
58e7a3e607 Fix typo in method name Struct::AddMemberName
Also add a method comment for it.
2017-04-01 11:19:40 -04:00
David Neto
ceb1d4f2fd Avoid inlining calls to external functions
External functions don't have bodies to inline anyway.
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/605
2017-03-31 10:36:58 -04:00
David Neto
4fc930229d opt::Function::cbegin and cend are const 2017-03-31 10:36:10 -04:00
David Neto
6cd4517730 Mention inliner in CHANGES 2017-03-29 18:02:40 -04:00
David Neto
2410e00851 Add low priority test suggestions for inliner 2017-03-29 18:02:40 -04:00
Greg Fischer
04fcc66743 Add exhaustive function call inlining to spirv-opt
Inlining is done for all functions designated as entry points.

Add optional validation to test fixture method SinglePassRunAndCheck.
2017-03-29 18:02:40 -04:00
David Srbecky
b85997a1df Add various accessors needed to read and edit SPIRV code. 2017-03-29 14:38:57 +01:00
David Neto
7fe8a57a5b Support SPV_AMD_gcn_shader
Supported in assembler, disassembler, and binary parser.

The validator does not check SPV_AMD_gcn_shader validation rules
beyond parsing the extension.

Adds generic support for generating instruction tables for vendor
extensions.

Adds generic support for extensions the validator should recognize
(but not check) but which aren't derived from the SPIR-V core
grammar file.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/594
2017-03-23 16:32:35 -04:00
David Neto
fa834dea40 Fix validator message for bad logical pointer
Affects OpLoad and OpStore validation.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/588
2017-03-23 15:50:45 -04:00
David Neto
ddd40f855b Update capability tests for SPV_KHR_16bit_storage rev 7
The SPIR-V core grammar file in a recent SPIRV-Headers
applied the fix from Rev 7 of SPV_KHR_16bit_storage:
FPRoundingMode enums are now enabled by the capabilities
introduced by that extension.

Update the SPIRV-Tools tests accordingly.
2017-03-23 15:46:08 -04:00
David Neto
654feb32f2 Do nothing if trying to make the current dir 2017-03-20 11:23:35 -04:00
David Neto
c3caa546a0 spirv-val prints warnings
Warnings and info messages go to stdout.
Errors still go to stderr.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/568
2017-03-17 12:48:51 -04:00
David Neto
0066a363d6 Add SpirvTools::Validate that takes an options object
Add spvtools::ValidatorOptions RAII wrapper around
a spv_validator_options value.
2017-03-17 12:48:51 -04:00
Andrey Tuganov
971ede33b2 Validator dissallows unsupported Vulkan capability
If environment is SPV_ENV_VULKAN_1_0, disallow OpCapability operands
which are not supported by Vulkan 1.0.

See https://github.com/KhronosGroup/SPIRV-Tools/issues/572
2017-03-17 10:28:35 -04:00
Andrey Tuganov
c804c125c5 Autogenererating enum-string mappings from grammar
Autogenerating the following code:
- extension enum
- extension-to-string
- string-to-extension
- capability-to-string

Capability mapping table will not compile if incomplete.
TODO: Use "spirv-latest-version.h" instead of 1.1.

Added function to generate capability tables for tests.
2017-03-16 15:29:17 -04:00
Andrey Tuganov
b011633171 Validator checks if operands require extension
If required extension is not found, returning new error
SPV_ERROR_MISSING_EXTENSION.
2017-03-14 13:39:43 -04:00
Andrey Tuganov
1fb8c37b57 Refactored enum_set
- removed forgotten file enum_set.cpp
- added IsEmpty and HasAnyOf
- hidden unsafe functions Add(uint32_t), Contains(uint32_t)
- added new tests
2017-03-10 13:38:32 -05:00
Andrey Tuganov
12f5509734 Fix extension grammar parsing
Extensions were not parsed correctly due to a typo in the Python script.
2017-03-09 15:32:42 -05:00
Andrey Tuganov
1c43cb8550 Validator parses and registers OpExtension
Known extensions are saved in validation state. Unknown extension
produce a dignostic message, but do not fail the validation.

Moved extension definitions to their own file.
2017-03-09 15:28:33 -05:00
David Neto
42037205a8 Test SPV_KHR_multiview in assembler, disassembler 2017-03-08 17:11:22 -05:00
David Neto
7327f63c34 Test SPV_KHR_device_group in assembler, disassembler 2017-03-08 17:11:22 -05:00
David Neto
83b334e549 Test SPV_KHR_16bit_storage in assembler, disassembler 2017-03-08 17:11:22 -05:00
David Neto
0004f721e3 Test SPV_KHR_subgroup_vote support in assembler, disassembler 2017-03-08 17:11:22 -05:00
Andrey Tuganov
9696393c5b Fix nullptr dereferencing in val_fixtures.cpp 2017-03-08 15:41:46 -05:00
David Neto
892b009959 Change Ids in tests to avoid confusion
The assembler assigns ID numbers sequentially, so it's confusing
to have a %1 in the source assembly when it isn't the first mentioned
ID.  Rewrite the ID names to avoid this situation in a few cases.
2017-03-07 09:51:32 -05:00
Aliya Pazylbekova
edb52647bd Validate that SpecId decoration target is a OpSpecConstant instruction
on a scalar

Fixes: https://github.com/KhronosGroup/SPIRV-Tools/issues/275
2017-03-07 09:51:16 -05:00
Andrey Tuganov
11fbe5dc1f Validator: unique type check allows runtime arrays
OpTypeRuntimeArray is an aggregate and therefore can have duplicate
declarations.
2017-03-02 17:24:29 -05:00
David Neto
a0c5ffe840 Use OpenCL extinst definitions from SPIRV-Headers
Remove the local copy of that file.
2017-03-02 10:37:37 -05:00
Ehsan Nasiri
2046e24498 Fixes issue #489.
From the SPIR-V Spec 2.16.1:

A function declaration (an OpFunction with no basic blocks), must have
a Linkage Attributes Decoration with the Import Linkage Type.

A function definition (an OpFunction with basic blocks) cannot be
decorated with the Import Linkage Type.
2017-03-02 10:06:29 -05:00
Lei Zhang
40be4bdd34 Allow using FPRoundingMode when see VK_KHR_16bit_storage
According to the extension, FPRoundingMode should be allowed to
use without requiring Kernel capability when VK_KHR_16bit_storage
is enabled.
2017-03-01 18:25:28 -05:00
Andrey Tuganov
94d94e1f4a Validator: downgraded dupl type decl to warning
Validator check for uniqueness of type declarations
(commit 0e9c24fdd1)
was causing failures in vulkancts tests.

Downgrading from error to warning.
2017-03-01 17:50:26 -05:00
Jean-Francois Roy
6a2b514826 Add a default virtual dtor to Pass and check for missing virtual dtors 2017-03-01 13:34:04 -05:00
Andrey Tuganov
0e9c24fdd1 Issue 559: check type declaration uniqueness
Adds PassTypeUnique to the validator.
Disallows repeated declarations of all types except for aggregates.
2017-02-28 22:27:08 -05:00
Andrey Tuganov
4ef3b3e0b9 Refactored validation_state, added new types
- validation_state.cpp uses functions from opcode.h instead of in-place
switches which need to be updated.
- added new spirv 1.1 type declaration opcodes to a 'is op type
declaration' switch in opcode.cpp.
2017-02-28 12:23:05 -05:00
Ehsan Nasiri
da4ae05638 Add command line options struct for the validator
The limit for the number of struct members is parameterized using
command line options.

Add --max-struct-depth command line option.
Add --max-switch-branches command line option.
Add --max-function-args command line option.
Add --max-control-flow-nesting-depth option.
Add --max-access-chain-indexes option.
2017-02-28 12:00:06 -05:00
David Neto
e3632a26b4 Update CHANGES for SPV_KHR_16bit_storage validator 2017-02-28 11:53:05 -05:00
David Neto
af7125dfb0 Validation of type decls for SPV_KHR_16bit_storage
Allow declaration of 16bit int or 16bit float in
the presence of capabilities from SPV_KHR_16bit_storage
2017-02-27 13:12:59 -05:00
David Neto
c6099ad242 Add a Feature struct to validation state.
For now, it is used only for checks of 16bit int and float types.
2017-02-27 13:12:59 -05:00
Adam Van Ymeren
c0949703b1 Fixes issue #548
Add validation checks for the reserved OpImageSparseSampleProj* opcodes.
2017-02-16 16:32:33 -05:00
David Neto
dadd5161bb Check strict domination of merge block
If a merge block is reachable, then it must be *strictly* dominated
by its header.  Until now we've allowed the header and the merge
block to be the same.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/551

Also: Use dominates and postdominates methods on BasicBlock to
improve readability.
2017-02-10 12:26:10 -05:00
Ehsan Nasiri
f2867d7485 The Signedness in OpTypeInt must always be 0.
When Kernel capability is used, The Signedness in OpTypeInt must always
be 0. Fixes issue #492.
2017-02-10 12:21:16 -05:00
Kenneth Benzie (Benie)
f980d8c671 Add vim-spirv plugin description to the README
Fixes #359
2017-02-01 21:43:01 +00:00
David Neto
ab03b879ca Encourage use of the validator 2017-01-29 22:53:50 -05:00
Ehsan Nasiri
affbc31849 Making the unit tests more robust.
It is best to check the error messages of unit tests that fail
validation. This will ensure that a validation failure is due to what we
expect and not due to some secondary reason.

Updating SPIR-V Validator unit tests with error message checks.
2017-01-29 22:50:37 -05:00
Ehsan Nasiri
cb009b3862 Fixes issue #497.
The Linkage Attributes Decoration cannot be applied to functions
targeted by an OpEntryPoint instruction.
2017-01-19 16:34:47 -05:00
Ehsan Nasiri
9c71c572e5 Check BuiltIn Decoration rules.
When applied to a structure-type member, all members of that structure
type must also be decorated with BuiltIn. (No allowed mixing of built-in
variables and non-built-in variables within a single structure.)

When applied to a structure-type member, that structure type cannot be
contained as a member of another structure type.

There is at most one object per Storage Class that can contain a
structure type containing members decorated with BuiltIn, consumed per
entry-point.
2017-01-19 16:01:06 -05:00