Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.code/src/jdk/vm/ci/code/ValueUtil.java @ 22780:b4ff1a18d19c
Move data fields from CompiledCode to HotSpotCompiledCode
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Tue, 19 Jan 2016 17:36:21 -0800 |
parents | f48b657b550d |
children | 1d4ce2d19e52 |
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 |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22533
diff
changeset
|
25 import java.util.ArrayList; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22533
diff
changeset
|
26 import java.util.List; |
13212
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
27 |
22672
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.AllocatableValue; |
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.JavaConstant; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22580
diff
changeset
|
30 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
|
31 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
|
32 import jdk.vm.ci.meta.Value; |
22054 | 33 |
6329
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5552
diff
changeset
|
34 /** |
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5552
diff
changeset
|
35 * 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
|
36 */ |
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5552
diff
changeset
|
37 public final class ValueUtil { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
38 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
39 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
|
40 assert value != null; |
19699
50b6f616b3c7
Use ILLEGAL.equals(value) in ValueUtil.isIllegal
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18430
diff
changeset
|
41 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
|
42 } |
9e0c1b4cfef5
Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff
changeset
|
43 |
22478
822922922f3c
Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
44 public static boolean isIllegalJavaValue(JavaValue value) { |
822922922f3c
Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
45 assert value != null; |
822922922f3c
Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
46 return Value.ILLEGAL.equals(value); |
822922922f3c
Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
47 } |
822922922f3c
Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
48 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
49 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
|
50 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
|
51 } |
9e0c1b4cfef5
Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff
changeset
|
52 |
22478
822922922f3c
Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
53 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
|
54 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
|
55 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
|
56 } |
9e0c1b4cfef5
Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff
changeset
|
57 |
22478
822922922f3c
Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
58 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
|
59 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
|
60 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
|
61 } |
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
|
62 |
22478
822922922f3c
Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
63 public static boolean isConstantJavaValue(JavaValue value) { |
822922922f3c
Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
64 assert value != null; |
822922922f3c
Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
65 return value instanceof JavaConstant; |
822922922f3c
Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
66 } |
822922922f3c
Explicitly store slot kinds in DebugInfo.
Roland Schatz <roland.schatz@oracle.com>
parents:
22054
diff
changeset
|
67 |
22580
6a7f2f656ed9
Add asConstantJavaValue method to ValueUtil.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
68 public static JavaConstant asConstantJavaValue(JavaValue value) { |
6a7f2f656ed9
Add asConstantJavaValue method to ValueUtil.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
69 assert value != null; |
6a7f2f656ed9
Add asConstantJavaValue method to ValueUtil.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
70 return (JavaConstant) value; |
6a7f2f656ed9
Add asConstantJavaValue method to ValueUtil.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
71 } |
6a7f2f656ed9
Add asConstantJavaValue method to ValueUtil.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
72 |
7907
ea1c2bed2bfa
Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents:
7816
diff
changeset
|
73 public static boolean isAllocatableValue(Value value) { |
ea1c2bed2bfa
Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents:
7816
diff
changeset
|
74 assert value != null; |
ea1c2bed2bfa
Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents:
7816
diff
changeset
|
75 return value instanceof AllocatableValue; |
ea1c2bed2bfa
Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents:
7816
diff
changeset
|
76 } |
ea1c2bed2bfa
Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents:
7816
diff
changeset
|
77 |
ea1c2bed2bfa
Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents:
7816
diff
changeset
|
78 public static AllocatableValue asAllocatableValue(Value value) { |
ea1c2bed2bfa
Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents:
7816
diff
changeset
|
79 assert value != null; |
ea1c2bed2bfa
Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents:
7816
diff
changeset
|
80 return (AllocatableValue) value; |
ea1c2bed2bfa
Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents:
7816
diff
changeset
|
81 } |
ea1c2bed2bfa
Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents:
7816
diff
changeset
|
82 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
83 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
|
84 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
|
85 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
|
86 } |
9e0c1b4cfef5
Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff
changeset
|
87 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
88 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
|
89 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
|
90 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
|
91 } |
9e0c1b4cfef5
Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff
changeset
|
92 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
93 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
|
94 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
|
95 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
|
96 } |
9e0c1b4cfef5
Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff
changeset
|
97 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
98 public static Register asRegister(Value value) { |
22506
363cba9482db
Add ValueUtil#asRegisterValue.
Josef Eisl <josef.eisl@jku.at>
parents:
22489
diff
changeset
|
99 return asRegisterValue(value).getRegister(); |
363cba9482db
Add ValueUtil#asRegisterValue.
Josef Eisl <josef.eisl@jku.at>
parents:
22489
diff
changeset
|
100 } |
363cba9482db
Add ValueUtil#asRegisterValue.
Josef Eisl <josef.eisl@jku.at>
parents:
22489
diff
changeset
|
101 |
363cba9482db
Add ValueUtil#asRegisterValue.
Josef Eisl <josef.eisl@jku.at>
parents:
22489
diff
changeset
|
102 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
|
103 assert value != null; |
22506
363cba9482db
Add ValueUtil#asRegisterValue.
Josef Eisl <josef.eisl@jku.at>
parents:
22489
diff
changeset
|
104 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
|
105 } |
9e0c1b4cfef5
Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff
changeset
|
106 |
22533
df053711614b
Remove Value.getKind().
Roland Schatz <roland.schatz@oracle.com>
parents:
22517
diff
changeset
|
107 public static Register asRegister(Value value, PlatformKind kind) { |
df053711614b
Remove Value.getKind().
Roland Schatz <roland.schatz@oracle.com>
parents:
22517
diff
changeset
|
108 if (value.getPlatformKind() != kind) { |
df053711614b
Remove Value.getKind().
Roland Schatz <roland.schatz@oracle.com>
parents:
22517
diff
changeset
|
109 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
|
110 } else { |
585cc62fcdc5
PTX enhancements - arithmetic, control, float, integer math, control and basic switch
Morris Meyer <morris.meyer@oracle.com>
parents:
8169
diff
changeset
|
111 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
|
112 } |
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
|
113 } |
9e0c1b4cfef5
Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff
changeset
|
114 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
115 public static boolean sameRegister(Value v1, Value v2) { |
9791
e92fdf3e1558
Register: replace usages of object identity with equals()
Bernhard Urban <bernhard.urban@jku.at>
parents:
9638
diff
changeset
|
116 return isRegister(v1) && isRegister(v2) && asRegister(v1).equals(asRegister(v2)); |
4323
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4314
diff
changeset
|
117 } |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4314
diff
changeset
|
118 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
119 public static boolean sameRegister(Value v1, Value v2, Value v3) { |
4323
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4314
diff
changeset
|
120 return sameRegister(v1, v2) && sameRegister(v1, v3); |
4254
1cf920630944
Canonicalize parameter lists and names
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4245
diff
changeset
|
121 } |
1cf920630944
Canonicalize parameter lists and names
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4245
diff
changeset
|
122 |
13212
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
123 /** |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
124 * Checks if all the provided values are different physical registers. The parameters can be |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
125 * either {@link Register registers}, {@link Value values} or arrays of them. All values that |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
126 * are not {@link RegisterValue registers} are ignored. |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
127 */ |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
128 public static boolean differentRegisters(Object... values) { |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
129 List<Register> registers = collectRegisters(values, new ArrayList<Register>()); |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
130 for (int i = 1; i < registers.size(); i++) { |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
131 Register r1 = registers.get(i); |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
132 for (int j = 0; j < i; j++) { |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
133 Register r2 = registers.get(j); |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
134 if (r1.equals(r2)) { |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
135 return false; |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
136 } |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
137 } |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
138 } |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
139 return true; |
4323
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4314
diff
changeset
|
140 } |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4314
diff
changeset
|
141 |
13212
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
142 private static List<Register> collectRegisters(Object[] values, List<Register> registers) { |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
143 for (Object o : values) { |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
144 if (o instanceof Register) { |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
145 registers.add((Register) o); |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
146 } else if (o instanceof Value) { |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
147 if (isRegister((Value) o)) { |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
148 registers.add(asRegister((Value) o)); |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
149 } |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
150 } else if (o instanceof Object[]) { |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
151 collectRegisters((Object[]) o, registers); |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
152 } else { |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
153 throw new IllegalArgumentException("Not a Register or Value: " + o); |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
154 } |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
155 } |
eb03a7335eb0
Use fixed instead of virtual register for target in far foreign call, since the register allocator does not support virtual registers to be used at call sites.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9791
diff
changeset
|
156 return registers; |
4254
1cf920630944
Canonicalize parameter lists and names
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4245
diff
changeset
|
157 } |
22517
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
158 |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
159 /** |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
160 * Subtract sets of registers (x - y). |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
161 * |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
162 * @param x a set of register to subtract from. |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
163 * @param y a set of registers to subtract. |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
164 * @return resulting set of registers (x - y). |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
165 */ |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
166 public static Value[] subtractRegisters(Value[] x, Value[] y) { |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
167 ArrayList<Value> result = new ArrayList<>(x.length); |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
168 for (Value i : x) { |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
169 boolean append = true; |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
170 for (Value j : y) { |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
171 if (ValueUtil.sameRegister(i, j)) { |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
172 append = false; |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
173 break; |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
174 } |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
175 } |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
176 if (append) { |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
177 result.add(i); |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
178 } |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
179 } |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
180 Value[] resultArray = new Value[result.size()]; |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
181 return result.toArray(resultArray); |
0915f5bfdfaa
Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22506
diff
changeset
|
182 } |
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
|
183 } |