Commit Graph

1311 Commits

Author SHA1 Message Date
Dejan Mircevski
374616d98f Negative test for Decoration. 2015-10-26 12:55:33 -04:00
Dejan Mircevski
c0eb225044 Negative test for FPRoundingMode. 2015-10-26 12:55:33 -04:00
Dejan Mircevski
355cc0c678 Negative test for FPFastMathMode. 2015-10-26 12:55:33 -04:00
Dejan Mircevski
971b344150 Negative test for ImageFormat. 2015-10-26 12:55:33 -04:00
Dejan Mircevski
d062f8b097 Make compilation input strings const.
Also rerun clang-format.
2015-10-26 12:55:33 -04:00
Dejan Mircevski
57c4398759 Negative test for SamplerFilterMode. 2015-10-26 12:55:33 -04:00
Dejan Mircevski
1e128260cb Negative test for SamplerAddressingMode. 2015-10-26 12:55:33 -04:00
Dejan Mircevski
63af6fd409 Negative test for ImageOperands. 2015-10-26 12:55:33 -04:00
Dejan Mircevski
2fd3792c3a Negative test for Dim. 2015-10-26 12:55:33 -04:00
Dejan Mircevski
52ff534040 Test OpTypeForwardPointer. 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
9db3a53897 Remove spv_opcode_flags_t and flags fields.
The flags fields in both spv_opcode_desc_t and spv_operand_desc_t
are redundant with the capabilities mask field in the same
structure.
2015-10-26 12:55:33 -04:00
Dejan Mircevski
725cc2a2df Negative test for ExecutionMode. 2015-10-26 12:55:33 -04:00
Dejan Mircevski
865034263d Negative test for AddressingModel, MemoryModel. 2015-10-26 12:55:33 -04:00
Dejan Mircevski
2d6796d45d Negative test for ExecutionModel. 2015-10-26 12:55:33 -04:00
Dejan Mircevski
d2c81cf34a Negative test for SourceLanguage.
Also, use "class" instead of "type" in the coverage CSV.
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
1b9d70a317 Test capabilities for enums sections 3.21-3.31
Fixes dependencies among capabilities.  (The table should store
the mask of capabilites, not the capability enum.)

Remove the old spot check test for capabilities of enums.
2015-10-26 12:55:33 -04:00
David Neto
ddda85a5c5 Fix capabilities for enums in Rev32, sec 3.3-3.20 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
Dejan Mircevski
78f6a4a649 Test operand-table capabilities. 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
287fdb0eb0 Test SPV_CAPABILITY_AS_MASK macro 2015-10-26 12:55:33 -04:00
David Neto
0cd7352d7d Use 3-arg MakeInstruction to reduce logic in tests
Avoids open-coded vector inserts and two variables in various
tests.  Should improve readability.
2015-10-26 12:55:33 -04:00
Dejan Mircevski
924997dc7f Test opcode table capability entries. 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
Dejan Mircevski
114206e0bc Clarify !<integer> parsing.
Implement some outstanding feedback from
Ic29c5a4a8178a62a5a1acad13d02f19cc1307097:

 - use "token" instead of "word" when referring to assembly text

 - specify how the numbers are parsed

