platform/upstream/SPIRV-Tools.git
7 years agoValidation code for control flow nesting depth.
Ehsan Nasiri [Wed, 21 Dec 2016 19:39:01 +0000 (14:39 -0500)]
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.

7 years agoSupport building under CYGWIN
David Neto [Mon, 19 Dec 2016 18:26:42 +0000 (13:26 -0500)]
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

7 years agoUpdate Travis notification emails
David Neto [Wed, 21 Dec 2016 15:31:29 +0000 (10:31 -0500)]
Update Travis notification emails

Remove deki, add ehsann

7 years agoGenerate spvasm.vim
David Neto [Fri, 16 Dec 2016 20:32:56 +0000 (15:32 -0500)]
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.

7 years agoStart v2016.7-dev
David Neto [Tue, 13 Dec 2016 16:49:50 +0000 (11:49 -0500)]
Start v2016.7-dev

7 years agoFinalize v2016.6
David Neto [Tue, 13 Dec 2016 16:49:09 +0000 (11:49 -0500)]
Finalize v2016.6

7 years agoGet vendor tool info from the SPIR-V registry file
David Neto [Fri, 9 Dec 2016 19:01:43 +0000 (14:01 -0500)]
Get vendor tool info from the SPIR-V registry file

Update old tests to use officially registered vendor names;
this affected "Codeplay".

7 years agoDocument the use of the GitHub Project feature
David Neto [Thu, 8 Dec 2016 23:21:17 +0000 (18:21 -0500)]
Document the use of the GitHub Project feature

7 years agoAdding validation for OpInBoundsAccessChain.
Ehsan Nasiri [Tue, 6 Dec 2016 16:59:49 +0000 (11:59 -0500)]
Adding validation for OpInBoundsAccessChain.

The validation for this instruction is similar to OpAccessChain.

Include a test for testing a struct with (valid) depth of 255.

7 years agoValidation for struct nesting depth.
Ehsan Nasiri [Sun, 4 Dec 2016 15:48:26 +0000 (10:48 -0500)]
Validation for struct nesting depth.

According to sectin 2.17 in SPIR-V Spec, the structure nesting depth may
not be larger than 255. This is interpreted as structures nested in
structures. The code does not look into arrays or follow pointers to see
if it reaches a structure downstream.

Use memoization to avoid exponential runtime.

7 years agoAn OpVariable initializer can be a module-scope variable
David Neto [Wed, 7 Dec 2016 15:33:27 +0000 (10:33 -0500)]
An OpVariable initializer can be a module-scope variable

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

7 years agoFixing bug in OpAccessChain validation code.
Ehsan Nasiri [Mon, 5 Dec 2016 20:11:51 +0000 (15:11 -0500)]
Fixing bug in OpAccessChain validation code.

The validation code for OpAccessChain was missing OpTypeRuntimeArray as
a possible type that can be indexed into.

This was caught by running the validator on VKCTS.

Also adding unit tests for it.

7 years agoAdd a test that exercises wrong usage of result id
Ehsan Nasiri [Mon, 5 Dec 2016 19:00:18 +0000 (14:00 -0500)]
Add a test that exercises wrong usage of result id

Result <id> resulting from an instruction within a function may not be
used outside that function.

7 years agoAdding validation code for OpAccessChain.
Ehsan Nasiri [Wed, 30 Nov 2016 18:29:12 +0000 (13:29 -0500)]
Adding validation code for OpAccessChain.

* Result Type must be an OpTypePointer. Its Type operand must be the
type reached by walking the Base’s type hierarchy down to the last
provided index in Indexes, and its Storage Class operand must be the
same as the Storage Class of Base.

* Base must be a pointer, pointing to the base of a composite object.

* Indexes walk the type hierarchy to the desired depth, potentially down
to scalar granularity. The first index in Indexes will select the
top-level member/element/component/element of the base composite. All
composite constituents use zero-based numbering, as described by their
OpType... instruction. The second index will apply similarly to that
result, and so on. Once any non-composite type is reached, there must
be no remaining (unused) indexes. Each of the Indexes must:
- be a scalar integer type,
- be an OpConstant when indexing into a structure.

