Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Touzeau
lruzdd
Commits
415a43ed
Commit
415a43ed
authored
Jun 02, 2018
by
Valentin Touzeau
Committed by
EXT Valentin Touzeau
Jun 02, 2018
Browse files
WIP
parent
65a44447
Changes
19
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
415a43ed
...
...
@@ -10,6 +10,13 @@ set(SOURCES "src/exactlru.cpp"
"src/ClassificationBuilder.cpp"
"src/ZDD/ZDD.cpp"
"src/ZDD/ZDDManager.cpp"
"src/ZDD/MustAbstractValuePolicy.cpp"
"src/ZDD/MayAbstractValuePolicy.cpp"
"src/GeneratorsSet/GSMayAbstractValuePolicy.cpp"
"src/GeneratorsSet/GSMustAbstractValuePolicy.cpp"
"src/ZDD/MustAbstractValuePolicy.cpp"
"src/ZDD/MayAbstractValuePolicy.cpp"
)
add_subdirectory
(
ddlib
)
...
...
include/exactlru/GeneratorsSet.h
deleted
100644 → 0
View file @
65a44447
#ifndef GENERATORS_SET_H
#define GENERATORS_SET_H
#include <set>
#include <exactlru/Generator.h>
namespace
exactlru
{
template
<
typename
AbstractValuePolicy
>
class
GSAbstractValue
:
public
AbstractValuePolicy
{
public:
friend
AbstractValuePolicy
;
using
Block
=
Generator
::
Block
;
using
GeneratorsSet
=
std
::
set
<
Generator
,
LexicalOrder
>
;
using
PartialOrder
=
typename
AbstractValuePolicy
::
Comparator
;
GSAbstractValue
(
const
GeneratorsSet
&
g
=
{})
:
_generators
(
g
)
{
}
void
update
(
const
Block
*
block
)
{
GeneratorsSet
old
(
_generators
);
_generators
.
clear
();
for
(
const
auto
&
g
:
old
)
{
Generator
newGenerator
(
g
);
newGenerator
.
update
(
block
);
insert
(
newGenerator
);
}
}
void
join
(
const
GSAbstractValue
&
rhs
)
{
for
(
const
auto
&
g
:
rhs
.
_generators
)
{
insert
(
g
);
}
}
inline
bool
operator
==
(
const
GSAbstractValue
&
rhs
)
const
{
return
_generators
==
rhs
.
_generators
;
}
inline
bool
operator
!=
(
const
GSAbstractValue
&
rhs
)
const
{
return
!
(
*
this
==
rhs
);
}
private:
void
insert
(
const
Generator
&
generator
)
{
// Check if "generator" is subsumed.
for
(
const
auto
&
g
:
_generators
)
if
(
_less
(
g
,
generator
))
return
;
// Remove old generators that are subsumed
typename
GeneratorsSet
::
const_iterator
it
=
_generators
.
begin
();
while
(
it
!=
_generators
.
end
())
{
if
(
_less
(
generator
,
*
it
))
it
=
_generators
.
erase
(
it
);
else
++
it
;
}
_generators
.
insert
(
generator
);
}
GeneratorsSet
_generators
;
PartialOrder
_less
;
};
class
GSMayAbstractValuePolicy
{
public:
using
Self
=
GSAbstractValue
<
GSMayAbstractValuePolicy
>
;
class
Comparator
{
public:
inline
bool
operator
()(
const
Generator
&
lhs
,
const
Generator
&
rhs
)
const
{
return
rhs
.
contains
(
lhs
);
}
};
bool
isAlwaysMiss
()
const
{
const
Self
&
self
=
static_cast
<
const
Self
&>
(
*
this
);
for
(
const
auto
&
g
:
self
.
_generators
)
{
if
(
!
g
.
isFocusedBlockEvicted
())
return
false
;
}
return
true
;
}
};
class
GSMustAbstractValuePolicy
{
public:
using
Self
=
GSAbstractValue
<
GSMustAbstractValuePolicy
>
;
class
Comparator
{
public:
inline
bool
operator
()(
const
Generator
&
lhs
,
const
Generator
&
rhs
)
const
{
return
lhs
.
contains
(
rhs
);
}
};
bool
isAlwaysHit
()
const
{
const
Self
&
self
=
static_cast
<
const
Self
&>
(
*
this
);
for
(
const
auto
&
g
:
self
.
_generators
)
{
if
(
g
.
isFocusedBlockEvicted
())
return
false
;
}
return
true
;
}
};
}
// namespace exactlru
#endif // MAY_GENERATORS_SET_H
src/Domain.h
View file @
415a43ed
...
...
@@ -5,7 +5,7 @@
#include <otawa/icache/features.h>
#include "ZDD/ZDDAbstractValue.h"
#include
<exactlru/
GeneratorsSet.h
>
#include
"
GeneratorsSet
/GSAbstractValue
.h
"
namespace
exactlru
{
...
...
@@ -78,157 +78,6 @@ private:
AbstractValue
m_tmp
;
};
class
ZDDMayDomainPolicy
{
public:
using
ManagerPtr
=
std
::
shared_ptr
<
ZDDManager
>
;
using
AbstractValue
=
ZDDAbstractValue
<
MayAbstractValuePolicy
>
;
ZDDMayDomainPolicy
(
const
otawa
::
icat3
::
LBlock
*
,
const
otawa
::
icat3
::
LBlockCollection
&
coll
,
int
set
,
const
AbstractValue
*
)
:
m_manager
(
new
ZDDManager
(
coll
[
set
]))
{
}
AbstractValue
createBot
(
const
otawa
::
icat3
::
LBlock
*
,
const
otawa
::
icat3
::
LBlockCollection
&
,
int
)
{
return
AbstractValue
(
AbstractValue
::
Init
::
Bot
);
}
AbstractValue
createTop
(
const
otawa
::
icat3
::
LBlock
*
,
const
otawa
::
icat3
::
LBlockCollection
&
,
int
)
{
return
AbstractValue
(
AbstractValue
::
Init
::
Top
);
}
void
fetch
(
AbstractValue
&
a
,
const
otawa
::
icat3
::
LBlock
*
lb
,
int
k
,
const
otawa
::
icat3
::
LBlock
*
focus
)
{
a
.
update
(
m_manager
,
lb
,
k
,
focus
);
}
bool
isAlwaysMiss
(
const
AbstractValue
&
a
)
const
{
return
a
.
isAlwaysMiss
(
m_manager
);
}
private:
ManagerPtr
m_manager
;
};
class
ZDDMustDomainPolicy
{
public:
using
ManagerPtr
=
std
::
shared_ptr
<
ZDDManager
>
;
using
AbstractValue
=
ZDDAbstractValue
<
MustAbstractValuePolicy
>
;
ZDDMustDomainPolicy
(
const
otawa
::
icat3
::
LBlock
*
,
const
otawa
::
icat3
::
LBlockCollection
&
coll
,
int
set
,
const
AbstractValue
*
)
:
m_manager
(
new
ZDDManager
(
coll
[
set
]))
{
}
AbstractValue
createBot
(
const
otawa
::
icat3
::
LBlock
*
,
const
otawa
::
icat3
::
LBlockCollection
&
,
int
)
{
return
AbstractValue
(
AbstractValue
::
Init
::
Bot
);
}
AbstractValue
createTop
(
const
otawa
::
icat3
::
LBlock
*
,
const
otawa
::
icat3
::
LBlockCollection
&
,
int
)
{
return
AbstractValue
(
AbstractValue
::
Init
::
Top
);
}
void
fetch
(
AbstractValue
&
a
,
const
otawa
::
icat3
::
LBlock
*
lb
,
int
k
,
const
otawa
::
icat3
::
LBlock
*
focus
)
{
a
.
update
(
m_manager
,
lb
,
k
,
focus
);
}
bool
isAlwaysHit
(
const
AbstractValue
&
a
)
const
{
return
a
.
isAlwaysHit
();
}
private:
ManagerPtr
m_manager
;
};
class
GSMayDomainPolicy
{
public:
using
AbstractValue
=
GSAbstractValue
<
GSMayAbstractValuePolicy
>
;
GSMayDomainPolicy
(
const
otawa
::
icat3
::
LBlock
*
,
const
otawa
::
icat3
::
LBlockCollection
&
,
int
,
const
AbstractValue
*
)
{
}
AbstractValue
createBot
(
const
otawa
::
icat3
::
LBlock
*
,
const
otawa
::
icat3
::
LBlockCollection
&
,
int
)
{
return
AbstractValue
();
}
AbstractValue
createTop
(
const
otawa
::
icat3
::
LBlock
*
focus
,
const
otawa
::
icat3
::
LBlockCollection
&
coll
,
int
)
{
return
AbstractValue
({
Generator
(
focus
,
coll
.
A
(),
false
)});
}
void
fetch
(
AbstractValue
&
a
,
const
otawa
::
icat3
::
LBlock
*
lb
,
int
,
const
otawa
::
icat3
::
LBlock
*
)
{
a
.
update
(
lb
);
}
bool
isAlwaysMiss
(
const
AbstractValue
&
a
)
const
{
return
a
.
isAlwaysMiss
();
}
};
class
GSMustDomainPolicy
{
public:
using
AbstractValue
=
GSAbstractValue
<
GSMustAbstractValuePolicy
>
;
GSMustDomainPolicy
(
const
otawa
::
icat3
::
LBlock
*
,
const
otawa
::
icat3
::
LBlockCollection
&
,
int
,
const
AbstractValue
*
)
{
}
AbstractValue
createBot
(
const
otawa
::
icat3
::
LBlock
*
,
const
otawa
::
icat3
::
LBlockCollection
&
,
int
)
{
return
AbstractValue
();
}
AbstractValue
createTop
(
const
otawa
::
icat3
::
LBlock
*
focus
,
const
otawa
::
icat3
::
LBlockCollection
&
coll
,
int
)
{
return
AbstractValue
({
Generator
(
focus
,
coll
.
A
(),
true
)});
}
void
fetch
(
AbstractValue
&
a
,
const
otawa
::
icat3
::
LBlock
*
lb
,
int
,
const
otawa
::
icat3
::
LBlock
*
)
{
a
.
update
(
lb
);
}
bool
isAlwaysHit
(
const
AbstractValue
&
a
)
const
{
return
a
.
isAlwaysHit
();
}
};
}
// namespace exactlru
...
...
src/GeneratorsSet/GSAbstractValue.h
0 → 100644
View file @
415a43ed
#ifndef GS_ABSTRACT_VALUE_H
#define GS_ABSTRACT_VALUE_H
#include <set>
#include <exactlru/Generator.h>
namespace
exactlru
{
template
<
typename
AbstractValuePolicy
>
class
GSAbstractValue
:
public
AbstractValuePolicy
{
public:
friend
AbstractValuePolicy
;
using
Block
=
Generator
::
Block
;
using
GeneratorsSet
=
std
::
set
<
Generator
,
LexicalOrder
>
;
using
PartialOrder
=
typename
AbstractValuePolicy
::
Comparator
;
GSAbstractValue
(
const
GeneratorsSet
&
g
=
{});
void
update
(
const
Block
*
block
);
void
join
(
const
GSAbstractValue
&
rhs
);
inline
bool
operator
==
(
const
GSAbstractValue
&
rhs
)
const
;
inline
bool
operator
!=
(
const
GSAbstractValue
&
rhs
)
const
;
private:
void
insert
(
const
Generator
&
generator
);
GeneratorsSet
_generators
;
PartialOrder
_less
;
};
template
<
typename
AbstractValuePolicy
>
GSAbstractValue
<
AbstractValuePolicy
>::
GSAbstractValue
(
const
GeneratorsSet
&
g
)
:
AbstractValuePolicy
(),
_generators
(
g
)
{
}
template
<
typename
AbstractValuePolicy
>
void
GSAbstractValue
<
AbstractValuePolicy
>::
update
(
const
Block
*
block
)
{
GeneratorsSet
old
(
_generators
);
_generators
.
clear
();
for
(
const
auto
&
g
:
old
)
{
Generator
newGenerator
(
g
);
newGenerator
.
update
(
block
);
insert
(
newGenerator
);
}
}
template
<
typename
AbstractValuePolicy
>
void
GSAbstractValue
<
AbstractValuePolicy
>::
join
(
const
GSAbstractValue
&
rhs
)
{
for
(
const
auto
&
g
:
rhs
.
_generators
)
{
insert
(
g
);
}
}
template
<
typename
AbstractValuePolicy
>
inline
bool
GSAbstractValue
<
AbstractValuePolicy
>::
operator
==
(
const
GSAbstractValue
&
rhs
)
const
{
return
_generators
==
rhs
.
_generators
;
}
template
<
typename
AbstractValuePolicy
>
inline
bool
GSAbstractValue
<
AbstractValuePolicy
>::
operator
!=
(
const
GSAbstractValue
&
rhs
)
const
{
return
!
(
*
this
==
rhs
);
}
}
// namespace exactlru
#endif // GS_ABSTRACT_VALUE_H
src/GeneratorsSet/GSMayAbstractValuePolicy.cpp
0 → 100644
View file @
415a43ed
#include "GSMayAbstractValuePolicy.h"
#include "GSMayDomainPolicy.h"
namespace
exactlru
{
bool
GSMayAbstractValuePolicy
::
isAlwaysMiss
(
const
GSMayDomainPolicy
&
)
const
{
const
Self
&
self
=
static_cast
<
const
Self
&>
(
*
this
);
for
(
const
auto
&
g
:
self
.
_generators
)
{
if
(
!
g
.
isFocusedBlockEvicted
())
return
false
;
}
return
true
;
}
}
// namespace exactlru
src/GeneratorsSet/GSMayAbstractValuePolicy.h
0 → 100644
View file @
415a43ed
#ifndef GS_MAY_ABSTRACT_VALUE_POLICY_H
#define GS_MAY_ABSTRACT_VALUE_POLICY_H
#include "GSAbstractValue.h"
namespace
exactlru
{
class
GSMayDomainPolicy
;
class
GSMayAbstractValuePolicy
{
public:
using
Self
=
GSAbstractValue
<
GSMayAbstractValuePolicy
>
;
class
Comparator
{
public:
inline
bool
operator
()(
const
Generator
&
lhs
,
const
Generator
&
rhs
)
const
{
return
rhs
.
contains
(
lhs
);
}
};
bool
isAlwaysMiss
(
const
GSMayDomainPolicy
&
)
const
;
};
}
// namespace exactlru
#endif // GS_MAY_ABSTRACT_VALUE_POLICY_H
src/GeneratorsSet/GSMayDomainPolicy.h
0 → 100644
View file @
415a43ed
#ifndef GS_MAY_DOMAIN_POLICY_H
#define GS_MAY_DOMAIN_POLICY_H
namespace
exactlru
{
class
GSMayDomainPolicy
{
public:
using
AbstractValue
=
GSAbstractValue
<
GSMayAbstractValuePolicy
>
;
GSMayDomainPolicy
(
const
otawa
::
icat3
::
LBlock
*
,
const
otawa
::
icat3
::
LBlockCollection
&
,
int
,
const
AbstractValue
*
)
{
}
AbstractValue
createBot
(
const
otawa
::
icat3
::
LBlock
*
,
const
otawa
::
icat3
::
LBlockCollection
&
,
int
)
{
return
AbstractValue
();
}
AbstractValue
createTop
(
const
otawa
::
icat3
::
LBlock
*
focus
,
const
otawa
::
icat3
::
LBlockCollection
&
coll
,
int
)
{
return
AbstractValue
({
Generator
(
focus
,
coll
.
A
(),
false
)});
}
void
fetch
(
AbstractValue
&
a
,
const
otawa
::
icat3
::
LBlock
*
lb
,
int
,
const
otawa
::
icat3
::
LBlock
*
)
{
a
.
update
(
lb
);
}
bool
isAlwaysMiss
(
const
AbstractValue
&
a
)
const
{
return
a
.
isAlwaysMiss
(
*
this
);
}
};
}
// namespace exactlru
#endif // GS_MAY_DOMAIN_POLICY_H
src/GeneratorsSet/GSMustAbstractValuePolicy.cpp
0 → 100644
View file @
415a43ed
#include "GSMustAbstractValuePolicy.h"
#include "GSMustDomainPolicy.h"
namespace
exactlru
{
bool
GSMustAbstractValuePolicy
::
isAlwaysHit
(
const
GSMustDomainPolicy
&
)
const
{
const
Self
&
self
=
static_cast
<
const
Self
&>
(
*
this
);
for
(
const
auto
&
g
:
self
.
_generators
)
{
if
(
g
.
isFocusedBlockEvicted
())
return
false
;
}
return
true
;
}
}
// namespace exactlru
src/GeneratorsSet/GSMustAbstractValuePolicy.h
0 → 100644
View file @
415a43ed
#ifndef GS_MUST_ABSTRACT_VALUE_POLICY_H
#define GS_MUST_ABSTRACT_VALUE_POLICY_H
#include "GSAbstractValue.h"
namespace
exactlru
{
class
GSMustDomainPolicy
;
class
GSMustAbstractValuePolicy
{
public:
using
Self
=
GSAbstractValue
<
GSMustAbstractValuePolicy
>
;
class
Comparator
{
public:
inline
bool
operator
()(
const
Generator
&
lhs
,
const
Generator
&
rhs
)
const
{
return
lhs
.
contains
(
rhs
);
}
};
bool
isAlwaysHit
(
const
GSMustDomainPolicy
&
)
const
;
};
}
#endif // GS_MUST_ABSTRACT_VALUE_POLICY_H
src/GeneratorsSet/GSMustDomainPolicy.h
0 → 100644
View file @
415a43ed
#ifndef GS_MUST_DOMAIN_POLICY_H
#define GS_MUST_DOMAIN_POLICY_H
namespace
exactlru
{
class
GSMustDomainPolicy
{
public:
using
AbstractValue
=
GSAbstractValue
<
GSMustAbstractValuePolicy
>
;
GSMustDomainPolicy
(
const
otawa
::
icat3
::
LBlock
*
,
const
otawa
::
icat3
::
LBlockCollection
&
,
int
,
const
AbstractValue
*
)
{
}
AbstractValue
createBot
(
const
otawa
::
icat3
::
LBlock
*
,
const
otawa
::
icat3
::
LBlockCollection
&
,
int
)
{
return
AbstractValue
();
}
AbstractValue
createTop
(
const
otawa
::
icat3
::
LBlock
*
focus
,
const
otawa
::
icat3
::
LBlockCollection
&
coll
,
int
)
{
return
AbstractValue
({
Generator
(
focus
,
coll
.
A
(),
true
)});
}
void
fetch
(
AbstractValue
&
a
,
const
otawa
::
icat3
::
LBlock
*
lb
,
int
,
const
otawa
::
icat3
::
LBlock
*
)
{
a
.
update
(
lb
);
}
bool
isAlwaysHit
(
const
AbstractValue
&
a
)
const
{
return
a
.
isAlwaysHit
(
*
this
);
}
};
}
// namespace exactlru
#endif // GS_MUST_DOMAIN_POLICY_H
src/MayAnalysis/MayAnalysis.cpp
View file @
415a43ed
...
...
@@ -30,6 +30,10 @@
#include <otawa/icat3/features.h>
#include <exactlru/features.h>
#include <exactlru/MayAnalysis/MayManager.h>
#include "../ZDD/MayAbstractValuePolicy.h"
#include "../ZDD/ZDDMayDomainPolicy.h"
#include "../GeneratorsSet/GSMayAbstractValuePolicy.h"
#include "../GeneratorsSet/GSMayDomainPolicy.h"
#include "../Domain.h"
...
...
@@ -41,8 +45,8 @@ namespace exactlru
class
MayAdapter
{
public:
//
typedef Domain<ZDDMayDomainPolicy> domain_t;
typedef
Domain
<
GSMayDomainPolicy
>
domain_t
;
typedef
Domain
<
ZDDMayDomainPolicy
>
domain_t
;
//
typedef Domain<GSMayDomainPolicy> domain_t;
typedef
typename
domain_t
::
t
t
;
typedef
CompositeCFG
graph_t
;
typedef
ai
::
ArrayStore
<
domain_t
,
graph_t
>
store_t
;
...
...
@@ -105,7 +109,8 @@ class MayAnalysis : public Processor
{
public:
//using domain_t = Domain<ZDDMayDomainPolicy>;
using
domain_t
=
Domain
<
GSMayDomainPolicy
>
;
//using domain_t = Domain<GSMayDomainPolicy>;
using
domain_t
=
MayAdapter
::
domain_t
;
static
p
::
declare
reg
;
MayAnalysis
(
p
::
declare
&
r
=
reg
)
:
...
...
src/MustAnalysis/MustAnalysis.cpp
View file @
415a43ed
...
...
@@ -28,6 +28,10 @@