platform/upstream/SPIRV-Tools.git
8 years agoAdd tests for SubgroupDispatch.
Dejan Mircevski [Thu, 21 Apr 2016 19:46:08 +0000 (15:46 -0400)]
Add tests for SubgroupDispatch.

Introduced in v1.1, SubgroupDispatch adds the following:
- two new execution modes
- one new capability
- two new opcodes

Extend ValidateBase methods to take a spv_target_env.  Replace the
context_ member with ScopedContext inside the said methods.  Give
ScopedContext wider visibility by moving it outside
TextToBinaryTestBase.

8 years agoMention 1.1 support in the README.
Dejan Mircevski [Tue, 19 Apr 2016 20:53:47 +0000 (16:53 -0400)]
Mention 1.1 support in the README.

8 years agoFirst tests for SPIR-V v1.1.
Dejan Mircevski [Tue, 19 Apr 2016 02:25:35 +0000 (22:25 -0400)]
First tests for SPIR-V v1.1.

Add test for named-barrier instructions and capability.

Add spv_target_env as an optional argument to CompileSuccessfully() and
CompileFailure().  Currently defaults to UNIVERSAL_1_0, though that
could change in the future.

Make spv_context a local variable in test methods instead of a
TextToBinaryTestBase member.  Introduce ScopedContext to make temp
contexts easier.

8 years agoFix wrong grammar .inc file dependency introduced by copy-paste.
Lei Zhang [Mon, 18 Apr 2016 20:48:33 +0000 (16:48 -0400)]
Fix wrong grammar .inc file dependency introduced by copy-paste.

8 years agoRework CMake rules for building grammar tables.
Lei Zhang [Fri, 15 Apr 2016 16:51:55 +0000 (12:51 -0400)]
Rework CMake rules for building grammar tables.

Use add_custom_command() to generate all .inc files and manage
dependency with set_source_files_properties().

8 years agoUpdate cmake files to support Android as a build target.
Derek Sollenberger [Mon, 18 Apr 2016 14:59:47 +0000 (10:59 -0400)]
Update cmake files to support Android as a build target.

This enables cross-compiling to Android using scripts like
cmake-android that update the system name to reflect the build
target.

8 years agoMake directories more safely.
David Neto [Mon, 18 Apr 2016 14:32:49 +0000 (10:32 -0400)]
Make directories more safely.

Avoid a race on check-for-dir vs. make-dir
when running the inc-file generation script concurrently.

8 years agoAdd SPIR-V 1.1 grammar.
Dejan Mircevski [Thu, 7 Apr 2016 18:41:34 +0000 (14:41 -0400)]
Add SPIR-V 1.1 grammar.

Switch to SPIR-V 1.1 as default.
Introduce SPV_ENV_UNIVERSAL_1_1.
Add "1_0" to the internal variable names.
Add spv_target_env to spv*GetTable().

8 years agoMark SPIR-V grammar files as 1.0.
Dejan Mircevski [Thu, 7 Apr 2016 18:09:48 +0000 (14:09 -0400)]
Mark SPIR-V grammar files as 1.0.

Factor the CMake generate_grammar_tables invocation into a function
parameterized on the version.

8 years agoGLSL grammar update.
Lei Zhang [Thu, 14 Apr 2016 22:35:14 +0000 (18:35 -0400)]
GLSL grammar update.

* Add names to operands.
* Fix capability requirements for UnpackDouble2x32.
* Fix operands list error for NClamp.

8 years agoMerge pull request #181 from antiagainst/readme
John Kessenich [Thu, 14 Apr 2016 19:09:09 +0000 (13:09 -0600)]
Merge pull request #181 from antiagainst/readme

Use footnotes for links in README.md.

8 years agoUse footnotes for links in README.md.
Lei Zhang [Thu, 14 Apr 2016 18:10:35 +0000 (14:10 -0400)]
Use footnotes for links in README.md.