* Check for the case where no indexes are passed to OpAccessChain.

Minor improvements based on code review.

7 years agoNo need to install cmake for new osx images.
Ehsan Nasiri [Thu, 1 Dec 2016 21:18:15 +0000 (16:18 -0500)]
No need to install cmake for new osx images.

It seems that the osx image has been updated and already includes ctest.
As a result, all jobs fail with this error:
Error: cmake-3.6.2 already installed

7 years agoValidate the number of global and local variables.
Ehsan Nasiri [Tue, 29 Nov 2016 20:50:34 +0000 (15:50 -0500)]
Validate the number of global and local variables.

According to the Universal Limits section of the SPIR-V Spec (2.17), the
number of global variables may not exceed 65,535 and the number of local
variables may not exceed 524,287.

Also added unit tests for each one.

7 years agoValidate the number of arguments in OpTypeFunction
Ehsan Nasiri [Mon, 28 Nov 2016 18:04:32 +0000 (13:04 -0500)]
Validate the number of arguments in OpTypeFunction

According to the SPIR-V spec (section 2.17: Universal Limits), the
OpTypeFunction instruction may not take more than 255 arguments for the
function. Also added unit tests for it.

7 years agoSay how the validator checks universal limits
David Neto [Wed, 30 Nov 2016 20:48:39 +0000 (15:48 -0500)]
Say how the validator checks universal limits

Indicate it's future work to allow parameterization of those
limits.

7 years agoAdding validation code for OpSwitch limits
Ehsan Nasiri [Fri, 25 Nov 2016 14:26:26 +0000 (09:26 -0500)]
Adding validation code for OpSwitch limits

The number of (literal, label) pairs passed to OpSwitch may not exceed
16,383. Added code to validate this and added unit tests for it.

Also fixed a typo in another validor error message.

7 years agoValidation for number of Struct members.
Ehsan Nasiri [Thu, 24 Nov 2016 20:37:22 +0000 (15:37 -0500)]
Validation for number of Struct members.

The number of members in a struct may not exceed 16,383.
Also Adding unit tests for Struct size limit check.

7 years agoChecks that result IDs are within the ID bound specified in the SPIR-V header
Ehsan Nasiri [Thu, 24 Nov 2016 20:37:22 +0000 (15:37 -0500)]
Checks that result IDs are within the ID bound specified in the SPIR-V header

This is described in Section 2.17 of the SPIR-V Spec.

* Updated existing unit test 'SemanticsIdIsAnIdNotALiteral' to pass by
manipulating the ID bound in its binary header.

* Fixed boundary check in the code.

* Added unit test to check the case that the largest ID is equal to the
ID bound.

7 years agoValidation for OpSampledImage instruction.
Ehsan Nasiri [Tue, 22 Nov 2016 23:06:55 +0000 (18:06 -0500)]
Validation for OpSampledImage instruction.

This change implements the validation for usages of OpSampledImage
instruction as described in the Data Rules section of the Universal
Validation Rules of the SPIR-V Spec.

7 years agoAdding validation for OpSpecConstantComposite.
Ehsan Nasiri [Wed, 16 Nov 2016 16:04:13 +0000 (11:04 -0500)]
Adding validation for OpSpecConstantComposite.

SpecConstantComposite may specialize to a vector, matrix, array, or
struct. In each case, the number of components and type of components
that are being specialized to must match the expected result type.

Removed use of macros in these tests.
Now using the spvValidateBase class. Using CompileSuccessfully(), and
ValidateInstructions() to compile to binary and run the validator. Also
using getDiagnosticString() to check the proper error message string.
All the heavy lifting is done in ValidateBase class.

7 years agoAdding validation code for OpTypeStruct.
Ehsan Nasiri [Thu, 10 Nov 2016 20:12:26 +0000 (15:12 -0500)]
Adding validation code for OpTypeStruct.

According to the Data Rules section of 2.16.1. Universal Validation
Rules of the SPIR-V Spec:

