Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
2024_compilation_bauquin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Insights
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
BAUQUIN Niels
2024_compilation_bauquin
Commits
802dc1a9
Commit
802dc1a9
authored
1 year ago
by
BAUQUIN Niels
Browse files
Options
Downloads
Patches
Plain Diff
FGS
parent
9144678c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/fg/FgSolution.java
+72
-14
72 additions, 14 deletions
src/fg/FgSolution.java
with
72 additions
and
14 deletions
src/fg/FgSolution.java
+
72
−
14
View file @
802dc1a9
...
@@ -22,7 +22,7 @@ public class FgSolution{
...
@@ -22,7 +22,7 @@ public class FgSolution{
this
.
in
=
new
HashMap
<
NasmInst
,
IntSet
>();
this
.
in
=
new
HashMap
<
NasmInst
,
IntSet
>();
this
.
out
=
new
HashMap
<
NasmInst
,
IntSet
>();
this
.
out
=
new
HashMap
<
NasmInst
,
IntSet
>();
int
intSetSize
=
nasm
.
getTempCounter
();
int
intSetSize
=
nasm
.
getTempCounter
();
iterNum
=
intSetSize
;
List
<
NasmInst
>
forbidden
=
fg
.
getForbiddenList
();
List
<
NasmInst
>
forbidden
=
fg
.
getForbiddenList
();
for
(
int
i
=
1
;
i
<
nasm
.
sectionText
.
size
();
i
++)
{
for
(
int
i
=
1
;
i
<
nasm
.
sectionText
.
size
();
i
++)
{
...
@@ -35,25 +35,79 @@ public class FgSolution{
...
@@ -35,25 +35,79 @@ public class FgSolution{
in
.
put
(
inst
,
new
IntSet
(
intSetSize
));
in
.
put
(
inst
,
new
IntSet
(
intSetSize
));
out
.
put
(
inst
,
new
IntSet
(
intSetSize
));
out
.
put
(
inst
,
new
IntSet
(
intSetSize
));
if
(
inst
.
srcDef
)
{
if
(
inst
.
srcDef
&&
inst
.
source
.
isGeneralRegister
())
{
def
.
get
(
inst
);
NasmRegister
source
=
(
NasmRegister
)
inst
.
source
;
def
.
get
(
inst
).
add
(
source
.
val
);
}
if
(
inst
.
srcUse
&&
inst
.
source
.
isGeneralRegister
())
{
NasmRegister
source
=
(
NasmRegister
)
inst
.
source
;
use
.
get
(
inst
).
add
(
source
.
val
);
}
if
(
inst
.
destDef
&&
inst
.
destination
.
isGeneralRegister
())
{
NasmRegister
destination
=
(
NasmRegister
)
inst
.
destination
;
def
.
get
(
inst
).
add
(
destination
.
val
);
}
if
(
inst
.
destUse
&&
inst
.
destination
.
isGeneralRegister
())
{
NasmRegister
destination
=
(
NasmRegister
)
inst
.
destination
;
use
.
get
(
inst
).
add
(
destination
.
val
);
}
}
if
(
inst
.
srcUse
){
use
.
get
(
inst
);
}
}
if
(
inst
.
destDef
){
while
(
true
)
{
def
.
get
(
inst
);
Map
<
NasmInst
,
IntSet
>
in2
=
getCopy
(
in
);
Map
<
NasmInst
,
IntSet
>
out2
=
getCopy
(
out
);
for
(
int
i
=
1
;
i
<
nasm
.
sectionText
.
size
();
i
++)
{
while
(
fg
.
secretMethod
(
nasm
.
sectionText
.
get
(
i
),
forbidden
))
{
i
++;
}
}
if
(
inst
.
destUse
){
NasmInst
inst
=
nasm
.
sectionText
.
get
(
i
);
use
.
get
(
inst
);
IntSet
temp
=
out
.
get
(
inst
).
copy
();
temp
.
minus
(
def
.
get
(
inst
));
temp
.
union
(
use
.
get
(
inst
));
in
.
put
(
inst
,
temp
);
NodeList
list
=
fg
.
inst2Node
.
get
(
inst
).
succ
();
IntSet
temp2
=
out
.
get
(
inst
).
copy
();
if
(
list
!=
null
)
while
(
true
)
{
temp2
.
union
(
in
.
get
(
fg
.
node2Inst
.
get
(
list
.
head
)));
if
(
list
.
tail
==
null
)
break
;
list
=
list
.
tail
;
}
}
out
.
put
(
inst
,
temp2
);
}
}
if
(
inAndOutEquals
(
in
,
in2
,
out
,
out2
))
break
;
}
}
}
Map
<
NasmInst
,
IntSet
>
getCopy
(
Map
<
NasmInst
,
IntSet
>
map
){
Map
<
NasmInst
,
IntSet
>
copy
=
new
HashMap
<>();
for
(
NasmInst
inst
:
map
.
keySet
())
copy
.
put
(
inst
,
map
.
get
(
inst
).
copy
());
return
copy
;
}
boolean
inAndOutEquals
(
Map
<
NasmInst
,
IntSet
>
in
,
Map
<
NasmInst
,
IntSet
>
in2
,
Map
<
NasmInst
,
IntSet
>
out
,
Map
<
NasmInst
,
IntSet
>
out2
)
{
for
(
NasmInst
inst
:
in
.
keySet
())
if
((!
in
.
get
(
inst
).
equal
(
in2
.
get
(
inst
)))
||
(!
out
.
get
(
inst
).
equal
(
out2
.
get
(
inst
))))
return
false
;
return
true
;
}
public
void
affiche
(
String
baseFileName
){
public
void
affiche
(
String
baseFileName
){
String
fileName
;
String
fileName
;
...
@@ -70,10 +124,14 @@ public class FgSolution{
...
@@ -70,10 +124,14 @@ public class FgSolution{
System
.
err
.
println
(
"Error: "
+
e
.
getMessage
());
System
.
err
.
println
(
"Error: "
+
e
.
getMessage
());
}
}
}
}
List
<
NasmInst
>
forbidden
=
fg
.
getForbiddenList
();
out
.
println
(
"iter num = "
+
iterNum
);
out
.
println
(
"iter num = "
+
iterNum
);
for
(
NasmInst
nasmInst
:
this
.
nasm
.
sectionText
){
for
(
int
i
=
1
;
i
<
nasm
.
sectionText
.
size
();
i
++)
{
out
.
println
(
"use = "
+
this
.
use
.
get
(
nasmInst
)
+
" def = "
+
this
.
def
.
get
(
nasmInst
)
+
"\tin = "
+
this
.
in
.
get
(
nasmInst
)
+
"\t \tout = "
+
this
.
out
.
get
(
nasmInst
)
+
"\t \t"
+
nasmInst
);
while
(
fg
.
secretMethod
(
nasm
.
sectionText
.
get
(
i
),
forbidden
))
{
i
++;
}
out
.
println
(
"use = "
+
this
.
use
.
get
(
nasm
.
sectionText
.
get
(
i
))
+
" def = "
+
this
.
def
.
get
(
nasm
.
sectionText
.
get
(
i
))
+
"\tin = "
+
this
.
in
.
get
(
nasm
.
sectionText
.
get
(
i
))
+
"\t \tout = "
+
this
.
out
.
get
(
nasm
.
sectionText
.
get
(
i
))
+
"\t \t"
+
nasm
.
sectionText
.
get
(
i
));
}
}
}
}
...
...
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