8 years agoGrammar update: OpPhi now uses PairIdRefIdRef as the last operand.
Lei Zhang [Wed, 13 Apr 2016 15:50:27 +0000 (11:50 -0400)]
Grammar update: OpPhi now uses PairIdRefIdRef as the last operand.

8 years agoUpdate the core grammar.
Lei Zhang [Tue, 12 Apr 2016 18:51:50 +0000 (14:51 -0400)]
Update the core grammar.

* IdType is renamed to IdResultType.
* version is splitted into major_version and minor_version.
* Seperate Scope and IdScope operand kinds. Same for MemorySemantics.

8 years agoMake paths to grammar output files
David Neto [Tue, 12 Apr 2016 20:09:13 +0000 (16:09 -0400)]
Make paths to grammar output files

The directory for a grammar output file will be created if
it doesn't already exist.

This is required to make the Android.mk build work.

8 years agoRemove revision from SPV_ENV_*.
Dejan Mircevski [Mon, 11 Apr 2016 19:31:00 +0000 (15:31 -0400)]
Remove revision from SPV_ENV_*.

Revisions proliferate quickly and we don't promise to retain extra
grammar copies for every historical one.

8 years agoAllow to only build certain grammar tables.
Lei Zhang [Fri, 8 Apr 2016 14:31:51 +0000 (10:31 -0400)]
Allow to only build certain grammar tables.

8 years agoRemove the outdated patch file.
Lei Zhang [Thu, 7 Apr 2016 19:09:31 +0000 (15:09 -0400)]
Remove the outdated patch file.

Now we use the JSON grammar and the generate_grammar_tables.py
script to maintain various info tables. That patch file will not
be needed anymore.

8 years agoFix MSVC error C2797.
Dejan Mircevski [Mon, 4 Apr 2016 20:05:31 +0000 (16:05 -0400)]
Fix MSVC error C2797.

8 years agoUse JSON grammar files to generate extended instruction sets.
Lei Zhang [Mon, 4 Apr 2016 18:30:56 +0000 (14:30 -0400)]
Use JSON grammar files to generate extended instruction sets.

8 years agoRname grammar.json to spirv.core.grammar.json and add version info.
Lei Zhang [Mon, 4 Apr 2016 18:03:35 +0000 (14:03 -0400)]
Rname grammar.json to spirv.core.grammar.json and add version info.

8 years agoFix validation of array length.
Dejan Mircevski [Mon, 4 Apr 2016 19:55:05 +0000 (15:55 -0400)]
Fix validation of array length.

8 years agoRemove dependency on SPIR-V headers in libspirv.h.
Lei Zhang [Thu, 31 Mar 2016 21:26:31 +0000 (17:26 -0400)]
Remove dependency on SPIR-V headers in libspirv.h.

For fulfilling this purpose, the |opcode| field in the
|spv_parsed_instruction_t| struct is changed to of type uint16_t.

Also add functions to query the information of a given SPIR-V
target environment.

8 years agoEnable linking against libSPIRV-Tools from linux shared libraries
Chris Forbes [Sun, 3 Apr 2016 22:21:35 +0000 (10:21 +1200)]
Enable linking against libSPIRV-Tools from linux shared libraries

Required for linking against libSPIRV-Tools from LVL's
libVkLayer_core_validation.so.

Signed-off-by: Chris Forbes <chrisforbes@google.com>
8 years agoFix spelling mistakes
Eric Engestrom [Sat, 2 Apr 2016 21:54:59 +0000 (22:54 +0100)]
Fix spelling mistakes

8 years agoUse the JSON grammar file to generate various info tables.
Lei Zhang [Mon, 21 Mar 2016 20:36:14 +0000 (16:36 -0400)]
Use the JSON grammar file to generate various info tables.

This patch uses a Python script to parse the JSON grammar file to
generate the opcode table and operand kind tables.

Now we don't need to do the post-processing (from OperandClass
to spv_operand_type_t) and copying of the opcode info table is
not required anymore!

8 years agoHandle CRLF in assembly text.
Dejan Mircevski [Fri, 1 Apr 2016 04:47:02 +0000 (00:47 -0400)]
Handle CRLF in assembly text.