Add a test for negative numbers.
2015-10-26 12:55:33 -04:00
Dejan Mircevski
14c4b10d44 Detect overflow in !<integer>. 2015-10-26 12:55:33 -04:00
David Neto
8bed0cea13 Add a .csv showing test coverage for operand class
It shows which spv::OperandClass values are used in
the syntax table in source/opcode.inc, and what tests
exercise those operand types.
2015-10-26 12:55:33 -04:00
Dejan Mircevski
897bff924a Simplify (and test) the alternate-parsing pattern. 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
David Neto
e77a7dd821 Assembly failure cases for OpMemoryBarrier
Fully tests OperandMemorySemantics from the syntax table.
2015-10-26 12:55:33 -04:00
David Neto
cb3db4327d Assembler failing cases for OpCapability 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
Dejan Mircevski
903f9d6b70 Implement alternate-parsing mode for !<integer>. 2015-10-26 12:55:33 -04:00
David Neto
c348d18486 Test bad 2nd target to OpGroupMemberDecorate 2015-10-26 12:55:33 -04:00
David Neto
454f51fa4d Assembly test for OpGroupMemberDecorate
Provides test coverage for OperandVariableIdLiteral
from the syntax table in the file 'opcode.inc'.
2015-10-26 12:55:33 -04:00
Dejan Mircevski
1b6f1960a8 Uncomment some !<integer> tests. 2015-10-26 12:55:33 -04:00
David Neto
d83179af7e Cleanup: Use EnumCase in OpDecorateSimpleTest 2015-10-26 12:55:33 -04:00
David Neto
ab778dc1dc Cleanup: Use EnumCase for ExecutionMode test 2015-10-26 12:55:33 -04:00
David Neto
54b2ea1088 Assembler test for optional operands of OpSource
These are the first tests to cover OperandOptionalId
and OperandOptionalLiteralString from the grammar in
opcode.inc
2015-10-26 12:55:33 -04:00
David Neto
f1b6471670 Dissasembler test showing reordering of masks 2015-10-26 12:55:33 -04:00
David Neto
b14a727a30 Execution scope, memory semantics operands are IDs
They shouldn't be parsed or printed as masks.
2015-10-26 12:55:33 -04:00
David Neto
619db2612e Disassembler support for mask expressions. 2015-10-26 12:55:33 -04:00
David Neto
bfa3d86f7b Memory semantics Relaxed is a synonym for None
The disassembler should prefer to print Relaxed,
I think. (Untested.)
2015-10-26 12:55:33 -04:00
David Neto
212bafe4da Assembler tests for remaining Debug instructions
OpString, OpName, OpMemberName, OpLine, OpNoLine,
OpSourceContinued.
2015-10-26 12:55:33 -04:00
David Neto
e0890da603 Update core instruction syntax to Rev32
Many instructions added and a few changed structure.

Workarounds:
- Some operands can be enabled by either one of two
  capabilities.  The spv_operand_desc_t does not handle that
  now. For now just select the first one.

Fixes to tests:
- OpLoopMerge now takes a mandatory continue target.
- OpTypePipe drops the type argument.  Pipes are opaque.
- OpLine no longer takes a target ID argument.

The ID validator was fixed the OpLine and OpTypePipe
changes.  Those were the only ID validator tests affected.

The patch to the spec doc generator was updated so it handles
the two-capability case, even if in an hacky way.
2015-10-26 12:55:33 -04:00
David Neto
6b31ce4d50 Assembler test TODOs for image instructions. 2015-10-26 12:55:33 -04:00
David Neto
d768798d48 Assembler supports new decorations in Rev32
They are:
 - NoContraction
 - InputTargetIndex
 - Alignment
2015-10-26 12:55:33 -04:00
Lei Zhang
863ddbeeaa Rev32: Remove DepthAny and mark Xfb as requiring TransformFeedback. 2015-10-26 12:55:33 -04:00
David Neto
c66f5074e2 Assembler support for new capabilities in Rev32 2015-10-26 12:55:33 -04:00
David Neto
8576c9c327 Support Image operand MinLod 2015-10-26 12:55:33 -04:00
David Neto
2d1b5e5bba Assembler supports new builtins in Rev32
They are VertexIndex and InstanceIndex.
2015-10-26 12:55:33 -04:00
David Neto
49c299b094 Assembler support for Nontemporal memory access 2015-10-26 12:55:33 -04:00
David Neto
c09d3857ff Fix permissions on test/TextToBinary.Barrier.cpp 2015-10-26 12:55:33 -04:00
David Neto
aa0c3a5c07 Support Dim InputTarget 2015-10-26 12:55:33 -04:00
David Neto
9819adf4cb Support StorageClass PushConstant 2015-10-26 12:55:33 -04:00
David Neto
3e52dd915d Support ExecutionMode IndependentForwardProgress 2015-10-26 12:55:33 -04:00
David Neto
16df562ad3 Assembler test for Memory Semantics enum
Enables mask expression parsing for Memory Semantics arguments,
e.g. on OpMemoryBarrier.
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
Lei Zhang
a66952d38c Remove executable file mode bits on source files. 2015-10-26 12:55:33 -04:00
David Neto
dbaf40718a Update to Rev32 headers. Part 1.
Just enough fixes to code make it build and pass tests.

