platform/upstream/SPIRV-Tools.git
6 years agoAndroid.mk: add source/opt/fold.cpp
David Neto [Wed, 18 Oct 2017 14:28:12 +0000 (10:28 -0400)]
Android.mk: add source/opt/fold.cpp

6 years agoMerge pull request #885 from dnovillo/const-prop
Diego Novillo [Wed, 18 Oct 2017 12:37:00 +0000 (08:37 -0400)]
Merge pull request #885 from dnovillo/const-prop

Re-factor generic constant folding code out of fold spec constants pass

6 years agoRe-factor generic constant folding code out of FoldSpecConstantOpAndCompositePass
Diego Novillo [Tue, 17 Oct 2017 23:41:37 +0000 (19:41 -0400)]
Re-factor generic constant folding code out of FoldSpecConstantOpAndCompositePass

There are no functional changes in this patch.  The generic folding
routines in FoldSpecConstantOpAndCompositePass are now inside opt/fold.{cpp,h}.
This code will be used by the upcoming constant propagation pass.  In
time, we'll add more expression folding and simplification into these
two files.

6 years agoADCE: Treat privates like locals in entry point with no calls
GregF [Tue, 10 Oct 2017 20:35:53 +0000 (14:35 -0600)]
ADCE: Treat privates like locals in entry point with no calls

This is needed for ongoing legalization of HLSL. It allows removal
of accesses to textures/buffers that are not used.

6 years agoOpt: Move *NextId functionality into MemPass
GregF [Tue, 10 Oct 2017 23:16:50 +0000 (17:16 -0600)]
Opt: Move *NextId functionality into MemPass

6 years agoValidator: Test OpReturnValue type check
David Neto [Thu, 12 Oct 2017 19:20:29 +0000 (15:20 -0400)]
Validator: Test OpReturnValue type check

The check already existed.  I added a test for it.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/876

6 years agoReenable validate type unique pass
Andrey Tuganov [Wed, 11 Oct 2017 15:34:38 +0000 (11:34 -0400)]
Reenable validate type unique pass

Vulkan CTS patch fixing the instances of non-unique type declaration in
autogenerated code has recently been submitted.

6 years agoRefactored MARK-V API
Andrey Tuganov [Tue, 3 Oct 2017 21:36:37 +0000 (17:36 -0400)]
Refactored MARK-V API

- switched from C to C++
- moved MARK-V model creation from backend to frontend
- The same MARK-V model object can be used to encode/decode multiple
files
- Added MARK-V model factory (currently only one option)
- Added --validate option to spirv-markv (run validation while
encoding/decoding)

6 years agoValidator checks OpReturn called from void func
Andrey Tuganov [Wed, 11 Oct 2017 22:13:21 +0000 (18:13 -0400)]
Validator checks OpReturn called from void func

Added check into validate_cfg which checks that OpReturn is not called
from functions which are supposed to return a value.

6 years agoGeneric intrusive linked list class.
Steven Perron [Tue, 10 Oct 2017 13:47:01 +0000 (09:47 -0400)]
Generic intrusive linked list class.

This commit is the initial implementation of the intrusive linked list
class.  It includes the implementation in the header files, and unit
test.

The iterators are circular: incrementing end() gives begin() and
decrementing begin() gives end().  Also made it valid to
decrement end().

Expliticly defines move constructor and move assignment
- Visual Studio 2013 does not implicitly generate the move constructor or
  move assignments.  So they need to be explicit, otherwise it will try to
  use the copy constructor, which we explicitly deleted.
- Can't use "= default" either.
  Seems like VS2013 does not support explicitly using the default move
  constructors and move assignments, so I wrote them out.

6 years agoDeadBranchElim: Add dead case elimination
GregF [Fri, 6 Oct 2017 02:37:00 +0000 (20:37 -0600)]
DeadBranchElim: Add dead case elimination

Expands dead branch elimination to eliminate dead switch cases. It also
changes dbe to eliminate orphaned merge blocks and recursively eliminate
any blocks thereby orphaned.

6 years agoAdd Android.mk to SPIRV-Tools
Andrey Tuganov [Thu, 5 Oct 2017 23:07:31 +0000 (19:07 -0400)]
Add Android.mk to SPIRV-Tools

