annotate graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java @ 9896:5945a36ccba4

Merge
author Christos Kotselidis <christos.kotselidis@oracle.com>
date Wed, 05 Jun 2013 15:11:58 +0200
parents 3d965e61b5f6 063a712fe8d8
children 5dd9670009df
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
4181
319860ae697a Simplify FrameMap: make offsets of spill slots and outgoing parameters independent so that they can be allocated at the same time, eliminating the separate phases. This makes the separate StackBlock unnecesary. Change CiStackSlot to use byte offsets instead of spill slot index. This makes CiTarget.spillSlotSize unnecessary.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4174
diff changeset
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
6495
75f130f2b30f moved AMD64 specific HotSpot code in com.oracle.graal.hotspot.amd64 project
Doug Simon <doug.simon@oracle.com>
parents: 6494
diff changeset
23 package com.oracle.graal.hotspot.amd64;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
6580
d56d600819fe moved AMD64 into its own (new) project: com.oracle.graal.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
25 import static com.oracle.graal.amd64.AMD64.*;
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9717
diff changeset
26 import static com.oracle.graal.phases.GraalOptions.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
27
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28 import java.util.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
29
6580
d56d600819fe moved AMD64 into its own (new) project: com.oracle.graal.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
30 import com.oracle.graal.amd64.*;
5510
426c605c9d3c Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
31 import com.oracle.graal.api.code.*;
6580
d56d600819fe moved AMD64 into its own (new) project: com.oracle.graal.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
32 import com.oracle.graal.api.code.CallingConvention.Type;
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5506
diff changeset
33 import com.oracle.graal.api.meta.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
34 import com.oracle.graal.graph.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
35 import com.oracle.graal.hotspot.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36
6494
df02fa2bce58 refactored all AMD64 specific HotSpot code in com.oracle.graal.hotspot.target.amd64 package
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
37 public class AMD64HotSpotRegisterConfig implements RegisterConfig {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
38
9425
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9423
diff changeset
39 private final Architecture architecture;
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9423
diff changeset
40
9886
d14b65dac937 Reserve r12 for heap base address when compressed oops are enabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9717
diff changeset
41 private final Register[] allocatable;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
42
9425
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9423
diff changeset
43 private final HashMap<PlatformKind, Register[]> categorized = new HashMap<>();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
44
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
45 private final RegisterAttributes[] attributesMap;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
46
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
47 @Override
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
48 public Register[] getAllocatableRegisters() {
9414
a58860b72b1f made AMD64HotSpotRegisterConfig return copies of internal arrays to prevent clients from modifying them
Doug Simon <doug.simon@oracle.com>
parents: 9296
diff changeset
49 return allocatable.clone();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51
9425
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9423
diff changeset
52 public Register[] getAllocatableRegisters(PlatformKind kind) {
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9423
diff changeset
53 if (categorized.containsKey(kind)) {
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9423
diff changeset
54 return categorized.get(kind);
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9423
diff changeset
55 }
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9423
diff changeset
56
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9423
diff changeset
57 ArrayList<Register> list = new ArrayList<>();
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9423
diff changeset
58 for (Register reg : getAllocatableRegisters()) {
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9423
diff changeset
59 if (architecture.canStoreValue(reg.getRegisterCategory(), kind)) {
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9423
diff changeset
60 list.add(reg);
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9423
diff changeset
61 }
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9423
diff changeset
62 }
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9423
diff changeset
63
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9423
diff changeset
64 Register[] ret = list.toArray(new Register[0]);
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9423
diff changeset
65 categorized.put(kind, ret);
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9423
diff changeset
66 return ret;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
69 @Override
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
70 public RegisterAttributes[] getAttributesMap() {
9414
a58860b72b1f made AMD64HotSpotRegisterConfig return copies of internal arrays to prevent clients from modifying them
Doug Simon <doug.simon@oracle.com>
parents: 9296
diff changeset
71 return attributesMap.clone();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
72 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
73
7364
1489cd4eabe7 added support for making calls with the native/C ABI
Doug Simon <doug.simon@oracle.com>
parents: 7300
diff changeset
74 private final Register[] javaGeneralParameterRegisters;
1489cd4eabe7 added support for making calls with the native/C ABI
Doug Simon <doug.simon@oracle.com>
parents: 7300
diff changeset
75 private final Register[] nativeGeneralParameterRegisters;
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
76 private final Register[] xmmParameterRegisters = {xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7};
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
78 private final CalleeSaveLayout csl;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
79
8222
7a81fbcd67bb Debug option to reduce available registers.
Roland Schatz <roland.schatz@oracle.com>
parents: 8140
diff changeset
80 private static Register findRegister(String name, Register[] all) {
7a81fbcd67bb Debug option to reduce available registers.
Roland Schatz <roland.schatz@oracle.com>
parents: 8140
diff changeset
81 for (Register reg : all) {
7a81fbcd67bb Debug option to reduce available registers.
Roland Schatz <roland.schatz@oracle.com>
parents: 8140
diff changeset
82 if (reg.name.equals(name)) {
7a81fbcd67bb Debug option to reduce available registers.
Roland Schatz <roland.schatz@oracle.com>
parents: 8140
diff changeset
83 return reg;
7a81fbcd67bb Debug option to reduce available registers.
Roland Schatz <roland.schatz@oracle.com>
parents: 8140
diff changeset
84 }
7a81fbcd67bb Debug option to reduce available registers.
Roland Schatz <roland.schatz@oracle.com>
parents: 8140
diff changeset
85 }
7a81fbcd67bb Debug option to reduce available registers.
Roland Schatz <roland.schatz@oracle.com>
parents: 8140
diff changeset
86 throw new IllegalArgumentException("register " + name + " is not allocatable");
7a81fbcd67bb Debug option to reduce available registers.
Roland Schatz <roland.schatz@oracle.com>
parents: 8140
diff changeset
87 }
7a81fbcd67bb Debug option to reduce available registers.
Roland Schatz <roland.schatz@oracle.com>
parents: 8140
diff changeset
88
9886
d14b65dac937 Reserve r12 for heap base address when compressed oops are enabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9717
diff changeset
89 private static Register[] initAllocatable(boolean reserveForHeapBase) {
d14b65dac937 Reserve r12 for heap base address when compressed oops are enabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9717
diff changeset
90 Register[] registers = null;
9717
f8e0bf2c70e2 consolidated the two RegisterConfig instances for HotSpotRuntime into one
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
91 // @formatter:off
9886
d14b65dac937 Reserve r12 for heap base address when compressed oops are enabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9717
diff changeset
92 if (reserveForHeapBase) {
d14b65dac937 Reserve r12 for heap base address when compressed oops are enabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9717
diff changeset
93 registers = new Register[] {
d14b65dac937 Reserve r12 for heap base address when compressed oops are enabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9717
diff changeset
94 rax, rbx, rcx, rdx, /*rsp,*/ rbp, rsi, rdi, r8, r9, r10, r11, /*r12,*/ r13, r14, /*r15, */
d14b65dac937 Reserve r12 for heap base address when compressed oops are enabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9717
diff changeset
95 xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7,
d14b65dac937 Reserve r12 for heap base address when compressed oops are enabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9717
diff changeset
96 xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15
d14b65dac937 Reserve r12 for heap base address when compressed oops are enabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9717
diff changeset
97 };
d14b65dac937 Reserve r12 for heap base address when compressed oops are enabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9717
diff changeset
98 } else {
d14b65dac937 Reserve r12 for heap base address when compressed oops are enabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9717
diff changeset
99 registers = new Register[] {
8338
16e34a47039b Make r10 allocatable.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8335
diff changeset
100 rax, rbx, rcx, rdx, /*rsp,*/ rbp, rsi, rdi, r8, r9, r10, r11, r12, r13, r14, /*r15, */
8222
7a81fbcd67bb Debug option to reduce available registers.
Roland Schatz <roland.schatz@oracle.com>
parents: 8140
diff changeset
101 xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7,
7a81fbcd67bb Debug option to reduce available registers.
Roland Schatz <roland.schatz@oracle.com>
parents: 8140
diff changeset
102 xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15
9886
d14b65dac937 Reserve r12 for heap base address when compressed oops are enabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9717
diff changeset
103 };
d14b65dac937 Reserve r12 for heap base address when compressed oops are enabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9717
diff changeset
104 }
d14b65dac937 Reserve r12 for heap base address when compressed oops are enabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9717
diff changeset
105 // @formatter:on
8222
7a81fbcd67bb Debug option to reduce available registers.
Roland Schatz <roland.schatz@oracle.com>
parents: 8140
diff changeset
106
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9717
diff changeset
107 if (RegisterPressure.getValue() != null) {
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9717
diff changeset
108 String[] names = RegisterPressure.getValue().split(",");
8222
7a81fbcd67bb Debug option to reduce available registers.
Roland Schatz <roland.schatz@oracle.com>
parents: 8140
diff changeset
109 Register[] regs = new Register[names.length];
7a81fbcd67bb Debug option to reduce available registers.
Roland Schatz <roland.schatz@oracle.com>
parents: 8140
diff changeset
110 for (int i = 0; i < names.length; i++) {
9886
d14b65dac937 Reserve r12 for heap base address when compressed oops are enabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9717
diff changeset
111 regs[i] = findRegister(names[i], registers);
8222
7a81fbcd67bb Debug option to reduce available registers.
Roland Schatz <roland.schatz@oracle.com>
parents: 8140
diff changeset
112 }
7a81fbcd67bb Debug option to reduce available registers.
Roland Schatz <roland.schatz@oracle.com>
parents: 8140
diff changeset
113 return regs;
7a81fbcd67bb Debug option to reduce available registers.
Roland Schatz <roland.schatz@oracle.com>
parents: 8140
diff changeset
114 }
7a81fbcd67bb Debug option to reduce available registers.
Roland Schatz <roland.schatz@oracle.com>
parents: 8140
diff changeset
115
9886
d14b65dac937 Reserve r12 for heap base address when compressed oops are enabled
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9717
diff changeset
116 return registers;
8222
7a81fbcd67bb Debug option to reduce available registers.
Roland Schatz <roland.schatz@oracle.com>
parents: 8140
diff changeset
117 }
7a81fbcd67bb Debug option to reduce available registers.
Roland Schatz <roland.schatz@oracle.com>
parents: 8140
diff changeset
118
9717
f8e0bf2c70e2 consolidated the two RegisterConfig instances for HotSpotRuntime into one
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
119 public AMD64HotSpotRegisterConfig(Architecture architecture, HotSpotVMConfig config) {
9425
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9423
diff changeset
120 this.architecture = architecture;
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9423
diff changeset
121
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
122 if (config.windowsOs) {
9717
f8e0bf2c70e2 consolidated the two RegisterConfig instances for HotSpotRuntime into one
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
123 javaGeneralParameterRegisters = new Register[]{rdx, r8, r9, rdi, rsi, rcx};
f8e0bf2c70e2 consolidated the two RegisterConfig instances for HotSpotRuntime into one
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
124 nativeGeneralParameterRegisters = new Register[]{rcx, rdx, r8, r9};
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
125 } else {
9717
f8e0bf2c70e2 consolidated the two RegisterConfig instances for HotSpotRuntime into one
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
126 javaGeneralParameterRegisters = new Register[]{rsi, rdx, rcx, r8, r9, rdi};
f8e0bf2c70e2 consolidated the two RegisterConfig instances for HotSpotRuntime into one
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
127 nativeGeneralParameterRegisters = new Register[]{rdi, rsi, rdx, rcx, r8, r9};
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
128 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
129
9717
f8e0bf2c70e2 consolidated the two RegisterConfig instances for HotSpotRuntime into one
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
130 csl = null;
9892
3d965e61b5f6 Unsuccessful attempt to save r12 when heap base is zero, verification uses it
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9886
diff changeset
131 allocatable = initAllocatable(config.useCompressedOops);
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
132 attributesMap = RegisterAttributes.createMap(this, AMD64.allRegisters);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
133 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
134
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
135 @Override
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
136 public Register[] getCallerSaveRegisters() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
137 return getAllocatableRegisters();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
138 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
139
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
140 @Override
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
141 public Register getRegisterForRole(int index) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
142 throw new UnsupportedOperationException();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
143 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
144
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
145 @Override
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7098
diff changeset
146 public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target, boolean stackOnly) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
147 if (type == Type.NativeCall) {
7364
1489cd4eabe7 added support for making calls with the native/C ABI
Doug Simon <doug.simon@oracle.com>
parents: 7300
diff changeset
148 return callingConvention(nativeGeneralParameterRegisters, returnType, parameterTypes, type, target, stackOnly);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
149 }
9717
f8e0bf2c70e2 consolidated the two RegisterConfig instances for HotSpotRuntime into one
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
150 // On x64, parameter locations are the same whether viewed
f8e0bf2c70e2 consolidated the two RegisterConfig instances for HotSpotRuntime into one
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
151 // from the caller or callee perspective
7364
1489cd4eabe7 added support for making calls with the native/C ABI
Doug Simon <doug.simon@oracle.com>
parents: 7300
diff changeset
152 return callingConvention(javaGeneralParameterRegisters, returnType, parameterTypes, type, target, stackOnly);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
153 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
154
9425
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9423
diff changeset
155 public Register[] getCallingConventionRegisters(Type type, Kind kind) {
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9423
diff changeset
156 if (architecture.canStoreValue(XMM, kind)) {
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents: 6495
diff changeset
157 return xmmParameterRegisters;
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents: 6495
diff changeset
158 }
9425
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9423
diff changeset
159 assert architecture.canStoreValue(CPU, kind);
7364
1489cd4eabe7 added support for making calls with the native/C ABI
Doug Simon <doug.simon@oracle.com>
parents: 7300
diff changeset
160 return type == Type.NativeCall ? nativeGeneralParameterRegisters : javaGeneralParameterRegisters;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
161 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
162
7364
1489cd4eabe7 added support for making calls with the native/C ABI
Doug Simon <doug.simon@oracle.com>
parents: 7300
diff changeset
163 private CallingConvention callingConvention(Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, Type type, TargetDescription target, boolean stackOnly) {
9296
1342574c4f7d Move targets can only be AllocatableValues.
Roland Schatz <roland.schatz@oracle.com>
parents: 8338
diff changeset
164 AllocatableValue[] locations = new AllocatableValue[parameterTypes.length];
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
165
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
166 int currentGeneral = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
167 int currentXMM = 0;
4181
319860ae697a Simplify FrameMap: make offsets of spill slots and outgoing parameters independent so that they can be allocated at the same time, eliminating the separate phases. This makes the separate StackBlock unnecesary. Change CiStackSlot to use byte offsets instead of spill slot index. This makes CiTarget.spillSlotSize unnecessary.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4174
diff changeset
168 int currentStackOffset = 0;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
169
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7098
diff changeset
170 for (int i = 0; i < parameterTypes.length; i++) {
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7098
diff changeset
171 final Kind kind = parameterTypes[i].getKind();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
172
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
173 switch (kind) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
174 case Byte:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
175 case Boolean:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
176 case Short:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
177 case Char:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
178 case Int:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
179 case Long:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
180 case Object:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
181 if (!stackOnly && currentGeneral < generalParameterRegisters.length) {
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
182 Register register = generalParameterRegisters[currentGeneral++];
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
183 locations[i] = register.asValue(kind);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
184 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
185 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
186 case Float:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
187 case Double:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
188 if (!stackOnly && currentXMM < xmmParameterRegisters.length) {
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
189 Register register = xmmParameterRegisters[currentXMM++];
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
190 locations[i] = register.asValue(kind);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
191 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
192 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
193 default:
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4220
diff changeset
194 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
195 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
196
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
197 if (locations[i] == null) {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6531
diff changeset
198 locations[i] = StackSlot.get(kind.getStackKind(), currentStackOffset, !type.out);
9423
3426008293e7 Move getSizeInBytes method to Architecture class.
Roland Schatz <roland.schatz@oracle.com>
parents: 9414
diff changeset
199 currentStackOffset += Math.max(target.arch.getSizeInBytes(kind), target.wordSize);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
200 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
201 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
202
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7098
diff changeset
203 Kind returnKind = returnType == null ? Kind.Void : returnType.getKind();
9296
1342574c4f7d Move targets can only be AllocatableValues.
Roland Schatz <roland.schatz@oracle.com>
parents: 8338
diff changeset
204 AllocatableValue returnLocation = returnKind == Kind.Void ? Value.ILLEGAL : getReturnRegister(returnKind).asValue(returnKind);
6470
b1010f7bc0bf expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents: 6413
diff changeset
205 return new CallingConvention(currentStackOffset, returnLocation, locations);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
206 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
207
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
208 @Override
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
209 public Register getReturnRegister(Kind kind) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
210 switch (kind) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
211 case Boolean:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
212 case Byte:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
213 case Char:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
214 case Short:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
215 case Int:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
216 case Long:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
217 case Object:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
218 return rax;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
219 case Float:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
220 case Double:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
221 return xmm0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
222 case Void:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
223 case Illegal:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
224 return null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
225 default:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
226 throw new UnsupportedOperationException("no return register for type " + kind);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
227 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
228 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
229
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
230 @Override
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
231 public Register getFrameRegister() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
232 return rsp;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
233 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
234
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
235 public CalleeSaveLayout getCalleeSaveLayout() {
5233
efbb1e33e2f3 removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents: 5061
diff changeset
236 return csl;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
237 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
238
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
239 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
240 public String toString() {
9717
f8e0bf2c70e2 consolidated the two RegisterConfig instances for HotSpotRuntime into one
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
241 return String.format("Allocatable: " + Arrays.toString(getAllocatableRegisters()) + "%n" + "CallerSave: " + Arrays.toString(getCallerSaveRegisters()) + "%n");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
242 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
243 }