Commit Graph

569 Commits

Author SHA1 Message Date
David Neto
e461cbe268 Avoid capability checks on ID values. They are not literals
Works around issue 248 by weakening the test:
https://github.com/KhronosGroup/SPIRV-Tools/issues/248

The validator should try to track (32-bit) constant values, and then
for capability checks on IDs, check the referenced value, not the
raw ID number.
2016-06-29 10:39:21 -04:00
Lei Zhang
f760d115b9 Add tests for the cpp interface. 2016-06-28 14:52:35 -04:00
Lei Zhang
abf8f6413c Promote ir namespace and create draft libspirv.{h|c}pp. 2016-06-28 14:52:34 -04:00
Lei Zhang
8590f9cc81 Add IrBuilder for constructing SPIR-V in-memory representation. 2016-06-27 16:57:42 -04:00
Lei Zhang
200e897887 Add an option to spvBinaryToText() to ignore header output. 2016-06-27 15:25:24 -04:00
Umar Arshad
886dd352d5 Fix several violations of the style guide 2016-06-27 10:45:46 -04:00
Lei Zhang
3df8f7cebd Add classes for representing SPIR-V language constructs in memory. 2016-06-24 20:54:06 -04:00
Lei Zhang
df37653333 Travis CI: bump OS X and XCode version. 2016-06-24 17:16:00 -04:00
David Neto
5065227748 Use pseudo entry and pseudo exit blocks for dominance.
For dominance calculations we use an "augmented" CFG
where we always add a pseudo-entry node that is the predecessor
in the augmented CFG to any nodes that have no predecessors in the
regular CFG.  Similarly, we add a pseudo-exit node that is the
predecessor in the augmented CFG that is a successor to any
node that has no successors in the regular CFG.

Pseudo entry and exit blocks live in the Function object.

Fixes a subtle problem where we were implicitly creating
the block_details for the pseudo-exit node since it didn't
appear in the idoms map, and yet we referenced it.  In such a case the
contents of the block details could be garbage, or zero-initialized.
That sometimes caused incorrect calculation of immediate dominators
and post-dominators.  For example, on a debug build where the details
could be zero-initialized, the dominator of an unreachable block would
be given as the pseudo-exit node.  Bizarre.

Also, enforce the rule that you must have an OpFunctionEnd to close off
the last function.
2016-06-24 17:08:20 -04:00
Lei Zhang
1a050b1069 Use arguments for add_spvtools_unittest. 2016-06-22 12:13:59 -04:00
Lei Zhang
18a263e763 Appveyor: Pull SPIRV-Headers for building and update README link. 2016-06-22 12:12:44 -04:00
Umar Arshad
f61db0bcc6 Validator structured flow checks: back-edge, constructs
Skip structured control flow chekcs for non-shader capability.

Fix infinite loop in dominator algorithm when there's an
unreachable block.
2016-06-22 11:51:19 -04:00
Lei Zhang
7cdf39c8f1 Ignore Vim swap files. 2016-06-21 17:27:27 -04:00
David Neto
1a18739650 Fix ExtInst parsing: no IdRef* at end
The operands following the extended instruction literal
number are determined by the extended instruction itself.
So drop the zero-or-more IdRef pattern at the end of OpExtInst.

It's arguable whether this should actually be a grammar fix.  I've
chosen to patch this in SPIRV-Tools instead of in the grammar file.

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

Also fix two test cases for OpenCL extended instructions.  These
errors of supplying too many operands are now detected.
2016-06-15 10:00:06 -04:00
David Neto
37e4600c3e Fix OpenCL pow and pown arguments
Spec fix appeared in SPIR-V 1.0 Rev 2:
https://www.khronos.org/registry/spir-v/specs/1.0/OpenCL.ExtendedInstructionSet.100.html#_changes_from_version_1_0_revision_1

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/143
2016-06-14 12:14:38 -04:00
David Neto
3ed641df39 In physical addressing, functions can return pointers
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/229
2016-06-14 11:00:39 -04:00
Lei Zhang
10dba91781 Use SPIR-V headers from the KhronosGroup/SPIRV-Headers repo. 2016-06-10 08:48:37 -04:00
David Neto
6fff41a6db std::function needs <functional>. Fixes Android build 2016-06-10 08:43:12 -04:00
David Neto
9ddd54d16d Avoid copy of work list argument: make it const ref 2016-06-10 06:41:38 -04:00
Umar Arshad
e3dcaf5610 Refactor depth first traversal to be more generic
Refactor the way the post order vector is created. This new method
will allow for the extraction of backedges and create the post order
vector in one pass.
2016-06-10 06:39:42 -04:00
Umar Arshad
11437165d6 Fix diagnostic message for layout errors 2016-06-09 15:51:39 -04:00
Umar Arshad
90a4252aae Split validate_types file into multiple classes
Creates separate files for the ValidationState, Function and
BasicBlock classes.
2016-06-08 14:40:33 -04:00
Umar Arshad
00b72c2995 Remove redundant in_block function from Function
Same test can be done through the get_current_block function
2016-06-06 10:27:40 -04:00
Dejan Mircevski
c5fe6d9dc9 Avoid accessing invalid iterator. 2016-06-03 21:46:19 -04:00
Umar Arshad
f9903c8d36 Additional CFG tests
* Empty function
* Single block loops
* Nested loops
* Nested selection
2016-06-03 15:29:44 -04:00
David Neto
87125a19c6 Fix CHANGES file version parsing. -dev is optional 2016-06-02 15:32:28 -04:00
Dejan Mircevski
812fb7d798 Make googletest regexes portable.
On Windows, test::MatchesRegex() doesn't support brackets.  On Linux, \d
doesn't work. :(
2016-06-02 13:13:04 -04:00
Umar Arshad
0b9fd50d31 Control Flow Graph Validation 2016-06-02 12:11:52 -04:00
Lei Zhang
2ea7449c9c Create a function for adding unittests in CMake.
Also remove unnecessary main() function for unittests.
2016-05-30 10:28:56 -04:00
Lei Zhang
6a1e1ac7b9 Travis CI: Use ctest to run all the tests. 2016-05-25 21:02:47 -04:00
Lei Zhang
c7551e1f07 Add Appveyor configuration for Windows build. 2016-05-17 09:48:48 -04:00
Dejan Mircevski
0d512bbef5 Test ABGR in both 1.0 and 1.1. 2016-05-12 22:06:28 -04:00
Dejan Mircevski
7fdf56cbdc Remove needless include dir for spirv-dis. 2016-05-11 15:21:10 -04:00
Dejan Mircevski
faad7fea3d Test ABGR image channel order.
Update include/spirv/spirv.h from SPIRV-Headers.
2016-05-11 15:14:21 -04:00
Dejan Mircevski
6520ba93ac Test OpModuleProcessed. 2016-05-11 12:40:59 -04:00
Dejan Mircevski
10f1020560 Remove done TODOs in OpNameTest.
Simplify the instantiation by using Values() instead of ValuesIn().

