1 // Copyright (c) 2017 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <cassert>
16 #include <cstring>
17 
18 #include "source/spirv_optimizer_options.h"
19 
spvOptimizerOptionsCreate(void)20 SPIRV_TOOLS_EXPORT spv_optimizer_options spvOptimizerOptionsCreate(void) {
21   return new spv_optimizer_options_t();
22 }
23 
spvOptimizerOptionsDestroy(spv_optimizer_options options)24 SPIRV_TOOLS_EXPORT void spvOptimizerOptionsDestroy(
25     spv_optimizer_options options) {
26   delete options;
27 }
28 
spvOptimizerOptionsSetRunValidator(spv_optimizer_options options,bool val)29 SPIRV_TOOLS_EXPORT void spvOptimizerOptionsSetRunValidator(
30     spv_optimizer_options options, bool val) {
31   options->run_validator_ = val;
32 }
33 
spvOptimizerOptionsSetValidatorOptions(spv_optimizer_options options,spv_validator_options val)34 SPIRV_TOOLS_EXPORT void spvOptimizerOptionsSetValidatorOptions(
35     spv_optimizer_options options, spv_validator_options val) {
36   options->val_options_ = *val;
37 }
spvOptimizerOptionsSetMaxIdBound(spv_optimizer_options options,uint32_t val)38 SPIRV_TOOLS_EXPORT void spvOptimizerOptionsSetMaxIdBound(
39     spv_optimizer_options options, uint32_t val) {
40   options->max_id_bound_ = val;
41 }
42 
spvOptimizerOptionsSetPreserveBindings(spv_optimizer_options options,bool val)43 SPIRV_TOOLS_EXPORT void spvOptimizerOptionsSetPreserveBindings(
44     spv_optimizer_options options, bool val) {
45   options->preserve_bindings_ = val;
46 }
47 
spvOptimizerOptionsSetPreserveSpecConstants(spv_optimizer_options options,bool val)48 SPIRV_TOOLS_EXPORT void spvOptimizerOptionsSetPreserveSpecConstants(
49     spv_optimizer_options options, bool val) {
50   options->preserve_spec_constants_ = val;
51 }
52