annotate graal/GraalCompiler/src/com/sun/c1x/gen/LIRGenerator.java @ 2825:9ba6a8abe894

Fix Invoke bci problem
author Gilles Duboscq <gilles.duboscq@oracle.com>
date Mon, 30 May 2011 18:01:32 +0200
parents ac4b086cbd72
children d54ea877a302
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 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
23 package com.sun.c1x.gen;
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
2768
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
33 import com.oracle.graal.graph.*;
2677
0ea5f12e873a use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents: 2671
diff changeset
34 import com.oracle.max.asm.*;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
35 import com.sun.c1x.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
36 import com.sun.c1x.alloc.*;
2822
530366123e46 Invoke is a block end
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2796
diff changeset
37 import com.sun.c1x.alloc.OperandPool.VariableFlag;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
38 import com.sun.c1x.debug.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
39 import com.sun.c1x.globalstub.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
40 import com.sun.c1x.graph.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
41 import com.sun.c1x.ir.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
42 import com.sun.c1x.lir.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
43 import com.sun.c1x.util.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
44 import com.sun.c1x.value.*;
2716
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
45 import com.sun.cri.bytecode.*;
2822
530366123e46 Invoke is a block end
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2796
diff changeset
46 import com.sun.cri.bytecode.Bytecodes.MemoryBarriers;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
47 import com.sun.cri.ci.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
48 import com.sun.cri.ri.*;
2822
530366123e46 Invoke is a block end
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2796
diff changeset
49 import com.sun.cri.xir.CiXirAssembler.XirConstant;
530366123e46 Invoke is a block end
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2796
diff changeset
50 import com.sun.cri.xir.CiXirAssembler.XirInstruction;
530366123e46 Invoke is a block end
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2796
diff changeset
51 import com.sun.cri.xir.CiXirAssembler.XirOperand;
530366123e46 Invoke is a block end
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2796
diff changeset
52 import com.sun.cri.xir.CiXirAssembler.XirParameter;
530366123e46 Invoke is a block end
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2796
diff changeset
53 import com.sun.cri.xir.CiXirAssembler.XirRegister;
530366123e46 Invoke is a block end
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2796
diff changeset
54 import com.sun.cri.xir.CiXirAssembler.XirTemp;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
55 import com.sun.cri.xir.*;
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 * 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
59 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
60 public abstract class LIRGenerator extends ValueVisitor {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
61
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 * 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
64 * with respect to volatile field accesses.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
65 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
66 * @see MemoryBarriers
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
67 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
68 class VolatileMemoryAccess {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
69 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
70 * 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
71 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
72 void preVolatileWrite() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
73 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
74 if (compilation.target.isMP && barriers != 0) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
75 lir.membar(barriers);
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 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
78
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
79 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
80 * 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
81 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
82 void postVolatileWrite() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
83 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
84 if (compilation.target.isMP && barriers != 0) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
85 lir.membar(barriers);
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 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
88
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
89 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
90 * 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
91 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
92 void preVolatileRead() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
93 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
94 if (compilation.target.isMP && barriers != 0) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
95 lir.membar(barriers);
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 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
98
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
99 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
100 * 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
101 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
102 void postVolatileRead() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
103 // 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
104 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
105 if (compilation.target.isMP && barriers != 0) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
106 lir.membar(barriers);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
107 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
108 }
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
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
111 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
112 * 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
113 * inserting move instructions if necessary.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
114 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
115 * @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
116 * @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
117 * @return {@code register} as an operand
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 protected CiValue force(Value instruction, CiRegister register) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
120 return force(instruction, register.asValue(instruction.kind));
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
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
123 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
124 * 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
125 * inserting move instructions if necessary.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
126 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
127 * @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
128 * @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
129 * @return {@code operand}
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
130 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
131 protected CiValue force(Value instruction, CiValue operand) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
132 CiValue result = makeOperand(instruction);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
133 if (result != operand) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
134 assert result.kind != CiKind.Illegal;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
135 if (!compilation.archKindsEqual(result.kind, operand.kind)) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
136 // 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
137 CiValue tmp = forceToSpill(result, operand.kind, false);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
138 lir.move(tmp, operand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
139 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
140 lir.move(result, operand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
141 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
142 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
143 return operand;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
144 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
145
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
146 protected CiValue load(Value val) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
147 CiValue result = makeOperand(val);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
148 if (!result.isVariableOrRegister()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
149 CiVariable operand = newVariable(val.kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
150 lir.move(result, operand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
151 return operand;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
152 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
153 return result;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
154 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
155
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
156 // 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
157 private static final class SwitchRange {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
158 final int lowKey;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
159 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
160 final LIRBlock sux;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
161
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
162 SwitchRange(int lowKey, LIRBlock sux) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
163 this.lowKey = lowKey;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
164 this.highKey = lowKey;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
165 this.sux = sux;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
166 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
167 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
168
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
169 protected final C1XCompilation compilation;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
170 protected final IR ir;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
171 protected final XirSupport xirSupport;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
172 protected final RiXirGenerator xir;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
173 protected final boolean isTwoOperand;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
174
2718
c1ce2a53d6c3 Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2716
diff changeset
175 private LIRBlock currentBlock;
2507
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 public final OperandPool operands;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
178
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
179 private Value currentInstruction;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
180 private Value lastInstructionPrinted; // Debugging only
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
181
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
182 private List<CiConstant> constants;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
183 private List<CiVariable> variablesForConstants;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
184 protected LIRList lir;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
185 final VolatileMemoryAccess vma;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
186 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
187 private FrameState lastState;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
188
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
189 public LIRGenerator(C1XCompilation compilation) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
190 this.compilation = compilation;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
191 this.ir = compilation.hir();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
192 this.xir = compilation.compiler.xir;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
193 this.xirSupport = new XirSupport();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
194 this.isTwoOperand = compilation.target.arch.twoOperandMode();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
195 this.vma = new VolatileMemoryAccess();
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 constants = new ArrayList<CiConstant>();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
198 variablesForConstants = new ArrayList<CiVariable>();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
199
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
200 this.operands = new OperandPool(compilation.target);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
201 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
202
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
203 public ArrayList<DeoptimizationStub> deoptimizationStubs() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
204 return deoptimizationStubs;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
205 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
206
2671
d8601d421b96 New Deoptimize node, remove ResolveClass node and replace it with deoptimization
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2670
diff changeset
207 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
208 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
209 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
210 }
d8601d421b96 New Deoptimize node, remove ResolveClass node and replace it with deoptimization
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2670
diff changeset
211 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
212 }
d8601d421b96 New Deoptimize node, remove ResolveClass node and replace it with deoptimization
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2670
diff changeset
213
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
214 public static class DeoptimizationStub {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
215 public final Label label = new Label();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
216 public final LIRDebugInfo info;
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 public DeoptimizationStub(FrameState state) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
219 info = new LIRDebugInfo(state, null);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
220 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
221 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
222
2718
c1ce2a53d6c3 Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2716
diff changeset
223 public void doBlock(LIRBlock block) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
224 blockDoProlog(block);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
225 this.currentBlock = block;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
226
2623
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
227 if (C1XOptions.TraceLIRGeneratorLevel >= 1) {
2718
c1ce2a53d6c3 Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2716
diff changeset
228 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
229 }
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
230
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
231 if (block.blockPredecessors().size() > 1) {
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()) {
2af109bec0c0 Make block contains a list of nodes instead a list of instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2796
diff changeset
236 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
237 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
238 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
239 }
2634
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2633
diff changeset
240 FrameState stateBefore = null;
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2633
diff changeset
241 if (instr instanceof StateSplit && ((StateSplit) instr).stateBefore() != null) {
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2633
diff changeset
242 stateBefore = ((StateSplit) instr).stateBefore();
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2633
diff changeset
243 }
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2633
diff changeset
244 if (stateBefore != null) {
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2633
diff changeset
245 lastState = stateBefore;
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2633
diff changeset
246 if (C1XOptions.TraceLIRGeneratorLevel >= 2) {
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2633
diff changeset
247 TTY.println("STATE CHANGE (stateBefore)");
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2633
diff changeset
248 if (C1XOptions.TraceLIRGeneratorLevel >= 3) {
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2633
diff changeset
249 TTY.println(stateBefore.toString());
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2633
diff changeset
250 }
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2633
diff changeset
251 }
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2633
diff changeset
252 }
2801
2af109bec0c0 Make block contains a list of nodes instead a list of instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2796
diff changeset
253 if (!(instr instanceof Merge) && 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
254 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
255 doRoot((Value) instr);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
256 }
2623
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
257 if (stateAfter != null) {
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
258 lastState = stateAfter;
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
259 if (C1XOptions.TraceLIRGeneratorLevel >= 2) {
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
260 TTY.println("STATE CHANGE");
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
261 if (C1XOptions.TraceLIRGeneratorLevel >= 3) {
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
262 TTY.println(stateAfter.toString());
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
263 }
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
264 }
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
265 }
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
266 }
2822
530366123e46 Invoke is a block end
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2796
diff changeset
267 if (block.blockSuccessors().size() >= 1 && (block.getInstructions().size() == 0 || !jumpsToNextBlock(block.getInstructions().get(block.getInstructions().size() - 1)))) {
2788
df4c5254c5cc Towards goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2784
diff changeset
268 moveToPhi();
df4c5254c5cc Towards goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2784
diff changeset
269 block.lir().jump(block.blockSuccessors().get(0));
df4c5254c5cc Towards goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2784
diff changeset
270 }
2623
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
271
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
272 if (C1XOptions.TraceLIRGeneratorLevel >= 1) {
2718
c1ce2a53d6c3 Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2716
diff changeset
273 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
274 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
275
2783
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
276 block.setLastState(lastState);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
277 this.currentBlock = null;
2718
c1ce2a53d6c3 Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2716
diff changeset
278 blockDoEpilog();
2507
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
2823
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2822 2812
diff changeset
281 private static boolean jumpsToNextBlock(Node node) {
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2822 2812
diff changeset
282 return node instanceof BlockEnd;
2822
530366123e46 Invoke is a block end
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2796
diff changeset
283 }
530366123e46 Invoke is a block end
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2796
diff changeset
284
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
285 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
286 public void visitArrayLength(ArrayLength x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
287 emitArrayLength(x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
288 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
289
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
290 public CiValue emitArrayLength(ArrayLength x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
291 XirArgument array = toXirArgument(x.array());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
292 XirSnippet snippet = xir.genArrayLength(site(x), array);
2541
0f9eeb15e636 More Value.Flag clean up.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2540
diff changeset
293 emitXir(snippet, x, stateFor(x), null, true);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
294 return x.operand();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
295 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
296
2783
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
297 private FrameState setOperandsForLocals() {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
298 CiCallingConvention args = compilation.frameMap().incomingArguments();
2783
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
299 int bci = 0;
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
300 if (Modifier.isSynchronized(compilation.method.accessFlags())) {
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
301 bci = Instruction.SYNCHRONIZATION_ENTRY_BCI;
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
302 }
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
303 FrameState fs = new FrameState(bci, compilation.method.maxLocals(), 0, 0, 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();
2783
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
308 fs.storeLocal(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 }
2783
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
320 return fs;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
321 }
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 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
324 public void visitCheckCast(CheckCast x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
325 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
326 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
327 emitXir(snippet, x, stateFor(x), null, true);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
328 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
329
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
330 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
331 public void visitInstanceOf(InstanceOf x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
332 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
333 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
334 emitXir(snippet, x, stateFor(x), null, true);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
335 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
336
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
337 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
338 public void visitMonitorEnter(MonitorEnter x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
339 XirArgument obj = toXirArgument(x.object());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
340 XirArgument lockAddress = toXirArgument(x.lockAddress());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
341 XirSnippet snippet = xir.genMonitorEnter(site(x), obj, lockAddress);
2634
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2633
diff changeset
342 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
343 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
344
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
345 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
346 public void visitMonitorExit(MonitorExit x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
347 XirArgument obj = toXirArgument(x.object());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
348 XirArgument lockAddress = toXirArgument(x.lockAddress());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
349 XirSnippet snippet = xir.genMonitorExit(site(x), obj, lockAddress);
2634
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2633
diff changeset
350 emitXir(snippet, x, stateFor(x), null, true);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
351 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
352
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
353 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
354 public void visitStoreIndexed(StoreIndexed x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
355 XirArgument array = toXirArgument(x.array());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
356 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
357 XirArgument index = toXirArgument(x.index());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
358 XirArgument value = toXirArgument(x.value());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
359 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
360 emitXir(snippet, x, stateFor(x), null, true);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
361 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
362
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
363 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
364 public void visitNewInstance(NewInstance x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
365 XirSnippet snippet = xir.genNewInstance(site(x), x.instanceClass());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
366 emitXir(snippet, x, stateFor(x), null, true);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
367 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
368
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
369 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
370 public void visitNewTypeArray(NewTypeArray x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
371 XirArgument length = toXirArgument(x.length());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
372 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
373 emitXir(snippet, x, stateFor(x), null, true);
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
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
376 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
377 public void visitNewObjectArray(NewObjectArray x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
378 XirArgument length = toXirArgument(x.length());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
379 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
380 emitXir(snippet, x, stateFor(x), null, true);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
381 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
382
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
383 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
384 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
385 XirArgument[] dims = new XirArgument[x.dimensionCount()];
2507
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 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
388 dims[i] = toXirArgument(x.dimension(i));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
389 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
390
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
391 XirSnippet snippet = xir.genNewMultiArray(site(x), dims, x.elementKind);
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 visitConstant(Constant x) {
2546
e1b3db8031ee Removed liveness marking.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2545
diff changeset
397 if (!canInlineAsConstant(x)) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
398 CiValue res = x.operand();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
399 if (!(res.isLegal())) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
400 res = x.asConstant();
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 if (res.isConstant()) {
2546
e1b3db8031ee Removed liveness marking.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2545
diff changeset
403 CiVariable reg = createResultVariable(x);
e1b3db8031ee Removed liveness marking.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2545
diff changeset
404 lir.move(res, reg);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
405 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
406 setResult(x, (CiVariable) res);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
407 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
408 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
409 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
410
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
411 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
412 public void visitExceptionObject(ExceptionObject x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
413 XirSnippet snippet = xir.genExceptionObject(site(x));
2634
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2633
diff changeset
414 emitXir(snippet, x, stateFor(x), null, true);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
415 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
416
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
417 @Override
2822
530366123e46 Invoke is a block end
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2796
diff changeset
418 public void visitAnchor(Anchor x) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
419 setNoResult(x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
420
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
421 // emit phi-instruction moves after safepoint since this simplifies
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
422 // describing the state at the safepoint.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
423
2778
2ac7b30b7290 Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2775
diff changeset
424 moveToPhi();
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
425 lir.jump(getLIRBlock(x.defaultSuccessor()));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
426 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
427
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
428 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
429 public void visitIfOp(IfOp i) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
430 Value x = i.x();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
431 Value y = i.y();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
432 CiKind xtype = x.kind;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
433 CiKind ttype = i.trueValue().kind;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
434 assert xtype.isInt() || xtype.isObject() : "cannot handle others";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
435 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
436 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
437
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
438 CiValue left = load(x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
439 CiValue right = null;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
440 if (!canInlineAsConstant(y)) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
441 right = load(y);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
442 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
443 right = makeOperand(y);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
444 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
445
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
446 CiValue tVal = makeOperand(i.trueValue());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
447 CiValue fVal = makeOperand(i.falseValue());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
448 CiValue reg = createResultVariable(i);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
449
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
450 lir.cmp(i.condition(), left, right);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
451 lir.cmove(i.condition(), tVal, fVal, reg);
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
2671
d8601d421b96 New Deoptimize node, remove ResolveClass node and replace it with deoptimization
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2670
diff changeset
454 protected FrameState stateBeforeInvokeReturn(Invoke invoke) {
2716
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
455 return invoke.stateAfter().duplicateModified(getBeforeInvokeBci(invoke), invoke.kind);
2640
9e30cf6dcf96 More frame state fixes. All jtt tests passing now again.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2639
diff changeset
456 }
9e30cf6dcf96 More frame state fixes. All jtt tests passing now again.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2639
diff changeset
457
9e30cf6dcf96 More frame state fixes. All jtt tests passing now again.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2639
diff changeset
458 protected FrameState stateBeforeInvokeWithArguments(Invoke invoke) {
2666
6ca76b891d31 duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents: 2661
diff changeset
459 Value[] args = new Value[invoke.argumentCount()];
6ca76b891d31 duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents: 2661
diff changeset
460 for (int i = 0; i < invoke.argumentCount(); i++) {
6ca76b891d31 duplicateModified helper method
Lukas Stadler <lukas.stadler@jku.at>
parents: 2661
diff changeset
461 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
462 }
2716
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
463 return invoke.stateAfter().duplicateModified(getBeforeInvokeBci(invoke), invoke.kind, args);
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
464 }
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
465
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
466 private int getBeforeInvokeBci(Invoke invoke) {
2825
9ba6a8abe894 Fix Invoke bci problem
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2823
diff changeset
467 /*int length = 3;
2716
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
468 if (invoke.opcode() == Bytecodes.INVOKEINTERFACE) {
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
469 length += 2;
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
470 }
2825
9ba6a8abe894 Fix Invoke bci problem
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2823
diff changeset
471 return invoke.stateAfter().bci - length;*/
9ba6a8abe894 Fix Invoke bci problem
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2823
diff changeset
472 return invoke.bci;
2628
569228710be8 More FrameState work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2623
diff changeset
473 }
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
474
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
475 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
476 public void visitInvoke(Invoke x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
477 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
478 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
479 LIRDebugInfo info2 = stateFor(x, stateBeforeInvokeReturn(x));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
480
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
481 XirSnippet snippet = null;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
482
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
483 int opcode = x.opcode();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
484 XirArgument receiver;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
485 switch (opcode) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
486 case INVOKESTATIC:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
487 snippet = xir.genInvokeStatic(site(x), target);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
488 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
489 case INVOKESPECIAL:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
490 receiver = toXirArgument(x.receiver());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
491 snippet = xir.genInvokeSpecial(site(x), receiver, target);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
492 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
493 case INVOKEVIRTUAL:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
494 receiver = toXirArgument(x.receiver());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
495 snippet = xir.genInvokeVirtual(site(x), receiver, target);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
496 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
497 case INVOKEINTERFACE:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
498 receiver = toXirArgument(x.receiver());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
499 snippet = xir.genInvokeInterface(site(x), receiver, target);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
500 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
501 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
502
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
503 CiValue destinationAddress = null;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
504 // 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
505 // implicit calling convention between the XirSnippet and the call.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
506 if (!C1XOptions.InvokeSnippetAfterArguments) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
507 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
508 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
509
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
510 CiValue resultOperand = resultOperandFor(x.kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
511 CiCallingConvention cc = compilation.frameMap().getCallingConvention(x.signature(), JavaCall);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
512 List<CiValue> pointerSlots = new ArrayList<CiValue>(2);
2596
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
513 List<CiValue> argList = visitInvokeArguments(cc, x, pointerSlots);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
514
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
515 if (C1XOptions.InvokeSnippetAfterArguments) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
516 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
517 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
518
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
519 // 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
520 if (destinationAddress instanceof CiConstant) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
521 // Direct call
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
522 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
523 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
524 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
525 // Indirect call
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
526 argList.add(destinationAddress);
2640
9e30cf6dcf96 More frame state fixes. All jtt tests passing now again.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2639
diff changeset
527 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
528 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
529
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
530 if (resultOperand.isLegal()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
531 CiValue result = createResultVariable(x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
532 lir.move(resultOperand, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
533 }
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
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
536 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
537 public void visitMonitorAddress(MonitorAddress x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
538 CiValue result = createResultVariable(x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
539 lir.monitorAddress(x.monitor(), result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
540 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
541
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
542 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
543 * 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
544 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
545 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
546 public void visitLoadField(LoadField x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
547 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
548 LIRDebugInfo info = stateFor(x);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
549 XirArgument receiver = toXirArgument(x.object());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
550 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
551 emitXir(snippet, x, info, null, true);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
552
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
553 if (x.isVolatile()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
554 vma.postVolatileRead();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
555 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
556 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
557
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
558 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
559 public void visitLoadIndexed(LoadIndexed x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
560 XirArgument array = toXirArgument(x.array());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
561 XirArgument index = toXirArgument(x.index());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
562 XirArgument length = toXirArgument(x.length());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
563 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
564 emitXir(snippet, x, stateFor(x), null, true);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
565 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
566
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
567 protected GlobalStub stubFor(CiRuntimeCall runtimeCall) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
568 GlobalStub stub = compilation.compiler.lookupGlobalStub(runtimeCall);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
569 compilation.frameMap().usesGlobalStub(stub);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
570 return stub;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
571 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
572
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
573 protected GlobalStub stubFor(GlobalStub.Id globalStub) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
574 GlobalStub stub = compilation.compiler.lookupGlobalStub(globalStub);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
575 compilation.frameMap().usesGlobalStub(stub);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
576 return stub;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
577 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
578
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
579 protected GlobalStub stubFor(XirTemplate template) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
580 GlobalStub stub = compilation.compiler.lookupGlobalStub(template);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
581 compilation.frameMap().usesGlobalStub(stub);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
582 return stub;
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
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
585 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
586 public void visitLocal(Local x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
587 if (x.operand().isIllegal()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
588 createResultVariable(x);
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
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
592 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
593 public void visitLookupSwitch(LookupSwitch x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
594 CiValue tag = load(x.value());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
595 setNoResult(x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
596
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
597 if (x.numberOfCases() == 0 || x.numberOfCases() < C1XOptions.SequentialSwitchLimit) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
598 int len = x.numberOfCases();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
599 for (int i = 0; i < len; i++) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
600 lir.cmp(Condition.EQ, tag, 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
601 lir.branch(Condition.EQ, CiKind.Int, getLIRBlock(x.blockSuccessor(i)));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
602 }
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
603 lir.jump(getLIRBlock(x.defaultSuccessor()));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
604 } 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
605 visitSwitchRanges(createLookupRanges(x), tag, getLIRBlock(x.defaultSuccessor()));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
606 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
607 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
608
2755
80b024e75b29 small fix for dead blocks
Lukas Stadler <lukas.stadler@jku.at>
parents: 2738
diff changeset
609 protected LIRBlock getLIRBlock(Instruction b) {
2789
aeccd2af4e9e Fixes around critical edge split and placeholder removal after goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2788
diff changeset
610 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
611 if (result == null) {
aeccd2af4e9e Fixes around critical edge split and placeholder removal after goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2788
diff changeset
612 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
613 }
aeccd2af4e9e Fixes around critical edge split and placeholder removal after goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2788
diff changeset
614 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
615 }
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
616
2507
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 visitNullCheck(NullCheck x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
619 CiValue value = load(x.object());
2661
194d93d089bd Towards clean up of canTrap().
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2660
diff changeset
620 LIRDebugInfo info = stateFor(x);
194d93d089bd Towards clean up of canTrap().
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2660
diff changeset
621 lir.nullCheck(value, info);
2507
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 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
625 public void visitPhi(Phi i) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
626 Util.shouldNotReachHere();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
627 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
628
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
629 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
630 public void visitReturn(Return x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
631 if (x.kind.isVoid()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
632 XirSnippet epilogue = xir.genEpilogue(site(x), compilation.method);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
633 if (epilogue != null) {
2775
3b73b230b86b Removed more stateAfter usages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2774
diff changeset
634 emitXir(epilogue, x, null, compilation.method, false);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
635 lir.returnOp(IllegalValue);
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 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
638 CiValue operand = resultOperandFor(x.kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
639 CiValue result = force(x.result(), operand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
640 XirSnippet epilogue = xir.genEpilogue(site(x), compilation.method);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
641 if (epilogue != null) {
2775
3b73b230b86b Removed more stateAfter usages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2774
diff changeset
642 emitXir(epilogue, x, null, compilation.method, false);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
643 lir.returnOp(result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
644 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
645 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
646 setNoResult(x);
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
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
649 protected XirArgument toXirArgument(CiValue v) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
650 if (v == null) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
651 return null;
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 return XirArgument.forInternalObject(v);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
655 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
656
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
657 protected XirArgument toXirArgument(Value i) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
658 if (i == null) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
659 return null;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
660 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
661
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
662 return XirArgument.forInternalObject(new LIRItem(i, this));
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
663 }
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 private CiValue allocateOperand(XirSnippet snippet, XirOperand op) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
666 if (op instanceof XirParameter) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
667 XirParameter param = (XirParameter) op;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
668 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
669 } else if (op instanceof XirRegister) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
670 XirRegister reg = (XirRegister) op;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
671 return reg.register;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
672 } else if (op instanceof XirTemp) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
673 return newVariable(op.kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
674 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
675 Util.shouldNotReachHere();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
676 return null;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
677 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
678 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
679
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
680 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
681 if (arg.constant != null) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
682 return arg.constant;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
683 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
684 assert arg.object != null;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
685 if (arg.object instanceof CiValue) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
686 return (CiValue) arg.object;
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 assert arg.object instanceof LIRItem;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
689 LIRItem item = (LIRItem) arg.object;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
690 if (canBeConstant) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
691 return item.instruction.operand();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
692 } else {
2537
4a016ff4d2df Clean up on LIRGenerator and related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2532
diff changeset
693 CiKind kind = var.kind;
4a016ff4d2df Clean up on LIRGenerator and related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2532
diff changeset
694 if (kind == CiKind.Byte || kind == CiKind.Boolean) {
4a016ff4d2df Clean up on LIRGenerator and related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2532
diff changeset
695 item.loadByteItem();
4a016ff4d2df Clean up on LIRGenerator and related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2532
diff changeset
696 } else {
4a016ff4d2df Clean up on LIRGenerator and related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2532
diff changeset
697 item.loadItem();
4a016ff4d2df Clean up on LIRGenerator and related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2532
diff changeset
698 }
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
699 return item.result();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
700 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
701 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
702 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
703
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
704 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
705 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
706 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
707
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
708 protected CiValue emitXir(XirSnippet snippet, Value instruction, LIRDebugInfo info, LIRDebugInfo infoAfter, RiMethod method, boolean setInstructionResult, List<CiValue> pointerSlots) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
709 if (C1XOptions.PrintXirTemplates) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
710 TTY.println("Emit XIR template " + snippet.template.name);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
711 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
712
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
713 final CiValue[] operands = new CiValue[snippet.template.variableCount];
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
714
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
715 compilation.frameMap().reserveOutgoing(snippet.template.outgoingStackSize);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
716
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
717 XirOperand resultOperand = snippet.template.resultOperand;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
718
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
719 if (snippet.template.allocateResultOperand) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
720 CiValue outputOperand = IllegalValue;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
721 // 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
722 // 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
723 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
724 if (setInstructionResult) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
725 outputOperand = newVariable(instruction.kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
726 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
727 outputOperand = newVariable(resultOperand.kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
728 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
729 assert operands[resultOperand.index] == null;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
730 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
731 operands[resultOperand.index] = outputOperand;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
732 if (C1XOptions.PrintXirTemplates) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
733 TTY.println("Output operand: " + outputOperand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
734 }
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
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
737 for (XirTemp t : snippet.template.temps) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
738 if (t instanceof XirRegister) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
739 XirRegister reg = (XirRegister) t;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
740 if (!t.reserve) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
741 operands[t.index] = reg.register;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
742 }
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
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
746 for (XirTemplate calleeTemplate : snippet.template.calleeTemplates) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
747 // TODO Save these for use in X86LIRAssembler
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
748 stubFor(calleeTemplate);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
749 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
750
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
751 for (XirConstant c : snippet.template.constants) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
752 assert operands[c.index] == null;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
753 operands[c.index] = c.value;
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 XirOperand[] inputOperands = snippet.template.inputOperands;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
757 XirOperand[] inputTempOperands = snippet.template.inputTempOperands;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
758 XirOperand[] tempOperands = snippet.template.tempOperands;
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 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
761 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
762 for (int i = 0; i < inputOperands.length; i++) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
763 XirOperand x = inputOperands[i];
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
764 CiValue op = allocateOperand(snippet, x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
765 operands[x.index] = op;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
766 operandArray[i] = op;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
767 operandIndicesArray[i] = x.index;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
768 if (C1XOptions.PrintXirTemplates) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
769 TTY.println("Input operand: " + x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
770 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
771 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
772
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
773 for (int i = 0; i < inputTempOperands.length; i++) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
774 XirOperand x = inputTempOperands[i];
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
775 CiValue op = allocateOperand(snippet, x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
776 CiValue newOp = newVariable(op.kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
777 lir.move(op, newOp);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
778 operands[x.index] = newOp;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
779 operandArray[i + inputOperands.length] = newOp;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
780 operandIndicesArray[i + inputOperands.length] = x.index;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
781 if (C1XOptions.PrintXirTemplates) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
782 TTY.println("InputTemp operand: " + x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
783 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
784 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
785
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
786 for (int i = 0; i < tempOperands.length; i++) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
787 XirOperand x = tempOperands[i];
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
788 CiValue op = allocateOperand(snippet, x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
789 operands[x.index] = op;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
790 operandArray[i + inputOperands.length + inputTempOperands.length] = op;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
791 operandIndicesArray[i + inputOperands.length + inputTempOperands.length] = x.index;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
792 if (C1XOptions.PrintXirTemplates) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
793 TTY.println("Temp operand: " + x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
794 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
795 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
796
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
797 for (CiValue operand : operands) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
798 assert operand != null;
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 CiValue allocatedResultOperand = operands[resultOperand.index];
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
802 if (!allocatedResultOperand.isVariableOrRegister()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
803 allocatedResultOperand = IllegalValue;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
804 }
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 if (setInstructionResult && allocatedResultOperand.isLegal()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
807 if (instruction.operand().isIllegal()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
808 setResult(instruction, (CiVariable) allocatedResultOperand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
809 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
810 assert instruction.operand() == allocatedResultOperand;
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 }
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
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
815 XirInstruction[] slowPath = snippet.template.slowPath;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
816 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
817 // 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
818 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
819 operandArray, operandIndicesArray,
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
820 (operands[resultOperand.index] == IllegalValue) ? -1 : resultOperand.index,
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
821 info, infoAfter, method, pointerSlots);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
822 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
823
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
824 return operands[resultOperand.index];
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
825 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
826
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
827 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
828 public void visitStoreField(StoreField x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
829 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
830 LIRDebugInfo info = stateFor(x);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
831
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
832 if (x.isVolatile()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
833 vma.preVolatileWrite();
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 XirArgument receiver = toXirArgument(x.object());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
837 XirArgument value = toXirArgument(x.value());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
838 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
839 emitXir(snippet, x, info, null, true);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
840
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
841 if (x.isVolatile()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
842 vma.postVolatileWrite();
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
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
846 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
847 public void visitTableSwitch(TableSwitch x) {
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 LIRItem value = new LIRItem(x.value(), this);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
850 // 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
851 value.setDestroysRegister();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
852 value.loadItem();
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 CiValue tag = value.result();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
855 setNoResult(x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
856
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
857 // TODO: tune the defaults for the controls used to determine what kind of translation to use
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
858 if (x.numberOfCases() == 0 || x.numberOfCases() <= C1XOptions.SequentialSwitchLimit) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
859 int loKey = x.lowKey();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
860 int len = x.numberOfCases();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
861 for (int i = 0; i < len; i++) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
862 lir.cmp(Condition.EQ, tag, i + loKey);
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
863 lir.branch(Condition.EQ, CiKind.Int, getLIRBlock(x.blockSuccessor(i)));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
864 }
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
865 lir.jump(getLIRBlock(x.defaultSuccessor()));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
866 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
867 SwitchRange[] switchRanges = createLookupRanges(x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
868 int rangeDensity = x.numberOfCases() / switchRanges.length;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
869 if (rangeDensity >= C1XOptions.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
870 visitSwitchRanges(switchRanges, tag, getLIRBlock(x.defaultSuccessor()));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
871 } else {
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
872 List<Instruction> nonDefaultSuccessors = x.blockSuccessors().subList(0, x.numberOfCases());
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
873 LIRBlock[] targets = new LIRBlock[nonDefaultSuccessors.size()];
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
874 for (int i = 0; i < nonDefaultSuccessors.size(); ++i) {
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
875 targets[i] = getLIRBlock(nonDefaultSuccessors.get(i));
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
876 }
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
877 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
878 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
879 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
880 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
881
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
882 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
883 public void visitThrow(Throw x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
884 setNoResult(x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
885 CiValue exceptionOpr = load(x.exception());
2639
8e96b2b3a866 Added stateBefore to Throw instruction.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2637
diff changeset
886 LIRDebugInfo info = stateFor(x, x.stateBefore());
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
887
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
888 // move exception oop into fixed register
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
889 CiCallingConvention callingConvention = compilation.frameMap().getCallingConvention(new CiKind[]{CiKind.Object}, RuntimeCall);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
890 CiValue argumentOperand = callingConvention.locations[0];
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
891 lir.move(exceptionOpr, argumentOperand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
892
2660
9f557e940180 Removed exception optimization that immediately unwinds if it is guaranteed that there is no local exception handler.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2658
diff changeset
893 lir.throwException(CiValue.IllegalValue, argumentOperand, info);
2507
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
2671
d8601d421b96 New Deoptimize node, remove ResolveClass node and replace it with deoptimization
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2670
diff changeset
896 @Override
d8601d421b96 New Deoptimize node, remove ResolveClass node and replace it with deoptimization
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2670
diff changeset
897 public void visitDeoptimize(Deoptimize deoptimize) {
2709
7b7dbe19fafb Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2677
diff changeset
898 DeoptimizationStub stub = new DeoptimizationStub(lastState);
2671
d8601d421b96 New Deoptimize node, remove ResolveClass node and replace it with deoptimization
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2670
diff changeset
899 addDeoptimizationStub(stub);
d8601d421b96 New Deoptimize node, remove ResolveClass node and replace it with deoptimization
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2670
diff changeset
900 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
901 }
d8601d421b96 New Deoptimize node, remove ResolveClass node and replace it with deoptimization
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2670
diff changeset
902
2718
c1ce2a53d6c3 Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2716
diff changeset
903 private void blockDoEpilog() {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
904 if (C1XOptions.PrintIRWithLIR) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
905 TTY.println();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
906 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
907
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
908 // clear out variables for local constants
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
909 constants.clear();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
910 variablesForConstants.clear();
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
2718
c1ce2a53d6c3 Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2716
diff changeset
913 private void blockDoProlog(LIRBlock block) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
914 if (C1XOptions.PrintIRWithLIR) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
915 TTY.print(block.toString());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
916 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
917 // set up the list of LIR instructions
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
918 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
919 lir = new LIRList(this);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
920 block.setLir(lir);
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 lir.branchDestination(block.label());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
923 if (block == ir.startBlock) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
924 XirSnippet prologue = xir.genPrologue(null, compilation.method);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
925 if (prologue != null) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
926 emitXir(prologue, null, null, null, false);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
927 }
2783
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
928 FrameState fs = setOperandsForLocals();
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
929 lastState = fs;
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
930 } else if (block.blockPredecessors().size() == 1) {
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
931 FrameState fs = block.blockPredecessors().get(0).lastState();
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
932 assert fs != null;
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
933 lastState = fs;
2507
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 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
936
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
937 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
938 * 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
939 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
940 * @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
941 * @param kind the kind of new operand
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
942 * @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
943 * @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
944 * initially defined a by move from {@code value}
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
945 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
946 CiValue forceToSpill(CiValue value, CiKind kind, boolean mustStayOnStack) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
947 assert value.isLegal() : "value should not be illegal";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
948 assert kind.jvmSlots == value.kind.jvmSlots : "size mismatch";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
949 if (!value.isVariableOrRegister()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
950 // 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
951 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
952 lir.move(value, operand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
953 return operand;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
954 }
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 // create a spill location
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
957 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
958 // move from register to spill
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
959 lir.move(value, operand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
960 return operand;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
961 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
962
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
963 private CiVariable loadConstant(Constant x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
964 return loadConstant(x.asConstant(), x.kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
965 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
966
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
967 protected CiVariable loadConstant(CiConstant c, CiKind kind) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
968 // 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
969 int index = constants.indexOf(c);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
970 if (index != -1) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
971 C1XMetrics.LoadConstantIterations += index;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
972 return variablesForConstants.get(index);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
973 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
974 C1XMetrics.LoadConstantIterations += constants.size();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
975
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
976 CiVariable result = newVariable(kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
977 lir.move(c, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
978 constants.add(c);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
979 variablesForConstants.add(result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
980 return result;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
981 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
982
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
983 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
984 * 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
985 * 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
986 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
987 * @param x an instruction that produces a result
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
988 * @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
989 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
990 protected CiVariable createResultVariable(Value x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
991 CiVariable operand = newVariable(x.kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
992 setResult(x, operand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
993 return operand;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
994 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
995
2519
f6125fb5bfbc Removed intrinsics.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2515
diff changeset
996 @Override
f6125fb5bfbc Removed intrinsics.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2515
diff changeset
997 public void visitRegisterFinalizer(RegisterFinalizer x) {
2628
569228710be8 More FrameState work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2623
diff changeset
998 CiValue receiver = load(x.object());
2669
405e7947a940 Fixed RegisterFinalizer stateBefore.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2661
diff changeset
999 LIRDebugInfo info = stateFor(x, x.stateBefore());
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1000 callRuntime(CiRuntimeCall.RegisterFinalizer, info, receiver);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1001 setNoResult(x);
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
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
1004 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
1005 for (int i = 0; i < x.length; i++) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1006 SwitchRange oneRange = x[i];
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1007 int lowKey = oneRange.lowKey;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1008 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
1009 LIRBlock dest = oneRange.sux;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1010 if (lowKey == highKey) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1011 lir.cmp(Condition.EQ, value, lowKey);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1012 lir.branch(Condition.EQ, CiKind.Int, dest);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1013 } else if (highKey - lowKey == 1) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1014 lir.cmp(Condition.EQ, value, lowKey);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1015 lir.branch(Condition.EQ, CiKind.Int, dest);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1016 lir.cmp(Condition.EQ, value, highKey);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1017 lir.branch(Condition.EQ, CiKind.Int, dest);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1018 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1019 Label l = new Label();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1020 lir.cmp(Condition.LT, value, lowKey);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1021 lir.branch(Condition.LT, l);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1022 lir.cmp(Condition.LE, value, highKey);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1023 lir.branch(Condition.LE, CiKind.Int, dest);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1024 lir.branchDestination(l);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1025 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1026 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1027 lir.jump(defaultSux);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1028 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1029
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1030 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
1031 CiValue leftOp = left;
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 if (isTwoOperand && leftOp != result) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1034 assert right != result : "malformed";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1035 lir.move(leftOp, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1036 leftOp = result;
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
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1039 switch (code) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1040 case DADD:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1041 case FADD:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1042 lir.add(leftOp, right, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1043 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1044 case FMUL:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1045 case DMUL:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1046 lir.mul(leftOp, right, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1047 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1048 case DSUB:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1049 case FSUB:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1050 lir.sub(leftOp, right, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1051 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1052 case FDIV:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1053 case DDIV:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1054 lir.div(leftOp, right, result, null);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1055 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1056 default:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1057 Util.shouldNotReachHere();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1058 }
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 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
1062 CiValue leftOp = left;
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 if (isTwoOperand && leftOp != result) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1065 assert right != result : "malformed";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1066 lir.move(leftOp, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1067 leftOp = result;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1068 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1069
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1070 switch (code) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1071 case IADD:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1072 lir.add(leftOp, right, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1073 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1074 case IMUL:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1075 boolean didStrengthReduce = false;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1076 if (right.isConstant()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1077 CiConstant rightConstant = (CiConstant) right;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1078 int c = rightConstant.asInt();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1079 if (CiUtil.isPowerOf2(c)) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1080 // do not need tmp here
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1081 lir.shiftLeft(leftOp, CiUtil.log2(c), result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1082 didStrengthReduce = true;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1083 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1084 didStrengthReduce = strengthReduceMultiply(leftOp, c, result, tmp);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1085 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1086 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1087 // 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
1088 if (!didStrengthReduce) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1089 lir.mul(leftOp, right, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1090 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1091 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1092 case ISUB:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1093 lir.sub(leftOp, right, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1094 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1095 default:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1096 // idiv and irem are handled elsewhere
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1097 Util.shouldNotReachHere();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1098 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1099 }
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 protected void arithmeticOpLong(int code, CiValue result, CiValue left, CiValue right, LIRDebugInfo info) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1102 CiValue leftOp = left;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1103
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1104 if (isTwoOperand && leftOp != result) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1105 assert right != result : "malformed";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1106 lir.move(leftOp, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1107 leftOp = result;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1108 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1109
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1110 switch (code) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1111 case LADD:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1112 lir.add(leftOp, right, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1113 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1114 case LMUL:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1115 lir.mul(leftOp, right, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1116 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1117 case LSUB:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1118 lir.sub(leftOp, right, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1119 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1120 default:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1121 // ldiv and lrem are handled elsewhere
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1122 Util.shouldNotReachHere();
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
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1126 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
1127 // get a result register
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1128 CiKind result = runtimeCall.resultKind;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1129 CiKind[] arguments = runtimeCall.arguments;
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 CiValue physReg = result.isVoid() ? IllegalValue : resultOperandFor(result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1132
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1133 List<CiValue> argumentList;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1134 if (arguments.length > 0) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1135 // move the arguments into the correct location
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1136 CiCallingConvention cc = compilation.frameMap().getCallingConvention(arguments, RuntimeCall);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1137 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
1138 for (int i = 0; i < args.length; i++) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1139 CiValue arg = args[i];
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1140 CiValue loc = cc.locations[i];
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1141 if (loc.isRegister()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1142 lir.move(arg, loc);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1143 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1144 assert loc.isStackSlot();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1145 CiStackSlot slot = (CiStackSlot) loc;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1146 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
1147 lir.unalignedMove(arg, slot);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1148 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1149 lir.move(arg, slot);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1150 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1151 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1152 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1153 argumentList = Arrays.asList(cc.locations);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1154 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1155 // no arguments
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1156 assert args == null || args.length == 0;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1157 argumentList = Util.uncheckedCast(Collections.emptyList());
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
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1160 lir.callRuntime(runtimeCall, physReg, argumentList, info);
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 return physReg;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1163 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1164
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1165 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
1166 CiVariable result = newVariable(runtimeCall.resultKind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1167 CiValue location = callRuntime(runtimeCall, info, args);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1168 lir.move(location, result);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1169 return result;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1170 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1171
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1172 SwitchRange[] createLookupRanges(LookupSwitch x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1173 // 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
1174 List<SwitchRange> res = new ArrayList<SwitchRange>(x.numberOfCases());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1175 int len = x.numberOfCases();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1176 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
1177 LIRBlock defaultSux = getLIRBlock(x.defaultSuccessor());
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1178 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
1179 LIRBlock sux = getLIRBlock(x.blockSuccessor(0));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1180 SwitchRange range = new SwitchRange(key, sux);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1181 for (int i = 1; i < len; i++) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1182 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
1183 LIRBlock newSux = getLIRBlock(x.blockSuccessor(i));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1184 if (key + 1 == newKey && sux == newSux) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1185 // still in same range
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1186 range.highKey = newKey;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1187 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1188 // skip tests which explicitly dispatch to the default
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1189 if (range.sux != defaultSux) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1190 res.add(range);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1191 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1192 range = new SwitchRange(newKey, newSux);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1193 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1194 key = newKey;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1195 sux = newSux;
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 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
1198 res.add(range);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1199 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1200 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1201 return res.toArray(new SwitchRange[res.size()]);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1202 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1203
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1204 SwitchRange[] createLookupRanges(TableSwitch x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1205 // 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
1206 List<SwitchRange> res = new ArrayList<SwitchRange>(x.numberOfCases());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1207 int len = x.numberOfCases();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1208 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
1209 LIRBlock sux = getLIRBlock(x.blockSuccessor(0));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1210 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
1211 LIRBlock defaultSux = getLIRBlock(x.defaultSuccessor());
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1212 SwitchRange range = new SwitchRange(key, sux);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1213 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
1214 LIRBlock newSux = getLIRBlock(x.blockSuccessor(i));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1215 if (sux == newSux) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1216 // still in same range
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1217 range.highKey = key;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1218 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1219 // skip tests which explicitly dispatch to the default
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1220 if (sux != defaultSux) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1221 res.add(range);
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 range = new SwitchRange(key, newSux);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1224 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1225 sux = newSux;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1226 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1227 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
1228 res.add(range);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1229 }
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 return res.toArray(new SwitchRange[res.size()]);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1232 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1233
2801
2af109bec0c0 Make block contains a list of nodes instead a list of instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2796
diff changeset
1234 void doRoot(Value instr) {
2623
b129b7da1397 Some fixes around LIRGenerator / frame state. New option C1X:TraceLIRGeneratorLevel
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2622
diff changeset
1235 if (C1XOptions.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
1236 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
1237 }
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1238 currentInstruction = instr;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1239
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1240 if (C1XOptions.TraceLIRVisit) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1241 TTY.println("Visiting " + instr);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1242 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1243 instr.accept(this);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1244 if (C1XOptions.TraceLIRVisit) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1245 TTY.println("Operand for " + instr + " = " + instr.operand());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1246 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1247 }
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 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
1250 if (isTwoOperand && leftOp != resultOp) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1251 assert rightOp != resultOp : "malformed";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1252 lir.move(leftOp, resultOp);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1253 leftOp = resultOp;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1254 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1255
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1256 switch (code) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1257 case IAND:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1258 case LAND:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1259 lir.logicalAnd(leftOp, rightOp, resultOp);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1260 break;
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 case IOR:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1263 case LOR:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1264 lir.logicalOr(leftOp, rightOp, resultOp);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1265 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1266
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1267 case IXOR:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1268 case LXOR:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1269 lir.logicalXor(leftOp, rightOp, resultOp);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1270 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1271
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1272 default:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1273 Util.shouldNotReachHere();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1274 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1275 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1276
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
1277 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
1278 // move current value to referenced phi function
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1279 if (suxVal instanceof Phi) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1280 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
1281
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1282 // curVal can be null without phi being null in conjunction with inlining
2546
e1b3db8031ee Removed liveness marking.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2545
diff changeset
1283 if (!phi.isDeadPhi() && 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
1284
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
1285 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
1286 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
1287 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
1288 }
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
1289 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
1290
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1291 assert !phi.isIllegal() : "illegal phi cannot be marked as live";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1292 if (curVal instanceof Phi) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1293 operandForPhi((Phi) curVal);
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 CiValue operand = curVal.operand();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1296 if (operand.isIllegal()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1297 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
1298 operand = operandForInstruction(curVal);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1299 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1300 resolver.move(operand, operandForPhi(phi));
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 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1303 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1304
2768
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1305 private List<Phi> getPhis(LIRBlock block) {
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1306 if (block.getInstructions().size() > 0) {
2806
f35c6f8f0f5d Fixed two regressions due to the flexible scheduling.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2805
diff changeset
1307 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
1308 if (i instanceof Merge) {
2768
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1309 List<Phi> result = new ArrayList<Phi>();
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1310 for (Node n : i.usages()) {
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1311 if (n instanceof Phi) {
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1312 result.add((Phi) n);
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1313 }
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1314 }
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1315 return result;
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1316 }
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1317 }
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1318 return null;
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1319 }
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1320
2778
2ac7b30b7290 Enabled new block finding algorithm.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2775
diff changeset
1321 protected void moveToPhi() {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1322 // Moves all stack values into their phi position
2718
c1ce2a53d6c3 Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2716
diff changeset
1323 LIRBlock bb = currentBlock;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1324 if (bb.numberOfSux() == 1) {
2718
c1ce2a53d6c3 Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2716
diff changeset
1325 LIRBlock sux = bb.suxAt(0);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1326 assert sux.numberOfPreds() > 0 : "invalid CFG";
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 // a block with only one predecessor never has phi functions
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1329 if (sux.numberOfPreds() > 1) {
2768
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1330
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1331
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1332 List<Phi> phis = getPhis(sux);
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
1333
2774
93fd92c9f8b0 Removed usage of stateAfter on BlockEnd instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2772
diff changeset
1334 if (phis != null) {
93fd92c9f8b0 Removed usage of stateAfter on BlockEnd instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2772
diff changeset
1335
93fd92c9f8b0 Removed usage of stateAfter on BlockEnd instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2772
diff changeset
1336 int predIndex = 0;
93fd92c9f8b0 Removed usage of stateAfter on BlockEnd instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2772
diff changeset
1337 for (; predIndex < sux.numberOfPreds(); ++predIndex) {
93fd92c9f8b0 Removed usage of stateAfter on BlockEnd instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2772
diff changeset
1338 if (sux.predAt(predIndex) == bb) {
93fd92c9f8b0 Removed usage of stateAfter on BlockEnd instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2772
diff changeset
1339 break;
93fd92c9f8b0 Removed usage of stateAfter on BlockEnd instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2772
diff changeset
1340 }
2768
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1341 }
2774
93fd92c9f8b0 Removed usage of stateAfter on BlockEnd instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2772
diff changeset
1342 assert predIndex < sux.numberOfPreds();
2768
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1343
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1344 PhiResolver resolver = new PhiResolver(this);
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1345 for (Phi phi : phis) {
2789
aeccd2af4e9e Fixes around critical edge split and placeholder removal after goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2788
diff changeset
1346 if (!phi.isDeadPhi()) {
2768
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1347 Value curVal = phi.valueAt(predIndex);
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
1348 if (curVal != null && curVal != phi) {
2768
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1349 if (curVal instanceof Phi) {
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1350 operandForPhi((Phi) curVal);
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1351 }
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1352 CiValue operand = curVal.operand();
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1353 if (operand.isIllegal()) {
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1354 assert curVal instanceof Constant || curVal instanceof Local : "these can be produced lazily" + curVal + "/" + phi;
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1355 operand = operandForInstruction(curVal);
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1356 }
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1357 resolver.move(operand, operandForPhi(phi));
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1358 }
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1359 }
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1360 }
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1361 resolver.dispose();
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2767
diff changeset
1362 }
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1363 }
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 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1366
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1367 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1368 * Creates a new {@linkplain CiVariable variable}.
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 * @param kind the kind of the variable
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1371 * @return a new variable
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 public CiVariable newVariable(CiKind kind) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1374 return operands.newVariable(kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1375 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1376
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1377 CiValue operandForInstruction(Value x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1378 CiValue operand = x.operand();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1379 if (operand.isIllegal()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1380 if (x instanceof Constant) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1381 x.setOperand(x.asConstant());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1382 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1383 assert x instanceof Phi || x instanceof Local : "only for Phi and Local";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1384 // allocate a variable for this local or phi
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1385 createResultVariable(x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1386 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1387 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1388 return x.operand();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1389 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1390
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1391 private CiValue operandForPhi(Phi phi) {
2532
3fca504f28ba Reinsert phi simplifier (does not seem to be optional). Disabled canonicalizer.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2522
diff changeset
1392 assert !phi.isDeadPhi();
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1393 if (phi.operand().isIllegal()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1394 // allocate a variable for this phi
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1395 CiVariable operand = newVariable(phi.kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1396 setResult(phi, operand);
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 return phi.operand();
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 protected void postGCWriteBarrier(CiValue addr, CiValue newVal) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1402 XirSnippet writeBarrier = xir.genWriteBarrier(toXirArgument(addr));
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1403 if (writeBarrier != null) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1404 emitXir(writeBarrier, null, null, null, false);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1405 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1406 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1407
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1408 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
1409 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1410
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1411 protected void setNoResult(Instruction x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1412 x.clearOperand();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1413 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1414
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1415 protected CiValue setResult(Value x, CiVariable operand) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1416 x.setOperand(operand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1417 if (C1XOptions.DetailedAsserts) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1418 operands.recordResult(operand, x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1419 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1420 return operand;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1421 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1422
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1423 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
1424 if (isTwoOperand && value != resultOp) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1425 assert count != resultOp : "malformed";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1426 lir.move(value, resultOp);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1427 value = resultOp;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1428 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1429
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1430 assert count.isConstant() || count.isVariableOrRegister();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1431 switch (code) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1432 case ISHL:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1433 case LSHL:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1434 lir.shiftLeft(value, count, resultOp, tmp);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1435 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1436 case ISHR:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1437 case LSHR:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1438 lir.shiftRight(value, count, resultOp, tmp);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1439 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1440 case IUSHR:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1441 case LUSHR:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1442 lir.unsignedShiftRight(value, count, resultOp, tmp);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1443 break;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1444 default:
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1445 Util.shouldNotReachHere();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1446 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1447 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1448
2801
2af109bec0c0 Make block contains a list of nodes instead a list of instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2796
diff changeset
1449 protected void walkState(Node x, FrameState state) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1450 if (state == null) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1451 return;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1452 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1453 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
1454 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
1455 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
1456 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
1457 }
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1458 }
2716
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
1459 for (int index = 0; index < state.localsSize(); index++) {
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
1460 final Value value = state.localAt(index);
2564
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2546
diff changeset
1461 if (value != null) {
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2546
diff changeset
1462 if (!value.isIllegal()) {
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2546
diff changeset
1463 walkStateValue(value);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1464 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1465 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1466 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1467 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1468
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1469 private void walkStateValue(Value value) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1470 if (value != null) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1471 if (value instanceof Phi && !value.isIllegal()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1472 // phi's are special
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1473 operandForPhi((Phi) value);
2515
4fdef1464592 Removed extended bytecodes and related HIR instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2509
diff changeset
1474 } else if (value.operand().isIllegal()) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1475 // instruction doesn't have an operand yet
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1476 CiValue operand = makeOperand(value);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1477 assert operand.isLegal() : "must be evaluated now";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1478 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1479 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1480 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1481
2805
c3f64b66fc78 Towards removing the next pointer from Constant and ArithmeticOp
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2801
diff changeset
1482 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
1483 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
1484 return stateFor(x, lastState);
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
2805
c3f64b66fc78 Towards removing the next pointer from Constant and ArithmeticOp
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2801
diff changeset
1487 protected LIRDebugInfo stateFor(Value x, FrameState state) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1488 if (compilation.placeholderState != null) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1489 state = compilation.placeholderState;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1490 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1491
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
1492 assert state != null;
2718
c1ce2a53d6c3 Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2716
diff changeset
1493 LIRBlock exceptionEdge = null;
c1ce2a53d6c3 Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2716
diff changeset
1494 if (x instanceof ExceptionEdgeInstruction) {
2781
bda5972a40a5 remove unnecessary BlockBegin nodes in frontend
Lukas Stadler <lukas.stadler@jku.at>
parents: 2775
diff changeset
1495 Instruction begin = ((ExceptionEdgeInstruction) x).exceptionEdge();
2718
c1ce2a53d6c3 Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2716
diff changeset
1496 if (begin != null) {
2728
7e470e1cd3b6 Removed special casing for exception phis in LIRGenerator. Removed dependency between LIRBlock.blockID and BlockBegin.blockID.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2727
diff changeset
1497 exceptionEdge = getLIRBlock(begin);
2718
c1ce2a53d6c3 Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2716
diff changeset
1498 }
c1ce2a53d6c3 Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2716
diff changeset
1499 }
c1ce2a53d6c3 Attempt to remove dependency between backend and BlockBegin.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2716
diff changeset
1500 return new LIRDebugInfo(state, exceptionEdge);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1501 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1502
2596
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
1503 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
1504 // 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
1505 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
1506 int j = 0;
2596
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
1507 for (int i = 0; i < x.argumentCount(); i++) {
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
1508 Value arg = x.argument(i);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1509 if (arg != null) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1510 CiValue operand = cc.locations[j++];
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1511 if (operand.isRegister()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1512 force(arg, operand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1513 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1514 LIRItem param = new LIRItem(arg, this);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1515 assert operand.isStackSlot();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1516 CiStackSlot slot = (CiStackSlot) operand;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1517 assert !slot.inCallerFrame();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1518 param.loadForStore(slot.kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1519 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
1520 lir.unalignedMove(param.result(), slot);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1521 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1522 lir.move(param.result(), slot);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1523 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1524
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1525 if (arg.kind == CiKind.Object && pointerSlots != null) {
2596
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
1526 // 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
1527 pointerSlots.add(slot);
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 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1530 argList.add(operand);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1531 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1532 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1533 return argList;
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 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1537 * 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
1538 * for storing the result of an instruction.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1539 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1540 * @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
1541 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1542 protected CiValue makeOperand(Value instruction) {
2537
4a016ff4d2df Clean up on LIRGenerator and related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2532
diff changeset
1543 if (instruction == null) {
4a016ff4d2df Clean up on LIRGenerator and related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2532
diff changeset
1544 return CiValue.IllegalValue;
4a016ff4d2df Clean up on LIRGenerator and related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2532
diff changeset
1545 }
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1546 CiValue operand = instruction.operand();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1547 if (operand.isIllegal()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1548 if (instruction instanceof Phi) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1549 // 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
1550 operand = operandForPhi((Phi) instruction);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1551 } else if (instruction instanceof Constant) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1552 operand = operandForInstruction(instruction);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1553 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1554 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1555 // 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
1556 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
1557 return operand;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1558 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1559
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1560 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1561 * 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
1562 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1563 * @param kind the kind of value being returned
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1564 * @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
1565 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1566 protected CiValue resultOperandFor(CiKind kind) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1567 if (kind == CiKind.Void) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1568 return IllegalValue;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1569 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1570 CiRegister returnRegister = compilation.registerConfig.getReturnRegister(kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1571 return returnRegister.asValue(kind);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1572 }
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 protected XirSupport site(Value x) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1575 return xirSupport.site(x);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1576 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1577
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1578 public void maybePrintCurrentInstruction() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1579 if (currentInstruction != null && lastInstructionPrinted != currentInstruction) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1580 lastInstructionPrinted = currentInstruction;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1581 InstructionPrinter ip = new InstructionPrinter(TTY.out());
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1582 ip.printInstructionListing(currentInstruction);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1583 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1584 }
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 protected abstract boolean canInlineAsConstant(Value i);
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 protected abstract boolean canStoreAsConstant(Value i, CiKind kind);
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 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
1591
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1592 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
1593
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1594 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
1595
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1596 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
1597
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1598 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1599 * Implements site-specific information for the XIR interface.
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 static class XirSupport implements XirSite {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1602 Value current;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1603
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1604 XirSupport() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1605 }
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 public CiCodePos getCodePos() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1608 // 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
1609 return null;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1610 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1611
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1612 public boolean isNonNull(XirArgument argument) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1613 if (argument.constant == null && argument.object instanceof LIRItem) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1614 // check the flag on the original value
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1615 return ((LIRItem) argument.object).instruction.isNonNull();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1616 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1617 return false;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1618 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1619
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1620 public boolean requiresNullCheck() {
2661
194d93d089bd Towards clean up of canTrap().
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2660
diff changeset
1621 return current == null || true;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1622 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1623
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1624 public boolean requiresBoundsCheck() {
2541
0f9eeb15e636 More Value.Flag clean up.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2540
diff changeset
1625 return true;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1626 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1627
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1628 public boolean requiresReadBarrier() {
2545
bb050fe2901d Fixed regression wrt write barriers.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2543
diff changeset
1629 return current == null || true;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1630 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1631
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1632 public boolean requiresWriteBarrier() {
2545
bb050fe2901d Fixed regression wrt write barriers.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2543
diff changeset
1633 return current == null || true;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1634 }
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 public boolean requiresArrayStoreCheck() {
2541
0f9eeb15e636 More Value.Flag clean up.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2540
diff changeset
1637 return true;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1638 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1639
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1640 public RiType getApproximateType(XirArgument argument) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1641 return current == null ? null : current.declaredType();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1642 }
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 public RiType getExactType(XirArgument argument) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1645 return current == null ? null : current.exactType();
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 XirSupport site(Value v) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1649 current = v;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1650 return this;
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
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1653 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1654 public String toString() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1655 return "XirSupport<" + current + ">";
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1656 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1657
2633
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2632 2628
diff changeset
1658
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1659 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1660
2630
c93adece95d2 Small clean up.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2623
diff changeset
1661 @Override
c93adece95d2 Small clean up.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2623
diff changeset
1662 public void visitFrameState(FrameState i) {
c93adece95d2 Small clean up.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2623
diff changeset
1663 // nothing to do for now
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1664 }
2707
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
1665
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
1666 @Override
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
1667 public void visitUnwind(Unwind x) {
2784
e62cfea1c134 Simplified fillSyncHandler. Fixed LIRGenerator visitUnwind.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2783
diff changeset
1668 // move exception oop into fixed register
e62cfea1c134 Simplified fillSyncHandler. Fixed LIRGenerator visitUnwind.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2783
diff changeset
1669 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
1670 CiValue argumentOperand = callingConvention.locations[0];
e62cfea1c134 Simplified fillSyncHandler. Fixed LIRGenerator visitUnwind.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2783
diff changeset
1671 lir.move(makeOperand(x.exception()), argumentOperand);
e62cfea1c134 Simplified fillSyncHandler. Fixed LIRGenerator visitUnwind.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2783
diff changeset
1672 List<CiValue> args = new ArrayList<CiValue>(1);
2707
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
1673 lir.callRuntime(CiRuntimeCall.UnwindException, CiValue.IllegalValue, args, null);
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
1674 setNoResult(x);
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
1675 }
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1676 }