Commit Graph

339 Commits

Author SHA1 Message Date
Lei Zhang
af9906e4e5 Use Google comment style and fix typos. 2015-11-16 17:25:43 -05:00
David Neto
287cfc1dd7 Fix grammar: "The SPIR-V Tools project provides" 2015-11-14 08:24:59 -06:00
David Neto
2266ba1061 Register Glslang tool 2015-11-13 12:35:47 -06:00
Lei Zhang
acf7287c42 Fix many typos. 2015-11-13 12:35:43 -06:00
David Neto
56fb3f016b Revamp the README for public release.
Reorganize the README, and update its contents to more accurately
reflect the public release.
Remove the incremental "Changes" section.

Rename readme.md to README.md
Rename license.txt to LICENSE

Update the assembler tool to support -h, and make its help look
more consistent with the disassembler.

Change the target and library name to SPIRV-Tools.  To better
match the GitHub repo name.  Also, it's not SHOUTING.
2015-11-13 12:35:39 -06:00
David Neto
3d348a8440 The version header word has 3 byte-size components.
Bits 24-31: 0
Bits 16-23: SPIR-V major number (1)
Bits  8-15: SPIR-V minor number (0)
Bits   0-7: SPIR-V minor number (2)

The assembler will construct the word appropriately,
and the disassemble will print it in major.minor.revision form.
2015-11-13 12:35:34 -06:00
David Neto
14b93e49ed Generator word now has two 16-bit components
The high 16-bits are a registered generator tool.
These are registered at
https://www.khronos.org/registry/spir-v/api/spir-v.xml

The low 16-bits are tool-specific.  It might be a version number,
for example, but is not constrained by the spec or by the registration
process.

The disassembler prints the tool name when we know it.
If we don't, print "Unknown" and then the numeric tool number
in parentheses.
In all cases, the disassembler prints lower 16-bit number on the
same line but after the tool name.

Also add newly registered generators:
  6: Khronos LLVM/SPIR-V Translator
  7: Khronos SPIR-V Tools Assembler
2015-11-13 12:35:29 -06:00
David Neto
5f7ed91e18 Support capabilities StorageImageReadWithoutFormat
Also add capability StorageImageWriteWithoutFormat.

They only affect validation rules.
2015-11-12 16:27:51 -05:00
David Neto
df3ea3c5de Disassembler can read the binary from stdin.
Read from stdin if:
 - no input filename specified
 - the input filename is "-"

Also, output goes to stdout if the output filename (argument to -o)
is "-".
2015-11-12 16:27:51 -05:00
David Neto
12511c8a4f Add GeometryStreams capability
Decoration Stream depends on it.
GeometryStreams depends on Geometry capability.

Spot check dependence of OpEmitStreamVertex on GeometryStreams.
(Opcode dependencies on capabilities are automatically generated from
opcode.inc)
2015-11-12 16:27:51 -05:00
David Neto
0c6cf8cdff Support OpImage
It's already in the syntax table.  Just test it.
2015-11-12 16:27:51 -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
Lei Zhang
321c3e206b Remove an obselete and redundant text. 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
David Neto
9a5ac08bcf spirv-dis prints to stdout by default.
Color printing is enabled only for printing to stdout.
Add --no-color to turn off color printing.
2015-11-12 16:27:50 -05:00
Lei Zhang
39b01b9988 Simplify some tests 2015-11-12 16:27:46 -05:00
Lei Zhang
4ac601a2c3 libspirv.h doesn't depend on spirv_operands.hpp anymore.
Also change spirv_operands.hpp to a C header since we only have
an enum inside it, and move it to source/.
2015-11-12 09:43:26 -05:00
Lei Zhang
a23a73671a Moves parser interface to libspirv.h. 2015-11-12 09:43:23 -05:00
Lei Zhang
8984f6f31f Move internal macros/structs for SPIR-V to a separate header. 2015-11-12 09:43:20 -05:00
David Neto
d02f68ae79 Update to 1.0 Rev 2 work-in-progress headers
Updated readme.

