Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
infosec-ecomp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cidre-public
Compilation
infosec-ecomp
Commits
ae384a8f
Commit
ae384a8f
authored
5 years ago
by
Wilke Pierre
Browse files
Options
Downloads
Patches
Plain Diff
sujet TP RTL + modifications mineures
parent
8b38e0b0
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
Sujet.pdf
+0
-0
0 additions, 0 deletions
Sujet.pdf
src/cfg.ml
+9
-25
9 additions, 25 deletions
src/cfg.ml
src/elang_run.ml
+1
-2
1 addition, 2 deletions
src/elang_run.ml
src/main.ml
+1
-1
1 addition, 1 deletion
src/main.ml
src/rtl_gen.ml
+6
-4
6 additions, 4 deletions
src/rtl_gen.ml
with
17 additions
and
32 deletions
Sujet.pdf
+
0
−
0
View file @
ae384a8f
No preview for this file type
This diff is collapsed.
Click to expand it.
src/cfg.ml
+
9
−
25
View file @
ae384a8f
...
...
@@ -26,18 +26,20 @@ type cfg_fun = {
type
cprog
=
cfg_fun
prog
(* [succs cfg n] gives the successors of a node [n] in a CFG [cfg]. *)
(* [succs cfg n] donne l'ensemble des successeurs d'un nœud [n] dans un CFG
[cfg]. *)
let
succs
cfg
n
=
match
Hashtbl
.
find_option
cfg
n
with
|
None
->
[]
|
None
->
Set
.
empty
|
Some
(
Cprint
(
_
,
s
))
|
Some
(
Cassign
(
_
,
_
,
s
))
->
[
s
]
|
Some
(
Creturn
_
)
->
[]
|
Some
(
Ccmp
(
_
,
s1
,
s2
))
->
[
s1
;
s2
]
|
Some
(
Cnop
s
)
->
[
s
]
|
Some
(
Cassign
(
_
,
_
,
s
))
->
Set
.
singleton
s
|
Some
(
Creturn
_
)
->
Set
.
empty
|
Some
(
Ccmp
(
_
,
s1
,
s2
))
->
Set
.
of_list
[
s1
;
s2
]
|
Some
(
Cnop
s
)
->
Set
.
singleton
s
(* [preds n] gives the list of predecessors of a node [n]. *)
(* [preds cfg n] donne l'ensemble des prédécesseurs d'un nœud [n] dans un CFG [cfg]
*)
let
preds
cfgfunbody
n
=
Hashtbl
.
fold
(
fun
m
m'
acc
->
match
m'
with
...
...
@@ -73,21 +75,3 @@ let rec size_instr (i: cfg_node) : int =
let
size_fun
f
=
Hashtbl
.
fold
(
fun
k
v
acc
->
acc
+
size_instr
v
)
f
0
let
fixpoint
(
transfer
:
(
int
,
cfg_node
)
Hashtbl
.
t
->
(
int
,
'
a
)
Hashtbl
.
t
->
int
->
'
a
)
(
init
:
(
int
,
cfg_node
)
Hashtbl
.
t
->
int
->
cfg_node
->
'
a
)
(
cfg
:
(
int
,
cfg_node
)
Hashtbl
.
t
)
:
(
int
,
'
a
)
Hashtbl
.
t
=
let
res
=
Hashtbl
.
map
(
fun
k
v
->
init
cfg
k
v
)
cfg
in
let
iter
res
=
Hashtbl
.
fold
(
fun
n
oldstate
changed
->
let
newstate
=
transfer
cfg
res
n
in
Hashtbl
.
replace
res
n
newstate
;
changed
||
not
(
Set
.
equal
newstate
oldstate
)
)
res
false
in
let
rec
fix
()
=
if
iter
res
then
fix
()
else
()
in
fix
()
;
res
This diff is collapsed.
Click to expand it.
src/elang_run.ml
+
1
−
2
View file @
ae384a8f
...
...
@@ -85,8 +85,7 @@ let eval_eprog oc (ep: eprog) (memsize: int) (params: int list)
:
int
option
res
=
let
st
=
init_state
memsize
in
find_function
ep
"main"
>>=
fun
f
->
(* trim the parameter list to only take as many as required by the function.
*)
(* ne garde que le nombre nécessaire de paramètres pour la fonction "main". *)
let
n
=
List
.
length
f
.
funargs
in
let
params
=
take
n
params
in
eval_efun
oc
st
f
"main"
params
>>=
fun
(
v
,
st
)
->
...
...
This diff is collapsed.
Click to expand it.
src/main.ml
+
1
−
1
View file @
ae384a8f
...
...
@@ -161,7 +161,7 @@ let dump file dumpf p additional_command =
(
Format
.
formatter_of_out_channel
oc
,
fun
()
->
close_out
oc
)
in
dumpf
oc
p
;
close
()
;
additional_command
file
()
if
file
<>
"-"
then
additional_command
file
()
end
...
...
This diff is collapsed.
Click to expand it.
src/rtl_gen.ml
+
6
−
4
View file @
ae384a8f
...
...
@@ -25,10 +25,9 @@ open Utils
*)
let
find_var
(
next_reg
,
var2reg
)
v
=
begin
match
List
.
assoc_opt
v
var2reg
with
match
List
.
assoc_opt
v
var2reg
with
|
Some
r
->
(
r
,
next_reg
,
var2reg
)
|
None
->
(
next_reg
,
next_reg
+
1
,
assoc_set
var2reg
v
next_reg
)
end
(* [rtl_instrs_of_cfg_expr (next_reg, var2reg) e] construit une liste
d'instructions RTL correspondant à l'évaluation d'une expression E.
...
...
@@ -52,9 +51,12 @@ let is_cmp_op =
|
Ecne
->
Some
Rcne
|
_
->
None
let
is
_cmp
(
e
:
expr
)
=
let
rtl
_cmp
_of_cfg_expr
(
e
:
expr
)
=
match
e
with
|
Ebinop
(
b
,
e1
,
e2
)
->
(
match
is_cmp_op
b
with
|
None
->
(
Rcne
,
e
,
Eint
0
)
|
Some
rop
->
(
rop
,
e1
,
e2
))
|
Ebinop
(
b
,
e1
,
e2
)
->
(
match
is_cmp_op
b
with
|
None
->
(
Rcne
,
e
,
Eint
0
)
|
Some
rop
->
(
rop
,
e1
,
e2
))
|
_
->
(
Rcne
,
e
,
Eint
0
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment