souffle
2.0.2-371-g6315b36
ram
analysis
Level.h
Go to the documentation of this file.
1
/*
2
* Souffle - A Datalog Compiler
3
* Copyright (c) 2019, 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 Level.h
12
*
13
* Get level of an expression/condition. The level of a condition/expression
14
* determines the outer-most scope in a loop-next of a query, for which the
15
* expression/condition is still safe to be computed.
16
*
17
***********************************************************************/
18
19
#pragma once
20
21
#include "
ram/Node.h
"
22
#include "
ram/TranslationUnit.h
"
23
#include "
ram/analysis/Analysis.h
"
24
#include "
ram/analysis/Relation.h
"
25
26
namespace
souffle::ram::analysis
{
27
28
/**
29
* @class LevelAnalysis
30
* @brief A Ram Analysis for determining the level of a expression/condition
31
*
32
* The expression is determined by the TupleElement of an expression/condition
33
* with the highest tuple-id number. Note in the implementation we assume that the
34
* tuple-id of TupleOperation operations are ordered, i.e., the most-outer loop has the
35
* smallest tuple-id and the most inner-loop has the largest tuple-id number.
36
*
37
* If an expression/condition does not contain an TupleElement accessing an element
38
* of a tuple, the analysis yields -1 for denoting that the expression/condition
39
* can be executed outside of the loop-nest, i.e., the expression/condition is
40
* independent of data stemming from relations.
41
*
42
*/
43
class
LevelAnalysis :
public
Analysis {
44
public
:
45
LevelAnalysis
(
const
char
*
id
) :
Analysis
(
id
) {}
46
47
static
constexpr
const
char
*
name
=
"level-analysis"
;
48
49
void
run
(
const
TranslationUnit& tUnit)
override
{
50
ra
= tUnit.getAnalysis<RelationAnalysis>();
51
}
52
53
/**
54
* @brief Get level of a RAM expression/condition
55
*/
56
int
getLevel
(
const
Node
* value)
const
;
57
58
protected
:
59
RelationAnalysis
*
ra
{
nullptr
};
60
};
61
62
}
// namespace souffle::ram::analysis
souffle::ram::analysis::LevelAnalysis::getLevel
int getLevel(const Node *value) const
Get level of a RAM expression/condition.
Definition:
Level.cpp:64
souffle::ram::analysis::LevelAnalysis::LevelAnalysis
LevelAnalysis(const char *id)
Definition:
Level.h:53
souffle::ram::analysis
Definition:
Analysis.h:32
souffle::ram::analysis::LevelAnalysis::ra
RelationAnalysis * ra
Definition:
Level.h:67
souffle::ram::Node
Node is a superclass for all RAM IR classes.
Definition:
Node.h:42
Relation.h
souffle::ram::analysis::LevelAnalysis::name
static constexpr const char * name
Definition:
Level.h:55
Analysis.h
TranslationUnit.h
souffle::ram::analysis::LevelAnalysis::run
void run(const TranslationUnit &tUnit) override
Run analysis for a RAM translation unit.
Definition:
Level.h:57
souffle::ram::analysis::Analysis::Analysis
Analysis(const char *id)
Definition:
Analysis.h:40
Node.h
souffle::ram::analysis::RelationAnalysis
A RAM Analysis for finding relations by name.
Definition:
Relation.h:36
id
void id(std::string col)
Definition:
Tui.h:1124
Generated by
1.8.17