Note: The header advertises itself as Rev 1, but contains
many (all?) the updates intended for Rev 2.  We might need
to update one more time before SPIR-V 1.0 Rev2 is published.

Regenerated syntax tables for 1.0.

Changed names:
  InputTriangles -> Triangles
  InputQuads -> Quads
  InputIsolines -> Isolines
  WorkgroupLocal -> Workgroup
  WorkgroupGlobal -> CrossWorkgroup
  PrivateGlobal -> Private
  (Dim) InputTarget -> SubpassData
  WorkgroupLocalMemoryMask -> WorkgroupMemoryMask
  WorkgroupGlobalMemoryMask -> CrossWorkgroupMemoryMask
  AsyncGroupCopy -> GroupAsyncCopy
  WaitGroupEvents -> GroupWaitEvents

Remove:
  IndependentForwardProgress capability
  Smooth decoration
  FragColor BuiltIn
  WorkgroupLinearId in favour of LocalInvocationId
  ImageSRGBWrite capability
  Special OpenCL image instructions

Add:
  image channel data type UnormInt101010_2
  AcquireReleaseMask

InputTargetIndex updates:
  InputTargetIndex -> InputAttachmentIndex
  InputAttachmentIndex depends on InputAttachment capability,
  and it takes a literal number argument.

Capability StorageImageExtendedFormats updates:
  Enum value changed from 26 to 49. (Changes position in tables).
  Replaces AdvancedImageFormat capability.

OpenCL source language -> OpenCL_C, OpenCL_CPP
2015-11-12 09:43:12 -05:00
Lei Zhang
aa056cd8c7 Move SPIR-V constants/limits to a separate header. 2015-11-12 09:43:09 -05:00
Lei Zhang
16f3ddfbb8 Use std::string instead of a huge array for storing literal strings. 2015-11-12 09:43:06 -05:00
Lei Zhang
2a0b773b27 Add missing copyright. 2015-11-12 09:43:03 -05:00
Lei Zhang
923f6c13fc Use quotation for libspirv.h and sort headers. 2015-11-12 09:43:01 -05:00
Lei Zhang
7a222e4abf Move info table related structs into table.h. 2015-11-12 09:42:58 -05:00
Lei Zhang
04736e7878 Move spv*TableGet() functions out of libspirv.h.
This is a part of the effort to clean up libspirv.h.
2015-11-12 09:42:55 -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
Andrew Woloszyn
ec691fba2a Fixed permissions 2015-11-11 12:12:16 -05:00
Andrew Woloszyn
55ecc2e097 Fixed warnings on windows and constness of spv_binary.
Replaced uint64_t with size_t in the places that make sense and
added spv_const_binary{,_t} to allow the interface to accept non
modifiable spirv where appropriate.
2015-11-11 12:12:13 -05:00
Lei Zhang
9049bb4877 Get magic number and version from spirv.h.
This is a part of the effort to clean up libspirv.h.
2015-11-11 12:12:10 -05:00
David Neto
2119694775 Disassembler support for OpSpecConstantOp
Document the fact that we use names for extended instructions
and OpSpecConstantOp opcode operands.
2015-11-11 12:12:07 -05:00
David Neto
0f166be68d Assembler support for OpSpecConstantOp
Adds SPV_OPERAND_TYPE_SPEC_CONSTANT_OP_NUMBER.
2015-11-11 12:12:04 -05:00
David Neto
ce9cef71ac Fix Windows build errors.
- uint64_t != size_t sometimes
- don't use C99 runtime sized arrays
2015-11-11 09:55:51 -05:00
David Neto
f252985059 Fix description of NaN encoding. 2015-11-11 09:55:49 -05:00
David Neto
003e288c35 Enable round trip tests for OpSwitch 2015-11-11 09:55:42 -05:00
Lei Zhang
aa3cd5abb9 Optional typed literal number should be concrete in BinaryParser. 2015-11-10 15:58:16 -05:00
David Neto
0db3721675 Update readme: binary parser refactor; non-32-bit literals 2015-11-10 15:58:14 -05:00
David Neto
7c3ca6d05a syntax.md: Describe hex floats and their use. 2015-11-10 15:58:10 -05:00
David Neto
2ae4a68fe8 Fix handling of OpExtInstImport
The assembler tracks mapping of extended instruction import Id
to extended instruction type.

