Mercurial > hg > graal-compiler
changeset 22224:1cf2b4143f3c
[SPARC] Use registers g1, g4 and g5 for allocation and g3 and o7 as scratch
line wrap: on
line diff
--- a/graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCMacroAssembler.java Mon Jul 13 17:36:11 2015 +0200 +++ b/graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCMacroAssembler.java Mon Jul 13 18:33:44 2015 +0200 @@ -39,7 +39,7 @@ * patched. */ private static final SPARCAddress Placeholder = new SPARCAddress(g0, 0); - private final ScratchRegister[] scratchRegister = new ScratchRegister[]{new ScratchRegister(g1), new ScratchRegister(g3)}; + private final ScratchRegister[] scratchRegister = new ScratchRegister[]{new ScratchRegister(g3), new ScratchRegister(o7)}; // Points to the next free scratch register private int nextFreeScratchRegister = 0; /**
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCDeoptimizeOp.java Mon Jul 13 17:36:11 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCDeoptimizeOp.java Mon Jul 13 18:33:44 2015 +0200 @@ -23,6 +23,8 @@ package com.oracle.graal.hotspot.sparc; import static com.oracle.graal.hotspot.HotSpotHostBackend.*; +import jdk.internal.jvmci.meta.*; +import jdk.internal.jvmci.sparc.*; import com.oracle.graal.asm.sparc.*; import com.oracle.graal.lir.*; @@ -34,12 +36,13 @@ final class SPARCDeoptimizeOp extends SPARCLIRInstruction implements BlockEndOp { public static final LIRInstructionClass<SPARCDeoptimizeOp> TYPE = LIRInstructionClass.create(SPARCDeoptimizeOp.class); public static final SizeEstimate SIZE = SizeEstimate.create(1); - + @Temp AllocatableValue pcRegister; @State private LIRFrameState info; - SPARCDeoptimizeOp(LIRFrameState info) { + SPARCDeoptimizeOp(LIRFrameState info, PlatformKind wordKind) { super(TYPE, SIZE); this.info = info; + pcRegister = SPARC.o7.asValue(LIRKind.value(wordKind)); } @Override @@ -52,6 +55,6 @@ // [Deopt Handler Code] // 0xffffffff749bb60c: call 0xffffffff748da540 ; {runtime_call} // 0xffffffff749bb610: nop - SPARCCall.directCall(crb, masm, crb.foreignCalls.lookupForeignCall(UNCOMMON_TRAP_HANDLER), null, false, info); + SPARCCall.directCall(crb, masm, crb.foreignCalls.lookupForeignCall(UNCOMMON_TRAP_HANDLER), null, info); } }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java Mon Jul 13 17:36:11 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java Mon Jul 13 18:33:44 2015 +0200 @@ -332,9 +332,9 @@ HotSpotForeignCallsProvider foreignCalls = getProviders().getForeignCalls(); if (!frameContext.isStub) { crb.recordMark(config.MARKID_EXCEPTION_HANDLER_ENTRY); - SPARCCall.directCall(crb, masm, foreignCalls.lookupForeignCall(EXCEPTION_HANDLER), null, false, null); + SPARCCall.directCall(crb, masm, foreignCalls.lookupForeignCall(EXCEPTION_HANDLER), null, null); crb.recordMark(config.MARKID_DEOPT_HANDLER_ENTRY); - SPARCCall.directCall(crb, masm, foreignCalls.lookupForeignCall(DEOPTIMIZATION_HANDLER), null, false, null); + SPARCCall.directCall(crb, masm, foreignCalls.lookupForeignCall(DEOPTIMIZATION_HANDLER), null, null); } else { // No need to emit the stubs for entries back into the method since // it has no calls that can cause such "return" entries
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java Mon Jul 13 17:36:11 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java Mon Jul 13 18:33:44 2015 +0200 @@ -99,6 +99,9 @@ Set<Register> callerSavedRegisters = new HashSet<>(); Collections.addAll(callerSavedRegisters, regConfig.getCalleeSaveLayout().registers); Collections.addAll(callerSavedRegisters, SPARC.fpuRegisters); + callerSavedRegisters.add(SPARC.g1); + callerSavedRegisters.add(SPARC.g4); + callerSavedRegisters.add(SPARC.g5); Value[] nativeABICallerSaveRegisters = new Value[callerSavedRegisters.size()]; int i = 0; for (Register reg : callerSavedRegisters) {
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCRuntimeCallPrologueOp.java Mon Jul 13 17:36:11 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCRuntimeCallPrologueOp.java Mon Jul 13 18:33:44 2015 +0200 @@ -22,10 +22,11 @@ */ package com.oracle.graal.hotspot.sparc; +import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; +import static jdk.internal.jvmci.code.ValueUtil.*; +import static jdk.internal.jvmci.sparc.SPARC.*; import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.meta.*; -import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; -import static jdk.internal.jvmci.sparc.SPARC.*; import com.oracle.graal.asm.sparc.*; import com.oracle.graal.lir.*; @@ -41,20 +42,23 @@ private final Register thread; private final Register stackPointer; @Def({REG, STACK}) protected Value threadTemp; + @Temp({REG}) protected AllocatableValue spScratch; - public SPARCHotSpotCRuntimeCallPrologueOp(int threadLastJavaSpOffset, Register thread, Register stackPointer, Value threadTemp) { + public SPARCHotSpotCRuntimeCallPrologueOp(int threadLastJavaSpOffset, Register thread, Register stackPointer, Value threadTemp, AllocatableValue spScratch) { super(TYPE, SIZE); this.threadLastJavaSpOffset = threadLastJavaSpOffset; this.thread = thread; this.stackPointer = stackPointer; this.threadTemp = threadTemp; + this.spScratch = spScratch; } @Override public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { // Save last Java frame. - masm.add(stackPointer, STACK_BIAS, g4); - masm.stx(g4, new SPARCAddress(thread, threadLastJavaSpOffset)); + Register scratchRegister = asRegister(spScratch); + masm.add(stackPointer, STACK_BIAS, scratchRegister); + masm.stx(scratchRegister, new SPARCAddress(thread, threadLastJavaSpOffset)); // Save the thread register when calling out to the runtime. SPARCMove.move(crb, masm, threadTemp, thread.asValue(LIRKind.value(Kind.Long)), delayedControlTransfer);
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotEnterUnpackFramesStackFrameOp.java Mon Jul 13 17:36:11 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotEnterUnpackFramesStackFrameOp.java Mon Jul 13 18:33:44 2015 +0200 @@ -22,11 +22,12 @@ */ package com.oracle.graal.hotspot.sparc; +import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; +import static jdk.internal.jvmci.code.ValueUtil.*; +import static jdk.internal.jvmci.meta.LIRKind.*; +import static jdk.internal.jvmci.sparc.SPARC.*; import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.meta.*; -import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; -import static jdk.internal.jvmci.code.ValueUtil.*; -import static jdk.internal.jvmci.sparc.SPARC.*; import com.oracle.graal.asm.sparc.*; import com.oracle.graal.hotspot.*; @@ -48,8 +49,10 @@ @Alive(REG) AllocatableValue framePc; @Alive(REG) AllocatableValue senderSp; @Temp(REG) AllocatableValue scratch; + @Temp(REG) AllocatableValue callerReturnPc; - SPARCHotSpotEnterUnpackFramesStackFrameOp(Register thread, int threadLastJavaSpOffset, int threadLastJavaPcOffset, AllocatableValue framePc, AllocatableValue senderSp, AllocatableValue scratch) { + SPARCHotSpotEnterUnpackFramesStackFrameOp(Register thread, int threadLastJavaSpOffset, int threadLastJavaPcOffset, AllocatableValue framePc, AllocatableValue senderSp, AllocatableValue scratch, + PlatformKind wordKind) { super(TYPE); this.thread = thread; this.threadLastJavaSpOffset = threadLastJavaSpOffset; @@ -57,6 +60,7 @@ this.framePc = framePc; this.senderSp = senderSp; this.scratch = scratch; + callerReturnPc = o7.asValue(value(wordKind)); } @Override @@ -70,7 +74,7 @@ masm.mov(senderSpRegister, o5); // Load final frame PC. - masm.mov(framePcRegister, o7); + masm.mov(framePcRegister, asRegister(callerReturnPc)); // Allocate a full sized frame. masm.save(sp, -totalFrameSize, sp);
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Mon Jul 13 17:36:11 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Mon Jul 13 18:33:44 2015 +0200 @@ -33,7 +33,7 @@ import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.common.*; import jdk.internal.jvmci.hotspot.*; -import jdk.internal.jvmci.hotspot.HotSpotVMConfig.*; +import jdk.internal.jvmci.hotspot.HotSpotVMConfig.CompressEncoding; import jdk.internal.jvmci.meta.*; import jdk.internal.jvmci.sparc.*; @@ -142,7 +142,8 @@ Register thread = registers.getThreadRegister(); Value threadTemp = newVariable(LIRKind.value(Kind.Long)); Register stackPointer = registers.getStackPointerRegister(); - append(new SPARCHotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), thread, stackPointer, threadTemp)); + Variable spScratch = newVariable(LIRKind.value(target().wordKind)); + append(new SPARCHotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), thread, stackPointer, threadTemp, spScratch)); result = super.emitForeignCall(hotspotLinkage, debugInfo, args); append(new SPARCHotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaPcOffset(), config.threadJavaFrameAnchorFlagsOffset(), thread, threadTemp)); } else { @@ -192,7 +193,7 @@ @Override public void emitDeoptimize(Value actionAndReason, Value speculation, LIRFrameState state) { moveDeoptValuesToThread(actionAndReason, speculation); - append(new SPARCDeoptimizeOp(state)); + append(new SPARCDeoptimizeOp(state, target().wordKind)); } @Override @@ -399,7 +400,8 @@ Variable framePcVariable = load(framePc); Variable senderSpVariable = load(senderSp); Variable scratchVariable = newVariable(LIRKind.value(getHostWordKind())); - append(new SPARCHotSpotEnterUnpackFramesStackFrameOp(thread, config.threadLastJavaSpOffset(), config.threadLastJavaPcOffset(), framePcVariable, senderSpVariable, scratchVariable)); + append(new SPARCHotSpotEnterUnpackFramesStackFrameOp(thread, config.threadLastJavaSpOffset(), config.threadLastJavaPcOffset(), framePcVariable, senderSpVariable, scratchVariable, + target().wordKind)); } public void emitLeaveUnpackFramesStackFrame(SaveRegistersOp saveRegisterOp) { @@ -419,10 +421,11 @@ ForeignCallLinkage linkage = getForeignCalls().lookupForeignCall(UNCOMMON_TRAP); Register threadRegister = getProviders().getRegisters().getThreadRegister(); - Value threadTemp = newVariable(LIRKind.value(Kind.Long)); + Value threadTemp = newVariable(LIRKind.value(target().wordKind)); Register stackPointerRegister = getProviders().getRegisters().getStackPointerRegister(); - append(new SPARCHotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), threadRegister, stackPointerRegister, threadTemp)); - Variable result = super.emitForeignCall(linkage, null, threadRegister.asValue(LIRKind.value(Kind.Long)), trapRequest); + Variable spScratch = newVariable(LIRKind.value(target().wordKind)); + append(new SPARCHotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), threadRegister, stackPointerRegister, threadTemp, spScratch)); + Variable result = super.emitForeignCall(linkage, null, threadRegister.asValue(LIRKind.value(target().wordKind)), trapRequest); append(new SPARCHotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaPcOffset(), config.threadJavaFrameAnchorFlagsOffset(), threadRegister, threadTemp)); Map<LIRFrameState, SaveRegistersOp> calleeSaveInfo = ((SPARCHotSpotLIRGenerationResult) getResult()).getCalleeSaveInfo(); @@ -438,10 +441,11 @@ ForeignCallLinkage linkage = getForeignCalls().lookupForeignCall(FETCH_UNROLL_INFO); Register threadRegister = getProviders().getRegisters().getThreadRegister(); - Value threadTemp = newVariable(LIRKind.value(Kind.Long)); + Value threadTemp = newVariable(LIRKind.value(target().wordKind)); Register stackPointerRegister = getProviders().getRegisters().getStackPointerRegister(); - append(new SPARCHotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), threadRegister, stackPointerRegister, threadTemp)); - Variable result = super.emitForeignCall(linkage, null, threadRegister.asValue(LIRKind.value(Kind.Long))); + Variable spScratch = newVariable(LIRKind.value(target().wordKind)); + append(new SPARCHotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), threadRegister, stackPointerRegister, threadTemp, spScratch)); + Variable result = super.emitForeignCall(linkage, null, threadRegister.asValue(LIRKind.value(target().wordKind))); append(new SPARCHotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaPcOffset(), config.threadJavaFrameAnchorFlagsOffset(), threadRegister, threadTemp)); Map<LIRFrameState, SaveRegistersOp> calleeSaveInfo = ((SPARCHotSpotLIRGenerationResult) getResult()).getCalleeSaveInfo();
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCall.java Mon Jul 13 17:36:11 2015 +0200 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCall.java Mon Jul 13 18:33:44 2015 +0200 @@ -22,15 +22,16 @@ */ package com.oracle.graal.lir.sparc; +import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; +import static jdk.internal.jvmci.code.ValueUtil.*; +import static jdk.internal.jvmci.sparc.SPARC.*; import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.common.*; import jdk.internal.jvmci.meta.*; -import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; -import static jdk.internal.jvmci.code.ValueUtil.*; -import static jdk.internal.jvmci.sparc.SPARC.*; import com.oracle.graal.asm.sparc.*; -import com.oracle.graal.asm.sparc.SPARCMacroAssembler.*; +import com.oracle.graal.asm.sparc.SPARCMacroAssembler.ScratchRegister; +import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Sethix; import com.oracle.graal.lir.*; import com.oracle.graal.lir.asm.*; @@ -81,7 +82,7 @@ public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { if (!emitted) { emitCallPrefixCode(crb, masm); - directCall(crb, masm, callTarget, null, true, state); + directCall(crb, masm, callTarget, null, state); } else { int after = masm.position(); if (after - before == 4) { @@ -165,7 +166,7 @@ @Override public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { - directCall(crb, masm, callTarget, null, false, state); + directCall(crb, masm, callTarget, null, state); } } @@ -180,15 +181,13 @@ @Override public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { - directCall(crb, masm, callTarget, o7, false, state); + try (ScratchRegister scratch = masm.getScratchRegister()) { + directCall(crb, masm, callTarget, scratch.getRegister(), state); + } } } - public static void directCall(CompilationResultBuilder crb, SPARCMacroAssembler masm, InvokeTarget callTarget, Register scratch, boolean align, LIRFrameState info) { - if (align) { - // We don't need alignment on SPARC. - } - + public static void directCall(CompilationResultBuilder crb, SPARCMacroAssembler masm, InvokeTarget callTarget, Register scratch, LIRFrameState info) { int before; if (scratch != null) { // offset might not fit a 30-bit displacement, generate an
--- a/jvmci/jdk.internal.jvmci.hotspot.sparc/src/jdk/internal/jvmci/hotspot/sparc/SPARCHotSpotRegisterConfig.java Mon Jul 13 17:36:11 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot.sparc/src/jdk/internal/jvmci/hotspot/sparc/SPARCHotSpotRegisterConfig.java Mon Jul 13 18:33:44 2015 +0200 @@ -110,7 +110,8 @@ // and the current register handler would ignore this fact if the called // method still does not modify registers, in fact o7 is modified by the Call instruction // There would be some extra handlin necessary to be able to handle the o7 properly for local usage - o0, o1, o2, o3, o4, o5, /*o6, o7,*/ + g1, g4, g5, + o0, o1, o2, o3, o4, o5, /*o6,o7,*/ l0, l1, l2, l3, l4, l5, l6, l7, i0, i1, i2, i3, i4, i5, /*i6,*/ /*i7,*/ //f0, f1, f2, f3, f4, f5, f6, f7, @@ -125,6 +126,7 @@ // @formatter:off registers = new Register[]{ // TODO this is not complete + g1, g4, g5, o0, o1, o2, o3, o4, o5, /*o6, o7,*/ l0, l1, l2, l3, l4, l5, l6, l7, i0, i1, i2, i3, i4, i5, /*i6,*/ /*i7,*/