annotate jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/Location.java @ 22672:1bbd4a7c274b

Rename jdk.internal.jvmci to jdk.vm.ci
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Thu, 08 Oct 2015 17:28:41 -0700
parents jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/Location.java@ae67bd822493
children 3e8ce13f4e12
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22054
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
1 /*
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
2 * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
4 *
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
7 * published by the Free Software Foundation.
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
8 *
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
13 * accompanied this code).
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
14 *
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
18 *
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
21 * questions.
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
22 */
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22134
diff changeset
23 package jdk.vm.ci.code;
22054
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
24
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
25 /**
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
26 * Represents a location where a value can be stored. This can be either a {@link Register} or a
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
27 * stack slot.
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
28 */
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
29 public final class Location {
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
30
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
31 public final Register reg;
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
32 public final int offset;
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
33
22134
ae67bd822493 jvmci: Move Location.addFrameSize logic from C++ to Java.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
34 private Location(Register reg, int offset) {
22054
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
35 this.reg = reg;
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
36 this.offset = offset;
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
37 }
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
38
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
39 /**
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
40 * Create a {@link Location} for a register.
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
41 */
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
42 public static Location register(Register reg) {
22134
ae67bd822493 jvmci: Move Location.addFrameSize logic from C++ to Java.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
43 return new Location(reg, 0);
22054
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
44 }
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
45
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
46 /**
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
47 * Create a {@link Location} for a vector subregister.
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
48 *
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
49 * @param reg the {@link Register vector register}
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
50 * @param offset the offset in bytes into the vector register
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
51 */
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
52 public static Location subregister(Register reg, int offset) {
22134
ae67bd822493 jvmci: Move Location.addFrameSize logic from C++ to Java.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
53 return new Location(reg, offset);
22054
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
54 }
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
55
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
56 /**
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
57 * Create a {@link Location} for a stack slot.
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
58 */
22134
ae67bd822493 jvmci: Move Location.addFrameSize logic from C++ to Java.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
59 public static Location stack(int offset) {
ae67bd822493 jvmci: Move Location.addFrameSize logic from C++ to Java.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
60 return new Location(null, offset);
22054
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
61 }
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
62
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
63 public boolean isRegister() {
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
64 return reg != null;
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
65 }
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
66
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
67 public boolean isStack() {
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
68 return reg == null;
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
69 }
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
70
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
71 @Override
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
72 public String toString() {
22134
ae67bd822493 jvmci: Move Location.addFrameSize logic from C++ to Java.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
73 String regName;
22054
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
74 if (isRegister()) {
22134
ae67bd822493 jvmci: Move Location.addFrameSize logic from C++ to Java.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
75 regName = reg.name + ":";
22054
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
76 } else {
22134
ae67bd822493 jvmci: Move Location.addFrameSize logic from C++ to Java.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
77 regName = "stack:";
22054
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
78 }
22134
ae67bd822493 jvmci: Move Location.addFrameSize logic from C++ to Java.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
79 return regName + offset;
22054
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
80 }
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents:
diff changeset
81 }