From: <cap...@us...> - 2007-10-27 12:17:23
|
Revision: 13833 http://jikesrvm.svn.sourceforge.net/jikesrvm/?rev=13833&view=rev Author: captain5050 Date: 2007-10-27 05:17:20 -0700 (Sat, 27 Oct 2007) Log Message: ----------- RVM-322: Intel assembler register naming improvement. This patch switches from identifying x86 registers by a byte value to using an enum appropriate for that instruction in the assembler. No longer will emitADD_Reg_Reg(XMM0, EAX) appear a valid Intel assembler instruction. The type safety comes at a negligible overhead for the opt compiler but a modest ~8% overhead for the baseline compiler. This will be improved by either immutable annotations or improvements to @Pure, both of which I'm working upon. The patch passed full sanity tests. Modified Paths: -------------- rvmroot/trunk/build/primordials/Classpath-0.96.1.txt rvmroot/trunk/build/primordials/RVM_IA32.txt rvmroot/trunk/build.xml rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/ia32/VM_Barriers.java rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/ia32/VM_BaselineExceptionDeliverer.java rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/ia32/VM_BaselineGCMapIterator.java rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/ia32/VM_Compiler.java rvmroot/trunk/rvm/src/org/jikesrvm/compilers/common/assembler/ia32/VM_Lister.java rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/ia32/OPT_AssemblerBase.java rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/ia32/VM_OptExceptionDeliverer.java rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/ia32/VM_OptGCMapIterator.java rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/ir/ia32/OPT_PhysicalRegisterSet.java rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_BaselineConstants.java rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_InterfaceMethodConflictResolver.java rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_MachineSpecificIA.java rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_OutOfLineMachineCode.java rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_ProcessorLocalState.java rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_RegisterConstants.java rvmroot/trunk/rvm/src/org/jikesrvm/jni/ia32/VM_JNICompiler.java rvmroot/trunk/rvm/src/org/jikesrvm/jni/ia32/VM_JNIGCMapIterator.java rvmroot/trunk/rvm/src/org/jikesrvm/osr/ia32/OSR_OptExecStateExtractor.java rvmroot/trunk/rvm/src/org/jikesrvm/tools/header_gen/GenArch_ia32.java rvmroot/trunk/rvm/src-generated/ia32-assembler/VM_Assembler.in rvmroot/trunk/rvm/src-generated/ia32-assembler/genAssembler.sh rvmroot/trunk/rvm/src-generated/ia32-assembler-opt/GenerateAssembler.java rvmroot/trunk/rvm/src-generated/ia32-assembler-opt/VM.fake rvmroot/trunk/rvm/src-generated/ia32-assembler-opt/VM_Lister.fake Added Paths: ----------- rvmroot/trunk/rvm/src-generated/ia32-assembler-opt/JikesRVMSupport.fake Modified: rvmroot/trunk/build/primordials/Classpath-0.96.1.txt =================================================================== --- rvmroot/trunk/build/primordials/Classpath-0.96.1.txt 2007-10-26 23:38:32 UTC (rev 13832) +++ rvmroot/trunk/build/primordials/Classpath-0.96.1.txt 2007-10-27 12:17:20 UTC (rev 13833) @@ -483,6 +483,7 @@ Ljava/lang/Class$Collector; Ljava/lang/Class$MethodKey; Ljava/lang/Class$StaticData; +Ljava/lang/Enum; [Ljava/lang/Byte; [Ljava/lang/Character; Modified: rvmroot/trunk/build/primordials/RVM_IA32.txt =================================================================== --- rvmroot/trunk/build/primordials/RVM_IA32.txt 2007-10-26 23:38:32 UTC (rev 13832) +++ rvmroot/trunk/build/primordials/RVM_IA32.txt 2007-10-27 12:17:20 UTC (rev 13833) @@ -12,3 +12,6 @@ # [Lorg/jikesrvm/ia32/VM_Code; [Lorg/jikesrvm/ia32/VM_CodeArray; +[Lorg/jikesrvm/ia32/VM_RegisterConstants$GPR; +[Lorg/jikesrvm/ia32/VM_RegisterConstants$FPR; +[Lorg/jikesrvm/ia32/VM_RegisterConstants$XMM; Modified: rvmroot/trunk/build.xml =================================================================== --- rvmroot/trunk/build.xml 2007-10-26 23:38:32 UTC (rev 13832) +++ rvmroot/trunk/build.xml 2007-10-27 12:17:20 UTC (rev 13833) @@ -696,6 +696,7 @@ <fileset dir="${ia32-assembler-opt.dir}"> <include name="**/VM*.fake"/> <include name="ArchitectureSpecific.fake"/> + <include name="JikesRVMSupport.fake"/> </fileset> </copy> <copy file="${main.java}/org/jikesrvm/compilers/common/assembler/VM_ForwardReference.java" Modified: rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/ia32/VM_Barriers.java =================================================================== --- rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/ia32/VM_Barriers.java 2007-10-26 23:38:32 UTC (rev 13832) +++ rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/ia32/VM_Barriers.java 2007-10-27 12:17:20 UTC (rev 13833) @@ -15,7 +15,6 @@ import org.jikesrvm.VM_Configuration; import org.jikesrvm.ArchitectureSpecific.VM_Assembler; import org.jikesrvm.ia32.VM_BaselineConstants; -import org.jikesrvm.objectmodel.VM_ObjectModel; import org.jikesrvm.runtime.VM_Entrypoints; import org.vmmagic.unboxed.Offset; @@ -37,7 +36,7 @@ asm.emitCALL_RegDisp(JTOC, VM_Entrypoints.arrayStoreWriteBarrierMethod.getOffset()); } - static void compilePutfieldBarrier(VM_Assembler asm, byte reg, int locationMetadata) { + static void compilePutfieldBarrier(VM_Assembler asm, GPR reg, int locationMetadata) { // on entry java stack contains ...|target_ref|ref_to_store| // SP -> ref_to_store, SP+4 -> target_ref Offset of4 = Offset.fromIntSignExtend(4); @@ -65,7 +64,7 @@ asm.emitCALL_RegDisp(JTOC, VM_Entrypoints.putfieldWriteBarrierMethod.getOffset()); } - static void compilePutstaticBarrier(VM_Assembler asm, byte reg, int locationMetadata) { + static void compilePutstaticBarrier(VM_Assembler asm, GPR reg, int locationMetadata) { // on entry java stack contains ...|ref_to_store| // SP -> ref_to_store Offset of4 = Offset.fromIntSignExtend(4); @@ -93,7 +92,7 @@ */ private static void genNullCheck(VM_Assembler asm, int offset) { asm.emitMOV_Reg_RegDisp(T1, SP, Offset.fromIntZeroExtend(offset)); - VM_ObjectModel.baselineEmitLoadTIB(asm, T1, T1); + VM_Compiler.baselineEmitLoadTIB(asm, T1, T1); } static void compileModifyCheck(VM_Assembler asm, int offset) { Modified: rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/ia32/VM_BaselineExceptionDeliverer.java =================================================================== --- rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/ia32/VM_BaselineExceptionDeliverer.java 2007-10-26 23:38:32 UTC (rev 13832) +++ rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/ia32/VM_BaselineExceptionDeliverer.java 2007-10-27 12:17:20 UTC (rev 13833) @@ -51,7 +51,7 @@ // sp = sp.minus(BYTES_IN_ADDRESS); sp.store(VM_Magic.objectAsAddress(exceptionObject)); - registers.gprs.set(SP, sp.toWord()); + registers.gprs.set(SP.value(), sp.toWord()); // set address at which to resume executing frame registers.ip = catchBlockInstructionAddress; @@ -103,8 +103,8 @@ } // Restore nonvolatile registers used by the baseline compiler. if (VM.VerifyAssertions) VM._assert(SAVED_GPRS == 2); - registers.gprs.set(JTOC, fp.plus(JTOC_SAVE_OFFSET).loadWord()); - registers.gprs.set(EBX, fp.plus(EBX_SAVE_OFFSET).loadWord()); + registers.gprs.set(JTOC.value(), fp.plus(JTOC_SAVE_OFFSET).loadWord()); + registers.gprs.set(EBX.value(), fp.plus(EBX_SAVE_OFFSET).loadWord()); registers.unwindStackFrame(); } Modified: rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/ia32/VM_BaselineGCMapIterator.java =================================================================== --- rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/ia32/VM_BaselineGCMapIterator.java 2007-10-26 23:38:32 UTC (rev 13832) +++ rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/ia32/VM_BaselineGCMapIterator.java 2007-10-27 12:17:20 UTC (rev 13833) @@ -202,7 +202,7 @@ if (!finishedWithRegularMap) { if (counterArrayBase) { counterArrayBase = false; - return registerLocations.get(EBX).toAddress(); + return registerLocations.get(EBX.value()).toAddress(); } if (mapId < 0) { mapIndex = maps.getNextJSRRefIndex(mapIndex); @@ -256,10 +256,10 @@ if (!bridgeRegistersLocationUpdated) { // point registerLocations[] to our callers stackframe // - registerLocations.set(JTOC, framePtr.plus(JTOC_SAVE_OFFSET).toWord()); - registerLocations.set(T0, framePtr.plus(T0_SAVE_OFFSET).toWord()); - registerLocations.set(T1, framePtr.plus(T1_SAVE_OFFSET).toWord()); - registerLocations.set(EBX, framePtr.plus(EBX_SAVE_OFFSET).toWord()); + registerLocations.set(JTOC.value(), framePtr.plus(JTOC_SAVE_OFFSET).toWord()); + registerLocations.set(T0.value(), framePtr.plus(T0_SAVE_OFFSET).toWord()); + registerLocations.set(T1.value(), framePtr.plus(T1_SAVE_OFFSET).toWord()); + registerLocations.set(EBX.value(), framePtr.plus(EBX_SAVE_OFFSET).toWord()); bridgeRegistersLocationUpdated = true; } @@ -328,8 +328,8 @@ } else { // point registerLocations[] to our callers stackframe // - registerLocations.set(JTOC, framePtr.plus(JTOC_SAVE_OFFSET).toWord()); - registerLocations.set(EBX, framePtr.plus(EBX_SAVE_OFFSET).toWord()); + registerLocations.set(JTOC.value(), framePtr.plus(JTOC_SAVE_OFFSET).toWord()); + registerLocations.set(EBX.value(), framePtr.plus(EBX_SAVE_OFFSET).toWord()); } return Address.zero(); Modified: rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/ia32/VM_Compiler.java =================================================================== --- rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/ia32/VM_Compiler.java 2007-10-26 23:38:32 UTC (rev 13832) +++ rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/ia32/VM_Compiler.java 2007-10-27 12:17:20 UTC (rev 13833) @@ -154,6 +154,12 @@ */ /** + * Utility to call baselineEmitLoadTIB with int arguments not GPR + */ + static void baselineEmitLoadTIB(org.jikesrvm.ArchitectureSpecific.VM_Assembler asm, GPR dest, GPR object) { + VM_ObjectModel.baselineEmitLoadTIB(asm, (int)dest.value(), (int)object.value()); + } + /** * Notify VM_Compiler that we are starting code gen for the bytecode biStart */ @Override @@ -2674,7 +2680,7 @@ Offset objectOffset = Offset.fromIntZeroExtend(methodRefparameterWords << 2).minus(4); // object offset into stack asm.emitMOV_Reg_RegDisp(T1, SP, objectOffset); // S0 has "this" parameter - VM_ObjectModel.baselineEmitLoadTIB(asm, S0, T1); + baselineEmitLoadTIB(asm, S0, T1); asm.emitMOV_Reg_RegIdx(S0, S0, T0, VM_Assembler.BYTE, NO_SLOT); // S0 has address of virtual method genParameterRegisterLoad(methodRef, true); asm.emitCALL_Reg(S0); // call virtual method @@ -2692,7 +2698,7 @@ Offset objectOffset = Offset.fromIntZeroExtend(methodRefparameterWords << 2).minus(WORDSIZE); // object offset into stack asm.emitMOV_Reg_RegDisp(T1, SP, objectOffset); - VM_ObjectModel.baselineEmitLoadTIB(asm, S0, T1); + baselineEmitLoadTIB(asm, S0, T1); genParameterRegisterLoad(methodRef, true); asm.emitCALL_RegDisp(S0, methodRefOffset); genResultRegisterUnload(methodRef); @@ -2782,7 +2788,7 @@ SP, Offset.fromIntZeroExtend((count - 1) << 2)); // "this" object asm.emitPUSH_Imm(methodRef.getId()); // dict id of target - VM_ObjectModel.baselineEmitLoadTIB(asm, S0, T1); + baselineEmitLoadTIB(asm, S0, T1); asm.emitPUSH_Reg(S0); genParameterRegisterLoad(2); // pass 2 parameter word asm.emitCALL_RegDisp(JTOC, @@ -2798,7 +2804,7 @@ asm.emitPUSH_RegDisp(T0, Offset.fromIntZeroExtend(TIB_TYPE_INDEX << 2)); // type of the interface method - VM_ObjectModel.baselineEmitLoadTIB(asm, S0, T1); + baselineEmitLoadTIB(asm, S0, T1); asm.emitPUSH_Reg(S0); genParameterRegisterLoad(2); // pass 2 parameter word asm.emitCALL_RegDisp(JTOC, @@ -2816,7 +2822,7 @@ // T1 = "this" object asm.emitMOV_Reg_RegDisp(T1, SP, Offset.fromIntZeroExtend((count - 1) << 2)); - VM_ObjectModel.baselineEmitLoadTIB(asm, S0, T1); + baselineEmitLoadTIB(asm, S0, T1); if (VM.BuildForIndirectIMT) { // Load the IMT Base into S0 asm.emitMOV_Reg_RegDisp(S0, S0, Offset.fromIntZeroExtend(TIB_IMT_TIB_INDEX << 2)); @@ -2828,7 +2834,7 @@ // T1 = "this" object asm.emitMOV_Reg_RegDisp(T1, SP, Offset.fromIntZeroExtend((count - 1) << 2)); - VM_ObjectModel.baselineEmitLoadTIB(asm, S0, T1); + baselineEmitLoadTIB(asm, S0, T1); // S0 = iTables asm.emitMOV_Reg_RegDisp(S0, S0, Offset.fromIntZeroExtend(TIB_ITABLES_TIB_INDEX << 2)); // S0 = iTable @@ -2866,7 +2872,7 @@ // itable address // T0 = "this" object asm.emitMOV_Reg_RegDisp(T0, SP, Offset.fromIntZeroExtend((count - 1) << 2)); - VM_ObjectModel.baselineEmitLoadTIB(asm, S0, T0); + baselineEmitLoadTIB(asm, S0, T0); asm.emitPUSH_Reg(S0); asm.emitPUSH_Imm(resolvedMethod.getDeclaringClass().getInterfaceId()); // interface id genParameterRegisterLoad(2); // pass 2 parameter words @@ -3297,7 +3303,8 @@ * @param indexReg the register containing the index * @param arrayRefReg the register containing the array reference */ - private void genBoundsCheck(VM_Assembler asm, byte indexReg, byte arrayRefReg) { + @Inline + private void genBoundsCheck(VM_Assembler asm, GPR indexReg, GPR arrayRefReg) { if (generateBoundsChecks) { // compare index to array length asm.emitCMP_RegDisp_Reg(arrayRefReg, @@ -3340,8 +3347,8 @@ asm.emitJCC_Cond_ImmOrLabel(cond, mTarget, bTarget); } } - - private void incEdgeCounter(byte scratch, int counterIdx) { + @Inline + private void incEdgeCounter(GPR scratch, int counterIdx) { if (VM.VerifyAssertions) VM._assert(((VM_BaselineCompiledMethod) compiledMethod).hasCounterArray()); asm.emitMOV_Reg_RegDisp(scratch, EBX, Offset.fromIntZeroExtend(counterIdx << 2)); asm.emitADD_Reg_Imm(scratch, 1); @@ -3351,8 +3358,8 @@ asm.emitMOV_RegDisp_Reg(EBX, Offset.fromIntSignExtend(counterIdx << 2), scratch); fr1.resolve(asm); } - - private void incEdgeCounterIdx(byte scratch, byte idx, int counterIdx) { + @Inline + private void incEdgeCounterIdx(GPR scratch, GPR idx, int counterIdx) { if (VM.VerifyAssertions) VM._assert(((VM_BaselineCompiledMethod) compiledMethod).hasCounterArray()); asm.emitMOV_Reg_RegIdx(scratch, EBX, idx, VM_Assembler.WORD, Offset.fromIntZeroExtend(counterIdx << 2)); asm.emitADD_Reg_Imm(scratch, 1); @@ -3394,7 +3401,7 @@ if (max == 0) return; // quit looking when all registers are full int gpr = 0; // number of general purpose registers filled int fpr = 0; // number of floating point registers filled - byte T = T0; // next GPR to get a parameter + GPR T = T0; // next GPR to get a parameter int params = method.getParameterWords() + (hasThisParam ? 1 : 0); Offset offset = Offset.fromIntZeroExtend((params - 1) << LG_WORDSIZE); // stack offset of first parameter word if (hasThisParam) { @@ -3425,7 +3432,7 @@ } else if (t.isFloatType()) { if (fpr < NUM_PARAMETER_FPRS) { if (SSE2_FULL) { - asm.emitMOVSS_Reg_RegDisp((byte)fpr, SP, offset); + asm.emitMOVSS_Reg_RegDisp(XMM.lookup(fpr), SP, offset); } else { asm.emitFLD_Reg_RegDisp(FP0, SP, offset); } @@ -3436,7 +3443,7 @@ } else if (t.isDoubleType()) { if (fpr < NUM_PARAMETER_FPRS) { if (SSE2_FULL) { - asm.emitMOVSD_Reg_RegDisp((byte)fpr, SP, offset.minus(WORDSIZE)); + asm.emitMOVSD_Reg_RegDisp(XMM.lookup(fpr), SP, offset.minus(WORDSIZE)); } else { asm.emitFLD_Reg_RegDisp_Quad(FP0, SP, offset.minus(WORDSIZE)); } @@ -3467,7 +3474,7 @@ private void genParameterCopy(Offset srcOffset, Offset dstOffset) { int gpr = 0; // number of general purpose registers unloaded int fpr = 0; // number of floating point registers unloaded - byte T = T0; // next GPR to get a parameter + GPR T = T0; // next GPR to get a parameter if (!method.isStatic()) { // handle "this" parameter if (gpr < NUM_PARAMETER_GPRS) { asm.emitMOV_RegDisp_Reg(SP, dstOffset, T); @@ -3514,7 +3521,7 @@ if (fpr < NUM_PARAMETER_FPRS) { //fprOffset.set(fpr, dstOffset); if (SSE2_FULL) { - asm.emitMOVSS_RegDisp_Reg(SP, dstOffset, (byte)fpr); + asm.emitMOVSS_RegDisp_Reg(SP, dstOffset, XMM.lookup(fpr)); } else { fprOffset[fpr] = dstOffset.toInt(); is32bit[fpr] = true; @@ -3532,7 +3539,7 @@ dstOffset = dstOffset.minus(WORDSIZE); //fprOffset.set(fpr, dstOffset); if (SSE2_FULL) { - asm.emitMOVSD_RegDisp_Reg(SP, dstOffset, (byte)fpr); + asm.emitMOVSD_RegDisp_Reg(SP, dstOffset, XMM.lookup(fpr)); } else { fprOffset[fpr] = dstOffset.toInt(); is32bit[fpr] = false; @@ -4251,7 +4258,7 @@ // code for VM_Type VM_Magic.getObjectType(Object object) if (methodName == VM_MagicNames.getObjectType) { asm.emitPOP_Reg(T0); // object ref - VM_ObjectModel.baselineEmitLoadTIB(asm, S0, T0); + baselineEmitLoadTIB(asm, S0, T0); asm.emitPUSH_RegDisp(S0, Offset.fromIntZeroExtend(TIB_TYPE_INDEX << LG_WORDSIZE)); // push VM_Type slot of TIB return true; } @@ -4594,7 +4601,7 @@ return offset.plus(offsetToFrameHead); } - private void emitDynamicLinkingSequence(byte reg, VM_MemberReference ref, boolean couldBeZero) { + private void emitDynamicLinkingSequence(GPR reg, VM_MemberReference ref, boolean couldBeZero) { int memberId = ref.getId(); Offset memberOffset = Offset.fromIntZeroExtend(memberId << 2); Offset tableOffset = VM_Entrypoints.memberOffsetsField.getOffset(); Modified: rvmroot/trunk/rvm/src/org/jikesrvm/compilers/common/assembler/ia32/VM_Lister.java =================================================================== --- rvmroot/trunk/rvm/src/org/jikesrvm/compilers/common/assembler/ia32/VM_Lister.java 2007-10-26 23:38:32 UTC (rev 13832) +++ rvmroot/trunk/rvm/src/org/jikesrvm/compilers/common/assembler/ia32/VM_Lister.java 2007-10-27 12:17:20 UTC (rev 13833) @@ -15,6 +15,7 @@ import org.jikesrvm.VM; import org.jikesrvm.ia32.VM_RegisterConstants; import org.vmmagic.unboxed.Offset; +import org.vmmagic.pragma.Pure; /** */ @@ -50,110 +51,118 @@ end(i); } - public final void R(int i, String op, byte R0) { + public final void R(int i, String op, Register R0) { i = begin(i, op); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R0] : GPR_NAMES[R0] + " ", DEST_AREA_SIZE)); + VM.sysWrite(right(R0 + " ", DEST_AREA_SIZE)); VM.sysWrite(right("", SOURCE_AREA_SIZE)); end(i); } - public final void RD(int i, String op, byte R0, Offset d) { + public final void RD(int i, String op, Register R0, Offset d) { i = begin(i, op); - VM.sysWrite(right(decimal(d) + "[" + GPR_NAMES[R0] + "]", DEST_AREA_SIZE)); + VM.sysWrite(right(decimal(d) + "[" + R0 + "]", DEST_AREA_SIZE)); VM.sysWrite(right("", SOURCE_AREA_SIZE)); end(i); } - public final void RI(int i, String op, byte R0, int n) { + public final void RI(int i, String op, Register R0, int n) { i = begin(i, op); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R0] : GPR_NAMES[R0] + " ", DEST_AREA_SIZE)); + VM.sysWrite(right(R0 + " ", DEST_AREA_SIZE)); VM.sysWrite(right(decimal(n) + " ", SOURCE_AREA_SIZE)); end(i); } - public final void RDI(int i, String op, byte R0, Offset d, int n) { + public final void RDI(int i, String op, Register R0, Offset d, int n) { i = begin(i, op); - VM.sysWrite(right(decimal(d) + "[" + GPR_NAMES[R0] + "]", DEST_AREA_SIZE)); + VM.sysWrite(right(decimal(d) + "[" + R0 + "]", DEST_AREA_SIZE)); VM.sysWrite(right(decimal(n) + " ", SOURCE_AREA_SIZE)); end(i); } - public final void RNI(int i, String op, byte R0, int n) { + public final void RNI(int i, String op, Register R0, int n) { i = begin(i, op); - VM.sysWrite(right("[" + GPR_NAMES[R0] + "]", DEST_AREA_SIZE)); + VM.sysWrite(right("[" + R0 + "]", DEST_AREA_SIZE)); VM.sysWrite(right(decimal(n) + " ", SOURCE_AREA_SIZE)); end(i); } - public final void RR(int i, String op, byte R0, byte R1) { + public final void RR(int i, String op, Register R0, Register R1) { i = begin(i, op); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R0] : GPR_NAMES[R0] + " ", DEST_AREA_SIZE)); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R1] : GPR_NAMES[R1] + " ", SOURCE_AREA_SIZE)); + VM.sysWrite(right(R0 + " ", DEST_AREA_SIZE)); + VM.sysWrite(right(R1 + " ", SOURCE_AREA_SIZE)); end(i); } - public final void RDR(int i, String op, byte R0, Offset d, byte R1) { + public final void RDR(int i, String op, Register R0, Offset d, Register R1) { i = begin(i, op); - VM.sysWrite(right(decimal(d) + "[" + GPR_NAMES[R0] + "]", DEST_AREA_SIZE)); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R1] : GPR_NAMES[R1] + " ", SOURCE_AREA_SIZE)); + VM.sysWrite(right(decimal(d) + "[" + R0 + "]", DEST_AREA_SIZE)); + VM.sysWrite(right(R1 + " ", SOURCE_AREA_SIZE)); end(i); } - public final void RDRI(int i, String op, byte R0, Offset d, byte R1, int imm) { + public final void RDRI(int i, String op, Register R0, Offset d, Register R1, int imm) { i = begin(i, op); - VM.sysWrite(right(decimal(d) + "[" + GPR_NAMES[R0] + "]", DEST_AREA_SIZE)); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R1] : GPR_NAMES[R1] + " ", SOURCE_AREA_SIZE)); + VM.sysWrite(right(decimal(d) + "[" + R0 + "]", DEST_AREA_SIZE)); + VM.sysWrite(right(R1 + " ", SOURCE_AREA_SIZE)); VM.sysWrite(right(decimal(imm), SOURCE_AREA_SIZE)); end(i); } - public final void RRD(int i, String op, byte R0, byte R1, Offset d) { + public final void RDRR(int i, String op, Register R0, Offset d, Register R1, Register R2) { i = begin(i, op); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R0] : GPR_NAMES[R0] + " ", DEST_AREA_SIZE)); - VM.sysWrite(right(decimal(d) + "[" + GPR_NAMES[R1] + "]", SOURCE_AREA_SIZE)); + VM.sysWrite(right(decimal(d) + "[" + R0 + "]", DEST_AREA_SIZE)); + VM.sysWrite(right(R1 + " ", SOURCE_AREA_SIZE)); + VM.sysWrite(right(R2 + " ", SOURCE_AREA_SIZE)); end(i); } - public final void RNR(int i, String op, byte R0, byte R1) { + public final void RRD(int i, String op, Register R0, Register R1, Offset d) { i = begin(i, op); - VM.sysWrite(right("[" + GPR_NAMES[R0] + "]", DEST_AREA_SIZE)); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R1] : GPR_NAMES[R1] + " ", SOURCE_AREA_SIZE)); + VM.sysWrite(right(R0 + " ", DEST_AREA_SIZE)); + VM.sysWrite(right(decimal(d) + "[" + R1 + "]", SOURCE_AREA_SIZE)); end(i); } - public final void RN(int i, String op, byte R0) { + public final void RNR(int i, String op, Register R0, Register R1) { i = begin(i, op); - VM.sysWrite(right("[" + GPR_NAMES[R0] + "]", DEST_AREA_SIZE)); + VM.sysWrite(right("[" + R0 + "]", DEST_AREA_SIZE)); + VM.sysWrite(right(R1 + " ", SOURCE_AREA_SIZE)); + end(i); + } + + public final void RN(int i, String op, Register R0) { + i = begin(i, op); + VM.sysWrite(right("[" + R0 + "]", DEST_AREA_SIZE)); VM.sysWrite(right(" ", SOURCE_AREA_SIZE)); end(i); } - public final void RRN(int i, String op, byte R0, byte R1) { + public final void RRN(int i, String op, Register R0, Register R1) { i = begin(i, op); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R0] : GPR_NAMES[R0] + " ", DEST_AREA_SIZE)); - VM.sysWrite(right("[" + GPR_NAMES[R1] + "]", SOURCE_AREA_SIZE)); + VM.sysWrite(right(R0 + " ", DEST_AREA_SIZE)); + VM.sysWrite(right("[" + R1 + "]", SOURCE_AREA_SIZE)); end(i); } - public final void RXD(int i, String op, byte R0, byte X, short s, Offset d) { + public final void RXD(int i, String op, Register R0, Register X, short s, Offset d) { i = begin(i, op); - VM.sysWrite(right("[" + decimal(d) + "+" + GPR_NAMES[R0] + "+" + GPR_NAMES[X] + "<<" + decimal(s) + "]", + VM.sysWrite(right("[" + decimal(d) + "+" + R0 + "+" + X + "<<" + decimal(s) + "]", DEST_AREA_SIZE)); VM.sysWrite(right("", SOURCE_AREA_SIZE)); end(i); } - public final void RXDI(int i, String op, byte R0, byte X, short s, Offset d, int n) { + public final void RXDI(int i, String op, Register R0, Register X, short s, Offset d, int n) { i = begin(i, op); - VM.sysWrite(right("[" + decimal(d) + "+" + GPR_NAMES[R0] + "+" + GPR_NAMES[X] + "<<" + decimal(s) + "]", + VM.sysWrite(right("[" + decimal(d) + "+" + R0 + "+" + X + "<<" + decimal(s) + "]", DEST_AREA_SIZE)); VM.sysWrite(right(decimal(n), SOURCE_AREA_SIZE)); end(i); } - public final void RFD(int i, String op, byte X, short s, Offset d) { + public final void RFD(int i, String op, Register X, short s, Offset d) { i = begin(i, op); - VM.sysWrite(right("[" + decimal(d) + "+" + GPR_NAMES[X] + "<<" + decimal(s) + "]", DEST_AREA_SIZE)); + VM.sysWrite(right("[" + decimal(d) + "+" + X + "<<" + decimal(s) + "]", DEST_AREA_SIZE)); VM.sysWrite(right("", SOURCE_AREA_SIZE)); end(i); } @@ -165,9 +174,9 @@ end(i); } - public final void RFDI(int i, String op, byte X, short s, Offset d, int n) { + public final void RFDI(int i, String op, Register X, short s, Offset d, int n) { i = begin(i, op); - VM.sysWrite(right("[" + decimal(d) + "+" + GPR_NAMES[X] + "<<" + decimal(s) + "]", DEST_AREA_SIZE)); + VM.sysWrite(right("[" + decimal(d) + "+" + X + "<<" + decimal(s) + "]", DEST_AREA_SIZE)); VM.sysWrite(right(decimal(n), SOURCE_AREA_SIZE)); end(i); } @@ -179,121 +188,129 @@ end(i); } - public final void RRR(int i, String op, byte R0, byte R1, byte R2) { + public final void RRR(int i, String op, Register R0, Register R1, Register R2) { i = begin(i, op); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R0] : GPR_NAMES[R0] + " ", DEST_AREA_SIZE)); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R1] : GPR_NAMES[R1] + " ", SOURCE_AREA_SIZE)); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R2] : GPR_NAMES[R2] + " ", SOURCE_AREA_SIZE)); + VM.sysWrite(right(R0 + " ", DEST_AREA_SIZE)); + VM.sysWrite(right(R1 + " ", SOURCE_AREA_SIZE)); + VM.sysWrite(right(R2 + " ", SOURCE_AREA_SIZE)); end(i); } - public final void RNRI(int i, String op, byte R0, byte R1, int imm) { + public final void RNRI(int i, String op, Register R0, Register R1, int imm) { i = begin(i, op); - VM.sysWrite(right("[" + GPR_NAMES[R0] + "] ", DEST_AREA_SIZE)); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R1] : GPR_NAMES[R1] + " ", SOURCE_AREA_SIZE)); + VM.sysWrite(right("[" + R0 + "] ", DEST_AREA_SIZE)); + VM.sysWrite(right(R1 + " ", SOURCE_AREA_SIZE)); VM.sysWrite(right(decimal(imm), SOURCE_AREA_SIZE)); end(i); } - public final void RRI(int i, String op, byte R0, byte R1, int imm) { + public final void RNRR(int i, String op, Register R0, Register R1, Register R2) { i = begin(i, op); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R0] : GPR_NAMES[R0] + " ", DEST_AREA_SIZE)); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R1] : GPR_NAMES[R1] + " ", SOURCE_AREA_SIZE)); + VM.sysWrite(right("[" + R0 + "] ", DEST_AREA_SIZE)); + VM.sysWrite(right(R1 + " ", SOURCE_AREA_SIZE)); + VM.sysWrite(right(R2 + " ", SOURCE_AREA_SIZE)); + end(i); + } + + public final void RRI(int i, String op, Register R0, Register R1, int imm) { + i = begin(i, op); + VM.sysWrite(right(R0 + " ", DEST_AREA_SIZE)); + VM.sysWrite(right(R1 + " ", SOURCE_AREA_SIZE)); VM.sysWrite(right(decimal(imm), SOURCE_AREA_SIZE)); end(i); } - public final void RRXD(int i, String op, byte R0, byte R1, byte X, short s, Offset d) { + public final void RRXD(int i, String op, Register R0, Register R1, Register X, short s, Offset d) { i = begin(i, op); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R0] : GPR_NAMES[R0], DEST_AREA_SIZE)); - VM.sysWrite(right("[" + decimal(d) + "+" + GPR_NAMES[R1] + "+" + GPR_NAMES[X] + "<<" + decimal(s) + "]", + VM.sysWrite(right(R0 + " ", DEST_AREA_SIZE)); + VM.sysWrite(right("[" + decimal(d) + "+" + R1 + "+" + X + "<<" + decimal(s) + "]", SOURCE_AREA_SIZE)); end(i); } - public final void RXDR(int i, String op, byte R0, byte X, short s, Offset d, byte R1) { + public final void RXDR(int i, String op, Register R0, Register X, short s, Offset d, Register R1) { i = begin(i, op); - VM.sysWrite(right("[" + decimal(d) + "+" + GPR_NAMES[R0] + "+" + GPR_NAMES[X] + "<<" + decimal(s) + "]", + VM.sysWrite(right("[" + decimal(d) + "+" + R0 + "+" + X + "<<" + decimal(s) + "]", DEST_AREA_SIZE)); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R1] : GPR_NAMES[R1] + " ", SOURCE_AREA_SIZE)); + VM.sysWrite(right(R1 + " ", SOURCE_AREA_SIZE)); end(i); } - public final void RXDRI(int i, String op, byte R0, byte X, short s, Offset d, byte R1, int imm) { + public final void RXDRI(int i, String op, Register R0, Register X, short s, Offset d, Register R1, int imm) { i = begin(i, op); - VM.sysWrite(right("[" + decimal(d) + "+" + GPR_NAMES[R0] + "+" + GPR_NAMES[X] + "<<" + decimal(s) + "]", + VM.sysWrite(right("[" + decimal(d) + "+" + R0 + "+" + X + "<<" + decimal(s) + "]", DEST_AREA_SIZE)); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R1] : GPR_NAMES[R1] + " ", SOURCE_AREA_SIZE)); + VM.sysWrite(right(R1 + " ", SOURCE_AREA_SIZE)); VM.sysWrite(right(decimal(imm), SOURCE_AREA_SIZE)); end(i); } - public final void RXDRR(int i, String op, byte R0, byte X, short s, Offset d, byte R1, byte R2) { + public final void RXDRR(int i, String op, Register R0, Register X, short s, Offset d, Register R1, Register R2) { i = begin(i, op); - VM.sysWrite(right("[" + decimal(d) + "+" + GPR_NAMES[R0] + "+" + GPR_NAMES[X] + "<<" + decimal(s) + "]", + VM.sysWrite(right("[" + decimal(d) + "+" + R0 + "+" + X + "<<" + decimal(s) + "]", SOURCE_AREA_SIZE)); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R1] : GPR_NAMES[R1] + " ", DEST_AREA_SIZE)); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R2] : GPR_NAMES[R2] + " ", SOURCE_AREA_SIZE)); + VM.sysWrite(right(R1 + " ", DEST_AREA_SIZE)); + VM.sysWrite(right(R2 + " ", SOURCE_AREA_SIZE)); end(i); } - public final void RRFD(int i, String op, byte R0, byte X, short s, Offset d) { + public final void RRFD(int i, String op, Register R0, Register X, short s, Offset d) { i = begin(i, op); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R0] : GPR_NAMES[R0], DEST_AREA_SIZE)); - VM.sysWrite(right("[" + decimal(d) + "+" + GPR_NAMES[X] + "<<" + decimal(s) + "]", SOURCE_AREA_SIZE)); + VM.sysWrite(right(R0 + " ", DEST_AREA_SIZE)); + VM.sysWrite(right("[" + decimal(d) + "+" + X + "<<" + decimal(s) + "]", SOURCE_AREA_SIZE)); end(i); } - public final void RFDR(int i, String op, byte X, short s, Offset d, byte R0) { + public final void RFDR(int i, String op, Register X, short s, Offset d, Register R0) { i = begin(i, op); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R0] : GPR_NAMES[R0] + " ", DEST_AREA_SIZE)); - VM.sysWrite(right("[" + decimal(d) + "+" + GPR_NAMES[X] + "<<" + decimal(s) + "]", SOURCE_AREA_SIZE)); + VM.sysWrite(right(R0 + " ", DEST_AREA_SIZE)); + VM.sysWrite(right("[" + decimal(d) + "+" + X + "<<" + decimal(s) + "]", SOURCE_AREA_SIZE)); end(i); } - public final void RFDRI(int i, String op, byte X, short s, Offset d, byte R0, int imm) { + public final void RFDRI(int i, String op, Register X, short s, Offset d, Register R0, int imm) { i = begin(i, op); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R0] : GPR_NAMES[R0] + " ", DEST_AREA_SIZE)); - VM.sysWrite(right("[" + decimal(d) + "+" + GPR_NAMES[X] + "<<" + decimal(s) + "]", SOURCE_AREA_SIZE)); + VM.sysWrite(right(R0 + " ", DEST_AREA_SIZE)); + VM.sysWrite(right("[" + decimal(d) + "+" + X + "<<" + decimal(s) + "]", SOURCE_AREA_SIZE)); VM.sysWrite(right(decimal(imm), SOURCE_AREA_SIZE)); end(i); } - public final void RFDRR(int i, String op, byte X, short s, Offset d, byte R0, byte R2) { + public final void RFDRR(int i, String op, Register X, short s, Offset d, Register R0, Register R2) { i = begin(i, op); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R0] : GPR_NAMES[R0] + " ", DEST_AREA_SIZE)); - VM.sysWrite(right("[" + decimal(d) + "+" + GPR_NAMES[X] + "<<" + decimal(s) + "]", SOURCE_AREA_SIZE)); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R2] : GPR_NAMES[R2] + " ", SOURCE_AREA_SIZE)); + VM.sysWrite(right(R0 + " ", DEST_AREA_SIZE)); + VM.sysWrite(right("[" + decimal(d) + "+" + X + "<<" + decimal(s) + "]", SOURCE_AREA_SIZE)); + VM.sysWrite(right(R2 + " ", SOURCE_AREA_SIZE)); end(i); } - public final void RRA(int i, String op, byte R0, Offset d) { + public final void RRA(int i, String op, Register R0, Offset d) { i = begin(i, op); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R0] : GPR_NAMES[R0], DEST_AREA_SIZE)); + VM.sysWrite(right(R0 +" ", DEST_AREA_SIZE)); VM.sysWrite(right("[" + hex(d) + "]", SOURCE_AREA_SIZE)); end(i); } - public final void RAR(int i, String op, Offset d, byte R0) { + public final void RAR(int i, String op, Offset d, Register R0) { i = begin(i, op); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R0] : GPR_NAMES[R0] + " ", DEST_AREA_SIZE)); + VM.sysWrite(right(R0 + " ", DEST_AREA_SIZE)); VM.sysWrite(right("[" + hex(d) + "]", SOURCE_AREA_SIZE)); end(i); } - public final void RARI(int i, String op, Offset d, byte R0, int imm) { + public final void RARI(int i, String op, Offset d, Register R0, int imm) { i = begin(i, op); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R0] : GPR_NAMES[R0] + " ", DEST_AREA_SIZE)); + VM.sysWrite(right(R0 + " ", DEST_AREA_SIZE)); VM.sysWrite(right("[" + hex(d) + "]", SOURCE_AREA_SIZE)); VM.sysWrite(right(decimal(imm), SOURCE_AREA_SIZE)); end(i); } - public final void RARR(int i, String op, Offset d, byte R0, byte R2) { + public final void RARR(int i, String op, Offset d, Register R0, Register R2) { i = begin(i, op); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R0] : GPR_NAMES[R0] + " ", DEST_AREA_SIZE)); + VM.sysWrite(right(R0 + " ", DEST_AREA_SIZE)); VM.sysWrite(right("[" + hex(d) + "]", SOURCE_AREA_SIZE)); - VM.sysWrite(right(isFP(op) ? FPR_NAMES[R2] : GPR_NAMES[R2] + " ", SOURCE_AREA_SIZE)); + VM.sysWrite(right(R2 + " ", SOURCE_AREA_SIZE)); end(i); } @@ -316,10 +333,7 @@ lockPrefix = false; } - private static boolean isFP(String op) { - return op.startsWith("F"); - } - + @Pure private static String left(String s, int w) { int n = s.length(); if (w < n) return s.substring(0, w); @@ -329,6 +343,7 @@ return s; } + @Pure private static String right(String s, int w) { int n = s.length(); if (w < n) return s.substring(n - w); @@ -342,6 +357,7 @@ return decimal(o.toInt()); } + @Pure static String decimal(int n) { if (n == 0) return "0"; String sign = ""; @@ -380,18 +396,22 @@ return decimal((int) s); } + @Pure static String hex(Offset i) { return (hex((short) (i.toInt() >> 16)) + hex((short) i.toInt())); } + @Pure public static String hex(int i) { return (hex((short) (i >> 16)) + hex((short) i)); } + @Pure static String hex(short i) { return (hex((byte) (i >> 8)) + hex((byte) i)); } + @Pure static String hex(byte b) { int i = b & 0xFF; byte j = (byte) (i / 0x10); Modified: rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/ia32/OPT_AssemblerBase.java =================================================================== --- rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/ia32/OPT_AssemblerBase.java 2007-10-26 23:38:32 UTC (rev 13832) +++ rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/ia32/OPT_AssemblerBase.java 2007-10-27 12:17:20 UTC (rev 13833) @@ -13,6 +13,7 @@ package org.jikesrvm.compilers.opt.ia32; import java.util.ArrayList; +import static org.jikesrvm.ia32.VM_ArchConstants.SSE2_FULL; import org.jikesrvm.ArchitectureSpecific.OPT_Assembler; import org.jikesrvm.ArchitectureSpecific.VM_Assembler; import org.jikesrvm.VM; @@ -183,6 +184,18 @@ return op.isRegister(); } + boolean isGPR_Reg(OPT_Operand op) { + return isReg(op); + } + + boolean isFPR_Reg(OPT_Operand op) { + return isReg(op); + } + + boolean isXMM_Reg(OPT_Operand op) { + return isReg(op); + } + /** * Return the machine-level register number corresponding to a given integer * OPT_Register. The optimizing compiler has its own notion of register @@ -197,11 +210,11 @@ * @param reg the register being queried * @return the 3 bit machine-level encoding of reg */ - private byte getGPMachineRegister(OPT_Register reg) { + private GPR getGPMachineRegister(OPT_Register reg) { if (VM.VerifyAssertions) { VM._assert(OPT_PhysicalRegisterSet.getPhysicalRegisterType(reg) == INT_REG); } - return (byte) (reg.number - FIRST_INT); + return GPR.lookup(reg.number - FIRST_INT); } /** @@ -220,23 +233,26 @@ * @param reg the register being queried * @return the 3 bit machine-level encoding of reg */ - private byte getMachineRegister(OPT_Register reg) { + private Register getMachineRegister(OPT_Register reg) { int type = OPT_PhysicalRegisterSet.getPhysicalRegisterType(reg); - byte result; + Register result; if (type == INT_REG) { - result = (byte) (reg.number - FIRST_INT); + result = GPR.lookup(reg.number - FIRST_INT); } else { if (VM.VerifyAssertions) VM._assert(type == DOUBLE_REG); - if (reg.number < FIRST_SPECIAL) { - result = (byte) (reg.number - FIRST_DOUBLE); - } else if (reg.number == ST0) { - result = 0; + if (SSE2_FULL) { + if (reg.number < FIRST_SPECIAL) { + result = XMM.lookup(reg.number - FIRST_DOUBLE); + } else if (reg.number == ST0) { + result = FP0; + } else { + if (VM.VerifyAssertions) VM._assert(reg.number == ST1); + result = FP1; + } } else { - if (VM.VerifyAssertions) VM._assert(reg.number == ST1); - result = 1; + result = FPR.lookup(reg.number - FIRST_DOUBLE); } } - if (OPT_IR.PARANOID) VM._assert((result & 0x7) == result); return result; } @@ -253,10 +269,22 @@ * @param op the register operand being queried * @return the 3 bit IA32 ISA encoding of op */ - byte getReg(OPT_Operand op) { + Register getReg(OPT_Operand op) { return getMachineRegister(op.asRegister().getRegister()); } + GPR getGPR_Reg(OPT_Operand op) { + return getGPMachineRegister(op.asRegister().getRegister()); + } + + FPR getFPR_Reg(OPT_Operand op) { + return (FPR)getMachineRegister(op.asRegister().getRegister()); + } + + XMM getXMM_Reg(OPT_Operand op) { + return (XMM)getMachineRegister(op.asRegister().getRegister()); + } + /** * Given a memory operand, return the 3 bit IA32 ISA encoding * of its base regsiter. This function translates the optimizing @@ -274,7 +302,7 @@ * @param op the register operand being queried * @return the 3 bit IA32 ISA encoding of the base register of op */ - byte getBase(OPT_Operand op) { + GPR getBase(OPT_Operand op) { return getGPMachineRegister(((OPT_MemoryOperand) op).base.getRegister()); } @@ -294,7 +322,7 @@ * @param op the register operand being queried * @return the 3 bit IA32 ISA encoding of the index register of op */ - byte getIndex(OPT_Operand op) { + GPR getIndex(OPT_Operand op) { return getGPMachineRegister(((OPT_MemoryOperand) op).index.getRegister()); } @@ -395,7 +423,7 @@ } /** - * Determine if a given operand is a memory operand representing + * Determine if a given operand is a memory operand representing * register-offset mode addressing. This method takes an * arbitrary operand, checks whether it is a memory operand, and, * if it is, checks whether it should be assembled as IA32 @@ -917,7 +945,7 @@ emitJMP_Label(getLabel(MIR_Branch.getTarget(inst))); } } else if (isReg(MIR_Branch.getTarget(inst))) { - emitJMP_Reg(getReg(MIR_Branch.getTarget(inst))); + emitJMP_Reg(getGPR_Reg(MIR_Branch.getTarget(inst))); } else if (isAbs(MIR_Branch.getTarget(inst))) { emitJMP_Abs(getDisp(MIR_Branch.getTarget(inst))); } else if (isRegDisp(MIR_Branch.getTarget(inst))) { Modified: rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/ia32/VM_OptExceptionDeliverer.java =================================================================== --- rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/ia32/VM_OptExceptionDeliverer.java 2007-10-26 23:38:32 UTC (rev 13832) +++ rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/ia32/VM_OptExceptionDeliverer.java 2007-10-27 12:17:20 UTC (rev 13833) @@ -54,7 +54,7 @@ // reset sp to "empty params" state (ie same as it was after prologue) Address sp = fp.minus(optMethod.getFrameFixedSize()); - registers.gprs.set(STACK_POINTER, sp.toWord()); + registers.gprs.set(STACK_POINTER.value(), sp.toWord()); // store exception object for later retrieval by catch block int offset = optMethod.getUnsignedExceptionOffset(); @@ -78,10 +78,10 @@ VM.sysWrite("Registers before delivering exception in "); VM.sysWrite(optMethod.getMethod()); VM.sysWrite("\n"); - for (int i = 0; i < NUM_GPRS; i++) { - VM.sysWrite(GPR_NAMES[i]); + for (GPR reg : GPR.values()) { + VM.sysWrite(reg.toString()); VM.sysWrite(" = "); - VM.sysWrite(registers.gprs.get(i)); + VM.sysWrite(registers.gprs.get(reg.value())); VM.sysWrite("\n"); } } @@ -126,10 +126,10 @@ VM.sysWrite("Registers before unwinding frame for "); VM.sysWrite(optMethod.getMethod()); VM.sysWrite("\n"); - for (int i = 0; i < NUM_GPRS; i++) { - VM.sysWrite(GPR_NAMES[i]); + for (GPR reg : GPR.values()) { + VM.sysWrite(reg.toString()); VM.sysWrite(" = "); - VM.sysWrite(registers.gprs.get(i)); + VM.sysWrite(registers.gprs.get(reg.value())); VM.sysWrite("\n"); } } @@ -137,7 +137,7 @@ // restore non-volatile registers int frameOffset = optMethod.getUnsignedNonVolatileOffset(); for (int i = optMethod.getFirstNonVolatileGPR(); i < NUM_NONVOLATILE_GPRS; i++, frameOffset += 4) { - registers.gprs.set(NONVOLATILE_GPRS[i], fp.minus(frameOffset).loadWord()); + registers.gprs.set(NONVOLATILE_GPRS[i].value(), fp.minus(frameOffset).loadWord()); } if (VM.VerifyAssertions) VM._assert(NUM_NONVOLATILE_FPRS == 0); @@ -147,10 +147,10 @@ VM.sysWrite("Registers after unwinding frame for "); VM.sysWrite(optMethod.getMethod()); VM.sysWrite("\n"); - for (int i = 0; i < NUM_GPRS; i++) { - VM.sysWrite(GPR_NAMES[i]); + for (GPR reg : GPR.values()) { + VM.sysWrite(reg.toString()); VM.sysWrite(" = "); - VM.sysWrite(registers.gprs.get(i)); + VM.sysWrite(registers.gprs.get(reg.value())); VM.sysWrite("\n"); } } Modified: rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/ia32/VM_OptGCMapIterator.java =================================================================== --- rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/ia32/VM_OptGCMapIterator.java 2007-10-26 23:38:32 UTC (rev 13832) +++ rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/ia32/VM_OptGCMapIterator.java 2007-10-27 12:17:20 UTC (rev 13833) @@ -83,7 +83,7 @@ for (int i = first; i < NUM_NONVOLATILE_GPRS; i++) { // determine what register index corresponds to this location - int registerIndex = NONVOLATILE_GPRS[i]; + int registerIndex = NONVOLATILE_GPRS[i].value(); registerLocations.set(registerIndex, location.toWord()); if (DEBUG) { VM.sysWrite("UpdateRegisterLocations: Register "); @@ -103,7 +103,7 @@ for (int i = 0; i < NUM_VOLATILE_GPRS; i++) { // determine what register index corresponds to this location - int registerIndex = VOLATILE_GPRS[i]; + int registerIndex = VOLATILE_GPRS[i].value(); registerLocations.set(registerIndex, location.toWord()); if (DEBUG) { VM.sysWrite("UpdateRegisterLocations: Register "); Modified: rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/ir/ia32/OPT_PhysicalRegisterSet.java =================================================================== --- rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/ir/ia32/OPT_PhysicalRegisterSet.java 2007-10-26 23:38:32 UTC (rev 13832) +++ rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/ir/ia32/OPT_PhysicalRegisterSet.java 2007-10-27 12:17:20 UTC (rev 13833) @@ -158,7 +158,7 @@ reg[C1].setSpansBasicBlock(); reg[C2].setSpansBasicBlock(); reg[C3].setSpansBasicBlock(); - reg[PROCESSOR_REGISTER].setSpansBasicBlock(); + reg[PROCESSOR_REGISTER.value()].setSpansBasicBlock(); // For SSE2 reg[ST0].setDouble(); @@ -344,6 +344,13 @@ /** * @return the nth physical GPR */ + public OPT_Register getGPR(GPR n) { + return reg[FIRST_INT + n.value()]; + } + + /** + * @return the nth physical GPR + */ public OPT_Register getGPR(int n) { return reg[FIRST_INT + n]; } @@ -400,6 +407,13 @@ /** * @return the nth physical FPR */ + public OPT_Register getFPR(FPR n) { + return reg[FIRST_DOUBLE + n.value()]; + } + + /** + * @return the nth physical FPR + */ public OPT_Register getFPR(int n) { return reg[FIRST_DOUBLE + n]; } @@ -443,13 +457,19 @@ static { String[] regName = registerName; - for (int i = 0; i < NUM_GPRS; i++) { - regName[i + FIRST_INT] = GPR_NAMES[i]; + for (GPR r : GPR.values()) { + regName[r.ordinal() + FIRST_INT] = r.toString(); } - for (int i = 0; i < NUM_FPRS; i++) { - regName[i + FIRST_DOUBLE] = FPR_NAMES[i]; + if (VM_ArchConstants.SSE2_FULL) { + for (XMM r : XMM.values()) { + regName[r.ordinal() + FIRST_DOUBLE] = r.toString(); + } + } else { + for (FPR r : FPR.values()) { + regName[r.ordinal() + FIRST_DOUBLE] = r.toString(); + } } - regName[PROCESSOR_REGISTER] = "PR"; + regName[PROCESSOR_REGISTER.value()] = "PR"; regName[AF] = "AF"; regName[CF] = "CF"; regName[OF] = "OF"; Modified: rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_BaselineConstants.java =================================================================== --- rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_BaselineConstants.java 2007-10-26 23:38:32 UTC (rev 13832) +++ rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_BaselineConstants.java 2007-10-27 12:17:20 UTC (rev 13833) @@ -25,17 +25,17 @@ // Dedicated registers. // - byte JTOC = EDI; - byte SP = ESP; - byte PR = PROCESSOR_REGISTER; + VM_RegisterConstants.GPR JTOC = EDI; + VM_RegisterConstants.GPR SP = ESP; + VM_RegisterConstants.GPR PR = PROCESSOR_REGISTER; // Volatile (parameter) registers. // - byte T0 = EAX; // DO NOT CHANGE THIS ASSIGNMENT - byte T1 = EDX; + VM_RegisterConstants.GPR T0 = EAX; // DO NOT CHANGE THIS ASSIGNMENT + VM_RegisterConstants.GPR T1 = EDX; // scratch register - byte S0 = ECX; + VM_RegisterConstants.GPR S0 = ECX; // Mnemonics corresponding to the above constants. // These are some alternate names that can be used in the debugger Modified: rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_InterfaceMethodConflictResolver.java =================================================================== --- rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_InterfaceMethodConflictResolver.java 2007-10-26 23:38:32 UTC (rev 13832) +++ rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_InterfaceMethodConflictResolver.java 2007-10-27 12:17:20 UTC (rev 13833) @@ -83,7 +83,7 @@ // factor out to reduce code space in each call. // private static void insertStubPrologue(VM_Assembler asm) { - VM_ObjectModel.baselineEmitLoadTIB((ArchitectureSpecific.VM_Assembler) asm, ECX, EAX); + VM_ObjectModel.baselineEmitLoadTIB((ArchitectureSpecific.VM_Assembler) asm, ECX.value(), EAX.value()); } // Generate a subtree covering from low to high inclusive. Modified: rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_MachineSpecificIA.java =================================================================== --- rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_MachineSpecificIA.java 2007-10-26 23:38:32 UTC (rev 13832) +++ rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_MachineSpecificIA.java 2007-10-27 12:17:20 UTC (rev 13833) @@ -64,7 +64,7 @@ */ @Interruptible public final void baselineEmitLoadTIB(ArchitectureSpecific.VM_Assembler asm, int dest, int object, Offset tibOffset) { - asm.emitMOV_Reg_RegDisp((byte) dest, (byte) object, tibOffset); + asm.emitMOV_Reg_RegDisp(GPR.lookup(dest), GPR.lookup(object), tibOffset); } /** @@ -85,8 +85,8 @@ VM_Magic.setCompiledMethodID(fp, INVISIBLE_METHOD_ID); sp = sp.minus(VM_SizeConstants.BYTES_IN_ADDRESS); // allow for one local - contextRegisters.gprs.set(ESP, sp.toWord()); - contextRegisters.gprs.set(VM_BaselineConstants.JTOC, VM_Magic.objectAsAddress(VM_Magic.getJTOC()).toWord()); + contextRegisters.gprs.set(ESP.value(), sp.toWord()); + contextRegisters.gprs.set(VM_BaselineConstants.JTOC.value(), VM_Magic.objectAsAddress(VM_Magic.getJTOC()).toWord()); contextRegisters.fp = fp; contextRegisters.ip = ip; } @@ -104,11 +104,11 @@ @Uninterruptible @Override public final void adjustESP(ArchitectureSpecific.VM_Registers registers, Offset delta, boolean traceAdjustments) { - Word old = registers.gprs.get(ESP); - registers.gprs.set(ESP, old.plus(delta)); + Word old = registers.gprs.get(ESP.value()); + registers.gprs.set(ESP.value(), old.plus(delta)); if (traceAdjustments) { VM.sysWrite(" esp ="); - VM.sysWrite(registers.gprs.get(ESP)); + VM.sysWrite(registers.gprs.get(ESP.value())); } } } Modified: rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_OutOfLineMachineCode.java =================================================================== --- rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_OutOfLineMachineCode.java 2007-10-26 23:38:32 UTC (rev 13832) +++ rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_OutOfLineMachineCode.java 2007-10-27 12:17:20 UTC (rev 13833) @@ -136,7 +136,7 @@ */ int gprs; Offset fpOffset = VM_ArchEntrypoints.framePointerField.getOffset(); - byte T = T0; + GPR T = T0; gprs = NUM_PARAMETER_GPRS; Offset offset = Offset.fromIntZeroExtend(5 << LG_WORDSIZE); // we have exactly 5 paramaters if (gprs > 0) { @@ -305,10 +305,10 @@ asm.emitMOV_RegDisp_Reg(T0, ipOffset, T1); // registers.ip := return address asm.emitADD_Reg_Imm(SP, 4); // throw away space for registers parameter (in T0) asm.emitMOV_Reg_RegDisp(S0, T0, gprsOffset); // S0 := registers.gprs[] - asm.emitMOV_RegDisp_Reg(S0, Offset.fromIntZeroExtend(SP << LG_WORDSIZE), SP); // registers.gprs[#SP] := SP + asm.emitMOV_RegDisp_Reg(S0, Offset.fromIntZeroExtend(SP.value() << LG_WORDSIZE), SP); // registers.gprs[#SP] := SP for (int i = 0; i < NUM_NONVOLATILE_GPRS; i++) { asm.emitMOV_RegDisp_Reg(S0, - Offset.fromIntZeroExtend(NONVOLATILE_GPRS[i] << LG_WORDSIZE), + Offset.fromIntZeroExtend(NONVOLATILE_GPRS[i].value() << LG_WORDSIZE), NONVOLATILE_GPRS[i]); // registers.gprs[i] := i'th register } asm.emitJMP_Reg(T1); // return to return address @@ -348,10 +348,10 @@ asm.emitPOP_RegDisp(S0, fpOffset); // T0.contextRegisters.fp = pushed framepointer asm.emitADD_Reg_Imm(SP, 8); // discard 2 words of parameters (T0, T1) asm.emitMOV_Reg_RegDisp(S0, S0, gprsOffset); // S0 = T0.contextRegisters.gprs; - asm.emitMOV_RegDisp_Reg(S0, Offset.fromIntZeroExtend(SP << LG_WORDSIZE), SP); // T0.contextRegisters.gprs[#SP] := SP + asm.emitMOV_RegDisp_Reg(S0, Offset.fromIntZeroExtend(SP.value() << LG_WORDSIZE), SP); // T0.contextRegisters.gprs[#SP] := SP for (int i = 0; i < NUM_NONVOLATILE_GPRS; i++) { asm.emitMOV_RegDisp_Reg(S0, - Offset.fromIntZeroExtend(NONVOLATILE_GPRS[i] << LG_WORDSIZE), + Offset.fromIntZeroExtend(NONVOLATILE_GPRS[i].value() << LG_WORDSIZE), NONVOLATILE_GPRS[i]); // T0.contextRegisters.gprs[i] := i'th register } @@ -366,11 +366,11 @@ VM_ArchEntrypoints.framePointerField.getOffset(), S0); // PR.framePointer = restoreRegs.fp asm.emitMOV_Reg_RegDisp(S0, T1, gprsOffset); // S0 := restoreRegs.gprs[] - asm.emitMOV_Reg_RegDisp(SP, S0, Offset.fromIntZeroExtend(SP << LG_WORDSIZE)); // SP := restoreRegs.gprs[#SP] + asm.emitMOV_Reg_RegDisp(SP, S0, Offset.fromIntZeroExtend(SP.value() << LG_WORDSIZE)); // SP := restoreRegs.gprs[#SP] for (int i = 0; i < NUM_NONVOLATILE_GPRS; i++) { asm.emitMOV_Reg_RegDisp(NONVOLATILE_GPRS[i], S0, - Offset.fromIntZeroExtend(NONVOLATILE_GPRS[i] << + Offset.fromIntZeroExtend(NONVOLATILE_GPRS[i].value() << LG_WORDSIZE)); // i'th register := restoreRegs.gprs[i] } asm.emitJMP_RegDisp(T1, ipOffset); // return to (save) return address @@ -399,7 +399,7 @@ // Restore SP asm.emitMOV_Reg_RegDisp(S0, T0, VM_ArchEntrypoints.registersGPRsField.getOffset()); - asm.emitMOV_Reg_RegDisp(SP, S0, Offset.fromIntZeroExtend(SP << LG_WORDSIZE)); + asm.emitMOV_Reg_RegDisp(SP, S0, Offset.fromIntZeroExtend(SP.value() << LG_WORDSIZE)); // Push registers.ip to stack (now that SP has been restored) asm.emitPUSH_RegDisp(T0, VM_ArchEntrypoints.registersIPField.getOffset()); @@ -408,13 +408,13 @@ // (restored above and then modified by pushing registers.ip!) Offset off = Offset.zero(); for (byte i = 0; i < NUM_GPRS; i++, off = off.plus(WORDSIZE)) { - if (i != S0 && i != ESI && i != SP) { - asm.emitMOV_Reg_RegDisp(i, S0, off); + if (i != S0.value() && i != ESI.value() && i != SP.value()) { + asm.emitMOV_Reg_RegDisp(GPR.lookup(i), S0, off); } } // Restore S0 - asm.emitMOV_Reg_RegDisp(S0, S0, Offset.fromIntZeroExtend(S0 << LG_WORDSIZE)); + asm.emitMOV_Reg_RegDisp(S0, S0, Offset.fromIntZeroExtend(S0.value() << LG_WORDSIZE)); // Return to registers.ip (popping stack) asm.emitRET(); Modified: rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_ProcessorLocalState.java =================================================================== --- rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_ProcessorLocalState.java 2007-10-26 23:38:32 UTC (rev 13832) +++ rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_ProcessorLocalState.java 2007-10-27 12:17:20 UTC (rev 13833) @@ -17,6 +17,7 @@ import org.jikesrvm.scheduler.VM_Processor; import org.vmmagic.pragma.Uninterruptible; import org.vmmagic.unboxed.Offset; +import org.jikesrvm.ia32.VM_RegisterConstants.GPR; /** * This class provides a layer of abstraction that the rest of the VM must @@ -26,7 +27,7 @@ */ public abstract class VM_ProcessorLocalState { - protected static final byte PROCESSOR_REGISTER = VM_RegisterConstants.ESI; + protected static final GPR PROCESSOR_REGISTER = VM_RegisterConstants.ESI; /** * The C bootstrap program has placed a pointer to the initial @@ -62,7 +63,7 @@ * @param offset of field in the <code>VM_Processor</code> object * @param reg number of the register supplying the new value */ - public static void emitMoveRegToField(VM_Assembler asm, Offset offset, byte reg) { + public static void emitMoveRegToField(VM_Assembler asm, Offset offset, GPR reg) { asm.emitMOV_RegDisp_Reg(PROCESSOR_REGISTER, offset, reg); } @@ -86,7 +87,7 @@ * @param dest number of destination register * @param offset of field in the <code>VM_Processor</code> object */ - public static void emitMoveFieldToReg(VM_Assembler asm, byte dest, Offset offset) { + public static void emitMoveFieldToReg(VM_Assembler asm, GPR dest, Offset offset) { asm.emitMOV_Reg_RegDisp(dest, PROCESSOR_REGISTER, offset); } @@ -110,7 +111,7 @@ * @param offset of field in the <code>VM_Processor</code> object * @param srcReg register containing value to exchange */ - public static void emitCompareAndExchangeField(VM_Assembler asm, Offset offset, byte srcReg) { + public static void emitCompareAndExchangeField(VM_Assembler asm, Offset offset, GPR srcReg) { asm.emitLockNextInstruction(); asm.emitCMPXCHG_RegDisp_Reg(PROCESSOR_REGISTER, offset, srcReg); } @@ -176,7 +177,7 @@ * @param base number of base register * @param offset offset */ - public static void emitStoreProcessor(VM_Assembler asm, byte base, Offset offset) { + public static void emitStoreProcessor(VM_Assembler asm, GPR base, Offset offset) { asm.emitMOV_RegDisp_Reg(base, offset, PROCESSOR_REGISTER); } @@ -188,7 +189,7 @@ * @param base number of base register * @param offset offset */ - public static void emitLoadProcessor(VM_Assembler asm, byte base, Offset offset) { + public static void emitLoadProcessor(VM_Assembler asm, GPR base, Offset offset) { asm.emitMOV_Reg_RegDisp(PROCESSOR_REGISTER, base, offset); } } Modified: rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_RegisterConstants.java =================================================================== --- rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_RegisterConstants.java 2007-10-26 23:38:32 UTC (rev 13832) +++ rvmroot/trunk/rvm/src/org/jikesrvm/ia32/VM_RegisterConstants.java 2007-10-27 12:17:20 UTC (rev 13833) @@ -12,6 +12,9 @@ */ package org.jikesrvm.ia32; +import org.vmmagic.pragma.Pure; +import org.vmmagic.pragma.UninterruptibleNoWarn; + public interface VM_RegisterConstants { //---------------------------------------------------------------------------------------// // RVM register usage conventions - Intel version. // @@ -20,53 +23,156 @@ byte LG_INSTRUCTION_WIDTH = 0; // log2 of instruction width in bytes int INSTRUCTION_WIDTH = 1 << LG_INSTRUCTION_WIDTH; + /** + * Common interface implemented by all registers constants + */ + public interface Register { + /** @return encoded value of this register */ + byte value(); + } + + /** + * Representation of general purpose registers + */ + public enum GPR implements Register { + EAX(0), ECX(1), EDX(2), EBX(3), ESP(4), EBP(5), ESI(6), EDI(7); + + /** Local copy of the backing array. Copied here to avoid calls to clone */ + private static final GPR[] vals = values(); + + /** Constructor a register with the given encoding value */ + private GPR(int v) { + if (v != ordinal()) { + throw new Error("Invalid register ordinal"); + } + } + /... [truncated message content] |