souffle  2.0.2-371-g6315b36
HoistAggregate.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2018, The Souffle Developers. All rights reserved
4  * Licensed under the Universal Permissive License v 1.0 as shown at:
5  * - https://opensource.org/licenses/UPL
6  * - <souffle root>/licenses/SOUFFLE-UPL.txt
7  */
8 
9 /************************************************************************
10  *
11  * @file HoistAggregate.h
12  *
13  ***********************************************************************/
14 
15 #pragma once
16 
17 #include "ram/Program.h"
18 #include "ram/TranslationUnit.h"
19 #include "ram/analysis/Level.h"
21 #include <string>
22 
23 namespace souffle::ram::transform {
24 
25 /**
26  * @class HoistAggregatesTransformer
27  * @brief Pushes one Aggregate as far up the loop nest as possible
28  *
29  * This transformer, if possible, pushes an aggregate up
30  * the loop nest to increase performance by performing less Aggregate
31  * operations
32  *
33  */
34 class HoistAggregateTransformer : public Transformer {
35 public:
36  std::string getName() const override {
37  return "HoistAggregateTransformer";
38  }
39 
40  /**
41  * @brief Apply hoistAggregate to the whole program
42  * @param RAM program
43  * @result A flag indicating whether the RAM program has been changed.
44  *
45  * Pushes an Aggregate up the loop nest if possible
46  */
47  bool hoistAggregate(Program& program);
48 
49 protected:
50  analysis::LevelAnalysis* rla{nullptr};
51  bool transform(TranslationUnit& translationUnit) override {
52  rla = translationUnit.getAnalysis<analysis::LevelAnalysis>();
53  return hoistAggregate(translationUnit.getProgram());
54  }
55 };
56 
57 } // namespace souffle::ram::transform
souffle::ram::transform
Definition: ChoiceConversion.cpp:30
souffle::ram::Program
RAM program relation declaration and functions.
Definition: Program.h:58
souffle::ram::TranslationUnit::getAnalysis
Analysis * getAnalysis() const
Get an analysis.
Definition: TranslationUnit.h:66
souffle::ram::analysis::LevelAnalysis
A Ram Analysis for determining the level of a expression/condition.
Definition: Level.h:51
Program.h
souffle::ram::transform::HoistAggregateTransformer::transform
bool transform(TranslationUnit &translationUnit) override
@Brief transform the translation unit / used by apply @Param translationUnit that will be transformed...
Definition: HoistAggregate.h:55
souffle::ram::TranslationUnit::getProgram
Program & getProgram() const
Get the RAM Program of the translation unit
Definition: TranslationUnit.h:107
souffle::ram::TranslationUnit
Translating a RAM program.
Definition: TranslationUnit.h:55
souffle::ram::transform::HoistAggregateTransformer::rla
analysis::LevelAnalysis * rla
Definition: HoistAggregate.h:54
TranslationUnit.h
Transformer.h
souffle::ram::transform::HoistAggregateTransformer::hoistAggregate
bool hoistAggregate(Program &program)
Apply hoistAggregate to the whole program.
Definition: HoistAggregate.cpp:34
Level.h
souffle::ram::transform::HoistAggregateTransformer::getName
std::string getName() const override
@Brief get name of the transformer
Definition: HoistAggregate.h:40