8 years agoAdd a target environment to spvContextCreate().
Dejan Mircevski [Thu, 31 Mar 2016 16:16:51 +0000 (12:16 -0400)]
Add a target environment to spvContextCreate().

Run clang-format.

8 years agoOpExecutionMode only takes a single ExecutionMode
David Neto [Tue, 29 Mar 2016 18:49:05 +0000 (14:49 -0400)]
OpExecutionMode only takes a single ExecutionMode

Previously, the grammar allowed many execution modes for a single
OpExecutionMode instruction.

Removes the variable- and optional- execution mode operand type
enum values.

Issue found by antiagainst@

8 years agoCapability fix: ImageReadWrite & ImageMipmap require ImageBasic.
Lei Zhang [Tue, 29 Mar 2016 13:47:23 +0000 (09:47 -0400)]
Capability fix: ImageReadWrite & ImageMipmap require ImageBasic.

8 years agoMake everything compile cleanly with -Wpedantic.
Andrew Woloszyn [Fri, 18 Mar 2016 18:13:16 +0000 (14:13 -0400)]
Make everything compile cleanly with -Wpedantic.

This makes SPIRV_WARN_EVERYTHING compile cleanly.

8 years agoSupport both -h, --help on spirv-as, spirv-val
David Neto [Thu, 17 Mar 2016 18:04:32 +0000 (14:04 -0400)]
Support both -h, --help on spirv-as, spirv-val

The spirv-dis command already supports both.

8 years agoTravis CI: update test binary location and return correct status.
Lei Zhang [Thu, 17 Mar 2016 19:20:22 +0000 (15:20 -0400)]
Travis CI: update test binary location and return correct status.

8 years agoSplit CMakeLists.txt into smaller ones.
Lei Zhang [Thu, 17 Mar 2016 02:43:31 +0000 (22:43 -0400)]
Split CMakeLists.txt into smaller ones.

8 years agoTravis CI: add configuration for testing on Mac OS X.
Lei Zhang [Wed, 16 Mar 2016 18:05:37 +0000 (14:05 -0400)]
Travis CI: add configuration for testing on Mac OS X.

8 years agoSupport Linux-to-Windows cross comiple via MinGW
David Neto [Mon, 29 Feb 2016 06:01:04 +0000 (01:01 -0500)]
Support Linux-to-Windows cross comiple via MinGW

For MinGW compile, statically link the C++ runtime

Change-Id: Ic58d1e47a814a265fd91edd7082e938ffc87f0c9

8 years agoChange the interface for getWord().
Lei Zhang [Tue, 15 Mar 2016 20:52:40 +0000 (16:52 -0400)]
Change the interface for getWord().

* It's redundant to provide two mutable spv_position to getWord().
* getWord() should take string pointer by the style guide.

8 years agoTravis CI: use Ubuntu 14.04 (Trusty) as the Linux environment.
Lei Zhang [Wed, 16 Mar 2016 18:54:47 +0000 (14:54 -0400)]
Travis CI: use Ubuntu 14.04 (Trusty) as the Linux environment.

8 years agoRemove AssemblyContext::getWord().
Dejan Mircevski [Tue, 15 Mar 2016 19:16:40 +0000 (15:16 -0400)]
Remove AssemblyContext::getWord().

Fixes #152.

8 years agoAdd patchlevel to CMake requirement
Daniel Robertson [Mon, 14 Mar 2016 12:41:32 +0000 (08:41 -0400)]
Add patchlevel to CMake requirement

8 years agoReturn str in describe() as said by the blurb.
Lei Zhang [Fri, 11 Mar 2016 20:24:41 +0000 (15:24 -0500)]
Return str in describe() as said by the blurb.

8 years agoFix the corner case in version generation script.
Lei Zhang [Fri, 11 Mar 2016 20:03:04 +0000 (15:03 -0500)]
Fix the corner case in version generation script.

When the given directory is not inside the SPIRV-Tools project,
describe() returns a str instance instead of bytes instance
in Python3, which will case problem when calling decode() on it.

