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 @Override 030 public void emitArchVirtualMachineDeclarations() { 031 Offset offset; 032 033 offset = ArchEntrypoints.registersFPField.getOffset(); 034 pln("Registers_fp_offset = ", offset); 035 036 p("static const int Constants_EAX = " + RegisterConstants.EAX.value() + ";\n"); 037 p("static const int Constants_ECX = " + RegisterConstants.ECX.value() + ";\n"); 038 p("static const int Constants_EDX = " + RegisterConstants.EDX.value() + ";\n"); 039 p("static const int Constants_EBX = " + RegisterConstants.EBX.value() + ";\n"); 040 p("static const int Constants_ESP = " + RegisterConstants.ESP.value() + ";\n"); 041 p("static const int Constants_EBP = " + RegisterConstants.EBP.value() + ";\n"); 042 p("static const int Constants_ESI = " + RegisterConstants.ESI.value() + ";\n"); 043 p("static const int Constants_EDI = " + RegisterConstants.EDI.value() + ";\n"); 044 p("static const int Constants_STACKFRAME_BODY_OFFSET = " + 045 StackframeLayoutConstants.STACKFRAME_BODY_OFFSET + ";\n"); 046 p("static const int Constants_STACKFRAME_RETURN_ADDRESS_OFFSET = " + 047 StackframeLayoutConstants.STACKFRAME_RETURN_ADDRESS_OFFSET + ";\n"); 048 p("static const int Constants_RVM_TRAP_BASE = " + TrapConstants.RVM_TRAP_BASE + ";\n"); 049 050 offset = ArchEntrypoints.framePointerField.getOffset(); 051 pln("Thread_framePointer_offset = ", offset); 052 offset = ArchEntrypoints.arrayIndexTrapParamField.getOffset(); 053 pln("Thread_arrayIndexTrapParam_offset = ", offset); 054 055 p("static const int ArchConstants_SSE2 = " + (ArchConstants.SSE2_BASE ? "1;\n" : "0;\n")); 056 } 057 058 @Override 059 public void emitArchAssemblerDeclarations() { 060 if (BaselineConstants.TR != BaselineConstants.ESI) { 061 throw new Error("Unexpected TR value"); 062 } 063 p("#define TR %ESI;\n"); 064 } 065 }