1 // Copyright (c) 2020 Google LLC
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 "source/fuzz/pass_management/repeated_pass_manager.h"
16
17 #include "source/fuzz/pass_management/repeated_pass_manager_looped_with_recommendations.h"
18 #include "source/fuzz/pass_management/repeated_pass_manager_random_with_recommendations.h"
19 #include "source/fuzz/pass_management/repeated_pass_manager_simple.h"
20
21 namespace spvtools {
22 namespace fuzz {
23
RepeatedPassManager(FuzzerContext * fuzzer_context,RepeatedPassInstances * pass_instances)24 RepeatedPassManager::RepeatedPassManager(FuzzerContext* fuzzer_context,
25 RepeatedPassInstances* pass_instances)
26 : fuzzer_context_(fuzzer_context), pass_instances_(pass_instances) {}
27
28 RepeatedPassManager::~RepeatedPassManager() = default;
29
Create(RepeatedPassStrategy strategy,FuzzerContext * fuzzer_context,RepeatedPassInstances * pass_instances,RepeatedPassRecommender * pass_recommender)30 std::unique_ptr<RepeatedPassManager> RepeatedPassManager::Create(
31 RepeatedPassStrategy strategy, FuzzerContext* fuzzer_context,
32 RepeatedPassInstances* pass_instances,
33 RepeatedPassRecommender* pass_recommender) {
34 switch (strategy) {
35 case RepeatedPassStrategy::kSimple:
36 return MakeUnique<RepeatedPassManagerSimple>(fuzzer_context,
37 pass_instances);
38 case RepeatedPassStrategy::kLoopedWithRecommendations:
39 return MakeUnique<RepeatedPassManagerLoopedWithRecommendations>(
40 fuzzer_context, pass_instances, pass_recommender);
41 case RepeatedPassStrategy::kRandomWithRecommendations:
42 return MakeUnique<RepeatedPassManagerRandomWithRecommendations>(
43 fuzzer_context, pass_instances, pass_recommender);
44 }
45
46 assert(false && "Unreachable");
47 return nullptr;
48 }
49
50 } // namespace fuzz
51 } // namespace spvtools
52