8 years agoFixed float->int16 conversion warnings in VS2013.
Andrew Woloszyn [Mon, 7 Mar 2016 20:55:44 +0000 (15:55 -0500)]
Fixed float->int16 conversion warnings in VS2013.

8 years agoAdd comments to explain why calling decode().
Lei Zhang [Mon, 7 Mar 2016 18:44:09 +0000 (13:44 -0500)]
Add comments to explain why calling decode().

8 years agoRun pyformat with -s 4 --force_quote_type=single.
Lei Zhang [Sun, 6 Mar 2016 18:00:58 +0000 (13:00 -0500)]
Run pyformat with -s 4 --force_quote_type=single.

8 years ago Imporve compatibility with Python3.
Lei Zhang [Sun, 6 Mar 2016 16:44:21 +0000 (11:44 -0500)]
 Imporve compatibility with Python3.

 * Use print_function from __future__ to tackle the print syntax
   change.
 * In Python3 str and bytes are no longer the same thing. Need
   proper decode.

8 years agoDon't check kernel entry-point signatures.
Florian Ziesche [Tue, 1 Mar 2016 18:56:14 +0000 (19:56 +0100)]
Don't check kernel entry-point signatures.

Recognize SpvOpInBoundsPtrAccessChain and SpvOpPtrAccessChain as opcodes
returning a pointer.

 * spvOpcodeIsPointer: recognize SpvOpInBoundsPtrAccessChain and SpvOpPtrAccessChain as opcodes returning a pointer

 * isValid<SpvOpEntryPoint>: don't check kernel function signatures (these don't have to be 'void main(void)')

 * added tests for kernel OpEntryPoint, OpInBoundsPtrAccessChain and OpPtrAccessChain, as well as facilities to actually test kernel/OpenCL SPIR-V

 * fixed pow and pown specification (both should take 2 parameters), spec bug reported at https://www.khronos.org/bugzilla/show_bug.cgi?id=1469

 * use ASSERT_TRUE instead of ASSERT_EQ

 * added pow and pown test (pow(val, 2.0f) and pown(val, 3))

Revert " * fixed pow and pown specification (both should take 2 parameters), spec bug reported at https://www.khronos.org/bugzilla/show_bug.cgi?id=1469"

This reverts commit c3d5a87e73334b25aa4278964eea6d1c7625cd81.

Revert " * added pow and pown test (pow(val, 2.0f) and pown(val, 3))"

This reverts commit 7624aec720a51dc212704dc92eff6ae3634d2d6c.

8 years agoMake libspirv.h more C friendly.
Dejan Mircevski [Tue, 1 Mar 2016 15:17:18 +0000 (10:17 -0500)]
Make libspirv.h more C friendly.

In C, `#include <stdbool.h>` so `bool` is recognized.

Add a `typedef` for `spv_context_t`.

8 years agoRemove stale code.
Lei Zhang [Fri, 26 Feb 2016 20:38:42 +0000 (15:38 -0500)]
Remove stale code.

8 years agoFix issues reported by cppcheck.
Lei Zhang [Thu, 25 Feb 2016 21:11:16 +0000 (16:11 -0500)]
Fix issues reported by cppcheck.

Remove code not being used, add explicit to constructors, and
add missing fields in constructors.

8 years agoAdded missing <cstdint> in bitutils.
Andrew Woloszyn [Wed, 24 Feb 2016 20:26:05 +0000 (15:26 -0500)]
Added missing <cstdint> in bitutils.

This was breaking MSVC2013.

8 years agoIf no tag in the repo, then show the commit hash
David Neto [Wed, 24 Feb 2016 17:41:29 +0000 (12:41 -0500)]
If no tag in the repo, then show the commit hash

8 years agoActually find the python executable before use.
Andrew Woloszyn [Wed, 24 Feb 2016 15:11:07 +0000 (10:11 -0500)]
Actually find the python executable before use.

Also change PYTHON_EXE to PYTHON_EXECUTABLE to match what
the cmake documentation says.