Core changes:
 - Fix spelling for: NoPerspective, NonWritable, NonReadable,
 - Remove NoStaticUse, RelaxedMask

GLSL changes:
 - Fixed spelling for: InverseSqrt, FaceForward, MatrixInverse,
   SmoothStep, FindILsb, FindSMsb, FindUMsb
 - Replace Mix with IMix and FMix
 - Remove AddCarry, SubBorrow, MulExtended

Replace header OpenCLLib.h with OpenCL.std.h

TODO:
 - Regenerate the core instruction syntax table (source/opcode.inc)
 - Add test coverage for new enums and instructions.
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
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
Andrew Woloszyn
815cb95247 Fix MSVC build for boolean opeartions on enums. 2015-10-26 12:55:33 -04:00
David Neto
d1dd2fbd7c Put const back on const char* in test case structs 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
David Neto
ee1b3bb3bb Assembler support for image operands from Rev31
Rev32 and later add many more image operands, and
rearrange their values.
2015-10-26 12:55:33 -04:00
Lei Zhang
184c76dbaf Let EncodeAndDecodeSuccessfully remove preamble comments. 2015-10-26 12:55:33 -04:00
Lei Zhang
6d41581c93 Clean up code for encoding literal operands. 2015-10-26 12:55:33 -04:00
David Neto
5bf88fcc95 Assembler: mask expressions where 1 bits imply operands
Properly support a memory access mask with a combination
of bits, including the Aligned bit. When the Aligned bit is
set, the parser should expect an alignment value literal operand.
2015-10-26 12:55:33 -04:00
David Neto
36b0c0f6b3 Assembler support for simple mask expressions
For example, support combining mask enums with "|",
such as "NotNaN|AllowRecip" for the fast math mode.

This is supported for mask values that don't modify the
expected operand pattern:
 - fast math mode
 - function control
 - loop control
 - selection control

TODO: disassembler support to print them as mask expressions.
2015-10-26 12:55:33 -04:00
Dejan Mircevski
e3a19c0d63 Forbid !<integer> preceding or succeeding '='. 2015-10-26 12:55:33 -04:00
David Neto
b30a0c529b Assembler test for Dim, ImageFormat enums.
Adds SPV_OPERAND_TYPE_SAMPLER_IMAGE_FORMAT, and the
translation tables for its values from the spv::ImageFormat values.
2015-10-26 12:55:33 -04:00
David Neto
f7ee0ca5da Use generalized EnumCase in AccessQualifier assembly tests
This is in preparation for coming tests that will also
use the templated EnumCase instead of making their
own structs.

Also reformat AccessQualifier test.
2015-10-26 12:55:33 -04:00
Dejan Mircevski
ba569fb1aa Handle IDs among !<integer> operands. 2015-10-26 12:55:33 -04:00
David Neto
5f33d31d89 Assembler test for SamplerAddressingMode, SamplerFilterMode
Uses OpConstantSampler instruction.
2015-10-26 12:55:33 -04:00
David Neto
5494dd4334 Assembler test for Storage Class enum values
This covers the storage classes in SPIR-V Rev31.  Rev32 has more.
2015-10-26 12:55:33 -04:00
Lei Zhang
b41d150b7f Support multiple word literal numbers as constants.
Add a new operand type SPV_OPERAND_TYPE_MULTIWORD_LITERAL_NUMBER
to represent those operands that can expand into multiple words.
Now only OpConstant and OpSpecConstant have such kind of operand.
2015-10-26 12:55:33 -04:00
David Neto
fadbf6220e Assembler test for ExecutionScope, with OpGroupIAdd
Use spvOperandTypeStr to generalize the error message
for failure to parse an ID.
Extend spvOperandTypeStr to cover SPV_OPERAND_TYPE_EXECUTION_SCOPE.
2015-10-26 12:55:33 -04:00
David Neto
abe51c4142 Assembler test for OpTypePipe
Covers all AccessQualifier enums.

