annotate graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64LIRGenerator.java @ 5406:ae759e820ce7

AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
author Lukas Stadler <lukas.stadler@jku.at>
date Tue, 15 May 2012 20:24:52 +0200
parents 80127e4a1742
children 0364a2a874b8
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
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
24 package com.oracle.graal.compiler.target.amd64;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
25
4199
aaac4894175c Renamed cri packages from sun to oracle.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4183
diff changeset
26 import static com.oracle.max.cri.ci.CiValueUtil.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
27 import static com.oracle.graal.lir.amd64.AMD64Arithmetic.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
28 import static com.oracle.graal.lir.amd64.AMD64Compare.*;
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
29
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
30 import java.util.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32 import com.oracle.max.asm.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33 import com.oracle.max.asm.target.amd64.*;
5402
80127e4a1742 remove Condition.OF and Condition.NOF
Lukas Stadler <lukas.stadler@jku.at>
parents: 5369
diff changeset
34 import com.oracle.max.asm.target.amd64.AMD64Assembler.ConditionFlag;
4199
aaac4894175c Renamed cri packages from sun to oracle.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4183
diff changeset
35 import com.oracle.max.cri.ci.*;
4325
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4323
diff changeset
36 import com.oracle.max.cri.ci.CiTargetMethod.Mark;
4265
4643ccd37dac * removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents: 4262
diff changeset
37 import com.oracle.max.cri.ri.*;
4325
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4323
diff changeset
38 import com.oracle.max.cri.xir.CiXirAssembler.XirMark;
4199
aaac4894175c Renamed cri packages from sun to oracle.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4183
diff changeset
39 import com.oracle.max.cri.xir.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
40 import com.oracle.graal.compiler.gen.*;
5320
e79727f1b3d0 rename: AMD64LIRLowerable -> LIRGenLowerable
Doug Simon <doug.simon@oracle.com>
parents: 5273
diff changeset
41 import com.oracle.graal.compiler.target.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
42 import com.oracle.graal.compiler.util.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
43 import com.oracle.graal.graph.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
44 import com.oracle.graal.lir.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
45 import com.oracle.graal.lir.StandardOp.JumpOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
46 import com.oracle.graal.lir.StandardOp.LabelOp;
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
47 import com.oracle.graal.lir.ValueUtil;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
48 import com.oracle.graal.lir.amd64.AMD64Arithmetic.DivOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
49 import com.oracle.graal.lir.amd64.AMD64Arithmetic.Op1Reg;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
50 import com.oracle.graal.lir.amd64.AMD64Arithmetic.Op1Stack;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
51 import com.oracle.graal.lir.amd64.AMD64Arithmetic.Op2Reg;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
52 import com.oracle.graal.lir.amd64.AMD64Arithmetic.Op2Stack;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
53 import com.oracle.graal.lir.amd64.AMD64Arithmetic.ShiftOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
54 import com.oracle.graal.lir.amd64.AMD64Call.DirectCallOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
55 import com.oracle.graal.lir.amd64.AMD64Call.IndirectCallOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
56 import com.oracle.graal.lir.amd64.AMD64Compare.CompareOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
57 import com.oracle.graal.lir.amd64.AMD64ControlFlow.BranchOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
58 import com.oracle.graal.lir.amd64.AMD64ControlFlow.CondMoveOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
59 import com.oracle.graal.lir.amd64.AMD64ControlFlow.FloatBranchOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
60 import com.oracle.graal.lir.amd64.AMD64ControlFlow.FloatCondMoveOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
61 import com.oracle.graal.lir.amd64.AMD64ControlFlow.ReturnOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
62 import com.oracle.graal.lir.amd64.AMD64ControlFlow.TableSwitchOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
63 import com.oracle.graal.lir.amd64.AMD64Move.CompareAndSwapOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
64 import com.oracle.graal.lir.amd64.AMD64Move.LeaOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
65 import com.oracle.graal.lir.amd64.AMD64Move.LoadOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
66 import com.oracle.graal.lir.amd64.AMD64Move.MembarOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
67 import com.oracle.graal.lir.amd64.AMD64Move.MoveFromRegOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
68 import com.oracle.graal.lir.amd64.AMD64Move.MoveToRegOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
69 import com.oracle.graal.lir.amd64.AMD64Move.NullCheckOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
70 import com.oracle.graal.lir.amd64.AMD64Move.SpillMoveOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
71 import com.oracle.graal.lir.amd64.AMD64Move.StoreOp;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
72 import com.oracle.graal.nodes.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
73 import com.oracle.graal.nodes.calc.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
74 import com.oracle.graal.nodes.extended.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
75 import com.oracle.graal.nodes.java.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
76
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
78 * This class implements the X86-specific portion of the LIR generator.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
79 */
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
80 public abstract class AMD64LIRGenerator extends LIRGenerator {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
81
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
82 private static final CiRegisterValue RAX_I = AMD64.rax.asValue(CiKind.Int);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
83 private static final CiRegisterValue RAX_L = AMD64.rax.asValue(CiKind.Long);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
84 private static final CiRegisterValue RDX_I = AMD64.rdx.asValue(CiKind.Int);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
85 private static final CiRegisterValue RDX_L = AMD64.rdx.asValue(CiKind.Long);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
86 private static final CiRegisterValue RCX_I = AMD64.rcx.asValue(CiKind.Int);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
87
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
88 public static class AMD64SpillMoveFactory implements LIR.SpillMoveFactory {
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
89 @Override
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
90 public LIRInstruction createMove(CiValue result, CiValue input) {
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
91 return new SpillMoveOp(result, input);
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
92 }
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
93
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
94 @Override
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
95 public LIRInstruction createExchange(CiValue input1, CiValue input2) {
5056
2f2c6347fce4 comments cleanup/retagging
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4705
diff changeset
96 // TODO (cwimmer) implement XCHG operation for LIR
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
97 return null;
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
5369
2e9a5365dfb0 moved conversion of type profiles into hints for type check instructions from front end to lowering phase
Doug Simon <doug.simon@oracle.com>
parents: 5322
diff changeset
101 public AMD64LIRGenerator(Graph graph, RiRuntime runtime, CiTarget target, FrameMap frameMap, RiResolvedMethod method, LIR lir, RiXirGenerator xir, CiAssumptions assumptions) {
2e9a5365dfb0 moved conversion of type profiles into hints for type check instructions from front end to lowering phase
Doug Simon <doug.simon@oracle.com>
parents: 5322
diff changeset
102 super(graph, runtime, target, frameMap, method, lir, xir, assumptions);
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
116 public boolean canStoreConstant(CiConstant c) {
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
118 switch (c.kind) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
119 case Long: return Util.isInt(c.asLong());
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
120 case Double: return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
121 case Object: return c.isNull();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
122 default: return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
123 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
124 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
125
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
126 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
127 public boolean canInlineConstant(CiConstant c) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
128 switch (c.kind) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
129 case Long: return NumUtil.isInt(c.asLong());
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
130 case Object: return c.isNull();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
131 default: return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
132 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
133 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
134
4314
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
135 @Override
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
136 public CiAddress makeAddress(LocationNode location, ValueNode object) {
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
137 CiValue base = operand(object);
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
138 CiValue index = CiValue.IllegalValue;
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
139 int scale = 1;
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
140 long displacement = location.displacement();
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
141
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
142 if (isConstant(base)) {
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
143 if (!asConstant(base).isNull()) {
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
144 displacement += asConstant(base).asLong();
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
145 }
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
146 base = CiValue.IllegalValue;
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
147 }
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
148
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
149 if (location instanceof IndexedLocationNode) {
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
150 IndexedLocationNode indexedLoc = (IndexedLocationNode) location;
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
151
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
152 index = operand(indexedLoc.index());
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
153 if (indexedLoc.indexScalingEnabled()) {
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
154 scale = target().sizeInBytes(location.getValueKind());
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
155 }
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
156 if (isConstant(index)) {
4705
27397872945f fix "integer overflow when computing constant displacement"
Lukas Stadler <lukas.stadler@jku.at>
parents: 4550
diff changeset
157 long newDisplacement = displacement + asConstant(index).asLong() * scale;
27397872945f fix "integer overflow when computing constant displacement"
Lukas Stadler <lukas.stadler@jku.at>
parents: 4550
diff changeset
158 // only use the constant index if the resulting displacement fits into a 32 bit offset
27397872945f fix "integer overflow when computing constant displacement"
Lukas Stadler <lukas.stadler@jku.at>
parents: 4550
diff changeset
159 if (NumUtil.isInt(newDisplacement)) {
27397872945f fix "integer overflow when computing constant displacement"
Lukas Stadler <lukas.stadler@jku.at>
parents: 4550
diff changeset
160 displacement = newDisplacement;
27397872945f fix "integer overflow when computing constant displacement"
Lukas Stadler <lukas.stadler@jku.at>
parents: 4550
diff changeset
161 index = CiValue.IllegalValue;
27397872945f fix "integer overflow when computing constant displacement"
Lukas Stadler <lukas.stadler@jku.at>
parents: 4550
diff changeset
162 } else {
27397872945f fix "integer overflow when computing constant displacement"
Lukas Stadler <lukas.stadler@jku.at>
parents: 4550
diff changeset
163 // create a temporary variable for the index, the pointer load cannot handle a constant index
27397872945f fix "integer overflow when computing constant displacement"
Lukas Stadler <lukas.stadler@jku.at>
parents: 4550
diff changeset
164 CiValue newIndex = newVariable(CiKind.Long);
27397872945f fix "integer overflow when computing constant displacement"
Lukas Stadler <lukas.stadler@jku.at>
parents: 4550
diff changeset
165 emitMove(index, newIndex);
27397872945f fix "integer overflow when computing constant displacement"
Lukas Stadler <lukas.stadler@jku.at>
parents: 4550
diff changeset
166 index = newIndex;
27397872945f fix "integer overflow when computing constant displacement"
Lukas Stadler <lukas.stadler@jku.at>
parents: 4550
diff changeset
167 }
4314
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
168 }
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
169 }
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
170
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
171 return new CiAddress(location.getValueKind(), base, index, CiAddress.Scale.fromInt(scale), (int) displacement);
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
172 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
173
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
174 @Override
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
175 public Variable emitMove(CiValue input) {
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
176 Variable result = newVariable(input.kind);
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
177 emitMove(input, result);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
178 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
179 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
180
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
181 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
182 public void emitMove(CiValue src, CiValue dst) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
183 if (isRegister(src) || isStackSlot(dst)) {
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
184 append(new MoveFromRegOp(dst, src));
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
185 } else {
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
186 append(new MoveToRegOp(dst, src));
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
187 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
188 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
189
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
190 @Override
4314
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
191 public Variable emitLoad(CiValue loadAddress, boolean canTrap) {
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
192 Variable result = newVariable(loadAddress.kind);
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
193 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
194 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
195 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
196
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
197 @Override
4314
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
198 public void emitStore(CiValue storeAddress, CiValue inputVal, boolean canTrap) {
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
199 CiValue input = loadForStore(inputVal, storeAddress.kind);
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
200 append(new StoreOp(storeAddress, input, canTrap ? state() : null));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
201 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
202
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
203 @Override
4314
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
204 public Variable emitLea(CiValue address) {
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
205 Variable result = newVariable(target().wordKind);
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
206 append(new LeaOp(result, address));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
207 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
208 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
209
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
210 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
211 public void emitLabel(Label label, boolean align) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
212 append(new LabelOp(label, align));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
213 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
214
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
215 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
216 public void emitJump(LabelRef label, LIRDebugInfo info) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
217 append(new JumpOp(label, info));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
218 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
219
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
220 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
221 public void emitBranch(CiValue left, CiValue right, Condition cond, boolean unorderedIsTrue, LabelRef label, LIRDebugInfo info) {
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
222 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
223 Condition finalCondition = mirrored ? cond.mirror() : cond;
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
224 switch (left.kind.stackKind()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
225 case Int:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
226 case Long:
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
227 case Object: append(new BranchOp(finalCondition, label, info)); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
228 case Float:
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
229 case Double: append(new FloatBranchOp(finalCondition, unorderedIsTrue, label, info)); break;
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
230 default: throw GraalInternalError.shouldNotReachHere("" + left.kind);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
231 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
232 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
233
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
234 @Override
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
235 public Variable emitCMove(CiValue left, CiValue right, Condition cond, boolean unorderedIsTrue, CiValue trueValue, CiValue falseValue) {
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
236 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
237 Condition finalCondition = mirrored ? cond.mirror() : cond;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
238
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
239 Variable result = newVariable(trueValue.kind);
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
240 switch (left.kind.stackKind()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
241 case Int:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
242 case Long:
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
243 case Object: append(new CondMoveOp(result, finalCondition, load(trueValue), loadNonConst(falseValue))); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
244 case Float:
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
245 case Double: append(new FloatCondMoveOp(result, finalCondition, unorderedIsTrue, load(trueValue), load(falseValue))); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
246
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
247 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
248 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
249 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
250
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
251 /**
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
252 * This method emits the compare instruction, and may reorder the operands. It returns true if it did so.
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
253 *
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
254 * @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
255 * @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
256 * @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
257 */
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
258 private boolean emitCompare(CiValue a, CiValue b) {
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
259 Variable left;
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
260 CiValue right;
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
261 boolean mirrored;
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
262 if (ValueUtil.isVariable(b)) {
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
263 left = load(b);
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
264 right = loadNonConst(a);
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
265 mirrored = true;
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
266 } else {
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
267 left = load(a);
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
268 right = loadNonConst(b);
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
269 mirrored = false;
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
270 }
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
271 switch (left.kind.stackKind()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
272 case Jsr:
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
273 case Int: append(new CompareOp(ICMP, left, right)); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
274 case Long: append(new CompareOp(LCMP, left, right)); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
275 case Object: append(new CompareOp(ACMP, left, right)); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
276 case Float: append(new CompareOp(FCMP, left, right)); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
277 case Double: append(new CompareOp(DCMP, left, right)); break;
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
278 default: throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
279 }
5406
ae759e820ce7 AMD64LIRGenerator: reorder compare operands to prevent unnecessary loads of constants
Lukas Stadler <lukas.stadler@jku.at>
parents: 5402
diff changeset
280 return mirrored;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
281 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
282
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
283 @Override
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
284 public Variable emitNegate(CiValue input) {
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
285 Variable result = newVariable(input.kind);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
286 switch (input.kind) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
287 case Int: append(new Op1Stack(INEG, result, input)); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
288 case Long: append(new Op1Stack(LNEG, result, input)); break;
4325
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4323
diff changeset
289 case Float: append(new Op2Reg(FXOR, result, input, CiConstant.forFloat(Float.intBitsToFloat(0x80000000)))); break;
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4323
diff changeset
290 case Double: append(new Op2Reg(DXOR, result, input, CiConstant.forDouble(Double.longBitsToDouble(0x8000000000000000L)))); break;
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
291 default: throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
292 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
293 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
294 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
295
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
296 @Override
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
297 public Variable emitAdd(CiValue a, CiValue b) {
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
298 Variable result = newVariable(a.kind);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
299 switch(a.kind) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
300 case Int: append(new Op2Stack(IADD, result, a, loadNonConst(b))); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
301 case Long: append(new Op2Stack(LADD, result, a, loadNonConst(b))); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
302 case Float: append(new Op2Stack(FADD, result, a, loadNonConst(b))); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
303 case Double: append(new Op2Stack(DADD, result, a, loadNonConst(b))); break;
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
304 default: throw GraalInternalError.shouldNotReachHere();
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
309 @Override
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
310 public Variable emitSub(CiValue a, CiValue b) {
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
311 Variable result = newVariable(a.kind);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
312 switch(a.kind) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
313 case Int: append(new Op2Stack(ISUB, result, a, loadNonConst(b))); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
314 case Long: append(new Op2Stack(LSUB, result, a, loadNonConst(b))); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
315 case Float: append(new Op2Stack(FSUB, result, a, loadNonConst(b))); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
316 case Double: append(new Op2Stack(DSUB, result, a, loadNonConst(b))); break;
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
317 default: throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
318 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
319 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
320 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
321
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
322 @Override
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
323 public Variable emitMul(CiValue a, CiValue b) {
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
324 Variable result = newVariable(a.kind);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
325 switch(a.kind) {
4325
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4323
diff changeset
326 case Int: append(new Op2Reg(IMUL, result, a, loadNonConst(b))); break;
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4323
diff changeset
327 case Long: append(new Op2Reg(LMUL, result, a, loadNonConst(b))); break;
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
328 case Float: append(new Op2Stack(FMUL, result, a, loadNonConst(b))); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
329 case Double: append(new Op2Stack(DMUL, result, a, loadNonConst(b))); break;
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
330 default: throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
331 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
332 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
333 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
334
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
335 @Override
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
336 public Variable emitDiv(CiValue a, CiValue b) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
337 switch(a.kind) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
338 case Int:
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
339 emitMove(a, RAX_I);
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
340 append(new DivOp(IDIV, RAX_I, RAX_I, load(b), state()));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
341 return emitMove(RAX_I);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
342 case Long:
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
343 emitMove(a, RAX_L);
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
344 append(new DivOp(LDIV, RAX_L, RAX_L, load(b), state()));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
345 return emitMove(RAX_L);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
346 case Float: {
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
347 Variable result = newVariable(a.kind);
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
348 append(new Op2Stack(FDIV, result, a, loadNonConst(b)));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
349 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
350 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
351 case Double: {
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
352 Variable result = newVariable(a.kind);
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
353 append(new Op2Stack(DDIV, result, a, loadNonConst(b)));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
354 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
355 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
356 default:
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
357 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
358 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
359 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
360
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
361 @Override
5322
7f038eb09d91 rename and generalize: LIRGeneratorTool.emitCallToRuntime(CiRuntimeCall, ...) -> LIRGeneratorTool.emitCall(Object target, CiKind returnKind, CiKind[] parameterKinds, ...)
Doug Simon <doug.simon@oracle.com>
parents: 5320
diff changeset
362 public CiValue emitRem(CiValue a, CiValue b) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
363 switch(a.kind) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
364 case Int:
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
365 emitMove(a, RAX_I);
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
366 append(new DivOp(IREM, RDX_I, RAX_I, load(b), state()));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
367 return emitMove(RDX_I);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
368 case Long:
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
369 emitMove(a, RAX_L);
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
370 append(new DivOp(LREM, RDX_L, RAX_L, load(b), state()));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
371 return emitMove(RDX_L);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
372 case Float:
5322
7f038eb09d91 rename and generalize: LIRGeneratorTool.emitCallToRuntime(CiRuntimeCall, ...) -> LIRGeneratorTool.emitCall(Object target, CiKind returnKind, CiKind[] parameterKinds, ...)
Doug Simon <doug.simon@oracle.com>
parents: 5320
diff changeset
373 return emitCall(CiRuntimeCall.ArithmeticFrem, false, a, b);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
374 case Double:
5322
7f038eb09d91 rename and generalize: LIRGeneratorTool.emitCallToRuntime(CiRuntimeCall, ...) -> LIRGeneratorTool.emitCall(Object target, CiKind returnKind, CiKind[] parameterKinds, ...)
Doug Simon <doug.simon@oracle.com>
parents: 5320
diff changeset
375 return emitCall(CiRuntimeCall.ArithmeticDrem, false, a, b);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
376 default:
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
377 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
378 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
379 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
380
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
381 @Override
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
382 public Variable emitUDiv(CiValue a, CiValue b) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
383 switch(a.kind) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
384 case Int:
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
385 emitMove(a, RAX_I);
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
386 append(new DivOp(IUDIV, RAX_I, RAX_I, load(b), state()));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
387 return emitMove(RAX_I);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
388 case Long:
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
389 emitMove(a, RAX_L);
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
390 append(new DivOp(LUDIV, RAX_L, RAX_L, load(b), state()));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
391 return emitMove(RAX_L);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
392 default:
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
393 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
394 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
395 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
396
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
397 @Override
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
398 public Variable emitURem(CiValue a, CiValue b) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
399 switch(a.kind) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
400 case Int:
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
401 emitMove(a, RAX_I);
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
402 append(new DivOp(IUREM, RDX_I, RAX_I, load(b), state()));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
403 return emitMove(RDX_I);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
404 case Long:
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
405 emitMove(a, RAX_L);
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
406 append(new DivOp(LUREM, RDX_L, RAX_L, load(b), state()));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
407 return emitMove(RDX_L);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
408 default:
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
409 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
410 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
411 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
412
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
413
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
414 @Override
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
415 public Variable emitAnd(CiValue a, CiValue b) {
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
416 Variable result = newVariable(a.kind);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
417 switch(a.kind) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
418 case Int: append(new Op2Stack(IAND, result, a, loadNonConst(b))); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
419 case Long: append(new Op2Stack(LAND, result, a, loadNonConst(b))); break;
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
420 default: throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
421 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
422 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
423 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
424
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
425 @Override
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
426 public Variable emitOr(CiValue a, CiValue b) {
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
427 Variable result = newVariable(a.kind);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
428 switch(a.kind) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
429 case Int: append(new Op2Stack(IOR, result, a, loadNonConst(b))); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
430 case Long: append(new Op2Stack(LOR, result, a, loadNonConst(b))); break;
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
431 default: throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
432 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
433 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
434 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
435
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
436 @Override
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
437 public Variable emitXor(CiValue a, CiValue b) {
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
438 Variable result = newVariable(a.kind);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
439 switch(a.kind) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
440 case Int: append(new Op2Stack(IXOR, result, a, loadNonConst(b))); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
441 case Long: append(new Op2Stack(LXOR, result, a, loadNonConst(b))); break;
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
442 default: throw GraalInternalError.shouldNotReachHere();
3733
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 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
445 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
446
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
447
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
448 @Override
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
449 public Variable emitShl(CiValue a, CiValue b) {
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
450 Variable result = newVariable(a.kind);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
451 switch (a.kind) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
452 case Int: append(new ShiftOp(ISHL, result, a, loadShiftCount(b))); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
453 case Long: append(new ShiftOp(LSHL, result, a, loadShiftCount(b))); break;
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
454 default: GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
455 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
456 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
457 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
458
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
459 @Override
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
460 public Variable emitShr(CiValue a, CiValue b) {
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
461 Variable result = newVariable(a.kind);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
462 switch (a.kind) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
463 case Int: append(new ShiftOp(ISHR, result, a, loadShiftCount(b))); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
464 case Long: append(new ShiftOp(LSHR, result, a, loadShiftCount(b))); break;
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
465 default: GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
466 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
467 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
468 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
469
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
470 @Override
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
471 public Variable emitUShr(CiValue a, CiValue b) {
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
472 Variable result = newVariable(a.kind);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
473 switch (a.kind) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
474 case Int: append(new ShiftOp(IUSHR, result, a, loadShiftCount(b))); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
475 case Long: append(new ShiftOp(LUSHR, result, a, loadShiftCount(b))); break;
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
476 default: GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
477 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
478 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
479 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
480
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
481 private CiValue loadShiftCount(CiValue value) {
4183
9e0c1b4cfef5 Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4181
diff changeset
482 if (isConstant(value)) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
483 return value;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
484 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
485 // Non-constant shift count must be in RCX
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
486 emitMove(value, RCX_I);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
487 return RCX_I;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
488 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
489
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 @Override
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
492 public Variable emitConvert(ConvertNode.Op opcode, CiValue inputVal) {
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
493 Variable input = load(inputVal);
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
494 Variable result = newVariable(opcode.to);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
495 switch (opcode) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
496 case I2L: append(new Op1Reg(I2L, result, input)); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
497 case L2I: append(new Op1Stack(L2I, result, input)); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
498 case I2B: append(new Op1Stack(I2B, result, input)); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
499 case I2C: append(new Op1Stack(I2C, result, input)); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
500 case I2S: append(new Op1Stack(I2S, result, input)); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
501 case F2D: append(new Op1Reg(F2D, result, input)); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
502 case D2F: append(new Op1Reg(D2F, result, input)); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
503 case I2F: append(new Op1Reg(I2F, result, input)); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
504 case I2D: append(new Op1Reg(I2D, result, input)); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
505 case F2I: append(new Op1Reg(F2I, result, input)); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
506 case D2I: append(new Op1Reg(D2I, result, input)); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
507 case L2F: append(new Op1Reg(L2F, result, input)); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
508 case L2D: append(new Op1Reg(L2D, result, input)); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
509 case F2L: append(new Op1Reg(F2L, result, input)); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
510 case D2L: append(new Op1Reg(D2L, result, input)); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
511 case MOV_I2F: append(new Op1Reg(MOV_I2F, result, input)); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
512 case MOV_L2D: append(new Op1Reg(MOV_L2D, result, input)); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
513 case MOV_F2I: append(new Op1Reg(MOV_F2I, result, input)); break;
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
514 case MOV_D2L: append(new Op1Reg(MOV_D2L, result, input)); break;
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4522
diff changeset
515 default: throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
516 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
517 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
518 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
519
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
520
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
521 @Override
5402
80127e4a1742 remove Condition.OF and Condition.NOF
Lukas Stadler <lukas.stadler@jku.at>
parents: 5369
diff changeset
522 public void emitDeoptimizeOnOverflow(RiDeoptAction action, RiDeoptReason reason, Object deoptInfo) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
523 LIRDebugInfo info = state();
5109
6766253384bf more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5105
diff changeset
524 LabelRef stubEntry = createDeoptStub(action, reason, info, deoptInfo);
5402
80127e4a1742 remove Condition.OF and Condition.NOF
Lukas Stadler <lukas.stadler@jku.at>
parents: 5369
diff changeset
525 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
526 }
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
527
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
528
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
529 @Override
5130
Lukas Stadler <lukas.stadler@jku.at>
parents: 5129 5114
diff changeset
530 public void emitDeoptimize(RiDeoptAction action, RiDeoptReason reason, Object deoptInfo, long leafGraphId) {
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
531 LIRDebugInfo info = state(leafGraphId);
5130
Lukas Stadler <lukas.stadler@jku.at>
parents: 5129 5114
diff changeset
532 LabelRef stubEntry = createDeoptStub(action, reason, info, deoptInfo);
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
533 append(new JumpOp(stubEntry, info));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
534 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
535
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
536 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
537 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
538 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
539 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
540 append(new MembarOp(necessaryBarriers));
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
541 }
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
542 }
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
543
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
544 @Override
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
545 protected void emitCall(Object targetMethod, CiValue result, List<CiValue> arguments, CiValue targetAddress, LIRDebugInfo info, Map<XirMark, Mark> marks) {
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
546 if (isConstant(targetAddress)) {
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
547 assert asConstant(targetAddress).isDefaultValue() : "destination address should be zero";
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
548 append(new DirectCallOp(targetMethod, result, arguments.toArray(new CiValue[arguments.size()]), info, marks));
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
549 } else {
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
550 append(new IndirectCallOp(targetMethod, result, arguments.toArray(new CiValue[arguments.size()]), targetAddress, info, marks));
3733
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 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
553
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
554 @Override
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
555 protected void emitReturn(CiValue input) {
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
556 append(new ReturnOp(input));
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
557 }
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
558
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
559 @Override
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
560 protected void emitXir(XirSnippet snippet, CiValue[] operands, CiValue outputOperand, CiValue[] inputs, CiValue[] temps, int[] inputOperandIndices, int[] tempOperandIndices, int outputOperandIndex,
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
561 LIRDebugInfo info, LIRDebugInfo infoAfter, LabelRef trueSuccessor, LabelRef falseSuccessor) {
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
562 append(new AMD64XirOp(snippet, operands, outputOperand, inputs, temps, inputOperandIndices, tempOperandIndices, outputOperandIndex, info, infoAfter, trueSuccessor, falseSuccessor));
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
563 }
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
564
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
565 @Override
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
566 protected void emitTableSwitch(int lowKey, LabelRef defaultTarget, LabelRef[] targets, CiValue index) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
567 // Making a copy of the switch value is necessary because jump table destroys the input value
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
568 Variable tmp = emitMove(index);
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
569 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
570 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
571
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
572 @Override
5114
dad1ac9dba7d finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5110
diff changeset
573 protected LabelRef createDeoptStub(RiDeoptAction action, RiDeoptReason reason, LIRDebugInfo info, Object deoptInfo) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
574 assert info.topFrame.bci >= 0 : "invalid bci for deopt framestate";
5109
6766253384bf more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5105
diff changeset
575 AMD64DeoptimizationStub stub = new AMD64DeoptimizationStub(action, reason, info, deoptInfo);
5273
7689999f0ea6 improved disassembly comments for out-of-line stubs
Doug Simon <doug.simon@oracle.com>
parents: 5247
diff changeset
576 lir.stubs.add(stub);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
577 return LabelRef.forLabel(stub.label);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
578 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
579
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
580 @Override
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
581 protected void emitNullCheckGuard(NullCheckNode node, long leafGraphId) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
582 Variable value = load(operand(node.object()));
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
583 LIRDebugInfo info = state(leafGraphId);
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
584 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
585 }
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
586
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
587 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
588 public void visitCompareAndSwap(CompareAndSwapNode node) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
589 CiKind kind = node.newValue().kind();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
590 assert kind == node.expected().kind();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
591
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
592 CiValue expected = loadNonConst(operand(node.expected()));
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
593 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
594
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
595 CiAddress 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
596 int displacement = node.displacement();
4314
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
597 CiValue index = operand(node.offset());
9ce8594bedaf Allow CiAddress as Input and Alive operands of LIR instructions.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4280
diff changeset
598 if (isConstant(index) && NumUtil.isInt(asConstant(index).asLong())) {
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
599 displacement += (int) asConstant(index).asLong();
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
600 address = new CiAddress(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
601 } else {
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
602 address = new CiAddress(kind, load(operand(node.object())), load(index), CiAddress.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
603 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
604
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
605 CiRegisterValue rax = AMD64.rax.asValue(kind);
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
606 emitMove(expected, rax);
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4314
diff changeset
607 append(new CompareAndSwapOp(rax, address, rax, newValue));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
608
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
609 Variable result = newVariable(node.kind());
5167
591f8231aa82 removed XIR & LIR code for nodes that are completely lowered in HotspotRuntime.lower()
Doug Simon <doug.simon@oracle.com>
parents: 5130
diff changeset
610 append(new CondMoveOp(result, Condition.EQ, load(CiConstant.TRUE), CiConstant.FALSE));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
611 setResult(node, result);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
612 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
613 }