docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
transformation.h
Go to the documentation of this file.
1#pragma once
2
3#include <exception>
4
9
10namespace sdfg {
11
13
14namespace transformations {
15
26protected:
28
29public:
30 virtual ~Transformation() = default;
31
36 virtual void set_report(PassReportConsumer* report) {
37 report_ = report;
38 }
39
44 virtual std::string name() const = 0;
45
52 // TODO builder and probably analysis manager should be given via constructor, as in practice, the nodes which are
53 // transformed are already constructor params, and therefore the SDFG is implied
55
62
73 auto can_be = can_be_applied(builder, analysis_manager);
74
75 if (!can_be) {
76 return false;
77 } else {
78 apply(builder, analysis_manager);
79 return true;
80 }
81 }
82
88 virtual void to_json(nlohmann::json& j) const = 0;
89};
90
94class InvalidTransformationException : public std::exception {
95private:
96 std::string message_;
97
98public:
99 explicit InvalidTransformationException(const std::string& message) : message_(message) {
100 }
101
102 const char* what() const noexcept override {
103 return message_.c_str();
104 }
105};
106
110class InvalidTransformationDescriptionException : public std::exception {
111private:
112 std::string message_;
113
114public:
115 explicit InvalidTransformationDescriptionException(const std::string& message) : message_(message) {
116 }
117
118 const char* what() const noexcept override {
119 return message_.c_str();
120 }
121};
122
123} // namespace transformations
124} // namespace sdfg
Definition pass_report_consumer.h:9
Definition analysis.h:53
Note: Even though the class references unique_ptr, it will never delete an SDFG it has a reference to...
Definition structured_sdfg_builder.h:44
InvalidTransformationDescriptionException(const std::string &message)
Definition transformation.h:115
const char * what() const noexcept override
Definition transformation.h:118
InvalidTransformationException(const std::string &message)
Definition transformation.h:99
const char * what() const noexcept override
Definition transformation.h:102
Base class for all SDFG transformations.
Definition transformation.h:25
PassReportConsumer * report_
Definition transformation.h:27
virtual void to_json(nlohmann::json &j) const =0
Serialize this transformation to JSON.
virtual bool can_be_applied(builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager)=0
Check if this transformation can be safely applied.
virtual std::string name() const =0
Get the name of this transformation.
virtual bool try_apply(builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager)
Attempt to apply the transformation if possible.
Definition transformation.h:72
virtual void set_report(PassReportConsumer *report)
Set the report consumer for transformation feedback.
Definition transformation.h:36
virtual void apply(builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager)=0
Apply this transformation to the SDFG.
Definition function_builder.h:10
Definition loop_parallelization.h:8
Definition analysis.h:7