souffle  2.0.2-371-g6315b36
ReorderLiterals.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 ReorderLiterals.h
12  *
13  ***********************************************************************/
14 
15 #pragma once
16 
17 #include "ast/Atom.h"
18 #include "ast/Clause.h"
19 #include "ast/TranslationUnit.h"
21 #include <functional>
22 #include <string>
23 #include <vector>
24 
25 namespace souffle::ast {
26 class BindingStore;
27 class SipsMetric;
28 } // namespace souffle::ast
29 namespace souffle::ast::transform {
30 
31 /**
32  * Transformation pass to reorder body literals.
33  */
35 public:
36  std::string getName() const override {
37  return "ReorderLiteralsTransformer";
38  }
39 
40  ReorderLiteralsTransformer* clone() const override {
41  return new ReorderLiteralsTransformer();
42  }
43 
44  /**
45  * Reorder the clause based on a given SIPS function.
46  * @param sipsFunction SIPS metric to use
47  * @param clause clause to reorder
48  * @return nullptr if no change, otherwise a new reordered clause
49  */
50  static Clause* reorderClauseWithSips(const SipsMetric& sips, const Clause* clause);
51 
52 private:
53  bool transform(TranslationUnit& translationUnit) override;
54 };
55 
56 } // namespace souffle::ast::transform
TranslationUnit.h
Transformer.h
souffle::ast::Clause
Intermediate representation of a horn clause.
Definition: Clause.h:51
souffle::ast::transform::ReorderLiteralsTransformer::transform
bool transform(TranslationUnit &translationUnit) override
Definition: ReorderLiterals.cpp:67
souffle::ast::transform::ReorderLiteralsTransformer
Transformation pass to reorder body literals.
Definition: ReorderLiterals.h:34
souffle::ast::transform::Transformer
Definition: Transformer.h:30
souffle::ast::transform::ReorderLiteralsTransformer::reorderClauseWithSips
static Clause * reorderClauseWithSips(const SipsMetric &sips, const Clause *clause)
Reorder the clause based on a given SIPS function.
Definition: ReorderLiterals.cpp:46
Atom.h
souffle::ast::TranslationUnit
Translation unit class for the translation pipeline.
Definition: TranslationUnit.h:51
souffle::ast::transform::ReorderLiteralsTransformer::clone
ReorderLiteralsTransformer * clone() const override
Definition: ReorderLiterals.h:40
souffle::ast::transform
Definition: Program.h:45
souffle::ast::transform::ReorderLiteralsTransformer::getName
std::string getName() const override
Definition: ReorderLiterals.h:36
souffle::ast::SipsMetric
Class for SIPS cost-metric functions Each subclass represents a different heuristic used for evaluati...
Definition: SipsMetric.h:39
Clause.h
souffle::ast
Definition: Aggregator.h:35