comparison c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRegisterConfig.java @ 1416:1b41af477605

Added HotSpotVM project Java source files.
author Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
date Wed, 23 Jun 2010 16:36:58 +0200
parents
children 55ac38887415
comparison
equal deleted inserted replaced
1415:712c7ff1afc1 1416:1b41af477605
1 /*
2 * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
3 *
4 * Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product
5 * that is described in this document. In particular, and without limitation, these intellectual property
6 * rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or
7 * more additional patents or pending patent applications in the U.S. and in other countries.
8 *
9 * U.S. Government Rights - Commercial software. Government users are subject to the Sun
10 * Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its
11 * supplements.
12 *
13 * Use is subject to license terms. Sun, Sun Microsystems, the Sun logo, Java and Solaris are trademarks or
14 * registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks
15 * are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the
16 * U.S. and other countries.
17 *
18 * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open
19 * Company, Ltd.
20 */
21 package com.sun.hotspot.c1x;
22
23 import com.sun.c1x.target.amd64.AMD64;
24 import com.sun.c1x.util.Util;
25 import com.sun.cri.ci.CiCallingConvention;
26 import com.sun.cri.ci.CiKind;
27 import com.sun.cri.ci.CiRegister;
28 import com.sun.cri.ci.CiStackSlot;
29 import com.sun.cri.ci.CiTarget;
30 import com.sun.cri.ci.CiValue;
31 import com.sun.cri.ri.RiRegisterConfig;
32
33 /**
34 * @author Thomas Wuerthinger
35 *
36 */
37 public class HotSpotRegisterConfig implements RiRegisterConfig {
38
39 @Override
40 public CiRegister[] getAllocatableRegisters() {
41 return new CiRegister[]{ AMD64.rax, AMD64.rbx, AMD64.rcx, AMD64.rdx, AMD64.rsi, AMD64.rdi, AMD64.r10, AMD64.r11} ;
42 }
43
44
45 private final CiRegister[] generalParameterRegisters = new CiRegister[]{AMD64.rdx, AMD64.r8, AMD64.r9, AMD64.rdi, AMD64.rsi, AMD64.rcx};
46 private final CiRegister[] xmmParameterRegisters = new CiRegister[]{AMD64.xmm0, AMD64.xmm1, AMD64.xmm2, AMD64.xmm3, AMD64.xmm4, AMD64.xmm5, AMD64.xmm6, AMD64.xmm7};
47
48 @Override
49 public int getCalleeSaveRegisterOffset(CiRegister register) {
50 return 0;
51 }
52
53 @Override
54 public CiRegister[] getCallerSaveRegisters() {
55 return getAllocatableRegisters();
56 }
57
58 @Override
59 public CiRegister getFramePointerRegister() {
60 return AMD64.rbp;
61 }
62
63 @Override
64 public CiRegister getIntegerRegister(int index) {
65 throw new UnsupportedOperationException();
66 }
67
68 @Override
69 public CiCallingConvention getJavaCallingConvention(CiKind[] parameters, boolean outgoing, CiTarget target) {
70 return callingConvention(parameters, outgoing, target);
71 }
72
73 private CiCallingConvention callingConvention(CiKind[] types, boolean outgoing, CiTarget target) {
74 CiValue[] locations = new CiValue[types.length];
75
76 int currentGeneral = 0;
77 int currentXMM = 0;
78 int currentStackIndex = 0;
79
80 for (int i = 0; i < types.length; i++) {
81 final CiKind kind = types[i];
82
83 switch (kind) {
84 case Byte:
85 case Boolean:
86 case Short:
87 case Char:
88 case Int:
89 case Long:
90 case Word:
91 case Object:
92 if (currentGeneral < generalParameterRegisters.length) {
93 CiRegister register = generalParameterRegisters[currentGeneral++];
94 locations[i] = register.asValue(kind);
95 }
96 break;
97
98 case Float:
99 case Double:
100 if (currentXMM < xmmParameterRegisters.length) {
101 CiRegister register = xmmParameterRegisters[currentXMM++];
102 locations[i] = register.asValue(kind);
103 }
104 break;
105
106 default:
107 throw Util.shouldNotReachHere();
108 }
109
110 if (locations[i] == null) {
111 locations[i] = CiStackSlot.get(kind.stackKind(), currentStackIndex, !outgoing);
112 currentStackIndex += target.spillSlots(kind);
113 }
114 }
115
116 return new CiCallingConvention(locations, currentStackIndex * target.spillSlotSize);
117 }
118
119 @Override
120 public int getMinimumCalleeSaveFrameSize() {
121 return 0;
122 }
123
124 @Override
125 public CiCallingConvention getNativeCallingConvention(CiKind[] parameters, boolean outgoing, CiTarget target) {
126 throw new UnsupportedOperationException();
127 }
128
129 @Override
130 public CiRegister[] getRegisterReferenceMapOrder() {
131 return getAllocatableRegisters();
132 }
133
134 @Override
135 public CiRegister getReturnRegister(CiKind kind) {
136 return AMD64.rax;
137 }
138
139 @Override
140 public CiCallingConvention getRuntimeCallingConvention(CiKind[] parameters, CiTarget target) {
141 throw new UnsupportedOperationException();
142 }
143
144 @Override
145 public CiRegister getSafepointRegister() {
146 return AMD64.r13;
147 }
148
149 @Override
150 public CiRegister getScratchRegister() {
151 return AMD64.r15;
152 }
153
154 @Override
155 public CiRegister getStackPointerRegister() {
156 return AMD64.rsp;
157 }
158
159 @Override
160 public CiRegister getThreadRegister() {
161 return AMD64.r14;
162 }
163
164 }