8 years agoUse subprocess.Popen, hoping for Windows portability
David Neto [Tue, 23 Feb 2016 22:58:31 +0000 (17:58 -0500)]
Use subprocess.Popen, hoping for Windows portability

Replaces use of subprocess.check_output

8 years agoRemove spv_validate_options_t and change tests accrodingly.
Lei Zhang [Mon, 22 Feb 2016 20:25:50 +0000 (15:25 -0500)]
Remove spv_validate_options_t and change tests accrodingly.

Users always want to run all the checks. The spv_validate_options_t
mechanism, which provides little benefits to users, complicates the
internal implementation and also makes the tests exercise different
paths as users do.

Right now the tests are more like integration tests instead of
unit tests, which should be our next refactoring aim.

8 years agoImplement --version for spirv-tools
qining [Mon, 22 Feb 2016 21:07:19 +0000 (16:07 -0500)]
Implement --version for spirv-tools

'spirv-as --version', 'spirv-dis --version' and 'spirv-val --version'
will display version information.

8 years agogetWord() should not go beyond the end of the source text.
Lei Zhang [Mon, 22 Feb 2016 22:17:25 +0000 (17:17 -0500)]
getWord() should not go beyond the end of the source text.

This addresses Bug #126 where EOL is missing at the end of
source file.

8 years agospirv-val help says it's a work in progress.
David Neto [Mon, 22 Feb 2016 21:43:53 +0000 (16:43 -0500)]
spirv-val help says it's a work in progress.

8 years agoAvoid closing stdin and stdout.
Lei Zhang [Fri, 19 Feb 2016 15:15:17 +0000 (10:15 -0500)]
Avoid closing stdin and stdout.

8 years agoFix command line option errors in val.
Lei Zhang [Thu, 18 Feb 2016 23:04:11 +0000 (18:04 -0500)]
Fix command line option errors in val.

* There is no -capability.
* -rules is missing.
* -id by default is turned off.
* Add -all.

8 years agoSupport outputting to stdout in the as tool.
Lei Zhang [Thu, 18 Feb 2016 22:43:23 +0000 (17:43 -0500)]
Support outputting to stdout in the as tool.

8 years agoRemove unnecessary null pointer checks
Eric Engestrom [Thu, 18 Feb 2016 23:41:16 +0000 (23:41 +0000)]
Remove unnecessary null pointer checks

Fixes #110

8 years agoDocument SPIR-V binary and assembly file naming convention.
Lei Zhang [Thu, 18 Feb 2016 20:51:04 +0000 (15:51 -0500)]
Document SPIR-V binary and assembly file naming convention.

8 years agoUse unordered_map to store defs in UseDefTracker for fast lookup.
Lei Zhang [Thu, 18 Feb 2016 19:38:12 +0000 (14:38 -0500)]
Use unordered_map to store defs in UseDefTracker for fast lookup.

8 years agoSupport using stdin to supply input in the val tool.
Lei Zhang [Thu, 18 Feb 2016 18:40:56 +0000 (13:40 -0500)]
Support using stdin to supply input in the val tool.

This allows getting output from other utilities using pipe.

8 years agoSupport using stdin to supply input in the as tool.
Lei Zhang [Thu, 18 Feb 2016 17:21:10 +0000 (12:21 -0500)]
Support using stdin to supply input in the as tool.

This allows getting output from other utilities using pipe.

8 years agoReject unknown long-named command line options in dis.
Lei Zhang [Thu, 18 Feb 2016 15:50:42 +0000 (10:50 -0500)]
Reject unknown long-named command line options in dis.

8 years agoFix the source organization section in README.md
David Neto [Thu, 18 Feb 2016 03:27:46 +0000 (22:27 -0500)]
Fix the source organization section in README.md

It now reflects the new header file organization.
It also tells API clients what to add to the search
include path.

8 years agoSPIR-V Tools fully supports SPIR-V 1.0 Rev3
David Neto [Tue, 16 Feb 2016 17:02:05 +0000 (12:02 -0500)]
SPIR-V Tools fully supports SPIR-V 1.0 Rev3

