# HG changeset patch # User Roland Schatz # Date 1413279490 -7200 # Node ID f609dff05ea0d869bbeafa5c7acc2afcc28d3f5e # Parent 50942f0169679128478f9120c7f8d7290a817011 Output correct register names in register maps in CFGPrinter. diff -r 50942f016967 -r f609dff05ea0 graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CodeUtil.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CodeUtil.java Mon Oct 13 15:52:19 2014 -0700 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CodeUtil.java Tue Oct 14 11:38:10 2014 +0200 @@ -326,9 +326,44 @@ } /** + * Formats a location in a register reference map. + */ + public static class DefaultRegFormatter implements RefMapFormatter { + + private final Register[] registers; + + public DefaultRegFormatter(Architecture arch) { + registers = new Register[arch.getRegisterReferenceMapSize()]; + for (Register r : arch.getRegisters()) { + if (r.getReferenceMapIndex() >= 0) { + registers[r.getReferenceMapIndex()] = r; + } + } + } + + public String formatStackSlot(int frameRefMapIndex) { + return null; + } + + public String formatRegister(int regRefMapIndex) { + int i = regRefMapIndex; + int idx = 0; + while (registers[i] == null) { + i--; + idx++; + } + if (idx == 0) { + return registers[i].toString(); + } else { + return String.format("%s+%d", registers[i].toString(), idx); + } + } + } + + /** * Formats a location present in a register or frame reference map. */ - public static class DefaultRefMapFormatter implements RefMapFormatter { + public static class DefaultRefMapFormatter extends DefaultRegFormatter { /** * The size of a stack slot. @@ -340,10 +375,6 @@ */ public final Register fp; - public final Architecture arch; - - private final Register[] registers; - /** * The offset (in bytes) from the slot pointed to by {@link #fp} to the slot corresponding * to bit 0 in the frame reference map. @@ -351,13 +382,13 @@ public final int refMapToFPOffset; public DefaultRefMapFormatter(Architecture arch, int slotSize, Register fp, int refMapToFPOffset) { - this.arch = arch; + super(arch); this.slotSize = slotSize; this.fp = fp; this.refMapToFPOffset = refMapToFPOffset; - this.registers = arch.getRegisters(); } + @Override public String formatStackSlot(int frameRefMapIndex) { int refMapOffset = frameRefMapIndex * slotSize; int fpOffset = refMapOffset + refMapToFPOffset; @@ -366,10 +397,6 @@ } return fp.name + fpOffset; } - - public String formatRegister(int regRefMapIndex) { - return registers[regRefMapIndex].toString(); - } } public static class NumberedRefMapFormatter implements RefMapFormatter { diff -r 50942f016967 -r f609dff05ea0 graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CompilationPrinter.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CompilationPrinter.java Mon Oct 13 15:52:19 2014 -0700 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CompilationPrinter.java Tue Oct 14 11:38:10 2014 +0200 @@ -112,23 +112,6 @@ end("compilation"); } - private static class ArchitectureRegFormatter implements RefMapFormatter { - - private final Register[] registers; - - public ArchitectureRegFormatter(Architecture arch) { - registers = arch.getRegisters(); - } - - public String formatStackSlot(int frameRefMapIndex) { - return null; - } - - public String formatRegister(int regRefMapIndex) { - return registers[regRefMapIndex].toString(); - } - } - /** * Formats given debug info as a multi line string. */ @@ -138,7 +121,7 @@ if (refMap != null && refMap.hasRegisterRefMap()) { sb.append("reg-ref-map:"); - refMap.appendRegisterMap(sb, arch != null ? new ArchitectureRegFormatter(arch) : formatter); + refMap.appendRegisterMap(sb, arch != null ? new CodeUtil.DefaultRegFormatter(arch) : formatter); sb.append("\n"); }