Commit Graph

2179 Commits

Author SHA1 Message Date
Andrew Woloszyn
6dfd4186f5 Updated HexFloat parsing for windows.
It is valid for float values to be modified on copy if they are NaN,
so long as they remain the correct NaN. What this means is that
we can not rely on the float data-type for storing float values
if we want to retain bit patterns.

Added FloatProxy which stores data in an unsigned integer, and updated
the HexFloat template to deal with FloatProxy values instead.
2015-11-02 13:52:31 -05:00
Andrew Woloszyn
0b61c593a2 Added HexFloat reading to HexFloat.
This allows reading of hex-encoded floats.
2015-11-02 13:52:28 -05:00
Andrew Woloszyn
c2887f98bc Added HexFloat helper class to print out floating point numbers.
TODO Add double tests before we actually use this.
2015-11-02 13:52:25 -05:00
Andrew Woloszyn
b78d2d31c5 Changed SetBits to index from LSB and take a size. 2015-11-02 13:52:23 -05:00
Lei Zhang
b36e704a47 Use spirv.h instead of spirv.hpp.
This is a part of the effort to make libspirv.h C-compatible.
2015-11-02 13:52:20 -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
David Neto
db901b622e Move endian utilities to their own file. 2015-11-02 13:52:12 -05:00
David Neto
0b9816813b Hide spvBinaryHeaderSet with its only client.
Also rename it to SetHeader since it's not part of the "binary"
API.
2015-11-02 13:52:09 -05:00
David Neto
fcc7d58353 Move AssemblyGrammar into its own source files 2015-11-02 13:52:05 -05:00
David Neto
e5e99b57cc Add DISABLED failing test for ext inst import confusion
Currently, the assembler does not track external import
IDs when there are two or more.

TODO(dneto): Fix this functionality.
2015-11-02 13:52:00 -05:00
David Neto
b6a43383e7 Use basic_string<char> for the UTF-8 test string
This is an attempt to fix the unit tests on DeveloperStudio 2013.
Currently, the size of the earth_africa string is reported as 2
on Windows.  But I think that may be 2 16-bit characters.
2015-11-02 13:51:57 -05:00
David Neto
1780fc4fcf Update to latest registered generator enums
The registry is at:
https://www.khronos.org/registry/spir-v/api/spir-v.xml
2015-11-02 13:51:54 -05:00
Andrew Woloszyn
f731cbf6c4 Added set_bits<> to bitutils.
This allows us to get a constant with the given bits set at
compile-time. This is needed for a future patch for HexFloat.
2015-11-02 13:51:51 -05:00
David Neto
e169a7cd86 Test cleanup: remove useless std::string constructor 2015-11-02 13:51:48 -05:00
Lei Zhang
b998c81315 Use typedef instead of using in libspirv.h.
The header file should be compatible with pre-C++11 code.
2015-11-02 13:51:45 -05:00
Kenneth Benzie
913e31f442 Merge branch 'google-asm-dis-oct-25' into 'master'
Google assembler disassembler catchup to oct 25

Catches up with the google branch through 2015-10-25:

* SPIR-V 0.99 Rev32
   * Core instructions, enumerants, and capabilities
* GLSL std450 extended instructions supported
* OpenCL extended instruction supported, version 1.0 Revision 1

See readme.md for missing features and known bugs, e.g.
* Fix disassembler support for non-32 bit numeric literals
* Fix: Assembler can't use extended instructions from two different imports
  in the same module
* TODO: 16-bit floating point literals

See merge request !10
2015-10-27 06:14:44 -04:00
David Neto
486a8d0a2b Fix readme: this is not the 'google' branch 2015-10-26 12:57:40 -04:00
Dejan Mircevski
d846247fd2 Fix GMOCK directory in CMakeLists.txt. 2015-10-26 12:55:33 -04:00
Andrew Woloszyn
fe6527fd80 Fixed typo in utf8 string literal 2015-10-26 12:55:33 -04:00
Andrew Woloszyn
4274f93065 Fixed UTF-8 encoding issues on windows.
Also cleaned up some warnings related to implicit size_t/uint64_t
conversions.
2015-10-26 12:55:33 -04: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
David Neto
d16ee3b428 Update readme: Support OpenCL, UTF-8 literal strings 2015-10-26 12:55:33 -04:00
David Neto
4942a318f4 Remaining tests for OpenCL extended instructions. 2015-10-26 12:55:33 -04:00
David Neto
445ce4401d Add operand type for extension instruction number
This is required to support extended instructions that
have literal numbers as operands.  An example is OpenCL's
vloadn.

The previous code in the assembler assumed that *any* literal
number argument in any part of an OpExtInst must be the name
of the extended instruction.  That's true only for the first
literal number argument.
2015-10-26 12:55:33 -04:00
David Neto
1bb8b70341 Use literal integers for OpenCL extended instructions. 2015-10-26 12:55:33 -04:00
David Neto
21c4ad4b22 Add OpenCL extended instructions.
Versions 1.2, 2.0, and 2.1 all use the same
extended instruction list.

Updated the source code patch for the SPIR-V doc generator,
so it can both generate the core syntax table, and also the
OpenCL extended instructions table.