Android.mk was migrated from shaderc/third_party.

android_test is a stub, only builds spirv-tools libs.h to test build.

6 years agoAdd -O, -Os and -Oconfig flags.
Diego Novillo [Wed, 30 Aug 2017 18:19:22 +0000 (14:19 -0400)]
Add -O, -Os and -Oconfig flags.

These flags are expanded to a series of spirv-opt flags with the
following semantics:

-O: expands to passes that attempt to improve the performance of the
    generated code.

-Os: expands to passes that attempt to reduce the size of the generated
     code.

-Oconfig=<file> expands to the sequence of passes determined by the
                flags specified in the user-provided file.

6 years agoSet cmake-policy CMP0048 to NEW
Tim Diekmann [Tue, 10 Oct 2017 12:23:42 +0000 (14:23 +0200)]
Set cmake-policy CMP0048 to NEW

6 years agoImplement Linker (module combiner)
Pierre Moreau [Thu, 13 Jul 2017 00:16:51 +0000 (02:16 +0200)]
Implement Linker (module combiner)

Add extra iterators for ir::Module's sections
Add extra getters to ir::Function
Add a const version of BasicBlock::GetLabelInst()

Use the max of all inputs' version as version

Split debug in debug1 and debug2
- Debug1 instructions have to be placed before debug2 instructions.

Error out if different addressing or memory models are found

Exit early if no binaries were given

Error out if entry points are redeclared

Implement copy ctors for Function and BasicBlock
- Visual Studio ends up generating copy constructors that call deleted
  functions while compiling the linker code, while GCC and clang do not.
  So explicitly write those functions to avoid Visual Studio messing up.

Move removing duplicate capabilities to its own pass

Add functions running on all IDs present in an instruction

Remove duplicate SpvOpExtInstImport

Give default options value for link functions

Remove linkage capability if not making a library

Check types before allowing to link

Detect if two types/variables/functions have different decorations

Remove decorations of imported variables/functions and their types

Add a DecorationManager

Add a method for removing all decorations of id

Add methods for removing operands from instructions

Error out if one of the modules has a non-zero schema

Update README.md to talk about the linker

Do not freak out if an imported built-in variable has no export

6 years agoRemove duplicate dead branch elim pass declaration
Andrey Tuganov [Thu, 5 Oct 2017 20:26:09 +0000 (16:26 -0400)]
Remove duplicate dead branch elim pass declaration

The function had two declarations in the same header with somewhat
different comments.

6 years agoHack around bug in gcc-4.8.1 templates.
Andrew Woloszyn [Thu, 5 Oct 2017 15:01:34 +0000 (11:01 -0400)]
Hack around bug in gcc-4.8.1 templates.

This keeps the previous behavior for other compilers that will
throw warnings on a negative shift operation, but works around
the internal compiler error in GCC.

6 years agoAggressiveDCE: Fix to not treat parameter memory refs as local
GregF [Fri, 29 Sep 2017 22:22:39 +0000 (16:22 -0600)]
AggressiveDCE: Fix to not treat parameter memory refs as local

This fixes a bug that incorrectly deletes stores to parameters, which
can be used to return values from functions.

6 years agoCompact-ids pass should update the header ID bound
Pierre Moreau [Sun, 1 Oct 2017 19:47:44 +0000 (21:47 +0200)]
Compact-ids pass should update the header ID bound

6 years agoDiagnosticStream move ctor moves output duties to new object
David Neto [Sun, 1 Oct 2017 13:27:00 +0000 (09:27 -0400)]
DiagnosticStream move ctor moves output duties to new object

- Take over contents of the expiring message stream
- Prevent the expiring object from emitting anything during destruction

6 years agoCache end iterators for speed
David Neto [Thu, 28 Sep 2017 15:14:00 +0000 (11:14 -0400)]
Cache end iterators for speed

Helps scaling of DefUseManager on modules with many thousands
of instructions.

6 years agoNo use to check OpBitCount result width
jcaraban [Fri, 29 Sep 2017 05:55:41 +0000 (08:55 +0300)]
No use to check OpBitCount result width

