docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
sdfg::transformations::LoopRotate Class Reference

Loop rotation transformation to convert negative stride to positive stride. More...

#include <sdfg/transformations/loop_rotate.h>

Inheritance diagram for sdfg::transformations::LoopRotate:
[legend]

Public Member Functions

 LoopRotate (structured_control_flow::StructuredLoop &loop)
 Construct a LoopRotate transformation.
virtual std::string name () const override
 Get the name of this transformation.
virtual bool can_be_applied (builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager) override
 Check if this transformation can be safely applied.
virtual void apply (builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager) override
 Apply this transformation to the SDFG.
virtual void to_json (nlohmann::json &j) const override
 Serialize this transformation to JSON.
const std::string & rotated_container_name () const
 Get the name of the container holding the rotated (original) value.
Public Member Functions inherited from sdfg::transformations::Transformation
virtual ~Transformation ()=default
virtual void set_report (PassReportConsumer *report)
 Set the report consumer for transformation feedback.
virtual bool try_apply (builder::StructuredSDFGBuilder &builder, analysis::AnalysisManager &analysis_manager)
 Attempt to apply the transformation if possible.

Static Public Member Functions

static LoopRotate from_json (builder::StructuredSDFGBuilder &builder, const nlohmann::json &j)

Additional Inherited Members

Protected Attributes inherited from sdfg::transformations::Transformation
PassReportConsumer * report_ = nullptr

Detailed Description

Loop rotation transformation to convert negative stride to positive stride.

This transformation reverses the iteration direction of a loop with negative stride.

Original loop (negative stride): for (i = init; bound < i; i -= 1) // or equivalently: i > bound body(i)

After LoopRotate: for (i = bound+1; i < init+1; i += 1) body(init + bound + 1 - i) // Transformed index

Example: // Original: i = 10, 9, 8, ..., 1 (while i > 0) for (i = 10; 0 < i; i–) A[i] = ...

// After rotation: i' = 1, 2, 3, ..., 10 for (i = 1; i < 11; i++) A[11 - i] = ... // 11-1=10, 11-2=9, ..., 11-10=1

Prerequisites:

  • Loop must have stride == -1
  • Loop condition must have extractable lower bound (form: bound < indvar)

Benefits:

  • Enables further transformations that require positive stride
  • Normalizes loops for analysis
  • Works with both For and Map loops
Note
After applying this transformation, you should run SymbolPropagation to propagate the rotated index expression into the loop body.

Constructor & Destructor Documentation

◆ LoopRotate()

sdfg::transformations::LoopRotate::LoopRotate ( structured_control_flow::StructuredLoop & loop)
explicit

Construct a LoopRotate transformation.

Parameters
loopThe loop to rotate (must have negative stride)

Member Function Documentation

◆ apply()

virtual void sdfg::transformations::LoopRotate::apply ( builder::StructuredSDFGBuilder & builder,
analysis::AnalysisManager & analysis_manager )
overridevirtual

Apply this transformation to the SDFG.

Parameters
builderThe SDFG builder
analysis_managerThe analysis manager (may be invalidated)

Implements sdfg::transformations::Transformation.

◆ can_be_applied()

virtual bool sdfg::transformations::LoopRotate::can_be_applied ( builder::StructuredSDFGBuilder & builder,
analysis::AnalysisManager & analysis_manager )
overridevirtual

Check if this transformation can be safely applied.

Parameters
builderThe SDFG builder
analysis_managerThe analysis manager providing necessary analyses
Returns
true if all preconditions are met

Implements sdfg::transformations::Transformation.

◆ from_json()

LoopRotate sdfg::transformations::LoopRotate::from_json ( builder::StructuredSDFGBuilder & builder,
const nlohmann::json & j )
static

◆ name()

virtual std::string sdfg::transformations::LoopRotate::name ( ) const
overridevirtual

Get the name of this transformation.

Returns
The transformation name (e.g., "LoopInterchange")

Implements sdfg::transformations::Transformation.

◆ rotated_container_name()

const std::string & sdfg::transformations::LoopRotate::rotated_container_name ( ) const
inline

Get the name of the container holding the rotated (original) value.

Returns
The container name, or empty string if not yet applied

◆ to_json()

virtual void sdfg::transformations::LoopRotate::to_json ( nlohmann::json & j) const
overridevirtual

Serialize this transformation to JSON.

Parameters
jJSON object to populate with transformation description
Exceptions
std::logic_errorif not implemented

Implements sdfg::transformations::Transformation.


The documentation for this class was generated from the following file: