annotate graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java @ 8166:d2733c9b3d0e

Convert AMD64Address to CompositeValue.
author Roland Schatz <roland.schatz@oracle.com>
date Thu, 07 Mar 2013 15:16:19 +0100
parents a016a19f3792
children 7f57c30575c8
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.*;
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
33 import com.oracle.graal.amd64.AMD64Address.Scale;
5510
426c605c9d3c Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
34 import com.oracle.graal.api.code.*;
7144
ae69cd8c08a9 rename: RuntimeCall -> RuntimeCallTarget
Doug Simon <doug.simon@oracle.com>
parents: 7143
diff changeset
35 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
36 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
37 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
38 import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
39 import com.oracle.graal.compiler.gen.*;
5320
e79727f1b3d0 rename: AMD64LIRLowerable -> LIRGenLowerable
Doug Simon <doug.simon@oracle.com>
parents: 5273
diff changeset
40 import com.oracle.graal.compiler.target.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
41 import com.oracle.graal.graph.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
42 import com.oracle.graal.lir.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
43 import com.oracle.graal.lir.StandardOp.JumpOp;
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
44 import com.oracle.graal.lir.amd64.*;
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
45 import com.oracle.graal.lir.amd64.AMD64Arithmetic.BinaryCommutative;
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
46 import com.oracle.graal.lir.amd64.AMD64Arithmetic.BinaryRegConst;
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
47 import com.oracle.graal.lir.amd64.AMD64Arithmetic.BinaryRegReg;
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
48 import com.oracle.graal.lir.amd64.AMD64Arithmetic.BinaryRegStack;
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
49 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
50 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
51 import com.oracle.graal.lir.amd64.AMD64Arithmetic.Unary1Op;
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
52 import com.oracle.graal.lir.amd64.AMD64Arithmetic.Unary2Op;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
53 import com.oracle.graal.lir.amd64.AMD64Call.DirectCallOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
54 import com.oracle.graal.lir.amd64.AMD64Call.IndirectCallOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
55 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
56 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
57 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
58 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
59 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
60 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
61 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
62 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
63 import com.oracle.graal.lir.amd64.AMD64ControlFlow.TableSwitchOp;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
64 import com.oracle.graal.lir.amd64.AMD64Move.CompareAndSwapOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
65 import com.oracle.graal.lir.amd64.AMD64Move.LeaOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
66 import com.oracle.graal.lir.amd64.AMD64Move.LoadOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
67 import com.oracle.graal.lir.amd64.AMD64Move.MembarOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
68 import com.oracle.graal.lir.amd64.AMD64Move.MoveFromRegOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
69 import com.oracle.graal.lir.amd64.AMD64Move.MoveToRegOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
70 import com.oracle.graal.lir.amd64.AMD64Move.NullCheckOp;
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) {
8144
a016a19f3792 Remove SpillMoveOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7936
diff changeset
97 return AMD64LIRGenerator.createMove(result, input);
4323
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
8144
a016a19f3792 Remove SpillMoveOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7936
diff changeset
149 private static AMD64LIRInstruction createMove(Value dst, Value src) {
a016a19f3792 Remove SpillMoveOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7936
diff changeset
150 if (isRegister(src) || isStackSlot(dst)) {
a016a19f3792 Remove SpillMoveOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7936
diff changeset
151 return new MoveFromRegOp(dst, src);
a016a19f3792 Remove SpillMoveOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7936
diff changeset
152 } else {
a016a19f3792 Remove SpillMoveOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7936
diff changeset
153 return new MoveToRegOp(dst, src);
a016a19f3792 Remove SpillMoveOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7936
diff changeset
154 }
a016a19f3792 Remove SpillMoveOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7936
diff changeset
155 }
a016a19f3792 Remove SpillMoveOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7936
diff changeset
156
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
157 @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
158 public void emitMove(Value dst, Value src) {
8144
a016a19f3792 Remove SpillMoveOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7936
diff changeset
159 append(createMove(dst, src));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
160 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
161
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
162 private AMD64AddressValue prepareAddress(Kind kind, Value base, int displacement, Value index, int scale) {
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
163 AllocatableValue baseRegister;
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
164 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
165 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
166 if (asConstant(base).isNull()) {
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
167 baseRegister = AllocatableValue.UNUSED;
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
168 } 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
169 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
170 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
171 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
172 finalDisp = (int) newDisplacement;
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
173 baseRegister = AllocatableValue.UNUSED;
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
174 } else {
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
175 Variable 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
176 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
177 baseRegister = newBase;
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
178 }
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
179 } else {
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
180 baseRegister = load(base);
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
181 }
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
182 } else if (base == Value.ILLEGAL) {
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
183 baseRegister = AllocatableValue.UNUSED;
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
184 } else {
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
185 baseRegister = asAllocatable(base);
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
186 }
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
187
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
188 AllocatableValue indexRegister;
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
189 Scale scaleEnum;
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
190 if (index != Value.ILLEGAL && scale != 0) {
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
191 scaleEnum = Scale.fromInt(scale);
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
192 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
193 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
194 // 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
195 // offset
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
196 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
197 finalDisp = (int) newDisplacement;
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
198 indexRegister = AllocatableValue.UNUSED;
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
199 } else {
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
200 // 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
201 // constant index
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
202 Variable 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
203 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
204 indexRegister = newIndex;
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
205 }
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
206 } else {
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
207 indexRegister = asAllocatable(index);
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
208 }
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
209 } else {
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
210 indexRegister = AllocatableValue.UNUSED;
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
211 scaleEnum = Scale.Times1;
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
212 }
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
213
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
214 return new AMD64AddressValue(kind, baseRegister, indexRegister, scaleEnum, finalDisp);
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
215 }
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
216
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
217 @Override
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
218 public Variable emitLoad(Kind kind, Value base, int displacement, Value index, int scale, boolean canTrap) {
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
219 AMD64AddressValue 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
220 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
221 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
222 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
223 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
224
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
225 @Override
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
226 public void emitStore(Kind kind, Value base, int displacement, Value index, int scale, Value inputVal, boolean canTrap) {
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
227 AMD64AddressValue 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
228 LIRFrameState state = canTrap ? state() : null;
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
229
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
230 if (isConstant(inputVal)) {
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
231 Constant c = asConstant(inputVal);
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
232 if (canStoreConstant(c)) {
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
233 append(new StoreConstantOp(storeAddress, c, state));
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
234 return;
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
235 }
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
236 }
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
237
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
238 Variable input = load(inputVal);
14b52a260099 Separate store op for storing constants.
Roland Schatz <roland.schatz@oracle.com>
parents: 7883
diff changeset
239 append(new StoreOp(storeAddress, input, state));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
240 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
241
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
242 @Override
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
243 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
244 Variable result = newVariable(target().wordKind);
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
245 AMD64AddressValue address = prepareAddress(result.getKind(), base, displacement, index, scale);
7861
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
246 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
247 return result;
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
248 }
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
249
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
250 @Override
c6d003891de0 Get rid of all direct usages of Address outside of backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7839
diff changeset
251 public Variable emitLea(StackSlot address) {
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
252 Variable result = newVariable(target().wordKind);
7882
124b28240347 Separate STACK and ADDR nodes in LIR.
Roland Schatz <roland.schatz@oracle.com>
parents: 7880
diff changeset
253 append(new StackLeaOp(result, address));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
254 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
255 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
256
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
257 @Override
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5705
diff changeset
258 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
259 append(new JumpOp(label, info));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
260 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
261
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
262 @Override
7725
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
263 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
264 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
265 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
266 switch (left.getKind().getStackKind()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
267 case Int:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
268 case Long:
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
269 case Object:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
270 append(new BranchOp(finalCondition, label, info));
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
271 break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
272 case Float:
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
273 case Double:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
274 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
275 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
276 default:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
277 throw GraalInternalError.shouldNotReachHere("" + left.getKind());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
278 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
279 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
280
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
281 @Override
7725
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
282 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
283 emitIntegerTest(left, right);
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
284 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
285 }
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
286
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
287 @Override
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
288 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
289 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
290 Condition finalCondition = mirrored ? cond.mirror() : cond;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
291
6329
92bc58dc5b5e More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5798
diff changeset
292 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
293 switch (left.getKind().getStackKind()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
294 case Int:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
295 case Long:
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
296 case Object:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
297 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
298 break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
299 case Float:
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
300 case Double:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
301 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
302 break;
7725
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
303 default:
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
304 throw GraalInternalError.shouldNotReachHere("" + left.getKind());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
305 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
306 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
307 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
308
7725
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
309 @Override
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
310 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
311 emitIntegerTest(left, right);
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
312 Variable result = newVariable(trueValue.getKind());
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
313 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
314 return result;
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
315 }
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
316
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
317 private void emitIntegerTest(Value a, Value b) {
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
318 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
319 if (LIRValueUtil.isVariable(b)) {
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
320 append(new AMD64TestOp(load(b), loadNonConst(a)));
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
321 } else {
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
322 append(new AMD64TestOp(load(a), loadNonConst(b)));
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
323 }
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
324 }
301cff1a99d1 backend support for integer test operation
Lukas Stadler <lukas.stadler@jku.at>
parents: 7660
diff changeset
325
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
326 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
327 * 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
328 * it did so.
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
329 *
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
330 * @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
331 * @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
332 * @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
333 */
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
334 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
335 Variable left;
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
336 Value right;
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
337 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
338 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
339 left = load(b);
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
340 right = loadNonConst(a);
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
341 mirrored = true;
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
342 } else {
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
343 left = load(a);
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
344 right = loadNonConst(b);
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
345 mirrored = false;
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
346 }
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
347 switch (left.getKind().getStackKind()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
348 case Int:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
349 append(new CompareOp(ICMP, 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 case Long:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
352 append(new CompareOp(LCMP, left, right));
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
353 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
354 case Object:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
355 append(new CompareOp(ACMP, left, right));
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
356 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
357 case Float:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
358 append(new CompareOp(FCMP, left, right));
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
359 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
360 case Double:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
361 append(new CompareOp(DCMP, left, right));
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
362 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
363 default:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
364 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
365 }
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
366 return mirrored;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
367 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
368
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
369 @Override
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
370 public Variable emitNegate(Value inputVal) {
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
371 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
372 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
373 switch (input.getKind()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
374 case Int:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
375 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
376 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
377 case Long:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
378 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
379 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
380 case Float:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
381 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
382 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
383 case Double:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
384 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
385 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
386 default:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
387 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
388 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
389 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
390 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
391
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
392 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
393 if (isConstant(b)) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
394 return emitBinaryConst(op, commutative, asAllocatable(a), asConstant(b));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
395 } else if (commutative && isConstant(a)) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
396 return emitBinaryConst(op, commutative, asAllocatable(b), asConstant(a));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
397 } else {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
398 return emitBinaryVar(op, commutative, asAllocatable(a), asAllocatable(b));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
399 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
400 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
401
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
402 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
403 switch (op) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
404 case IADD:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
405 case LADD:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
406 case ISUB:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
407 case LSUB:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
408 case IAND:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
409 case LAND:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
410 case IOR:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
411 case LOR:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
412 case IXOR:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
413 case LXOR:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
414 if (NumUtil.isInt(b.asLong())) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
415 Variable result = newVariable(a.getKind());
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
416 append(new BinaryRegConst(op, result, a, b));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
417 return result;
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
418 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
419 break;
7919
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 case IMUL:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
422 case LMUL:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
423 if (NumUtil.isInt(b.asLong())) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
424 Variable result = newVariable(a.getKind());
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
425 append(new BinaryRegStackConst(op, result, a, b));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
426 return result;
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
427 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
428 break;
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
429 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
430
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
431 return emitBinaryVar(op, commutative, a, asAllocatable(b));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
432 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
433
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
434 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
435 Variable result = newVariable(a.getKind());
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
436 if (commutative) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
437 append(new BinaryCommutative(op, result, a, b));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
438 } else {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
439 append(new BinaryRegStack(op, result, a, b));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
440 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
441 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
442 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
443
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
444 @Override
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
445 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
446 switch (a.getKind()) {
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
447 case Int:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
448 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
449 case Long:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
450 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
451 case Float:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
452 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
453 case Double:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
454 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
455 default:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
456 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
457 }
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
458 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
459
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
460 @Override
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
461 public Variable emitSub(Value a, Value b) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
462 switch (a.getKind()) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
463 case Int:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
464 return emitBinary(ISUB, false, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
465 case Long:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
466 return emitBinary(LSUB, false, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
467 case Float:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
468 return emitBinary(FSUB, false, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
469 case Double:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
470 return emitBinary(DSUB, false, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
471 default:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
472 throw GraalInternalError.shouldNotReachHere();
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
473 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
474 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
475
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
476 @Override
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
477 public Variable emitMul(Value a, Value b) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
478 switch (a.getKind()) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
479 case Int:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
480 return emitBinary(IMUL, true, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
481 case Long:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
482 return emitBinary(LMUL, true, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
483 case Float:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
484 return emitBinary(FMUL, true, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
485 case Double:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
486 return emitBinary(DMUL, true, a, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
487 default:
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
488 throw GraalInternalError.shouldNotReachHere();
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
489 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
490 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
491
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
492 @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
493 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
494 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
495 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
496 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
497 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
498 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
499 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
500 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
501 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
502 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
503 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
504 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
505 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
506 } else {
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
507 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
508 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
509 }
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
510 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
511 }
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
512 }
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
513 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
514 }
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
515 }
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
516 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
517 }
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
518
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
519 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
520 AllocatableValue rax = AMD64.rax.asValue(a.getKind());
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
521 emitMove(rax, a);
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
522 append(new DivRemOp(op, rax, asAllocatable(b), state()));
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
523 }
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
524
7380
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
525 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
526 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
527 case Int:
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
528 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
529 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
530 case Long:
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
531 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
532 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
533 default:
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
534 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
535 }
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
536 }
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
537
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
538 @Override
3207ee96b659 Added possibility for platform-specific peephole optimizations. Added combining div/rem optimization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7328
diff changeset
539 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
540 switch (a.getKind()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
541 case Int:
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
542 emitDivRem(IDIV, a, b);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
543 return emitMove(RAX_I);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
544 case Long:
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
545 emitDivRem(LDIV, a, b);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
546 return emitMove(RAX_L);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
547 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
548 Variable result = newVariable(a.getKind());
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
549 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
550 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
551 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
552 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
553 Variable result = newVariable(a.getKind());
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
554 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
555 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
556 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
557 default:
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
558 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
559 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
560 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
561
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
562 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
563 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
564 switch (a.getKind()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
565 case Int:
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
566 emitDivRem(IREM, a, b);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
567 return emitMove(RDX_I);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
568 case Long:
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
569 emitDivRem(LREM, a, b);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
570 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
571 case Float: {
7144
ae69cd8c08a9 rename: RuntimeCall -> RuntimeCallTarget
Doug Simon <doug.simon@oracle.com>
parents: 7143
diff changeset
572 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
573 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
574 }
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
575 case Double: {
7144
ae69cd8c08a9 rename: RuntimeCall -> RuntimeCallTarget
Doug Simon <doug.simon@oracle.com>
parents: 7143
diff changeset
576 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
577 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
578 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
579 default:
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
580 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
581 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
582 }
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 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
585 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
586 switch (a.getKind()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
587 case Int:
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
588 emitDivRem(IUDIV, a, b);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
589 return emitMove(RAX_I);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
590 case Long:
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
591 emitDivRem(LUDIV, a, b);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
592 return emitMove(RAX_L);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
593 default:
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
594 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
595 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
596 }
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 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
599 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
600 switch (a.getKind()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
601 case Int:
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
602 emitDivRem(IUREM, a, b);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
603 return emitMove(RDX_I);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
604 case Long:
7920
2e3e4b691835 Remove duplicate code in DivOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7919
diff changeset
605 emitDivRem(LUREM, a, b);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
606 return emitMove(RDX_L);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
607 default:
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
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 emitAnd(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(IAND, 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(LAND, 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 emitOr(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(IOR, 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(LOR, 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 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
634 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
635
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
636 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
637 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
638 switch (a.getKind()) {
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
639 case Int:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
640 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
641 case Long:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
642 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
643 default:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
644 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
645 }
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
646 }
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
647
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
648 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
649 Variable result = newVariable(a.getKind());
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
650 AllocatableValue input = asAllocatable(a);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
651 if (isConstant(b)) {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
652 append(new BinaryRegConst(op, result, input, asConstant(b)));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
653 } else {
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
654 emitMove(RCX_I, b);
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
655 append(new BinaryRegReg(op, result, input, RCX_I));
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
656 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
657 return result;
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 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
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(ISHL, 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(LSHL, 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 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
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(ISHR, 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(LSHR, 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 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
686 switch (a.getKind()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
687 case Int:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
688 return emitShift(IUSHR, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
689 case Long:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
690 return emitShift(LUSHR, a, b);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
691 default:
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
692 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
693 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
694 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
695
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
696 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
697 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
698 Variable input = load(inputVal);
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
699 Variable result = newVariable(opcode.to);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
700 switch (opcode) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
701 case I2L:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
702 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
703 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
704 case L2I:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
705 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
706 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
707 case I2B:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
708 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
709 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
710 case I2C:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
711 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
712 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
713 case I2S:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
714 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
715 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
716 case F2D:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
717 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
718 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
719 case D2F:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
720 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
721 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
722 case I2F:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
723 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
724 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
725 case I2D:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
726 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
727 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
728 case F2I:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
729 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
730 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
731 case D2I:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
732 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
733 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
734 case L2F:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
735 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
736 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
737 case L2D:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
738 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
739 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
740 case F2L:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
741 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
742 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
743 case D2L:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
744 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
745 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
746 case MOV_I2F:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
747 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
748 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
749 case MOV_L2D:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
750 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
751 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
752 case MOV_F2I:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
753 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
754 break;
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
755 case MOV_D2L:
7910
748cb57f53cb Cleanup Op1 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7909
diff changeset
756 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
757 break;
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7280
diff changeset
758 case UNSIGNED_I2L:
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
759 // 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
760 // bits of the register to zero.
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7280
diff changeset
761 // 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
762 emitMove(result, input);
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7280
diff changeset
763 break;
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
764 default:
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7380
diff changeset
765 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
766 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
767 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
768 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
769
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
770 @Override
7936
c6c72de0537e Remove setDeoptInfo functionality. Start getting rid of scratch register usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7927
diff changeset
771 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
772 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
773 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
774 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
775 }
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
776
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
777 @Override
7936
c6c72de0537e Remove setDeoptInfo functionality. Start getting rid of scratch register usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7927
diff changeset
778 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
779 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
780 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
781 append(new JumpOp(stubEntry, info));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
782 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
783
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
784 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
785 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
786 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
787 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
788 append(new MembarOp(necessaryBarriers));
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
789 }
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
790 }
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
791
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
792 @Override
6478
62878ae057a5 added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents: 6476
diff changeset
793 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
794 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
795 }
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6329
diff changeset
796
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6329
diff changeset
797 @Override
6478
62878ae057a5 added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents: 6476
diff changeset
798 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
799 // 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
800 // register.
6409
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6329
diff changeset
801 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
802 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
803 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
804 }
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6329
diff changeset
805
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6329
diff changeset
806 @Override
7144
ae69cd8c08a9 rename: RuntimeCall -> RuntimeCallTarget
Doug Simon <doug.simon@oracle.com>
parents: 7143
diff changeset
807 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
808 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
809 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
810 } 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
811 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
812 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
813 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
814
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
815 @Override
7280
f368ec89e231 added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents: 7144
diff changeset
816 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
817 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
818 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
819 } else {
7909
afb56ecdb083 Fix usage and operand flags of AMD64BitManipulationOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7884
diff changeset
820 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
821 }
f368ec89e231 added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents: 7144
diff changeset
822 }
f368ec89e231 added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents: 7144
diff changeset
823
f368ec89e231 added intrinsifications for Integer.bitCount() and Long.bitCount()
Doug Simon <doug.simon@oracle.com>
parents: 7144
diff changeset
824 @Override
6496
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
825 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
826 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
827 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
828
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
829 @Override
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
830 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
831 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
832 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
833 } else {
7909
afb56ecdb083 Fix usage and operand flags of AMD64BitManipulationOp.
Roland Schatz <roland.schatz@oracle.com>
parents: 7884
diff changeset
834 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
835 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
836 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
837
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
838 @Override
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
839 public void emitMathAbs(Variable result, Variable input) {
7919
0ae70d44ec9a Restructure Op2 in AMD64 backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 7910
diff changeset
840 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
841 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
842
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
843 @Override
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
844 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
845 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
846 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
847
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
848 @Override
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
849 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
850 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
851 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
852
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
853 @Override
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
854 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
855 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
856 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
857
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
858 @Override
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
859 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
860 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
861 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
862
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
863 @Override
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
864 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
865 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
866 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
867
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
868 @Override
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
869 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
870 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
871 }
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
872
16d1411409b4 moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents: 6493
diff changeset
873 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
874 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
875 append(new ReturnOp(input));
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
876 }
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
877
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
878 @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
879 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
880 // 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
881 // value
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6675
diff changeset
882 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
883 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
884 } else {
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6675
diff changeset
885 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
886 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
887 }
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
888 }
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
889
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
890 @Override
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
891 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
892 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
893 }
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
894
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
895 @Override
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5667
diff changeset
896 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
897 // 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
898 // 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
899 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
900 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
901 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
902
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
903 @Override
7936
c6c72de0537e Remove setDeoptInfo functionality. Start getting rid of scratch register usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7927
diff changeset
904 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
905 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
906 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
907 lir.stubs.add(stub);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
908 return LabelRef.forLabel(stub.label);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
909 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
910
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
911 @Override
7927
3362be58312a Move implicit null check emission to AMD64 specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7920
diff changeset
912 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
913 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
914 emitNullCheckGuard(((IsNullNode) comp).object());
3362be58312a Move implicit null check emission to AMD64 specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7920
diff changeset
915 } else {
3362be58312a Move implicit null check emission to AMD64 specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7920
diff changeset
916 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
917 }
3362be58312a Move implicit null check emission to AMD64 specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7920
diff changeset
918 }
3362be58312a Move implicit null check emission to AMD64 specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7920
diff changeset
919
3362be58312a Move implicit null check emission to AMD64 specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7920
diff changeset
920 private void emitNullCheckGuard(ValueNode object) {
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5406
diff changeset
921 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
922 LIRFrameState info = state();
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
923 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
924 }
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
925
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
926 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
927 public void visitCompareAndSwap(CompareAndSwapNode node) {
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5539
diff changeset
928 Kind kind = node.newValue().kind();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
929 assert kind == node.expected().kind();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
930
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
931 Value expected = loadNonConst(operand(node.expected()));
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
932 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
933
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
934 AMD64AddressValue 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
935 int displacement = node.displacement();
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
936 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
937 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
938 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
939 displacement += (int) asConstant(index).asLong();
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
940 address = new AMD64AddressValue(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
941 } else {
8166
d2733c9b3d0e Convert AMD64Address to CompositeValue.
Roland Schatz <roland.schatz@oracle.com>
parents: 8144
diff changeset
942 address = new AMD64AddressValue(kind, load(operand(node.object())), load(index), 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
943 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
944
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5546
diff changeset
945 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
946 emitMove(rax, expected);
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
947 append(new CompareAndSwapOp(rax, address, rax, newValue));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
948
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
949 Variable result = newVariable(node.kind());
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
950 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
951 setResult(node, result);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
952 }
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
953
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
954 @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
955 public void visitBreakpointNode(BreakpointNode node) {
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7280
diff changeset
956 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
957 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
958 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
959 }
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
960
7300
2912b72d840a More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7280
diff changeset
961 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
962 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
963 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
964 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
965 }