Commit Graph

986 Commits

Author SHA1 Message Date
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
Ehsan Nasiri
3a7df2cf1b Fixes issue #532.
It is acceptable for OpAccessChain, OpInBoundsAccessChain,
OpPtrAccessChain, OpInBoundsPtrAccessChain, OpCompositeInsert, and
OpCompositeExtract to not take any indexes as arguments. In such cases,
no indexing will be done on the Base pointer/composite.
2017-01-19 11:03:04 -05:00
Ehsan Nasiri
eb7d2534df Fixes issue #493.
Check function call operands and return type agree with the called
function type.

The validation code exists. I have fixed the unit tests.
2017-01-18 17:04:00 -05:00
Ehsan Nasiri
d75bf5ef03 Validation for decoration rules. Fixes issue #499.
Added a new file where all the decoration validation can be performed.

In this change the SPIRV Spec Section 2.16.1 is implemented:
"It is illegal to initialize an imported variable. This means
that a module-scope OpVariable with initialization value cannot be
marked with the Import Linkage Type."

Also added unit tests.
2017-01-18 16:29:14 -05:00
David Neto
699943d297 Say why we allow override of build timestamp
It's for reproducible builds.

Also, fix Python formatting.
2017-01-17 15:42:02 -05:00
Bernhard M. Wiedemann
29b37fb310 make build reproducible
see https://reproducible-builds.org/ for why this is good
2017-01-17 19:36:39 +01:00
Ehsan Nasiri
fcf7df069d Adding decoration class and tests.
* Added the decoration class as well as the code that registers the
decorations for each <id> and also decorations for struct members.

* Added unit tests for decorations in ValidationState as well as
decoration id tests.
2017-01-16 16:52:08 -05:00
Ehsan Nasiri
1c11c8690f Validation of OpEntryPoint usage.
According to the SPIRV Spec (2.16.1):
* There is at least one OpEntryPoint instruction, unless the Linkage
capability is being used.

* No function can be targeted by both an OpEntryPoint instruction and an
OpFunctionCall instruction.

Also updated unit tests to includ OpEntryPoint.
2017-01-13 16:15:11 -05:00
Ehsan Nasiri
68e36ec7e9 Introducing a new flow for running the Validator.
We are adding a new API which can be called to run the SPIR-V validator,
and retrieve the ValidationState_t object. This is very useful for
unit testing.

I have also added basic unit tests that demonstrate usage of this flow
and ease of use to verify correctness.
2017-01-13 16:07:03 -05:00
Lei Zhang
d5e4f06eec Update Travis CI configuration.
* Stop updating brew.
* Shadow clone of dependencies.
* Fix `nproc` on macOS.
2017-01-13 09:53:16 -05:00
David Neto
545a6c1dc3 Provide friendly names for true and false 2017-01-11 16:33:45 -05:00
Ehsan Nasiri
d1868b9361 Validation for Composite Extract and Insert.
The validity of each command is checked based on the descripton in
SPIR-V Spec Section 3.32.12 (Composite Instructions).

Also checked that the number of indexes passed to these commands does
not exceed the limit described in 2.17 (Universal Limits).

Also added unit tests for each one.
2017-01-06 17:14:38 -05:00
Ehsan Nasiri
109ce225c9 Fixes bug #517.
entry_block_to_construct_ maps an entry block to its construct. The key
in this map (the entry block) is not unique, and therefore the entry for
the continue construct gets overwritten when the selection construct is
discovered.

Since a given block may be the entry block of different types of
constructs, the (basic_block, construct_type) pair should be able to
uniquely identify the construct.

Adds test:
- In this test, a basic block is the entry block of a continue construct
  as well as the entry block of a selection construct.
  It can be shown that this unit test would crash without the fix in this
  PR and passes with the fix in this PR.
2017-01-06 14:23:17 -05:00
David Neto
558ac1e5aa Allow trailing whitespace on version lines in CHANGES 2017-01-06 13:18:50 -05:00
David Neto
20b2035f20 Use the default Xcode image on OSX
As of November 2016, the default OSX image is Xcode 7.3.1, which works.
2017-01-05 16:06:31 -05:00
Ehsan Nasiri
ff272a9820 Adding validation code for PtrAccessChain.
Validation for OpPtrAccessChain is similar to OpAccessChain with the
following difference: OpPtrAccessChain takes an extra argument (word 4)
which is the Element <id> argument.

Validation for OpInBoundsPtrAccessChain is also similar to OpPtrAccessChain.

Also added tests for all access chain instructions:
Modified the existing parameterized tests to accommodate OpPtrAccessChain and
OpInBoundsPtrAccessChain.

Also fixed a typo in previous commits.
2017-01-03 16:36:35 -05:00
Ehsan Nasiri
c656c23ad3 Refactoring unit tests using TEST_P.
Using parameterized unit tests to avoid duplicate code that runs the
tests of OpAccessChain and OpInBoundsAccessChain.

This is also a steppingstone to adding tests for OpPtrAccessChain and
OpInBoundsPtrAccessChain.
2017-01-03 14:58:48 -05:00
Ehsan Nasiri
6993fc413d Validation code for control flow nesting depth.
According to Section 2.17 (Universal Limits) of the SPIR-V Spec, the
control flow nesting depth may not be larger than 1023.

This is checked only when we are required to have structured
control flow.  Otherwise it's not clear how to compute control
flow nesting depth.
2016-12-23 14:14:50 -05:00
David Neto
37422e9dba Support building under CYGWIN
- Parse CHANGES file with Universal Python line endings in case
  the source tree was checked out with Windows line endings.
- Use our own clone of strnlen_s which might not be available
  everywhere.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/508
2016-12-21 10:34:23 -05:00
David Neto
e0e4044ffe Update Travis notification emails
Remove deki, add ehsann
2016-12-21 10:33:03 -05:00
David Neto
f8cc397573 Generate spvasm.vim
Generate a vim syntax file for SPIR-V assembly.
Copy the resulting spvasm.vim into your $HOME/.vim/syntax directory
to get syntax highlighting in Vim.

Also, suggest that the grammar file include information
about what opcodes can be used in OpSpecConstantOp.
2016-12-20 11:36:41 -05:00
David Neto
68c5f0436f Start v2016.7-dev 2016-12-13 11:49:50 -05:00
David Neto
5f5fa3a3f1 Finalize v2016.6 2016-12-13 11:49:09 -05:00
David Neto
5a0b5ca4a7 Get vendor tool info from the SPIR-V registry file
Update old tests to use officially registered vendor names;
this affected "Codeplay".
2016-12-09 14:01:43 -05:00