6 years agoSkip checking copyright if SPIRV_SKIP_TESTS is enabled
Lei Zhang [Thu, 28 Sep 2017 01:22:05 +0000 (21:22 -0400)]
Skip checking copyright if SPIRV_SKIP_TESTS is enabled

6 years agoUpdate CHANGES to reflect fix for #827
David Neto [Wed, 27 Sep 2017 14:03:20 +0000 (10:03 -0400)]
Update CHANGES to reflect fix for #827

6 years agoCompact-ids pass should update instruction's result_id member
David Neto [Tue, 26 Sep 2017 22:05:27 +0000 (18:05 -0400)]
Compact-ids pass should update instruction's result_id member

Also update the result type field.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/827

6 years agoRemove duplicated declaration of CreateAggressiveDCEPass().
Lei Zhang [Tue, 26 Sep 2017 17:55:23 +0000 (13:55 -0400)]
Remove duplicated declaration of CreateAggressiveDCEPass().

6 years agoAdd bitwise operations validator pass
Andrey Tuganov [Mon, 18 Sep 2017 20:49:11 +0000 (16:49 -0400)]
Add bitwise operations validator pass

The pass checks correctness of operand types of all bitwise instructions
(opcode range from SpvOpShiftRightLogical to SpvOpBitCount).

6 years agoAdd remaining opcodes to arithmetics validation
Andrey Tuganov [Mon, 18 Sep 2017 17:06:40 +0000 (13:06 -0400)]
Add remaining opcodes to arithmetics validation

Add validation rules for:
- OpIAddCarry
- OpISubBorrow
- OpUMulExtended
- OpSMulExtended

Includes some refactoring of old code.

6 years agoUpdate CHANGES with recent news
David Neto [Tue, 26 Sep 2017 15:30:57 +0000 (11:30 -0400)]
Update CHANGES with recent news

6 years agoCreate the dead function elimination pass
Steven Perron [Tue, 19 Sep 2017 14:12:13 +0000 (10:12 -0400)]
Create the dead function elimination pass

Creates a pass called eliminate dead functions that looks for functions
that could never be called, and deletes them from the module.

To support this change a new function was added to the Pass class to
traverse the call trees from diffent starting points.

Includes a test to ensure that annotations are removed when deleting a
dead function.  They were not, so fixed that up as well.

Did some cleanup of the assembly for the test in pass_test.cpp.  Trying
to make them smaller and easier to read.

6 years agoDetach MARK-V from the validator
Andrey Tuganov [Mon, 25 Sep 2017 18:55:44 +0000 (14:55 -0400)]
Detach MARK-V from the validator

MARK-V codec was previously dependent on the validation state.
Now it doesn't need the validator to function, but can still optionally
create it and validate every instruction once it's decoded.

6 years agoAvoid using global static variables
Lei Zhang [Thu, 21 Sep 2017 21:24:57 +0000 (17:24 -0400)]
Avoid using global static variables

Previously we have several grammar tables defined as global static
variables and these grammar table entries contains non-POD struct
fields (CapabilitySet/ExtensionSet). The initialization of these
non-POD struct fields may require calling operator new. If used
as a library and the caller defines its own operator new, things
can screw up.

This pull request changes all global static variables into
function static variables, which is lazy evaluated in a thread
safe way as guaranteed by C++11.

6 years agoAdd SPIRV_SPIRV_COMPRESSION option to cmake
Andrey Tuganov [Mon, 25 Sep 2017 16:45:48 +0000 (12:45 -0400)]
Add SPIRV_SPIRV_COMPRESSION option to cmake

The option is off by default.
cmake -DSPIRV_BUILD_COMPRESSION=ON ..
enables the compression lib, executable, and test build.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/834

6 years agoMerge pull request #829 from atgoo/fix_val_logicals
Ehsan [Thu, 21 Sep 2017 22:50:09 +0000 (18:50 -0400)]
Merge pull request #829 from atgoo/fix_val_logicals

Validator: fix logicals pass for OpSelect pointers

6 years agoValidator: fix logicals pass for OpSelect pointers
Andrey Tuganov [Thu, 21 Sep 2017 20:12:14 +0000 (16:12 -0400)]
Validator: fix logicals pass for OpSelect pointers

