mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-02-20 00:29:10 +00:00
A few renames and better doc.
This commit is contained in:
parent
d501534561
commit
45e64d59f1
@ -3,7 +3,9 @@ package dk.camelot64.kickc.icl;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/** The call graph for the entire control flow graph, */
|
||||
/** The call graph for the entire control flow graph.
|
||||
* Created by {@link dk.camelot64.kickc.passes.Pass3CallGraphAnalysis}
|
||||
* */
|
||||
public class CallGraph {
|
||||
|
||||
private List<CallBlock> callBlocks;
|
||||
|
@ -32,7 +32,7 @@ public class LiveRangeEquivalenceClass {
|
||||
if(variables.contains(variable)) {
|
||||
return;
|
||||
}
|
||||
VariableLiveRanges liveRanges = program.getScope().getLiveRanges();
|
||||
LiveRangeVariables liveRanges = program.getScope().getLiveRanges();
|
||||
LiveRange varLiveRange = liveRanges.getLiveRange(variable);
|
||||
if (classLiveRange.overlaps(varLiveRange)) {
|
||||
throw new RuntimeException("Compilation error! Variable live range overlaps live range equivalence class live range. " + variable);
|
||||
|
@ -4,12 +4,14 @@ import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
/** Live ranges for all variables. */
|
||||
public class VariableLiveRanges {
|
||||
/** Live ranges for all variables.
|
||||
* Created by * Created by {@link dk.camelot64.kickc.passes.Pass3CallGraphAnalysis}
|
||||
*/
|
||||
public class LiveRangeVariables {
|
||||
|
||||
private LinkedHashMap<VariableRef, LiveRange> liveRanges;
|
||||
|
||||
public VariableLiveRanges() {
|
||||
public LiveRangeVariables() {
|
||||
this.liveRanges = new LinkedHashMap<>();
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import java.util.Set;
|
||||
|
||||
/** A set of natural loops in a control flow graph.
|
||||
* <p>For definitions and more see http://www.cs.colostate.edu/~cs553/ClassNotes/lecture09-control-dominators.ppt.pdf
|
||||
* <p>Created by {@link dk.camelot64.kickc.passes.Pass3LoopAnalysis}
|
||||
* */
|
||||
public class NaturalLoopSet {
|
||||
|
||||
|
@ -11,7 +11,7 @@ public class ProgramScope extends Scope {
|
||||
|
||||
private RegisterAllocation allocation;
|
||||
|
||||
private VariableLiveRanges liveRanges;
|
||||
private LiveRangeVariables liveRanges;
|
||||
|
||||
public ProgramScope() {
|
||||
super("", null);
|
||||
@ -50,11 +50,11 @@ public class ProgramScope extends Scope {
|
||||
return allocation;
|
||||
}
|
||||
|
||||
public void setLiveRanges(VariableLiveRanges liveRanges) {
|
||||
public void setLiveRanges(LiveRangeVariables liveRanges) {
|
||||
this.liveRanges = liveRanges;
|
||||
}
|
||||
|
||||
public VariableLiveRanges getLiveRanges() {
|
||||
public LiveRangeVariables getLiveRanges() {
|
||||
return liveRanges;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ public abstract class StatementBase implements Statement {
|
||||
if(scope==null || scope.getLiveRanges()==null) {
|
||||
return "";
|
||||
}
|
||||
VariableLiveRanges liveRanges = scope.getLiveRanges();
|
||||
LiveRangeVariables liveRanges = scope.getLiveRanges();
|
||||
List<VariableRef> alive = liveRanges.getAlive(this);
|
||||
StringBuilder str = new StringBuilder();
|
||||
str.append(" [ ");
|
||||
|
@ -23,7 +23,7 @@ public class Pass3LiveRangesAnalysis {
|
||||
|
||||
public void findLiveRanges() {
|
||||
generateStatementIndexes();
|
||||
VariableLiveRanges liveRanges = initializeLiveRanges();
|
||||
LiveRangeVariables liveRanges = initializeLiveRanges();
|
||||
program.getScope().setLiveRanges(liveRanges);
|
||||
//log.append("CONTROL FLOW GRAPH - LIVE RANGES");
|
||||
//log.append(program.getGraph().toString(program.getScope()));
|
||||
@ -57,7 +57,7 @@ public class Pass3LiveRangesAnalysis {
|
||||
*
|
||||
* @return The initial live ranges.
|
||||
*/
|
||||
private VariableLiveRanges initializeLiveRanges() {
|
||||
private LiveRangeVariables initializeLiveRanges() {
|
||||
LiveRangeInitializer liveRangeInitializer = new LiveRangeInitializer(program);
|
||||
return liveRangeInitializer.initialize();
|
||||
}
|
||||
@ -65,7 +65,7 @@ public class Pass3LiveRangesAnalysis {
|
||||
private static class LiveRangeInitializer extends ControlFlowGraphBaseVisitor<Void> {
|
||||
|
||||
private final Program program;
|
||||
private VariableLiveRanges liveRanges;
|
||||
private LiveRangeVariables liveRanges;
|
||||
|
||||
/**
|
||||
* Contains the previous statement through the iteration of each block. null if this statement is the first in the block.
|
||||
@ -78,10 +78,10 @@ public class Pass3LiveRangesAnalysis {
|
||||
|
||||
public LiveRangeInitializer(Program program) {
|
||||
this.program = program;
|
||||
this.liveRanges = new VariableLiveRanges();
|
||||
this.liveRanges = new LiveRangeVariables();
|
||||
}
|
||||
|
||||
public VariableLiveRanges initialize() {
|
||||
public LiveRangeVariables initialize() {
|
||||
this.visitGraph(program.getGraph());
|
||||
return liveRanges;
|
||||
}
|
||||
@ -195,7 +195,7 @@ public class Pass3LiveRangesAnalysis {
|
||||
*
|
||||
* @return true if any propagation was done. (and more propagation is necessary to complete the live ranges)
|
||||
*/
|
||||
private boolean propagateLiveRanges(VariableLiveRanges liveRanges) {
|
||||
private boolean propagateLiveRanges(LiveRangeVariables liveRanges) {
|
||||
LiveRangePropagator liveRangePropagator = new LiveRangePropagator(program, liveRanges);
|
||||
return liveRangePropagator.propagate();
|
||||
}
|
||||
@ -210,7 +210,7 @@ public class Pass3LiveRangesAnalysis {
|
||||
/**
|
||||
* The variable live ranges being propagated.
|
||||
*/
|
||||
private VariableLiveRanges liveRanges;
|
||||
private LiveRangeVariables liveRanges;
|
||||
|
||||
/**
|
||||
* Has anything been modified.
|
||||
@ -227,7 +227,7 @@ public class Pass3LiveRangesAnalysis {
|
||||
*/
|
||||
private ControlFlowBlock currentBlock;
|
||||
|
||||
public LiveRangePropagator(Program program, VariableLiveRanges liveRanges) {
|
||||
public LiveRangePropagator(Program program, LiveRangeVariables liveRanges) {
|
||||
this.program = program;
|
||||
this.liveRanges = liveRanges;
|
||||
this.modified = false;
|
||||
|
@ -82,11 +82,11 @@ public class Pass4ZeroPageAllocationLiveRange {
|
||||
}
|
||||
|
||||
private void addToEquivalenceClassSet(VariableRef lValVar, List<VariableRef> preferences) {
|
||||
VariableLiveRanges variableLiveRanges = program.getScope().getLiveRanges();
|
||||
LiveRangeVariables liveRangeVariables = program.getScope().getLiveRanges();
|
||||
LiveRangeEquivalenceClass lValEquivalenceClass =
|
||||
liveRangeEquivalenceClassSet.getEquivalenceClass(lValVar);
|
||||
if(lValEquivalenceClass==null) {
|
||||
LiveRange lValLiveRange = variableLiveRanges.getLiveRange(lValVar);
|
||||
LiveRange lValLiveRange = liveRangeVariables.getLiveRange(lValVar);
|
||||
// Variable in need of an equivalence class - Look through preferences
|
||||
LiveRangeEquivalenceClass chosen = null;
|
||||
for (VariableRef preference : preferences) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user