Commit Graph

32 Commits

Author SHA1 Message Date
Dejan Mircevski
3d27da4bc7 Add a target environment to spvContextCreate().
Run clang-format.
2016-03-31 12:16:51 -04: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
Lei Zhang
972788bf23 Use opaque context object to hold SPIR-V info tables.
Previously the opcode table is declared as an global array and we
have spvOpcodeTableInitialize() modifying it. That can result in
race condition. Now spvOpcodeTabelGet() copies the whole underlying
array.
2015-11-12 16:27:51 -05:00
David Neto
e7c426ac8d Disassembler tool indents to 15 by default
The assigned-to result Id appears to the left of the 15th column.

Add --no-indent option.

The API form of the disassembler does not indent by default.
2015-11-12 16:27:50 -05:00
Lei Zhang
df920ecb71 Remove table parameters from API functions.
Opcode, operand, and external instruction tables are no longer
passed in as parameters to spvTextToBinary(), spvBinaryToText(),
and spvValidate().
2015-11-12 09:42:50 -05:00
David Neto
229b90f6f4 Print OpConstant values according to type.
Zero and normal floating point values are printed with enough
enough digits to reproduce all the bits exactly.
Other float values (subnormal, infinity, and NaN) are printed
as hex floats.

Fix a binary parse bug: Count partially filled words in a
typed literal number operand.

TODO: Assembler support for hex numbers, and therefore reading
infinities and NaNs.
2015-11-10 15:57:59 -05:00
Lei Zhang
9042f40f7c Remove support for canonical assembly syntax format. 2015-11-10 15:57:49 -05:00
David Neto
ea633a6427 Empty assembly text compiles to no instructions.
But it's still a valid module.
2015-11-10 15:56:57 -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
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
Andrew Woloszyn
157e41bf57 Added type tracking to the disassembler.
TODO: Actually use the tracked types to make sure that we print out
values correctly.
2015-10-26 12:55:33 -04:00
Lei Zhang
4c2db8347e Simplify methods for compilation failure in test framework.
Remove  CompileWithFormatFailure() and make CompileFailure() accept
a default argument.
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
42bfd4bfab Assembly test for OpSwitch
Removes old weak and fragile tests for OpSwitch.

Adds spvtest::TextToBinaryTest::CompileWithFormatFailure
2015-10-26 12:55:33 -04:00
Andrew Woloszyn
13804e5d63 All values now represent symbolic names instead of mixed with numeric.
Also removed un-necessary heap-allocation of spv_named_id_table.
This removed the necessity to expose a function to create/destroy it
and simplified the interface.
2015-10-26 12:55:33 -04:00
David Neto
1b5fd4962e Put the test fixture into spvtest namespace.
All test utility code should go into the spvtest namespace.
2015-10-26 12:55:33 -04:00
Lei Zhang
184c76dbaf Let EncodeAndDecodeSuccessfully remove preamble comments. 2015-10-26 12:55:33 -04:00
Dejan Mircevski
58fc88e2ee Simplify format indication in CompileSuccesfully(). 2015-10-26 12:55:33 -04:00
Lei Zhang
06efdc59e1 Add an API parameter to choose assembly syntax format for assembler.
Added a new enum for supported assembly syntax formats:
Canonical Assembly Format (CAF) and Assignment Assembly Format (AAF).

Updated assembler interface functions to support choice of assembly
syntax format.
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
Lei Zhang
574352c7a9 Fix interface function calls to the new API. 2015-10-26 12:54:39 -04:00
Lei Zhang
610c525865 Preserve float values during encoding and decoding roundtrip. 2015-10-26 12:54:39 -04:00
Andrew Woloszyn
cfeac48a37 Removed the ambiguity in the API for cleaning input vs output data.
Previous the api used spv_text_t and spv_binary_t for both input
and output, but depending on the usage, you either MUST
call spvBinaryDestroy or you MUST NOT call spvBinaryDestroy on the
pointer.
2015-10-26 12:54:39 -04:00
David Neto
cac38f92dd Simplify uses of spvBinaryDestroy in tests
Always try to destroy the binary during common methods
of test fixtures.  This is safe if no other code in the test
attempted to destroy the binary.

Take advantage of the fact spvBinaryDestroy is a no-op on a nullptr,
by eliminating the null pointer check in the caller.
2015-10-26 12:54:39 -04:00
Dejan Mircevski
ea5a2a5242 Add invalid-operand tests for !<integer>. 2015-10-26 12:52:01 -04:00
Dejan Mircevski
6c03f87490 Print failing assembly text in CompileSuccessfully(). 2015-10-26 12:52:01 -04:00
Dejan Mircevski
0a8f219d1e Add a few unit tests for !<integer>. More to come.
Start using GMock: modify CMakeLists, fix googletest URL in readme.

Add useful utilities to the TestFixture class.  Also make it conform to
go/gunit recommendations about setup/teardown.
2015-10-26 12:52:01 -04:00
Dejan Mircevski
73d7082245 Put test classes in anonymous namespace.
Put TestFixture.h classes in a namespace.

Remove unused #includes.
2015-10-26 12:52:01 -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
Lei Zhang
fb76d81aa0 Move test fixture into a separate header file so it can be reused. 2015-08-24 15:04:45 -04:00