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.VM;
016 import org.jikesrvm.ppc.BaselineConstants;
017 import org.jikesrvm.ppc.RegisterConstants;
018 import org.jikesrvm.ppc.StackframeLayoutConstants;
019 import org.jikesrvm.ppc.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_ppc extends GenArch {
029 public void emitArchVirtualMachineDeclarations() {
030 Offset offset;
031 offset = ArchEntrypoints.registersLRField.getOffset();
032 pln("Registers_lr_offset = ", offset);
033
034 p("static const int Constants_JTOC_POINTER = " + RegisterConstants.JTOC_POINTER + ";\n");
035 p("static const int Constants_FRAME_POINTER = " + RegisterConstants.FRAME_POINTER + ";\n");
036 p("static const int Constants_THREAD_REGISTER = " + RegisterConstants.THREAD_REGISTER + ";\n");
037 p("static const int Constants_FIRST_VOLATILE_GPR = " + RegisterConstants.FIRST_VOLATILE_GPR + ";\n");
038 p("static const int Constants_DIVIDE_BY_ZERO_MASK = " + TrapConstants.DIVIDE_BY_ZERO_MASK + ";\n");
039 p("static const int Constants_DIVIDE_BY_ZERO_TRAP = " + TrapConstants.DIVIDE_BY_ZERO_TRAP + ";\n");
040 p("static const int Constants_MUST_IMPLEMENT_MASK = " + TrapConstants.MUST_IMPLEMENT_MASK + ";\n");
041 p("static const int Constants_MUST_IMPLEMENT_TRAP = " + TrapConstants.MUST_IMPLEMENT_TRAP + ";\n");
042 p("static const int Constants_STORE_CHECK_MASK = " + TrapConstants.STORE_CHECK_MASK + ";\n");
043 p("static const int Constants_STORE_CHECK_TRAP = " + TrapConstants.STORE_CHECK_TRAP + ";\n");
044 p("static const int Constants_ARRAY_INDEX_MASK = " + TrapConstants.ARRAY_INDEX_MASK + ";\n");
045 p("static const int Constants_ARRAY_INDEX_TRAP = " + TrapConstants.ARRAY_INDEX_TRAP + ";\n");
046 p("static const int Constants_ARRAY_INDEX_REG_MASK = " + TrapConstants.ARRAY_INDEX_REG_MASK + ";\n");
047 p("static const int Constants_ARRAY_INDEX_REG_SHIFT = " + TrapConstants.ARRAY_INDEX_REG_SHIFT + ";\n");
048 p("static const int Constants_CONSTANT_ARRAY_INDEX_MASK = " +
049 TrapConstants.CONSTANT_ARRAY_INDEX_MASK + ";\n");
050 p("static const int Constants_CONSTANT_ARRAY_INDEX_TRAP = " +
051 TrapConstants.CONSTANT_ARRAY_INDEX_TRAP + ";\n");
052 p("static const int Constants_CONSTANT_ARRAY_INDEX_INFO = " +
053 TrapConstants.CONSTANT_ARRAY_INDEX_INFO + ";\n");
054 p("static const int Constants_WRITE_BUFFER_OVERFLOW_MASK = " +
055 TrapConstants.WRITE_BUFFER_OVERFLOW_MASK + ";\n");
056 p("static const int Constants_WRITE_BUFFER_OVERFLOW_TRAP = " +
057 TrapConstants.WRITE_BUFFER_OVERFLOW_TRAP + ";\n");
058 p("static const int Constants_STACK_OVERFLOW_MASK = " + TrapConstants.STACK_OVERFLOW_MASK + ";\n");
059 p("static const int Constants_STACK_OVERFLOW_HAVE_FRAME_TRAP = " +
060 TrapConstants.STACK_OVERFLOW_HAVE_FRAME_TRAP + ";\n");
061 p("static const int Constants_STACK_OVERFLOW_TRAP = " + TrapConstants.STACK_OVERFLOW_TRAP + ";\n");
062 p("static const int Constants_CHECKCAST_MASK = " + TrapConstants.CHECKCAST_MASK + ";\n");
063 p("static const int Constants_CHECKCAST_TRAP = " + TrapConstants.CHECKCAST_TRAP + ";\n");
064 p("static const int Constants_REGENERATE_MASK = " + TrapConstants.REGENERATE_MASK + ";\n");
065 p("static const int Constants_REGENERATE_TRAP = " + TrapConstants.REGENERATE_TRAP + ";\n");
066 p("static const int Constants_NULLCHECK_MASK = " + TrapConstants.NULLCHECK_MASK + ";\n");
067 p("static const int Constants_NULLCHECK_TRAP = " + TrapConstants.NULLCHECK_TRAP + ";\n");
068 p("static const int Constants_JNI_STACK_TRAP_MASK = " +
069 TrapConstants.JNI_STACK_TRAP_MASK + ";\n");
070 p("static const int Constants_JNI_STACK_TRAP = " + TrapConstants.JNI_STACK_TRAP + ";\n");
071 p("static const int Constants_STACKFRAME_NEXT_INSTRUCTION_OFFSET = " +
072 StackframeLayoutConstants.STACKFRAME_NEXT_INSTRUCTION_OFFSET + ";\n");
073 p("static const int Constants_STACKFRAME_ALIGNMENT = " +
074 StackframeLayoutConstants.STACKFRAME_ALIGNMENT + " ;\n");
075 }
076
077 public void emitArchAssemblerDeclarations() {
078 if (VM.BuildForOsx) {
079 pln("#define FP r" + BaselineConstants.FP);
080 pln("#define JTOC r" + BaselineConstants.JTOC);
081 pln("#define THREAD_REGISTER r" + BaselineConstants.THREAD_REGISTER);
082 pln("#define S0 r" + BaselineConstants.S0);
083 pln("#define T0 r" + BaselineConstants.T0);
084 pln("#define T1 r" + BaselineConstants.T1);
085 pln("#define T2 r" + BaselineConstants.T2);
086 pln("#define T3 r" + BaselineConstants.T3);
087 pln("#define STACKFRAME_NEXT_INSTRUCTION_OFFSET " +
088 StackframeLayoutConstants.STACKFRAME_NEXT_INSTRUCTION_OFFSET);
089 } else {
090 pln(".set FP," + BaselineConstants.FP);
091 pln(".set JTOC," + BaselineConstants.JTOC);
092 pln(".set THREAD_REGISTER," + BaselineConstants.THREAD_REGISTER);
093 pln(".set S0," + BaselineConstants.S0);
094 pln(".set T0," + BaselineConstants.T0);
095 pln(".set T1," + BaselineConstants.T1);
096 pln(".set T2," + BaselineConstants.T2);
097 pln(".set T3," + BaselineConstants.T3);
098 pln(".set STACKFRAME_NEXT_INSTRUCTION_OFFSET," + StackframeLayoutConstants.STACKFRAME_NEXT_INSTRUCTION_OFFSET);
099 if (!VM.BuildForAix) {
100 pln(".set T4," + (BaselineConstants.T3 + 1));
101 }
102 }
103 }
104 }