annotate graal/com.oracle.graal.lir/src/com/oracle/graal/lir/CompositeValue.java @ 19529:8fc336a04d77

Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Fri, 20 Feb 2015 22:22:55 +0100
parents d216de21bfe8
children a69a7c0e0ccc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8165
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
1 /*
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 11486
diff changeset
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
8165
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
4 *
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
8 *
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
13 * accompanied this code).
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
14 *
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
18 *
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
21 * questions.
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
22 */
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.lir;
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
24
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
25 import java.lang.annotation.*;
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
26
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
27 import com.oracle.graal.api.meta.*;
16739
6a78b0f8ad74 Make CompositeValue Cloneable.
Josef Eisl <josef.eisl@jku.at>
parents: 16289
diff changeset
28 import com.oracle.graal.compiler.common.*;
11486
5d5bfb75dae0 added metrics for total number of Nodes, LIRInstructions and CompositeValues created (GRAAL-448)
Doug Simon <doug.simon@oracle.com>
parents: 9640
diff changeset
29 import com.oracle.graal.debug.*;
8165
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
30 import com.oracle.graal.lir.LIRInstruction.OperandFlag;
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
31 import com.oracle.graal.lir.LIRInstruction.OperandMode;
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
32
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
33 /**
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
34 * Base class to represent values that need to be stored in more than one register.
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
35 */
18319
56cc1a799a60 (re)converted Value to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18186
diff changeset
36 public abstract class CompositeValue extends AbstractValue implements Cloneable {
8165
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
37
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
38 private static final long serialVersionUID = -169180052684126180L;
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
39
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
40 @Retention(RetentionPolicy.RUNTIME)
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
41 @Target(ElementType.FIELD)
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
42 public static @interface Component {
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
43
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
44 OperandFlag[] value() default OperandFlag.REG;
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
45 }
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
46
19470
d216de21bfe8 Fix unchecked warnings in NodeClass.
Roland Schatz <roland.schatz@oracle.com>
parents: 18319
diff changeset
47 private final CompositeValueClass<?> valueClass;
8165
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
48
11486
5d5bfb75dae0 added metrics for total number of Nodes, LIRInstructions and CompositeValues created (GRAAL-448)
Doug Simon <doug.simon@oracle.com>
parents: 9640
diff changeset
49 private static final DebugMetric COMPOSITE_VALUE_COUNT = Debug.metric("CompositeValues");
5d5bfb75dae0 added metrics for total number of Nodes, LIRInstructions and CompositeValues created (GRAAL-448)
Doug Simon <doug.simon@oracle.com>
parents: 9640
diff changeset
50
19529
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19470
diff changeset
51 public CompositeValue(CompositeValueClass<? extends CompositeValue> c, LIRKind kind) {
8165
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
52 super(kind);
11486
5d5bfb75dae0 added metrics for total number of Nodes, LIRInstructions and CompositeValues created (GRAAL-448)
Doug Simon <doug.simon@oracle.com>
parents: 9640
diff changeset
53 COMPOSITE_VALUE_COUNT.increment();
19529
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19470
diff changeset
54 valueClass = c;
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19470
diff changeset
55 assert c.getClazz() == this.getClass();
8165
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
56 }
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
57
17287
0f8b1fb632df Remove InstructionValueProcedureBase (superseded by InstructionValueProcedure).
Josef Eisl <josef.eisl@jku.at>
parents: 16799
diff changeset
58 final CompositeValue forEachComponent(LIRInstruction inst, OperandMode mode, InstructionValueProcedure proc) {
16740
bc1b601dabc9 Create LIRIntrospection.forEachComponent (copy of LIRIntrospection.forEach).
Josef Eisl <josef.eisl@jku.at>
parents: 16739
diff changeset
59 return valueClass.forEachComponent(inst, this, mode, proc);
16138
f315b1c0a590 Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents: 16094
diff changeset
60 }
f315b1c0a590 Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents: 16094
diff changeset
61
16799
dc9f55fbbf38 Restrict access to internal forEach* in LIRInstructionClass and friends.
Josef Eisl <josef.eisl@jku.at>
parents: 16797
diff changeset
62 final void forEachComponent(LIRInstruction inst, OperandMode mode, ValuePositionProcedure proc, ValuePosition outerPosition) {
16289
b2b362cc1a9f Rename ValuePosition.superPosition to outerPosition.
Josef Eisl <josef.eisl@jku.at>
parents: 16283
diff changeset
63 valueClass.forEachComponent(inst, this, mode, proc, outerPosition);
16281
14e56cef5be8 Start to make ValuePosition aware of CompositeValues.
Josef Eisl <josef.eisl@jku.at>
parents: 16214
diff changeset
64 }
14e56cef5be8 Start to make ValuePosition aware of CompositeValues.
Josef Eisl <josef.eisl@jku.at>
parents: 16214
diff changeset
65
8165
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
66 @Override
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
67 public String toString() {
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
68 return valueClass.toString(this);
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
69 }
9631
3c9aeef2702c Value: provide proper `hashCode()' and `equals()' implementations
Bernhard Urban <bernhard.urban@jku.at>
parents: 9422
diff changeset
70
3c9aeef2702c Value: provide proper `hashCode()' and `equals()' implementations
Bernhard Urban <bernhard.urban@jku.at>
parents: 9422
diff changeset
71 @Override
3c9aeef2702c Value: provide proper `hashCode()' and `equals()' implementations
Bernhard Urban <bernhard.urban@jku.at>
parents: 9422
diff changeset
72 public int hashCode() {
9640
65d7696fb58a Value: tidy up generated `hashCode()' and `equals()' methods a bit
Bernhard Urban <bernhard.urban@jku.at>
parents: 9631
diff changeset
73 return 53 * super.hashCode() + valueClass.hashCode();
9631
3c9aeef2702c Value: provide proper `hashCode()' and `equals()' implementations
Bernhard Urban <bernhard.urban@jku.at>
parents: 9422
diff changeset
74 }
3c9aeef2702c Value: provide proper `hashCode()' and `equals()' implementations
Bernhard Urban <bernhard.urban@jku.at>
parents: 9422
diff changeset
75
3c9aeef2702c Value: provide proper `hashCode()' and `equals()' implementations
Bernhard Urban <bernhard.urban@jku.at>
parents: 9422
diff changeset
76 @Override
3c9aeef2702c Value: provide proper `hashCode()' and `equals()' implementations
Bernhard Urban <bernhard.urban@jku.at>
parents: 9422
diff changeset
77 public boolean equals(Object obj) {
9640
65d7696fb58a Value: tidy up generated `hashCode()' and `equals()' methods a bit
Bernhard Urban <bernhard.urban@jku.at>
parents: 9631
diff changeset
78 if (obj instanceof CompositeValue) {
65d7696fb58a Value: tidy up generated `hashCode()' and `equals()' methods a bit
Bernhard Urban <bernhard.urban@jku.at>
parents: 9631
diff changeset
79 CompositeValue other = (CompositeValue) obj;
65d7696fb58a Value: tidy up generated `hashCode()' and `equals()' methods a bit
Bernhard Urban <bernhard.urban@jku.at>
parents: 9631
diff changeset
80 return super.equals(other) && valueClass.equals(other.valueClass);
9631
3c9aeef2702c Value: provide proper `hashCode()' and `equals()' implementations
Bernhard Urban <bernhard.urban@jku.at>
parents: 9422
diff changeset
81 }
9640
65d7696fb58a Value: tidy up generated `hashCode()' and `equals()' methods a bit
Bernhard Urban <bernhard.urban@jku.at>
parents: 9631
diff changeset
82 return false;
9631
3c9aeef2702c Value: provide proper `hashCode()' and `equals()' implementations
Bernhard Urban <bernhard.urban@jku.at>
parents: 9422
diff changeset
83 }
16281
14e56cef5be8 Start to make ValuePosition aware of CompositeValues.
Josef Eisl <josef.eisl@jku.at>
parents: 16214
diff changeset
84
19470
d216de21bfe8 Fix unchecked warnings in NodeClass.
Roland Schatz <roland.schatz@oracle.com>
parents: 18319
diff changeset
85 CompositeValueClass<?> getValueClass() {
16281
14e56cef5be8 Start to make ValuePosition aware of CompositeValues.
Josef Eisl <josef.eisl@jku.at>
parents: 16214
diff changeset
86 return valueClass;
14e56cef5be8 Start to make ValuePosition aware of CompositeValues.
Josef Eisl <josef.eisl@jku.at>
parents: 16214
diff changeset
87 }
14e56cef5be8 Start to make ValuePosition aware of CompositeValues.
Josef Eisl <josef.eisl@jku.at>
parents: 16214
diff changeset
88
16739
6a78b0f8ad74 Make CompositeValue Cloneable.
Josef Eisl <josef.eisl@jku.at>
parents: 16289
diff changeset
89 @Override
6a78b0f8ad74 Make CompositeValue Cloneable.
Josef Eisl <josef.eisl@jku.at>
parents: 16289
diff changeset
90 public final CompositeValue clone() {
16744
3507ad1b0c44 Clone value arrays in CompositeValue.clone().
Josef Eisl <josef.eisl@jku.at>
parents: 16740
diff changeset
91 CompositeValue compositeValue = null;
16739
6a78b0f8ad74 Make CompositeValue Cloneable.
Josef Eisl <josef.eisl@jku.at>
parents: 16289
diff changeset
92 try {
16744
3507ad1b0c44 Clone value arrays in CompositeValue.clone().
Josef Eisl <josef.eisl@jku.at>
parents: 16740
diff changeset
93 compositeValue = (CompositeValue) super.clone();
16739
6a78b0f8ad74 Make CompositeValue Cloneable.
Josef Eisl <josef.eisl@jku.at>
parents: 16289
diff changeset
94 } catch (CloneNotSupportedException e) {
6a78b0f8ad74 Make CompositeValue Cloneable.
Josef Eisl <josef.eisl@jku.at>
parents: 16289
diff changeset
95 throw new GraalInternalError(e);
6a78b0f8ad74 Make CompositeValue Cloneable.
Josef Eisl <josef.eisl@jku.at>
parents: 16289
diff changeset
96 }
16744
3507ad1b0c44 Clone value arrays in CompositeValue.clone().
Josef Eisl <josef.eisl@jku.at>
parents: 16740
diff changeset
97
3507ad1b0c44 Clone value arrays in CompositeValue.clone().
Josef Eisl <josef.eisl@jku.at>
parents: 16740
diff changeset
98 // copy value arrays
3507ad1b0c44 Clone value arrays in CompositeValue.clone().
Josef Eisl <josef.eisl@jku.at>
parents: 16740
diff changeset
99 getValueClass().copyValueArrays(compositeValue);
3507ad1b0c44 Clone value arrays in CompositeValue.clone().
Josef Eisl <josef.eisl@jku.at>
parents: 16740
diff changeset
100
3507ad1b0c44 Clone value arrays in CompositeValue.clone().
Josef Eisl <josef.eisl@jku.at>
parents: 16740
diff changeset
101 return compositeValue;
16739
6a78b0f8ad74 Make CompositeValue Cloneable.
Josef Eisl <josef.eisl@jku.at>
parents: 16289
diff changeset
102 }
6a78b0f8ad74 Make CompositeValue Cloneable.
Josef Eisl <josef.eisl@jku.at>
parents: 16289
diff changeset
103
8165
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
104 }