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 */
013package org.jikesrvm.ia32;
014
015import static org.jikesrvm.ia32.ArchConstants.SSE2_FULL;
016import static org.jikesrvm.ia32.RegisterConstants.EAX;
017import static org.jikesrvm.ia32.RegisterConstants.ECX;
018import static org.jikesrvm.ia32.RegisterConstants.EDI;
019import static org.jikesrvm.ia32.RegisterConstants.EDX;
020import static org.jikesrvm.ia32.RegisterConstants.ESP;
021import static org.jikesrvm.ia32.RegisterConstants.THREAD_REGISTER;
022import static org.jikesrvm.ia32.StackframeLayoutConstants.FPU_STATE_SIZE;
023import static org.jikesrvm.ia32.StackframeLayoutConstants.STACKFRAME_BODY_OFFSET;
024import static org.jikesrvm.ia32.StackframeLayoutConstants.XMM_STATE_SIZE;
025
026import org.jikesrvm.VM;
027import org.jikesrvm.ia32.RegisterConstants.GPR;
028import org.vmmagic.unboxed.Offset;
029
030/**
031 * Registers used by baseline compiler implementation of virtual machine.
032 */
033public final class BaselineConstants {
034
035  public static final int WORDSIZE = VM.BuildFor64Addr ? 8 : 4; // bytes
036  public static final int LG_WORDSIZE = VM.BuildFor64Addr ? 3 : 2;
037
038  // Dedicated registers.
039  //
040  public static final GPR SP = ESP;
041  public static final GPR TR = THREAD_REGISTER;
042
043  // Volatile (parameter) registers.
044  //
045  public static final GPR T0 = EAX;  // DO NOT CHANGE THIS ASSIGNMENT
046  public static final GPR T1 = EDX;
047
048  // scratch register
049  public static final GPR S0 = ECX;
050  public static final GPR S1 = EDI;
051
052  // Constants describing baseline compiler conventions for
053  // saving registers in stackframes.
054
055  public static final Offset STACKFRAME_REG_SAVE_OFFSET = STACKFRAME_BODY_OFFSET;
056  /** offset from FP of the saved registers. Some registers are saved in all baseline
057    * frames, and most register as saved in the  dynamic bridge frames. */
058  public static final Offset STACKFRAME_FIRST_PARAMETER_OFFSET = STACKFRAME_REG_SAVE_OFFSET.minus(2 * WORDSIZE);
059  /** bridge frames save 2 additional GPRs **/
060  public static final int BRIDGE_FRAME_EXTRA_SIZE = (SSE2_FULL ? XMM_STATE_SIZE : FPU_STATE_SIZE) + (2 * WORDSIZE);
061
062  /** EDI and EBX are nonvolatile registers used by baseline compiler **/
063  public static final int SAVED_GPRS = 2;
064  /** save all non-volatiles **/
065  public static final int SAVED_GPRS_FOR_SAVE_LS_REGISTERS = 3;
066
067  public static final Offset EDI_SAVE_OFFSET = STACKFRAME_REG_SAVE_OFFSET;
068  public static final Offset EBX_SAVE_OFFSET = STACKFRAME_REG_SAVE_OFFSET.minus(WORDSIZE);
069  public static final Offset EBP_SAVE_OFFSET = STACKFRAME_REG_SAVE_OFFSET.minus(WORDSIZE * 2);
070  public static final Offset T0_SAVE_OFFSET = STACKFRAME_FIRST_PARAMETER_OFFSET;
071  public static final Offset T1_SAVE_OFFSET = STACKFRAME_FIRST_PARAMETER_OFFSET.minus(WORDSIZE);
072  public static final Offset FPU_SAVE_OFFSET = T1_SAVE_OFFSET.minus(FPU_STATE_SIZE);
073  public static final Offset XMM_SAVE_OFFSET = T1_SAVE_OFFSET.minus(XMM_STATE_SIZE);
074
075  private BaselineConstants() {
076    // prevent instantation
077  }
078}
079