Run clang-format.
2016-05-11 10:34:27 -04:00
Dejan Mircevski
a7c1265c38 Test SpecId validation. 2016-05-11 10:01:06 -04:00
Dejan Mircevski
2703039b44 Add --target-env.
commit 7648187c34
Author: Dejan Mircevski <deki@google.com>
Date:   Thu Apr 21 15:44:07 2016 -0400

    Turn --vulkan into --target-env.
2016-05-11 09:48:52 -04:00
Dejan Mircevski
4376856b1a Add tests for MaxByteOffset. 2016-05-10 22:46:27 -04:00
Jamie Madill
dc4c2ba7dc Add PipeStorage tests. 2016-05-09 13:54:05 -04:00
Jamie Madill
34cb0035fd Fix several warnings exposed in MSVS 2015.
diagnostic.cpp:
- unreachable code

operand.cpp
- conversion between int and uint32_t
- unreachable code

hex_float.h:
- conversion from 'const int' to 'unsigned int'
- unreachable code

validate_id.cpp
- forcing value to bool 'true' or 'false'

validate_types.cpp:
- forcing value to bool 'true' or 'false'
2016-04-29 18:02:01 -04:00
Florian Ziesche
66fcb456c1 bitcast fixes
* ValidationState_t and idUsage now store the addressing model and memory model of the SPIR-V module (this is necessary for certain instructions that need different checks depending on if the logical or physical addressing model is used)
 * removed SpvOpPtrAccessChain and SpvOpInBoundsPtrAccessChain from spvOpcodeIsPointer again as these are disallowed in logical addressing mode and only allowed in physical addressing mode (which doesn't use/need spvOpcodeIsPointer in the first place)
 * added SpvOpImageTexelPointer and SpvOpCopyObject to spvOpcodeIsPointer
 * OpLoad/OpStore now only check if the used pointer operand originated from a valid pointer producing opcode in logical addressing mode (as per 2.16.1)
 * moved bitcast pointer tests to the kernel / physical addressing model part (+cleanup)
 * renamed spvOpcodeIsPointer to spvOpcodeReturnsLogicalPointer to clarify this function is only meant to be used with the logical addressing model
2016-04-29 14:55:05 -04:00
Dejan Mircevski
13877a3b0e Add v1.1 tests for OpLoopMerge. 2016-04-29 14:09:52 -04:00
Dejan Mircevski
3732d6cc21 Add v1.1 capabilities validation.
Refactor the ValidateCapability test fixture.

Explain the meaning of test parameters.  Factor out methods for
convenience and readability.  DRY v1.0 and v1.1 tests.
2016-04-29 13:40:01 -04:00
Dejan Mircevski
af701f8f6a Add basic Initializer/Finalizer tests. 2016-04-27 22:02:39 -04:00
Lei Zhang
ca1bf94c90 Use a single definition of ARRAY_SIZE to simplify code. 2016-04-27 17:05:24 -04:00
Dejan Mircevski
45d391b7b1 Add OpSizeOf tests. 2016-04-27 15:41:58 -04:00
Dejan Mircevski
da8222ee4e Refactor OpExecutionModeTest and apply it on v1.1.
Previously v1.1 testing was dead.
2016-04-26 13:03:28 -04:00
Dejan Mircevski
27d6008889 Refactor v1.1 tests and turn them on.
Previously, the "V11" text fixture was empty.
2016-04-26 12:16:00 -04:00
David Neto
9166854ac9 Add CHANGES file with high level software history
Add a high level version number for SPIRV-Tools, beginning
with v2016.0-dev.  The README describes the format of the
version number.

The high level version number is extracted from the CHANGES
file.  That works around:
 - stale-bait for when we don't add tags to the repository
 - our inability to add tags to the repository

Option --version causes spirv-as, spirv-dis, and spirv-val to
show the high level version number.

Add spvSoftwareVersionString to return the C-string for
the high level version number.

Add spvSoftwareVersionDetailsString() so that clients can get
more information if they want to.
Also allows us to clean up the uses in the tool executables files,
so now only one file includes build-version.inc.

Move the update-build-version logic to the only
CMakeLists file that needs it.

The update build version script takes a new argument
to name the output file.
2016-04-22 15:19:45 -04:00