annotate graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/ValueUtil.java @ 21556:48c1ebd24120

renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Wed, 27 May 2015 00:36:16 +0200
parents graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/ValueUtil.java@50b6f616b3c7
children f5b549811bac
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 /*
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 16319
diff changeset
2 * Copyright (c) 2012, 2014, 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 */
21556
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 19699
diff changeset
23 package com.oracle.jvmci.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
21556
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 19699
diff changeset
25 import com.oracle.jvmci.meta.Kind;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 19699
diff changeset
26 import com.oracle.jvmci.meta.Value;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 19699
diff changeset
27 import com.oracle.jvmci.meta.AllocatableValue;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 19699
diff changeset
28 import com.oracle.jvmci.meta.JavaConstant;
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
29 import java.util.*;
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
30
5502
13aee5aba8cc Moved RiConstant to cri.ri package.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5501
diff changeset
31
6329
92bc58dc5b5e More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5552
diff changeset
32 /**
92bc58dc5b5e More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5552
diff changeset
33 * 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
34 */
92bc58dc5b5e More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5552
diff changeset
35 public final class ValueUtil {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
36
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
37 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
38 assert value != null;
19699
50b6f616b3c7 Use ILLEGAL.equals(value) in ValueUtil.isIllegal
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18430
diff changeset
39 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
40 }
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
41
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
42 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
43 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
44 }
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
45
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
46 public static boolean isVirtualObject(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 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
48 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
49 }
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
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
51 public static VirtualObject asVirtualObject(Value 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
52 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
53 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
54 }
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
55
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
56 public static boolean isConstant(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
57 assert value != null;
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 16319
diff changeset
58 return value instanceof JavaConstant;
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 }
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
60
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 16319
diff changeset
61 public static JavaConstant asConstant(Value value) {
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4233
diff changeset
62 assert value != null;
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 16319
diff changeset
63 return (JavaConstant) value;
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4233
diff changeset
64 }
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4233
diff changeset
65
7907
ea1c2bed2bfa Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents: 7816
diff changeset
66 public static boolean isAllocatableValue(Value value) {
ea1c2bed2bfa Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents: 7816
diff changeset
67 assert value != null;
ea1c2bed2bfa Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents: 7816
diff changeset
68 return value instanceof AllocatableValue;
ea1c2bed2bfa Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents: 7816
diff changeset
69 }
ea1c2bed2bfa Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents: 7816
diff changeset
70
ea1c2bed2bfa Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents: 7816
diff changeset
71 public static AllocatableValue asAllocatableValue(Value value) {
ea1c2bed2bfa Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents: 7816
diff changeset
72 assert value != null;
ea1c2bed2bfa Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents: 7816
diff changeset
73 return (AllocatableValue) value;
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
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
76 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
77 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
78 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
79 }
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
80
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
81 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
82 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
83 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
84 }
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
85
18430
9c590632d079 LIRVerifier: allow StackSlotValues for OperandFlag.STACK.
Josef Eisl <josef.eisl@jku.at>
parents: 18425
diff changeset
86 public static boolean isStackSlotValue(Value value) {
9c590632d079 LIRVerifier: allow StackSlotValues for OperandFlag.STACK.
Josef Eisl <josef.eisl@jku.at>
parents: 18425
diff changeset
87 assert value != null;
9c590632d079 LIRVerifier: allow StackSlotValues for OperandFlag.STACK.
Josef Eisl <josef.eisl@jku.at>
parents: 18425
diff changeset
88 return value instanceof StackSlotValue;
9c590632d079 LIRVerifier: allow StackSlotValues for OperandFlag.STACK.
Josef Eisl <josef.eisl@jku.at>
parents: 18425
diff changeset
89 }
9c590632d079 LIRVerifier: allow StackSlotValues for OperandFlag.STACK.
Josef Eisl <josef.eisl@jku.at>
parents: 18425
diff changeset
90
9c590632d079 LIRVerifier: allow StackSlotValues for OperandFlag.STACK.
Josef Eisl <josef.eisl@jku.at>
parents: 18425
diff changeset
91 public static StackSlotValue asStackSlotValue(Value value) {
9c590632d079 LIRVerifier: allow StackSlotValues for OperandFlag.STACK.
Josef Eisl <josef.eisl@jku.at>
parents: 18425
diff changeset
92 assert value != null;
9c590632d079 LIRVerifier: allow StackSlotValues for OperandFlag.STACK.
Josef Eisl <josef.eisl@jku.at>
parents: 18425
diff changeset
93 return (StackSlotValue) value;
9c590632d079 LIRVerifier: allow StackSlotValues for OperandFlag.STACK.
Josef Eisl <josef.eisl@jku.at>
parents: 18425
diff changeset
94 }
9c590632d079 LIRVerifier: allow StackSlotValues for OperandFlag.STACK.
Josef Eisl <josef.eisl@jku.at>
parents: 18425
diff changeset
95
18425
b856446ff7e0 Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents: 18187
diff changeset
96 public static boolean isVirtualStackSlot(Value value) {
b856446ff7e0 Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents: 18187
diff changeset
97 assert value != null;
b856446ff7e0 Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents: 18187
diff changeset
98 return value instanceof VirtualStackSlot;
b856446ff7e0 Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents: 18187
diff changeset
99 }
b856446ff7e0 Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents: 18187
diff changeset
100
b856446ff7e0 Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents: 18187
diff changeset
101 public static VirtualStackSlot asVirtualStackSlot(Value value) {
b856446ff7e0 Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents: 18187
diff changeset
102 assert value != null;
b856446ff7e0 Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents: 18187
diff changeset
103 return (VirtualStackSlot) value;
b856446ff7e0 Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents: 18187
diff changeset
104 }
b856446ff7e0 Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents: 18187
diff changeset
105
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
106 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
107 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
108 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
109 }
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
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
111 public static Register asRegister(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
112 assert value != null;
5552
69a8969dbf40 Reduce public fields in api.code project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5547
diff changeset
113 return ((RegisterValue) value).getRegister();
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
114 }
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
115
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
116 public static Register asIntReg(Value value) {
14942
13a8c3454e76 Make type assertions in backend less strict.
Roland Schatz <roland.schatz@oracle.com>
parents: 13212
diff changeset
117 if (value.getKind().getStackKind() != Kind.Int) {
8995
585cc62fcdc5 PTX enhancements - arithmetic, control, float, integer math, control and basic switch
Morris Meyer <morris.meyer@oracle.com>
parents: 8169
diff changeset
118 throw new InternalError("needed Int got: " + value.getKind());
585cc62fcdc5 PTX enhancements - arithmetic, control, float, integer math, control and basic switch
Morris Meyer <morris.meyer@oracle.com>
parents: 8169
diff changeset
119 } else {
585cc62fcdc5 PTX enhancements - arithmetic, control, float, integer math, control and basic switch
Morris Meyer <morris.meyer@oracle.com>
parents: 8169
diff changeset
120 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
121 }
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
122 }
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
123
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
124 public static Register asLongReg(Value value) {
8995
585cc62fcdc5 PTX enhancements - arithmetic, control, float, integer math, control and basic switch
Morris Meyer <morris.meyer@oracle.com>
parents: 8169
diff changeset
125 if (value.getKind() != Kind.Long) {
585cc62fcdc5 PTX enhancements - arithmetic, control, float, integer math, control and basic switch
Morris Meyer <morris.meyer@oracle.com>
parents: 8169
diff changeset
126 throw new InternalError("needed Long got: " + value.getKind());
585cc62fcdc5 PTX enhancements - arithmetic, control, float, integer math, control and basic switch
Morris Meyer <morris.meyer@oracle.com>
parents: 8169
diff changeset
127 } else {
585cc62fcdc5 PTX enhancements - arithmetic, control, float, integer math, control and basic switch
Morris Meyer <morris.meyer@oracle.com>
parents: 8169
diff changeset
128 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
129 }
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
130 }
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
131
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
132 public static Register asObjectReg(Value value) {
16319
a4bd33d52985 Fixing tests with number conversions, float and double handling. Introducing new VIS3 instructions. Adding testcases.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 14942
diff changeset
133 assert value.getKind() == Kind.Object : value.getKind();
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
134 return asRegister(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
135 }
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
136
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
137 public static Register asFloatReg(Value value) {
16319
a4bd33d52985 Fixing tests with number conversions, float and double handling. Introducing new VIS3 instructions. Adding testcases.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 14942
diff changeset
138 assert value.getKind() == Kind.Float : value.getKind();
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
139 return asRegister(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
140 }
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
diff changeset
141
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
142 public static Register asDoubleReg(Value value) {
16319
a4bd33d52985 Fixing tests with number conversions, float and double handling. Introducing new VIS3 instructions. Adding testcases.
Stefan Anzinger <stefan.anzinger@gmail.com>
parents: 14942
diff changeset
143 assert value.getKind() == Kind.Double : value.getKind();
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
144 return asRegister(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
145 }
4254
1cf920630944 Canonicalize parameter lists and names
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4245
diff changeset
146
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
147 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
148 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
149 }
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
150
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
151 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
152 return sameRegister(v1, v2) && sameRegister(v1, v3);
4254
1cf920630944 Canonicalize parameter lists and names
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4245
diff changeset
153 }
1cf920630944 Canonicalize parameter lists and names
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4245
diff changeset
154
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
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 * 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
157 * 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
158 * 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
159 */
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
160 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
161 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
162 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
163 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
164 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
165 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
166 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
167 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
168 }
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
169 }
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
170 }
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
171 return true;
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
172 }
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
173
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
174 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
175 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
176 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
177 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
178 } 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
179 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
180 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
181 }
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
182 } 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
183 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
184 } 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
185 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
186 }
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
187 }
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
188 return registers;
4254
1cf920630944 Canonicalize parameter lists and names
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4245
diff changeset
189 }
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
190 }