diff options
author | Ehsan Nasiri <ehsann@google.com> | 2017-01-09 11:10:52 -0500 |
---|---|---|
committer | David Neto <dneto@google.com> | 2017-01-13 16:15:11 -0500 |
commit | 1c11c8690f6b8dd3a396447bca8a180e468156a7 (patch) | |
tree | b6b65a30ab2bae7c01a4dac5a5c5178c35291384 /source/val | |
parent | 68e36ec7e9da5300b5d183be543162928aee5776 (diff) | |
download | spirv-tools-1c11c8690f6b8dd3a396447bca8a180e468156a7.tar.gz |
Validation of OpEntryPoint usage.
According to the SPIRV Spec (2.16.1):
* There is at least one OpEntryPoint instruction, unless the Linkage
capability is being used.
* No function can be targeted by both an OpEntryPoint instruction and an
OpFunctionCall instruction.
Also updated unit tests to includ OpEntryPoint.
Diffstat (limited to 'source/val')
-rw-r--r-- | source/val/validation_state.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/source/val/validation_state.h b/source/val/validation_state.h index 5abf9c37..a4a41406 100644 --- a/source/val/validation_state.h +++ b/source/val/validation_state.h @@ -129,6 +129,16 @@ class ValidationState_t { std::vector<uint32_t>& entry_points() { return entry_points_; } const std::vector<uint32_t>& entry_points() const { return entry_points_; } + /// Inserts an <id> to the set of functions that are target of OpFunctionCall. + void AddFunctionCallTarget(const uint32_t id) { + function_call_targets_.insert(id); + } + + /// Returns whether or not a function<id> is the target of OpFunctionCall. + bool IsFunctionCallTarget(const uint32_t id) { + return (function_call_targets_.find(id) != function_call_targets_.end()); + } + /// Registers the capability and its dependent capabilities void RegisterCapability(SpvCapability cap); @@ -255,6 +265,9 @@ class ValidationState_t { /// IDs that are entry points, ie, arguments to OpEntryPoint. std::vector<uint32_t> entry_points_; + /// Functions IDs that are target of OpFunctionCall. + std::unordered_set<uint32_t> function_call_targets_; + /// ID Bound from the Header uint32_t id_bound_; |