In Rev32, OpTypePipe no longer has a type argument.
Added TODOs for this.
2015-10-26 12:55:33 -04:00
David Neto
4a29131dcd Assembler test for single-valued Memory Access flag. 2015-10-26 12:55:33 -04:00
David Neto
f4fde6c60d Assembler test for single-valued FunctionControl mask
Fixed name of "Inline" enumerant.

Support for combinations of function control masks should come later.
2015-10-26 12:55:33 -04:00
David Neto
c0b32ecb54 Assembler test for single-valued LoopControl mask
Support for combining masks should come later.
2015-10-26 12:55:33 -04:00
David Neto
ad18c77ac9 Assembler test for single-valued SelectionControl mask
Support for combining masks should come later.
2015-10-26 12:55:33 -04:00
Lei Zhang
a94701db39 Run clang-format. 2015-10-26 12:55:33 -04:00
David Neto
e8e3712c3b Assembler test for OpExecutionMode 2015-10-26 12:55:33 -04:00
David Neto
f6498bfc73 Assembler test for OpEntryPoint 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
4e092d3ac3 Move bitwisecast.h to source/ and add include guard. 2015-10-26 12:55:33 -04:00
David Neto
a48678ab92 Fix an infinite loop during message generation.
Rename getWord to spvGetWord and unit test it.
2015-10-26 12:55:33 -04:00
Dejan Mircevski
f79519c926 Handle operands when OpCode is !<integer>. 2015-10-26 12:55:33 -04:00
David Neto
4caa47c3d4 Assembler test for OpMemoryModel 2015-10-26 12:55:33 -04:00
Lei Zhang
29e667eb6c Add library function parameter to set assembly format for disassembler. 2015-10-26 12:55:33 -04:00
David Neto
c6402d64f4 Assembler tests for OpCapability.
Adds test file for instructions in the Mode-Setting section
of the SPIR-V spec.
2015-10-26 12:55:33 -04:00
David Neto
55bdfcb0bc Assembler test for LinkageAttributes decorations 2015-10-26 12:54:39 -04:00
David Neto
37547b2304 Assembler tests for all decorations except Linkage attributes
Fixes typos in various parser tables.

