Commit Graph

45 Commits

Author SHA1 Message Date
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
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
0b9fd50d31 Control Flow Graph Validation 2016-06-02 12:11:52 -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
Eric Engestrom
c9b2285bfc Fix spelling mistakes 2016-04-02 22:54:59 +01:00
Lei Zhang
6032b98c53 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.
2016-03-16 15:46:15 -04:00
Lei Zhang
712bed0227 Fix issues reported by cppcheck.
Remove code not being used, add explicit to constructors, and
add missing fields in constructors.
2016-02-25 16:16:28 -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
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
1a3734d265 Avoid relative path in #include
Adds CMAKE_CURRENT_SOURCE_DIR to the include path for UnitSPIRV
2016-01-04 13:07:45 -05:00
David Neto
4c21571728 Rename endian.h to spirv_endian.h
If we later add a source/ as an -I include directory,
then avoid confusing other headers that want to include the
standard "endian.h" from /usr/include.

Also rename source/endian.cpp to source/spirv_endian.cpp
2016-01-04 10:47:27 -05:00
David Neto
590ff131ac PrintTo on WordVector should preserve the fill char 2015-12-01 18:25:03 -05:00
Dejan Mircevski
15aebef8a0 Merge PR #32.
Simplify binary parser tests using GoogleMock.
2015-11-30 18:06:33 -05:00
David Neto
750f205b63 Several unit tests for spvBinaryParse
Add a non-zero spv_result_t value SPV_REQUESTED_TERMINATION
which should be used to signal an ok result, but signals
early termination for a process, such as binary parsing.

Tests include:
 - correct contents sent to header and instruction callbacks
 - non-zero status from a callback should terminate parsing,
   but the parser should not generate its own diagnostic.

TODO: Check diagnostics generated by the parser itself.
2015-11-27 10:19:06 -05:00
David Neto
c9e0845c7f Aliasing through a union member is valid.
Take back my previous TODO.
2015-11-23 15:35:00 -05:00
Lei Zhang
8bd75d650e Clean up CMake configuration and address compiler warnings.
- Removed dead configuration in CMakeLists.txt.
- Used target_compile_options() instead of CMAKE_{C|CXX}_FLAGS.
- Turned on warnings on tests.
- Fixed various warnings for comparing signed with unsigned values.
- Removed dead code exposed by compiler warnings.
2015-11-18 16:32:41 -05:00
Lei Zhang
923f6c13fc Use quotation for libspirv.h and sort headers. 2015-11-12 09:43:01 -05:00
Lei Zhang
1a0334edee Run clang-format to enforce Google style globally.
Note that we are more strict than Google style for one aspect:
pointer/reference indicators are adjacent to their types, not
their variables.

find . -name "*.h" -exec clang-format -i {} \;
find . -name "*.cpp" -exec clang-format -i {} \;
2015-11-10 15:56:47 -05:00
Lei Zhang
b36e704a47 Use spirv.h instead of spirv.hpp.
This is a part of the effort to make libspirv.h C-compatible.
2015-11-02 13:52:20 -05:00
David Neto
9f79d789ec Inclusion guards follow Google C++ style
Follow the scheme in
http://google-styleguide.googlecode.com/svn/trunk/cppguide.html#The__define_Guard
except:
 - 'include/' is dropped from the guard token
 - 'source/' is dropped from the guard token
2015-11-02 13:52:15 -05:00
David Neto
db901b622e Move endian utilities to their own file. 2015-11-02 13:52:12 -05:00
David Neto
fcc7d58353 Move AssemblyGrammar into its own source files 2015-11-02 13:52:05 -05:00
David Neto
b6a43383e7 Use basic_string<char> for the UTF-8 test string
This is an attempt to fix the unit tests on DeveloperStudio 2013.
Currently, the size of the earth_africa string is reported as 2
on Windows.  But I think that may be 2 16-bit characters.
2015-11-02 13:51:57 -05:00
Andrew Woloszyn
f731cbf6c4 Added set_bits<> to bitutils.
This allows us to get a constant with the given bits set at
compile-time. This is needed for a future patch for HexFloat.
2015-11-02 13:51:51 -05:00
Andrew Woloszyn
4274f93065 Fixed UTF-8 encoding issues on windows.
Also cleaned up some warnings related to implicit size_t/uint64_t
conversions.
2015-10-26 12:55:33 -04:00
Andrew Woloszyn
537e77663d Added tracking to types and validated certain instructions.
We need to know how to generate correct SPIRV for cases like
OpConstant %int64 42 since the current parser will encode the 42 as a
32-bit value incorrectly.

