annotate graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java @ 7936:c6c72de0537e

Remove setDeoptInfo functionality. Start getting rid of scratch register usages.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 05 Mar 2013 19:20:05 +0100
parents 3362be58312a
children a016a19f3792
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
4181
319860ae697a Simplify FrameMap: make offsets of spill slots and outgoing parameters independent so that they can be allocated at the same time, eliminating the separate phases. This makes the separate StackBlock unnecesary. Change CiStackSlot to use byte offsets instead of spill slot index. This makes CiTarget.spillSlotSize unnecessary.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4142
diff changeset
2 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
23
6532
0c6030872cd0 renamed package: com.oracle.graal.compiler.target.amd64 -> com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6531
diff changeset
24 package com.oracle.graal.compiler.amd64;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
25
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5546
diff changeset
26 import static com.oracle.graal.api.code.ValueUtil.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
27 import static com.oracle.graal.lir.amd64.AMD64Arithmetic.*;
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
28 import static com.oracle.graal.lir.amd64.AMD64BitManipulationOp.IntrinsicOpcode.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
29 import static com.oracle.graal.lir.amd64.AMD64Compare.*;
7280
f368ec89e231 added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents: 7144
diff changeset
30 import static com.oracle.graal.lir.amd64.AMD64MathIntrinsicOp.IntrinsicOpcode.*;
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
31
6580
d56d600819fe moved AMD64 into its own (new) project: com.oracle.graal.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
32 import com.oracle.graal.amd64.*;
5510
426c605c9d3c Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
33 import com.oracle.graal.api.code.*;
7144
ae69cd8c08a9 rename: RuntimeCall -> RuntimeCallTarget
Doug Simon <doug.simon@oracle.com>
parents: 7143
diff changeset
34 import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor;
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5506
diff changeset
35 import com.oracle.graal.api.meta.*;
6531
4afe23aa0a00 renamed packages: com.oracle.max.asm... -> com.oracle.graal.asm...
Doug Simon <doug.simon@oracle.com>
parents: 6525
diff changeset
36 import com.oracle.graal.asm.*;
6675
6eb83c6eb177 change LIRGenerator to take StructuredGraph instead of Graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 6580
diff changeset
37 import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
38 import com.oracle.graal.compiler.gen.*;
5320
e79727f1b3d0 rename: AMD64LIRLowerable -> LIRGenLowerable
Doug Simon <doug.simon@oracle.com>
parents: 5273
diff changeset
39 import com.oracle.graal.compiler.target.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
40 import com.oracle.graal.graph.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
41 import com.oracle.graal.lir.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
42 import com.oracle.graal.lir.StandardOp.JumpOp;
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
43 import com.oracle.graal.lir.amd64.*;
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
44 import com.oracle.graal.lir.amd64.AMD64Arithmetic.BinaryCommutative;
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
45 import com.oracle.graal.lir.amd64.AMD64Arithmetic.BinaryRegConst;
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
46 import com.oracle.graal.lir.amd64.AMD64Arithmetic.BinaryRegReg;
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
47 import com.oracle.graal.lir.amd64.AMD64Arithmetic.BinaryRegStack;
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
48 import com.oracle.graal.lir.amd64.AMD64Arithmetic.BinaryRegStackConst;
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
49 import com.oracle.graal.lir.amd64.AMD64Arithmetic.DivRemOp;
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
50 import com.oracle.graal.lir.amd64.AMD64Arithmetic.Unary1Op;
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
51 import com.oracle.graal.lir.amd64.AMD64Arithmetic.Unary2Op;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
52 import com.oracle.graal.lir.amd64.AMD64Call.DirectCallOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
53 import com.oracle.graal.lir.amd64.AMD64Call.IndirectCallOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
54 import com.oracle.graal.lir.amd64.AMD64Compare.CompareOp;
5798
2585af1e26ac implemented non-XIR lowering of invokes (todo: inline virtual dispatch and null checking of receivers)
Doug Simon <doug.simon@oracle.com>
parents: 5775
diff changeset
55 import com.oracle.graal.lir.amd64.AMD64ControlFlow.BranchOp;
2585af1e26ac implemented non-XIR lowering of invokes (todo: inline virtual dispatch and null checking of receivers)
Doug Simon <doug.simon@oracle.com>
parents: 5775
diff changeset
56 import com.oracle.graal.lir.amd64.AMD64ControlFlow.CondMoveOp;
2585af1e26ac implemented non-XIR lowering of invokes (todo: inline virtual dispatch and null checking of receivers)
Doug Simon <doug.simon@oracle.com>
parents: 5775
diff changeset
57 import com.oracle.graal.lir.amd64.AMD64ControlFlow.FloatBranchOp;
2585af1e26ac implemented non-XIR lowering of invokes (todo: inline virtual dispatch and null checking of receivers)
Doug Simon <doug.simon@oracle.com>
parents: 5775
diff changeset
58 import com.oracle.graal.lir.amd64.AMD64ControlFlow.FloatCondMoveOp;
2585af1e26ac implemented non-XIR lowering of invokes (todo: inline virtual dispatch and null checking of receivers)
Doug Simon <doug.simon@oracle.com>
parents: 5775
diff changeset
59 import com.oracle.graal.lir.amd64.AMD64ControlFlow.ReturnOp;
2585af1e26ac implemented non-XIR lowering of invokes (todo: inline virtual dispatch and null checking of receivers)
Doug Simon <doug.simon@oracle.com>
parents: 5775
diff changeset
60 import com.oracle.graal.lir.amd64.AMD64ControlFlow.SequentialSwitchOp;
2585af1e26ac implemented non-XIR lowering of invokes (todo: inline virtual dispatch and null checking of receivers)
Doug Simon <doug.simon@oracle.com>
parents: 5775
diff changeset
61 import com.oracle.graal.lir.amd64.AMD64ControlFlow.SwitchRangesOp;
2585af1e26ac implemented non-XIR lowering of invokes (todo: inline virtual dispatch and null checking of receivers)
Doug Simon <doug.simon@oracle.com>
parents: 5775
diff changeset
62 import com.oracle.graal.lir.amd64.AMD64ControlFlow.TableSwitchOp;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
63 import com.oracle.graal.lir.amd64.AMD64Move.CompareAndSwapOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
64 import com.oracle.graal.lir.amd64.AMD64Move.LeaOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
65 import com.oracle.graal.lir.amd64.AMD64Move.LoadOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
66 import com.oracle.graal.lir.amd64.AMD64Move.MembarOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
67 import com.oracle.graal.lir.amd64.AMD64Move.MoveFromRegOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
68 import com.oracle.graal.lir.amd64.AMD64Move.MoveToRegOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
69 import com.oracle.graal.lir.amd64.AMD64Move.NullCheckOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
70 import com.oracle.graal.lir.amd64.AMD64Move.SpillMoveOp;
7882
124b28240347 Separate STACK and ADDR nodes in LIR.
Roland Schatz <roland.schatz@oracle.com>
parents: 7880
diff changeset
71 import com.oracle.graal.lir.amd64.AMD64Move.StackLeaOp;
7884
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
72 import com.oracle.graal.lir.amd64.AMD64Move.StoreConstantOp;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
73 import com.oracle.graal.lir.amd64.AMD64Move.StoreOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
74 import com.oracle.graal.nodes.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
75 import com.oracle.graal.nodes.calc.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
76 import com.oracle.graal.nodes.java.*;
6525
2c913b643422 rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents: 6521
diff changeset
77 import com.oracle.graal.phases.util.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
78
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
79 /**
6496
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
80 * This class implements the AMD64 specific portion of the LIR generator.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
81 */
5247
62bbfd78c703 removed mechanism for lowering ExceptionObjectNode via substitution; only LIR lowering by the runtime is now supported
Doug Simon <doug.simon@oracle.com>
parents: 5233
diff changeset
82 public abstract class AMD64LIRGenerator extends LIRGenerator {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
83
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7280
diff changeset
84 public static final Descriptor ARITHMETIC_FREM = new Descriptor("arithmeticFrem", false, float.class, float.class, float.class);
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7280
diff changeset
85 public static final Descriptor ARITHMETIC_DREM = new Descriptor("arithmeticDrem", false, double.class, double.class, double.class);
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents: 6496
diff changeset
86
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5546
diff changeset
87 private static final RegisterValue RAX_I = AMD64.rax.asValue(Kind.Int);
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5546
diff changeset
88 private static final RegisterValue RAX_L = AMD64.rax.asValue(Kind.Long);
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5546
diff changeset
89 private static final RegisterValue RDX_I = AMD64.rdx.asValue(Kind.Int);
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5546
diff changeset
90 private static final RegisterValue RDX_L = AMD64.rdx.asValue(Kind.Long);
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5546
diff changeset
91 private static final RegisterValue RCX_I = AMD64.rcx.asValue(Kind.Int);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
92
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
93 public static class AMD64SpillMoveFactory implements LIR.SpillMoveFactory {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
94
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
95 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
96 public LIRInstruction createMove(Value result, Value input) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
97 return new SpillMoveOp(result, input);
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
98 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
99 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
100
6675
6eb83c6eb177 change LIRGenerator to take StructuredGraph instead of Graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 6580
diff changeset
101 public AMD64LIRGenerator(StructuredGraph graph, CodeCacheProvider runtime, TargetDescription target, FrameMap frameMap, ResolvedJavaMethod method, LIR lir) {
6462
b3f5dc099f9d removed XIR
Doug Simon <doug.simon@oracle.com>
parents: 6409
diff changeset
102 super(graph, runtime, target, frameMap, method, lir);
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
103 lir.spillMoveFactory = new AMD64SpillMoveFactory();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
104 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
105
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
106 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
107 protected void emitNode(ValueNode node) {
5320
e79727f1b3d0 rename: AMD64LIRLowerable -> LIRGenLowerable
Doug Simon <doug.simon@oracle.com>
parents: 5273
diff changeset
108 if (node instanceof LIRGenLowerable) {
e79727f1b3d0 rename: AMD64LIRLowerable -> LIRGenLowerable
Doug Simon <doug.simon@oracle.com>
parents: 5273
diff changeset
109 ((LIRGenLowerable) node).generate(this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
110 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
111 super.emitNode(node);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
112 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
113 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
114
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
115 @Override
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
116 public boolean canStoreConstant(Constant c) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
117 // there is no immediate move of 64-bit constants on Intel
6329
92bc58dc5b5e More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5798
diff changeset
118 switch (c.getKind()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
119 case Long:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
120 return Util.isInt(c.asLong()) && !runtime.needsDataPatch(c);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
121 case Double:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
122 return false;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
123 case Object:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
124 return c.isNull();
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
125 default:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
126 return true;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
127 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
128 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
129
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
130 @Override
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
131 public boolean canInlineConstant(Constant c) {
6329
92bc58dc5b5e More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5798
diff changeset
132 switch (c.getKind()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
133 case Long:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
134 return NumUtil.isInt(c.asLong()) && !runtime.needsDataPatch(c);
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
135 case Object:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
136 return c.isNull();
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
137 default:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
138 return true;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
139 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
140 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
141
4314
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
142 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
143 public Variable emitMove(Value input) {
6329
92bc58dc5b5e More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5798
diff changeset
144 Variable result = newVariable(input.getKind());
7883
cc9b45598a4f Change argument order to be consistent with the rest of the backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7882
diff changeset
145 emitMove(result, input);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
146 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
147 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
148
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
149 @Override
7883
cc9b45598a4f Change argument order to be consistent with the rest of the backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7882
diff changeset
150 public void emitMove(Value dst, Value src) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
151 if (isRegister(src) || isStackSlot(dst)) {
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
152 append(new MoveFromRegOp(dst, src));
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
153 } else {
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
154 append(new MoveToRegOp(dst, src));
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
155 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
156 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
157
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
158 private AMD64Address prepareAddress(Kind kind, Value base, int displacement, Value index, int scale) {
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
159 Value baseRegister = base;
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
160 int finalDisp = displacement;
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
161 if (isConstant(base)) {
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
162 if (asConstant(base).isNull()) {
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
163 baseRegister = Value.ILLEGAL;
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
164 } else if (asConstant(base).getKind() != Kind.Object) {
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
165 long newDisplacement = displacement + asConstant(base).asLong();
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
166 if (NumUtil.isInt(newDisplacement)) {
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
167 assert !runtime.needsDataPatch(asConstant(base));
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
168 finalDisp = (int) newDisplacement;
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
169 baseRegister = Value.ILLEGAL;
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
170 } else {
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
171 Value newBase = newVariable(Kind.Long);
7883
cc9b45598a4f Change argument order to be consistent with the rest of the backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7882
diff changeset
172 emitMove(newBase, base);
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
173 baseRegister = newBase;
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
174 }
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
175 }
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
176 }
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
177
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
178 Value indexRegister = index;
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
179 AMD64Address.Scale scaleEnum;
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
180 if (index != Value.ILLEGAL && scale > 0) {
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
181 scaleEnum = AMD64Address.Scale.fromInt(scale);
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
182 if (isConstant(index)) {
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
183 long newDisplacement = finalDisp + asConstant(index).asLong() * scale;
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
184 // only use the constant index if the resulting displacement fits into a 32 bit
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
185 // offset
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
186 if (NumUtil.isInt(newDisplacement)) {
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
187 finalDisp = (int) newDisplacement;
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
188 indexRegister = Value.ILLEGAL;
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
189 } else {
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
190 // create a temporary variable for the index, the pointer load cannot handle a
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
191 // constant index
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
192 Value newIndex = newVariable(Kind.Long);
7883
cc9b45598a4f Change argument order to be consistent with the rest of the backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7882
diff changeset
193 emitMove(newIndex, index);
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
194 indexRegister = newIndex;
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
195 }
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
196 }
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
197 } else {
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
198 indexRegister = Value.ILLEGAL;
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
199 scaleEnum = AMD64Address.Scale.Times1;
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
200 }
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
201
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
202 return new AMD64Address(kind, baseRegister, indexRegister, scaleEnum, finalDisp);
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
203 }
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
204
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
205 @Override
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
206 public Variable emitLoad(Kind kind, Value base, int displacement, Value index, int scale, boolean canTrap) {
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
207 AMD64Address loadAddress = prepareAddress(kind, base, displacement, index, scale);
6329
92bc58dc5b5e More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5798
diff changeset
208 Variable result = newVariable(loadAddress.getKind());
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
209 append(new LoadOp(result, loadAddress, canTrap ? state() : null));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
210 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
211 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
212
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
213 @Override
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
214 public void emitStore(Kind kind, Value base, int displacement, Value index, int scale, Value inputVal, boolean canTrap) {
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
215 AMD64Address storeAddress = prepareAddress(kind, base, displacement, index, scale);
7884
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
216 LIRFrameState state = canTrap ? state() : null;
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
217
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
218 if (isConstant(inputVal)) {
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
219 Constant c = asConstant(inputVal);
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
220 if (canStoreConstant(c)) {
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
221 append(new StoreConstantOp(storeAddress, c, state));
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
222 return;
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
223 }
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
224 }
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
225
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
226 Variable input = load(inputVal);
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
227 append(new StoreOp(storeAddress, input, state));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
228 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
229
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
230 @Override
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
231 public Variable emitLea(Value base, int displacement, Value index, int scale) {
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
232 Variable result = newVariable(target().wordKind);
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
233 AMD64Address address = prepareAddress(result.getKind(), base, displacement, index, scale);
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
234 append(new LeaOp(result, address));
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
235 return result;
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
236 }
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
237
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
238 @Override
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
239 public Variable emitLea(StackSlot address) {
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
240 Variable result = newVariable(target().wordKind);
7882
124b28240347 Separate STACK and ADDR nodes in LIR.
Roland Schatz <roland.schatz@oracle.com>
parents: 7880
diff changeset
241 append(new StackLeaOp(result, address));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
242 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
243 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
244
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
245 @Override
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5705
diff changeset
246 public void emitJump(LabelRef label, LIRFrameState info) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
247 append(new JumpOp(label, info));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
248 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
249
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
250 @Override
7725
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
251 public void emitCompareBranch(Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef label, LIRFrameState info) {
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
252 boolean mirrored = emitCompare(left, right);
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
253 Condition finalCondition = mirrored ? cond.mirror() : cond;
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
254 switch (left.getKind().getStackKind()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
255 case Int:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
256 case Long:
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
257 case Object:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
258 append(new BranchOp(finalCondition, label, info));
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
259 break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
260 case Float:
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
261 case Double:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
262 append(new FloatBranchOp(finalCondition, unorderedIsTrue, label, info));
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
263 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
264 default:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
265 throw GraalInternalError.shouldNotReachHere("" + left.getKind());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
266 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
267 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
268
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
269 @Override
7725
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
270 public void emitIntegerTestBranch(Value left, Value right, boolean negated, LabelRef label, LIRFrameState info) {
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
271 emitIntegerTest(left, right);
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
272 append(new BranchOp(negated ? Condition.NE : Condition.EQ, label, info));
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
273 }
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
274
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
275 @Override
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
276 public Variable emitConditionalMove(Value left, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue) {
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
277 boolean mirrored = emitCompare(left, right);
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
278 Condition finalCondition = mirrored ? cond.mirror() : cond;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
279
6329
92bc58dc5b5e More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5798
diff changeset
280 Variable result = newVariable(trueValue.getKind());
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
281 switch (left.getKind().getStackKind()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
282 case Int:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
283 case Long:
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
284 case Object:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
285 append(new CondMoveOp(result, finalCondition, load(trueValue), loadNonConst(falseValue)));
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
286 break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
287 case Float:
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
288 case Double:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
289 append(new FloatCondMoveOp(result, finalCondition, unorderedIsTrue, load(trueValue), load(falseValue)));
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
290 break;
7725
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
291 default:
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
292 throw GraalInternalError.shouldNotReachHere("" + left.getKind());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
293 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
294 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
295 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
296
7725
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
297 @Override
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
298 public Variable emitIntegerTestMove(Value left, Value right, Value trueValue, Value falseValue) {
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
299 emitIntegerTest(left, right);
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
300 Variable result = newVariable(trueValue.getKind());
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
301 append(new CondMoveOp(result, Condition.EQ, load(trueValue), loadNonConst(falseValue)));
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
302 return result;
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
303 }
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
304
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
305 private void emitIntegerTest(Value a, Value b) {
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
306 assert a.getKind().getStackKind() == Kind.Int || a.getKind() == Kind.Long;
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
307 if (LIRValueUtil.isVariable(b)) {
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
308 append(new AMD64TestOp(load(b), loadNonConst(a)));
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
309 } else {
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
310 append(new AMD64TestOp(load(a), loadNonConst(b)));
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
311 }
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
312 }
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
313
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
314 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
315 * This method emits the compare instruction, and may reorder the operands. It returns true if
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
316 * it did so.
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
317 *
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
318 * @param a the left operand of the comparison
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
319 * @param b the right operand of the comparison
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
320 * @return true if the left and right operands were switched, false otherwise
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
321 */
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
322 private boolean emitCompare(Value a, Value b) {
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
323 Variable left;
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
324 Value right;
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
325 boolean mirrored;
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5546
diff changeset
326 if (LIRValueUtil.isVariable(b)) {
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
327 left = load(b);
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
328 right = loadNonConst(a);
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
329 mirrored = true;
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
330 } else {
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
331 left = load(a);
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
332 right = loadNonConst(b);
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
333 mirrored = false;
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
334 }
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
335 switch (left.getKind().getStackKind()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
336 case Int:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
337 append(new CompareOp(ICMP, left, right));
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
338 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
339 case Long:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
340 append(new CompareOp(LCMP, left, right));
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
341 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
342 case Object:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
343 append(new CompareOp(ACMP, left, right));
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
344 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
345 case Float:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
346 append(new CompareOp(FCMP, left, right));
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
347 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
348 case Double:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
349 append(new CompareOp(DCMP, left, right));
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
350 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
351 default:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
352 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
353 }
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
354 return mirrored;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
355 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
356
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
357 @Override
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
358 public Variable emitNegate(Value inputVal) {
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
359 AllocatableValue input = asAllocatable(inputVal);
6329
92bc58dc5b5e More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5798
diff changeset
360 Variable result = newVariable(input.getKind());
92bc58dc5b5e More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5798
diff changeset
361 switch (input.getKind()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
362 case Int:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
363 append(new Unary1Op(INEG, result, input));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
364 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
365 case Long:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
366 append(new Unary1Op(LNEG, result, input));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
367 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
368 case Float:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
369 append(new BinaryRegConst(FXOR, result, input, Constant.forFloat(Float.intBitsToFloat(0x80000000))));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
370 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
371 case Double:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
372 append(new BinaryRegConst(DXOR, result, input, Constant.forDouble(Double.longBitsToDouble(0x8000000000000000L))));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
373 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
374 default:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
375 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
376 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
377 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
378 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
379
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
380 private Variable emitBinary(AMD64Arithmetic op, boolean commutative, Value a, Value b) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
381 if (isConstant(b)) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
382 return emitBinaryConst(op, commutative, asAllocatable(a), asConstant(b));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
383 } else if (commutative && isConstant(a)) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
384 return emitBinaryConst(op, commutative, asAllocatable(b), asConstant(a));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
385 } else {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
386 return emitBinaryVar(op, commutative, asAllocatable(a), asAllocatable(b));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
387 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
388 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
389
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
390 private Variable emitBinaryConst(AMD64Arithmetic op, boolean commutative, AllocatableValue a, Constant b) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
391 switch (op) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
392 case IADD:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
393 case LADD:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
394 case ISUB:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
395 case LSUB:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
396 case IAND:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
397 case LAND:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
398 case IOR:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
399 case LOR:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
400 case IXOR:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
401 case LXOR:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
402 if (NumUtil.isInt(b.asLong())) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
403 Variable result = newVariable(a.getKind());
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
404 append(new BinaryRegConst(op, result, a, b));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
405 return result;
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
406 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
407 break;
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
408
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
409 case IMUL:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
410 case LMUL:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
411 if (NumUtil.isInt(b.asLong())) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
412 Variable result = newVariable(a.getKind());
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
413 append(new BinaryRegStackConst(op, result, a, b));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
414 return result;
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
415 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
416 break;
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
417 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
418
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
419 return emitBinaryVar(op, commutative, a, asAllocatable(b));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
420 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
421
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
422 private Variable emitBinaryVar(AMD64Arithmetic op, boolean commutative, AllocatableValue a, AllocatableValue b) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
423 Variable result = newVariable(a.getKind());
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
424 if (commutative) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
425 append(new BinaryCommutative(op, result, a, b));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
426 } else {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
427 append(new BinaryRegStack(op, result, a, b));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
428 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
429 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
430 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
431
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
432 @Override
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
433 public Variable emitAdd(Value a, Value b) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
434 switch (a.getKind()) {
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
435 case Int:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
436 return emitBinary(IADD, true, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
437 case Long:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
438 return emitBinary(LADD, true, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
439 case Float:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
440 return emitBinary(FADD, true, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
441 case Double:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
442 return emitBinary(DADD, true, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
443 default:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
444 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
445 }
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
446 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
447
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
448 @Override
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
449 public Variable emitSub(Value a, Value b) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
450 switch (a.getKind()) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
451 case Int:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
452 return emitBinary(ISUB, false, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
453 case Long:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
454 return emitBinary(LSUB, false, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
455 case Float:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
456 return emitBinary(FSUB, false, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
457 case Double:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
458 return emitBinary(DSUB, false, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
459 default:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
460 throw GraalInternalError.shouldNotReachHere();
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
461 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
462 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
463
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
464 @Override
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
465 public Variable emitMul(Value a, Value b) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
466 switch (a.getKind()) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
467 case Int:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
468 return emitBinary(IMUL, true, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
469 case Long:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
470 return emitBinary(LMUL, true, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
471 case Float:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
472 return emitBinary(FMUL, true, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
473 case Double:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
474 return emitBinary(DMUL, true, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
475 default:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
476 throw GraalInternalError.shouldNotReachHere();
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
477 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
478 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
479
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
480 @Override
7380
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
481 protected boolean peephole(ValueNode valueNode) {
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
482 if ((valueNode instanceof IntegerDivNode) || (valueNode instanceof IntegerRemNode)) {
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
483 FixedBinaryNode divRem = (FixedBinaryNode) valueNode;
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
484 FixedNode node = divRem.next();
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
485 while (node instanceof FixedWithNextNode) {
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
486 FixedWithNextNode fixedWithNextNode = (FixedWithNextNode) node;
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
487 if (((fixedWithNextNode instanceof IntegerDivNode) || (fixedWithNextNode instanceof IntegerRemNode)) && fixedWithNextNode.getClass() != divRem.getClass()) {
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
488 FixedBinaryNode otherDivRem = (FixedBinaryNode) fixedWithNextNode;
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
489 if (otherDivRem.x() == divRem.x() && otherDivRem.y() == divRem.y() && operand(otherDivRem) == null) {
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
490 Value[] results = emitIntegerDivRem(operand(divRem.x()), operand(divRem.y()));
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
491 if (divRem instanceof IntegerDivNode) {
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
492 setResult(divRem, results[0]);
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
493 setResult(otherDivRem, results[1]);
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
494 } else {
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
495 setResult(divRem, results[1]);
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
496 setResult(otherDivRem, results[0]);
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
497 }
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
498 return true;
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
499 }
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
500 }
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
501 node = fixedWithNextNode.next();
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
502 }
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
503 }
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
504 return false;
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
505 }
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
506
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
507 private void emitDivRem(AMD64Arithmetic op, Value a, Value b) {
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
508 AllocatableValue rax = AMD64.rax.asValue(a.getKind());
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
509 emitMove(rax, a);
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
510 append(new DivRemOp(op, rax, asAllocatable(b), state()));
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
511 }
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
512
7380
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
513 public Value[] emitIntegerDivRem(Value a, Value b) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
514 switch (a.getKind()) {
7380
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
515 case Int:
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
516 emitDivRem(IDIVREM, a, b);
7380
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
517 return new Value[]{emitMove(RAX_I), emitMove(RDX_I)};
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
518 case Long:
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
519 emitDivRem(LDIVREM, a, b);
7380
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
520 return new Value[]{emitMove(RAX_L), emitMove(RDX_L)};
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
521 default:
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
522 throw GraalInternalError.shouldNotReachHere();
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
523 }
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
524 }
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
525
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
526 @Override
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
527 public Value emitDiv(Value a, Value b) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
528 switch (a.getKind()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
529 case Int:
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
530 emitDivRem(IDIV, a, b);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
531 return emitMove(RAX_I);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
532 case Long:
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
533 emitDivRem(LDIV, a, b);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
534 return emitMove(RAX_L);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
535 case Float: {
6329
92bc58dc5b5e More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5798
diff changeset
536 Variable result = newVariable(a.getKind());
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
537 append(new BinaryRegStack(FDIV, result, asAllocatable(a), asAllocatable(b)));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
538 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
539 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
540 case Double: {
6329
92bc58dc5b5e More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5798
diff changeset
541 Variable result = newVariable(a.getKind());
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
542 append(new BinaryRegStack(DDIV, result, asAllocatable(a), asAllocatable(b)));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
543 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
544 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
545 default:
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
546 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
547 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
548 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
549
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
550 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
551 public Value emitRem(Value a, Value b) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
552 switch (a.getKind()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
553 case Int:
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
554 emitDivRem(IREM, a, b);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
555 return emitMove(RDX_I);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
556 case Long:
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
557 emitDivRem(LREM, a, b);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
558 return emitMove(RDX_L);
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents: 6496
diff changeset
559 case Float: {
7144
ae69cd8c08a9 rename: RuntimeCall -> RuntimeCallTarget
Doug Simon <doug.simon@oracle.com>
parents: 7143
diff changeset
560 RuntimeCallTarget stub = runtime.lookupRuntimeCall(ARITHMETIC_FREM);
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents: 6496
diff changeset
561 return emitCall(stub, stub.getCallingConvention(), false, a, b);
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents: 6496
diff changeset
562 }
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents: 6496
diff changeset
563 case Double: {
7144
ae69cd8c08a9 rename: RuntimeCall -> RuntimeCallTarget
Doug Simon <doug.simon@oracle.com>
parents: 7143
diff changeset
564 RuntimeCallTarget stub = runtime.lookupRuntimeCall(ARITHMETIC_DREM);
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents: 6496
diff changeset
565 return emitCall(stub, stub.getCallingConvention(), false, a, b);
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents: 6496
diff changeset
566 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
567 default:
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
568 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
569 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
570 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
571
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
572 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
573 public Variable emitUDiv(Value a, Value b) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
574 switch (a.getKind()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
575 case Int:
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
576 emitDivRem(IUDIV, a, b);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
577 return emitMove(RAX_I);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
578 case Long:
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
579 emitDivRem(LUDIV, a, b);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
580 return emitMove(RAX_L);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
581 default:
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
582 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
583 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
584 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
585
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
586 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
587 public Variable emitURem(Value a, Value b) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
588 switch (a.getKind()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
589 case Int:
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
590 emitDivRem(IUREM, a, b);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
591 return emitMove(RDX_I);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
592 case Long:
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
593 emitDivRem(LUREM, a, b);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
594 return emitMove(RDX_L);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
595 default:
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
596 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
597 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
598 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
599
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
600 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
601 public Variable emitAnd(Value a, Value b) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
602 switch (a.getKind()) {
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
603 case Int:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
604 return emitBinary(IAND, true, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
605 case Long:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
606 return emitBinary(LAND, true, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
607 default:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
608 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
609 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
610 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
611
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
612 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
613 public Variable emitOr(Value a, Value b) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
614 switch (a.getKind()) {
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
615 case Int:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
616 return emitBinary(IOR, true, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
617 case Long:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
618 return emitBinary(LOR, true, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
619 default:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
620 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
621 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
622 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
623
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
624 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
625 public Variable emitXor(Value a, Value b) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
626 switch (a.getKind()) {
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
627 case Int:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
628 return emitBinary(IXOR, true, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
629 case Long:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
630 return emitBinary(LXOR, true, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
631 default:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
632 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
633 }
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
634 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
635
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
636 private Variable emitShift(AMD64Arithmetic op, Value a, Value b) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
637 Variable result = newVariable(a.getKind());
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
638 AllocatableValue input = asAllocatable(a);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
639 if (isConstant(b)) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
640 append(new BinaryRegConst(op, result, input, asConstant(b)));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
641 } else {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
642 emitMove(RCX_I, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
643 append(new BinaryRegReg(op, result, input, RCX_I));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
644 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
645 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
646 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
647
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
648 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
649 public Variable emitShl(Value a, Value b) {
6329
92bc58dc5b5e More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5798
diff changeset
650 switch (a.getKind()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
651 case Int:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
652 return emitShift(ISHL, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
653 case Long:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
654 return emitShift(LSHL, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
655 default:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
656 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
657 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
658 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
659
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
660 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
661 public Variable emitShr(Value a, Value b) {
6329
92bc58dc5b5e More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5798
diff changeset
662 switch (a.getKind()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
663 case Int:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
664 return emitShift(ISHR, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
665 case Long:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
666 return emitShift(LSHR, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
667 default:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
668 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
669 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
670 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
671
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
672 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
673 public Variable emitUShr(Value a, Value b) {
6329
92bc58dc5b5e More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5798
diff changeset
674 switch (a.getKind()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
675 case Int:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
676 return emitShift(IUSHR, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
677 case Long:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
678 return emitShift(LUSHR, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
679 default:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
680 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
681 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
682 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
683
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
684 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
685 public Variable emitConvert(ConvertNode.Op opcode, Value inputVal) {
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
686 Variable input = load(inputVal);
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
687 Variable result = newVariable(opcode.to);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
688 switch (opcode) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
689 case I2L:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
690 append(new Unary2Op(I2L, result, input));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
691 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
692 case L2I:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
693 append(new Unary1Op(L2I, result, input));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
694 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
695 case I2B:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
696 append(new Unary2Op(I2B, result, input));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
697 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
698 case I2C:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
699 append(new Unary1Op(I2C, result, input));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
700 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
701 case I2S:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
702 append(new Unary2Op(I2S, result, input));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
703 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
704 case F2D:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
705 append(new Unary2Op(F2D, result, input));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
706 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
707 case D2F:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
708 append(new Unary2Op(D2F, result, input));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
709 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
710 case I2F:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
711 append(new Unary2Op(I2F, result, input));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
712 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
713 case I2D:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
714 append(new Unary2Op(I2D, result, input));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
715 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
716 case F2I:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
717 append(new Unary2Op(F2I, result, input));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
718 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
719 case D2I:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
720 append(new Unary2Op(D2I, result, input));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
721 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
722 case L2F:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
723 append(new Unary2Op(L2F, result, input));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
724 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
725 case L2D:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
726 append(new Unary2Op(L2D, result, input));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
727 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
728 case F2L:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
729 append(new Unary2Op(F2L, result, input));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
730 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
731 case D2L:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
732 append(new Unary2Op(D2L, result, input));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
733 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
734 case MOV_I2F:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
735 append(new Unary2Op(MOV_I2F, result, input));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
736 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
737 case MOV_L2D:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
738 append(new Unary2Op(MOV_L2D, result, input));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
739 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
740 case MOV_F2I:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
741 append(new Unary2Op(MOV_F2I, result, input));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
742 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
743 case MOV_D2L:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
744 append(new Unary2Op(MOV_D2L, result, input));
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
745 break;
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7280
diff changeset
746 case UNSIGNED_I2L:
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
747 // Instructions that move or generate 32-bit register values also set the upper 32
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
748 // bits of the register to zero.
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7280
diff changeset
749 // Consequently, there is no need for a special zero-extension move.
7883
cc9b45598a4f Change argument order to be consistent with the rest of the backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7882
diff changeset
750 emitMove(result, input);
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7280
diff changeset
751 break;
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
752 default:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
753 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
754 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
755 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
756 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
757
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
758 @Override
7936
c6c72de0537e Remove setDeoptInfo functionality. Start getting rid of scratch register usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7927
diff changeset
759 public void emitDeoptimizeOnOverflow(DeoptimizationAction action, DeoptimizationReason reason) {
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5705
diff changeset
760 LIRFrameState info = state();
7936
c6c72de0537e Remove setDeoptInfo functionality. Start getting rid of scratch register usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7927
diff changeset
761 LabelRef stubEntry = createDeoptStub(action, reason, info);
7824
dc497f975c37 Changes in backend due to assembly renamings. Use jccb in two places for smaller code size.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7816
diff changeset
762 append(new BranchOp(ConditionFlag.Overflow, stubEntry, info));
5129
51111665eda6 Support for recording a leaf graph id for each deoptimization point in the debug info.
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
763 }
51111665eda6 Support for recording a leaf graph id for each deoptimization point in the debug info.
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
764
51111665eda6 Support for recording a leaf graph id for each deoptimization point in the debug info.
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
765 @Override
7936
c6c72de0537e Remove setDeoptInfo functionality. Start getting rid of scratch register usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7927
diff changeset
766 public void emitDeoptimize(DeoptimizationAction action, DeoptimizationReason reason) {
7660
0b646334c5f7 keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7650
diff changeset
767 LIRFrameState info = state();
7936
c6c72de0537e Remove setDeoptInfo functionality. Start getting rid of scratch register usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7927
diff changeset
768 LabelRef stubEntry = createDeoptStub(action, reason, info);
5129
51111665eda6 Support for recording a leaf graph id for each deoptimization point in the debug info.
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
769 append(new JumpOp(stubEntry, info));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
770 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
771
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
772 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
773 public void emitMembar(int barriers) {
4260
78379b4203ec remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents: 4245
diff changeset
774 int necessaryBarriers = target.arch.requiredBarriers(barriers);
78379b4203ec remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents: 4245
diff changeset
775 if (target.isMP && necessaryBarriers != 0) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
776 append(new MembarOp(necessaryBarriers));
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
777 }
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
778 }
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
779
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
780 @Override
6478
62878ae057a5 added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents: 6476
diff changeset
781 protected void emitDirectCall(DirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) {
62878ae057a5 added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents: 6476
diff changeset
782 append(new DirectCallOp(callTarget.target(), result, parameters, temps, callState));
6409
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6329
diff changeset
783 }
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6329
diff changeset
784
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6329
diff changeset
785 @Override
6478
62878ae057a5 added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents: 6476
diff changeset
786 protected void emitIndirectCall(IndirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
787 // The current register allocator cannot handle variables at call sites, need a fixed
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
788 // register.
6409
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6329
diff changeset
789 Value targetAddress = AMD64.rax.asValue();
7883
cc9b45598a4f Change argument order to be consistent with the rest of the backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7882
diff changeset
790 emitMove(targetAddress, operand(callTarget.computedAddress()));
6478
62878ae057a5 added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents: 6476
diff changeset
791 append(new IndirectCallOp(callTarget.target(), result, parameters, temps, targetAddress, callState));
6409
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6329
diff changeset
792 }
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6329
diff changeset
793
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6329
diff changeset
794 @Override
7144
ae69cd8c08a9 rename: RuntimeCall -> RuntimeCallTarget
Doug Simon <doug.simon@oracle.com>
parents: 7143
diff changeset
795 protected void emitCall(RuntimeCallTarget callTarget, Value result, Value[] arguments, Value[] temps, Value targetAddress, LIRFrameState info) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
796 if (isConstant(targetAddress)) {
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents: 7121
diff changeset
797 append(new DirectCallOp(callTarget, result, arguments, temps, info));
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
798 } else {
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents: 7121
diff changeset
799 append(new IndirectCallOp(callTarget, result, arguments, temps, targetAddress, info));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
800 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
801 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
802
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
803 @Override
7280
f368ec89e231 added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents: 7144
diff changeset
804 public void emitBitCount(Variable result, Value value) {
f368ec89e231 added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents: 7144
diff changeset
805 if (value.getKind().getStackKind() == Kind.Int) {
7909
afb56ecdb083 Fix usage and operand flags of AMD64BitManipulationOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7884
diff changeset
806 append(new AMD64BitManipulationOp(IPOPCNT, result, asAllocatable(value)));
7280
f368ec89e231 added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents: 7144
diff changeset
807 } else {
7909
afb56ecdb083 Fix usage and operand flags of AMD64BitManipulationOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7884
diff changeset
808 append(new AMD64BitManipulationOp(LPOPCNT, result, asAllocatable(value)));
7280
f368ec89e231 added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents: 7144
diff changeset
809 }
f368ec89e231 added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents: 7144
diff changeset
810 }
f368ec89e231 added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents: 7144
diff changeset
811
f368ec89e231 added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents: 7144
diff changeset
812 @Override
6496
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
813 public void emitBitScanForward(Variable result, Value value) {
7909
afb56ecdb083 Fix usage and operand flags of AMD64BitManipulationOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7884
diff changeset
814 append(new AMD64BitManipulationOp(BSF, result, asAllocatable(value)));
6496
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
815 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
816
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
817 @Override
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
818 public void emitBitScanReverse(Variable result, Value value) {
7098
e23980f4a890 Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7074
diff changeset
819 if (value.getKind().getStackKind() == Kind.Int) {
7909
afb56ecdb083 Fix usage and operand flags of AMD64BitManipulationOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7884
diff changeset
820 append(new AMD64BitManipulationOp(IBSR, result, asAllocatable(value)));
6496
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
821 } else {
7909
afb56ecdb083 Fix usage and operand flags of AMD64BitManipulationOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7884
diff changeset
822 append(new AMD64BitManipulationOp(LBSR, result, asAllocatable(value)));
6496
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
823 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
824 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
825
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
826 @Override
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
827 public void emitMathAbs(Variable result, Variable input) {
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
828 append(new BinaryRegConst(DAND, result, input, Constant.forDouble(Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL))));
6496
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
829 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
830
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
831 @Override
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
832 public void emitMathSqrt(Variable result, Variable input) {
7280
f368ec89e231 added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents: 7144
diff changeset
833 append(new AMD64MathIntrinsicOp(SQRT, result, input));
6496
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
834 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
835
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
836 @Override
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
837 public void emitMathLog(Variable result, Variable input, boolean base10) {
7280
f368ec89e231 added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents: 7144
diff changeset
838 append(new AMD64MathIntrinsicOp(base10 ? LOG10 : LOG, result, input));
6496
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
839 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
840
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
841 @Override
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
842 public void emitMathCos(Variable result, Variable input) {
7280
f368ec89e231 added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents: 7144
diff changeset
843 append(new AMD64MathIntrinsicOp(COS, result, input));
6496
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
844 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
845
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
846 @Override
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
847 public void emitMathSin(Variable result, Variable input) {
7280
f368ec89e231 added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents: 7144
diff changeset
848 append(new AMD64MathIntrinsicOp(SIN, result, input));
6496
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
849 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
850
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
851 @Override
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
852 public void emitMathTan(Variable result, Variable input) {
7280
f368ec89e231 added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents: 7144
diff changeset
853 append(new AMD64MathIntrinsicOp(TAN, result, input));
6496
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
854 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
855
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
856 @Override
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
857 public void emitByteSwap(Variable result, Value input) {
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
858 append(new AMD64ByteSwapOp(result, input));
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
859 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
860
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
861 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
862 protected void emitReturn(Value input) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
863 append(new ReturnOp(input));
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
864 }
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
865
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
866 @Override
5698
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
867 protected void emitSequentialSwitch(Constant[] keyConstants, LabelRef[] keyTargets, LabelRef defaultTarget, Value key) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
868 // Making a copy of the switch value is necessary because jump table destroys the input
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
869 // value
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6675
diff changeset
870 if (key.getKind() == Kind.Int || key.getKind() == Kind.Long) {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
871 append(new SequentialSwitchOp(keyConstants, keyTargets, defaultTarget, key, Value.ILLEGAL));
5698
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
872 } else {
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6675
diff changeset
873 assert key.getKind() == Kind.Object : key.getKind();
5698
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
874 append(new SequentialSwitchOp(keyConstants, keyTargets, defaultTarget, key, newVariable(Kind.Object)));
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
875 }
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
876 }
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
877
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
878 @Override
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
879 protected void emitSwitchRanges(int[] lowKeys, int[] highKeys, LabelRef[] targets, LabelRef defaultTarget, Value key) {
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
880 append(new SwitchRangesOp(lowKeys, highKeys, targets, defaultTarget, key));
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
881 }
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
882
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
883 @Override
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
884 protected void emitTableSwitch(int lowKey, LabelRef defaultTarget, LabelRef[] targets, Value key) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
885 // Making a copy of the switch value is necessary because jump table destroys the input
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
886 // value
5698
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
887 Variable tmp = emitMove(key);
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
888 append(new TableSwitchOp(lowKey, defaultTarget, targets, tmp, newVariable(target.wordKind)));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
889 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
890
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
891 @Override
7936
c6c72de0537e Remove setDeoptInfo functionality. Start getting rid of scratch register usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7927
diff changeset
892 protected LabelRef createDeoptStub(DeoptimizationAction action, DeoptimizationReason reason, LIRFrameState info) {
5552
69a8969dbf40 Reduce public fields in api.code project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5547
diff changeset
893 assert info.topFrame.getBCI() >= 0 : "invalid bci for deopt framestate";
7936
c6c72de0537e Remove setDeoptInfo functionality. Start getting rid of scratch register usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7927
diff changeset
894 AMD64DeoptimizationStub stub = new AMD64DeoptimizationStub(action, reason, info);
5273
7689999f0ea6 improved disassembly comments for out-of-line stubs
Doug Simon <doug.simon@oracle.com>
parents: 5247
diff changeset
895 lir.stubs.add(stub);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
896 return LabelRef.forLabel(stub.label);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
897 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
898
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
899 @Override
7927
3362be58312a Move implicit null check emission to AMD64 specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7920
diff changeset
900 public void emitGuardCheck(LogicNode comp, DeoptimizationReason deoptReason, DeoptimizationAction action, boolean negated) {
3362be58312a Move implicit null check emission to AMD64 specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7920
diff changeset
901 if (comp instanceof IsNullNode && negated) {
3362be58312a Move implicit null check emission to AMD64 specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7920
diff changeset
902 emitNullCheckGuard(((IsNullNode) comp).object());
3362be58312a Move implicit null check emission to AMD64 specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7920
diff changeset
903 } else {
3362be58312a Move implicit null check emission to AMD64 specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7920
diff changeset
904 super.emitGuardCheck(comp, deoptReason, action, negated);
3362be58312a Move implicit null check emission to AMD64 specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7920
diff changeset
905 }
3362be58312a Move implicit null check emission to AMD64 specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7920
diff changeset
906 }
3362be58312a Move implicit null check emission to AMD64 specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7920
diff changeset
907
3362be58312a Move implicit null check emission to AMD64 specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7920
diff changeset
908 private void emitNullCheckGuard(ValueNode object) {
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5406
diff changeset
909 Variable value = load(operand(object));
7660
0b646334c5f7 keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents: 7650
diff changeset
910 LIRFrameState info = state();
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
911 append(new NullCheckOp(value, info));
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
912 }
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
913
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
914 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
915 public void visitCompareAndSwap(CompareAndSwapNode node) {
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5539
diff changeset
916 Kind kind = node.newValue().kind();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
917 assert kind == node.expected().kind();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
918
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
919 Value expected = loadNonConst(operand(node.expected()));
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
920 Variable newValue = load(operand(node.newValue()));
4314
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
921
7880
eb41b39fd1e4 Convert Value fields to Address.
Roland Schatz <roland.schatz@oracle.com>
parents: 7861
diff changeset
922 AMD64Address address;
5187
9b8c0d1bc2dd unsafe load/store snippets now require a displacement argument which allows x86 complex addressing modes to be used for tighter encoding of array store/load operations
Doug Simon <doug.simon@oracle.com>
parents: 5167
diff changeset
923 int displacement = node.displacement();
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
924 Value index = operand(node.offset());
5705
f96e7b39e9fe Be more strict on isInt check in CAS lowering when index is constant
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5698
diff changeset
925 if (isConstant(index) && NumUtil.isInt(asConstant(index).asLong() + displacement)) {
7074
1361501d6bd5 added some more assertions to ensure that metadata constant are not emitted inline
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7073
diff changeset
926 assert !runtime.needsDataPatch(asConstant(index));
5187
9b8c0d1bc2dd unsafe load/store snippets now require a displacement argument which allows x86 complex addressing modes to be used for tighter encoding of array store/load operations
Doug Simon <doug.simon@oracle.com>
parents: 5167
diff changeset
927 displacement += (int) asConstant(index).asLong();
7839
838293a77af7 Make Address class platform specific.
Roland Schatz <roland.schatz@oracle.com>
parents: 7827
diff changeset
928 address = new AMD64Address(kind, load(operand(node.object())), displacement);
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4206
diff changeset
929 } else {
7839
838293a77af7 Make Address class platform specific.
Roland Schatz <roland.schatz@oracle.com>
parents: 7827
diff changeset
930 address = new AMD64Address(kind, load(operand(node.object())), load(index), AMD64Address.Scale.Times1, displacement);
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4206
diff changeset
931 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
932
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5546
diff changeset
933 RegisterValue rax = AMD64.rax.asValue(kind);
7883
cc9b45598a4f Change argument order to be consistent with the rest of the backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7882
diff changeset
934 emitMove(rax, expected);
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
935 append(new CompareAndSwapOp(rax, address, rax, newValue));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
936
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
937 Variable result = newVariable(node.kind());
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
938 append(new CondMoveOp(result, Condition.EQ, load(Constant.TRUE), Constant.FALSE));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
939 setResult(node, result);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
940 }
7121
4aa99b5b158b LIR generation for BreakpointNode is not HotSpot specific and generally useful, so it should not be in HotSpot project
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7098
diff changeset
941
4aa99b5b158b LIR generation for BreakpointNode is not HotSpot specific and generally useful, so it should not be in HotSpot project
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7098
diff changeset
942 @Override
4aa99b5b158b LIR generation for BreakpointNode is not HotSpot specific and generally useful, so it should not be in HotSpot project
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7098
diff changeset
943 public void visitBreakpointNode(BreakpointNode node) {
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7280
diff changeset
944 JavaType[] sig = new JavaType[node.arguments.size()];
7121
4aa99b5b158b LIR generation for BreakpointNode is not HotSpot specific and generally useful, so it should not be in HotSpot project
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7098
diff changeset
945 for (int i = 0; i < sig.length; i++) {
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7280
diff changeset
946 sig[i] = node.arguments.get(i).stamp().javaType(runtime);
7121
4aa99b5b158b LIR generation for BreakpointNode is not HotSpot specific and generally useful, so it should not be in HotSpot project
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7098
diff changeset
947 }
4aa99b5b158b LIR generation for BreakpointNode is not HotSpot specific and generally useful, so it should not be in HotSpot project
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7098
diff changeset
948
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7280
diff changeset
949 CallingConvention cc = frameMap.registerConfig.getCallingConvention(CallingConvention.Type.JavaCall, null, sig, target(), false);
7121
4aa99b5b158b LIR generation for BreakpointNode is not HotSpot specific and generally useful, so it should not be in HotSpot project
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7098
diff changeset
950 Value[] parameters = visitInvokeArguments(cc, node.arguments);
4aa99b5b158b LIR generation for BreakpointNode is not HotSpot specific and generally useful, so it should not be in HotSpot project
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7098
diff changeset
951 append(new AMD64BreakpointOp(parameters));
4aa99b5b158b LIR generation for BreakpointNode is not HotSpot specific and generally useful, so it should not be in HotSpot project
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7098
diff changeset
952 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
953 }