aboutsummaryrefslogtreecommitdiff
path: root/source/val
diff options
context:
space:
mode:
authorEhsan Nasiri <ehsann@google.com>2017-02-15 13:29:33 -0500
committerDavid Neto <dneto@google.com>2017-02-28 12:00:06 -0500
commitda4ae05638f72fb399702257a7d6e4cd5cb4dba7 (patch)
treef1603de9908ada6553db0331e8add64716ddb94c /source/val
parente3632a26b423682306e4c5d88332528180a522a4 (diff)
downloadspirv-tools-da4ae05638f72fb399702257a7d6e4cd5cb4dba7.tar.gz
Add command line options struct for the validator
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.
Diffstat (limited to 'source/val')
-rw-r--r--source/val/validation_state.cpp8
-rw-r--r--source/val/validation_state.h9
2 files changed, 14 insertions, 3 deletions
diff --git a/source/val/validation_state.cpp b/source/val/validation_state.cpp
index 78ac7046..4f1cb7d1 100644
--- a/source/val/validation_state.cpp
+++ b/source/val/validation_state.cpp
@@ -182,8 +182,10 @@ bool IsInstructionInLayoutSection(ModuleLayoutSection layout, SpvOp op) {
} // anonymous namespace
-ValidationState_t::ValidationState_t(const spv_const_context ctx)
+ValidationState_t::ValidationState_t(const spv_const_context ctx,
+ const spv_const_validator_options opt)
: context_(ctx),
+ options_(opt),
instruction_counter_(0),
unresolved_forward_ids_{},
operand_names_{},
@@ -198,7 +200,9 @@ ValidationState_t::ValidationState_t(const spv_const_context ctx)
grammar_(ctx),
addressing_model_(SpvAddressingModelLogical),
memory_model_(SpvMemoryModelSimple),
- in_function_(false) {}
+ in_function_(false) {
+ assert(opt && "Validator options may not be Null.");
+}
spv_result_t ValidationState_t::ForwardDeclareId(uint32_t id) {
unresolved_forward_ids_.insert(id);
diff --git a/source/val/validation_state.h b/source/val/validation_state.h
index 97f4e7f5..ac845b04 100644
--- a/source/val/validation_state.h
+++ b/source/val/validation_state.h
@@ -60,11 +60,15 @@ class ValidationState_t {
bool declare_float16_type = false; // Allow OpTypeFloat with 16 bit width?
};
- ValidationState_t(const spv_const_context context);
+ ValidationState_t(const spv_const_context context,
+ const spv_const_validator_options opt);
/// Returns the context
spv_const_context context() const { return context_; }
+ /// Returns the command line options
+ spv_const_validator_options options() const { return options_; }
+
/// Forward declares the id in the module
spv_result_t ForwardDeclareId(uint32_t id);
@@ -305,6 +309,9 @@ class ValidationState_t {
const spv_const_context context_;
+ /// Stores the Validator command line options. Must be a valid options object.
+ const spv_const_validator_options options_;
+
/// Tracks the number of instructions evaluated by the validator
int instruction_counter_;