• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/transformation_compute_data_synonym_fact_closure.h"
16 
17 namespace spvtools {
18 namespace fuzz {
19 
20 TransformationComputeDataSynonymFactClosure::
TransformationComputeDataSynonymFactClosure(protobufs::TransformationComputeDataSynonymFactClosure message)21     TransformationComputeDataSynonymFactClosure(
22         protobufs::TransformationComputeDataSynonymFactClosure message)
23     : message_(std::move(message)) {}
24 
25 TransformationComputeDataSynonymFactClosure::
TransformationComputeDataSynonymFactClosure(uint32_t maximum_equivalence_class_size)26     TransformationComputeDataSynonymFactClosure(
27         uint32_t maximum_equivalence_class_size) {
28   message_.set_maximum_equivalence_class_size(maximum_equivalence_class_size);
29 }
30 
IsApplicable(opt::IRContext *,const TransformationContext &) const31 bool TransformationComputeDataSynonymFactClosure::IsApplicable(
32     opt::IRContext* /*unused*/, const TransformationContext& /*unused*/) const {
33   return true;
34 }
35 
Apply(opt::IRContext *,TransformationContext * transformation_context) const36 void TransformationComputeDataSynonymFactClosure::Apply(
37     opt::IRContext* /*unused*/,
38     TransformationContext* transformation_context) const {
39   transformation_context->GetFactManager()->ComputeClosureOfFacts(
40       message_.maximum_equivalence_class_size());
41 }
42 
43 protobufs::Transformation
ToMessage() const44 TransformationComputeDataSynonymFactClosure::ToMessage() const {
45   protobufs::Transformation result;
46   *result.mutable_compute_data_synonym_fact_closure() = message_;
47   return result;
48 }
49 
50 std::unordered_set<uint32_t>
GetFreshIds() const51 TransformationComputeDataSynonymFactClosure::GetFreshIds() const {
52   return std::unordered_set<uint32_t>();
53 }
54 
55 }  // namespace fuzz
56 }  // namespace spvtools
57