Forward reference operands in an OpTypeStruct
* must be later declared with OpTypePointer
* the type pointed to must be an OpTypeStruct
* had an earlier OpTypeForwardPointer forward reference to the same <id>

7 years agoSkip building example executable when asked
David Neto [Wed, 16 Nov 2016 15:52:31 +0000 (10:52 -0500)]
Skip building example executable when asked

7 years agoMake friendly number-based names for OpConstant
David Neto [Thu, 13 Oct 2016 20:22:04 +0000 (16:22 -0400)]
Make friendly number-based names for OpConstant

For example:
  %int_42 = OpConstant %int 42
  %int_n42 = OpConstant %int -42
  %float_3_14 = OpConstant %float 3.14

7 years agoExtract EmitNumericLiteral from disassembler
David Neto [Thu, 13 Oct 2016 19:17:11 +0000 (15:17 -0400)]
Extract EmitNumericLiteral from disassembler

Test with disassembly of numeric literals.

7 years agoAdding validation code for more data rules.
Ehsan Nasiri [Thu, 10 Nov 2016 20:12:26 +0000 (15:12 -0500)]
Adding validation code for more data rules.

These rules are under "Data Rules" in 2.16.1 (Universal Validation
Rules) part of the SPIR-V 1.1 Specification document:

* Scalar floating-point types can be parameterized only as 32 bit, plus
any additional sizes enabled by capabilities.

* Scalar integer types can be parameterized only as 32 bit, plus any
additional sizes enabled by capabilities.

* Vector types can only be parameterized with numerical types or the
OpTypeBool type.

* Matrix types can only be parameterized with floating-point types.

* Matrix types can only be parameterized as having only 2, 3, or 4
columns.

* Specialization constants (see Specialization) are limited to integers,
Booleans, floating-point numbers, and vectors of these.

7 years agoRename validation source files to comply with Google style guide.
Lei Zhang [Tue, 8 Nov 2016 18:26:09 +0000 (10:26 -0800)]
Rename validation source files to comply with Google style guide.

7 years agoRename validation tests to comply with Google style guide.
Lei Zhang [Tue, 8 Nov 2016 18:11:07 +0000 (10:11 -0800)]
Rename validation tests to comply with Google style guide.

7 years agoAdding validation for vector data rule.
Ehsan Nasiri [Fri, 4 Nov 2016 22:31:21 +0000 (18:31 -0400)]
Adding validation for vector data rule.

Number of components in a vector can be 2 or 3 or 4. If Vector16
capability is used, 8 and 16 components are also allowed.
Also added unit tests for vector data rule.

7 years agoRenaming test files to comply with Google style guide.
Lei Zhang [Thu, 22 Sep 2016 15:05:30 +0000 (11:05 -0400)]
Renaming test files to comply with Google style guide.

