aboutsummaryrefslogtreecommitdiff
path: root/source/validate.h
AgeCommit message (Collapse)Author
2018-04-20Fixes #1480. Validate group non-uniform scopes.Alan Baker
* Adds new pass for validating non-uniform group instructions * Currently on checks execution scope for Vulkan 1.1 and SPIR-V 1.3 * Added test framework
2018-03-23Add Vulkan validation rules for BuiltIn variablesAndrey Tuganov
Added a framework for validation of BuiltIn variables. The framework allows implementation of flexible abstract rules which are required for built-ins as the information (decoration, definition, reference) is not in one place, but is scattered all over the module. Validation rules are implemented as a map id -> list<functor(instrution)> Ids which are dependent on built-in types or objects receive a task list, such as "this id cannot be referenced from function which is called from entry point with execution model X; propagate this rule to your descendants in the global scope". Also refactored test/val/val_fixtures. All built-ins covered by tests
2018-03-17Migrate to use unified grammar tablesLei Zhang
Previously we keep a separate static grammar table for opcodes/ operands per SPIR-V version. This commit changes that to use a single unified static grammar table for opcodes/operands. This essentially changes how grammar facts are queried against a certain target environment. There are only limited filtering according to the desired target environment; a symbol is considered as available as long as: 1. The target environment satisfies the minimal requirement of the symbol; or 2. There is at least one extension enabling this symbol. Note that the second rule assumes the extension enabling the symbol is indeed requested in the SPIR-V code; checking that should be the validator's work. Also fixed a few grammar related issues: * Rounding mode capability requirements are moved to client APIs. * Reserved symbols not available in any extension is no longer recognized by assembler.
2018-02-05Add barrier instructions validation passAndrey Tuganov
2018-02-01Add adjacency validation passJeremy Hayes
Validate OpPhi predecessors. Validate OpLoopMerge successors. Validate OpSelectionMerge successors. Fix collateral damage to existing tests. Remove ValidateIdWithMessage.OpSampledImageUsedInOpPhiBad.
2018-01-02Add ExtInst validation pass (GLSL only for now)Andrey Tuganov
Validates all GLSL.std.450 extended instructions.
2017-12-19validate & test of literal's upper bitsJesus Carabano
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/660
2017-12-15Add primitive instruction validation passJeremy Hayes
2017-12-13Add validation rules for atomic instructionsAndrey Tuganov
Validates all OpAtomicXXX instructions.
2017-12-05Add composite instruction validation passAndrey Tuganov
Validates instructions in the opcode range from OpVectorExtractDynamic to OpTranspose.
2017-11-23Add derivatives validation passAndrey Tuganov
Checks operands of instructions in opcode range from OpDPdx to OpFwidthCoarse.
2017-11-22Validator pass for image instructionsAndrey Tuganov
Includes validation rules for OpImageXXX and ImageOperand. Doesn't include OpTypeImage and OpImageSparseXXX. Disabled an invalid test.
2017-11-08Re-format files in source, source/opt, source/util, source/val and tools.Diego Novillo
NFC. This just makes sure every file is formatted following the formatting definition in .clang-format. Re-formatted with: $ clang-format -i $(find source tools include -name '*.cpp') $ clang-format -i $(find source tools include -name '*.h')
2017-10-20Add validation pass for conversion instructionsAndrey Tuganov
The pass checks correctness of operands of instruction in opcode range OpConvertFToU - OpBitset. Disabled invalid tests Disabled UConvert validation until Vulkan CTS can catch up. Add validate_conversion to Android.mk Also remove duplicate entry in CMakeLists.txt.
2017-09-26Add bitwise operations validator passAndrey Tuganov
The pass checks correctness of operand types of all bitwise instructions (opcode range from SpvOpShiftRightLogical to SpvOpBitCount).
2017-09-20Add validate logicals pass to the validatorAndrey Tuganov
New pass checks operands of all instructions listed under 3.32.15. Relational and Logical Instructions
2017-09-05Add validation pass for arithmetic operationsAndrey Tuganov
The pass checks if arithmetic operations (such as OpFMul) receive correct operands.
2017-05-25CFA: Pull in CalculateDominatorsGreg Fischer
2017-05-09Stats analyzer uses validatorAndrey Tuganov
Stats analyzer calls validator to check the instruction and update validator state. Fixed unit tests (validator was failing).
2017-05-08Inline: Create CFA classGreg Fischer
Create class to encapsulate control flow analysis and share across validator and optimizer. A WIP. Start with DepthFirstTraversal. Next pull in CalculateDominators.
2017-03-17Validator dissallows unsupported Vulkan capabilityAndrey Tuganov
If environment is SPV_ENV_VULKAN_1_0, disallow OpCapability operands which are not supported by Vulkan 1.0. See https://github.com/KhronosGroup/SPIRV-Tools/issues/572
2017-02-28Issue 559: check type declaration uniquenessAndrey Tuganov
Adds PassTypeUnique to the validator. Disallows repeated declarations of all types except for aggregates.
2017-02-28Add command line options struct for the validatorEhsan Nasiri
The limit for the number of struct members is parameterized using command line options. Add --max-struct-depth command line option. Add --max-switch-branches command line option. Add --max-function-args command line option. Add --max-control-flow-nesting-depth option. Add --max-access-chain-indexes option.
2017-01-18Validation for decoration rules. Fixes issue #499.Ehsan Nasiri
Added a new file where all the decoration validation can be performed. In this change the SPIRV Spec Section 2.16.1 is implemented: "It is illegal to initialize an imported variable. This means that a module-scope OpVariable with initialization value cannot be marked with the Import Linkage Type." Also added unit tests.
2017-01-13Introducing a new flow for running the Validator.Ehsan Nasiri
We are adding a new API which can be called to run the SPIR-V validator, and retrieve the ValidationState_t object. This is very useful for unit testing. I have also added basic unit tests that demonstrate usage of this flow and ease of use to verify correctness.
2016-11-08Adding validation for vector data rule.Ehsan Nasiri
Number of components in a vector can be 2 or 3 or 4. If Vector16 capability is used, 8 and 16 components are also allowed. Also added unit tests for vector data rule.
2016-09-15Add a callback mechanism for communicating messages to callers.Lei Zhang
Every time an event happens in the library that the user should be aware of, the callback will be invoked. The existing diagnostic mechanism is hijacked internally by a callback that creates an diagnostic object each time an event happens.
2016-09-02Relicense SPIRV-Tools under Apache 2.0David Neto
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/383 Finalize v2016.4
2016-09-02Kill the spvCheckReturn macro.Lei Zhang
2016-08-09Refactor Id -> InstructionUmar Arshad
2016-08-07Remove unnecessary headersUmar Arshad
2016-07-28Fix infinite loop in dominance calculation.David Neto
Ensure the dominance calculation visits all nodes in the CFG. The successor list of the pseudo-entry node is augmented with a single node in each cycle that otherwise would not be visited. Similarly, the predecssors list of the pseduo-exit node is augmented with the a single node in each cycle that otherwise would not be visited. Pulls DepthFirstSearch out so it's accessible outside of the dominator calculation. Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/279
2016-07-26Check definitions appear in dominator of useUmar Arshad
Also address use and def of ID in same instruction
2016-07-26Refactor IDs definition and use trackingUmar Arshad
* Creates an ID class which manages definition and use of IDs * Moved tracking code from validate.cpp to validate_id.cpp * Rename and combine SsaPass and ProcessIds into IdPass * Remove module dependency in Function
2016-06-27Fix several violations of the style guideUmar Arshad
2016-06-24Use pseudo entry and pseudo exit blocks for dominance.David Neto
For dominance calculations we use an "augmented" CFG where we always add a pseudo-entry node that is the predecessor in the augmented CFG to any nodes that have no predecessors in the regular CFG. Similarly, we add a pseudo-exit node that is the predecessor in the augmented CFG that is a successor to any node that has no successors in the regular CFG. Pseudo entry and exit blocks live in the Function object. Fixes a subtle problem where we were implicitly creating the block_details for the pseudo-exit node since it didn't appear in the idoms map, and yet we referenced it. In such a case the contents of the block details could be garbage, or zero-initialized. That sometimes caused incorrect calculation of immediate dominators and post-dominators. For example, on a debug build where the details could be zero-initialized, the dominator of an unreachable block would be given as the pseudo-exit node. Bizarre. Also, enforce the rule that you must have an OpFunctionEnd to close off the last function.
2016-06-22Validator structured flow checks: back-edge, constructsUmar Arshad
Skip structured control flow chekcs for non-shader capability. Fix infinite loop in dominator algorithm when there's an unreachable block.
2016-06-08Split validate_types file into multiple classesUmar Arshad
Creates separate files for the ValidationState, Function and BasicBlock classes.
2016-06-06Remove redundant in_block function from FunctionUmar Arshad
Same test can be done through the get_current_block function
2016-06-02Control Flow Graph ValidationUmar Arshad
2016-04-29bitcast fixesFlorian Ziesche
* ValidationState_t and idUsage now store the addressing model and memory model of the SPIR-V module (this is necessary for certain instructions that need different checks depending on if the logical or physical addressing model is used) * removed SpvOpPtrAccessChain and SpvOpInBoundsPtrAccessChain from spvOpcodeIsPointer again as these are disallowed in logical addressing mode and only allowed in physical addressing mode (which doesn't use/need spvOpcodeIsPointer in the first place) * added SpvOpImageTexelPointer and SpvOpCopyObject to spvOpcodeIsPointer * OpLoad/OpStore now only check if the used pointer operand originated from a valid pointer producing opcode in logical addressing mode (as per 2.16.1) * moved bitcast pointer tests to the kernel / physical addressing model part (+cleanup) * renamed spvOpcodeIsPointer to spvOpcodeReturnsLogicalPointer to clarify this function is only meant to be used with the logical addressing model
2016-04-22Turn module_capabilities_ into a spv_capability_mask_t.Dejan Mircevski
2016-04-02Fix spelling mistakesEric Engestrom
2016-02-25Fix issues reported by cppcheck.Lei Zhang
Remove code not being used, add explicit to constructors, and add missing fields in constructors.
2016-02-23Remove spv_validate_options_t and change tests accrodingly.Lei Zhang
Users always want to run all the checks. The spv_validate_options_t mechanism, which provides little benefits to users, complicates the internal implementation and also makes the tests exercise different paths as users do. Right now the tests are more like integration tests instead of unit tests, which should be our next refactoring aim.
2016-02-18Use unordered_map to store defs in UseDefTracker for fast lookup.Lei Zhang
2016-02-17Rearrange headersDavid Neto
Now we have public headers arranged as follows: $SPIRV_TOOLS_ROOT/include/spirv-tools/libspirv.h $SPIRV_TOOLS_ROOT/include/spirv/spirv.h $SPIRV_TOOLS_ROOT/include/spirv/GLSL.std.450.h $SPIRV_TOOLS_ROOT/include/spirv/OpenCL.std.h A project should use -I$SPIRV_TOOLS_ROOT/include and then #include "spirv-tools/libspirv.h" The headers from the SPIR-V Registry can be accessed as "spirv/spirv." for example. The install target should also install the headers from the SPIR-V Registry. The libspirv.h header is broken otherwise. The SPIRV-Tools library depends on the headers from the SPIR-V Registry. The util/bitutils.h and util/hex_float.h are pulled into the internal source tree. Those are not part of the public API to SPIRV-Tools.
2016-02-02Use AssemblyGrammar for capability validation.Dejan Mircevski
Also: - ForEach() for spv_capability_mask_t. - Add capability min/max constants. - Move max definition from validate_types.cpp to spirv_definition.h.
2016-01-29Fix validator mem overflow when tracking capabilitiesqining
2016-01-27Remove spvOpcodeIsObject().Dejan Mircevski
Also - Add type_id to spv_id_info_t. - Use spv_id_info_t::type_id instead of words[1]. Triggered some asserts on tests, where the code incorrectly assumed words[1] had a type. Remove the asserts and handle gracefully. - Add tests for OpStore of a label, a void, and a function.