0
|
1 /*
|
|
2 * Copyright 2000-2002 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 *
|
|
5 * This code is free software; you can redistribute it and/or modify it
|
|
6 * under the terms of the GNU General Public License version 2 only, as
|
|
7 * published by the Free Software Foundation.
|
|
8 *
|
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 * version 2 for more details (a copy is included in the LICENSE file that
|
|
13 * accompanied this code).
|
|
14 *
|
|
15 * You should have received a copy of the GNU General Public License version
|
|
16 * 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 *
|
|
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 * CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 * have any questions.
|
|
22 *
|
|
23 */
|
|
24
|
|
25 package sun.jvm.hotspot.asm.sparc;
|
|
26
|
|
27 import sun.jvm.hotspot.asm.*;
|
|
28 import sun.jvm.hotspot.runtime.*;
|
|
29 import sun.jvm.hotspot.utilities.*;
|
|
30
|
|
31 public class SPARCRegister extends Register {
|
|
32 private static final int nofRegisters = 32; // total number of registers
|
|
33
|
|
34 private static final int GLOBAL_BASE = 0;
|
|
35 private static final int OUT_BASE = 8;
|
|
36 private static final int LOCAL_BASE = 16;
|
|
37 private static final int IN_BASE = 24;
|
|
38
|
|
39 private static final int LOCAL_SP_WORD_OFFSET = 0;
|
|
40 private static final int IN_SP_WORD_OFFSET = 8;
|
|
41
|
|
42 /** Constructor for an explicitly numbered register */
|
|
43 public SPARCRegister(int number) {
|
|
44 super(number);
|
|
45 }
|
|
46
|
|
47 /** Constructor for an I, G, O, or L register */
|
|
48 public SPARCRegister(SPARCRegisterType type, int number) {
|
|
49 if (type == SPARCRegisterType.GLOBAL) {
|
|
50 this.number = number + GLOBAL_BASE;
|
|
51 } else if (type == SPARCRegisterType.OUT) {
|
|
52 this.number = number + OUT_BASE;
|
|
53 } else if (type == SPARCRegisterType.LOCAL) {
|
|
54 this.number = number + LOCAL_BASE;
|
|
55 } else if (type == SPARCRegisterType.IN) {
|
|
56 this.number = number + IN_BASE;
|
|
57 } else {
|
|
58 throw new IllegalArgumentException("Invalid SPARC register type");
|
|
59 }
|
|
60 }
|
|
61
|
|
62 public int getNumberOfRegisters() {
|
|
63 return nofRegisters;
|
|
64 }
|
|
65
|
|
66 public boolean isIn() {
|
|
67 return (IN_BASE <= getNumber());
|
|
68 }
|
|
69
|
|
70 public boolean isLocal() {
|
|
71 return (LOCAL_BASE <= getNumber() && getNumber() < IN_BASE);
|
|
72 }
|
|
73
|
|
74 public boolean isOut() {
|
|
75 return (OUT_BASE <= getNumber() && getNumber() < LOCAL_BASE);
|
|
76 }
|
|
77
|
|
78 public boolean isGlobal() {
|
|
79 return (GLOBAL_BASE <= getNumber() && getNumber() < OUT_BASE);
|
|
80 }
|
|
81
|
|
82 public SPARCRegister afterSave() {
|
|
83 if (Assert.ASSERTS_ENABLED) {
|
|
84 Assert.that(isOut() || isGlobal(), "register not visible after save");
|
|
85 }
|
|
86 return isOut() ? new SPARCRegister(getNumber() + (IN_BASE - OUT_BASE)) : this;
|
|
87 }
|
|
88
|
|
89 public SPARCRegister afterRestore() {
|
|
90 if (Assert.ASSERTS_ENABLED) {
|
|
91 Assert.that(isIn() || isGlobal(), "register not visible after save");
|
|
92 }
|
|
93 return isIn() ? new SPARCRegister(getNumber() + (OUT_BASE - IN_BASE)) : this;
|
|
94 }
|
|
95
|
|
96 /** NOTE: this returns an offset in BYTES in this system! */
|
|
97 public long spOffsetInSavedWindow() {
|
|
98 if (isIn()) {
|
|
99 return VM.getVM().getAddressSize() * (getNumber() - IN_BASE + IN_SP_WORD_OFFSET);
|
|
100 } else if (isLocal()) {
|
|
101 return VM.getVM().getAddressSize() * (getNumber() - LOCAL_BASE + LOCAL_SP_WORD_OFFSET);
|
|
102 }
|
|
103 if (Assert.ASSERTS_ENABLED) {
|
|
104 Assert.that(isIn() || isLocal(), "only ins and locals are saved in my frame");
|
|
105 }
|
|
106 return 0;
|
|
107 }
|
|
108
|
|
109 public String toString() {
|
|
110 return SPARCRegisters.getRegisterName(number);
|
|
111 }
|
|
112
|
|
113 public boolean isFramePointer() {
|
|
114 return number == 30; // is I6?
|
|
115 }
|
|
116
|
|
117 public boolean isStackPointer() {
|
|
118 return number == 14; // is O6?
|
|
119 }
|
|
120
|
|
121 public boolean isFloat() {
|
|
122 return false;
|
|
123 }
|
|
124
|
|
125 public boolean isV9Only() {
|
|
126 return false;
|
|
127 }
|
|
128 }
|