Also posfixing test files with `_test' to make it more clear.

7 years agoRemove source/instruction.cpp
David Neto [Fri, 28 Oct 2016 02:47:20 +0000 (22:47 -0400)]
Remove source/instruction.cpp

Avoids linker problems on Windows and OSX with duplicate object file
names.  Avoids collision with source/val/instruction.cpp

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

7 years agoenum_set: Fix bool performance warning.
Jamie Madill [Thu, 27 Oct 2016 20:09:06 +0000 (16:09 -0400)]
enum_set: Fix bool performance warning.

Implicit casts from int to bool cause a warning in visual studio.

7 years agoDo not gitignore source/opt/build_module.*
Christopher Gautier [Fri, 14 Oct 2016 10:45:27 +0000 (12:45 +0200)]
Do not gitignore source/opt/build_module.*

7 years agoTest SPV_KHR_shader_draw_parameters support
David Neto [Wed, 12 Oct 2016 14:47:28 +0000 (10:47 -0400)]
Test SPV_KHR_shader_draw_parameters support

In assembler, disassembler, parser.

7 years agoFix compilation errors when building inside Chromium
Corentin Wallez [Tue, 4 Oct 2016 21:47:19 +0000 (17:47 -0400)]
Fix compilation errors when building inside Chromium

Example of an error:
    spirv-tools/source/validate_cfg.cpp:516:45: error: chosen constructor is
    explicit in copy-initialization:
      _.current_function().RegisterBlockEnd({}, opcode);

7 years agoAdd begin() and end() for TypeManager.
Lei Zhang [Thu, 29 Sep 2016 16:00:35 +0000 (12:00 -0400)]
Add begin() and end() for TypeManager.

7 years agoRemove unnecessary #include
David Neto [Thu, 29 Sep 2016 20:43:47 +0000 (16:43 -0400)]
Remove unnecessary #include

This will make it easier to port these tests to different contexts.

7 years agoAdd examples to demo C++ library APIs.
Lei Zhang [Wed, 28 Sep 2016 14:50:43 +0000 (10:50 -0400)]
Add examples to demo C++ library APIs.

7 years agoAvoid appending EOL in StringifyMessage().
Lei Zhang [Fri, 23 Sep 2016 19:13:24 +0000 (15:13 -0400)]
Avoid appending EOL in StringifyMessage().

EOL should be appended when outputing to streams by the tool.

7 years agoFix operand class test coverage table.
Lei Zhang [Thu, 22 Sep 2016 15:28:48 +0000 (11:28 -0400)]
Fix operand class test coverage table.

* Fix a missing column.
* Convert line endings.

This will make the table beautiful and searchable on Github.

7 years agoClean up header dependency.
Lei Zhang [Wed, 21 Sep 2016 21:16:31 +0000 (17:16 -0400)]
Clean up header dependency.

7 years agoHandle parse failure for setting spec constants
David Neto [Thu, 22 Sep 2016 21:09:34 +0000 (17:09 -0400)]
Handle parse failure for setting spec constants

7 years agoFix forward reference issues with forword pointer
Umar Arshad [Thu, 22 Sep 2016 14:23:08 +0000 (10:23 -0400)]
Fix forward reference issues with forword pointer

* Allows OpTypeForwardPointer to reference IDs not yet declared in
  the module
* Allows OpTypeStruct to reference IDs not yet declared in
  the module

Possible Issue: OpTypeStruct should only allow forward references
if the ID is a pointer that is referenced by a forward pointer. Need
Type support in Validator which is currently a work in progress.

7 years agoCommand line option for set default value for spec constant
qining [Thu, 22 Sep 2016 15:50:12 +0000 (11:50 -0400)]
Command line option for set default value for spec constant

Format:
```
--set-spec-constant-default-value "<spec id A>:<default value A> <spec id
B>:<default value B> ..."
```

Example:
  shader: `test.vert`
```

layout(constant_id = 100) const int myint = 10;
layout(constant_id = 101) const int myuint = 100;
layout(constant_id = 200) const float myfloat = 1.25;
layout(constant_id = 201) const double mydouble = 2.34;

void main() {}
```
  command line:
```
spirv-opt --set-spec-const-default-value "100:12   101:200 200:1.2323
201:1.2345" test.vert -o output.spv
```
  output:
```
      ...
               OpDecorate %7 SpecId 100
               OpDecorate %8 SpecId 101
               OpDecorate %10 SpecId 200
               OpDecorate %12 SpecId 201
       %void = OpTypeVoid
          %3 = OpTypeFunction %void
        %int = OpTypeInt 32 1
          %7 = OpSpecConstant %int 12
          %8 = OpSpecConstant %int 200
      %float = OpTypeFloat 32
         %10 = OpSpecConstant %float 1.23232
     %double = OpTypeFloat 64
         %12 = OpSpecConstant %double 2.34232
      ...
