annotate graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstructionClass.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 35481bcb5882
children 6b119b6362de
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
1 /*
8164
25fd899b979f Move reusable parts of LIRInstructionClass into base class.
Roland Schatz <roland.schatz@oracle.com>
parents: 8136
diff changeset
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
4 *
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
8 *
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
13 * accompanied this code).
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
14 *
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
18 *
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
21 * questions.
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
22 */
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.lir;
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 5858
diff changeset
24
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
25 import java.lang.reflect.*;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
26 import java.util.*;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
27
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
28 import com.oracle.graal.api.code.*;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
29 import com.oracle.graal.api.meta.*;
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 13127
diff changeset
30 import com.oracle.graal.compiler.common.*;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
31 import com.oracle.graal.lir.LIRInstruction.OperandFlag;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
32 import com.oracle.graal.lir.LIRInstruction.OperandMode;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
33
19470
d216de21bfe8 Fix unchecked warnings in NodeClass.
Roland Schatz <roland.schatz@oracle.com>
parents: 18261
diff changeset
34 public class LIRInstructionClass<T> extends LIRIntrospection<T> {
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
35
19529
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19528
diff changeset
36 public static final <T extends LIRInstruction> LIRInstructionClass<T> create(Class<T> c) {
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19528
diff changeset
37 return new LIRInstructionClass<>(c);
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
38 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
39
8164
25fd899b979f Move reusable parts of LIRInstructionClass into base class.
Roland Schatz <roland.schatz@oracle.com>
parents: 8136
diff changeset
40 private static final Class<LIRInstruction> INSTRUCTION_CLASS = LIRInstruction.class;
25fd899b979f Move reusable parts of LIRInstructionClass into base class.
Roland Schatz <roland.schatz@oracle.com>
parents: 8136
diff changeset
41 private static final Class<LIRFrameState> STATE_CLASS = LIRFrameState.class;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
42
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
43 private final Values uses;
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
44 private final Values alives;
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
45 private final Values temps;
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
46 private final Values defs;
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
47 private final Fields states;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
48
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
49 private String opcodeConstant;
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
50 private int opcodeIndex;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
51
19470
d216de21bfe8 Fix unchecked warnings in NodeClass.
Roland Schatz <roland.schatz@oracle.com>
parents: 18261
diff changeset
52 private LIRInstructionClass(Class<T> clazz) {
18261
d66c79acfeac refactored Fields class to make it usable for implementing custom serialization
Doug Simon <doug.simon@oracle.com>
parents: 17287
diff changeset
53 this(clazz, new FieldsScanner.DefaultCalcOffset());
13127
f42f1f5d5ce0 Allow custom field offset providers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9856
diff changeset
54 }
f42f1f5d5ce0 Allow custom field offset providers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9856
diff changeset
55
19470
d216de21bfe8 Fix unchecked warnings in NodeClass.
Roland Schatz <roland.schatz@oracle.com>
parents: 18261
diff changeset
56 public LIRInstructionClass(Class<T> clazz, FieldsScanner.CalcOffset calcOffset) {
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5796
diff changeset
57 super(clazz);
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
58 assert INSTRUCTION_CLASS.isAssignableFrom(clazz);
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
59
18261
d66c79acfeac refactored Fields class to make it usable for implementing custom serialization
Doug Simon <doug.simon@oracle.com>
parents: 17287
diff changeset
60 LIRInstructionFieldsScanner ifs = new LIRInstructionFieldsScanner(calcOffset);
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
61 ifs.scan(clazz);
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
62
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
63 uses = new Values(ifs.valueAnnotations.get(LIRInstruction.Use.class));
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
64 alives = new Values(ifs.valueAnnotations.get(LIRInstruction.Alive.class));
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
65 temps = new Values(ifs.valueAnnotations.get(LIRInstruction.Temp.class));
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
66 defs = new Values(ifs.valueAnnotations.get(LIRInstruction.Def.class));
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
67
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
68 states = new Fields(ifs.states);
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
69 data = new Fields(ifs.data);
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
70
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
71 opcodeConstant = ifs.opcodeConstant;
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
72 if (ifs.opcodeField == null) {
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
73 opcodeIndex = -1;
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
74 } else {
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
75 opcodeIndex = ifs.data.indexOf(ifs.opcodeField);
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
76 }
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
77 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
78
18261
d66c79acfeac refactored Fields class to make it usable for implementing custom serialization
Doug Simon <doug.simon@oracle.com>
parents: 17287
diff changeset
79 private static class LIRInstructionFieldsScanner extends LIRFieldsScanner {
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
80
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
81 private String opcodeConstant;
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
82
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
83 /**
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
84 * Field (if any) annotated by {@link Opcode}.
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
85 */
18261
d66c79acfeac refactored Fields class to make it usable for implementing custom serialization
Doug Simon <doug.simon@oracle.com>
parents: 17287
diff changeset
86 private FieldsScanner.FieldInfo opcodeField;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
87
18261
d66c79acfeac refactored Fields class to make it usable for implementing custom serialization
Doug Simon <doug.simon@oracle.com>
parents: 17287
diff changeset
88 public LIRInstructionFieldsScanner(FieldsScanner.CalcOffset calc) {
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5796
diff changeset
89 super(calc);
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
90
8164
25fd899b979f Move reusable parts of LIRInstructionClass into base class.
Roland Schatz <roland.schatz@oracle.com>
parents: 8136
diff changeset
91 valueAnnotations.put(LIRInstruction.Use.class, new OperandModeAnnotation());
25fd899b979f Move reusable parts of LIRInstructionClass into base class.
Roland Schatz <roland.schatz@oracle.com>
parents: 8136
diff changeset
92 valueAnnotations.put(LIRInstruction.Alive.class, new OperandModeAnnotation());
25fd899b979f Move reusable parts of LIRInstructionClass into base class.
Roland Schatz <roland.schatz@oracle.com>
parents: 8136
diff changeset
93 valueAnnotations.put(LIRInstruction.Temp.class, new OperandModeAnnotation());
25fd899b979f Move reusable parts of LIRInstructionClass into base class.
Roland Schatz <roland.schatz@oracle.com>
parents: 8136
diff changeset
94 valueAnnotations.put(LIRInstruction.Def.class, new OperandModeAnnotation());
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
95 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
96
8164
25fd899b979f Move reusable parts of LIRInstructionClass into base class.
Roland Schatz <roland.schatz@oracle.com>
parents: 8136
diff changeset
97 @Override
25fd899b979f Move reusable parts of LIRInstructionClass into base class.
Roland Schatz <roland.schatz@oracle.com>
parents: 8136
diff changeset
98 protected EnumSet<OperandFlag> getFlags(Field field) {
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
99 EnumSet<OperandFlag> result = EnumSet.noneOf(OperandFlag.class);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 5858
diff changeset
100 // Unfortunately, annotations cannot have class hierarchies or implement interfaces, so
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 5858
diff changeset
101 // we have to duplicate the code for every operand mode.
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 5858
diff changeset
102 // Unfortunately, annotations cannot have an EnumSet property, so we have to convert
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 5858
diff changeset
103 // from arrays to EnumSet manually.
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
104 if (field.isAnnotationPresent(LIRInstruction.Use.class)) {
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
105 result.addAll(Arrays.asList(field.getAnnotation(LIRInstruction.Use.class).value()));
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
106 } else if (field.isAnnotationPresent(LIRInstruction.Alive.class)) {
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
107 result.addAll(Arrays.asList(field.getAnnotation(LIRInstruction.Alive.class).value()));
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
108 } else if (field.isAnnotationPresent(LIRInstruction.Temp.class)) {
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
109 result.addAll(Arrays.asList(field.getAnnotation(LIRInstruction.Temp.class).value()));
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
110 } else if (field.isAnnotationPresent(LIRInstruction.Def.class)) {
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
111 result.addAll(Arrays.asList(field.getAnnotation(LIRInstruction.Def.class).value()));
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
112 } else {
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
113 GraalInternalError.shouldNotReachHere();
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
114 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
115 return result;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
116 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
117
15295
21663230ba88 Move FieldIntrospection to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15193
diff changeset
118 public void scan(Class<?> clazz) {
9856
fbeda9df497d implemented workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=409824
Doug Simon <doug.simon@oracle.com>
parents: 8164
diff changeset
119 if (clazz.getAnnotation(Opcode.class) != null) {
fbeda9df497d implemented workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=409824
Doug Simon <doug.simon@oracle.com>
parents: 8164
diff changeset
120 opcodeConstant = clazz.getAnnotation(Opcode.class).value();
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
121 }
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
122 opcodeField = null;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
123
19528
35481bcb5882 Remove LIRInstruction interface. Rename LIRInstructionBase to LIRInstruction.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19470
diff changeset
124 super.scan(clazz, LIRInstruction.class, false);
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
125
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
126 if (opcodeConstant == null && opcodeField == null) {
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
127 opcodeConstant = clazz.getSimpleName();
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
128 if (opcodeConstant.endsWith("Op")) {
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
129 opcodeConstant = opcodeConstant.substring(0, opcodeConstant.length() - 2);
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
130 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
131 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
132 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
133
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5796
diff changeset
134 @Override
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
135 protected void scanField(Field field, long offset) {
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
136 Class<?> type = field.getType();
8164
25fd899b979f Move reusable parts of LIRInstructionClass into base class.
Roland Schatz <roland.schatz@oracle.com>
parents: 8136
diff changeset
137 if (STATE_CLASS.isAssignableFrom(type)) {
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5796
diff changeset
138 assert getOperandModeAnnotation(field) == null : "Field must not have operand mode annotation: " + field;
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5796
diff changeset
139 assert field.getAnnotation(LIRInstruction.State.class) != null : "Field must have state annotation: " + field;
18261
d66c79acfeac refactored Fields class to make it usable for implementing custom serialization
Doug Simon <doug.simon@oracle.com>
parents: 17287
diff changeset
140 states.add(new FieldsScanner.FieldInfo(offset, field.getName(), type));
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5796
diff changeset
141 } else {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
142 super.scanField(field, offset);
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5796
diff changeset
143 }
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
144
9856
fbeda9df497d implemented workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=409824
Doug Simon <doug.simon@oracle.com>
parents: 8164
diff changeset
145 if (field.getAnnotation(Opcode.class) != null) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
146 assert opcodeConstant == null && opcodeField == null : "Can have only one Opcode definition: " + type;
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
147 assert data.get(data.size() - 1).offset == offset;
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
148 opcodeField = data.get(data.size() - 1);
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5796
diff changeset
149 }
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
150 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
151 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
152
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
153 @Override
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
154 public String toString() {
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
155 StringBuilder str = new StringBuilder();
15295
21663230ba88 Move FieldIntrospection to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15193
diff changeset
156 str.append(getClass().getSimpleName()).append(" ").append(getClazz().getSimpleName()).append(" use[");
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
157 uses.appendFields(str);
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
158 str.append("] alive[");
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
159 alives.appendFields(str);
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
160 str.append("] temp[");
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
161 temps.appendFields(str);
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
162 str.append("] def[");
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
163 defs.appendFields(str);
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
164 str.append("] state[");
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
165 states.appendFields(str);
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
166 str.append("] data[");
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
167 data.appendFields(str);
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
168 str.append("]");
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
169 return str.toString();
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
170 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
171
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
172 Values getValues(OperandMode mode) {
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
173 switch (mode) {
16277
2bcba15fa725 Introduce LIRInstructionClass.Position.
Josef Eisl <josef.eisl@jku.at>
parents: 16214
diff changeset
174 case USE:
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
175 return uses;
16277
2bcba15fa725 Introduce LIRInstructionClass.Position.
Josef Eisl <josef.eisl@jku.at>
parents: 16214
diff changeset
176 case ALIVE:
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
177 return alives;
16277
2bcba15fa725 Introduce LIRInstructionClass.Position.
Josef Eisl <josef.eisl@jku.at>
parents: 16214
diff changeset
178 case TEMP:
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
179 return temps;
16277
2bcba15fa725 Introduce LIRInstructionClass.Position.
Josef Eisl <josef.eisl@jku.at>
parents: 16214
diff changeset
180 case DEF:
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
181 return defs;
16277
2bcba15fa725 Introduce LIRInstructionClass.Position.
Josef Eisl <josef.eisl@jku.at>
parents: 16214
diff changeset
182 default:
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
183 throw GraalInternalError.shouldNotReachHere("unknown OperandMode: " + mode);
16277
2bcba15fa725 Introduce LIRInstructionClass.Position.
Josef Eisl <josef.eisl@jku.at>
parents: 16214
diff changeset
184 }
2bcba15fa725 Introduce LIRInstructionClass.Position.
Josef Eisl <josef.eisl@jku.at>
parents: 16214
diff changeset
185 }
2bcba15fa725 Introduce LIRInstructionClass.Position.
Josef Eisl <josef.eisl@jku.at>
parents: 16214
diff changeset
186
16799
dc9f55fbbf38 Restrict access to internal forEach* in LIRInstructionClass and friends.
Josef Eisl <josef.eisl@jku.at>
parents: 16797
diff changeset
187 final String getOpcode(LIRInstruction obj) {
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
188 if (opcodeConstant != null) {
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
189 return opcodeConstant;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
190 }
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
191 assert opcodeIndex != -1;
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
192 return data.getObject(obj, opcodeIndex).toString();
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
193 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
194
16799
dc9f55fbbf38 Restrict access to internal forEach* in LIRInstructionClass and friends.
Josef Eisl <josef.eisl@jku.at>
parents: 16797
diff changeset
195 final boolean hasOperands() {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
196 return uses.getCount() > 0 || alives.getCount() > 0 || temps.getCount() > 0 || defs.getCount() > 0;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
197 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
198
16799
dc9f55fbbf38 Restrict access to internal forEach* in LIRInstructionClass and friends.
Josef Eisl <josef.eisl@jku.at>
parents: 16797
diff changeset
199 final boolean hasState(LIRInstruction obj) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
200 for (int i = 0; i < states.getCount(); i++) {
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
201 if (states.getObject(obj, i) != null) {
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
202 return true;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
203 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
204 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
205 return false;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
206 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
207
17277
730aa0eb20e5 LIRIntrospection: rename forEach*(ValuePositionProcedure) to forEach*Pos.
Josef Eisl <josef.eisl@jku.at>
parents: 17247
diff changeset
208 final void forEachUsePos(LIRInstruction obj, ValuePositionProcedure proc) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
209 forEach(obj, obj, uses, OperandMode.USE, proc, ValuePosition.ROOT_VALUE_POSITION);
16279
69b9980ff5c2 Add ValuePositionProcedure and corresponding forEach methods.
Josef Eisl <josef.eisl@jku.at>
parents: 16278
diff changeset
210 }
69b9980ff5c2 Add ValuePositionProcedure and corresponding forEach methods.
Josef Eisl <josef.eisl@jku.at>
parents: 16278
diff changeset
211
17277
730aa0eb20e5 LIRIntrospection: rename forEach*(ValuePositionProcedure) to forEach*Pos.
Josef Eisl <josef.eisl@jku.at>
parents: 17247
diff changeset
212 final void forEachAlivePos(LIRInstruction obj, ValuePositionProcedure proc) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
213 forEach(obj, obj, alives, OperandMode.ALIVE, proc, ValuePosition.ROOT_VALUE_POSITION);
16279
69b9980ff5c2 Add ValuePositionProcedure and corresponding forEach methods.
Josef Eisl <josef.eisl@jku.at>
parents: 16278
diff changeset
214 }
69b9980ff5c2 Add ValuePositionProcedure and corresponding forEach methods.
Josef Eisl <josef.eisl@jku.at>
parents: 16278
diff changeset
215
17277
730aa0eb20e5 LIRIntrospection: rename forEach*(ValuePositionProcedure) to forEach*Pos.
Josef Eisl <josef.eisl@jku.at>
parents: 17247
diff changeset
216 final void forEachTempPos(LIRInstruction obj, ValuePositionProcedure proc) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
217 forEach(obj, obj, temps, OperandMode.TEMP, proc, ValuePosition.ROOT_VALUE_POSITION);
16279
69b9980ff5c2 Add ValuePositionProcedure and corresponding forEach methods.
Josef Eisl <josef.eisl@jku.at>
parents: 16278
diff changeset
218 }
69b9980ff5c2 Add ValuePositionProcedure and corresponding forEach methods.
Josef Eisl <josef.eisl@jku.at>
parents: 16278
diff changeset
219
17277
730aa0eb20e5 LIRIntrospection: rename forEach*(ValuePositionProcedure) to forEach*Pos.
Josef Eisl <josef.eisl@jku.at>
parents: 17247
diff changeset
220 final void forEachDefPos(LIRInstruction obj, ValuePositionProcedure proc) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
221 forEach(obj, obj, defs, OperandMode.DEF, proc, ValuePosition.ROOT_VALUE_POSITION);
16279
69b9980ff5c2 Add ValuePositionProcedure and corresponding forEach methods.
Josef Eisl <josef.eisl@jku.at>
parents: 16278
diff changeset
222 }
69b9980ff5c2 Add ValuePositionProcedure and corresponding forEach methods.
Josef Eisl <josef.eisl@jku.at>
parents: 16278
diff changeset
223
17287
0f8b1fb632df Remove InstructionValueProcedureBase (superseded by InstructionValueProcedure).
Josef Eisl <josef.eisl@jku.at>
parents: 17285
diff changeset
224 final void forEachUse(LIRInstruction obj, InstructionValueProcedure proc) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
225 forEach(obj, uses, OperandMode.USE, proc);
16138
f315b1c0a590 Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents: 15295
diff changeset
226 }
f315b1c0a590 Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents: 15295
diff changeset
227
17287
0f8b1fb632df Remove InstructionValueProcedureBase (superseded by InstructionValueProcedure).
Josef Eisl <josef.eisl@jku.at>
parents: 17285
diff changeset
228 final void forEachAlive(LIRInstruction obj, InstructionValueProcedure proc) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
229 forEach(obj, alives, OperandMode.ALIVE, proc);
16138
f315b1c0a590 Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents: 15295
diff changeset
230 }
f315b1c0a590 Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents: 15295
diff changeset
231
17287
0f8b1fb632df Remove InstructionValueProcedureBase (superseded by InstructionValueProcedure).
Josef Eisl <josef.eisl@jku.at>
parents: 17285
diff changeset
232 final void forEachTemp(LIRInstruction obj, InstructionValueProcedure proc) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
233 forEach(obj, temps, OperandMode.TEMP, proc);
16138
f315b1c0a590 Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents: 15295
diff changeset
234 }
f315b1c0a590 Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents: 15295
diff changeset
235
17287
0f8b1fb632df Remove InstructionValueProcedureBase (superseded by InstructionValueProcedure).
Josef Eisl <josef.eisl@jku.at>
parents: 17285
diff changeset
236 final void forEachDef(LIRInstruction obj, InstructionValueProcedure proc) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
237 forEach(obj, defs, OperandMode.DEF, proc);
16138
f315b1c0a590 Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents: 15295
diff changeset
238 }
f315b1c0a590 Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents: 15295
diff changeset
239
17287
0f8b1fb632df Remove InstructionValueProcedureBase (superseded by InstructionValueProcedure).
Josef Eisl <josef.eisl@jku.at>
parents: 17285
diff changeset
240 final void forEachState(LIRInstruction obj, InstructionValueProcedure proc) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
241 for (int i = 0; i < states.getCount(); i++) {
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
242 LIRFrameState state = (LIRFrameState) states.getObject(obj, i);
16138
f315b1c0a590 Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents: 15295
diff changeset
243 if (state != null) {
f315b1c0a590 Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents: 15295
diff changeset
244 state.forEachState(obj, proc);
f315b1c0a590 Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents: 15295
diff changeset
245 }
f315b1c0a590 Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents: 15295
diff changeset
246 }
f315b1c0a590 Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents: 15295
diff changeset
247 }
f315b1c0a590 Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents: 15295
diff changeset
248
16799
dc9f55fbbf38 Restrict access to internal forEach* in LIRInstructionClass and friends.
Josef Eisl <josef.eisl@jku.at>
parents: 16797
diff changeset
249 final void forEachState(LIRInstruction obj, InstructionStateProcedure proc) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
250 for (int i = 0; i < states.getCount(); i++) {
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
251 LIRFrameState state = (LIRFrameState) states.getObject(obj, i);
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
252 if (state != null) {
16354
b6e70c59b32d Introduce InstructionStateProcedure.
Josef Eisl <josef.eisl@jku.at>
parents: 16282
diff changeset
253 proc.doState(obj, state);
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
254 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
255 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
256 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
257
17287
0f8b1fb632df Remove InstructionValueProcedureBase (superseded by InstructionValueProcedure).
Josef Eisl <josef.eisl@jku.at>
parents: 17285
diff changeset
258 final Value forEachRegisterHint(LIRInstruction obj, OperandMode mode, InstructionValueProcedure proc) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
259 Values hints;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
260 if (mode == OperandMode.USE) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
261 hints = defs;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
262 } else if (mode == OperandMode.DEF) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
263 hints = uses;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
264 } else {
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
265 return null;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
266 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
267
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
268 for (int i = 0; i < hints.getCount(); i++) {
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
269 if (i < hints.getDirectCount()) {
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
270 Value hintValue = hints.getValue(obj, i);
17287
0f8b1fb632df Remove InstructionValueProcedureBase (superseded by InstructionValueProcedure).
Josef Eisl <josef.eisl@jku.at>
parents: 17285
diff changeset
271 Value result = proc.doValue(obj, hintValue, null, null);
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
272 if (result != null) {
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
273 return result;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
274 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
275 } else {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
276 Value[] hintValues = hints.getValueArray(obj, i);
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
277 for (int j = 0; j < hintValues.length; j++) {
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
278 Value hintValue = hintValues[j];
17287
0f8b1fb632df Remove InstructionValueProcedureBase (superseded by InstructionValueProcedure).
Josef Eisl <josef.eisl@jku.at>
parents: 17285
diff changeset
279 Value result = proc.doValue(obj, hintValue, null, null);
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
280 if (result != null) {
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
281 return result;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
282 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
283 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
284 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
285 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
286 return null;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
287 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
288
16799
dc9f55fbbf38 Restrict access to internal forEach* in LIRInstructionClass and friends.
Josef Eisl <josef.eisl@jku.at>
parents: 16797
diff changeset
289 String toString(LIRInstruction obj) {
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
290 StringBuilder result = new StringBuilder();
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
291
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
292 appendValues(result, obj, "", " = ", "(", ")", new String[]{""}, defs);
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
293 result.append(String.valueOf(getOpcode(obj)).toUpperCase());
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
294 appendValues(result, obj, " ", "", "(", ")", new String[]{"", "~"}, uses, alives);
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
295 appendValues(result, obj, " ", "", "{", "}", new String[]{""}, temps);
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
296
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
297 for (int i = 0; i < data.getCount(); i++) {
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
298 if (i == opcodeIndex) {
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
299 continue;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
300 }
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
301 result.append(" ").append(data.getName(i)).append(": ").append(getFieldString(obj, i, data));
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
302 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
303
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
304 for (int i = 0; i < states.getCount(); i++) {
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
305 LIRFrameState state = (LIRFrameState) states.getObject(obj, i);
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
306 if (state != null) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17211
diff changeset
307 result.append(" ").append(states.getName(i)).append(" [bci:");
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
308 String sep = "";
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
309 for (BytecodeFrame cur = state.topFrame; cur != null; cur = cur.caller()) {
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
310 result.append(sep).append(cur.getBCI());
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
311 sep = ", ";
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
312 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
313 result.append("]");
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
314 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
315 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
316
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
317 return result.toString();
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
318 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff changeset
319 }