Граф коммитов

138 Коммитов

Автор SHA1 Сообщение Дата
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
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
Ehsan Nasiri 6c899a52f9 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.
2016-11-08 17:48:30 -05:00
Lei Zhang 5edf054926 Add more Assemble(), Disassemble() and Validate() overloads. 2016-09-21 14:42:04 -04:00
Lei Zhang 620f05e679 Publish the C++ interface. 2016-09-21 14:41:47 -04:00
Umar Arshad bf467da9c9 Update validate interface to accept binary pointers 2016-09-19 16:43:28 -04:00
Lei Zhang 755f97f534 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.
2016-09-15 12:35:48 -04:00
David Neto 4e2ed04d6e 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.
2016-09-14 15:19:10 -04:00
David Neto 9fc8658ef3 Relicense SPIRV-Tools under Apache 2.0
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/383

Finalize v2016.4
2016-09-02 10:00:29 -04:00
David Neto c296701964 Add target envs for OpenCL, OpenGL
Covers: OpenCL 2.1, OpenCL 2.2
Covers: OpenGL 4.0, OpenGL 4.1, OpenGL 4.2, OpenGL 4.3, OpenGL 4.5.
The OpenGL environments assume the use of GL_ARB_gl_spirv, of course.
2016-08-05 18:19:30 -04:00
David Neto 0bdcc23f7e Disassembling: map IDs to friendly names.
Add a FriendlyNameMapper to deduce friendly names for IDs based on
OpName, type structure, etc.
2016-07-19 16:28:17 -04:00
Lei Zhang 200e897887 Add an option to spvBinaryToText() to ignore header output. 2016-06-27 15:25:24 -04:00
Lei Zhang 10dba91781 Use SPIR-V headers from the KhronosGroup/SPIRV-Headers repo. 2016-06-10 08:48:37 -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
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
Dejan Mircevski 7b33485f6e 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.
2016-04-19 16:34:12 -04:00
Dejan Mircevski cb3c49ef82 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().
2016-04-18 10:45:57 -04:00
Dejan Mircevski 8ba7c92a94 Remove revision from SPV_ENV_*.
Revisions proliferate quickly and we don't promise to retain extra
grammar copies for every historical one.
2016-04-11 15:31:00 -04:00
Dejan Mircevski 3fb2676d23 Fix validation of array length. 2016-04-04 15:55:05 -04:00
Lei Zhang 6fa3f8aad9 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.
2016-04-04 10:34:28 -04:00
Dejan Mircevski 3d27da4bc7 Add a target environment to spvContextCreate().
Run clang-format.
2016-03-31 12:16:51 -04:00
David Neto 6836e17f24 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@
2016-03-29 14:51:02 -04:00
Andrew Woloszyn 4c657bfa8f Make everything compile cleanly with -Wpedantic.
This makes SPIRV_WARN_EVERYTHING compile cleanly.
2016-03-21 10:01:13 -04:00
Dejan Mircevski c31a31942b Make libspirv.h more C friendly.
In C, `#include <stdbool.h>` so `bool` is recognized.

Add a `typedef` for `spv_context_t`.
2016-03-01 12:38:59 -05:00
Lei Zhang b6ccd0d891 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.
2016-02-23 16:19:33 -05:00
David Neto 4d2f2239bf 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
2016-02-17 16:01:39 -05:00
David Neto 5a70335bf1 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.
2016-02-17 14:49:44 -05:00
David Neto 2889a0c21c 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.
2016-02-16 16:47:04 -05:00
David Neto 0c0a07f0aa Don't promise particular values when float parsing fails.
This should address problems on Windows:
https://github.com/KhronosGroup/SPIRV-Tools/issues/104
2016-02-16 12:13:51 -05:00
David Neto c7a9a909a8 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.
2016-02-15 09:31:10 -05:00
David Neto 6bad02c320 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.
2016-02-12 16:01:42 -05:00
David Neto 000cad9cc6 Reject float literals with two leading signs
E.g. --1 should be rejected.
2016-02-11 14:11:16 -05:00
David Neto b5267569d1 Add spvOperandIsConcreteMask 2016-02-02 12:05:34 -05:00
Dejan Mircevski 0c8bdfe163 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.
2016-02-02 11:40:05 -05:00
Umar Arshad 61a627586b 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
2016-01-27 08:37:23 -05:00
David Neto c62f41e281 Add disassembler option to show byte offset
The option is disabled by default.

The offset is printed in hex, as a comment after each instruction.
2016-01-20 17:07:30 -05:00
Umar Arshad 1ddeb246eb Validation refactor
* Organize passes into seperate files
* Remove module layout logic from Cfg pass
* Remove module layout logic from Functions class
* Refactor ModuleLayoutPass for readability
* Adapt consistent naming of layout sections (Stage/Section -> Section)
2016-01-14 21:59:28 -05:00
Norbert Nopper 32197bdcd7 Fix, that spirv-tools did not build, as two casts are not present. 2016-01-13 10:29:18 -05:00
Andrew Woloszyn 7ffd8ffeb2 Minor fixes to remove warnings in VS2013.
Also fixes VS2015 build due to missing #include <iterator>
2016-01-11 16:22:34 -05:00
David Neto 5d30edb36d spvDiagnosticDestroy is safe to call on nullptr
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/62
2016-01-11 14:26:46 -05:00
Andrew Woloszyn 7a35473573 Made compilation with gcc and clang more strict.
Added additional compilation flags to gcc and clang builds.
Adds -Wall -Wextra -Wno-long-long -Wshadow -Wundef -Wconversion
-WNo-sign-conversion and -Wno-missing-field-initializers
where appropriate.

Does not add -Wundef to tests, because GTEST tests undefined
macros all over the place.
2016-01-11 10:54:20 -05:00
Andrew Woloszyn 43401d2ed0 Support 16-bit float in assembler and disassembler
This adds half-precision constants to spirv-tools.
16-bit floats are always disassembled into hex-float format,
but can be assembled from floating point or hex-float inputs.
2016-01-08 10:48:39 -05:00
Dejan Mircevski b6fe02fc39 Extend copyright to 2016. 2016-01-07 13:44:22 -05:00
David Neto ae7d707fdb Fix shadowing warnings reported by GCC 2016-01-06 17:36:33 -05:00
David Neto ba73a7cee5 Fix conversion warnings reported by GCC. 2016-01-06 17:36:33 -05:00
David Neto f80b51fa9b Fix var shadowing and width mismatches in hex_float.h 2016-01-06 13:11:42 -05:00
David Neto d0de196439 operator<< on FloatProxy preserves float and fill
Fixes formatting of disassembler output after printing
a hex float, e.g. for a NaN or subnormal.
2016-01-05 12:49:55 -05:00
Umar Arshad a3d0d3c719 Initial logical layout validation
* Validates module level instructions for logical layout
  conformance
* Does not validate:
  1. Function logical layout
  2. Minor cases with OpVariable
  3. Missing MemoryModel instruction in module
  4. Order of function definition and function declaration
* 782 unit tests for logical layout

Addressed feedback
2015-12-17 15:58:09 -05:00
Umar Arshad 6d37e3c5f3 Refactor validation types into another file 2015-12-17 15:56:58 -05:00
Umar Arshad b9ad418c95 Fix warnings with Apple clang++
* Unused private member
* Overflow error when subtracting num_fraction_bits for HF16 and HF
2015-12-10 13:15:06 -05:00