Updates readme.md with the fixes.
2015-10-26 12:54:39 -04:00
Lei Zhang
e78a7c19ff Run clang-format. 2015-10-26 12:54:39 -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
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
08d89bb7a5 Test assembly of OpSource using all language enums
Adds a file to test assembly of instructions in the "Debug" section
of the SPIR-V spec.
2015-10-26 12:54:39 -04:00
David Neto
43f0e819c4 Avoid undefined pointer given to spvTextDestroy
The undefined pointer might get through to the call
to spvTextDestroy if the test fails on an earlier step.
In that case I just want to see the test failure, and
not a test failure followed by undefined behaviour.
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
David Neto
ac6f71b2de spvTextDestroy is no-op on nullptr. 2015-10-26 12:54:39 -04:00
David Neto
a71138372e Fix spvBinaryDestroy test to use an API-created object 2015-10-26 12:54:39 -04:00
David Neto
b6a8898fa5 Enable OpcodeMake test, by sampling values.
The previous version of the test was disabled, presumably
because it took to long to run.
2015-10-26 12:54:39 -04:00
David Neto
f4fd780654 spvBinaryDestroy(nullptr) is a no-op. 2015-10-26 12:54:39 -04:00
David Neto
c9b5152b4f Remove spvOpcodeIsVariable
Nothing was using it.
2015-10-26 12:54:39 -04:00
Dejan Mircevski
1a3990233c Add hex-format tests for !<integer>. 2015-10-26 12:52:01 -04:00
Dejan Mircevski
ea5a2a5242 Add invalid-operand tests for !<integer>. 2015-10-26 12:52:01 -04:00
Dejan Mircevski
a4b834e456 Make all SpirvVectors const in ImmediateInt.cpp. 2015-10-26 12:52:01 -04:00
Dejan Mircevski
d8454a7967 Tests for parsing recognizable words after !<integer>. 2015-10-26 12:52:01 -04:00
David Neto
f58d8c0965 Add disabled test to check float value parsing
Disabled for now because float parsing is broken.
2015-10-26 12:52:01 -04:00
David Neto
c978643748 Print diagnostics at the beginning of input.
A spv_diagnostic_t value knows if the source is textual rather
than binary.
2015-10-26 12:52:01 -04:00
Dejan Mircevski
e75b3e769d Avoid "operands" in the !<immediate> explanation.
Also declare "!<integer> = OpCode" legal.
2015-10-26 12:52:01 -04:00
Dejan Mircevski
d5769bf08a Test consecutive opcodes being !<integer>. 2015-10-26 12:52:01 -04:00
David Neto
78c3b43774 Use opcode operand definitions from SPIR-V specification generator.
The assembler and disassembler now use a dynamically adjusted
sequence of expected operand types.  (Internally, it is a deque,
for readability.)  Both parsers repeatedly pull an expected operand
type from the left of this pattern list, and try to match the next
input token against it.

The expected pattern is adjusted during the parse to accommodate:
- an extended instruction's expected operands, depending on the
  extended instruction's index.
- when an operand itself has operands
- to handle sequences of zero or more operands, or pairs of
  operands.  These are expanded lazily during the parse.

Adds spv::OperandClass from the SPIR-V specification generator.

Modifies spv_operand_desc_t:
 - adds hasResult, hasType, and operandClass array to the opcode
description type.
 - "wordCount" is replaced with "numTypes", which counts the number
   of entries in operandTypes.  And each of those describes a
   *logical* operand, including the type id for the instruction,
   and the result id for the instruction.  A logical operand could be
   variable-width, such as a literal string.

Adds opcode.inc, an automatically-generated table of operation
descriptions, with one line to describe each core instruction.
Externally, we have modified the SPIR-V spec doc generator to
emit this file.
(We have hacked this copy to use the old semantics for OpLine.)

Inside the assembler, parsing an operand may fail with new
error code SPV_FAIL_MATCH.  For an optional operand, this is not
fatal, but should trigger backtracking at a higher level.

The spvTextIsStartOfNewInst checks the case of the third letter
of what might be an opcode.  So now, "OpenCL" does not look like
an opcode name.

In assembly, the EntryPoint name field is mandatory, but can be
an empty string.

Adjust tests for changes to:
- OpSampedImage
- OpTypeSampler
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
David Neto
b3669d13fe Remove unused struct "bin" 2015-10-26 12:52:01 -04:00
Dejan Mircevski
741cdc4829 More !<integer> tests. 2015-10-26 12:52:01 -04:00
Dejan Mircevski
5f45e596bd Use spvOpcodeMake() in ImmediateInt tests. 2015-10-26 12:52:01 -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
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
David Neto
9fa9157c4d Add bin-to-text test for operand with operands 2015-10-26 12:52:01 -04:00
David Neto
c9a23a6fd5 Add binary-to-text test for single instruction
This is easier to debug!

Binary-to-text testing needs more tests, and more
specific tests.  That's for future work.
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
Dejan Mircevski
f184109d7b Move ImmediateInt tests into their own file.
This is in preparation of adding many more tests in accordance with the
evolved spec.

Also sort the test-source lines in CMakeLists.
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
David Neto
574884cd7e Getting the next word ends at a comment (;) 2015-10-26 12:52:01 -04:00
David Neto
98290a243e String literals must be quoted. 2015-10-26 12:52:01 -04:00
David Neto
affa696027 Fix some bugs in parsing literals.
- a single hyphen is a string, not a number.
- a string with more than one period is a string, not a number
- check for string overflow

