Mercurial > hg > truffle
annotate graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/ValueUtil.java @ 21743:b54b13157d4b
removed BytecodeDisassemblerProvider
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 05 Jun 2015 10:50:00 +0200 |
parents | f5b549811bac |
children |
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:
19692
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:
19692
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:
19692
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:
19692
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:
19692
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 |
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; |
19692
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 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
41 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
|
42 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
|
43 } |
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 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
45 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
|
46 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
|
47 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
|
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 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
50 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
|
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 (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
|
53 } |
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 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
55 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
|
56 assert value != null; |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
16319
diff
changeset
|
57 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
|
58 } |
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 |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
16319
diff
changeset
|
60 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
|
61 assert value != null; |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
16319
diff
changeset
|
62 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
|
63 } |
75c620f90ab9
Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4233
diff
changeset
|
64 |
7907
ea1c2bed2bfa
Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents:
7816
diff
changeset
|
65 public static boolean isAllocatableValue(Value value) { |
ea1c2bed2bfa
Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents:
7816
diff
changeset
|
66 assert value != null; |
ea1c2bed2bfa
Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents:
7816
diff
changeset
|
67 return value instanceof AllocatableValue; |
ea1c2bed2bfa
Common superclass for RegisterValue, StackSlot and Variable.
Roland Schatz <roland.schatz@oracle.com>
parents:
7816
diff
changeset
|
68 } |
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 public static AllocatableValue asAllocatableValue(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 (AllocatableValue) value; |
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 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
75 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
|
76 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
|
77 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
|
78 } |
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 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
80 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
|
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 (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
|
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 |
18430
9c590632d079
LIRVerifier: allow StackSlotValues for OperandFlag.STACK.
Josef Eisl <josef.eisl@jku.at>
parents:
18425
diff
changeset
|
85 public static boolean isStackSlotValue(Value value) { |
9c590632d079
LIRVerifier: allow StackSlotValues for OperandFlag.STACK.
Josef Eisl <josef.eisl@jku.at>
parents:
18425
diff
changeset
|
86 assert value != null; |
9c590632d079
LIRVerifier: allow StackSlotValues for OperandFlag.STACK.
Josef Eisl <josef.eisl@jku.at>
parents:
18425
diff
changeset
|
87 return value instanceof StackSlotValue; |
9c590632d079
LIRVerifier: allow StackSlotValues for OperandFlag.STACK.
Josef Eisl <josef.eisl@jku.at>
parents:
18425
diff
changeset
|
88 } |
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 public static StackSlotValue asStackSlotValue(Value value) { |
9c590632d079
LIRVerifier: allow StackSlotValues for OperandFlag.STACK.
Josef Eisl <josef.eisl@jku.at>
parents:
18425
diff
changeset
|
91 assert value != null; |
9c590632d079
LIRVerifier: allow StackSlotValues for OperandFlag.STACK.
Josef Eisl <josef.eisl@jku.at>
parents:
18425
diff
changeset
|
92 return (StackSlotValue) value; |
9c590632d079
LIRVerifier: allow StackSlotValues for OperandFlag.STACK.
Josef Eisl <josef.eisl@jku.at>
parents:
18425
diff
changeset
|
93 } |
9c590632d079
LIRVerifier: allow StackSlotValues for OperandFlag.STACK.
Josef Eisl <josef.eisl@jku.at>
parents:
18425
diff
changeset
|
94 |
18425
b856446ff7e0
Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents:
18187
diff
changeset
|
95 public static boolean isVirtualStackSlot(Value value) { |
b856446ff7e0
Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents:
18187
diff
changeset
|
96 assert value != null; |
b856446ff7e0
Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents:
18187
diff
changeset
|
97 return value instanceof VirtualStackSlot; |
b856446ff7e0
Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents:
18187
diff
changeset
|
98 } |
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 public static VirtualStackSlot asVirtualStackSlot(Value value) { |
b856446ff7e0
Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents:
18187
diff
changeset
|
101 assert value != null; |
b856446ff7e0
Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents:
18187
diff
changeset
|
102 return (VirtualStackSlot) value; |
b856446ff7e0
Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents:
18187
diff
changeset
|
103 } |
b856446ff7e0
Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents:
18187
diff
changeset
|
104 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
105 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
|
106 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
|
107 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
|
108 } |
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 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
110 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
|
111 assert value != null; |
5552
69a8969dbf40
Reduce public fields in api.code project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5547
diff
changeset
|
112 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
|
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 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
115 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
|
116 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
|
117 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
|
118 } else { |
585cc62fcdc5
PTX enhancements - arithmetic, control, float, integer math, control and basic switch
Morris Meyer <morris.meyer@oracle.com>
parents:
8169
diff
changeset
|
119 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
|
120 } |
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
|
121 } |
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 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
123 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
|
124 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
|
125 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
|
126 } else { |
585cc62fcdc5
PTX enhancements - arithmetic, control, float, integer math, control and basic switch
Morris Meyer <morris.meyer@oracle.com>
parents:
8169
diff
changeset
|
127 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
|
128 } |
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
|
129 } |
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 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
131 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
|
132 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
|
133 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
|
134 } |
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 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
136 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
|
137 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
|
138 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
|
139 } |
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 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
141 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
|
142 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
|
143 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
|
144 } |
4254
1cf920630944
Canonicalize parameter lists and names
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4245
diff
changeset
|
145 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
146 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
|
147 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
|
148 } |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4314
diff
changeset
|
149 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
150 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
|
151 return sameRegister(v1, v2) && sameRegister(v1, v3); |
4254
1cf920630944
Canonicalize parameter lists and names
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4245
diff
changeset
|
152 } |
1cf920630944
Canonicalize parameter lists and names
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4245
diff
changeset
|
153 |
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
|
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 * 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
|
156 * 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
|
157 * 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
|
158 */ |
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 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
|
160 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
|
161 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
|
162 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
|
163 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
|
164 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
|
165 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
|
166 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
|
167 } |
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 return true; |
4323
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4314
diff
changeset
|
171 } |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4314
diff
changeset
|
172 |
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
|
173 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
|
174 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
|
175 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
|
176 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
|
177 } 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
|
178 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
|
179 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
|
180 } |
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 } 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
|
182 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
|
183 } 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
|
184 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
|
185 } |
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 return registers; |
4254
1cf920630944
Canonicalize parameter lists and names
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4245
diff
changeset
|
188 } |
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
|
189 } |