- Update version numbers in libspirv.h.
  Add a test for the relevant macros.
- Update the README

8 years agoAdd MultiViewport capability, new in 1.0.3
David Neto [Wed, 17 Feb 2016 17:12:45 +0000 (12:12 -0500)]
Add MultiViewport capability, new in 1.0.3

Fix typos in previous tests with MultiViewport.

8 years agoRearrange headers
David Neto [Wed, 17 Feb 2016 19:44:00 +0000 (14:44 -0500)]
Rearrange headers

Now we have public headers arranged as follows:
$SPIRV_TOOLS_ROOT/include/spirv-tools/libspirv.h
$SPIRV_TOOLS_ROOT/include/spirv/spirv.h
$SPIRV_TOOLS_ROOT/include/spirv/GLSL.std.450.h
$SPIRV_TOOLS_ROOT/include/spirv/OpenCL.std.h

A project should use -I$SPIRV_TOOLS_ROOT/include
and then #include "spirv-tools/libspirv.h"

The headers from the SPIR-V Registry can be accessed as "spirv/spirv."
for example.

The install target should also install the headers from the SPIR-V
Registry.  The libspirv.h header is broken otherwise.

The SPIRV-Tools library depends on the headers from the SPIR-V Registry.

The util/bitutils.h and util/hex_float.h are pulled into the internal
source tree.  Those are not part of the public API to SPIRV-Tools.

8 years agoSome GLSL extended instructions depend on capabilities.
David Neto [Wed, 17 Feb 2016 17:17:04 +0000 (12:17 -0500)]
Some GLSL extended instructions depend on capabilities.

8 years agoAdd GLSL instructions NMin, NMax, NClamp
David Neto [Wed, 17 Feb 2016 00:26:13 +0000 (19:26 -0500)]
Add GLSL instructions NMin, NMax, NClamp

These appear first in GLSL.std.450 in 1.0 Rev3

8 years agoTest OpImageSparseRead
David Neto [Mon, 15 Feb 2016 19:20:01 +0000 (14:20 -0500)]
Test OpImageSparseRead

Also tweak the image operands test with OpImageFetch so the input assembly
more closely matches the expected output.  But don't make it a round
trip test since we want to check the assembler's ability to read the
image operand mask with out-of-order mask names.

The OpImageSparseRead assembly test is also a round trip disassembler
test.

8 years agoFixed internal compiler error in gcc-4.9.
Andrew Woloszyn [Wed, 17 Feb 2016 18:00:23 +0000 (13:00 -0500)]
Fixed internal compiler error in gcc-4.9.

This showed up in mips and mips64 builds. A combination of templates
and the error reporting were causing gcc to crash. This splits up the
functionality in a way that now successfully compiles.

8 years agoRemove remaining float overflow value tests
David Neto [Wed, 17 Feb 2016 17:39:41 +0000 (12:39 -0500)]
Remove remaining float overflow value tests

Should fix tests on Windows.

8 years agoUse syntax tables for SPIR-V 1.0 Rev3
David Neto [Mon, 15 Feb 2016 18:50:00 +0000 (13:50 -0500)]
Use syntax tables for SPIR-V 1.0 Rev3

- The SPIR-V spec generator has changed how it represents optional
  operands.  Now it tracks a separate boolean flag indicating optionality.
  However, SPIRV-Tools still wants to represent both operand class
  and optionality in the same enums space (SPV_OPERAND_TYPE_*).
  So there's extra work in the patch.

- In the spec generator, OperandImage is now OperandImageOperands.
  This affects enum translation in opcode.cpp.

- In the spec generator, image operands are explicitly followed by
  Id, and VariableIds.  However, SPIRV-Tools uses the bits set
  in the image operand bitmask to control the number and meaning
  of the Ids that follow.  So in writing the opcode.inc syntax
  table, drop all operands after OperandImageOperands.

- Some enums are now more explicitly represented in the generated
  opcode.inc:
    - AccessQualifier (e.g. on OpTypeImage), in both required and
      optional flavours.
    - MemoryAccess (e.g. on loads and stores)

