annotate jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/ValueUtil.java @ 24225:a2dbb6fcc923

Added tag jvmci-0.33 for changeset 3aed4cb813f4
author Doug Simon <doug.simon@oracle.com>
date Fri, 18 Aug 2017 22:47:33 +0200
parents 1d4ce2d19e52
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
1 /*
22478
822922922f3c Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
4 *
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
8 *
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
13 * accompanied this code).
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
14 *
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
18 *
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
21 * questions.
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
22 */
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22580
diff changeset
23 package jdk.vm.ci.code;
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
24
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22580
diff changeset
25 import jdk.vm.ci.meta.AllocatableValue;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22580
diff changeset
26 import jdk.vm.ci.meta.JavaConstant;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22580
diff changeset
27 import jdk.vm.ci.meta.JavaValue;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22580
diff changeset
28 import jdk.vm.ci.meta.PlatformKind;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22580
diff changeset
29 import jdk.vm.ci.meta.Value;
22054
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents: 21798
diff changeset
30
6329
92bc58dc5b5e More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5552
diff changeset
31 /**
92bc58dc5b5e More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5552
diff changeset
32 * Utility class for working with the {@link Value} class and its subclasses.
92bc58dc5b5e More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5552
diff changeset
33 */
92bc58dc5b5e More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5552
diff changeset
34 public final class ValueUtil {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
35
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
36 public static boolean isIllegal(Value value) {
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
37 assert value != null;
19699
50b6f616b3c7 Use ILLEGAL.equals(value) in ValueUtil.isIllegal
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18430
diff changeset
38 return Value.ILLEGAL.equals(value);
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
39 }
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
40
22478
822922922f3c Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
41 public static boolean isIllegalJavaValue(JavaValue value) {
822922922f3c Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
42 assert value != null;
822922922f3c Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
43 return Value.ILLEGAL.equals(value);
822922922f3c Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
44 }
822922922f3c Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
45
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
46 public static boolean isLegal(Value value) {
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
47 return !isIllegal(value);
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
48 }
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
49
22478
822922922f3c Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
50 public static boolean isVirtualObject(JavaValue value) {
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
51 assert value != null;
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
52 return value instanceof VirtualObject;
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
53 }
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
54
22478
822922922f3c Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
55 public static VirtualObject asVirtualObject(JavaValue value) {
4233
fa53d5e4aa35 Remove lock information from frame states, and compute it instead when LIR is generated.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4206
diff changeset
56 assert value != null;
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
57 return (VirtualObject) value;
4233
fa53d5e4aa35 Remove lock information from frame states, and compute it instead when LIR is generated.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4206
diff changeset
58 }
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
59
22478
822922922f3c Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
60 public static boolean isConstantJavaValue(JavaValue value) {
822922922f3c Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
61 assert value != null;
822922922f3c Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
62 return value instanceof JavaConstant;
822922922f3c Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
63 }
822922922f3c Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents: 22054
diff changeset
64
22580
6a7f2f656ed9 Add asConstantJavaValue method to ValueUtil.
Roland Schatz <roland.schatz@oracle.com>
parents: 22569
diff changeset
65 public static JavaConstant asConstantJavaValue(JavaValue value) {
6a7f2f656ed9 Add asConstantJavaValue method to ValueUtil.
Roland Schatz <roland.schatz@oracle.com>
parents: 22569
diff changeset
66 assert value != null;
6a7f2f656ed9 Add asConstantJavaValue method to ValueUtil.
Roland Schatz <roland.schatz@oracle.com>
parents: 22569
diff changeset
67 return (JavaConstant) value;
6a7f2f656ed9 Add asConstantJavaValue method to ValueUtil.
Roland Schatz <roland.schatz@oracle.com>
parents: 22569
diff changeset
68 }
6a7f2f656ed9 Add asConstantJavaValue method to ValueUtil.
Roland Schatz <roland.schatz@oracle.com>
parents: 22569
diff changeset
69
7907
ea1c2bed2bfa Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents: 7816
diff changeset
70 public static boolean isAllocatableValue(Value value) {
ea1c2bed2bfa Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents: 7816
diff changeset
71 assert value != null;
ea1c2bed2bfa Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents: 7816
diff changeset
72 return value instanceof AllocatableValue;
ea1c2bed2bfa Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents: 7816
diff changeset
73 }
ea1c2bed2bfa Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents: 7816
diff changeset
74
ea1c2bed2bfa Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents: 7816
diff changeset
75 public static AllocatableValue asAllocatableValue(Value value) {
ea1c2bed2bfa Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents: 7816
diff changeset
76 assert value != null;
ea1c2bed2bfa Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents: 7816
diff changeset
77 return (AllocatableValue) value;
ea1c2bed2bfa Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents: 7816
diff changeset
78 }
ea1c2bed2bfa Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents: 7816
diff changeset
79
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
80 public static boolean isStackSlot(Value value) {
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
81 assert value != null;
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
82 return value instanceof StackSlot;
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
83 }
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
84
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
85 public static StackSlot asStackSlot(Value value) {
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
86 assert value != null;
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
87 return (StackSlot) value;
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
88 }
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
89
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
90 public static boolean isRegister(Value value) {
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
91 assert value != null;
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
92 return value instanceof RegisterValue;
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
93 }
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
94
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
95 public static Register asRegister(Value value) {
22506
363cba9482db Add ValueUtil#asRegisterValue.
Josef Eisl <josef.eisl@jku.at>
parents: 22489
diff changeset
96 return asRegisterValue(value).getRegister();
363cba9482db Add ValueUtil#asRegisterValue.
Josef Eisl <josef.eisl@jku.at>
parents: 22489
diff changeset
97 }
363cba9482db Add ValueUtil#asRegisterValue.
Josef Eisl <josef.eisl@jku.at>
parents: 22489
diff changeset
98
363cba9482db Add ValueUtil#asRegisterValue.
Josef Eisl <josef.eisl@jku.at>
parents: 22489
diff changeset
99 public static RegisterValue asRegisterValue(Value value) {
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
100 assert value != null;
22506
363cba9482db Add ValueUtil#asRegisterValue.
Josef Eisl <josef.eisl@jku.at>
parents: 22489
diff changeset
101 return (RegisterValue) value;
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
102 }
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
103
22533
df053711614b Remove Value.getKind().
Roland Schatz <roland.schatz@oracle.com>
parents: 22517
diff changeset
104 public static Register asRegister(Value value, PlatformKind kind) {
df053711614b Remove Value.getKind().
Roland Schatz <roland.schatz@oracle.com>
parents: 22517
diff changeset
105 if (value.getPlatformKind() != kind) {
df053711614b Remove Value.getKind().
Roland Schatz <roland.schatz@oracle.com>
parents: 22517
diff changeset
106 throw new InternalError("needed: " + kind + " got: " + value.getPlatformKind());
8995
585cc62fcdc5 PTX enhancements - arithmetic, control, float, integer math, control and basic switch
Morris Meyer <morris.meyer@oracle.com>
parents: 8169
diff changeset
107 } else {
585cc62fcdc5 PTX enhancements - arithmetic, control, float, integer math, control and basic switch
Morris Meyer <morris.meyer@oracle.com>
parents: 8169
diff changeset
108 return asRegister(value);
585cc62fcdc5 PTX enhancements - arithmetic, control, float, integer math, control and basic switch
Morris Meyer <morris.meyer@oracle.com>
parents: 8169
diff changeset
109 }
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
110 }
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
111 }