Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/Location.java @ 24218:719853999215 jvmci-0.32
Merge with jdk8u141-b15
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 14 Aug 2017 23:20:38 +0200 |
parents | 3e8ce13f4e12 |
children |
rev | line source |
---|---|
22054 | 1 /* |
23398
3e8ce13f4e12
minimize diff to jvmci-9
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
22054 | 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
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 | 24 |
25 /** | |
26 * Represents a location where a value can be stored. This can be either a {@link Register} or a | |
27 * stack slot. | |
28 */ | |
29 public final class Location { | |
30 | |
31 public final Register reg; | |
32 public final int offset; | |
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 | 35 this.reg = reg; |
36 this.offset = offset; | |
37 } | |
38 | |
39 /** | |
40 * Create a {@link Location} for a register. | |
41 */ | |
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 | 44 } |
45 | |
46 /** | |
47 * Create a {@link Location} for a vector subregister. | |
48 * | |
49 * @param reg the {@link Register vector register} | |
50 * @param offset the offset in bytes into the vector register | |
51 */ | |
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 | 54 } |
55 | |
56 /** | |
57 * Create a {@link Location} for a stack slot. | |
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 | 61 } |
62 | |
63 public boolean isRegister() { | |
64 return reg != null; | |
65 } | |
66 | |
67 public boolean isStack() { | |
68 return reg == null; | |
69 } | |
70 | |
71 @Override | |
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 | 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 | 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 | 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 | 80 } |
81 } |