Commit Graph

23 Commits

Author SHA1 Message Date
Lei Zhang
6d41581c93 Clean up code for encoding literal operands. 2015-10-26 12:55:33 -04:00
David Neto
3fca4cddee Remove SPV_OPERAND_TYPE_VARIABLE_MEMORY_ACCESS
If a memory mask operand is present, it is a mask.  The mask appears
only once, so just use SPV_OPERAND_TYPE_OPTIONAL_MEMORY_MASK.

The "variable literals" aspect comes into play as follows: if the
Aligned bit is set in the mask, then the parser will be made to
expect the alignment value as a literal number operand that follows
the mask.  That is done through mask operand expansion.
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
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
Lei Zhang
4005670363 Limit the use of spvCheck and spvCheckReturn to validator.
spvCheck is indeed just an if-statement. Defining such a macro
doesn't help much.
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
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
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
ac6f71b2de spvTextDestroy is no-op on nullptr. 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
David Neto
ec5f82082f Remove SPV_OPERAND_TYPE_ELLIPSIS 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
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
David Neto
225baf88bc Add SPV_FAILED_MATCH status code
This is for future use by the parser.
2015-10-26 12:52:01 -04:00
David Neto
4799482787 Fix spelling of SPV_OPERAND_TYPE_KERNEL_PROFILING_INFO 2015-10-26 12:52:01 -04:00
Lei Zhang
dfc50086a6 Support "<result-id> = <opcode> <operand>.." format. 2015-08-24 15:04:58 -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
884c833889 Substitute GLSL450Lib.h with GLSL.std.450.h of revision 31. 2015-08-17 09:08:31 -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