Commit Graph

942 Commits

Author SHA1 Message Date
qining
f4e3a905d4 Add the const version of AsXXtype() interface. 2016-08-11 17:13:43 -04:00
qining
cd6d6c0ccf Add GetId(Type* type) API to the type manager 2016-08-11 15:10:09 -04:00
David Neto
892239b7cc Avoid double-copy of NameMapper object. 2016-08-11 12:11:36 -04:00
David Neto
8a5ce18f12 Use friendly names for Ids 2016-08-11 11:30:18 -04:00
David Neto
996a814ae3 Add spirv-cfg to dump a GraphViz graph of the CFG
This is experimental, and has not tests.
It's been used to debug validation of structured control flow.

- Has a legend describing special arcs to merge blocks and continue
  targets.
- Labels the function entry block, with the Id of the function.
2016-08-11 11:24:51 -04:00
qining
23266c9b56 Add back the missing msg about --eliminate-dead-const 2016-08-10 19:44:18 -04:00
Lei Zhang
75d4316280 Fix build error about passing initializer-list to constructor.
VS2013 is not happy with using initializer-list to initialize
vector parameters to explicit constructors taking one vector.
2016-08-10 16:10:14 -04:00
Lei Zhang
dda9de965d Make type manager RAII-like w.r.t. the module to be analyzed. 2016-08-10 12:53:17 -04:00
Lei Zhang
c562e231e3 Optimization: Add type manager.
Type manager will construct a map of types gradually from
instructions.
2016-08-10 12:53:17 -04:00
Lei Zhang
6d4d15b9d0 Optimization: Add type class hierarchy. 2016-08-10 12:53:17 -04:00
Lei Zhang
478d96aac4 Appveyor: also test on Visual Studio 2013. 2016-08-10 12:52:11 -04:00
David Neto
75c6db0746 Fix paths in the README. 2016-08-10 12:18:22 -04:00
Lei Zhang
80c94a4fa8 Change the interfaces of in-memory representation to use pointers.
Previously we use vectors of objects and move semantics to handle
ownership. That approach has the flaw that inserting an object into
the middle of a vector, which may trigger a vector reallocation,
can invalidate some addresses taken from instructions.

Now the in-memory representation internally uses vector of unique
pointers to handle ownership. Since objects are explicitly heap-
allocated now, pointers to them won't be invalidated by vector
resizing anymore.
2016-08-10 12:11:33 -04:00
David Neto
7784829b3a Update CHANGES to say issue 288 is fixed 2016-08-10 10:40:59 -04:00
Andrew Woloszyn
38c9471a0e Fixed the build for MSVC.
assembly_builder was missing an include for cstdint.
2016-08-10 09:45:15 -04:00
Lei Zhang
485f513a29 Manually create move the constructor/assignment for Instruction.
This is because some old visual studio versions (e.g., 2013) do
not support automatically generating move constructors/assignments.
2016-08-09 19:27:13 -04:00
David Neto
677ae7fbe8 Fix compilation. My bad
The API changed, and I forgot to submit this patch.
2016-08-09 18:23:40 -04:00
Umar Arshad
489204cf03 Check dominance of OpPhi parent and variable pairs 2016-08-09 18:19:47 -04:00
Umar Arshad
8ea1268f84 Removed dead code/const_casts/lists 2016-08-09 18:09:38 -04:00
qining
60461428f4 Separate pass.h from passes.h
Future pass implementations should only need to include pass.h
2016-08-09 17:16:52 -04:00
Lei Zhang
190b0d3162 Use NEW behavior for policy CMP0054.
The NEW behavior is to not dereference variables or interpret keywords
that have been quoted or bracketed.

For more information, see
https://cmake.org/cmake/help/v3.1/policy/CMP0054.html.

This is to suppress a warning when using CMake 3.1.3+.
2016-08-09 16:09:59 -04:00
Umar Arshad
816f29805b Refactor Id -> Instruction 2016-08-09 15:50:03 -04:00
qining
d49928f0cc Fix minor mistakes in the tests of dead-const-elim 2016-08-09 14:37:58 -04:00
qining
a90fc84779 Print the shader when module building failed 2016-08-08 17:19:47 -04:00
qining
51a2484b36 Dead constant elimination
A pass to remove dead constants, including both front-end constants and spec
constants.

