annotate graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java @ 3018:5857923e563c

Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Sat, 18 Jun 2011 19:13:55 +0200
parents b4ba003eb11d
children 2433838f0414 cebfa0b55183 3ed1b2a5d071
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1 /*
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
4 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
7 * published by the Free Software Foundation.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
8 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
13 * accompanied this code).
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
14 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
18 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
21 * questions.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
22 */
2874
d90bf514d647 Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2872
diff changeset
23 package com.oracle.max.graal.compiler.gen;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
24
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
25 import static com.sun.cri.bytecode.Bytecodes.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
26 import static com.sun.cri.bytecode.Bytecodes.MemoryBarriers.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
27 import static com.sun.cri.ci.CiCallingConvention.Type.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
28 import static com.sun.cri.ci.CiValue.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
29
2783
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
30 import java.lang.reflect.*;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
31 import java.util.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
32
2677
0ea5f12e873a use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents: 2671
diff changeset
33 import com.oracle.max.asm.*;
2874
d90bf514d647 Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2872
diff changeset
34 import com.oracle.max.graal.compiler.*;
d90bf514d647 Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2872
diff changeset
35 import com.oracle.max.graal.compiler.alloc.*;
d90bf514d647 Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2872
diff changeset
36 import com.oracle.max.graal.compiler.alloc.OperandPool.*;
d90bf514d647 Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2872
diff changeset
37 import com.oracle.max.graal.compiler.debug.*;
d90bf514d647 Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2872
diff changeset
38 import com.oracle.max.graal.compiler.globalstub.*;
d90bf514d647 Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2872
diff changeset
39 import com.oracle.max.graal.compiler.graph.*;
d90bf514d647 Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2872
diff changeset
40 import com.oracle.max.graal.compiler.ir.*;
2935
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2924
diff changeset
41 import com.oracle.max.graal.compiler.ir.Deoptimize.DeoptAction;
2874
d90bf514d647 Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2872
diff changeset
42 import com.oracle.max.graal.compiler.lir.*;
d90bf514d647 Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2872
diff changeset
43 import com.oracle.max.graal.compiler.util.*;
d90bf514d647 Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2872
diff changeset
44 import com.oracle.max.graal.compiler.value.*;
d90bf514d647 Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2872
diff changeset
45 import com.oracle.max.graal.graph.*;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
46 import com.sun.cri.ci.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
47 import com.sun.cri.ri.*;
2990
66ecfc755c86 inlining of monomorphic profiled callsites with quick type checks
Lukas Stadler <lukas.stadler@jku.at>
parents: 2948
diff changeset
48 import com.sun.cri.ri.RiType.*;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
49 import com.sun.cri.xir.*;
2872
0341b6424579 Project renaming.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2868
diff changeset
50 import com.sun.cri.xir.CiXirAssembler.*;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
51
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
52 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
53 * This class traverses the HIR instructions and generates LIR instructions from them.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
54 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
55 public abstract class LIRGenerator extends ValueVisitor {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
56
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
57 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
58 * Helper class for inserting memory barriers as necessary to implement the Java Memory Model
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
59 * with respect to volatile field accesses.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
60 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
61 * @see MemoryBarriers
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
62 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
63 class VolatileMemoryAccess {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
64 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
65 * Inserts any necessary memory barriers before a volatile write as required by the JMM.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
66 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
67 void preVolatileWrite() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
68 int barriers = compilation.target.arch.requiredBarriers(JMM_PRE_VOLATILE_WRITE);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
69 if (compilation.target.isMP && barriers != 0) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
70 lir.membar(barriers);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
71 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
72 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
73
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
74 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
75 * Inserts any necessary memory barriers after a volatile write as required by the JMM.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
76 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
77 void postVolatileWrite() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
78 int barriers = compilation.target.arch.requiredBarriers(JMM_POST_VOLATILE_WRITE);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
79 if (compilation.target.isMP && barriers != 0) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
80 lir.membar(barriers);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
81 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
82 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
83
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
84 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
85 * Inserts any necessary memory barriers before a volatile read as required by the JMM.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
86 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
87 void preVolatileRead() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
88 int barriers = compilation.target.arch.requiredBarriers(JMM_PRE_VOLATILE_READ);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
89 if (compilation.target.isMP && barriers != 0) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
90 lir.membar(barriers);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
91 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
92 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
93
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
94 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
95 * Inserts any necessary memory barriers after a volatile read as required by the JMM.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
96 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
97 void postVolatileRead() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
98 // Ensure field's data is loaded before any subsequent loads or stores.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
99 int barriers = compilation.target.arch.requiredBarriers(LOAD_LOAD | LOAD_STORE);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
100 if (compilation.target.isMP && barriers != 0) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
101 lir.membar(barriers);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
102 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
103 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
104 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
105
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
106 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
107 * Forces the result of a given instruction to be available in a given register,
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
108 * inserting move instructions if necessary.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
109 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
110 * @param instruction an instruction that produces a {@linkplain Value#operand() result}
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
111 * @param register the {@linkplain CiRegister} in which the result of {@code instruction} must be available
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
112 * @return {@code register} as an operand
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
113 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
114 protected CiValue force(Value instruction, CiRegister register) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
115 return force(instruction, register.asValue(instruction.kind));
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
116 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
117
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
118 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
119 * Forces the result of a given instruction to be available in a given operand,
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
120 * inserting move instructions if necessary.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
121 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
122 * @param instruction an instruction that produces a {@linkplain Value#operand() result}
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
123 * @param operand the operand in which the result of {@code instruction} must be available
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
124 * @return {@code operand}
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
125 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
126 protected CiValue force(Value instruction, CiValue operand) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
127 CiValue result = makeOperand(instruction);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
128 if (result != operand) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
129 assert result.kind != CiKind.Illegal;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
130 if (!compilation.archKindsEqual(result.kind, operand.kind)) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
131 // moves between different types need an intervening spill slot
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
132 CiValue tmp = forceToSpill(result, operand.kind, false);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
133 lir.move(tmp, operand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
134 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
135 lir.move(result, operand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
136 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
137 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
138 return operand;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
139 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
140
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
141 protected CiValue load(Value val) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
142 CiValue result = makeOperand(val);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
143 if (!result.isVariableOrRegister()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
144 CiVariable operand = newVariable(val.kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
145 lir.move(result, operand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
146 return operand;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
147 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
148 return result;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
149 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
150
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
151 // the range of values in a lookupswitch or tableswitch statement
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
152 private static final class SwitchRange {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
153 final int lowKey;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
154 int highKey;
2725
c379183d1c54 Removed target block references from LIR to BlockBegin instructions. Now there is a getLIRBlock method in the LIRGenerator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2718
diff changeset
155 final LIRBlock sux;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
156
2725
c379183d1c54 Removed target block references from LIR to BlockBegin instructions. Now there is a getLIRBlock method in the LIRGenerator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2718
diff changeset
157 SwitchRange(int lowKey, LIRBlock sux) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
158 this.lowKey = lowKey;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
159 this.highKey = lowKey;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
160 this.sux = sux;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
161 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
162 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
163
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
164 protected final GraalCompilation compilation;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
165 protected final IR ir;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
166 protected final XirSupport xirSupport;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
167 protected final RiXirGenerator xir;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
168 protected final boolean isTwoOperand;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
169
2718
c1ce2a53d6c3 Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2716
diff changeset
170 private LIRBlock currentBlock;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
171
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
172 public final OperandPool operands;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
173
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
174 private Value currentInstruction;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
175 private Value lastInstructionPrinted; // Debugging only
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
176
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
177 private List<CiConstant> constants;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
178 private List<CiVariable> variablesForConstants;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
179 protected LIRList lir;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
180 final VolatileMemoryAccess vma;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
181 private ArrayList<DeoptimizationStub> deoptimizationStubs;
2622
91d3952f7eb7 Framestate work : using stateAFter and reducting the number of nodes with framestates. Intermediate state (does not pass tests)
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2602
diff changeset
182 private FrameState lastState;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
183
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
184 public LIRGenerator(GraalCompilation compilation) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
185 this.compilation = compilation;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
186 this.ir = compilation.hir();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
187 this.xir = compilation.compiler.xir;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
188 this.xirSupport = new XirSupport();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
189 this.isTwoOperand = compilation.target.arch.twoOperandMode();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
190 this.vma = new VolatileMemoryAccess();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
191
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
192 constants = new ArrayList<CiConstant>();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
193 variablesForConstants = new ArrayList<CiVariable>();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
194
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
195 this.operands = new OperandPool(compilation.target);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
196 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
197
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
198 public ArrayList<DeoptimizationStub> deoptimizationStubs() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
199 return deoptimizationStubs;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
200 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
201
2671
d8601d421b96 New Deoptimize node, remove ResolveClass node and replace it with deoptimization
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2670
diff changeset
202 private void addDeoptimizationStub(DeoptimizationStub stub) {
d8601d421b96 New Deoptimize node, remove ResolveClass node and replace it with deoptimization
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2670
diff changeset
203 if (deoptimizationStubs == null) {
d8601d421b96 New Deoptimize node, remove ResolveClass node and replace it with deoptimization
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2670
diff changeset
204 deoptimizationStubs = new ArrayList<LIRGenerator.DeoptimizationStub>();
d8601d421b96 New Deoptimize node, remove ResolveClass node and replace it with deoptimization
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2670
diff changeset
205 }
d8601d421b96 New Deoptimize node, remove ResolveClass node and replace it with deoptimization
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2670
diff changeset
206 deoptimizationStubs.add(stub);
d8601d421b96 New Deoptimize node, remove ResolveClass node and replace it with deoptimization
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2670
diff changeset
207 }
d8601d421b96 New Deoptimize node, remove ResolveClass node and replace it with deoptimization
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2670
diff changeset
208
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
209 public static class DeoptimizationStub {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
210 public final Label label = new Label();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
211 public final LIRDebugInfo info;
2935
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2924
diff changeset
212 public final DeoptAction action;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
213
2935
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2924
diff changeset
214 public DeoptimizationStub(DeoptAction action, FrameState state) {
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2924
diff changeset
215 this.action = action;
2833
1cd59ca9ac86 Removed Throw HIR instruction. Removed special handling for exceptions in register allocator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2826
diff changeset
216 info = new LIRDebugInfo(state);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
217 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
218 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
219
2718
c1ce2a53d6c3 Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2716
diff changeset
220 public void doBlock(LIRBlock block) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
221 blockDoProlog(block);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
222 this.currentBlock = block;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
223
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
224 if (GraalOptions.TraceLIRGeneratorLevel >= 1) {
2718
c1ce2a53d6c3 Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2716
diff changeset
225 TTY.println("BEGIN Generating LIR for block B" + block.blockID());
2623
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
226 }
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
227
2812
d27bdbec3d67 Removed ArrayLength from CFG. Fixed an issue when scheduling Merge instructions within a block.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2807
diff changeset
228 if (block.blockPredecessors().size() > 1) {
2983
11dfbb40ca69 LoopCounter, WIP
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2981
diff changeset
229 if (GraalOptions.TraceLIRGeneratorLevel >= 2) {
11dfbb40ca69 LoopCounter, WIP
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2981
diff changeset
230 TTY.println("STATE RESET");
11dfbb40ca69 LoopCounter, WIP
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2981
diff changeset
231 }
2812
d27bdbec3d67 Removed ArrayLength from CFG. Fixed an issue when scheduling Merge instructions within a block.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2807
diff changeset
232 lastState = null;
d27bdbec3d67 Removed ArrayLength from CFG. Fixed an issue when scheduling Merge instructions within a block.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2807
diff changeset
233 }
d27bdbec3d67 Removed ArrayLength from CFG. Fixed an issue when scheduling Merge instructions within a block.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2807
diff changeset
234
2801
2af109bec0c0 Make block contains a list of nodes instead a list of instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2796
diff changeset
235 for (Node instr : block.getInstructions()) {
2983
11dfbb40ca69 LoopCounter, WIP
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2981
diff changeset
236 if (GraalOptions.TraceLIRGeneratorLevel >= 3) {
11dfbb40ca69 LoopCounter, WIP
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2981
diff changeset
237 TTY.println("LIRGen for " + instr);
11dfbb40ca69 LoopCounter, WIP
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2981
diff changeset
238 }
2801
2af109bec0c0 Make block contains a list of nodes instead a list of instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2796
diff changeset
239 FrameState stateAfter = null;
2af109bec0c0 Make block contains a list of nodes instead a list of instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2796
diff changeset
240 if (instr instanceof Instruction) {
2af109bec0c0 Make block contains a list of nodes instead a list of instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2796
diff changeset
241 stateAfter = ((Instruction) instr).stateAfter();
2af109bec0c0 Make block contains a list of nodes instead a list of instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2796
diff changeset
242 }
2974
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
243 if (instr != instr.graph().start()) {
2622
91d3952f7eb7 Framestate work : using stateAFter and reducting the number of nodes with framestates. Intermediate state (does not pass tests)
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2602
diff changeset
244 walkState(instr, stateAfter);
2801
2af109bec0c0 Make block contains a list of nodes instead a list of instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2796
diff changeset
245 doRoot((Value) instr);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
246 }
2623
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
247 if (stateAfter != null) {
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
248 lastState = stateAfter;
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
249 if (GraalOptions.TraceLIRGeneratorLevel >= 2) {
2623
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
250 TTY.println("STATE CHANGE");
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
251 if (GraalOptions.TraceLIRGeneratorLevel >= 3) {
2623
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
252 TTY.println(stateAfter.toString());
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
253 }
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
254 }
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
255 }
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
256 }
2996
4025f436a2e4 Clean up scheduler. Remove test for HIR loop end in LIRGenerator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2991
diff changeset
257 if (block.blockSuccessors().size() >= 1 && !block.endsWithJump()) {
2974
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
258 block.lir().jump(getLIRBlock((FixedNode) block.lastInstruction().successors().get(0)));
2788
df4c5254c5cc Towards goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2784
diff changeset
259 }
2623
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
260
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
261 if (GraalOptions.TraceLIRGeneratorLevel >= 1) {
2718
c1ce2a53d6c3 Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2716
diff changeset
262 TTY.println("END Generating LIR for block B" + block.blockID());
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
263 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
264
2783
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
265 block.setLastState(lastState);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
266 this.currentBlock = null;
2718
c1ce2a53d6c3 Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2716
diff changeset
267 blockDoEpilog();
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
268 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
269
2974
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
270 @Override
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
271 public void visitMerge(Merge x) {
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
272 // Nothing to do.
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
273 }
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
274
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
275 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
276 public void visitArrayLength(ArrayLength x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
277 emitArrayLength(x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
278 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
279
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
280 public CiValue emitArrayLength(ArrayLength x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
281 XirArgument array = toXirArgument(x.array());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
282 XirSnippet snippet = xir.genArrayLength(site(x), array);
2541
0f9eeb15e636 More Value.Flag clean up.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2540
diff changeset
283 emitXir(snippet, x, stateFor(x), null, true);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
284 return x.operand();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
285 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
286
2783
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
287 private FrameState setOperandsForLocals() {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
288 CiCallingConvention args = compilation.frameMap().incomingArguments();
2783
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
289 int bci = 0;
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
290 if (Modifier.isSynchronized(compilation.method.accessFlags())) {
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
291 bci = Instruction.SYNCHRONIZATION_ENTRY_BCI;
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
292 }
2938
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2935
diff changeset
293
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2935
diff changeset
294 boolean withReceiver = !Modifier.isStatic(compilation.method.accessFlags());
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2935
diff changeset
295 CiKind[] arguments = Util.signatureToKinds(compilation.method.signature(), withReceiver ? CiKind.Object : null);
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2935
diff changeset
296 int[] argumentSlots = new int[arguments.length];
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2935
diff changeset
297 int slot = 0;
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2935
diff changeset
298 for (int arg = 0; arg < arguments.length; arg++) {
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2935
diff changeset
299 argumentSlots[arg] = slot;
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2935
diff changeset
300 slot += arguments[arg].sizeInSlots();
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2935
diff changeset
301 }
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2935
diff changeset
302
3018
5857923e563c Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3017
diff changeset
303 FrameState fs = new FrameState(compilation.method, bci, compilation.method.maxLocals(), 0, 0, false, compilation.graph);
2771
056e392d63d4 Connected local variables to start node. No more need for frame state to emit locals.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2769
diff changeset
304 for (Node node : compilation.graph.start().usages()) {
056e392d63d4 Connected local variables to start node. No more need for frame state to emit locals.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2769
diff changeset
305 if (node instanceof Local) {
056e392d63d4 Connected local variables to start node. No more need for frame state to emit locals.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2769
diff changeset
306 Local local = (Local) node;
056e392d63d4 Connected local variables to start node. No more need for frame state to emit locals.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2769
diff changeset
307 int i = local.index();
2938
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2935
diff changeset
308 fs.storeLocal(argumentSlots[i], local);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
309
2771
056e392d63d4 Connected local variables to start node. No more need for frame state to emit locals.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2769
diff changeset
310 CiValue src = args.locations[i];
056e392d63d4 Connected local variables to start node. No more need for frame state to emit locals.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2769
diff changeset
311 assert src.isLegal() : "check";
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
312
2771
056e392d63d4 Connected local variables to start node. No more need for frame state to emit locals.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2769
diff changeset
313 CiVariable dest = newVariable(src.kind.stackKind());
056e392d63d4 Connected local variables to start node. No more need for frame state to emit locals.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2769
diff changeset
314 lir.move(src, dest, src.kind);
056e392d63d4 Connected local variables to start node. No more need for frame state to emit locals.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2769
diff changeset
315
056e392d63d4 Connected local variables to start node. No more need for frame state to emit locals.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2769
diff changeset
316 assert src.kind.stackKind() == local.kind.stackKind() : "local type check failed";
056e392d63d4 Connected local variables to start node. No more need for frame state to emit locals.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2769
diff changeset
317 setResult(local, dest);
056e392d63d4 Connected local variables to start node. No more need for frame state to emit locals.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2769
diff changeset
318 }
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
319 }
2938
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2935
diff changeset
320 assert checkOperands(fs);
2783
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
321 return fs;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
322 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
323
2938
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2935
diff changeset
324 private boolean checkOperands(FrameState fs) {
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2935
diff changeset
325 boolean withReceiver = !Modifier.isStatic(compilation.method.accessFlags());
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2935
diff changeset
326 CiKind[] arguments = Util.signatureToKinds(compilation.method.signature(), withReceiver ? CiKind.Object : null);
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2935
diff changeset
327 int slot = 0;
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2935
diff changeset
328 for (CiKind kind : arguments) {
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2935
diff changeset
329 assert fs.localAt(slot) != null : "slot: " + slot;
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2935
diff changeset
330 slot += kind.sizeInSlots();
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2935
diff changeset
331 }
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2935
diff changeset
332 return true;
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2935
diff changeset
333 }
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2935
diff changeset
334
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
335 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
336 public void visitCheckCast(CheckCast x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
337 XirArgument obj = toXirArgument(x.object());
2600
f1bc67c2d453 new node layout: TypeCheck, RegisterFinalizer, Invoke, NewArray, NullCheck
Lukas Stadler <lukas.stadler@jku.at>
parents: 2596
diff changeset
338 XirSnippet snippet = xir.genCheckCast(site(x), obj, toXirArgument(x.targetClassInstruction()), x.targetClass());
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
339 emitXir(snippet, x, stateFor(x), null, true);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
340 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
341
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
342 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
343 public void visitInstanceOf(InstanceOf x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
344 XirArgument obj = toXirArgument(x.object());
2600
f1bc67c2d453 new node layout: TypeCheck, RegisterFinalizer, Invoke, NewArray, NullCheck
Lukas Stadler <lukas.stadler@jku.at>
parents: 2596
diff changeset
345 XirSnippet snippet = xir.genInstanceOf(site(x), obj, toXirArgument(x.targetClassInstruction()), x.targetClass());
2634
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2633
diff changeset
346 emitXir(snippet, x, stateFor(x), null, true);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
347 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
348
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
349 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
350 public void visitMonitorEnter(MonitorEnter x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
351 XirArgument obj = toXirArgument(x.object());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
352 XirArgument lockAddress = toXirArgument(x.lockAddress());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
353 XirSnippet snippet = xir.genMonitorEnter(site(x), obj, lockAddress);
2634
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2633
diff changeset
354 emitXir(snippet, x, stateFor(x), stateFor(x, x.stateAfter()), null, true, null);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
355 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
356
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
357 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
358 public void visitMonitorExit(MonitorExit x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
359 XirArgument obj = toXirArgument(x.object());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
360 XirArgument lockAddress = toXirArgument(x.lockAddress());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
361 XirSnippet snippet = xir.genMonitorExit(site(x), obj, lockAddress);
2634
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2633
diff changeset
362 emitXir(snippet, x, stateFor(x), null, true);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
363 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
364
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
365 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
366 public void visitStoreIndexed(StoreIndexed x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
367 XirArgument array = toXirArgument(x.array());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
368 XirArgument length = x.length() == null ? null : toXirArgument(x.length());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
369 XirArgument index = toXirArgument(x.index());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
370 XirArgument value = toXirArgument(x.value());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
371 XirSnippet snippet = xir.genArrayStore(site(x), array, index, length, value, x.elementKind(), null);
2634
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2633
diff changeset
372 emitXir(snippet, x, stateFor(x), null, true);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
373 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
374
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
375 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
376 public void visitNewInstance(NewInstance x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
377 XirSnippet snippet = xir.genNewInstance(site(x), x.instanceClass());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
378 emitXir(snippet, x, stateFor(x), null, true);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
379 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
380
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
381 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
382 public void visitNewTypeArray(NewTypeArray x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
383 XirArgument length = toXirArgument(x.length());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
384 XirSnippet snippet = xir.genNewArray(site(x), length, x.elementKind(), null, null);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
385 emitXir(snippet, x, stateFor(x), null, true);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
386 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
387
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
388 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
389 public void visitNewObjectArray(NewObjectArray x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
390 XirArgument length = toXirArgument(x.length());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
391 XirSnippet snippet = xir.genNewArray(site(x), length, CiKind.Object, x.elementClass(), x.exactType());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
392 emitXir(snippet, x, stateFor(x), null, true);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
393 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
394
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
395 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
396 public void visitNewMultiArray(NewMultiArray x) {
2600
f1bc67c2d453 new node layout: TypeCheck, RegisterFinalizer, Invoke, NewArray, NullCheck
Lukas Stadler <lukas.stadler@jku.at>
parents: 2596
diff changeset
397 XirArgument[] dims = new XirArgument[x.dimensionCount()];
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
398
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
399 for (int i = 0; i < dims.length; i++) {
2600
f1bc67c2d453 new node layout: TypeCheck, RegisterFinalizer, Invoke, NewArray, NullCheck
Lukas Stadler <lukas.stadler@jku.at>
parents: 2596
diff changeset
400 dims[i] = toXirArgument(x.dimension(i));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
401 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
402
2834
bfce42cd9c07 Graph duplication now passes all tests
Lukas Stadler <lukas.stadler@jku.at>
parents: 2826
diff changeset
403 XirSnippet snippet = xir.genNewMultiArray(site(x), dims, x.elementType);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
404 emitXir(snippet, x, stateFor(x), null, true);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
405 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
406
2922
e37f27b6af77 Changes to LIRBranch.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2920
diff changeset
407
e37f27b6af77 Changes to LIRBranch.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2920
diff changeset
408 @Override
e37f27b6af77 Changes to LIRBranch.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2920
diff changeset
409 public void visitGuardNode(GuardNode x) {
e37f27b6af77 Changes to LIRBranch.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2920
diff changeset
410 FrameState state = lastState;
e37f27b6af77 Changes to LIRBranch.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2920
diff changeset
411 assert state != null : "deoptimize instruction always needs a state";
e37f27b6af77 Changes to LIRBranch.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2920
diff changeset
412
e37f27b6af77 Changes to LIRBranch.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2920
diff changeset
413 if (deoptimizationStubs == null) {
e37f27b6af77 Changes to LIRBranch.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2920
diff changeset
414 deoptimizationStubs = new ArrayList<DeoptimizationStub>();
e37f27b6af77 Changes to LIRBranch.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2920
diff changeset
415 }
e37f27b6af77 Changes to LIRBranch.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2920
diff changeset
416
2935
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2924
diff changeset
417 DeoptimizationStub stub = new DeoptimizationStub(DeoptAction.InvalidateReprofile, state);
2922
e37f27b6af77 Changes to LIRBranch.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2920
diff changeset
418 deoptimizationStubs.add(stub);
2941
cd4176d590e7 Towards lowering phase.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2940
diff changeset
419
cd4176d590e7 Towards lowering phase.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2940
diff changeset
420 emitCompare(x.node());
cd4176d590e7 Towards lowering phase.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2940
diff changeset
421 //emitBranch(x.node(), stub.label)
2922
e37f27b6af77 Changes to LIRBranch.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2920
diff changeset
422 throw new RuntimeException();
e37f27b6af77 Changes to LIRBranch.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2920
diff changeset
423 //lir.branch(x.condition.negate(), stub.label, stub.info);
e37f27b6af77 Changes to LIRBranch.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2920
diff changeset
424 }
e37f27b6af77 Changes to LIRBranch.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2920
diff changeset
425
e37f27b6af77 Changes to LIRBranch.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2920
diff changeset
426
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
427 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
428 public void visitConstant(Constant x) {
2546
e1b3db8031ee Removed liveness marking.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2545
diff changeset
429 if (!canInlineAsConstant(x)) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
430 CiValue res = x.operand();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
431 if (!(res.isLegal())) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
432 res = x.asConstant();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
433 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
434 if (res.isConstant()) {
2546
e1b3db8031ee Removed liveness marking.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2545
diff changeset
435 CiVariable reg = createResultVariable(x);
e1b3db8031ee Removed liveness marking.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2545
diff changeset
436 lir.move(res, reg);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
437 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
438 setResult(x, (CiVariable) res);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
439 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
440 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
441 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
442
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
443 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
444 public void visitExceptionObject(ExceptionObject x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
445 XirSnippet snippet = xir.genExceptionObject(site(x));
2634
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2633
diff changeset
446 emitXir(snippet, x, stateFor(x), null, true);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
447 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
448
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
449 @Override
2822
530366123e46 Invoke is a block end
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2796
diff changeset
450 public void visitAnchor(Anchor x) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
451 setNoResult(x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
452 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
453
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
454 @Override
2924
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
455 public void visitIf(If x) {
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
456 emitCompare(x.compare());
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
457 emitBranch(x.compare(), getLIRBlock(x.trueSuccessor()), getLIRBlock(x.falseSuccessor()));
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
458 assert x.defaultSuccessor() == x.falseSuccessor() : "wrong destination above";
2976
57c2e3409be7 Fixed merge issues.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2974
diff changeset
459 LIRBlock block = getLIRBlock(x.defaultSuccessor());
57c2e3409be7 Fixed merge issues.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2974
diff changeset
460 assert block != null : x;
57c2e3409be7 Fixed merge issues.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2974
diff changeset
461 lir.jump(block);
2924
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
462 }
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
463
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
464 public void emitBranch(Compare compare, LIRBlock trueSuccessor, LIRBlock falseSucc) {
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
465 Condition cond = compare.condition();
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
466 if (compare.x().kind.isFloat() || compare.x().kind.isDouble()) {
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
467 LIRBlock unorderedSuccBlock = falseSucc;
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
468 if (compare.unorderedIsTrue()) {
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
469 unorderedSuccBlock = trueSuccessor;
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
470 }
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
471 lir.branch(cond, trueSuccessor, unorderedSuccBlock);
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
472 } else {
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
473 lir.branch(cond, trueSuccessor);
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
474 }
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
475 }
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
476
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
477 public void emitCompare(Compare compare) {
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
478 CiKind kind = compare.x().kind;
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
479
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
480 Condition cond = compare.condition();
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
481
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
482 LIRItem xitem = new LIRItem(compare.x(), this);
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
483 LIRItem yitem = new LIRItem(compare.y(), this);
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
484 LIRItem xin = xitem;
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
485 LIRItem yin = yitem;
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
486
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
487 if (kind.isLong()) {
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
488 // for longs, only conditions "eql", "neq", "lss", "geq" are valid;
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
489 // mirror for other conditions
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
490 if (cond == Condition.GT || cond == Condition.LE) {
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
491 cond = cond.mirror();
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
492 xin = yitem;
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
493 yin = xitem;
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
494 }
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
495 xin.setDestroysRegister();
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
496 }
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
497 xin.loadItem();
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
498 if (kind.isLong() && yin.result().isConstant() && yin.instruction.asConstant().asLong() == 0 && (cond == Condition.EQ || cond == Condition.NE)) {
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
499 // dont load item
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
500 } else if (kind.isLong() || kind.isFloat() || kind.isDouble()) {
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
501 // longs cannot handle constants at right side
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
502 yin.loadItem();
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
503 }
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
504
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
505 CiValue left = xin.result();
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
506 CiValue right = yin.result();
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
507 lir.cmp(cond, left, right);
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
508 }
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
509
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
510 @Override
2852
c6bdec623ef9 Move TypeCHeck to floating nodes, rename Nodes to aboid using an *Op suffix
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2851
diff changeset
511 public void visitIfOp(Conditional i) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
512 Value x = i.x();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
513 Value y = i.y();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
514 CiKind xtype = x.kind;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
515 CiKind ttype = i.trueValue().kind;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
516 assert xtype.isInt() || xtype.isObject() : "cannot handle others";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
517 assert ttype.isInt() || ttype.isObject() || ttype.isLong() || ttype.isWord() : "cannot handle others";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
518 assert ttype.equals(i.falseValue().kind) : "cannot handle others";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
519
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
520 CiValue left = load(x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
521 CiValue right = null;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
522 if (!canInlineAsConstant(y)) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
523 right = load(y);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
524 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
525 right = makeOperand(y);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
526 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
527
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
528 CiValue tVal = makeOperand(i.trueValue());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
529 CiValue fVal = makeOperand(i.falseValue());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
530 CiValue reg = createResultVariable(i);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
531
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
532 lir.cmp(i.condition(), left, right);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
533 lir.cmove(i.condition(), tVal, fVal, reg);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
534 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
535
2671
d8601d421b96 New Deoptimize node, remove ResolveClass node and replace it with deoptimization
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2670
diff changeset
536 protected FrameState stateBeforeInvokeReturn(Invoke invoke) {
3018
5857923e563c Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3017
diff changeset
537 return invoke.stateAfter().duplicateModified(getBeforeInvokeBci(invoke), invoke.stateAfter().rethrowException(), invoke.kind);
2640
9e30cf6dcf96 More frame state fixes. All jtt tests passing now again.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2639
diff changeset
538 }
9e30cf6dcf96 More frame state fixes. All jtt tests passing now again.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2639
diff changeset
539
9e30cf6dcf96 More frame state fixes. All jtt tests passing now again.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2639
diff changeset
540 protected FrameState stateBeforeInvokeWithArguments(Invoke invoke) {
2666
6ca76b891d31 duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents: 2661
diff changeset
541 Value[] args = new Value[invoke.argumentCount()];
6ca76b891d31 duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents: 2661
diff changeset
542 for (int i = 0; i < invoke.argumentCount(); i++) {
6ca76b891d31 duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents: 2661
diff changeset
543 args[i] = invoke.argument(i);
2640
9e30cf6dcf96 More frame state fixes. All jtt tests passing now again.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2639
diff changeset
544 }
3018
5857923e563c Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3017
diff changeset
545 return invoke.stateAfter().duplicateModified(getBeforeInvokeBci(invoke), invoke.stateAfter().rethrowException(), invoke.kind, args);
2716
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
546 }
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
547
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
548 private int getBeforeInvokeBci(Invoke invoke) {
2924
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
549 // Cannot calculate BCI, because the invoke can have changed from e.g. invokeinterface to invokespecial because of optimizations.
2825
9ba6a8abe894 Fix Invoke bci problem
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2823
diff changeset
550 return invoke.bci;
2628
569228710be8 More FrameState work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2623
diff changeset
551 }
2622
91d3952f7eb7 Framestate work : using stateAFter and reducting the number of nodes with framestates. Intermediate state (does not pass tests)
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2602
diff changeset
552
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
553 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
554 public void visitInvoke(Invoke x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
555 RiMethod target = x.target();
2640
9e30cf6dcf96 More frame state fixes. All jtt tests passing now again.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2639
diff changeset
556 LIRDebugInfo info = stateFor(x, stateBeforeInvokeWithArguments(x));
2671
d8601d421b96 New Deoptimize node, remove ResolveClass node and replace it with deoptimization
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2670
diff changeset
557 LIRDebugInfo info2 = stateFor(x, stateBeforeInvokeReturn(x));
2833
1cd59ca9ac86 Removed Throw HIR instruction. Removed special handling for exceptions in register allocator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2826
diff changeset
558 if (x.exceptionEdge() != null) {
1cd59ca9ac86 Removed Throw HIR instruction. Removed special handling for exceptions in register allocator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2826
diff changeset
559 info2.setExceptionEdge(getLIRBlock(x.exceptionEdge()));
1cd59ca9ac86 Removed Throw HIR instruction. Removed special handling for exceptions in register allocator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2826
diff changeset
560 }
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
561
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
562 XirSnippet snippet = null;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
563
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
564 int opcode = x.opcode();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
565 XirArgument receiver;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
566 switch (opcode) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
567 case INVOKESTATIC:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
568 snippet = xir.genInvokeStatic(site(x), target);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
569 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
570 case INVOKESPECIAL:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
571 receiver = toXirArgument(x.receiver());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
572 snippet = xir.genInvokeSpecial(site(x), receiver, target);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
573 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
574 case INVOKEVIRTUAL:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
575 receiver = toXirArgument(x.receiver());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
576 snippet = xir.genInvokeVirtual(site(x), receiver, target);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
577 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
578 case INVOKEINTERFACE:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
579 receiver = toXirArgument(x.receiver());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
580 snippet = xir.genInvokeInterface(site(x), receiver, target);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
581 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
582 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
583
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
584 CiValue destinationAddress = null;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
585 // emitting the template earlier can ease pressure on register allocation, but the argument loading can destroy an
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
586 // implicit calling convention between the XirSnippet and the call.
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
587 if (!GraalOptions.InvokeSnippetAfterArguments) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
588 destinationAddress = emitXir(snippet, x, info.copy(), x.target(), false);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
589 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
590
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
591 CiValue resultOperand = resultOperandFor(x.kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
592 CiCallingConvention cc = compilation.frameMap().getCallingConvention(x.signature(), JavaCall);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
593 List<CiValue> pointerSlots = new ArrayList<CiValue>(2);
2596
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
594 List<CiValue> argList = visitInvokeArguments(cc, x, pointerSlots);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
595
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
596 if (GraalOptions.InvokeSnippetAfterArguments) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
597 destinationAddress = emitXir(snippet, x, info.copy(), null, x.target(), false, pointerSlots);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
598 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
599
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
600 // emit direct or indirect call to the destination address
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
601 if (destinationAddress instanceof CiConstant) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
602 // Direct call
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
603 assert ((CiConstant) destinationAddress).isDefaultValue() : "destination address should be zero";
2640
9e30cf6dcf96 More frame state fixes. All jtt tests passing now again.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2639
diff changeset
604 lir.callDirect(target, resultOperand, argList, info2, snippet.marks, pointerSlots);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
605 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
606 // Indirect call
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
607 argList.add(destinationAddress);
2640
9e30cf6dcf96 More frame state fixes. All jtt tests passing now again.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2639
diff changeset
608 lir.callIndirect(target, resultOperand, argList, info2, snippet.marks, pointerSlots);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
609 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
610
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
611 if (resultOperand.isLegal()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
612 CiValue result = createResultVariable(x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
613 lir.move(resultOperand, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
614 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
615 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
616
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
617 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
618 public void visitMonitorAddress(MonitorAddress x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
619 CiValue result = createResultVariable(x);
2910
7eec76f3e39e adjust monitor index while inlining, renamed NodeWorklist to NodeFlood
Lukas Stadler <lukas.stadler@jku.at>
parents: 2874
diff changeset
620 lir.monitorAddress(x.monitorIndex(), result);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
621 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
622
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
623 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
624 * For note on volatile fields, see {@link #visitStoreField(StoreField)}.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
625 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
626 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
627 public void visitLoadField(LoadField x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
628 RiField field = x.field();
2622
91d3952f7eb7 Framestate work : using stateAFter and reducting the number of nodes with framestates. Intermediate state (does not pass tests)
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2602
diff changeset
629 LIRDebugInfo info = stateFor(x);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
630 XirArgument receiver = toXirArgument(x.object());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
631 XirSnippet snippet = x.isStatic() ? xir.genGetStatic(site(x), receiver, field) : xir.genGetField(site(x), receiver, field);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
632 emitXir(snippet, x, info, null, true);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
633
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
634 if (x.isVolatile()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
635 vma.postVolatileRead();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
636 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
637 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
638
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
639 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
640 public void visitLoadIndexed(LoadIndexed x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
641 XirArgument array = toXirArgument(x.array());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
642 XirArgument index = toXirArgument(x.index());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
643 XirArgument length = toXirArgument(x.length());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
644 XirSnippet snippet = xir.genArrayLoad(site(x), array, index, length, x.elementKind(), null);
2634
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2633
diff changeset
645 emitXir(snippet, x, stateFor(x), null, true);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
646 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
647
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
648 protected GlobalStub stubFor(CiRuntimeCall runtimeCall) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
649 GlobalStub stub = compilation.compiler.lookupGlobalStub(runtimeCall);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
650 compilation.frameMap().usesGlobalStub(stub);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
651 return stub;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
652 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
653
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
654 protected GlobalStub stubFor(GlobalStub.Id globalStub) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
655 GlobalStub stub = compilation.compiler.lookupGlobalStub(globalStub);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
656 compilation.frameMap().usesGlobalStub(stub);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
657 return stub;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
658 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
659
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
660 protected GlobalStub stubFor(XirTemplate template) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
661 GlobalStub stub = compilation.compiler.lookupGlobalStub(template);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
662 compilation.frameMap().usesGlobalStub(stub);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
663 return stub;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
664 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
665
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
666 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
667 public void visitLocal(Local x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
668 if (x.operand().isIllegal()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
669 createResultVariable(x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
670 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
671 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
672
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
673 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
674 public void visitLookupSwitch(LookupSwitch x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
675 CiValue tag = load(x.value());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
676 setNoResult(x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
677
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
678 if (x.numberOfCases() == 0 || x.numberOfCases() < GraalOptions.SequentialSwitchLimit) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
679 int len = x.numberOfCases();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
680 for (int i = 0; i < len; i++) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
681 lir.cmp(Condition.EQ, tag, x.keyAt(i));
2922
e37f27b6af77 Changes to LIRBranch.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2920
diff changeset
682 lir.branch(Condition.EQ, getLIRBlock(x.blockSuccessor(i)));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
683 }
2725
c379183d1c54 Removed target block references from LIR to BlockBegin instructions. Now there is a getLIRBlock method in the LIRGenerator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2718
diff changeset
684 lir.jump(getLIRBlock(x.defaultSuccessor()));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
685 } else {
2725
c379183d1c54 Removed target block references from LIR to BlockBegin instructions. Now there is a getLIRBlock method in the LIRGenerator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2718
diff changeset
686 visitSwitchRanges(createLookupRanges(x), tag, getLIRBlock(x.defaultSuccessor()));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
687 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
688 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
689
2967
60a58915c94d Removed next pointer from EndNode to Merge. New scheduler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2960
diff changeset
690 protected LIRBlock getLIRBlock(FixedNode b) {
2924
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
691 if (b == null) {
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
692 return null;
9d4e5b492521 Refactored LIR generation for If.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2922
diff changeset
693 }
2789
aeccd2af4e9e Fixes around critical edge split and placeholder removal after goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2788
diff changeset
694 LIRBlock result = ir.valueToBlock.get(b);
aeccd2af4e9e Fixes around critical edge split and placeholder removal after goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2788
diff changeset
695 if (result == null) {
aeccd2af4e9e Fixes around critical edge split and placeholder removal after goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2788
diff changeset
696 TTY.println("instruction without lir block: " + b);
aeccd2af4e9e Fixes around critical edge split and placeholder removal after goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2788
diff changeset
697 }
aeccd2af4e9e Fixes around critical edge split and placeholder removal after goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2788
diff changeset
698 return result;
2725
c379183d1c54 Removed target block references from LIR to BlockBegin instructions. Now there is a getLIRBlock method in the LIRGenerator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2718
diff changeset
699 }
c379183d1c54 Removed target block references from LIR to BlockBegin instructions. Now there is a getLIRBlock method in the LIRGenerator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2718
diff changeset
700
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
701 @Override
2940
bf15ed11c2bc Rename ClipNode=>FixedGuard and FixedNullCheck=>IsNonNull.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2924
diff changeset
702 public void visitFixedGuard(FixedGuard fixedGuard) {
bf15ed11c2bc Rename ClipNode=>FixedGuard and FixedNullCheck=>IsNonNull.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2924
diff changeset
703 Node comp = fixedGuard.node();
3010
ac6fb0c93ffb Towards lowering (example lowering for field access).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3007
diff changeset
704 emitGuardComp(comp);
ac6fb0c93ffb Towards lowering (example lowering for field access).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3007
diff changeset
705 }
ac6fb0c93ffb Towards lowering (example lowering for field access).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3007
diff changeset
706
ac6fb0c93ffb Towards lowering (example lowering for field access).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3007
diff changeset
707 public void emitGuardComp(Node comp) {
2940
bf15ed11c2bc Rename ClipNode=>FixedGuard and FixedNullCheck=>IsNonNull.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2924
diff changeset
708 if (comp instanceof IsNonNull) {
bf15ed11c2bc Rename ClipNode=>FixedGuard and FixedNullCheck=>IsNonNull.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2924
diff changeset
709 IsNonNull x = (IsNonNull) comp;
bf15ed11c2bc Rename ClipNode=>FixedGuard and FixedNullCheck=>IsNonNull.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2924
diff changeset
710 CiValue value = load(x.object());
bf15ed11c2bc Rename ClipNode=>FixedGuard and FixedNullCheck=>IsNonNull.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2924
diff changeset
711 LIRDebugInfo info = stateFor(x);
bf15ed11c2bc Rename ClipNode=>FixedGuard and FixedNullCheck=>IsNonNull.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2924
diff changeset
712 lir.nullCheck(value, info);
2990
66ecfc755c86 inlining of monomorphic profiled callsites with quick type checks
Lukas Stadler <lukas.stadler@jku.at>
parents: 2948
diff changeset
713 } else if (comp instanceof IsType) {
66ecfc755c86 inlining of monomorphic profiled callsites with quick type checks
Lukas Stadler <lukas.stadler@jku.at>
parents: 2948
diff changeset
714 IsType x = (IsType) comp;
3010
ac6fb0c93ffb Towards lowering (example lowering for field access).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3007
diff changeset
715 load(x.object());
2990
66ecfc755c86 inlining of monomorphic profiled callsites with quick type checks
Lukas Stadler <lukas.stadler@jku.at>
parents: 2948
diff changeset
716 LIRDebugInfo info = stateFor(x);
66ecfc755c86 inlining of monomorphic profiled callsites with quick type checks
Lukas Stadler <lukas.stadler@jku.at>
parents: 2948
diff changeset
717 XirArgument clazz = toXirArgument(x.type().getEncoding(Representation.ObjectHub));
66ecfc755c86 inlining of monomorphic profiled callsites with quick type checks
Lukas Stadler <lukas.stadler@jku.at>
parents: 2948
diff changeset
718 XirSnippet typeCheck = xir.genTypeCheck(site(x), toXirArgument(x.object()), clazz, x.type());
66ecfc755c86 inlining of monomorphic profiled callsites with quick type checks
Lukas Stadler <lukas.stadler@jku.at>
parents: 2948
diff changeset
719 emitXir(typeCheck, x, info, compilation.method, false);
2940
bf15ed11c2bc Rename ClipNode=>FixedGuard and FixedNullCheck=>IsNonNull.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2924
diff changeset
720 }
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
721 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
722
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
723 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
724 public void visitPhi(Phi i) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
725 Util.shouldNotReachHere();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
726 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
727
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
728 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
729 public void visitReturn(Return x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
730 if (x.kind.isVoid()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
731 XirSnippet epilogue = xir.genEpilogue(site(x), compilation.method);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
732 if (epilogue != null) {
2775
3b73b230b86b Removed more stateAfter usages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2774
diff changeset
733 emitXir(epilogue, x, null, compilation.method, false);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
734 lir.returnOp(IllegalValue);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
735 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
736 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
737 CiValue operand = resultOperandFor(x.kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
738 CiValue result = force(x.result(), operand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
739 XirSnippet epilogue = xir.genEpilogue(site(x), compilation.method);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
740 if (epilogue != null) {
2775
3b73b230b86b Removed more stateAfter usages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2774
diff changeset
741 emitXir(epilogue, x, null, compilation.method, false);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
742 lir.returnOp(result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
743 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
744 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
745 setNoResult(x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
746 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
747
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
748 protected XirArgument toXirArgument(CiValue v) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
749 if (v == null) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
750 return null;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
751 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
752
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
753 return XirArgument.forInternalObject(v);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
754 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
755
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
756 protected XirArgument toXirArgument(Value i) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
757 if (i == null) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
758 return null;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
759 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
760
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
761 return XirArgument.forInternalObject(new LIRItem(i, this));
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
762 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
763
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
764 private CiValue allocateOperand(XirSnippet snippet, XirOperand op) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
765 if (op instanceof XirParameter) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
766 XirParameter param = (XirParameter) op;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
767 return allocateOperand(snippet.arguments[param.parameterIndex], op, param.canBeConstant);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
768 } else if (op instanceof XirRegister) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
769 XirRegister reg = (XirRegister) op;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
770 return reg.register;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
771 } else if (op instanceof XirTemp) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
772 return newVariable(op.kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
773 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
774 Util.shouldNotReachHere();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
775 return null;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
776 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
777 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
778
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
779 private CiValue allocateOperand(XirArgument arg, XirOperand var, boolean canBeConstant) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
780 if (arg.constant != null) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
781 return arg.constant;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
782 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
783 assert arg.object != null;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
784 if (arg.object instanceof CiValue) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
785 return (CiValue) arg.object;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
786 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
787 assert arg.object instanceof LIRItem;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
788 LIRItem item = (LIRItem) arg.object;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
789 if (canBeConstant) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
790 return item.instruction.operand();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
791 } else {
2537
4a016ff4d2df Clean up on LIRGenerator and related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2532
diff changeset
792 CiKind kind = var.kind;
4a016ff4d2df Clean up on LIRGenerator and related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2532
diff changeset
793 if (kind == CiKind.Byte || kind == CiKind.Boolean) {
4a016ff4d2df Clean up on LIRGenerator and related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2532
diff changeset
794 item.loadByteItem();
4a016ff4d2df Clean up on LIRGenerator and related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2532
diff changeset
795 } else {
4a016ff4d2df Clean up on LIRGenerator and related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2532
diff changeset
796 item.loadItem();
4a016ff4d2df Clean up on LIRGenerator and related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2532
diff changeset
797 }
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
798 return item.result();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
799 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
800 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
801 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
802
2812
d27bdbec3d67 Removed ArrayLength from CFG. Fixed an issue when scheduling Merge instructions within a block.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2807
diff changeset
803 protected CiValue emitXir(XirSnippet snippet, Value x, LIRDebugInfo info, RiMethod method, boolean setInstructionResult) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
804 return emitXir(snippet, x, info, null, method, setInstructionResult, null);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
805 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
806
2812
d27bdbec3d67 Removed ArrayLength from CFG. Fixed an issue when scheduling Merge instructions within a block.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2807
diff changeset
807 protected CiValue emitXir(XirSnippet snippet, Value instruction, LIRDebugInfo info, LIRDebugInfo infoAfter, RiMethod method, boolean setInstructionResult, List<CiValue> pointerSlots) {
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
808 if (GraalOptions.PrintXirTemplates) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
809 TTY.println("Emit XIR template " + snippet.template.name);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
810 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
811
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
812 final CiValue[] operands = new CiValue[snippet.template.variableCount];
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
813
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
814 compilation.frameMap().reserveOutgoing(snippet.template.outgoingStackSize);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
815
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
816 XirOperand resultOperand = snippet.template.resultOperand;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
817
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
818 if (snippet.template.allocateResultOperand) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
819 CiValue outputOperand = IllegalValue;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
820 // This snippet has a result that must be separately allocated
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
821 // Otherwise it is assumed that the result is part of the inputs
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
822 if (resultOperand.kind != CiKind.Void && resultOperand.kind != CiKind.Illegal) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
823 if (setInstructionResult) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
824 outputOperand = newVariable(instruction.kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
825 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
826 outputOperand = newVariable(resultOperand.kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
827 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
828 assert operands[resultOperand.index] == null;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
829 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
830 operands[resultOperand.index] = outputOperand;
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
831 if (GraalOptions.PrintXirTemplates) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
832 TTY.println("Output operand: " + outputOperand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
833 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
834 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
835
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
836 for (XirTemp t : snippet.template.temps) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
837 if (t instanceof XirRegister) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
838 XirRegister reg = (XirRegister) t;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
839 if (!t.reserve) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
840 operands[t.index] = reg.register;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
841 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
842 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
843 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
844
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
845 for (XirTemplate calleeTemplate : snippet.template.calleeTemplates) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
846 // TODO Save these for use in X86LIRAssembler
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
847 stubFor(calleeTemplate);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
848 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
849
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
850 for (XirConstant c : snippet.template.constants) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
851 assert operands[c.index] == null;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
852 operands[c.index] = c.value;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
853 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
854
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
855 XirOperand[] inputOperands = snippet.template.inputOperands;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
856 XirOperand[] inputTempOperands = snippet.template.inputTempOperands;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
857 XirOperand[] tempOperands = snippet.template.tempOperands;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
858
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
859 CiValue[] operandArray = new CiValue[inputOperands.length + inputTempOperands.length + tempOperands.length];
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
860 int[] operandIndicesArray = new int[inputOperands.length + inputTempOperands.length + tempOperands.length];
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
861 for (int i = 0; i < inputOperands.length; i++) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
862 XirOperand x = inputOperands[i];
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
863 CiValue op = allocateOperand(snippet, x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
864 operands[x.index] = op;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
865 operandArray[i] = op;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
866 operandIndicesArray[i] = x.index;
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
867 if (GraalOptions.PrintXirTemplates) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
868 TTY.println("Input operand: " + x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
869 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
870 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
871
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
872 for (int i = 0; i < inputTempOperands.length; i++) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
873 XirOperand x = inputTempOperands[i];
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
874 CiValue op = allocateOperand(snippet, x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
875 CiValue newOp = newVariable(op.kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
876 lir.move(op, newOp);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
877 operands[x.index] = newOp;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
878 operandArray[i + inputOperands.length] = newOp;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
879 operandIndicesArray[i + inputOperands.length] = x.index;
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
880 if (GraalOptions.PrintXirTemplates) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
881 TTY.println("InputTemp operand: " + x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
882 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
883 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
884
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
885 for (int i = 0; i < tempOperands.length; i++) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
886 XirOperand x = tempOperands[i];
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
887 CiValue op = allocateOperand(snippet, x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
888 operands[x.index] = op;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
889 operandArray[i + inputOperands.length + inputTempOperands.length] = op;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
890 operandIndicesArray[i + inputOperands.length + inputTempOperands.length] = x.index;
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
891 if (GraalOptions.PrintXirTemplates) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
892 TTY.println("Temp operand: " + x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
893 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
894 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
895
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
896 for (CiValue operand : operands) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
897 assert operand != null;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
898 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
899
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
900 CiValue allocatedResultOperand = operands[resultOperand.index];
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
901 if (!allocatedResultOperand.isVariableOrRegister()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
902 allocatedResultOperand = IllegalValue;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
903 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
904
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
905 if (setInstructionResult && allocatedResultOperand.isLegal()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
906 if (instruction.operand().isIllegal()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
907 setResult(instruction, (CiVariable) allocatedResultOperand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
908 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
909 assert instruction.operand() == allocatedResultOperand;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
910 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
911 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
912
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
913
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
914 XirInstruction[] slowPath = snippet.template.slowPath;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
915 if (!operands[resultOperand.index].isConstant() || snippet.template.fastPath.length != 0 || (slowPath != null && slowPath.length > 0)) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
916 // XIR instruction is only needed when the operand is not a constant!
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
917 lir.xir(snippet, operands, allocatedResultOperand, inputTempOperands.length, tempOperands.length,
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
918 operandArray, operandIndicesArray,
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
919 (operands[resultOperand.index] == IllegalValue) ? -1 : resultOperand.index,
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
920 info, infoAfter, method, pointerSlots);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
921 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
922
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
923 return operands[resultOperand.index];
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
924 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
925
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
926 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
927 public void visitStoreField(StoreField x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
928 RiField field = x.field();
2622
91d3952f7eb7 Framestate work : using stateAFter and reducting the number of nodes with framestates. Intermediate state (does not pass tests)
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2602
diff changeset
929 LIRDebugInfo info = stateFor(x);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
930
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
931 if (x.isVolatile()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
932 vma.preVolatileWrite();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
933 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
934
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
935 XirArgument receiver = toXirArgument(x.object());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
936 XirArgument value = toXirArgument(x.value());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
937 XirSnippet snippet = x.isStatic() ? xir.genPutStatic(site(x), receiver, field, value) : xir.genPutField(site(x), receiver, field, value);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
938 emitXir(snippet, x, info, null, true);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
939
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
940 if (x.isVolatile()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
941 vma.postVolatileWrite();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
942 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
943 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
944
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
945 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
946 public void visitTableSwitch(TableSwitch x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
947
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
948 LIRItem value = new LIRItem(x.value(), this);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
949 // Making a copy of the switch value is necessary when generating a jump table
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
950 value.setDestroysRegister();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
951 value.loadItem();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
952
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
953 CiValue tag = value.result();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
954 setNoResult(x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
955
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
956 // TODO: tune the defaults for the controls used to determine what kind of translation to use
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
957 if (x.numberOfCases() == 0 || x.numberOfCases() <= GraalOptions.SequentialSwitchLimit) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
958 int loKey = x.lowKey();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
959 int len = x.numberOfCases();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
960 for (int i = 0; i < len; i++) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
961 lir.cmp(Condition.EQ, tag, i + loKey);
2922
e37f27b6af77 Changes to LIRBranch.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2920
diff changeset
962 lir.branch(Condition.EQ, getLIRBlock(x.blockSuccessor(i)));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
963 }
2725
c379183d1c54 Removed target block references from LIR to BlockBegin instructions. Now there is a getLIRBlock method in the LIRGenerator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2718
diff changeset
964 lir.jump(getLIRBlock(x.defaultSuccessor()));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
965 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
966 SwitchRange[] switchRanges = createLookupRanges(x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
967 int rangeDensity = x.numberOfCases() / switchRanges.length;
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
968 if (rangeDensity >= GraalOptions.RangeTestsSwitchDensity) {
2725
c379183d1c54 Removed target block references from LIR to BlockBegin instructions. Now there is a getLIRBlock method in the LIRGenerator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2718
diff changeset
969 visitSwitchRanges(switchRanges, tag, getLIRBlock(x.defaultSuccessor()));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
970 } else {
3007
de3ac4888421 Clean up on ControlSplit class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3001
diff changeset
971 LIRBlock[] targets = new LIRBlock[x.numberOfCases()];
de3ac4888421 Clean up on ControlSplit class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3001
diff changeset
972 for (int i = 0; i < x.numberOfCases(); ++i) {
de3ac4888421 Clean up on ControlSplit class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3001
diff changeset
973 targets[i] = getLIRBlock(x.blockSuccessor(i));
2725
c379183d1c54 Removed target block references from LIR to BlockBegin instructions. Now there is a getLIRBlock method in the LIRGenerator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2718
diff changeset
974 }
c379183d1c54 Removed target block references from LIR to BlockBegin instructions. Now there is a getLIRBlock method in the LIRGenerator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2718
diff changeset
975 lir.tableswitch(tag, x.lowKey(), getLIRBlock(x.defaultSuccessor()), targets);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
976 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
977 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
978 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
979
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
980 @Override
2671
d8601d421b96 New Deoptimize node, remove ResolveClass node and replace it with deoptimization
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2670
diff changeset
981 public void visitDeoptimize(Deoptimize deoptimize) {
2935
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2924
diff changeset
982 assert lastState != null : "deoptimize always needs a state";
3017
b4ba003eb11d Fixed unnecessary node in the graph builder.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3010
diff changeset
983 assert lastState.bci != Instruction.SYNCHRONIZATION_ENTRY_BCI : "bci must not be -1 for deopt framestate";
2935
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2924
diff changeset
984 DeoptimizationStub stub = new DeoptimizationStub(deoptimize.action(), lastState);
2671
d8601d421b96 New Deoptimize node, remove ResolveClass node and replace it with deoptimization
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2670
diff changeset
985 addDeoptimizationStub(stub);
d8601d421b96 New Deoptimize node, remove ResolveClass node and replace it with deoptimization
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2670
diff changeset
986 lir.branch(Condition.TRUE, stub.label, stub.info);
d8601d421b96 New Deoptimize node, remove ResolveClass node and replace it with deoptimization
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2670
diff changeset
987 }
d8601d421b96 New Deoptimize node, remove ResolveClass node and replace it with deoptimization
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2670
diff changeset
988
2718
c1ce2a53d6c3 Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2716
diff changeset
989 private void blockDoEpilog() {
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
990 if (GraalOptions.PrintIRWithLIR) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
991 TTY.println();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
992 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
993
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
994 // clear out variables for local constants
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
995 constants.clear();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
996 variablesForConstants.clear();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
997 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
998
2718
c1ce2a53d6c3 Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2716
diff changeset
999 private void blockDoProlog(LIRBlock block) {
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
1000 if (GraalOptions.PrintIRWithLIR) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1001 TTY.print(block.toString());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1002 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1003 // set up the list of LIR instructions
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1004 assert block.lir() == null : "LIR list already computed for this block";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1005 lir = new LIRList(this);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1006 block.setLir(lir);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1007
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1008 lir.branchDestination(block.label());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1009 if (block == ir.startBlock) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1010 XirSnippet prologue = xir.genPrologue(null, compilation.method);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1011 if (prologue != null) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1012 emitXir(prologue, null, null, null, false);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1013 }
2783
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
1014 FrameState fs = setOperandsForLocals();
2983
11dfbb40ca69 LoopCounter, WIP
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2981
diff changeset
1015 if (GraalOptions.TraceLIRGeneratorLevel >= 2) {
11dfbb40ca69 LoopCounter, WIP
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2981
diff changeset
1016 TTY.println("STATE CHANGE (setOperandsForLocals)");
11dfbb40ca69 LoopCounter, WIP
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2981
diff changeset
1017 if (GraalOptions.TraceLIRGeneratorLevel >= 3) {
11dfbb40ca69 LoopCounter, WIP
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2981
diff changeset
1018 TTY.println(fs.toString());
11dfbb40ca69 LoopCounter, WIP
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2981
diff changeset
1019 }
11dfbb40ca69 LoopCounter, WIP
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2981
diff changeset
1020 }
2783
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
1021 lastState = fs;
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
1022 } else if (block.blockPredecessors().size() == 1) {
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
1023 FrameState fs = block.blockPredecessors().get(0).lastState();
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
1024 assert fs != null;
2983
11dfbb40ca69 LoopCounter, WIP
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2981
diff changeset
1025 if (GraalOptions.TraceLIRGeneratorLevel >= 2) {
11dfbb40ca69 LoopCounter, WIP
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2981
diff changeset
1026 TTY.println("STATE CHANGE (singlePred)");
11dfbb40ca69 LoopCounter, WIP
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2981
diff changeset
1027 if (GraalOptions.TraceLIRGeneratorLevel >= 3) {
11dfbb40ca69 LoopCounter, WIP
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2981
diff changeset
1028 TTY.println(fs.toString());
11dfbb40ca69 LoopCounter, WIP
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2981
diff changeset
1029 }
11dfbb40ca69 LoopCounter, WIP
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2981
diff changeset
1030 }
2783
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
1031 lastState = fs;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1032 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1033 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1034
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1035 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1036 * Copies a given value into an operand that is forced to be a stack location.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1037 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1038 * @param value a value to be forced onto the stack
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1039 * @param kind the kind of new operand
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1040 * @param mustStayOnStack specifies if the new operand must never be allocated to a register
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1041 * @return the operand that is guaranteed to be a stack location when it is
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1042 * initially defined a by move from {@code value}
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1043 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1044 CiValue forceToSpill(CiValue value, CiKind kind, boolean mustStayOnStack) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1045 assert value.isLegal() : "value should not be illegal";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1046 assert kind.jvmSlots == value.kind.jvmSlots : "size mismatch";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1047 if (!value.isVariableOrRegister()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1048 // force into a variable that must start in memory
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1049 CiValue operand = operands.newVariable(value.kind, mustStayOnStack ? VariableFlag.MustStayInMemory : VariableFlag.MustStartInMemory);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1050 lir.move(value, operand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1051 return operand;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1052 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1053
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1054 // create a spill location
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1055 CiValue operand = operands.newVariable(kind, mustStayOnStack ? VariableFlag.MustStayInMemory : VariableFlag.MustStartInMemory);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1056 // move from register to spill
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1057 lir.move(value, operand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1058 return operand;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1059 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1060
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1061 private CiVariable loadConstant(Constant x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1062 return loadConstant(x.asConstant(), x.kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1063 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1064
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1065 protected CiVariable loadConstant(CiConstant c, CiKind kind) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1066 // XXX: linear search might be kind of slow for big basic blocks
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1067 int index = constants.indexOf(c);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1068 if (index != -1) {
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
1069 GraalMetrics.LoadConstantIterations += index;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1070 return variablesForConstants.get(index);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1071 }
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
1072 GraalMetrics.LoadConstantIterations += constants.size();
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1073
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1074 CiVariable result = newVariable(kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1075 lir.move(c, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1076 constants.add(c);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1077 variablesForConstants.add(result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1078 return result;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1079 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1080
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1081 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1082 * Allocates a variable operand to hold the result of a given instruction.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1083 * This can only be performed once for any given instruction.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1084 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1085 * @param x an instruction that produces a result
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1086 * @return the variable assigned to hold the result produced by {@code x}
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1087 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1088 protected CiVariable createResultVariable(Value x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1089 CiVariable operand = newVariable(x.kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1090 setResult(x, operand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1091 return operand;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1092 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1093
2519
f6125fb5bfbc Removed intrinsics.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2515
diff changeset
1094 @Override
f6125fb5bfbc Removed intrinsics.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2515
diff changeset
1095 public void visitRegisterFinalizer(RegisterFinalizer x) {
2628
569228710be8 More FrameState work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2623
diff changeset
1096 CiValue receiver = load(x.object());
3000
6c95d57cb1e2 Removed usage of stateBefore. Now framestate is always a successor of its associated node.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2998
diff changeset
1097 LIRDebugInfo info = stateFor(x);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1098 callRuntime(CiRuntimeCall.RegisterFinalizer, info, receiver);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1099 setNoResult(x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1100 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1101
2725
c379183d1c54 Removed target block references from LIR to BlockBegin instructions. Now there is a getLIRBlock method in the LIRGenerator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2718
diff changeset
1102 private void visitSwitchRanges(SwitchRange[] x, CiValue value, LIRBlock defaultSux) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1103 for (int i = 0; i < x.length; i++) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1104 SwitchRange oneRange = x[i];
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1105 int lowKey = oneRange.lowKey;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1106 int highKey = oneRange.highKey;
2725
c379183d1c54 Removed target block references from LIR to BlockBegin instructions. Now there is a getLIRBlock method in the LIRGenerator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2718
diff changeset
1107 LIRBlock dest = oneRange.sux;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1108 if (lowKey == highKey) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1109 lir.cmp(Condition.EQ, value, lowKey);
2922
e37f27b6af77 Changes to LIRBranch.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2920
diff changeset
1110 lir.branch(Condition.EQ, dest);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1111 } else if (highKey - lowKey == 1) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1112 lir.cmp(Condition.EQ, value, lowKey);
2922
e37f27b6af77 Changes to LIRBranch.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2920
diff changeset
1113 lir.branch(Condition.EQ, dest);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1114 lir.cmp(Condition.EQ, value, highKey);
2922
e37f27b6af77 Changes to LIRBranch.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2920
diff changeset
1115 lir.branch(Condition.EQ, dest);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1116 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1117 Label l = new Label();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1118 lir.cmp(Condition.LT, value, lowKey);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1119 lir.branch(Condition.LT, l);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1120 lir.cmp(Condition.LE, value, highKey);
2922
e37f27b6af77 Changes to LIRBranch.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2920
diff changeset
1121 lir.branch(Condition.LE, dest);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1122 lir.branchDestination(l);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1123 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1124 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1125 lir.jump(defaultSux);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1126 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1127
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1128 protected void arithmeticOpFpu(int code, CiValue result, CiValue left, CiValue right, CiValue tmp) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1129 CiValue leftOp = left;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1130
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1131 if (isTwoOperand && leftOp != result) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1132 assert right != result : "malformed";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1133 lir.move(leftOp, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1134 leftOp = result;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1135 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1136
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1137 switch (code) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1138 case DADD:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1139 case FADD:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1140 lir.add(leftOp, right, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1141 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1142 case FMUL:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1143 case DMUL:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1144 lir.mul(leftOp, right, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1145 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1146 case DSUB:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1147 case FSUB:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1148 lir.sub(leftOp, right, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1149 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1150 case FDIV:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1151 case DDIV:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1152 lir.div(leftOp, right, result, null);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1153 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1154 default:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1155 Util.shouldNotReachHere();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1156 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1157 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1158
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1159 protected void arithmeticOpInt(int code, CiValue result, CiValue left, CiValue right, CiValue tmp) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1160 CiValue leftOp = left;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1161
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1162 if (isTwoOperand && leftOp != result) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1163 assert right != result : "malformed";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1164 lir.move(leftOp, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1165 leftOp = result;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1166 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1167
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1168 switch (code) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1169 case IADD:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1170 lir.add(leftOp, right, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1171 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1172 case IMUL:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1173 boolean didStrengthReduce = false;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1174 if (right.isConstant()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1175 CiConstant rightConstant = (CiConstant) right;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1176 int c = rightConstant.asInt();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1177 if (CiUtil.isPowerOf2(c)) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1178 // do not need tmp here
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1179 lir.shiftLeft(leftOp, CiUtil.log2(c), result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1180 didStrengthReduce = true;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1181 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1182 didStrengthReduce = strengthReduceMultiply(leftOp, c, result, tmp);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1183 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1184 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1185 // we couldn't strength reduce so just emit the multiply
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1186 if (!didStrengthReduce) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1187 lir.mul(leftOp, right, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1188 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1189 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1190 case ISUB:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1191 lir.sub(leftOp, right, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1192 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1193 default:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1194 // idiv and irem are handled elsewhere
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1195 Util.shouldNotReachHere();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1196 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1197 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1198
2981
42681ed31c4d Some LoopCounter work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2948
diff changeset
1199 protected void arithmeticOpLong(int code, CiValue result, CiValue left, CiValue right) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1200 CiValue leftOp = left;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1201
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1202 if (isTwoOperand && leftOp != result) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1203 assert right != result : "malformed";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1204 lir.move(leftOp, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1205 leftOp = result;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1206 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1207
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1208 switch (code) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1209 case LADD:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1210 lir.add(leftOp, right, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1211 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1212 case LMUL:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1213 lir.mul(leftOp, right, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1214 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1215 case LSUB:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1216 lir.sub(leftOp, right, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1217 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1218 default:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1219 // ldiv and lrem are handled elsewhere
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1220 Util.shouldNotReachHere();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1221 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1222 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1223
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1224 protected final CiValue callRuntime(CiRuntimeCall runtimeCall, LIRDebugInfo info, CiValue... args) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1225 // get a result register
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1226 CiKind result = runtimeCall.resultKind;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1227 CiKind[] arguments = runtimeCall.arguments;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1228
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1229 CiValue physReg = result.isVoid() ? IllegalValue : resultOperandFor(result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1230
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1231 List<CiValue> argumentList;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1232 if (arguments.length > 0) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1233 // move the arguments into the correct location
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1234 CiCallingConvention cc = compilation.frameMap().getCallingConvention(arguments, RuntimeCall);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1235 assert cc.locations.length == args.length : "argument count mismatch";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1236 for (int i = 0; i < args.length; i++) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1237 CiValue arg = args[i];
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1238 CiValue loc = cc.locations[i];
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1239 if (loc.isRegister()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1240 lir.move(arg, loc);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1241 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1242 assert loc.isStackSlot();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1243 CiStackSlot slot = (CiStackSlot) loc;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1244 if (slot.kind == CiKind.Long || slot.kind == CiKind.Double) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1245 lir.unalignedMove(arg, slot);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1246 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1247 lir.move(arg, slot);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1248 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1249 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1250 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1251 argumentList = Arrays.asList(cc.locations);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1252 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1253 // no arguments
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1254 assert args == null || args.length == 0;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1255 argumentList = Util.uncheckedCast(Collections.emptyList());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1256 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1257
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1258 lir.callRuntime(runtimeCall, physReg, argumentList, info);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1259
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1260 return physReg;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1261 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1262
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1263 protected final CiVariable callRuntimeWithResult(CiRuntimeCall runtimeCall, LIRDebugInfo info, CiValue... args) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1264 CiVariable result = newVariable(runtimeCall.resultKind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1265 CiValue location = callRuntime(runtimeCall, info, args);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1266 lir.move(location, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1267 return result;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1268 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1269
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1270 SwitchRange[] createLookupRanges(LookupSwitch x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1271 // we expect the keys to be sorted by increasing value
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1272 List<SwitchRange> res = new ArrayList<SwitchRange>(x.numberOfCases());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1273 int len = x.numberOfCases();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1274 if (len > 0) {
2725
c379183d1c54 Removed target block references from LIR to BlockBegin instructions. Now there is a getLIRBlock method in the LIRGenerator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2718
diff changeset
1275 LIRBlock defaultSux = getLIRBlock(x.defaultSuccessor());
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1276 int key = x.keyAt(0);
2725
c379183d1c54 Removed target block references from LIR to BlockBegin instructions. Now there is a getLIRBlock method in the LIRGenerator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2718
diff changeset
1277 LIRBlock sux = getLIRBlock(x.blockSuccessor(0));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1278 SwitchRange range = new SwitchRange(key, sux);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1279 for (int i = 1; i < len; i++) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1280 int newKey = x.keyAt(i);
2725
c379183d1c54 Removed target block references from LIR to BlockBegin instructions. Now there is a getLIRBlock method in the LIRGenerator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2718
diff changeset
1281 LIRBlock newSux = getLIRBlock(x.blockSuccessor(i));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1282 if (key + 1 == newKey && sux == newSux) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1283 // still in same range
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1284 range.highKey = newKey;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1285 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1286 // skip tests which explicitly dispatch to the default
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1287 if (range.sux != defaultSux) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1288 res.add(range);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1289 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1290 range = new SwitchRange(newKey, newSux);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1291 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1292 key = newKey;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1293 sux = newSux;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1294 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1295 if (res.size() == 0 || res.get(res.size() - 1) != range) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1296 res.add(range);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1297 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1298 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1299 return res.toArray(new SwitchRange[res.size()]);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1300 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1301
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1302 SwitchRange[] createLookupRanges(TableSwitch x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1303 // XXX: try to merge this with the code for LookupSwitch
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1304 List<SwitchRange> res = new ArrayList<SwitchRange>(x.numberOfCases());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1305 int len = x.numberOfCases();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1306 if (len > 0) {
2725
c379183d1c54 Removed target block references from LIR to BlockBegin instructions. Now there is a getLIRBlock method in the LIRGenerator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2718
diff changeset
1307 LIRBlock sux = getLIRBlock(x.blockSuccessor(0));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1308 int key = x.lowKey();
2725
c379183d1c54 Removed target block references from LIR to BlockBegin instructions. Now there is a getLIRBlock method in the LIRGenerator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2718
diff changeset
1309 LIRBlock defaultSux = getLIRBlock(x.defaultSuccessor());
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1310 SwitchRange range = new SwitchRange(key, sux);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1311 for (int i = 0; i < len; i++, key++) {
2725
c379183d1c54 Removed target block references from LIR to BlockBegin instructions. Now there is a getLIRBlock method in the LIRGenerator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2718
diff changeset
1312 LIRBlock newSux = getLIRBlock(x.blockSuccessor(i));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1313 if (sux == newSux) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1314 // still in same range
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1315 range.highKey = key;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1316 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1317 // skip tests which explicitly dispatch to the default
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1318 if (sux != defaultSux) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1319 res.add(range);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1320 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1321 range = new SwitchRange(key, newSux);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1322 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1323 sux = newSux;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1324 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1325 if (res.size() == 0 || res.get(res.size() - 1) != range) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1326 res.add(range);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1327 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1328 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1329 return res.toArray(new SwitchRange[res.size()]);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1330 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1331
2801
2af109bec0c0 Make block contains a list of nodes instead a list of instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2796
diff changeset
1332 void doRoot(Value instr) {
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
1333 if (GraalOptions.TraceLIRGeneratorLevel >= 2) {
2801
2af109bec0c0 Make block contains a list of nodes instead a list of instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2796
diff changeset
1334 TTY.println("Emitting LIR for instruction " + instr);
2623
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
1335 }
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1336 currentInstruction = instr;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1337
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
1338 if (GraalOptions.TraceLIRVisit) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1339 TTY.println("Visiting " + instr);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1340 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1341 instr.accept(this);
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
1342 if (GraalOptions.TraceLIRVisit) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1343 TTY.println("Operand for " + instr + " = " + instr.operand());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1344 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1345 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1346
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1347 protected void logicOp(int code, CiValue resultOp, CiValue leftOp, CiValue rightOp) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1348 if (isTwoOperand && leftOp != resultOp) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1349 assert rightOp != resultOp : "malformed";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1350 lir.move(leftOp, resultOp);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1351 leftOp = resultOp;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1352 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1353
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1354 switch (code) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1355 case IAND:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1356 case LAND:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1357 lir.logicalAnd(leftOp, rightOp, resultOp);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1358 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1359
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1360 case IOR:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1361 case LOR:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1362 lir.logicalOr(leftOp, rightOp, resultOp);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1363 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1364
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1365 case IXOR:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1366 case LXOR:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1367 lir.logicalXor(leftOp, rightOp, resultOp);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1368 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1369
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1370 default:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1371 Util.shouldNotReachHere();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1372 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1373 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1374
2769
dd6419f4bfe2 Fixed several issues with incorrect predecessor count/order. One known issue around exception dispatch remaining in fop.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2768
diff changeset
1375 void moveToPhi(PhiResolver resolver, Value curVal, Value suxVal, List<Phi> phis, int predIndex) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1376 // move current value to referenced phi function
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1377 if (suxVal instanceof Phi) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1378 Phi phi = (Phi) suxVal;
2769
dd6419f4bfe2 Fixed several issues with incorrect predecessor count/order. One known issue around exception dispatch remaining in fop.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2768
diff changeset
1379
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1380 // curVal can be null without phi being null in conjunction with inlining
2821
015be60afcf3 removed flags from Value class
Lukas Stadler <lukas.stadler@jku.at>
parents: 2812
diff changeset
1381 if (!phi.isDead() && curVal != null && curVal != phi) {
2769
dd6419f4bfe2 Fixed several issues with incorrect predecessor count/order. One known issue around exception dispatch remaining in fop.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2768
diff changeset
1382
dd6419f4bfe2 Fixed several issues with incorrect predecessor count/order. One known issue around exception dispatch remaining in fop.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2768
diff changeset
1383 assert phis.contains(phi);
dd6419f4bfe2 Fixed several issues with incorrect predecessor count/order. One known issue around exception dispatch remaining in fop.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2768
diff changeset
1384 if (phi.valueAt(predIndex) != curVal) {
dd6419f4bfe2 Fixed several issues with incorrect predecessor count/order. One known issue around exception dispatch remaining in fop.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2768
diff changeset
1385 phi.print(TTY.out());
dd6419f4bfe2 Fixed several issues with incorrect predecessor count/order. One known issue around exception dispatch remaining in fop.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2768
diff changeset
1386 }
dd6419f4bfe2 Fixed several issues with incorrect predecessor count/order. One known issue around exception dispatch remaining in fop.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2768
diff changeset
1387 assert phi.valueAt(predIndex) == curVal : "curVal=" + curVal + "valueAt(" + predIndex + ")=" + phi.valueAt(predIndex);
dd6419f4bfe2 Fixed several issues with incorrect predecessor count/order. One known issue around exception dispatch remaining in fop.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2768
diff changeset
1388
2821
015be60afcf3 removed flags from Value class
Lukas Stadler <lukas.stadler@jku.at>
parents: 2812
diff changeset
1389 assert !phi.isDead() : "illegal phi cannot be marked as live";
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1390 if (curVal instanceof Phi) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1391 operandForPhi((Phi) curVal);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1392 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1393 CiValue operand = curVal.operand();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1394 if (operand.isIllegal()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1395 assert curVal instanceof Constant || curVal instanceof Local : "these can be produced lazily";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1396 operand = operandForInstruction(curVal);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1397 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1398 resolver.move(operand, operandForPhi(phi));
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1399 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1400 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1401 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1402
2768
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1403 private List<Phi> getPhis(LIRBlock block) {
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1404 if (block.getInstructions().size() > 0) {
2806
f35c6f8f0f5d Fixed two regressions due to the flexible scheduling.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2805
diff changeset
1405 Node i = block.firstInstruction();
2793
d3fc4fe063bf Rename BlockBegin to Merge, remove some Block related member from it. Made CFGPrinter work with the Block class from schedule
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2789
diff changeset
1406 if (i instanceof Merge) {
2768
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1407 List<Phi> result = new ArrayList<Phi>();
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1408 for (Node n : i.usages()) {
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1409 if (n instanceof Phi) {
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1410 result.add((Phi) n);
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1411 }
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1412 }
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1413 return result;
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1414 }
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1415 }
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1416 return null;
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1417 }
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1418
2974
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1419 @Override
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1420 public void visitEndNode(EndNode end) {
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1421 setNoResult(end);
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1422 Merge merge = end.merge();
2998
775881292ddb Made Deoptimize instruction into FixedNode instead of Instruction.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2996
diff changeset
1423 assert merge != null;
2974
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1424 moveToPhi(merge, merge.endIndex(end));
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1425 lir.jump(getLIRBlock(end.merge()));
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1426 }
2768
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1427
3010
ac6fb0c93ffb Towards lowering (example lowering for field access).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3007
diff changeset
1428 @Override
ac6fb0c93ffb Towards lowering (example lowering for field access).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3007
diff changeset
1429 public void visitMemoryRead(MemoryRead memRead) {
ac6fb0c93ffb Towards lowering (example lowering for field access).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3007
diff changeset
1430 if (memRead.guard() != null) {
ac6fb0c93ffb Towards lowering (example lowering for field access).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3007
diff changeset
1431 emitGuardComp(memRead.guard());
ac6fb0c93ffb Towards lowering (example lowering for field access).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3007
diff changeset
1432 }
ac6fb0c93ffb Towards lowering (example lowering for field access).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3007
diff changeset
1433 lir.move(new CiAddress(memRead.valueKind(), load(memRead.location()), memRead.displacement()), createResultVariable(memRead), memRead.valueKind());
ac6fb0c93ffb Towards lowering (example lowering for field access).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3007
diff changeset
1434 }
ac6fb0c93ffb Towards lowering (example lowering for field access).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3007
diff changeset
1435
2768
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1436
2974
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1437 @Override
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1438 public void visitLoopEnd(LoopEnd x) {
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1439 setNoResult(x);
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1440 moveToPhi(x.loopBegin(), x.loopBegin().endCount());
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1441 lir.jump(getLIRBlock(x.loopBegin()));
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1442 }
2768
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1443
2974
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1444 private void moveToPhi(Merge merge, int nextSuccIndex) {
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1445 PhiResolver resolver = new PhiResolver(this);
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1446 for (Node n : merge.usages()) {
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1447 if (n instanceof Phi) {
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1448 Phi phi = (Phi) n;
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1449 if (!phi.isDead()) {
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1450 Value curVal = phi.valueAt(nextSuccIndex);
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1451 if (curVal != null && curVal != phi) {
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1452 if (curVal instanceof Phi) {
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1453 operandForPhi((Phi) curVal);
2768
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1454 }
2974
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1455 CiValue operand = curVal.operand();
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1456 if (operand.isIllegal()) {
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1457 assert curVal instanceof Constant || curVal instanceof Local : "these can be produced lazily" + curVal + "/" + phi;
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1458 operand = operandForInstruction(curVal);
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1459 }
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1460 resolver.move(operand, operandForPhi(phi));
2768
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1461 }
2960
49a8b14e9d24 Tentative change that adds successor tags.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2948
diff changeset
1462 }
49a8b14e9d24 Tentative change that adds successor tags.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2948
diff changeset
1463 }
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1464 }
2974
d69b4d2eb499 Cleaned up code around moveToPhi. The function is now explicitely called for EndNode and LoopEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2972
diff changeset
1465 resolver.dispose();
2984
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2976 2983
diff changeset
1466 //TODO (gd) remove that later
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2976 2983
diff changeset
1467 if (merge instanceof LoopBegin) {
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2976 2983
diff changeset
1468 for (Node usage : merge.usages()) {
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2976 2983
diff changeset
1469 if (usage instanceof LoopCounter) {
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2976 2983
diff changeset
1470 LoopCounter counter = (LoopCounter) usage;
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2976 2983
diff changeset
1471 if (counter.operand().isIllegal()) {
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2976 2983
diff changeset
1472 createResultVariable(counter);
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2976 2983
diff changeset
1473 }
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2976 2983
diff changeset
1474 if (nextSuccIndex == 0) { // (gd) nasty
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2976 2983
diff changeset
1475 lir.move(operandForInstruction(counter.init()), counter.operand());
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2976 2983
diff changeset
1476 } else {
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2976 2983
diff changeset
1477 if (counter.kind == CiKind.Int) {
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2976 2983
diff changeset
1478 this.arithmeticOpInt(IADD, counter.operand(), counter.operand(), operandForInstruction(counter.stride()), CiValue.IllegalValue);
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2976 2983
diff changeset
1479 } else {
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2976 2983
diff changeset
1480 assert counter.kind == CiKind.Long;
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2976 2983
diff changeset
1481 this.arithmeticOpLong(LADD, counter.operand(), counter.operand(), operandForInstruction(counter.stride()));
2981
42681ed31c4d Some LoopCounter work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2948
diff changeset
1482 }
42681ed31c4d Some LoopCounter work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2948
diff changeset
1483 }
2768
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1484 }
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1485 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1486 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1487 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1488
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1489 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1490 * Creates a new {@linkplain CiVariable variable}.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1491 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1492 * @param kind the kind of the variable
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1493 * @return a new variable
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1494 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1495 public CiVariable newVariable(CiKind kind) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1496 return operands.newVariable(kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1497 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1498
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1499 CiValue operandForInstruction(Value x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1500 CiValue operand = x.operand();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1501 if (operand.isIllegal()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1502 if (x instanceof Constant) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1503 x.setOperand(x.asConstant());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1504 } else {
2981
42681ed31c4d Some LoopCounter work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2948
diff changeset
1505 assert x instanceof Phi || x instanceof Local : "only for Phi and Local : " + x;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1506 // allocate a variable for this local or phi
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1507 createResultVariable(x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1508 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1509 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1510 return x.operand();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1511 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1512
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1513 private CiValue operandForPhi(Phi phi) {
2868
6d24c27902a2 turned inlining into a phase, some node cloning fixes, added NodeWorklist
Lukas Stadler <lukas.stadler@jku.at>
parents: 2852
diff changeset
1514 assert !phi.isDead() : "dead phi: " + phi.id();
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1515 if (phi.operand().isIllegal()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1516 // allocate a variable for this phi
2981
42681ed31c4d Some LoopCounter work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2948
diff changeset
1517 createResultVariable(phi);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1518 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1519 return phi.operand();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1520 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1521
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1522 protected void postGCWriteBarrier(CiValue addr, CiValue newVal) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1523 XirSnippet writeBarrier = xir.genWriteBarrier(toXirArgument(addr));
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1524 if (writeBarrier != null) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1525 emitXir(writeBarrier, null, null, null, false);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1526 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1527 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1528
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1529 protected void preGCWriteBarrier(CiValue addrOpr, boolean patch, LIRDebugInfo info) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1530 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1531
2847
caf55daa41dc Fixed/FLoating Node
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2826
diff changeset
1532 protected void setNoResult(Value x) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1533 x.clearOperand();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1534 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1535
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1536 protected CiValue setResult(Value x, CiVariable operand) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1537 x.setOperand(operand);
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
1538 if (GraalOptions.DetailedAsserts) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1539 operands.recordResult(operand, x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1540 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1541 return operand;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1542 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1543
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1544 protected void shiftOp(int code, CiValue resultOp, CiValue value, CiValue count, CiValue tmp) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1545 if (isTwoOperand && value != resultOp) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1546 assert count != resultOp : "malformed";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1547 lir.move(value, resultOp);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1548 value = resultOp;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1549 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1550
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1551 assert count.isConstant() || count.isVariableOrRegister();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1552 switch (code) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1553 case ISHL:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1554 case LSHL:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1555 lir.shiftLeft(value, count, resultOp, tmp);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1556 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1557 case ISHR:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1558 case LSHR:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1559 lir.shiftRight(value, count, resultOp, tmp);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1560 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1561 case IUSHR:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1562 case LUSHR:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1563 lir.unsignedShiftRight(value, count, resultOp, tmp);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1564 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1565 default:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1566 Util.shouldNotReachHere();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1567 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1568 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1569
2801
2af109bec0c0 Make block contains a list of nodes instead a list of instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2796
diff changeset
1570 protected void walkState(Node x, FrameState state) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1571 if (state == null) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1572 return;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1573 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1574 for (int index = 0; index < state.stackSize(); index++) {
2622
91d3952f7eb7 Framestate work : using stateAFter and reducting the number of nodes with framestates. Intermediate state (does not pass tests)
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2602
diff changeset
1575 Value value = state.stackAt(index);
91d3952f7eb7 Framestate work : using stateAFter and reducting the number of nodes with framestates. Intermediate state (does not pass tests)
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2602
diff changeset
1576 if (value != x) {
91d3952f7eb7 Framestate work : using stateAFter and reducting the number of nodes with framestates. Intermediate state (does not pass tests)
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2602
diff changeset
1577 walkStateValue(value);
91d3952f7eb7 Framestate work : using stateAFter and reducting the number of nodes with framestates. Intermediate state (does not pass tests)
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2602
diff changeset
1578 }
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1579 }
2716
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
1580 for (int index = 0; index < state.localsSize(); index++) {
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
1581 final Value value = state.localAt(index);
2564
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2546
diff changeset
1582 if (value != null) {
2821
015be60afcf3 removed flags from Value class
Lukas Stadler <lukas.stadler@jku.at>
parents: 2812
diff changeset
1583 if (!(value instanceof Phi && ((Phi) value).isDead())) {
2564
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2546
diff changeset
1584 walkStateValue(value);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1585 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1586 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1587 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1588 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1589
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1590 private void walkStateValue(Value value) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1591 if (value != null) {
2821
015be60afcf3 removed flags from Value class
Lukas Stadler <lukas.stadler@jku.at>
parents: 2812
diff changeset
1592 if (value instanceof Phi && !((Phi) value).isDead()) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1593 // phi's are special
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1594 operandForPhi((Phi) value);
2515
4fdef1464592 Removed extended bytecodes and related HIR instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2509
diff changeset
1595 } else if (value.operand().isIllegal()) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1596 // instruction doesn't have an operand yet
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1597 CiValue operand = makeOperand(value);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1598 assert operand.isLegal() : "must be evaluated now";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1599 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1600 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1601 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1602
2805
c3f64b66fc78 Towards removing the next pointer from Constant and ArithmeticOp
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2801
diff changeset
1603 protected LIRDebugInfo stateFor(Value x) {
2622
91d3952f7eb7 Framestate work : using stateAFter and reducting the number of nodes with framestates. Intermediate state (does not pass tests)
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2602
diff changeset
1604 assert lastState != null : "must have state before instruction for " + x;
91d3952f7eb7 Framestate work : using stateAFter and reducting the number of nodes with framestates. Intermediate state (does not pass tests)
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2602
diff changeset
1605 return stateFor(x, lastState);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1606 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1607
2805
c3f64b66fc78 Towards removing the next pointer from Constant and ArithmeticOp
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2801
diff changeset
1608 protected LIRDebugInfo stateFor(Value x, FrameState state) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1609 if (compilation.placeholderState != null) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1610 state = compilation.placeholderState;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1611 }
2833
1cd59ca9ac86 Removed Throw HIR instruction. Removed special handling for exceptions in register allocator.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2826
diff changeset
1612 return new LIRDebugInfo(state);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1613 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1614
2596
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
1615 List<CiValue> visitInvokeArguments(CiCallingConvention cc, Invoke x, List<CiValue> pointerSlots) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1616 // for each argument, load it into the correct location
2596
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
1617 List<CiValue> argList = new ArrayList<CiValue>(x.argumentCount());
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1618 int j = 0;
2596
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
1619 for (int i = 0; i < x.argumentCount(); i++) {
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
1620 Value arg = x.argument(i);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1621 if (arg != null) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1622 CiValue operand = cc.locations[j++];
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1623 if (operand.isRegister()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1624 force(arg, operand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1625 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1626 LIRItem param = new LIRItem(arg, this);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1627 assert operand.isStackSlot();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1628 CiStackSlot slot = (CiStackSlot) operand;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1629 assert !slot.inCallerFrame();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1630 param.loadForStore(slot.kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1631 if (slot.kind == CiKind.Long || slot.kind == CiKind.Double) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1632 lir.unalignedMove(param.result(), slot);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1633 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1634 lir.move(param.result(), slot);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1635 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1636
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1637 if (arg.kind == CiKind.Object && pointerSlots != null) {
2596
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
1638 // This slot must be marked explicitly in the pointer map.
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1639 pointerSlots.add(slot);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1640 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1641 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1642 argList.add(operand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1643 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1644 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1645 return argList;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1646 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1647
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1648 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1649 * Ensures that an operand has been {@linkplain Value#setOperand(CiValue) initialized}
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1650 * for storing the result of an instruction.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1651 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1652 * @param instruction an instruction that produces a result value
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1653 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1654 protected CiValue makeOperand(Value instruction) {
2537
4a016ff4d2df Clean up on LIRGenerator and related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2532
diff changeset
1655 if (instruction == null) {
4a016ff4d2df Clean up on LIRGenerator and related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2532
diff changeset
1656 return CiValue.IllegalValue;
4a016ff4d2df Clean up on LIRGenerator and related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2532
diff changeset
1657 }
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1658 CiValue operand = instruction.operand();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1659 if (operand.isIllegal()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1660 if (instruction instanceof Phi) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1661 // a phi may not have an operand yet if it is for an exception block
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1662 operand = operandForPhi((Phi) instruction);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1663 } else if (instruction instanceof Constant) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1664 operand = operandForInstruction(instruction);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1665 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1666 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1667 // the value must be a constant or have a valid operand
2805
c3f64b66fc78 Towards removing the next pointer from Constant and ArithmeticOp
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2801
diff changeset
1668 assert operand.isLegal() : "this root has not been visited yet; instruction=" + instruction;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1669 return operand;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1670 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1671
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1672 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1673 * Gets the ABI specific operand used to return a value of a given kind from a method.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1674 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1675 * @param kind the kind of value being returned
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1676 * @return the operand representing the ABI defined location used return a value of kind {@code kind}
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1677 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1678 protected CiValue resultOperandFor(CiKind kind) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1679 if (kind == CiKind.Void) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1680 return IllegalValue;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1681 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1682 CiRegister returnRegister = compilation.registerConfig.getReturnRegister(kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1683 return returnRegister.asValue(kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1684 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1685
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1686 protected XirSupport site(Value x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1687 return xirSupport.site(x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1688 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1689
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1690 public void maybePrintCurrentInstruction() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1691 if (currentInstruction != null && lastInstructionPrinted != currentInstruction) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1692 lastInstructionPrinted = currentInstruction;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1693 InstructionPrinter ip = new InstructionPrinter(TTY.out());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1694 ip.printInstructionListing(currentInstruction);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1695 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1696 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1697
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1698 protected abstract boolean canInlineAsConstant(Value i);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1699
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1700 protected abstract boolean canStoreAsConstant(Value i, CiKind kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1701
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1702 protected abstract boolean strengthReduceMultiply(CiValue left, int constant, CiValue result, CiValue tmp);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1703
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1704 protected abstract CiAddress genAddress(CiValue base, CiValue index, int shift, int disp, CiKind kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1705
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1706 protected abstract void genCmpMemInt(Condition condition, CiValue base, int disp, int c, LIRDebugInfo info);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1707
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1708 protected abstract void genCmpRegMem(Condition condition, CiValue reg, CiValue base, int disp, CiKind kind, LIRDebugInfo info);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1709
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1710 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1711 * Implements site-specific information for the XIR interface.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1712 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1713 static class XirSupport implements XirSite {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1714 Value current;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1715
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1716 XirSupport() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1717 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1718
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1719 public CiCodePos getCodePos() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1720 // TODO: get the code position of the current instruction if possible
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1721 return null;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1722 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1723
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1724 public boolean isNonNull(XirArgument argument) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1725 return false;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1726 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1727
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1728 public boolean requiresNullCheck() {
2661
194d93d089bd Towards clean up of canTrap().
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2660
diff changeset
1729 return current == null || true;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1730 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1731
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1732 public boolean requiresBoundsCheck() {
2541
0f9eeb15e636 More Value.Flag clean up.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2540
diff changeset
1733 return true;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1734 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1735
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1736 public boolean requiresReadBarrier() {
2545
bb050fe2901d Fixed regression wrt write barriers.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2543
diff changeset
1737 return current == null || true;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1738 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1739
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1740 public boolean requiresWriteBarrier() {
2545
bb050fe2901d Fixed regression wrt write barriers.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2543
diff changeset
1741 return current == null || true;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1742 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1743
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1744 public boolean requiresArrayStoreCheck() {
2541
0f9eeb15e636 More Value.Flag clean up.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2540
diff changeset
1745 return true;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1746 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1747
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1748 public RiType getApproximateType(XirArgument argument) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1749 return current == null ? null : current.declaredType();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1750 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1751
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1752 public RiType getExactType(XirArgument argument) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1753 return current == null ? null : current.exactType();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1754 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1755
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1756 XirSupport site(Value v) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1757 current = v;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1758 return this;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1759 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1760
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1761 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1762 public String toString() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1763 return "XirSupport<" + current + ">";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1764 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1765
2633
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2632 2628
diff changeset
1766
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1767 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1768
2630
c93adece95d2 Small clean up.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2623
diff changeset
1769 @Override
c93adece95d2 Small clean up.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2623
diff changeset
1770 public void visitFrameState(FrameState i) {
c93adece95d2 Small clean up.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2623
diff changeset
1771 // nothing to do for now
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1772 }
2707
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
1773
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
1774 @Override
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
1775 public void visitUnwind(Unwind x) {
2784
e62cfea1c134 Simplified fillSyncHandler. Fixed LIRGenerator visitUnwind.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2783
diff changeset
1776 // move exception oop into fixed register
e62cfea1c134 Simplified fillSyncHandler. Fixed LIRGenerator visitUnwind.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2783
diff changeset
1777 CiCallingConvention callingConvention = compilation.frameMap().getCallingConvention(new CiKind[]{CiKind.Object}, RuntimeCall);
e62cfea1c134 Simplified fillSyncHandler. Fixed LIRGenerator visitUnwind.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2783
diff changeset
1778 CiValue argumentOperand = callingConvention.locations[0];
e62cfea1c134 Simplified fillSyncHandler. Fixed LIRGenerator visitUnwind.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2783
diff changeset
1779 lir.move(makeOperand(x.exception()), argumentOperand);
e62cfea1c134 Simplified fillSyncHandler. Fixed LIRGenerator visitUnwind.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2783
diff changeset
1780 List<CiValue> args = new ArrayList<CiValue>(1);
2707
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
1781 lir.callRuntime(CiRuntimeCall.UnwindException, CiValue.IllegalValue, args, null);
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
1782 setNoResult(x);
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
1783 }
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1784 }