- Add SPV_OPERAND_TYPE_OPTIONAL_ACCESS_QUALIFIER

- Add tests for the optional AccessQualifier operand on OpTypeImage.

- Update the AccessQualifier test for OpTypeImage so it's a round
  trip test through the disassembler as well.

8 years agoUpdate capabilities for 1.0 Rev3
David Neto [Sun, 14 Feb 2016 18:55:50 +0000 (13:55 -0500)]
Update capabilities for 1.0 Rev3

8 years agoDon't promise particular values when float parsing fails.
David Neto [Tue, 16 Feb 2016 17:13:51 +0000 (12:13 -0500)]
Don't promise particular values when float parsing fails.

This should address problems on Windows:
https://github.com/KhronosGroup/SPIRV-Tools/issues/104

8 years agoConfigure gmock locally only if not already configured.
David Neto [Mon, 15 Feb 2016 14:36:20 +0000 (09:36 -0500)]
Configure gmock locally only if not already configured.

Allows an enclosing project to have already configured gmock, even
if the developer has placed the googletest sources under this
project's external/googletest directory.

Describe how to enable the tests in the two essential scenarios:
where SPIR-V Tools is standalone, or where SPIR-V Tools is configured
as a part of a larger project.

8 years agoUse SPIR-V headers for 1.0 Rev3
David Neto [Sun, 14 Feb 2016 18:42:17 +0000 (13:42 -0500)]
Use SPIR-V headers for 1.0 Rev3

Refresh from the SPIR-V registry.

8 years agoParse overflow for fp16 like for 32- and 64-bit
David Neto [Sat, 6 Feb 2016 18:48:05 +0000 (13:48 -0500)]
Parse overflow for fp16  like for 32- and 64-bit

In that case, set the stream fail bit, and set the maximum normal
value or lowest normal value, depending on the sign of the original
value.

8 years agoFloat literal parsing fixes
David Neto [Sat, 6 Feb 2016 18:48:05 +0000 (13:48 -0500)]
Float literal parsing fixes

- For 32- and 64-bit floats, overflow is a parse error

  This works around a difference between Xcode's istringstream
  and other platforms.  Xcode's runtime library will happlily
  "round up" overflow values to infinity.  We want to make it fail.

- When parsing a float fails due to bad syntax, follow C++11
  behaviour for operator>> and set the value to zero.

- When parsing a 32-bit or 64-bit float overflows, follow C++11
  behaviour for operator>> and set the value to the nearest
  normal value: either max or lowest finite value for the type.

- Add FloatProxy<T>::max() and ::lowest()

- Make 16-bit overflow behaviour more consistent: we always get a
  16-bit infinity of the right sign, whether the original string
  is a normal value for 32-bit or an overflow value for 32-bit.
  That matches our earlier intent.
  Added TODO's to make 16-bit overflow always an error, just like
  for 32-bit and 64-bit.

- Simplify normal parsing of Float16 values by delegating to
  normal parsing of 32-bit floats.

8 years agoReject float literals with two leading signs
David Neto [Wed, 10 Feb 2016 16:46:05 +0000 (11:46 -0500)]
Reject float literals with two leading signs

E.g. --1 should be rejected.

8 years agoMore parsing tests for literals with leading minus
David Neto [Mon, 8 Feb 2016 19:33:41 +0000 (14:33 -0500)]
More parsing tests for literals with leading minus

Also checks some hex literal cases.

This addresses part of
https://github.com/KhronosGroup/SPIRV-Tools/issues/45
by removing the parseNumber case for "-0" on unsigned
integers.  We don't care about that platform difference
at the level of std::istringstream, since we reject it
at a higher parsing level.

8 years agoMake IsTypeNullable a transitive check.
Dejan Mircevski [Wed, 3 Feb 2016 22:16:27 +0000 (17:16 -0500)]
Make IsTypeNullable a transitive check.