This pass does not handle dead variables and types.
2016-08-08 17:17:15 -04:00
Umar Arshad
fd965c9e7e Remove unnecessary headers 2016-08-07 10:11:49 -04:00
Umar Arshad
ffa42994fd Remove needless copies. Delete copy constructor.
* Deletes the ValidationState_t copy constructor
* Removes needless copies of the copy constructor
2016-08-06 12:24:19 -04:00
David Neto
c296701964 Add target envs for OpenCL, OpenGL
Covers: OpenCL 2.1, OpenCL 2.2
Covers: OpenGL 4.0, OpenGL 4.1, OpenGL 4.2, OpenGL 4.3, OpenGL 4.5.
The OpenGL environments assume the use of GL_ARB_gl_spirv, of course.
2016-08-05 18:19:30 -04:00
David Neto
aa3031273f Start v2016.3-dev 2016-08-05 17:10:36 -04:00
David Neto
8e3ac3ca58 Finalize v2016.2
Document recently fixed bugs.
2016-08-05 17:08:20 -04:00
David Neto
e712f826b6 Hide implementations of BasicBlock::dominates,postdominates 2016-08-05 16:55:21 -04:00
David Neto
605847f15b Track a construct by its entry block. 2016-08-05 16:05:44 -04:00
David Neto
b51b80980c Validator cfg fixes
- Find unreachable continue targets.  Look for back edges
  with a DFS traversal separate from the dominance traversals,
  where we count the OpLoopMerge from the header to the continue
  target as an edge in the graph.

- It's ok for a loop to have multiple back edges, provided
  they are all from the same block, and we call that the latch block.
  This may require a clarification/fix in the SPIR-V spec.

- Compute postdominance correctly for infinite loop:
  Bias *predecessor* traversal root finding so that you use
  a later block in the original list.  This ensures that
  for certain simple infinite loops in the CFG where neither
  block branches to a node without successors, that we'll
  compute the loop header as dominating the latch block, and the
  latch block as postdominating the loop header.
2016-08-05 15:15:37 -04:00
David Neto
3bf4dc102f Add BasicBlock methods: dominates postdominates 2016-08-05 15:14:18 -04:00
David Neto
bb4c0b1af6 Rename a variable so it's consistent with spec
In the spec "continue block" is a block with a branch
to the Continue Target.  It's not the Continue Target.
2016-08-05 15:12:47 -04:00
Lei Zhang
71fac5a29c Check configuration and gmock existence when adding unit tests. 2016-08-05 14:38:18 -04:00
David Neto
3184687714 Fix dominance calculation
Fixes dominance calculation when there is a forward arc from an
unreachable block A to a reachable block B.  Before this fix, we would
say that B is not dominated by the graph entry node, and instead say
that the immediate dominator of B is the psuedo-entry node of the
augmented CFG.

The fix:

- Dominance is defined in terms of a traversal from the entry block
  of the CFG.  So the forward DFS should start from the function
  entry block, not the pseudo-entry-block.

- When following edges backward during dominance calculations, only go to
  nodes that are actually reachable in the forward traversal.
  Important: the sense of reachability flips around when computing
  post-dominance.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/297
2016-08-05 11:09:29 -04:00
qining
5be1ee173f Add blurbs for freeze-spec-const pass 2016-08-05 10:39:50 -04:00
Lei Zhang
0d8ddd0b75 Create directory first if not existing and always refresh. 2016-08-05 10:23:41 -04:00
Lei Zhang
c6465fb220 Avoid redefining builtin dir. 2016-08-05 10:23:41 -04:00
qining
d37ecb924a Simple Assembly code builder for test uses
AssemblyBuilder contains boilplates.
Adds OpName instructions for all added defining instructions.
Adds OpDecorate SpecId for all spec constants added with OpSpecConstant,
OpSpecConstantTrue and OpSpecConstantFalse instructions.
2016-08-04 16:45:59 -04:00
David Neto
621fa3961f Only check def dominance of reachable uses
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/295
2016-08-04 14:58:27 -04:00
David Neto
50707a1257 Update CHANGES to reflect INotEqual update 2016-08-02 17:48:16 -04:00
qining
256c56db89 Allow OpINotEqual in OpSpecConstantOp inst
Pendding for now until the spec is fixed.
2016-08-02 15:11:27 -04:00
David Neto
9acc0f1401 Never generate % for a friendly disassembled Id
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/290
2016-08-02 11:59:10 -04:00
David Neto
e7a9e00738 Add disabled test for phi variable def-use check
Disabled because doing a proper check requires much more
code, and it can wait.
2016-07-29 20:00:38 -04:00
David Neto
1408aea260 Avoid checking def-use dominance for OpPhi value operands
The def-use dominance checker doesn't have enough info to know
that a particular use is in an OpPhi, so skip tracking those uses
for now.  Add a TODO to do a proper OpPhi variable-argument check
in the future.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/286
2016-07-29 20:00:38 -04:00
Lei Zhang
64ff3c6dc1 Optimization: Add def use analysis. 2016-07-29 15:45:14 -04:00
Lei Zhang
1db4cb456b Use default copy/move constructors/assignments for Instruction. 2016-07-29 00:58:09 -04:00
Lei Zhang
dcf28bf6ce Allow missing memory model instructions in modules. 2016-07-29 00:58:09 -04:00