OpSelect works with pointers also when capability
VariablePointersStorageBuffer is declared (before worked only with
capability VariablePointers).

6 years agoelim-multi-store: only patch loop header phis that we created
David Neto [Wed, 20 Sep 2017 15:07:55 +0000 (11:07 -0400)]
elim-multi-store: only patch loop header phis that we created

There can already be OpPhi instructions in a loop header that
are unrelated to the optimization.  We should not be patching those.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/826

6 years agoAdd validate logicals pass to the validator
Andrey Tuganov [Thu, 7 Sep 2017 21:27:57 +0000 (17:27 -0400)]
Add validate logicals pass to the validator

New pass checks operands of all instructions listed under
3.32.15. Relational and Logical Instructions

6 years agoRefactored validate_aritmetics.cpp
Andrey Tuganov [Mon, 18 Sep 2017 21:07:00 +0000 (17:07 -0400)]
Refactored validate_aritmetics.cpp

Improved error messages and readability.

6 years agoUpdated markv_autogen
Andrey Tuganov [Wed, 6 Sep 2017 20:44:15 +0000 (16:44 -0400)]
Updated markv_autogen

- now includes a table of all descriptors with coding scheme
(improves performance by 5% by allowing to avoid creation of
move-to-front sequences which will never be used)
- increased the size of markv_autogen.inc, clang doesn't seem
to have the long compilation time problem now
(probably was inadvertently fixed by using Huffman codec
serialization)

6 years agoElimLocalMultiStore: Reset structured successors for each function
Greg Fischer [Tue, 19 Sep 2017 19:47:28 +0000 (13:47 -0600)]
ElimLocalMultiStore: Reset structured successors for each function

6 years agoAdd strength reduction; for now replace multiply by power of 2
Steven Perron [Fri, 8 Sep 2017 16:08:03 +0000 (12:08 -0400)]
Add strength reduction; for now replace multiply by power of 2

Create a new optimization pass, strength reduction, which will replace
integer multiplication by a constant power of 2 with an equivalent bit
shift.  More changes could be added later.

- Does not duplicate constants

- Adds vector |Concat| utility function to a common test header.

6 years agoExtractInsert: Handle rudimentary CompositeConstruct and ConstantComposite
GregF [Wed, 13 Sep 2017 00:15:09 +0000 (18:15 -0600)]
ExtractInsert: Handle rudimentary CompositeConstruct and ConstantComposite

This optimizes a single index extract whose composite value terminates with a
CompositeConstruct (or ConstantComposite) by evaluating to the correct
component. This was needed for opaque legalization.

This highlights the need/opportunity to improve this optimization to deal
with more complex composite expressions including currently handled ops
plus Null ops and special vector composition. A TODO has been added.

6 years agoRecognize SPV_AMD_shader_fragment_mask
David Neto [Thu, 14 Sep 2017 14:35:22 +0000 (10:35 -0400)]
Recognize SPV_AMD_shader_fragment_mask

6 years agoAdd new checks to validate arithmetics pass
Andrey Tuganov [Wed, 6 Sep 2017 18:30:27 +0000 (14:30 -0400)]
Add new checks to validate arithmetics pass

New operations:
- OpDot
- OpVectorTimesScalar
- OpMatrixTimesScalar
- OpVectorTimesMatrix
- OpMatrixTimesVector
- OpMatrixTimesMatrix
- OpOuterProduct

6 years agoUpdate CHANGES for OpModuleProcessed validation rule
David Neto [Fri, 8 Sep 2017 13:16:15 +0000 (09:16 -0400)]
Update CHANGES for OpModuleProcessed validation rule

6 years agovalidator: OpModuleProcessed allowed in layout section 7c
David Neto [Thu, 7 Sep 2017 21:38:31 +0000 (17:38 -0400)]
validator: OpModuleProcessed allowed in layout section 7c

Recent spec fix from SPIR Working group:
  Allow OpModuleProcessed after debug names, but before any
  annotation instructions.