8 years agoEliminate parameter-order check from ID-validation.
Dejan Mircevski [Wed, 3 Feb 2016 17:34:52 +0000 (12:34 -0500)]
Eliminate parameter-order check from ID-validation.

8 years agoAllow Op[No]Line between OpFunctionParameters.
Dejan Mircevski [Wed, 3 Feb 2016 15:26:59 +0000 (10:26 -0500)]
Allow Op[No]Line between OpFunctionParameters.

Also ensure we don't get thrown off by too many parameters.

8 years agoEnable ctest.
Dejan Mircevski [Tue, 2 Feb 2016 19:41:35 +0000 (14:41 -0500)]
Enable ctest.

8 years agoValidation of mask operand capabilities is more data driven
David Neto [Tue, 2 Feb 2016 17:12:48 +0000 (12:12 -0500)]
Validation of mask operand capabilities is more data driven

Use spvOperandIsConcreteMask to determine if an operand is
a bitmask.  Check its individual bits in a generic way.

8 years agoAdd spvOperandIsConcreteMask
David Neto [Tue, 2 Feb 2016 17:05:34 +0000 (12:05 -0500)]
Add spvOperandIsConcreteMask

8 years agoUse AssemblyGrammar for capability validation.
Dejan Mircevski [Sun, 31 Jan 2016 04:32:09 +0000 (23:32 -0500)]
Use AssemblyGrammar for capability validation.

Also:
- ForEach() for spv_capability_mask_t.
- Add capability min/max constants.
- Move max definition from validate_types.cpp to spirv_definition.h.

8 years agoForbid Generic variables.
Dejan Mircevski [Fri, 29 Jan 2016 21:49:40 +0000 (16:49 -0500)]
Forbid Generic variables.

8 years agoFix validator mem overflow when tracking capabilities
qining [Fri, 29 Jan 2016 17:09:34 +0000 (12:09 -0500)]
Fix validator mem overflow when tracking capabilities

8 years agoFix in-function storage class validation.
Dejan Mircevski [Fri, 29 Jan 2016 03:20:28 +0000 (22:20 -0500)]
Fix in-function storage class validation.

Move tests into a fixture that properly turns on the relevant passes.

8 years agoInitialize vector<string>s on first use, not statically.
Dejan Mircevski [Thu, 28 Jan 2016 18:18:00 +0000 (13:18 -0500)]
Initialize vector<string>s on first use, not statically.

8 years agoFix validation of return value.
Dejan Mircevski [Fri, 22 Jan 2016 21:52:40 +0000 (16:52 -0500)]
Fix validation of return value.

8 years agoRemove spvOpcodeIsObject().
Dejan Mircevski [Fri, 22 Jan 2016 19:27:00 +0000 (14:27 -0500)]
Remove spvOpcodeIsObject().

Also
- Add type_id to spv_id_info_t.
- Use spv_id_info_t::type_id instead of words[1].
  Triggered some asserts on tests, where the code incorrectly assumed
  words[1] had a type.  Remove the asserts and handle gracefully.
- Add tests for OpStore of a label, a void, and a function.

8 years agoInitial capability implementation and unit tests
Umar Arshad [Sat, 23 Jan 2016 19:14:32 +0000 (14:14 -0500)]
Initial capability implementation and unit tests

* Register capabilility and checks
* Add validate storage class capabilities checks and tests
* Instruction pass refactor
  - More generic form of capability checking by checking operands
    instead of instructions
* Execution Model capabilities checks
* Decorate BuiltIn capability checks
* Addressing Model capability checks
* Memory Model capability checks
* Execution Mode capability checks
* Dim capability checks
* SamplerAddressingMode capability checks

8 years agoQualify CMake function names with "spvtools" to avoid conflictions.
Lei Zhang [Tue, 26 Jan 2016 23:04:55 +0000 (18:04 -0500)]
Qualify CMake function names with "spvtools" to avoid conflictions.

If a third-party project defines a CMake function with the same
name, by importing that project's CMake configuration, we may end
up overwriting our own copy. Qualify all defined functions to
reduce that probability.