```

7 years agoUse nullptr as the default message consumer to ignore all messages.
Lei Zhang [Wed, 21 Sep 2016 20:45:53 +0000 (16:45 -0400)]
Use nullptr as the default message consumer to ignore all messages.

There is no difference between the previous IgnoreMessage() function
and a null std::function, from functionality's perspective.
The user can set nullptr as the MessageConsumer, so need to guard
against nullptr before calling the consumer anyway. It's better
we use it internally so that it may expose problems by us instead
of the user.

7 years agoChange some asserts to normal errors in IrLoader.
Lei Zhang [Wed, 21 Sep 2016 14:53:15 +0000 (10:53 -0400)]
Change some asserts to normal errors in IrLoader.

7 years agoAdd two more utility functions for sending errors to consumer.
Lei Zhang [Wed, 21 Sep 2016 14:52:31 +0000 (10:52 -0400)]
Add two more utility functions for sending errors to consumer.

7 years agoChange parameter name from file to source in Log() and Logf().
Lei Zhang [Wed, 14 Sep 2016 16:09:52 +0000 (12:09 -0400)]
Change parameter name from file to source in Log() and Logf().

7 years agoAdd more Assemble(), Disassemble() and Validate() overloads.
Lei Zhang [Tue, 20 Sep 2016 22:03:37 +0000 (18:03 -0400)]
Add more Assemble(), Disassemble() and Validate() overloads.

7 years agoPublish the C++ interface.
Lei Zhang [Fri, 16 Sep 2016 20:12:04 +0000 (16:12 -0400)]
Publish the C++ interface.

7 years agoRename SpvTools to SpirvTools.
Lei Zhang [Fri, 16 Sep 2016 19:56:30 +0000 (15:56 -0400)]
Rename SpvTools to SpirvTools.

7 years agoUse C style names for MessageLevel.
Lei Zhang [Wed, 21 Sep 2016 16:44:37 +0000 (12:44 -0400)]
Use C style names for MessageLevel.

7 years agoChange to use enum instead of enum class for MessageLevel.
Lei Zhang [Wed, 21 Sep 2016 15:30:41 +0000 (11:30 -0400)]
Change to use enum instead of enum class for MessageLevel.

This allows us to create C interface with MessageLevel later.

7 years agoAdd a C++ interface to the optimization functionalities.
Lei Zhang [Mon, 12 Sep 2016 18:11:46 +0000 (14:11 -0400)]
Add a C++ interface to the optimization functionalities.

7 years agoAllow changing MessageConsumer in Pass & PassManager.
Lei Zhang [Tue, 20 Sep 2016 20:48:00 +0000 (16:48 -0400)]
Allow changing MessageConsumer in Pass & PassManager.

Default-constructed Pass/PassManager will have a MessageConsumer
which ignores all messages. SetMessageConsumer() should be called
to supply a meaningful MessageConsumer.

7 years agoChange BuildModule() to accept pointer-size pair for binary.
Lei Zhang [Tue, 20 Sep 2016 20:44:24 +0000 (16:44 -0400)]
Change BuildModule() to accept pointer-size pair for binary.

7 years agoChange interface of Pass::Process() to return possible failures.
Lei Zhang [Mon, 12 Sep 2016 16:39:44 +0000 (12:39 -0400)]
Change interface of Pass::Process() to return possible failures.

7 years agoProvide friendly names for shader ballot BuiltIns
David Neto [Mon, 19 Sep 2016 14:13:04 +0000 (10:13 -0400)]
Provide friendly names for shader ballot BuiltIns

7 years agoUpdate validate interface to accept binary pointers
Umar Arshad [Thu, 15 Sep 2016 21:32:44 +0000 (17:32 -0400)]
Update validate interface to accept binary pointers

7 years agoSet the default source name as "input".
Lei Zhang [Fri, 16 Sep 2016 19:43:41 +0000 (15:43 -0400)]
Set the default source name as "input".

7 years agoStart v2016.6-dev
David Neto [Fri, 16 Sep 2016 20:40:00 +0000 (16:40 -0400)]
Start v2016.6-dev

7 years agoFinalize v2016.5
David Neto [Fri, 16 Sep 2016 20:39:40 +0000 (16:39 -0400)]
Finalize v2016.5

7 years agoAdd basic support for SPV_KHR_shader_ballot
David Neto [Fri, 16 Sep 2016 18:40:02 +0000 (14:40 -0400)]
Add basic support for SPV_KHR_shader_ballot

Requires use of SPIRV-Headers that has support
for SPV_KHR_shader_ballot.

Adds assembler, disassembler, binary parser support.

Adds general support for allowing an operand to be
only enabled by a set of extensions.

TODO: Validator support for extension checking.

7 years agoPrepare the C++ interface for publication.
Lei Zhang [Fri, 9 Sep 2016 14:46:23 +0000 (10:46 -0400)]
Prepare the C++ interface for publication.

* Use PIMPL idiom in the C++ interface.
* Clean up interface for assembling and disassembling.
* Add validation into C++ interface.
* Add more tests for the C++ interface.

7 years agoMove functions for building modules outside of the C++ interface.
Lei Zhang [Fri, 9 Sep 2016 18:45:18 +0000 (14:45 -0400)]
Move functions for building modules outside of the C++ interface.

7 years agoLet SPIRV_ASSERT() exit the program if the assertion fails.
Lei Zhang [Fri, 16 Sep 2016 16:10:47 +0000 (12:10 -0400)]
Let SPIRV_ASSERT() exit the program if the assertion fails.

7 years agoAdd MessageConsumer to PassManager, Pass, and analysis interfaces.
Lei Zhang [Sat, 20 Aug 2016 03:17:44 +0000 (23:17 -0400)]
Add MessageConsumer to PassManager, Pass, and analysis interfaces.

Also convert some uses of assert() in optimization code to use
SPIRV_ASSERT(), SPIRV_UNIMPLEMENTED(), or SPIRV_UNREACHABLE()
accordingly.

7 years agoAdd utility macros for logging messages.
Lei Zhang [Thu, 8 Sep 2016 15:43:48 +0000 (11:43 -0400)]
Add utility macros for logging messages.

Add the following macros for logging purpose:
* SPIRV_ASSERT
* SPIRV_DEBUG
* SPIRV_UNIMPLEMENTED
* SPIRV_UNREACHABLE

The last two is always turned on, while the first two can only
be turned on in debug build.

7 years agoAdd a callback mechanism for communicating messages to callers.
Lei Zhang [Fri, 2 Sep 2016 22:06:18 +0000 (18:06 -0400)]
Add a callback mechanism for communicating messages to callers.

Every time an event happens in the library that the user should be
aware of, the callback will be invoked.

The existing diagnostic mechanism is hijacked internally by a
callback that creates an diagnostic object each time an event
happens.

7 years agoMake friendly names for built-in variables.
David Neto [Tue, 13 Sep 2016 16:38:42 +0000 (12:38 -0400)]
Make friendly names for built-in variables.

Handles only OpDecorate

Does not handle:
- decorations on struct members
- decoration via OpGroupDecorate

7 years agoUpdate CHANGES to say #414 is fixed
David Neto [Wed, 14 Sep 2016 19:22:47 +0000 (15:22 -0400)]
Update CHANGES to say #414 is fixed

7 years agoFix validator: OpUndef can be member of a constant composite
David Neto [Wed, 14 Sep 2016 15:57:20 +0000 (11:57 -0400)]
Fix validator: OpUndef can be member of a constant composite

This was enabled in SPIR-V 1.0 Rev 7

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

7 years agoClarify: Ok to pass null diagnostic to spvBinaryParse
David Neto [Wed, 14 Sep 2016 16:48:38 +0000 (12:48 -0400)]
Clarify: Ok to pass null diagnostic to spvBinaryParse

It's a valid use case: I might mostly trust my binaries and I don't
care to to collect detailed diagnostic feedback.

7 years agoFix validator SSA check: Phi can use its own value sometimes
David Neto [Wed, 14 Sep 2016 15:04:19 +0000 (11:04 -0400)]
Fix validator SSA check: Phi can use its own value sometimes

Defer removal of a Phi's result id from the undefined-forward-reference
set until after you've scanned the arguments.  The reordering is only
significant for Phi.

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

7 years agoBuild "spec id->default val str" mapping from string
qining [Fri, 9 Sep 2016 15:47:42 +0000 (11:47 -0400)]
Build "spec id->default val str" mapping from string

Add function `ParseDefaultValuesString()` to build the spec id->default
value string mapping required by `SetSpecConstantDefaultValuePass`.

7 years agoGuard against nullptr in number parsing utilities
qining [Tue, 13 Sep 2016 15:57:02 +0000 (11:57 -0400)]
Guard against nullptr in number parsing utilities

ParseNumber(): Returns false if the given string is a nullptr.
ParseAndEncodeXXXX(): Returns kInvalidText and populate error message:
  "The given text is a nullptr", if the givne string is a nullptr.

7 years agoSet default values for spec const decorated by SpecId
qining [Tue, 30 Aug 2016 18:57:56 +0000 (14:57 -0400)]
Set default values for spec const decorated by SpecId

The pass instance is constructed with a map from spec id (uint32_t) to
default values in string format. The default value strings will be
parsed to numbers according to the target spec constant type.

If the Spec Id decoration is found to be applied on multiple different
target ids, that decoration instruction (OpDecorate or OpGroupDecorate)
will be skipped. But other decoration instrucitons may still be
processed.

7 years agoUpdate CMake condition for Emacs load/save helper
David Neto [Mon, 12 Sep 2016 20:48:05 +0000 (16:48 -0400)]
Update CMake condition for Emacs load/save helper

Make SPIRV_TOOLS_INSTALL_EMACS_HELPERS a CMake option.  Otherwise
I get a variable-defined-but-not-used error.

7 years agoadd spirv-dis/spirv-as support for emacs when loading .spv binaries
steve-lunarg [Fri, 2 Sep 2016 20:04:02 +0000 (14:04 -0600)]
add spirv-dis/spirv-as support for emacs when loading .spv binaries

7 years agoAdd IsSigned() to opt::Analysis::Integer.
qining [Thu, 8 Sep 2016 22:00:12 +0000 (18:00 -0400)]
Add IsSigned() to opt::Analysis::Integer.

7 years agoPull out the number parsing logic
qining [Thu, 1 Sep 2016 18:27:04 +0000 (14:27 -0400)]
Pull out the number parsing logic

Pull out the number parsing logic from
AssemblyContext::binaryEncodeNumericLiteral() to utilities.

The new utility function: `ParseAndEncodeNumber()` now accepts:
  * number text to parse
  * number type
  * a emit function, which is a function which will be called with each
    parsed uint32 word.
  * a pointer to std::string to be overwritten with error messages.
    (pass nullptr if expect no error message)
and returns:
  * an enum result type to indicate the status

Type/Structs moved to utility:
  * template<typename T> class ClampToZeroIfUnsignedType

New type:
* enum EncodeNumberStatus: success or error code
* NumberType: hold the number type information for the number to be parsed.
 * several helper functions are also added for NumberType.

Functions moved to utility:
  * Helpers:
    * template<typename T> checkRangeAndIfHexThenSignExtend() -> CheckRangeAndIfHex....()
  * Interfaces:
    * template<typename T> parseNumber() -> ParseNumber()
    * binaryEncodeIntegerLiteral() -> ParseAndEncodeIntegerNumber()
    * binaryEncodeFloatingPointLiteral() -> ParseAndEncodeFloatingPointNumber()
    * binaryEncodeNumericLiteral() -> ParseAndEncodeNumber()

Tests added/moved to test/ParseNumber.cpp, including tests for:
* ParseNumber(): This is moved from TextToBinary.cpp to ParseNumber.cpp
* ParseAndEncodeIntegerNumber(): New added
* ParseAndEncodeFloatingPointNumber(): New added
* ParseAndEncodeNumber(): New added

Note that the error messages are kept almost the same as before, but
they may be inappropriate for an utility function. Those will be fixed
in another CL.

7 years agoMerge diagnostic tests and single them out in a separate binary.
Lei Zhang [Thu, 8 Sep 2016 21:26:53 +0000 (17:26 -0400)]
Merge diagnostic tests and single them out in a separate binary.

7 years agoCreate separate binaries for validation tests.
Lei Zhang [Wed, 7 Sep 2016 21:43:15 +0000 (17:43 -0400)]
Create separate binaries for validation tests.

7 years agoPrefix test binaries with `test_`, rename UnitSPIRV, update README.
Lei Zhang [Wed, 7 Sep 2016 21:26:18 +0000 (17:26 -0400)]
Prefix test binaries with `test_`, rename UnitSPIRV, update README.

7 years agoTravis CI: mark build as finished once a job failed.
Lei Zhang [Mon, 5 Sep 2016 20:17:33 +0000 (16:17 -0400)]
Travis CI: mark build as finished once a job failed.

7 years agoKill the spvCheck macro which is just alias to if-statement.
Lei Zhang [Mon, 5 Sep 2016 21:11:44 +0000 (17:11 -0400)]
Kill the spvCheck macro which is just alias to if-statement.

7 years agoUpdate README about the optimization library and tool.
Lei Zhang [Fri, 2 Sep 2016 14:15:47 +0000 (10:15 -0400)]
Update README about the optimization library and tool.

7 years agoSay contributors have to click through the CLA
David Neto [Fri, 2 Sep 2016 14:29:14 +0000 (10:29 -0400)]
Say contributors have to click through the CLA

7 years agoAdd test for presence of copyrights and license terms
David Neto [Fri, 2 Sep 2016 13:29:52 +0000 (09:29 -0400)]
Add test for presence of copyrights and license terms

7 years agoStart v2016.5-dev
David Neto [Thu, 1 Sep 2016 19:38:53 +0000 (15:38 -0400)]
Start v2016.5-dev

7 years agoRelicense SPIRV-Tools under Apache 2.0
David Neto [Thu, 1 Sep 2016 19:33:59 +0000 (15:33 -0400)]
Relicense SPIRV-Tools under Apache 2.0

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

Finalize v2016.4

7 years agoAdd check_copyright to check or update copyright.
David Neto [Thu, 1 Sep 2016 18:49:14 +0000 (14:49 -0400)]
Add check_copyright to check or update copyright.

It will also replace an MIT or Khronos free use license with
the Apache license notice.

7 years agoFix Google copyright lines
David Neto [Thu, 1 Sep 2016 17:04:00 +0000 (13:04 -0400)]
Fix Google copyright lines

7 years agoKill the spvCheckReturn macro.
Lei Zhang [Fri, 2 Sep 2016 13:51:44 +0000 (09:51 -0400)]
Kill the spvCheckReturn macro.

7 years agoKill diagnostic_helper & the wrapping DIAGNOSTIC macro.
Lei Zhang [Fri, 2 Sep 2016 13:49:56 +0000 (09:49 -0400)]
Kill diagnostic_helper & the wrapping DIAGNOSTIC macro.

7 years agoTests for preserving line debug insts even killing its affecting targets.
Lei Zhang [Wed, 31 Aug 2016 23:37:13 +0000 (19:37 -0400)]
Tests for preserving line debug insts even killing its affecting targets.

7 years agoUnify constants pass
qining [Wed, 17 Aug 2016 21:19:48 +0000 (17:19 -0400)]
Unify constants pass

De-duplicate constants and unifies the uses of constants for a SPIR-V
module. If two constants are defined exactly the same, only one of them
will be kept and all the uses of the removed constant will be redirected
to the kept one.

This pass handles normal constants (defined with
OpConstant{|True|False|Composite}), some spec constants (those defined
with OpSpecConstant{Op|Composite}) and null constants (defined with
OpConstantNull).

There are several cases not handled by this pass:

  1) If there are decorations for the result id of a constant defining
  instruction, that instruction will not be processed. This means the
  instruction won't be used to replace other instructions and other
  instructions won't be used to replace it either.

  2) This pass does not unify null constants (defined with
  OpConstantNull instruction) with their equivalent zero-valued normal
  constants (defined with OpConstant{|False|Composite} with zero as the
  operand values or component values).

7 years agoRefactor CapabilitySet into templated class EnumSet
David Neto [Wed, 31 Aug 2016 18:35:58 +0000 (14:35 -0400)]
Refactor CapabilitySet into templated class EnumSet