Skip to content
Snippets Groups Projects
Commit 56541776 authored by BAUQUIN Niels's avatar BAUQUIN Niels
Browse files

FG & FGS CORRECTION + IG

parent 802dc1a9
No related branches found
No related tags found
No related merge requests found
......@@ -48,9 +48,10 @@ public class Compiler
buildFg();
System.out.println("[SOLVE FLOW GRAPH]");
solveFg();
/*
System.out.println("[BUILD INTERFERENCE GRAPH] ");
buildIg();
/*
System.out.println("[ALLOCATE REGISTERS]");
interferenceGraph.allocateRegisters();
System.out.println("[PRINT NASM]");
......
......@@ -97,6 +97,16 @@ public class Fg implements NasmVisitor <Void> {
for (NasmInst nasmInst : list)
if (nasmInst.toString().equals(inst.toString()))
return true;
if (inst instanceof NasmMov) {
NasmRegister register = (NasmRegister) inst.destination;
return register.color == Nasm.REG_EDX;
}
return false;
}
......
......@@ -90,7 +90,7 @@ public class FgSolution{
break;
}
affiche("big caca");
}
......
......@@ -25,6 +25,30 @@ public class Ig {
}
public void build(){
for (NasmInst inst : fgs.in.keySet()) {
IntSet set = fgs.in.get(inst);
System.out.println(set);
List<Node> nodes = new ArrayList<>();
for (int i = 0; i < set.getSize(); i ++) {
if (set.isMember(i)) {
if (int2Node[i]==null)
int2Node[i] = graph.newNode();
nodes.add(int2Node[i]);
}
}
for (int i = 0; i < nodes.size(); i++ ) {
for (int j = 0; j < nodes.size(); j++) {
if (j == i)
j++;
if (j == nodes.size())
break;
graph.addEdge(nodes.get(i), nodes.get(j));
}
}
}
affiche("ptit caca en vif");
}
public void affiche(String baseFileName){
......@@ -45,6 +69,8 @@ public class Ig {
for(int i = 0; i < regNb; i++){
Node n = this.int2Node[i];
System.out.println(n);
if (n!=null) {
out.print(n + " : ( ");
for(NodeList q=n.succ(); q!=null; q=q.tail) {
out.print(q.head.toString());
......@@ -52,6 +78,8 @@ public class Ig {
}
out.println(")");
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment