1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-04-08 14:37:40 +00:00

Improving ssa_mem variable support.

This commit is contained in:
jespergravgaard 2020-02-10 00:33:16 +01:00
parent 353d45ab65
commit bd9a403b64
2 changed files with 10 additions and 6 deletions

View File

@ -531,8 +531,9 @@ public class Pass4CodeGeneration {
setCurrentSegment(variable.getDataSegment(), asm);
// Add any comments
generateComments(asm, variable.getComments());
if(!mainVar.getAsmName().equals(variable.getAsmName())) {
asm.addLabelDecl(variable.getAsmName(), AsmFormat.getAsmConstant(program, new ConstantSymbolPointer(mainVar.getRef()), 99, scopeRef));
final String mainAsmName = AsmFormat.getAsmConstant(program, new ConstantSymbolPointer(mainVar.getRef()), 99, scopeRef);
if(!mainAsmName.equals(variable.getAsmName())) {
asm.addLabelDecl(variable.getAsmName(), mainAsmName);
} else {
// Add any alignment
Integer declaredAlignment = variable.getMemoryAlignment();

View File

@ -1,9 +1,6 @@
package dk.camelot64.kickc.passes;
import dk.camelot64.kickc.model.CallGraph;
import dk.camelot64.kickc.model.LiveRangeEquivalenceClass;
import dk.camelot64.kickc.model.LiveRangeEquivalenceClassSet;
import dk.camelot64.kickc.model.Program;
import dk.camelot64.kickc.model.*;
import dk.camelot64.kickc.model.values.ScopeRef;
import dk.camelot64.kickc.model.values.VariableRef;
@ -54,6 +51,9 @@ public class Pass4MemoryCoalesceCallGraph extends Pass2Base {
List<LiveRangeEquivalenceClass> handledECs = new ArrayList<>();
List<LiveRangeEquivalenceClass> allECs = new ArrayList<>(liveRangeEquivalenceClassSet.getEquivalenceClasses());
for(LiveRangeEquivalenceClass thisEC : allECs) {
// Skip main-memory registers
if(Registers.RegisterType.MAIN_MEM.equals(thisEC.getRegister().getType()))
continue;
// Find all calling scopes - since we want to avoid coalescing with variables in these
Set<ScopeRef> allCallingScopes = new LinkedHashSet<>();
for(ScopeRef ecScope : getEquivalenceClassScopes(thisEC)) {
@ -62,6 +62,9 @@ public class Pass4MemoryCoalesceCallGraph extends Pass2Base {
// Go through the already handled equivalence classes - and try to coalesce with any that does not have variables from the calling scopes
boolean coalesced = false;
for(LiveRangeEquivalenceClass otherEC : handledECs) {
// Skip main-memory registers
if(Registers.RegisterType.MAIN_MEM.equals(otherEC.getRegister().getType()))
continue;
// Skip if there is a scope overlap
if(isScopeOverlap(otherEC, allCallingScopes))
continue;