Adds a few new ways to fail.
2015-11-10 15:58:07 -05:00
David Neto
9e545d7968 Assembler supports hex float constants.
The bit pattern for a hex float is preserved through
assembly and disassembly.

You can use a hex float to express Inf and any kind of NaN
in a portable way.
2015-11-10 15:58:03 -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
0c00eb2cdf Remove canonical assembly format in syntax.md. 2015-11-10 15:57:56 -05:00
Lei Zhang
8f6ba14b58 advance() should check current string index is in bound. 2015-11-10 15:57:52 -05:00
Lei Zhang
9042f40f7c Remove support for canonical assembly syntax format. 2015-11-10 15:57:49 -05:00
David Neto
201caf7001 spv_operand_type_t cleanup.
- Concrete operand types are never optional.
  Split them to make this so, e.g. add SPV_OPERAND_TYPE_IMAGE
  since there was SPV_OPERAND_TYPE_OPTIONAL_IMAGE.
  Similarly for SPV_OPERAND_TYPE_MEMORY_ACCESS.
  This entails duplicating two operand table entries.

- The above, plus some rearranging of enums, allows us to define
  first and last optional operand types, and first and last
  variable operand types.
  This lets us simplify the code for spvOperandIsOptional, and
  spvOperandIsVariable.

- Replace SPV_OPERAND_TYPE_MULTIWORD_LITERAL_NUMBER with the
  more accurately named SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER.
  Its special characteristic is that the type of the literal
  number is determined by some previous operand in the instruction.
  This is used for literals in OpSwitch, OpConstant, and OpSpecConstant.
  This lets us refactor operand parsing cases in the assembler.

- Remove the special required-thing-in-optional-tuple in favour of
  the corresponding concrete operand type:
        SPV_OPERAND_TYPE_ID_IN_OPTIONAL_TUPLE
    --> SPV_OPERAND_TYPE_ID
        SPV_OPERAND_TYPE_INTEGER_LITERAL_IN_OPTIONAL_TUPLE
    --> SPV_OPERAND_TYPE_INTEGER_LITERAL

- Constrain spvOpeandTypeStr to only have to work for non-variable
  operand types.  Add a test for this.
2015-11-10 15:57:45 -05:00
David Neto
97e4a5d83d Remove TODO: Strings are always little-endian
SPIR-V strings are UTF-8 encoded, and always byte-addressed.
2015-11-10 15:57:42 -05:00
David Neto
0ca6b59bfd Refactor the binary parser.
The binary parser has a C API, described in binary.h.
Eventually we will make it public in libspirv.h.
The API is event-driven in the sense that a callback is called
when a valid header is parsed, and for each parsed instruction.

Classify some operand types as "concrete".  The binary parser uses
only concrete operand types to describe parsed instructions.

The old disassembler APIs are moved into disassemble.cpp

TODO: Add unit tests for spvBinaryParse.
2015-11-10 15:57:33 -05:00
Dejan Mircevski
0981b1514e Slay "undeflow." 2015-11-10 15:57:31 -05:00
Dejan Mircevski
fc10eac868 Refactor EncodeTestHelper() and DecodeTestHelper(). 2015-11-10 15:57:28 -05:00
David Neto
a010444b79 Consts before the type, not after 2015-11-10 15:57:26 -05:00