Commit Graph

4066 Commits

Author SHA1 Message Date
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
ee5104286f Remove stale TODO. Fix use of OpCode to 'instruction' 2015-10-26 12:55:33 -04:00
David Neto
21aac5c653 Update readme: capabilities are up to date 2015-10-26 12:55:33 -04:00
David Neto
8b19f27026 Define spv_capability_mask_t for readability. 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
David Neto
104da61432 Update readme: Finish assembler !<integer> support
Also internal cleanups and additional tests.
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
Dejan Mircevski
205408bae4 Make capabilities a bitfield in opcode/operand tables. 2015-10-26 12:55:33 -04:00
Dejan Mircevski
4170ceca12 Create spv_language_capabilities_t and widen capabilities fields.
If this is acceptable, I'll do a wholesale switch of operand and opcode
definitions to capability bitfields.
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
97e2c8fc3d Try to fix the Android build. 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
David Neto
7cefb23ddb Document non-use of certain operand types
Operand class enum values not used in the syntax table:
- Image channel order: only used to describe a return value
- Image channel type: only used to describe a return value
- "Image operands": used to make a section in the spec
  to describe values used to construct an optional image id,
  but does not itself appear in the syntax table.

Removes some TODOs from opcode.cpp.
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
50babb2d00 Run clang-format. 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
e3940ab166 Readme: capabilities for instructions are ok
Capabilities for enumerants may be out of date.
2015-10-26 12:55:33 -04:00
Andrew Woloszyn
38acba2c3c Updated syntax.md to remove references to % numerical ids. 2015-10-26 12:55:33 -04:00
Dejan Mircevski
9672ad39cf Remove isIdType(), which is now dead code. 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
561dc4e975 Remove SPV_OPERAND_TYPE_LITERAL
All uses of OptionalLiteral by the SPIR-V spec are used
for literal numbers.

Also rename:
- SPV_OPERAND_TYPE_OPTIONAL_LITERAL to
  SPV_OPERAND_TYPE_OPTIONAL_LITERAL_NUMBER.
- SPV_OPERAND_TYPE_VARIABLE_LITERAL to
  SPV_OPERAND_TYPE_VARIABLE_LITERAL_NUMBER.
- SPV_OPERAND_TYPE_VARIABLE_LITERAL_ID to
  SPV_OPERAND_TYPE_VARIABLE_LITERAL_NUMBER_ID.
- SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL to
  SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL_NUMBER.
- SPV_OPERAND_TYPE_LITERAL_IN_OPTIONAL_TUPLE to
  SPV_OPERAND_TYPE_LITERAL_NUMBER_IN_OPTIONAL_TUPLE.
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
e4eba63932 Update Readme: Support Rev32; IDs never alias 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