7 years agoUpdate MARK-V to version 1.01
Andrey Tuganov [Wed, 9 Aug 2017 18:01:12 +0000 (14:01 -0400)]
Update MARK-V to version 1.01

Includes:
- Multi-sequence move-to-front
- Coding by id descriptor
- Statistical coding of non-id words
- Joint coding of opcode and num_operands

Removed explicit form Huffman codec constructor
- The standard use case for it is to be constructed from initializer list.

Using serialization for Huffman codecs

7 years agospirv-as: Fail for unrecognized long option
David Neto [Fri, 1 Sep 2017 22:12:15 +0000 (18:12 -0400)]
spirv-as: Fail for unrecognized long option

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/798

7 years agoInliner: Fix LoopMerge when inline into loop header of multi block loop
David Neto [Sat, 2 Sep 2017 23:01:03 +0000 (19:01 -0400)]
Inliner: Fix LoopMerge when inline into loop header of multi block loop

This adapts the fix for the single-block loop.  Split the loop like
before.  But when we move the OpLoopMerge back to the loop header,
redirect the continue target only when the original loop was a single
block loop.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/800

7 years agoAdd validation pass for arithmetic operations
Andrey Tuganov [Wed, 30 Aug 2017 14:13:10 +0000 (10:13 -0400)]
Add validation pass for arithmetic operations

The pass checks if arithmetic operations (such as OpFMul) receive
correct operands.

7 years agoMake enums for all currently published extensions
David Neto [Thu, 17 Aug 2017 17:53:14 +0000 (13:53 -0400)]
Make enums for all currently published extensions

Use the list from the SPIR-V registry page.  Also, capture it as
a string so it's much easier to update via copy-paste.

The validator will accept modules that declare these known
extensions.  However, we might not know about new tokens or
instructions declared in them.  For that we need grammar updates
applied to SPIRV-Headers.

7 years agoStarge v2017.1-dev
David Neto [Fri, 1 Sep 2017 20:28:22 +0000 (16:28 -0400)]
Starge v2017.1-dev

7 years agoCreate v2017.0
David Neto [Fri, 1 Sep 2017 20:24:27 +0000 (16:24 -0400)]
Create v2017.0

Update README to describe that we understand SPIR-V syntax based on the
grammar files included from the SPIRV-Headers repo.