This change is the first of a pair. This one tracks types, and makes
sure that OpConstant and OpSpecConstant are only ever called with
Integer or Float types, and OpSwitch is only called with integer
generating values.
2015-10-26 12:55:33 -04:00
David Neto
f6b865110c Accept long UTF-8 Literal Strings 2015-10-26 12:55:33 -04:00
David Neto
b5dc8fcd5d Support strings with up to 65535 chars, and null.
Move the definition of spv_instruction_t to an internal
header file, since it now depends on C++ and is not
used by the external interface.

Use a std::vector<uint32_t> in spv_instruction_t
instead of a fixed size array.
2015-10-26 12:55:33 -04:00
David Neto
3d2bf53294 Move AutoText and EnumCase into spvtest namespace
Also fix using declaration order.
Also put a few tests into the anonymous namespace.
2015-10-26 12:55:33 -04:00
David Neto
e3296f0945 Add TODO for fixing endianness testing.
Currently it uses a union, a write to one field, and read from
another of a different type.

Moves the endianness-determining macro close to the variable
it references.
2015-10-26 12:55:33 -04:00
David Neto
ff5dce48a1 Add assembler test for OpEnqueueKernel.
Adds a form of spvtest::MakeInstruction which takes two vectors
of operands.  That leads to simpler test code.
We can clean up some other test code, in another CL.
2015-10-26 12:55:33 -04:00
Andrew Woloszyn
71fc05587b Refactored dynamic and static state out of text processing.
This reduces the number of arguments required to be passed
to every single function. This is in preparation for adding
id tracking.
2015-10-26 12:55:33 -04:00
Lei Zhang
a66952d38c Remove executable file mode bits on source files. 2015-10-26 12:55:33 -04:00
David Neto
74af05f012 Cleanups for EnumCase
Make it a class, since it has non-trivial behaviour for converting
the enumerated value to a uint32_t value. (Comply with style guide.)

Merge EnumCaseWithOperands into EnumCase.
2015-10-26 12:55:33 -04:00
Andrew Woloszyn
f2d0775f1b A bunch of small fixes to build in MSVC2013.
Fixed an issue where some of the tests were testing
the wrong word with the wrong operation. (| != ||).

Coalesced the many versions of EnumCase into one.
Added a get_value() to EnumCase to convert to a uint32_t.

Replaces ASSERT_TRUE(pointer), with ASSERT_NE(nullptr, pointer),
so that we do not do implicit pointer->bool conversion.

Removed const from some test structs since gtest needs to be
able to swap them.
2015-10-26 12:55:33 -04:00
Lei Zhang
a94701db39 Run clang-format. 2015-10-26 12:55:33 -04:00
David Neto
a08350a2c3 Assembler test for OpSourceExtension.
Add test utility function MakeVector(std::string) to encode
a string as a vector of 32-bit words, as per the SPIR-V literal
string encoding.
2015-10-26 12:54:39 -04:00
David Neto
c88dcd6a72 Add OpNop, OpUndef tests for spvTextToBinary
Add text_fixture::TextToBinaryTestBase::CompiledInstructions,
to more easily just examine the generated instructions by skipping
over the header.

Add spvtest::MakeInstruction utility function to easily generate
a vector containing an opcode and its operands.
2015-10-26 12:54:39 -04:00
David Neto
d3ead501de Don't overload operators in std namespace.
Use a spvtest::WordVector proxy object to easily print
std::vector<uint32_t> and spv_binary_t values.
2015-10-26 12:52:01 -04:00
David Neto
e7ee4c4476 Getting the next word respects quoting and escaping.
Use double quotes (").  They can be interspersed with
other whitespace characters, just like shell quoting.

A backslash (\) always escapes the next character.

The end of the stream always terminates the word.

Add AutoText struct to unit test utilities, to easily
make spv_text_t values and reference them as spv_text values.
2015-10-26 12:52:01 -04:00
Andrew Woloszyn
2facab2d08 Added stream operators for spv_binary_t and std::vector<uint32_t> 2015-08-24 15:05:02 -04:00
Andrew Woloszyn
1d2a87ed1b Added the initial set of glsl450 instructions.
Also rewrote the extended-instruction tests so that they would actually
make sure that the instruction actually appears in the output.
2015-08-24 15:04:49 -04:00
Kenneth Benzie (Benie)
83e5a29b06 Code drop of the Codeplay spirv-tools source.
This commit contains the source for the SPIRV static library, spirv-as,
spirv-dis, and spirv-val tools.
2015-05-22 18:26:19 +01:00