Tested the Math and Common functions.
TODO: test the remaining entries.
2015-10-26 12:55:33 -04:00
Andrew Woloszyn
ccc210b4cc Some minor clean-ups to binary.{h,cpp}.
Removed spvBinaryDecodeOpcode and spvBinaryDecodeOperand from the public
interface since they were only ever used in binary.cpp.

Replaced the usage of spv_operand_table_t and it's ilk with the
AssemblyGrammar to reduce the number of passed parameters.

Fixed typo in comment.
2015-10-26 12:55:33 -04:00
Lei Zhang
6483bd7132 Enforce suitable literal number operands to be unsigned integers.
Except for OpConstant and OpSpecConstant, all other literal number
operands are indeed unsigned integers. So,

* Rename all *LITERAL_NUMBER* operand types to *LITERAL_INTEGER*.
* Expect unsigned integers for *LITERAL_INTEGER* operands.
* Keep MULITPLE_WORD_LITERAL untouched since it is only used by
  OpConstant and OpSpecConstant.

And we want to provide the capability to specify floating-point
numbers after !<integer> in the alternate parsing mode. So,
OPTIONAL_LITERAL_NUMBER is reserved for OPTIONAL_CIV.
2015-10-26 12:55:33 -04:00
David Neto
5d65ea726c Git ignore compile_commands.json in root directory.
Useful for standalone development of SPIR-V Tools with
Ninja and YouCompleteMe.
2015-10-26 12:55:33 -04:00
Lei Zhang
62f92cdae6 Use normal string instead of raw string for simple strings. 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
005a11a4ac Use SPIRV_PERF=1 when performance tuning.
It tells the compiler to keep frame pointers, so you have good
call stacks in your profiles.
2015-10-26 12:55:33 -04:00
David Neto
980b7cb95e Avoid strlen in a loop, for speed. 2015-10-26 12:55:33 -04:00
David Neto
9e11c7d301 Fix Android build: use std::numeric_limits<T>::max and friends
UINT32_MAX and friends are not available.
2015-10-26 12:55:33 -04:00
David Neto
470405e0ed Add disabled tests for disassembler literal emission
Currently, negative numbers are printed as if they were
first statically cast to unsigned.
2015-10-26 12:55:33 -04:00
Andrew Woloszyn
e59e6b72f9 Added proper string escaping to the disassembler.
The disassembler now generates correct string when encountering
quotes and slashes.
2015-10-26 12:55:33 -04:00
David Neto
51013d15ee SPV_FAILED_MATCH error mutes DiagnosticStream.
The DiagnosticStream will not emit the accumulated message
text if the error is SPV_FAILED_MATCH.

Change various interfaces to accept the intended error
code instead of a boolean "is_optional".  This allows
us to avoid repeating the following type of logic deep
inside helper methods:

  if (is_optional) return SPV_FAILED_MATCH;
  return diagnostic() << " message text ";
2015-10-26 12:55:33 -04:00
Andrew Woloszyn
f08c679e97 Removed un-needed comments and fixed merge issue. 2015-10-26 12:55:33 -04:00
Andrew Woloszyn
3e69cd1b9f Updated string escaping in the assembler.
Strings are now escaped correctly when assembling.
TODO dissassembler support for strange strings (newlines for example).
2015-10-26 12:55:33 -04:00
David Neto
daf493b202 Update readme. Long instructions, literal number encoding 2015-10-26 12:55:33 -04:00
Dejan Mircevski
497b226c68 Add negative-coverage location to operand-class-test-coverage.csv. 2015-10-26 12:55:33 -04:00
David Neto
78e677b5cd Parse and encode literal integers to the right width
Affects OpConstant, and OpSwitch.

Adds constant libspirv::kUnknownType for readability.

Adds tests for hexadecimal number parsing.

Updates syntax.md to describe hex parsing, including
sign extension.
2015-10-26 12:55:33 -04:00
David Neto
6274120eb9 Add AssemblyContext::parseNumber
It parses a text string for a value of a given target type.
2015-10-26 12:55:33 -04:00
David Neto
ac508b0d80 DiagnosticStream can convert to a stored error code
Use this to shorten error return code in the assembler.

For example, change this:

   if (error = something()) {
      diagnostic() << " Bad integer literal " << value;
      return SPV_ERROR_INVALID_VALUE;
   }

to this:

   if (error = something())
      return diagnostic() << " Bad integer literal " << value;

Also shorten code due to the fact that binaryEncodeU32 and
binaryCodeU64 can't fail (short of failure to expand a std::vector).
2015-10-26 12:55:33 -04:00
Dejan Mircevski
cc936dc613 Negative test for FunctionControl. 2015-10-26 12:55:33 -04:00
Dejan Mircevski
2fc334c701 Negative test for LoopControl. 2015-10-26 12:55:33 -04:00
Dejan Mircevski
8386c57d0c Negative test for SelectionControl. 2015-10-26 12:55:33 -04:00
Dejan Mircevski
c002213d95 Negative test for GroupOperation. 2015-10-26 12:55:33 -04:00
Dejan Mircevski
9d0c813547 Negative test for LinkageType. 2015-10-26 12:55:33 -04:00
Dejan Mircevski
d7b0f83bd1 Negative test for BuiltIn. 2015-10-26 12:55:33 -04:00