001    /*
002     *  This file is part of the Jikes RVM project (http://jikesrvm.org).
003     *
004     *  This file is licensed to You under the Eclipse Public License (EPL);
005     *  You may not use this file except in compliance with the License. You
006     *  may obtain a copy of the License at
007     *
008     *      http://www.opensource.org/licenses/eclipse-1.0.php
009     *
010     *  See the COPYRIGHT.txt file distributed with this work for information
011     *  regarding copyright ownership.
012     */
013    package org.jikesrvm.ia32;
014    
015    import org.jikesrvm.Constants;
016    import org.vmmagic.unboxed.Offset;
017    import org.jikesrvm.VM;
018    
019    /**
020     * Registers used by baseline compiler implementation of virtual machine.
021     */
022    public interface BaselineConstants extends Constants, ArchConstants {
023    
024      int WORDSIZE = VM.BuildFor64Addr ? 8 : 4; // bytes
025      int LG_WORDSIZE = VM.BuildFor64Addr ? 3 : 2;
026    
027      // Dedicated registers.
028      //
029      RegisterConstants.GPR SP = ESP;
030      RegisterConstants.GPR TR = THREAD_REGISTER;
031    
032      // Volatile (parameter) registers.
033      //
034      RegisterConstants.GPR T0 = EAX;  // DO NOT CHANGE THIS ASSIGNMENT
035      RegisterConstants.GPR T1 = EDX;
036    
037      // HACK: IA32 has been modernized to use Enums; PPC still uses ints.
038      int T0_int = T0.value();
039      int T1_int = T1.value();
040    
041      // scratch register
042      RegisterConstants.GPR S0 = ECX;
043      RegisterConstants.GPR S1 = EDI;
044    
045      // Constants describing baseline compiler conventions for
046      // saving registers in stackframes.
047    
048      int STACKFRAME_REG_SAVE_OFFSET = STACKFRAME_BODY_OFFSET;
049      /** offset from FP of the saved registers. Some registers are saved in all baseline
050        * frames, and most register as saved in the  dynamic bridge frames. */
051      int STACKFRAME_FIRST_PARAMETER_OFFSET = STACKFRAME_REG_SAVE_OFFSET - (2 * WORDSIZE);
052      /** bridge frames save 2 additional GPRs **/
053      int BRIDGE_FRAME_EXTRA_SIZE = (SSE2_FULL ? XMM_STATE_SIZE : FPU_STATE_SIZE) + (2 * WORDSIZE);
054    
055      /** EDI and EBX are nonvolatile registers used by baseline compiler **/
056      int SAVED_GPRS = 2;
057      /** save all non-volatiles **/
058      int SAVED_GPRS_FOR_SAVE_LS_REGISTERS = 3;
059    
060      Offset EDI_SAVE_OFFSET = Offset.fromIntSignExtend(STACKFRAME_REG_SAVE_OFFSET);
061      Offset EBX_SAVE_OFFSET = Offset.fromIntSignExtend(STACKFRAME_REG_SAVE_OFFSET).minus(WORDSIZE);
062      Offset EBP_SAVE_OFFSET = Offset.fromIntSignExtend(STACKFRAME_REG_SAVE_OFFSET).minus(WORDSIZE*2);
063      Offset T0_SAVE_OFFSET = Offset.fromIntSignExtend(STACKFRAME_FIRST_PARAMETER_OFFSET);
064      Offset T1_SAVE_OFFSET = Offset.fromIntSignExtend(STACKFRAME_FIRST_PARAMETER_OFFSET).minus(WORDSIZE);
065      Offset FPU_SAVE_OFFSET = T1_SAVE_OFFSET.minus(FPU_STATE_SIZE);
066      Offset XMM_SAVE_OFFSET = T1_SAVE_OFFSET.minus(XMM_STATE_SIZE);
067    }
068