Add some unit tests
2015-10-26 12:52:01 -04:00
Lei Zhang
5b73214223 Add GLSL std450 extended instruction 72-80. 2015-10-26 12:52:01 -04:00
Dejan Mircevski
afdbd2d303 Add std450 instructions 53-64. 2015-10-26 12:52:01 -04:00
Lei Zhang
3cb589639d Add GLSL std450 extended instruction 65-71. 2015-10-26 12:52:01 -04:00
Lei Zhang
85d4d6d677 Add test for Modf and ModfStruct. 2015-10-26 12:52:01 -04:00
Dejan Mircevski
c48fcce978 Add std450 instructions 49-52. 2015-10-26 12:52:01 -04:00
Lei Zhang
dca65b3f8c Reformat GLSL std450 extended instruction table.
Also add test for Smoothstep.
2015-10-26 12:52:01 -04:00
Dejan Mircevski
c4ba8821e7 Add tests for Atan2 and Pow.
Fix a typo in "ParameterizedExtInst."
2015-10-26 12:52:01 -04:00
Lei Zhang
65bfc4d585 Unify tests for GLSL std450 extended instructions.
Previously we had two tests: one checks test to binary, the other
checks round trip. This patch merges the check in the former to
the latter.
2015-10-26 12:52:01 -04:00
Lei Zhang
e5ae7f677f Add GLSL std450 instructions 35-48. 2015-10-26 12:52:01 -04:00
Lei Zhang
0e149d7cc4 Move tests for GLSL std450 instructions to a separate file. 2015-10-26 12:52:01 -04:00
Dejan Mircevski
a5c171544b Add std450 instructions 25-34. 2015-10-26 12:52:01 -04:00
Lei Zhang
8a37520908 Disassemble in the format of "<result-id> = <opcode> <operand>..". 2015-10-26 12:52:01 -04:00
Lei Zhang
abafd5e674 Only use '%' as variable name prefix.
Since now we can distinguish between def and use according to
the variable's location, there is no need to keep two variable
prefixes.

Also reformat tests to use the value generating instruction
format ("<result-id> = <opcode> <operand>..").
2015-08-24 15:05:11 -04:00
Lei Zhang
977e9bcfc6 Bugfix: report the correct location for wrong opcode.
Also add more tests for the "<result-id> = <opcode> <operand>.."
format.
2015-08-24 15:05:08 -04:00
Lei Zhang
ee87cc2a1e Fix TextAdvance() problems involving whitespace around comment lines.
Fix the bug that TextAdvance() forgot to skip whitespace at the
beginning of the next line after a comment line.

Fix the bug that TextAdvanceLine() increase line number after going
over a character.
2015-08-24 15:05:05 -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
Lei Zhang
dfc50086a6 Support "<result-id> = <opcode> <operand>.." format. 2015-08-24 15:04:58 -04:00
Andrew Woloszyn
0d350b5992 Make the disassembler print the Extended instruction name.
This allows the disassembled output to more closely follow the
original assembly.
2015-08-24 15:04:55 -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
Kenneth Benzie
67b649fa01 Merge branch 'update-header-to-rev31' into 'master'
Update external headers to rev 31

See merge request !3
2015-08-18 05:34:27 -04:00
David Neto
f6184a8b37 Parenthesize SPV_BIT macro to avoid surprises. 2015-08-17 17:01:42 -04:00
Lei Zhang
604e5cea12 Update spirv.h to revision 31.
For enum Capability and enum Op, not all newly added enumerants are
registered into capabilityInfoEntries and opcodeTableEntries yet.
That will come in following commits.
2015-08-17 11:40:24 -04:00
Lei Zhang
3a7315498f Fix failing tests.
The generator number is set to SPV_GENERATOR_KHRONOS in the
spvBinaryHeaderSet function, so tests should catch up.
2015-07-30 15:21:42 -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