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.tools.header_gen;
014
015 import org.jikesrvm.ia32.ArchConstants;
016 import org.jikesrvm.ia32.BaselineConstants;
017 import org.jikesrvm.ia32.RegisterConstants;
018 import org.jikesrvm.ia32.StackframeLayoutConstants;
019 import org.jikesrvm.ia32.TrapConstants;
020 import org.jikesrvm.runtime.ArchEntrypoints;
021 import org.vmmagic.unboxed.Offset;
022
023 /**
024 * Emit the architecture-specific part of a header file containing declarations
025 * required to access VM data structures from C++.
026 * Posix version: AIX PPC, Linux PPC, Linux IA32
027 */
028 final class GenArch_ia32 extends GenArch {
029 public void emitArchVirtualMachineDeclarations() {
030 Offset offset;
031
032 offset = ArchEntrypoints.registersFPField.getOffset();
033 pln("Registers_fp_offset = ", offset);
034
035 p("static const int Constants_EAX = " + RegisterConstants.EAX.value() + ";\n");
036 p("static const int Constants_ECX = " + RegisterConstants.ECX.value() + ";\n");
037 p("static const int Constants_EDX = " + RegisterConstants.EDX.value() + ";\n");
038 p("static const int Constants_EBX = " + RegisterConstants.EBX.value() + ";\n");
039 p("static const int Constants_ESP = " + RegisterConstants.ESP.value() + ";\n");
040 p("static const int Constants_EBP = " + RegisterConstants.EBP.value() + ";\n");
041 p("static const int Constants_ESI = " + RegisterConstants.ESI.value() + ";\n");
042 p("static const int Constants_EDI = " + RegisterConstants.EDI.value() + ";\n");
043 p("static const int Constants_STACKFRAME_BODY_OFFSET = " +
044 StackframeLayoutConstants.STACKFRAME_BODY_OFFSET + ";\n");
045 p("static const int Constants_STACKFRAME_RETURN_ADDRESS_OFFSET = " +
046 StackframeLayoutConstants.STACKFRAME_RETURN_ADDRESS_OFFSET + ";\n");
047 p("static const int Constants_RVM_TRAP_BASE = " + TrapConstants.RVM_TRAP_BASE + ";\n");
048
049 offset = ArchEntrypoints.framePointerField.getOffset();
050 pln("Thread_framePointer_offset = ", offset);
051 offset = ArchEntrypoints.arrayIndexTrapParamField.getOffset();
052 pln("Thread_arrayIndexTrapParam_offset = ", offset);
053
054 p("static const int ArchConstants_SSE2 = " + (ArchConstants.SSE2_BASE ? "1;\n" : "0;\n"));
055 }
056
057 public void emitArchAssemblerDeclarations() {
058 if (BaselineConstants.TR != BaselineConstants.ESI) {
059 throw new Error("Unexpected TR value");
060 }
061 p("#define TR %ESI;\n");
062 }
063 }