(Also, it's high time we issue a v2017 release!

7 years agoFinalize v2016.7
David Neto [Fri, 1 Sep 2017 20:14:25 +0000 (16:14 -0400)]
Finalize v2016.7

7 years agoUpdate CHANGES for recent inliner fixes
David Neto [Fri, 1 Sep 2017 20:13:12 +0000 (16:13 -0400)]
Update CHANGES for recent inliner fixes

7 years agoFix mingw build (source/print.cpp)
Andrey Tuganov [Mon, 28 Aug 2017 22:36:52 +0000 (18:36 -0400)]
Fix mingw build (source/print.cpp)

source/print.cpp doesn't compile due to integer conversion.

Tested by @dneto0 on a Windows machine.

7 years agoInliner: Remap callee entry block id to single-trip loop header
David Neto [Thu, 31 Aug 2017 21:33:44 +0000 (17:33 -0400)]
Inliner: Remap callee entry block id to single-trip loop header

Otherwise cloned phis can be invalid.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/790

7 years agoInline: Fix single-block loop caller cases
David Neto [Thu, 31 Aug 2017 19:47:31 +0000 (15:47 -0400)]
Inline: Fix single-block loop caller cases

If the caller block is a single-block loop and inlining will
replace the caller block by several blocks, then:
- The original OpLoopMerge instruction will end up in the *last*
  such block.  That's the wrong place to put it.
- Move it back to the end of the first block.
- Update its Continue Target ID to point to the last block

We also have to take care of cases where the inlined code
begins with a structured header block.  In this case
we need to ensure the restored OpLoopMerge does not appear
in the same block as the merge instruction from the callee's
first block.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/787

7 years agoBasicBlock: add ctail, GetMergeInst, GetLoopMergeInst
David Neto [Thu, 31 Aug 2017 15:37:17 +0000 (11:37 -0400)]
BasicBlock: add ctail, GetMergeInst, GetLoopMergeInst

7 years agoUpdate tests for new preferred name as ShaderViewportIndexLayerEXT
David Neto [Fri, 1 Sep 2017 14:26:41 +0000 (10:26 -0400)]
Update tests for new preferred name as ShaderViewportIndexLayerEXT

This reacts to a recent update to SPIRV-Headers

7 years agoUpdate CHANGES for fix to 781
David Neto [Fri, 1 Sep 2017 14:15:42 +0000 (10:15 -0400)]
Update CHANGES for fix to 781

7 years agoExtension allows multiple same OpTypePointer types
Andrey Tuganov [Tue, 29 Aug 2017 20:25:23 +0000 (16:25 -0400)]
Extension allows multiple same OpTypePointer types

SPV_KHR_variable_pointers allows OpTypePointer to declare multiple
pointer identical types.

https://github.com/KhronosGroup/SPIRV-Tools/issues/781

7 years agoUpdate CHANGES for fix to 776
David Neto [Wed, 30 Aug 2017 18:25:23 +0000 (14:25 -0400)]
Update CHANGES for fix to 776

7 years agoDeadBranchElim: Fix dead block detection to ignore backedges
GregF [Wed, 23 Aug 2017 23:05:38 +0000 (17:05 -0600)]
DeadBranchElim: Fix dead block detection to ignore backedges

- DeadBranchElim: Make sure to mark orphan'd merge blocks and continue
targets as live.
- Add test with loop in dead branch
- Add test that orphan'd merge block is handled.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/776

7 years agoInlineOpaque: Remove from usage until complete Opaque policy is designed.
GregF [Tue, 29 Aug 2017 00:02:14 +0000 (18:02 -0600)]
InlineOpaque: Remove from usage until complete Opaque policy is designed.

7 years agoUpdate changes for fix to issue 782
David Neto [Wed, 30 Aug 2017 03:22:07 +0000 (23:22 -0400)]
Update changes for fix to issue 782

7 years agoInline: Fix remapping of non-label forward references in callee phi
GregF [Wed, 30 Aug 2017 00:35:05 +0000 (18:35 -0600)]
Inline: Fix remapping of non-label forward references in callee phi

7 years agoDisassembler: Print colour codes only when writing to a terminal
David Neto [Mon, 28 Aug 2017 14:30:58 +0000 (10:30 -0400)]
Disassembler: Print colour codes only when writing to a terminal

7 years agoFix encode zero bits on word boundary bug
Andrey Tuganov [Mon, 28 Aug 2017 17:18:45 +0000 (13:18 -0400)]
Fix encode zero bits on word boundary bug

Bit stream writer was manifesting incorrect behaviour when the following
two conditions were met:
- writer was on 64-bit word boundary
- WriteBits was invoked with num_bits=0 (can happen when a Huffman codec has only one
value)

The bug was causing very rare sporadic corruption which was detected by
tests after a random experimental change in MARK-V model.

7 years agoShow result id for CompositeInsert validation failure
David Neto [Thu, 24 Aug 2017 22:11:23 +0000 (18:11 -0400)]
Show result id for CompositeInsert validation failure

7 years agoREADME: Add reference to SPIR-V size reduction white paper
GregF [Thu, 24 Aug 2017 22:36:53 +0000 (16:36 -0600)]
README: Add reference to SPIR-V size reduction white paper

7 years agoWindows: Increase intensity of blue text
David Neto [Thu, 24 Aug 2017 14:34:00 +0000 (10:34 -0400)]
Windows: Increase intensity of blue text

7 years agoFix: background color was erroneously reset on Win32 platform.
Lukas Hermanns [Sun, 20 Aug 2017 12:11:50 +0000 (14:11 +0200)]
Fix: background color was erroneously reset on Win32 platform.

Fix: background color was erroneously reset on Win32 platform.

7 years agoUpdated capabilites for SampleMask
David Neto [Wed, 23 Aug 2017 17:28:48 +0000 (13:28 -0400)]
Updated capabilites for SampleMask

SPIRV-Headers recently fixed the capability dependency
for SampleMask.  It depends on Shader, not SampleRateShading

7 years agoOpt: Create InlineOpaquePass
GregF [Tue, 15 Aug 2017 23:58:28 +0000 (17:58 -0600)]
Opt: Create InlineOpaquePass

Only inline calls to functions with opaque params or return

TODO: Handle parameter type or return type where the opqaue
type is buried within an array.

7 years agoOpt: Have "size" passes process full entry point call tree.
GregF [Thu, 10 Aug 2017 22:42:16 +0000 (16:42 -0600)]
Opt: Have "size" passes process full entry point call tree.

Includes code to deal correctly with OpFunctionParameter. This
is needed by opaque propagation which may not exhaustively inline
entry point functions.

Adds ProcessEntryPointCallTree: a method to do work on the
functions in the entry point call trees in a deterministic order.

7 years agoSupport supplying extra definitions via CMAKE variable
Lei Zhang [Wed, 16 Aug 2017 20:42:50 +0000 (16:42 -0400)]
Support supplying extra definitions via CMAKE variable

7 years agoHuffman codec can serialize to text
Andrey Tuganov [Fri, 11 Aug 2017 20:51:24 +0000 (16:51 -0400)]
Huffman codec can serialize to text

Refactored the Huffman codec implementation and added ability to
serialize to C++-like text format. This would reduce the time-complexity
if loading hard-coded codecs.

7 years agoOpt: Add opaque tests
GregF [Tue, 15 Aug 2017 21:54:41 +0000 (15:54 -0600)]
Opt: Add opaque tests

7 years agoAdd id descriptor feature to SPIR-V
Andrey Tuganov [Wed, 2 Aug 2017 20:47:25 +0000 (16:47 -0400)]
Add id descriptor feature to SPIR-V

Id descriptors are computed as a recursive hash of all instructions used
to define an id. Descriptors are invarint of actual id values and
the similar code in different files would produce the same descriptors.

Multiple ids can have the same descriptor. For example
%1 = OpConstant %u32 1
%2 = OpConstant %u32 1
would produce two ids with the same descriptor. But
%3 = OpConstant %s32 1
%4 = OpConstant %u32 2
would have descriptors different from %1 and %2.

Descriptors will be used as handles of move-to-front sequences in SPIR-V
compression.

7 years agoADCE: Add support for function calls
GregF [Fri, 4 Aug 2017 21:04:37 +0000 (15:04 -0600)]
ADCE: Add support for function calls

ADCE will now generate correct code in the presence of function calls.
This is needed for opaque type optimization needed by glslang. Currently
all function calls are marked as live. TODO: mark calls live only if they
write a non-local.

7 years agoUpdate CHANGE to list fix for issue 755
David Neto [Thu, 10 Aug 2017 17:13:33 +0000 (13:13 -0400)]
Update CHANGE to list fix for issue 755

7 years agoInliner: callee can have early return that isn't multi-return
David Neto [Wed, 9 Aug 2017 18:59:04 +0000 (14:59 -0400)]
Inliner: callee can have early return that isn't multi-return

Avoid generating an invalid OpLabel.
Create the continue target for the single-trip loop only if
you actually created the header for the single-trip loop.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/755

7 years agoAccessChainConvert: Add HasOnlySupportedRefs()
GregF [Fri, 4 Aug 2017 18:00:30 +0000 (12:00 -0600)]
AccessChainConvert: Add HasOnlySupportedRefs()

This avoids conversion on variables which will not ultimately be optimized.
Also removed an obsolete restriction from FindTargetVars(). Also added
decorates to supported refs (eg. RelaxedPrecision). Also fixed name to
IsNonTypeDecorate().

7 years agoInline: Split out InlineExhaustivePass from InlinePass
GregF [Tue, 1 Aug 2017 23:20:13 +0000 (17:20 -0600)]
Inline: Split out InlineExhaustivePass from InlinePass

7 years agoMem2Reg: Allow Image and Sampler types as base target types.
GregF [Thu, 3 Aug 2017 23:27:02 +0000 (17:27 -0600)]
Mem2Reg: Allow Image and Sampler types as base target types.

7 years agoUpdate CHANGES with common uniform loads pass
David Neto [Fri, 4 Aug 2017 21:48:22 +0000 (17:48 -0400)]
Update CHANGES with common uniform loads pass

7 years agoUpdate README.md with new code-reduction passes
GregF [Thu, 3 Aug 2017 16:37:26 +0000 (10:37 -0600)]
Update README.md with new code-reduction passes

7 years agoAdd CommonUniformElim pass
GregF [Mon, 3 Jul 2017 23:23:04 +0000 (17:23 -0600)]
Add CommonUniformElim pass

- UniformElim: Only process reachable blocks

- UniformElim: Don't reuse loads of samplers and images across blocks.
  Added a second phase which only reuses loads within a block for samplers
  and images.

- UniformElim: Upgrade CopyObject skipping in GetPtr

- UniformElim: Add extensions whitelist
  Currently disallowing SPV_KHR_variable_pointers because it doesn't
  handle extended pointer forms.

- UniformElim: Do not process shaders with GroupDecorate

- UniformElim: Bail on shaders with non-32-bit ints.

- UniformElim: Document support for only single index and add TODO.

7 years agoAdd MemPass, move all shared functions to it.
GregF [Thu, 27 Jul 2017 19:30:12 +0000 (13:30 -0600)]
Add MemPass, move all shared functions to it.

7 years agoAdd multi-sequence move-to-front implementation
Andrey Tuganov [Mon, 24 Jul 2017 18:29:35 +0000 (14:29 -0400)]
Add multi-sequence move-to-front implementation

Add MultiMoveToFront class which supports multiple move-to-front
sequences and allows to promote value in all sequences at once.

Added caching for last accessed sequence handle and last accessed value
in each sequence.

7 years agoUpdate CHANGES with recently added optimizations
David Neto [Tue, 1 Aug 2017 19:33:15 +0000 (15:33 -0400)]
Update CHANGES with recently added optimizations

7 years agoOpt: Add new size-reduction passes to usage message.
GregF [Tue, 1 Aug 2017 18:55:29 +0000 (12:55 -0600)]
Opt: Add new size-reduction passes to usage message.

7 years agoAdded C++ code generation to spirv-stats
Andrey Tuganov [Mon, 31 Jul 2017 17:08:38 +0000 (13:08 -0400)]
Added C++ code generation to spirv-stats

The tool can now generate C++ code returning some of the historgrams and
Huffman codecs generated from those historgrams.

7 years agoAdd Appveyor config that uses VS 2017
David Neto [Tue, 1 Aug 2017 15:42:28 +0000 (11:42 -0400)]
Add Appveyor config that uses VS 2017

7 years agoOpt: Delete names and decorations of dead instructions
GregF [Wed, 26 Jul 2017 22:34:41 +0000 (18:34 -0400)]
Opt: Delete names and decorations of dead instructions

7 years agoOpt: HasOnlySupportedRefs should consider OpCopyObject
Lei Zhang [Mon, 24 Jul 2017 15:43:47 +0000 (11:43 -0400)]
Opt: HasOnlySupportedRefs should consider OpCopyObject

This fixes test failure after merging the previous pull request.

7 years agoRevert "Revert "Opt: LocalBlockElim: Add HasOnlySupportedRefs""
Lei Zhang [Mon, 24 Jul 2017 14:37:38 +0000 (10:37 -0400)]
Revert "Revert "Opt: LocalBlockElim: Add HasOnlySupportedRefs""

This reverts commit df96e243c633b939690a42d89904e04f50126e86.

7 years agoAdd extension whitelists to size-reduction passes.
GregF [Wed, 19 Jul 2017 00:57:26 +0000 (18:57 -0600)]
Add extension whitelists to size-reduction passes.

Currently only SPV_KHR_variable_pointers is disallowed in passes which
do pointer analysis. Positive and negative tests of the general extensions
mechanism were added to aggressive_dce but cover all passes.

7 years agoRevert "Opt: LocalBlockElim: Add HasOnlySupportedRefs"
Lei Zhang [Sat, 22 Jul 2017 14:48:28 +0000 (10:48 -0400)]
Revert "Opt: LocalBlockElim: Add HasOnlySupportedRefs"

This reverts commit 2d0f7fbc1151004c4cf111b947f1070a03dfe092.