comparison graal/com.oracle.graal.lir/src/com/oracle/graal/lir/framemap/SimpleStackSlotAllocator.java @ 19021:252067cb86ad

Remove FrameMappingTool.
author Josef Eisl <josef.eisl@jku.at>
date Wed, 03 Dec 2014 20:34:57 +0100
parents eb2a8bb3c2c4
children 0be248fb42b2
comparison
equal deleted inserted replaced
19020:312cf5a0376e 19021:252067cb86ad
20 * or visit www.oracle.com if you need additional information or have any 20 * or visit www.oracle.com if you need additional information or have any
21 * questions. 21 * questions.
22 */ 22 */
23 package com.oracle.graal.lir.framemap; 23 package com.oracle.graal.lir.framemap;
24 24
25 import static com.oracle.graal.api.code.ValueUtil.*;
26
25 import com.oracle.graal.api.code.*; 27 import com.oracle.graal.api.code.*;
26 import com.oracle.graal.compiler.common.*; 28 import com.oracle.graal.compiler.common.*;
29 import com.oracle.graal.compiler.common.cfg.*;
30 import com.oracle.graal.debug.*;
31 import com.oracle.graal.debug.Debug.*;
32 import com.oracle.graal.lir.*;
33 import com.oracle.graal.lir.gen.*;
27 34
28 public class SimpleStackSlotAllocator implements StackSlotAllocator { 35 public class SimpleStackSlotAllocator implements StackSlotAllocator {
29 36
30 public FrameMappingTool allocateStackSlots(FrameMapBuilderImpl builder) { 37 public void allocateStackSlots(FrameMapBuilderImpl builder, LIRGenerationResult res) {
31 StackSlot[] mapping = new StackSlot[builder.getNumberOfStackSlots()]; 38 StackSlot[] mapping = new StackSlot[builder.getNumberOfStackSlots()];
32 for (VirtualStackSlot virtualSlot : builder.getStackSlots()) { 39 for (VirtualStackSlot virtualSlot : builder.getStackSlots()) {
33 final StackSlot slot; 40 final StackSlot slot;
34 if (virtualSlot instanceof SimpleVirtualStackSlot) { 41 if (virtualSlot instanceof SimpleVirtualStackSlot) {
35 slot = mapSimpleVirtualStackSlot(builder, (SimpleVirtualStackSlot) virtualSlot); 42 slot = mapSimpleVirtualStackSlot(builder, (SimpleVirtualStackSlot) virtualSlot);
38 } else { 45 } else {
39 throw GraalInternalError.shouldNotReachHere("Unknown VirtualStackSlot: " + virtualSlot); 46 throw GraalInternalError.shouldNotReachHere("Unknown VirtualStackSlot: " + virtualSlot);
40 } 47 }
41 mapping[virtualSlot.getId()] = slot; 48 mapping[virtualSlot.getId()] = slot;
42 } 49 }
43 return v -> mapping[v.getId()]; 50 updateLIR(res, mapping);
51 }
52
53 protected void updateLIR(LIRGenerationResult res, StackSlot[] mapping) {
54 try (Scope scope = Debug.scope("StackSlotMappingLIR")) {
55 ValueProcedure updateProc = (value, mode, flags) -> {
56 if (isVirtualStackSlot(value)) {
57 StackSlot stackSlot = mapping[asVirtualStackSlot(value).getId()];
58 Debug.log("map %s -> %s", value, stackSlot);
59 return stackSlot;
60 }
61 return value;
62 };
63 for (AbstractBlock<?> block : res.getLIR().getControlFlowGraph().getBlocks()) {
64 try (Indent indent0 = Debug.logAndIndent("block: %s", block)) {
65 for (LIRInstruction inst : res.getLIR().getLIRforBlock(block)) {
66 try (Indent indent1 = Debug.logAndIndent("Inst: %d: %s", inst.id(), inst)) {
67 inst.forEachAlive(updateProc);
68 inst.forEachInput(updateProc);
69 inst.forEachOutput(updateProc);
70 inst.forEachTemp(updateProc);
71 inst.forEachState(updateProc);
72 }
73 }
74 }
75 }
76 }
44 } 77 }
45 78
46 protected StackSlot mapSimpleVirtualStackSlot(FrameMapBuilderImpl builder, SimpleVirtualStackSlot virtualStackSlot) { 79 protected StackSlot mapSimpleVirtualStackSlot(FrameMapBuilderImpl builder, SimpleVirtualStackSlot virtualStackSlot) {
47 return builder.frameMap.allocateSpillSlot(virtualStackSlot.getLIRKind()); 80 return builder.frameMap.allocateSpillSlot(virtualStackSlot.getLIRKind());
48 } 81 }